diff options
author | ByteHamster <info@bytehamster.com> | 2020-03-18 20:21:47 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-03-19 21:22:44 +0100 |
commit | 260bb8f5ccca9136a1520443252ad352f3d0b6ac (patch) | |
tree | d6773bdc682303b009a9808d3c7a09260a4c267e | |
parent | 2026b3dd226faa79b881f4d47cc584734453c632 (diff) | |
download | AntennaPod-260bb8f5ccca9136a1520443252ad352f3d0b6ac.zip |
Updated tests
4 files changed, 16 insertions, 6 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java b/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java index 6ae14a58e..d32a6b382 100644 --- a/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java +++ b/app/src/androidTest/java/de/test/antennapod/EspressoTestUtils.java @@ -20,6 +20,7 @@ import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.storage.PodDBAdapter; import de.danoeh.antennapod.dialog.RatingDialog; +import de.danoeh.antennapod.fragment.NavDrawerFragment; import org.awaitility.Awaitility; import org.awaitility.core.ConditionTimeoutException; import org.hamcrest.Matcher; @@ -132,9 +133,10 @@ public class EspressoTestUtils { } public static void setLastNavFragment(String tag) { - InstrumentationRegistry.getTargetContext().getSharedPreferences(MainActivity.PREF_NAME, Context.MODE_PRIVATE) + InstrumentationRegistry.getTargetContext().getSharedPreferences( + NavDrawerFragment.PREF_NAME, Context.MODE_PRIVATE) .edit() - .putString(MainActivity.PREF_LAST_FRAGMENT_TAG, tag) + .putString(NavDrawerFragment.PREF_LAST_FRAGMENT_TAG, tag) .commit(); } diff --git a/app/src/androidTest/java/de/test/antennapod/ui/MainActivityTest.java b/app/src/androidTest/java/de/test/antennapod/ui/MainActivityTest.java index d0b2cb4b4..72e4c29d9 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/MainActivityTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/MainActivityTest.java @@ -99,6 +99,7 @@ public class MainActivityTest { solo.goBackToActivity(MainActivity.class.getSimpleName()); solo.goBack(); + solo.goBack(); assertEquals(solo.getString(R.string.subscriptions_label), getActionbarTitle()); } @@ -111,6 +112,7 @@ public class MainActivityTest { onView(withText(R.string.back_button_open_drawer)).perform(click()); solo.goBackToActivity(MainActivity.class.getSimpleName()); solo.goBack(); + solo.goBack(); assertTrue(((MainActivity)solo.getCurrentActivity()).isDrawerOpen()); } @@ -124,6 +126,7 @@ public class MainActivityTest { solo.goBackToActivity(MainActivity.class.getSimpleName()); solo.goBack(); solo.goBack(); + solo.goBack(); assertThat(mActivityRule.getActivityResult(), hasResultCode(Activity.RESULT_CANCELED)); } @@ -136,6 +139,7 @@ public class MainActivityTest { onView(withText(R.string.back_button_show_prompt)).perform(click()); solo.goBackToActivity(MainActivity.class.getSimpleName()); solo.goBack(); + solo.goBack(); onView(withText(R.string.yes)).perform(click()); Thread.sleep(100); assertThat(mActivityRule.getActivityResult(), hasResultCode(Activity.RESULT_CANCELED)); @@ -150,6 +154,7 @@ public class MainActivityTest { onView(withText(R.string.back_button_default)).perform(click()); solo.goBackToActivity(MainActivity.class.getSimpleName()); solo.goBack(); + solo.goBack(); assertThat(mActivityRule.getActivityResult(), hasResultCode(Activity.RESULT_CANCELED)); } } diff --git a/app/src/androidTest/java/de/test/antennapod/ui/NavigationDrawerTest.java b/app/src/androidTest/java/de/test/antennapod/ui/NavigationDrawerTest.java index e7fbbcb89..86b167db2 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/NavigationDrawerTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/NavigationDrawerTest.java @@ -12,6 +12,7 @@ import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.fragment.DownloadsFragment; import de.danoeh.antennapod.fragment.EpisodesFragment; +import de.danoeh.antennapod.fragment.NavDrawerFragment; import de.danoeh.antennapod.fragment.PlaybackHistoryFragment; import de.danoeh.antennapod.fragment.QueueFragment; import de.test.antennapod.EspressoTestUtils; @@ -26,7 +27,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static androidx.test.espresso.Espresso.onData; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.longClick; @@ -194,7 +194,7 @@ public class NavigationDrawerTest { List<String> hidden = UserPreferences.getHiddenDrawerItems(); assertEquals(titles.length, hidden.size()); - for (String tag : MainActivity.NAV_DRAWER_TAGS) { + for (String tag : NavDrawerFragment.NAV_DRAWER_TAGS) { assertTrue(hidden.contains(tag)); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java index 0c8e5d8db..b3492d79c 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java @@ -16,6 +16,7 @@ import android.widget.AdapterView; import android.widget.ListView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import de.danoeh.antennapod.R; @@ -48,8 +49,10 @@ import java.util.List; public class NavDrawerFragment extends Fragment implements AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener { - private static final String PREF_LAST_FRAGMENT_TAG = "prefLastFragmentTag"; - private static final String PREF_NAME = "NavDrawerPrefs"; + @VisibleForTesting + public static final String PREF_LAST_FRAGMENT_TAG = "prefLastFragmentTag"; + @VisibleForTesting + public static final String PREF_NAME = "NavDrawerPrefs"; public static final String TAG = "NavDrawerFragment"; public static final String[] NAV_DRAWER_TAGS = { |