summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/de/test
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/androidTest/java/de/test')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java48
1 files changed, 33 insertions, 15 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java
index b3c2ee2be..a27089726 100644
--- a/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/ui/PlaybackTest.java
@@ -7,7 +7,9 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.test.ActivityInstrumentationTestCase2;
import android.test.FlakyTest;
+import android.view.View;
import android.widget.ImageButton;
+import android.widget.ListView;
import com.robotium.solo.Solo;
import com.robotium.solo.Timeout;
@@ -33,6 +35,8 @@ import de.danoeh.antennapod.core.util.playback.PlaybackController;
public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity> {
private static final String TAG = PlaybackTest.class.getSimpleName();
+ public static final int EPISODES_DRAWER_LIST_INDEX = 1;
+ public static final int QUEUE_DRAWER_LIST_INDEX = 0;
private Solo solo;
private UITestUtils uiTestUtils;
@@ -141,12 +145,20 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
PodDBAdapter.deleteDatabase();
+ context = getInstrumentation().getTargetContext();
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ prefs.edit()
+ .clear()
+ .putBoolean(UserPreferences.PREF_UNPAUSE_ON_HEADSET_RECONNECT, false)
+ .putBoolean(UserPreferences.PREF_PAUSE_ON_HEADSET_DISCONNECT, false)
+ .commit();
+
controller = createController(getActivity());
controller.init();
solo = new Solo(getInstrumentation(), getActivity());
- context = getInstrumentation().getTargetContext();
uiTestUtils = new UITestUtils(context);
uiTestUtils.setup();
@@ -154,13 +166,6 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.close();
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- prefs.edit()
- .clear()
- .putBoolean(UserPreferences.PREF_UNPAUSE_ON_HEADSET_RECONNECT, false)
- .putBoolean(UserPreferences.PREF_PAUSE_ON_HEADSET_DISCONNECT, false)
- .commit();
}
@Override
@@ -191,12 +196,18 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
}
private void startLocalPlayback() {
- String allEpisodesLabel = solo.getString(R.string.all_episodes_label);
- if(!getActivity().getSupportActionBar().getTitle().equals(allEpisodesLabel)) {
- openNavDrawer();
- solo.clickOnText(solo.getString(R.string.episodes_label));
- solo.clickOnText(solo.getString(R.string.all_episodes_short_label));
- }
+ openNavDrawer();
+ // if we try to just click on plain old text then
+ // we might wind up clicking on the fragment title and not
+ // the drawer element like we want.
+ ListView drawerView = (ListView)solo.getView(R.id.nav_list);
+ // this should be 'Episodes'
+ View targetView = drawerView.getChildAt(EPISODES_DRAWER_LIST_INDEX);
+ solo.waitForView(targetView);
+ solo.clickOnView(targetView);
+ solo.waitForText(solo.getString(R.string.all_episodes_short_label));
+ solo.clickOnText(solo.getString(R.string.all_episodes_short_label));
+
final List<FeedItem> episodes = DBReader.getRecentlyPublishedEpisodes(10);
assertTrue(solo.waitForView(solo.getView(R.id.butSecondaryAction)));
@@ -215,7 +226,14 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
private void startLocalPlaybackFromQueue() {
openNavDrawer();
- solo.clickOnText(solo.getString(R.string.queue_label));
+ // if we try to just click on plain old text then
+ // we might wind up clicking on the fragment title and not
+ // the drawer element like we want.
+ ListView drawerView = (ListView)solo.getView(R.id.nav_list);
+ // this should be 'Queue'
+ View targetView = drawerView.getChildAt(QUEUE_DRAWER_LIST_INDEX);
+ solo.waitForView(targetView);
+ solo.clickOnView(targetView);
assertTrue(solo.waitForView(solo.getView(R.id.butSecondaryAction)));
final List<FeedItem> queue = DBReader.getQueue();