mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-24 16:02:13 +01:00
Updated tests
This commit is contained in:
parent
2026b3dd22
commit
260bb8f5cc
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user