forked from upstream-mirrors/OpenTracks
Add a new method setupForDebug() in EndToEndTestUtils.
This commit is contained in:
+32
-26
@@ -94,11 +94,6 @@ public class EndToEndTestUtils {
|
||||
public static int LONG_WAIT_TIME = 15000;
|
||||
public static int SUPER_LONG_WAIT_TIME = 100000;
|
||||
|
||||
/**
|
||||
* During debug, sets it to false to make debug is more efficient.
|
||||
*/
|
||||
public static boolean clearEnvironment = true;
|
||||
|
||||
public static String deviceLanguage = "";
|
||||
|
||||
static {
|
||||
@@ -234,24 +229,37 @@ public class EndToEndTestUtils {
|
||||
isEmulator = android.os.Build.MODEL.equals("google_sdk");
|
||||
}
|
||||
|
||||
/**
|
||||
* A setup for debugging end-to-end tests.
|
||||
*
|
||||
* @param instrumentation the instrumentation is used for test
|
||||
* @param activityMyTracks the startup activity
|
||||
*/
|
||||
public static void setupForDebug(Instrumentation instrumentation,
|
||||
TrackListActivity activityMyTracks) {
|
||||
EndToEndTestUtils.instrumentation = instrumentation;
|
||||
EndToEndTestUtils.activityMytracks = activityMyTracks;
|
||||
SOLO = new Solo(EndToEndTestUtils.instrumentation, EndToEndTestUtils.activityMytracks);
|
||||
}
|
||||
|
||||
/**
|
||||
* A setup for all end-to-end tests.
|
||||
*
|
||||
* @param instrumentation the instrumentation is used for test
|
||||
* @param activityMyTracks the startup activity
|
||||
*/
|
||||
public static void setupForAllTest(Instrumentation instrumentation, TrackListActivity activityMyTracks) {
|
||||
public static void setupForAllTest(Instrumentation instrumentation,
|
||||
TrackListActivity activityMyTracks) {
|
||||
EndToEndTestUtils.instrumentation = instrumentation;
|
||||
EndToEndTestUtils.activityMytracks = activityMyTracks;
|
||||
SOLO = new Solo(EndToEndTestUtils.instrumentation,
|
||||
EndToEndTestUtils.activityMytracks);
|
||||
|
||||
SOLO = new Solo(EndToEndTestUtils.instrumentation, EndToEndTestUtils.activityMytracks);
|
||||
|
||||
// Check if open MyTracks first time after install. If so, there would be a
|
||||
// welcome view with accept buttons. And makes sure only check once.
|
||||
if (!isCheckedFirstLaunch) {
|
||||
setIsEmulator();
|
||||
if ((getButtonOnScreen(EndToEndTestUtils.activityMytracks
|
||||
.getString(R.string.eula_accept), false, false) != null)) {
|
||||
if ((getButtonOnScreen(EndToEndTestUtils.activityMytracks.getString(R.string.eula_accept),
|
||||
false, false) != null)) {
|
||||
verifyFirstLaunch();
|
||||
} else if (SOLO.waitForText(
|
||||
// After reset setting, welcome page will show again.
|
||||
@@ -261,23 +269,21 @@ public class EndToEndTestUtils {
|
||||
hasActionBar = setHasActionBar();
|
||||
checkLanguage();
|
||||
isCheckedFirstLaunch = true;
|
||||
if (clearEnvironment) {
|
||||
deleteAllTracks();
|
||||
resetAllSettings(activityMyTracks, false);
|
||||
|
||||
instrumentation.waitForIdleSync();
|
||||
// Check the status of real phone. For emulator, we would fix GPS signal.
|
||||
if(!isEmulator) {
|
||||
GoToMyLocationTest.findAndClickMyLocation(activityMyTracks);
|
||||
hasGpsSingal = !SOLO.waitForText(NO_GPS_MESSAGE_PREFIX, 1,
|
||||
EndToEndTestUtils.SHORT_WAIT_TIME);
|
||||
SOLO.goBack();
|
||||
}
|
||||
} else if (SOLO.waitForText(
|
||||
// After reset setting, welcome page will show again.
|
||||
deleteAllTracks();
|
||||
resetAllSettings(activityMyTracks, false);
|
||||
|
||||
instrumentation.waitForIdleSync();
|
||||
// Check the status of real phone. For emulator, we would fix GPS signal.
|
||||
if (!isEmulator) {
|
||||
GoToMyLocationTest.findAndClickMyLocation(activityMyTracks);
|
||||
hasGpsSingal = !SOLO.waitForText(NO_GPS_MESSAGE_PREFIX, 1,
|
||||
EndToEndTestUtils.SHORT_WAIT_TIME);
|
||||
SOLO.goBack();
|
||||
}
|
||||
} else if (SOLO.waitForText(
|
||||
// After reset setting, welcome page will show again.
|
||||
activityMytracks.getString(R.string.welcome_title), 0, SHORT_WAIT_TIME)) {
|
||||
resetPreferredUnits();
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether is under recording. If previous test failed, the recording
|
||||
|
||||
@@ -48,7 +48,6 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
super.setUp();
|
||||
instrumentation = getInstrumentation();
|
||||
activityMyTracks = getActivity();
|
||||
EndToEndTestUtils.clearEnvironment = false;
|
||||
EndToEndTestUtils.setupForAllTest(instrumentation, activityMyTracks);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user