forked from upstream-mirrors/OpenTracks
Code cleanup: CreateTrackTest
This commit is contained in:
+40
-38
@@ -84,35 +84,19 @@ public class EndToEndTestUtils {
|
|||||||
private static final String MENUITEM_CLASSNAME = "com.android.internal.view.menu.IconMenuItemView";
|
private static final String MENUITEM_CLASSNAME = "com.android.internal.view.menu.IconMenuItemView";
|
||||||
|
|
||||||
// Following is some check strings in English and Chinese
|
// Following is some check strings in English and Chinese
|
||||||
private static final HashMap<String, String> RELATIVE_START_TIME_POSTFIX_MULTILINGUAL = new HashMap<String, String>();
|
private static final HashMap<String, String>
|
||||||
private static final HashMap<String, String> KM_MULTILINGUAL = new HashMap<String, String>();
|
RELATIVE_START_TIME_SUFFIX_MULTILINGUAL = new HashMap<String, String>();
|
||||||
private static final HashMap<String, String> MILE_MULTILINGUAL = new HashMap<String, String>();
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("en", "mins ago");
|
RELATIVE_START_TIME_SUFFIX_MULTILINGUAL.put("en", "mins ago");
|
||||||
RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("de", "Minuten");
|
RELATIVE_START_TIME_SUFFIX_MULTILINGUAL.put("de", "Minuten");
|
||||||
RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("fr", "minute");
|
RELATIVE_START_TIME_SUFFIX_MULTILINGUAL.put("fr", "minute");
|
||||||
RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("ar", "دقيقة");
|
RELATIVE_START_TIME_SUFFIX_MULTILINGUAL.put("ar", "دقيقة");
|
||||||
RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("zh", "分钟前");
|
RELATIVE_START_TIME_SUFFIX_MULTILINGUAL.put("zh", "分钟前");
|
||||||
|
|
||||||
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("en", "mi");
|
|
||||||
MILE_MULTILINGUAL.put("de", "mi");
|
|
||||||
MILE_MULTILINGUAL.put("fr", "mile");
|
|
||||||
MILE_MULTILINGUAL.put("ar", "ميل");
|
|
||||||
MILE_MULTILINGUAL.put("zh", "英里");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int emulatorPort = 5554; // usually 5554.
|
public static int emulatorPort = 5554; // usually 5554.
|
||||||
public static String activityType = DEFAULT_ACTIVITY_TYPE;
|
public static String activityType = DEFAULT_ACTIVITY_TYPE;
|
||||||
public static String RELATIVE_START_TIME_POSTFIX = "";
|
|
||||||
public static String KM = "";
|
|
||||||
public static String MILE = "";
|
|
||||||
public static String trackName;
|
public static String trackName;
|
||||||
public static String trackDescription;
|
public static String trackDescription;
|
||||||
public static com.robotium.solo.Solo SOLO;
|
public static com.robotium.solo.Solo SOLO;
|
||||||
@@ -129,7 +113,8 @@ public class EndToEndTestUtils {
|
|||||||
|
|
||||||
private static boolean isCheckedFirstLaunch = false;
|
private static boolean isCheckedFirstLaunch = false;
|
||||||
private static boolean isGooglePlayServicesLatest = true;
|
private static boolean isGooglePlayServicesLatest = true;
|
||||||
|
private static String language;
|
||||||
|
|
||||||
private EndToEndTestUtils() {};
|
private EndToEndTestUtils() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,17 +128,7 @@ public class EndToEndTestUtils {
|
|||||||
.getResources().getConfiguration();
|
.getResources().getConfiguration();
|
||||||
configuration.locale = locale;
|
configuration.locale = locale;
|
||||||
|
|
||||||
String language = instrumentation.getContext().getResources().getConfiguration().locale
|
language = instrumentation.getContext().getResources().getConfiguration().locale.getLanguage();
|
||||||
.getLanguage();
|
|
||||||
if (RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.get(language) != null) {
|
|
||||||
RELATIVE_START_TIME_POSTFIX = RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.get(language);
|
|
||||||
KM = KM_MULTILINGUAL.get(language);
|
|
||||||
MILE = MILE_MULTILINGUAL.get(language);
|
|
||||||
} else {
|
|
||||||
RELATIVE_START_TIME_POSTFIX = RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.get("en");
|
|
||||||
KM = KM_MULTILINGUAL.get("en");
|
|
||||||
MILE = MILE_MULTILINGUAL.get("en");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -347,11 +322,10 @@ public class EndToEndTestUtils {
|
|||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
stopRecording(true);
|
stopRecording(true);
|
||||||
|
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
if (showTrackList) {
|
if (showTrackList) {
|
||||||
SOLO.goBack();
|
SOLO.goBack();
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
}
|
}
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -477,6 +451,8 @@ public class EndToEndTestUtils {
|
|||||||
enterTextAvoidSoftKeyBoard(2, trackDescription);
|
enterTextAvoidSoftKeyBoard(2, trackDescription);
|
||||||
SOLO.clickOnText(trackListActivity.getString(R.string.generic_save));
|
SOLO.clickOnText(trackListActivity.getString(R.string.generic_save));
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
|
} else {
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -928,7 +904,7 @@ public class EndToEndTestUtils {
|
|||||||
*
|
*
|
||||||
* @param activity
|
* @param activity
|
||||||
*/
|
*/
|
||||||
public static void findAndClickMyLocation(Activity activity) {
|
private static void findAndClickMyLocation(Activity activity) {
|
||||||
createTrackIfEmpty(1, false);
|
createTrackIfEmpty(1, false);
|
||||||
sendGps(30);
|
sendGps(30);
|
||||||
|
|
||||||
@@ -948,4 +924,30 @@ public class EndToEndTestUtils {
|
|||||||
}
|
}
|
||||||
SOLO.clickOnView(myLocation);
|
SOLO.clickOnView(myLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the relative start time suffix.
|
||||||
|
*/
|
||||||
|
public static String getRelativeStartTimeSuffix() {
|
||||||
|
String value = RELATIVE_START_TIME_SUFFIX_MULTILINGUAL.get(language);
|
||||||
|
return value != null ? value : RELATIVE_START_TIME_SUFFIX_MULTILINGUAL.get("en");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes to metric units.
|
||||||
|
*/
|
||||||
|
public static void changeToMetricUnits() {
|
||||||
|
EndToEndTestUtils.findMenuItem(trackListActivity.getString(R.string.menu_settings), true);
|
||||||
|
EndToEndTestUtils.SOLO.clickOnText(
|
||||||
|
trackListActivity.getString(R.string.track_detail_stats_tab));
|
||||||
|
Assert.assertTrue(EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
trackListActivity.getString(R.string.settings_stats_units_title)));
|
||||||
|
|
||||||
|
// Change the preferred units
|
||||||
|
EndToEndTestUtils.SOLO.clickOnText(
|
||||||
|
trackListActivity.getString(R.string.settings_stats_units_title));
|
||||||
|
EndToEndTestUtils.SOLO.clickOnText(trackListActivity.getString(R.string.unit_kilometer));
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+121
-171
@@ -13,6 +13,7 @@
|
|||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks.endtoendtest.common;
|
package com.google.android.apps.mytracks.endtoendtest.common;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.TrackListActivity;
|
import com.google.android.apps.mytracks.TrackListActivity;
|
||||||
@@ -21,18 +22,17 @@ import com.google.android.maps.mytracks.R;
|
|||||||
|
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.test.ActivityInstrumentationTestCase2;
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests creating a track with markers, and editing and sending send a track.
|
* Tests creating new tracks.
|
||||||
*
|
*
|
||||||
* @author Youtao Liu
|
* @author Youtao Liu
|
||||||
*/
|
*/
|
||||||
public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
||||||
|
|
||||||
private Instrumentation instrumentation;
|
private Instrumentation instrumentation;
|
||||||
private TrackListActivity activityMyTracks;
|
private TrackListActivity trackListActivity;
|
||||||
|
|
||||||
public CreateTrackTest() {
|
public CreateTrackTest() {
|
||||||
super(TrackListActivity.class);
|
super(TrackListActivity.class);
|
||||||
@@ -42,176 +42,10 @@ public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListA
|
|||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
instrumentation = getInstrumentation();
|
instrumentation = getInstrumentation();
|
||||||
activityMyTracks = getActivity();
|
trackListActivity = getActivity();
|
||||||
EndToEndTestUtils.setupForAllTest(instrumentation, activityMyTracks);
|
EndToEndTestUtils.setupForAllTest(instrumentation, trackListActivity);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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)));
|
|
||||||
|
|
||||||
// Save
|
|
||||||
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
// Go back to the TrackListActivity
|
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.searchText(newName));
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.searchText(newDescription));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a track with one marker.
|
|
||||||
*/
|
|
||||||
public void testCreateTrackWithMarker() {
|
|
||||||
|
|
||||||
// Start recording
|
|
||||||
EndToEndTestUtils.startRecording();
|
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
// Send GPS points
|
|
||||||
EndToEndTestUtils.sendGps(2);
|
|
||||||
if (EndToEndTestUtils.hasActionBar) {
|
|
||||||
// Check the title is Recording...
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.searchText(
|
|
||||||
activityMyTracks.getString(R.string.generic_recording)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create marker
|
|
||||||
EndToEndTestUtils.createWaypoint(0);
|
|
||||||
EndToEndTestUtils.sendGps(2, 2);
|
|
||||||
|
|
||||||
// Go back to the TrackListActivity
|
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
// Rotate phone
|
|
||||||
EndToEndTestUtils.rotateCurrentActivity();
|
|
||||||
|
|
||||||
// Stops recording
|
|
||||||
EndToEndTestUtils.stopRecording(false);
|
|
||||||
|
|
||||||
// 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 name in TrackListActivity
|
|
||||||
EndToEndTestUtils.SOLO.scrollUp();
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
name, 1, EndToEndTestUtils.NORMAL_WAIT_TIME, true, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests displaying relative time like "mins ago" for a new track.
|
|
||||||
*/
|
|
||||||
public void testNewTrackRelativeTime() {
|
|
||||||
|
|
||||||
// Delete all tracks
|
|
||||||
EndToEndTestUtils.deleteAllTracks();
|
EndToEndTestUtils.deleteAllTracks();
|
||||||
|
|
||||||
// Reset all settings
|
|
||||||
EndToEndTestUtils.resetAllSettings(activityMyTracks, false);
|
|
||||||
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
|
||||||
.getString(R.string.track_list_empty_message)));
|
|
||||||
|
|
||||||
// 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_START_TIME_POSTFIX, 1,
|
|
||||||
false, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests whether the split marker is created as setting.
|
|
||||||
*/
|
|
||||||
public void testSplitSetting() {
|
|
||||||
EndToEndTestUtils.startRecording();
|
|
||||||
|
|
||||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_split_frequency), true);
|
|
||||||
boolean isFoundKM = EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.KM);
|
|
||||||
if (isFoundKM) {
|
|
||||||
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.KM, 0);
|
|
||||||
} else {
|
|
||||||
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.MILE, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
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),
|
|
||||||
true));
|
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
if (EndToEndTestUtils.hasGpsSignal) {
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount() > 0);
|
|
||||||
} else {
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount() == 0);
|
|
||||||
}
|
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
|
||||||
|
|
||||||
EndToEndTestUtils.stopRecording(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -219,4 +53,120 @@ public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListA
|
|||||||
EndToEndTestUtils.SOLO.finishOpenedActivities();
|
EndToEndTestUtils.SOLO.finishOpenedActivities();
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests creating a new track and checks the relative time in
|
||||||
|
* {@link TrackListActivity}.
|
||||||
|
*/
|
||||||
|
public void testNewTrack() {
|
||||||
|
// Start a recording
|
||||||
|
EndToEndTestUtils.startRecording();
|
||||||
|
checkRecording();
|
||||||
|
|
||||||
|
// Stop the recording
|
||||||
|
EndToEndTestUtils.stopRecording(false);
|
||||||
|
|
||||||
|
// Save the track
|
||||||
|
EndToEndTestUtils.getButtonOnScreen(
|
||||||
|
trackListActivity.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.getRelativeStartTimeSuffix(), 1, false, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests creating a new track with two markers.
|
||||||
|
*/
|
||||||
|
public void testNewTrackWithMarker() {
|
||||||
|
// Start a recording
|
||||||
|
EndToEndTestUtils.startRecording();
|
||||||
|
checkRecording();
|
||||||
|
|
||||||
|
// Create a marker
|
||||||
|
EndToEndTestUtils.sendGps(2);
|
||||||
|
EndToEndTestUtils.createWaypoint(0);
|
||||||
|
|
||||||
|
// Send more gps points
|
||||||
|
EndToEndTestUtils.sendGps(2, 2);
|
||||||
|
EndToEndTestUtils.createWaypoint(1);
|
||||||
|
|
||||||
|
// Go back to the TrackListActivity
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
// Rotate the phone
|
||||||
|
EndToEndTestUtils.rotateCurrentActivity();
|
||||||
|
|
||||||
|
// Stop the recording
|
||||||
|
EndToEndTestUtils.stopRecording(false);
|
||||||
|
|
||||||
|
// Update edit page and save
|
||||||
|
String trackName = EndToEndTestUtils.TRACK_NAME_PREFIX + System.currentTimeMillis();
|
||||||
|
EndToEndTestUtils.SOLO.enterText(0, trackName);
|
||||||
|
EndToEndTestUtils.SOLO.enterText(1, EndToEndTestUtils.activityType);
|
||||||
|
EndToEndTestUtils.SOLO.clickOnButton(trackListActivity.getString(R.string.generic_save));
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
// Check the track name in the TrackListActivity
|
||||||
|
EndToEndTestUtils.SOLO.scrollUp();
|
||||||
|
assertTrue(EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
trackName, 1, EndToEndTestUtils.NORMAL_WAIT_TIME, true, false));
|
||||||
|
|
||||||
|
// Go to the TrackDetailActivity
|
||||||
|
EndToEndTestUtils.SOLO.clickOnText(trackName);
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
// Go to Markers
|
||||||
|
EndToEndTestUtils.findMenuItem(trackListActivity.getString(R.string.menu_markers), true);
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
// Make sure there are two markers
|
||||||
|
assertTrue(EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests creating a new track with split markers.
|
||||||
|
*/
|
||||||
|
public void testNewTrackWithSplit() {
|
||||||
|
EndToEndTestUtils.changeToMetricUnits();
|
||||||
|
|
||||||
|
EndToEndTestUtils.startRecording();
|
||||||
|
checkRecording();
|
||||||
|
|
||||||
|
EndToEndTestUtils.findMenuItem(
|
||||||
|
trackListActivity.getString(R.string.menu_split_frequency), true);
|
||||||
|
EndToEndTestUtils.SOLO.clickOnText(trackListActivity.getString(R.string.unit_kilometer), 0);
|
||||||
|
EndToEndTestUtils.getButtonOnScreen(
|
||||||
|
trackListActivity.getString(R.string.generic_ok), true, true);
|
||||||
|
|
||||||
|
// Send gps to give a distance more than one kilometer
|
||||||
|
EndToEndTestUtils.sendGps(50);
|
||||||
|
assertTrue(
|
||||||
|
EndToEndTestUtils.findMenuItem(trackListActivity.getString(R.string.menu_markers), true));
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
if (EndToEndTestUtils.isEmulator) {
|
||||||
|
assertTrue(EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount() > 0);
|
||||||
|
}
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
EndToEndTestUtils.stopRecording(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks recording.
|
||||||
|
*/
|
||||||
|
private void checkRecording() {
|
||||||
|
if (EndToEndTestUtils.hasActionBar) {
|
||||||
|
// Check the title is Recording...
|
||||||
|
assertTrue(EndToEndTestUtils.SOLO.searchText(
|
||||||
|
trackListActivity.getString(R.string.generic_recording)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.android.apps.mytracks.endtoendtest.common;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.TrackListActivity;
|
||||||
|
import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.app.Instrumentation;
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests editing a track.
|
||||||
|
*
|
||||||
|
* @author Youtao Liu
|
||||||
|
*/
|
||||||
|
public class EditTrackTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
||||||
|
|
||||||
|
private Instrumentation instrumentation;
|
||||||
|
private TrackListActivity trackListActivity;
|
||||||
|
|
||||||
|
public EditTrackTest() {
|
||||||
|
super(TrackListActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
instrumentation = getInstrumentation();
|
||||||
|
trackListActivity = getActivity();
|
||||||
|
EndToEndTestUtils.setupForAllTest(instrumentation, trackListActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
EndToEndTestUtils.SOLO.finishOpenedActivities();
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests editing a track.
|
||||||
|
*/
|
||||||
|
public void testEditTrack() {
|
||||||
|
EndToEndTestUtils.deleteAllTracks();
|
||||||
|
|
||||||
|
EndToEndTestUtils.createSimpleTrack(1, false);
|
||||||
|
|
||||||
|
// Click on the Edit menu item
|
||||||
|
EndToEndTestUtils.findMenuItem(trackListActivity.getString(R.string.menu_edit), true);
|
||||||
|
|
||||||
|
// Rotate phone
|
||||||
|
EndToEndTestUtils.rotateCurrentActivity();
|
||||||
|
EndToEndTestUtils.SOLO.waitForText(trackListActivity.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);
|
||||||
|
|
||||||
|
// 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(
|
||||||
|
trackListActivity.getString(R.string.track_edit_activity_type_hint));
|
||||||
|
int walkingActivityTypeIndex = 1;
|
||||||
|
EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getImage(walkingActivityTypeIndex));
|
||||||
|
EndToEndTestUtils.SOLO.clickOnButton(trackListActivity.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(
|
||||||
|
trackListActivity.getString(R.string.activity_type_walking)));
|
||||||
|
|
||||||
|
// Save
|
||||||
|
EndToEndTestUtils.SOLO.clickOnButton(trackListActivity.getString(R.string.generic_save));
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
// Go back to the TrackListActivity
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
assertTrue(EndToEndTestUtils.SOLO.searchText(newName));
|
||||||
|
assertTrue(EndToEndTestUtils.SOLO.searchText(newDescription));
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-19
@@ -213,7 +213,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
|
|||||||
* @param trackFileFormat the track file format
|
* @param trackFileFormat the track file format
|
||||||
*/
|
*/
|
||||||
private void testExportImportOne(TrackFileFormat trackFileFormat) {
|
private void testExportImportOne(TrackFileFormat trackFileFormat) {
|
||||||
changeToMetricUnits();
|
EndToEndTestUtils.changeToMetricUnits();
|
||||||
showGradeElevation();
|
showGradeElevation();
|
||||||
|
|
||||||
addTrackFromGpxFile();
|
addTrackFromGpxFile();
|
||||||
@@ -619,24 +619,6 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes to metric units.
|
|
||||||
*/
|
|
||||||
private void changeToMetricUnits() {
|
|
||||||
EndToEndTestUtils.findMenuItem(trackListActivity.getString(R.string.menu_settings), true);
|
|
||||||
EndToEndTestUtils.SOLO.clickOnText(
|
|
||||||
trackListActivity.getString(R.string.track_detail_stats_tab));
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
trackListActivity.getString(R.string.settings_stats_units_title)));
|
|
||||||
|
|
||||||
// Change the preferred units
|
|
||||||
EndToEndTestUtils.SOLO.clickOnText(
|
|
||||||
trackListActivity.getString(R.string.settings_stats_units_title));
|
|
||||||
EndToEndTestUtils.SOLO.clickOnText(trackListActivity.getString(R.string.unit_kilometer));
|
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows grade elevation.
|
* Shows grade elevation.
|
||||||
*/
|
*/
|
||||||
|
|||||||
-1
@@ -298,7 +298,6 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
|
|||||||
EndToEndTestUtils.startRecording();
|
EndToEndTestUtils.startRecording();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
EndToEndTestUtils.stopRecording(false);
|
EndToEndTestUtils.stopRecording(false);
|
||||||
instrumentation.waitForIdleSync();
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks.getString(
|
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks.getString(
|
||||||
R.string.track_name_format).split(" ")[0]));
|
R.string.track_name_format).split(" ")[0]));
|
||||||
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.activityType));
|
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.activityType));
|
||||||
|
|||||||
Reference in New Issue
Block a user