Upgrade to robotium 5.0.1

This commit is contained in:
Jimmy Shih
2014-01-22 11:19:09 -08:00
parent 974d7434d7
commit 18cd3d49fa
5 changed files with 88 additions and 54 deletions
Binary file not shown.
Binary file not shown.
@@ -21,7 +21,7 @@ import com.google.android.apps.mytracks.TrackListActivity;
import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
import com.jayway.android.robotium.solo.Solo;
import com.robotium.solo.Solo;
import android.annotation.SuppressLint;
import android.app.Activity;
@@ -107,26 +107,26 @@ public class EndToEndTestUtils {
public static String trackDesc;
static {
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("es", "mins ago");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("en", "mins ago");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("de", "Minuten");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("fr", "minute");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("ar", "دقيقة");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("zh", "分钟前");
KM_MULTILINGUAL.put("es", "km");
KM_MULTILINGUAL.put("en", "km");
KM_MULTILINGUAL.put("de", "km");
KM_MULTILINGUAL.put("fr", "km");
KM_MULTILINGUAL.put("ar", "كم");
KM_MULTILINGUAL.put("zh", "公里");
MILE_MULTILINGUAL.put("es", "mi");
MILE_MULTILINGUAL.put("en", "mi");
MILE_MULTILINGUAL.put("de", "mi");
MILE_MULTILINGUAL.put("fr", "mile");
MILE_MULTILINGUAL.put("ar", "ميل");
MILE_MULTILINGUAL.put("zh", "英里");
}
public static Solo SOLO;
public static com.robotium.solo.Solo SOLO;
public static Instrumentation instrumentation;
public static TrackListActivity activityMytracks;
@@ -343,11 +343,6 @@ public class EndToEndTestUtils {
if ((getButtonOnScreen(activityMytracks.getString(R.string.eula_accept), false, false) != null)) {
getButtonOnScreen(activityMytracks.getString(R.string.eula_accept), true, true);
}
if (SOLO.waitForText(activityMytracks.getString(R.string.sync_drive_confirm_title))) {
// Click for Sync with Google Drive(Don't enable sync as default).
getButtonOnScreen(activityMytracks.getString(R.string.generic_no), true, true);
instrumentation.waitForIdleSync();
}
}
/**
@@ -844,7 +839,7 @@ public class EndToEndTestUtils {
*/
public static void resetAllSettings(Activity activityMyTracks, boolean keepInSettingList) {
findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_advanced));
Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset)));
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset));
getButtonOnScreen(activityMytracks.getString(R.string.generic_yes), true, true);
@@ -28,9 +28,9 @@ public class RunConfiguration {
* Set to false as default. True to run the test. Default to false since this
* test can take a long time.
*/
public static boolean runStressTest = true;
public static boolean runResourceUsageTest = true;
public static boolean runSensorTest = true;
public static boolean runStressTest = false;
public static boolean runResourceUsageTest = false;
public static boolean runSensorTest = false;
public boolean runSyncTest = false;
private RunConfiguration() {
@@ -50,7 +50,7 @@ public class RunConfiguration {
* @return true means can run sync tests in this device
*/
public static boolean canRunSyncTest() {
return true;
return false;
// EndToEndTestUtils.findMenuItem(
// EndToEndTestUtils.activityMytracks.getString(R.string.menu_settings), true);
// EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.activityMytracks
@@ -50,95 +50,134 @@ public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListA
* Tests editing a track.
*/
public void testEditTrack() {
// Create a track and open in TrackEditActivitiy
EndToEndTestUtils.createTrackIfEmpty(1, false);
instrumentation.waitForIdleSync();
// Click on the Edit menu item
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_edit), true);
String newTrackName = EndToEndTestUtils.TRACK_NAME_PREFIX + "_new" + System.currentTimeMillis();
String newType = EndToEndTestUtils.activityType;
String newDesc = "desc" + newTrackName;
instrumentation.waitForIdleSync();
// Rotate phone
EndToEndTestUtils.rotateCurrentActivity();
EndToEndTestUtils.SOLO.waitForText(activityMyTracks.getString(R.string.generic_save));
String newName = EndToEndTestUtils.TRACK_NAME_PREFIX + "_new" + System.currentTimeMillis();
String newActivityType = EndToEndTestUtils.activityType;
String newDescription = "new_description_" + newName;
// Clear name field
sendKeys(KeyEvent.KEYCODE_DEL);
// Enter new name
EndToEndTestUtils.enterTextAvoidSoftKeyBoard(0, newName);
// Enter new activity type
EndToEndTestUtils.SOLO.clearEditText(1);
EndToEndTestUtils.enterTextAvoidSoftKeyBoard(1, newActivityType);
// Enter new description
EndToEndTestUtils.SOLO.clearEditText(2);
EndToEndTestUtils.enterTextAvoidSoftKeyBoard(2, newDescription);
EndToEndTestUtils.enterTextAvoidSoftKeyBoard(0, newTrackName);
EndToEndTestUtils.enterTextAvoidSoftKeyBoard(1, newType);
// Change activity type using the activity picker
assertTrue(EndToEndTestUtils.SOLO.searchText(newActivityType));
EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getCurrentActivity()
.findViewById(R.id.track_edit_activity_type_icon));
EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.track_edit_activity_type_hint));
int walkingActivityTypeIndex = 1;
EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getImage(walkingActivityTypeIndex));
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
// The activity type should be replaced by the walking activity type
assertFalse(EndToEndTestUtils.SOLO.searchText(newActivityType));
assertTrue(EndToEndTestUtils.SOLO.searchText(
activityMyTracks.getString(R.string.activity_type_walking)));
EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getCurrentActivity().findViewById(
R.id.track_edit_activity_type_icon));
EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.track_edit_activity_type_hint));
EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getImage(1));
// The test type should be replaced by the first type option.
assertFalse(EndToEndTestUtils.SOLO.searchText(newType));
EndToEndTestUtils.enterTextAvoidSoftKeyBoard(2, newDesc);
// Save
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_save));
instrumentation.waitForIdleSync();
// Go back to track list.
// Go back to the TrackListActivity
EndToEndTestUtils.SOLO.goBack();
instrumentation.waitForIdleSync();
assertTrue(EndToEndTestUtils.SOLO.searchText(newTrackName));
assertTrue(EndToEndTestUtils.SOLO.searchText(newDesc));
assertTrue(EndToEndTestUtils.SOLO.searchText(newName));
assertTrue(EndToEndTestUtils.SOLO.searchText(newDescription));
}
/**
* Creates one track with a two locations, a way point and a statistics point.
* Creates a track with one marker.
*/
public void testCreateTrackWithMarkers() {
public void testCreateTrackWithMarker() {
// Start recording
EndToEndTestUtils.startRecording();
instrumentation.waitForIdleSync();
// Send Gps before creating marker.
// Send GPS points
EndToEndTestUtils.sendGps(2);
if (EndToEndTestUtils.hasActionBar) {
// Check the title is Recording.
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks
.getString(R.string.generic_recording)));
// Check the title is Recording...
assertTrue(EndToEndTestUtils.SOLO.searchText(
activityMyTracks.getString(R.string.generic_recording)));
}
// Create marker
EndToEndTestUtils.createWaypoint(0);
EndToEndTestUtils.sendGps(2, 2);
// Back to tracks list.
// Go back to the TrackListActivity
EndToEndTestUtils.SOLO.goBack();
instrumentation.waitForIdleSync();
// Rotate phone
EndToEndTestUtils.rotateCurrentActivity();
// Stops recording
EndToEndTestUtils.stopRecording(false);
EndToEndTestUtils.trackName = EndToEndTestUtils.TRACK_NAME_PREFIX + System.currentTimeMillis();
EndToEndTestUtils.SOLO.enterText(0, EndToEndTestUtils.trackName);
// Update Edit page and Save
String name = EndToEndTestUtils.TRACK_NAME_PREFIX + System.currentTimeMillis();
EndToEndTestUtils.SOLO.enterText(0, name);
EndToEndTestUtils.SOLO.enterText(1, EndToEndTestUtils.activityType);
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_save));
instrumentation.waitForIdleSync();
// Check the new track
// Check the new track name in TrackListActivity
EndToEndTestUtils.SOLO.scrollUp();
assertTrue(EndToEndTestUtils.SOLO.waitForText(EndToEndTestUtils.trackName, 1,
EndToEndTestUtils.NORMAL_WAIT_TIME, true, false));
assertTrue(EndToEndTestUtils.SOLO.waitForText(
name, 1, EndToEndTestUtils.NORMAL_WAIT_TIME, true, false));
}
/**
* Tests the display of track relative time.
* Tests displaying relative time like "mins ago" for a new track.
*/
public void testTrackRelativeTime() {
// Delete all track first.
public void testNewTrackRelativeTime() {
// Delete all tracks
EndToEndTestUtils.deleteAllTracks();
// Reset all settings.
// Reset all settings
EndToEndTestUtils.resetAllSettings(activityMyTracks, false);
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.track_list_empty_message)));
// Test should not show relative time.
// Start a new recording
EndToEndTestUtils.startRecording();
instrumentation.waitForIdleSync();
// Stops the recording
EndToEndTestUtils.stopRecording(false);
instrumentation.waitForIdleSync();
// Save the track
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_save), true,
true);
instrumentation.waitForIdleSync();
// Go back to the TrackListActivity
EndToEndTestUtils.SOLO.goBack();
instrumentation.waitForIdleSync();
// Make sure "mins ago" is displayed
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.RELATIVE_STARTTIME_POSTFIX, 1,
false, true));
}
@@ -159,6 +198,7 @@ public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListA
EndToEndTestUtils
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
// Send Gps to give a distance more than one kilometer or one mile.
EndToEndTestUtils.sendGps(50);
assertTrue(EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_markers),
@@ -179,5 +219,4 @@ public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListA
EndToEndTestUtils.SOLO.finishOpenedActivities();
super.tearDown();
}
}