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