Add a method to check whether the Google Play Services update dialog is shown.

This commit is contained in:
youtaol
2012-11-07 15:54:16 +08:00
parent 326684d01c
commit 3da337b91b
@@ -125,6 +125,7 @@ public class EndToEndTestUtils {
static boolean isEmulator = true; static boolean isEmulator = true;
static boolean hasGpsSingal = true; static boolean hasGpsSingal = true;
static boolean isCheckedFirstLaunch = false; static boolean isCheckedFirstLaunch = false;
static boolean isGooglePlayServicesLatest = true;
public static final String LOG_TAG = "MyTracksTest"; public static final String LOG_TAG = "MyTracksTest";
private EndToEndTestUtils() {} private EndToEndTestUtils() {}
@@ -229,6 +230,13 @@ public class EndToEndTestUtils {
isEmulator = android.os.Build.MODEL.equals("google_sdk"); isEmulator = android.os.Build.MODEL.equals("google_sdk");
} }
/**
* Checks whether the Google Play Services need update.
*/
private static boolean isGooglePlayServicesLatest() {
return !SOLO.searchText(activityMytracks.getString(R.string.common_google_play_services_update_text));
}
/** /**
* A setup for debugging end-to-end tests. * A setup for debugging end-to-end tests.
* *
@@ -254,9 +262,21 @@ public class EndToEndTestUtils {
EndToEndTestUtils.activityMytracks = activityMyTracks; EndToEndTestUtils.activityMytracks = activityMyTracks;
SOLO = new Solo(EndToEndTestUtils.instrumentation, EndToEndTestUtils.activityMytracks); SOLO = new Solo(EndToEndTestUtils.instrumentation, EndToEndTestUtils.activityMytracks);
if (!isGooglePlayServicesLatest) {
SOLO.finishOpenedActivities();
Assert.fail();
Log.e(LOG_TAG, "Need update Google Play Services");
}
// 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) {
isGooglePlayServicesLatest = isGooglePlayServicesLatest();
if (!isGooglePlayServicesLatest) {
SOLO.finishOpenedActivities();
Assert.fail();
Log.e(LOG_TAG, "Need update Google Play Services");
}
setIsEmulator(); setIsEmulator();
if ((getButtonOnScreen(EndToEndTestUtils.activityMytracks.getString(R.string.eula_accept), if ((getButtonOnScreen(EndToEndTestUtils.activityMytracks.getString(R.string.eula_accept),
false, false) != null)) { false, false) != null)) {
@@ -281,9 +301,9 @@ public class EndToEndTestUtils {
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