Fix tests

This commit is contained in:
Martin Fietz 2015-12-01 19:02:49 +01:00
parent 2ad94d582e
commit f82ced9dc3
3 changed files with 10 additions and 13 deletions

View File

@ -51,6 +51,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
adapter.close();
// override first launch preference
// do this BEFORE calling getActivity()!
prefs = getInstrumentation().getTargetContext().getSharedPreferences(MainActivity.PREF_NAME, Context.MODE_PRIVATE);
prefs.edit().putBoolean(MainActivity.PREF_IS_FIRST_LAUNCH, false).commit();
@ -71,7 +72,8 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
}
private void openNavDrawer() {
solo.clickOnScreen(50, 50);
solo.clickOnImageButton(0);
getInstrumentation().waitForIdleSync();
}
public void testAddFeed() throws Exception {
@ -125,7 +127,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
assertEquals(solo.getString(R.string.add_feed_label), getActionbarTitle());
// podcasts
ListView list = (ListView)solo.getView(R.id.nav_list);
ListView list = (ListView) solo.getView(R.id.nav_list);
for (int i = 0; i < uiTestUtils.hostedFeeds.size(); i++) {
Feed f = uiTestUtils.hostedFeeds.get(i);
solo.clickOnScreen(50, 50); // open nav drawer
@ -137,7 +139,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
}
private String getActionbarTitle() {
return ((MainActivity)solo.getCurrentActivity()).getSupportActionBar().getTitle().toString();
return ((MainActivity) solo.getCurrentActivity()).getSupportActionBar().getTitle().toString();
}
@FlakyTest(tolerance = 3)
@ -185,14 +187,14 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
openNavDrawer();
solo.clickLongOnText(solo.getString(R.string.queue_label));
solo.waitForDialogToOpen();
for(String title : titles) {
for (String title : titles) {
solo.clickOnText(title);
}
solo.clickOnText(solo.getString(R.string.confirm_label));
solo.waitForDialogToClose();
List<String> hidden = UserPreferences.getHiddenDrawerItems();
assertEquals(titles.length, hidden.size());
for(String tag : MainActivity.NAV_DRAWER_TAGS) {
for (String tag : MainActivity.NAV_DRAWER_TAGS) {
assertTrue(hidden.contains(tag));
}
}

View File

@ -1,7 +1,6 @@
package de.test.antennapod.ui;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -10,7 +9,6 @@ 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;
@ -21,15 +19,12 @@ import java.util.List;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.playback.Playable;
import de.danoeh.antennapod.core.util.playback.PlaybackController;
/**
* test cases for starting and ending playback from the MainActivity and AudioPlayerActivity
@ -90,7 +85,7 @@ public class PlaybackSonicTest extends ActivityInstrumentationTestCase2<MainActi
}
private void openNavDrawer() {
solo.clickOnScreen(50, 50);
solo.clickOnImageButton(0);
getInstrumentation().waitForIdleSync();
}

View File

@ -79,9 +79,9 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
super.tearDown();
}
private void openNavDrawer() {
solo.clickOnScreen(50, 50);
solo.clickOnImageButton(0);
getInstrumentation().waitForIdleSync();
}
private void setContinuousPlaybackPreference(boolean value) {