Cleanup logging in end to end tests

This commit is contained in:
Jimmy Shih
2014-01-28 18:20:06 -08:00
parent 98ef2a8975
commit 0e7d909646
18 changed files with 214 additions and 204 deletions
@@ -27,6 +27,7 @@ import android.util.Log;
*/ */
public class EndToEndTestRunner extends InstrumentationTestRunner { public class EndToEndTestRunner extends InstrumentationTestRunner {
private static final String TAG = EndToEndTestRunner.class.getSimpleName();
private static final String PORT_KEY = "port"; private static final String PORT_KEY = "port";
private static final String RESOURCE_KEY = "resource"; private static final String RESOURCE_KEY = "resource";
private static final String SENSOR_KEY = "sensor"; private static final String SENSOR_KEY = "sensor";
@@ -42,23 +43,22 @@ public class EndToEndTestRunner extends InstrumentationTestRunner {
try { try {
EndToEndTestUtils.emulatorPort = Integer.parseInt(port); EndToEndTestUtils.emulatorPort = Integer.parseInt(port);
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, Log.e(TAG, "Unable to get emulator port parameter, use the default value.", e);
"Unable to get emulator port parameter, use the default value.", e);
} }
} }
Log.i(EndToEndTestUtils.LOG_TAG, "Emulator port: " + EndToEndTestUtils.emulatorPort); Log.d(TAG, "Emulator port: " + EndToEndTestUtils.emulatorPort);
RunConfiguration runConfiguration = RunConfiguration.getInstance(); RunConfiguration runConfiguration = RunConfiguration.getInstance();
runConfiguration.setRunResourceTest( runConfiguration.setRunResourceTest(
TRUE_VALUE.equalsIgnoreCase(bundle.getString(RESOURCE_KEY))); TRUE_VALUE.equalsIgnoreCase(bundle.getString(RESOURCE_KEY)));
Log.i(EndToEndTestUtils.LOG_TAG, "Run resource test: " + runConfiguration.getRunResourceTest()); Log.d(TAG, "Run resource test: " + runConfiguration.getRunResourceTest());
runConfiguration.setRunSensorTest(TRUE_VALUE.equalsIgnoreCase(bundle.getString(SENSOR_KEY))); runConfiguration.setRunSensorTest(TRUE_VALUE.equalsIgnoreCase(bundle.getString(SENSOR_KEY)));
Log.i(EndToEndTestUtils.LOG_TAG, "Run sensor test: " + runConfiguration.getRunSensorTest()); Log.d(TAG, "Run sensor test: " + runConfiguration.getRunSensorTest());
runConfiguration.setRunStressTest(TRUE_VALUE.equalsIgnoreCase(bundle.getString(STRESS_KEY))); runConfiguration.setRunStressTest(TRUE_VALUE.equalsIgnoreCase(bundle.getString(STRESS_KEY)));
Log.i(EndToEndTestUtils.LOG_TAG, "Run stress test: " + runConfiguration.getRunStressTest()); Log.d(TAG, "Run stress test: " + runConfiguration.getRunStressTest());
super.onCreate(bundle); super.onCreate(bundle);
} }
@@ -56,6 +56,8 @@ import junit.framework.Assert;
* @author Youtao Liu * @author Youtao Liu
*/ */
public class EndToEndTestUtils { public class EndToEndTestUtils {
private static final String TAG = EndToEndTestUtils.class.getSimpleName();
public static int emulatorPort = 5554; public static int emulatorPort = 5554;
// usually 5554. // usually 5554.
private static final int ORIENTATION_PORTRAIT = 1; private static final int ORIENTATION_PORTRAIT = 1;
@@ -63,7 +65,7 @@ public class EndToEndTestUtils {
private static final String ANDROID_LOCAL_IP = "10.0.2.2"; private static final String ANDROID_LOCAL_IP = "10.0.2.2";
private static final String NO_GPS_MESSAGE_PREFIX = "GPS is not available"; private static final String NO_GPS_MESSAGE_PREFIX = "GPS is not available";
private static final String MOREOPTION_CLASSNAME = "com.android.internal.view.menu.ActionMenuPresenter$OverflowMenuButton"; private static final String MORE_OPTION_CLASSNAME = "com.android.internal.view.menu.ActionMenuPresenter$OverflowMenuButton";
private static final String MENUITEM_CLASSNAME = "com.android.internal.view.menu.IconMenuItemView"; private static final String MENUITEM_CLASSNAME = "com.android.internal.view.menu.IconMenuItemView";
// Pause 200ms between each send. // Pause 200ms between each send.
@@ -73,21 +75,18 @@ public class EndToEndTestUtils {
public static final double DELTA_LADITUDE = 0.0005f; public static final double DELTA_LADITUDE = 0.0005f;
public static final String WAYPOINT_NAME = "testWaypoint"; public static final String WAYPOINT_NAME = "testWaypoint";
public static final String WAYPOINT_TYPE = "testWaypoinType"; public static final String WAYPOINT_TYPE = "testWaypoinType";
public static final String WAYPOINT_DESC = "testWaypointDesc"; public static final String WAYPOINT_DESCRIPTION = "testWaypointDesc";
public static final String DEFAULTACTIVITYTYPE = "TestActivity"; public static final String DEFAULT_ACTIVITY_TYPE = "TestActivity";
public static final String TRACK_NAME_PREFIX = "testTrackName"; public static final String TRACK_NAME_PREFIX = "testTrackName";
public static final String TRACK_DESC_PREFIX = "testTrackDesc"; private static final String TRACK_DESCRIPTION_PREFIX = "testTrackDesc";
public static final String GPX = "gpx"; public static final String GPX = "gpx";
public static final String KML = "kml"; public static final String KML = "kml";
public static final String KMZ = "kmz"; public static final String KMZ = "kmz";
public static final String CSV = "csv"; public static final String CSV = "csv";
public static final String TCX = "tcx"; public static final String TCX = "tcx";
public static final String BACKUPS = "backups";
public static final String MENU_MORE = "More";
public static final String LOG_TAG = "MyTracksTest";
// 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_STARTTIME_POSTFIX_MULTILINGUAL = new HashMap<String, String>(); private static final HashMap<String, String> RELATIVE_START_TIME_POSTFIX_MULTILINGUAL = new HashMap<String, String>();
private static final HashMap<String, String> KM_MULTILINGUAL = new HashMap<String, String>(); private static final HashMap<String, String> KM_MULTILINGUAL = new HashMap<String, String>();
private static final HashMap<String, String> MILE_MULTILINGUAL = new HashMap<String, String>(); private static final HashMap<String, String> MILE_MULTILINGUAL = new HashMap<String, String>();
@@ -98,20 +97,19 @@ public class EndToEndTestUtils {
public static final int LONG_WAIT_TIME = 15000; public static final int LONG_WAIT_TIME = 15000;
public static final int SUPER_LONG_WAIT_TIME = 100000; public static final int SUPER_LONG_WAIT_TIME = 100000;
public static String activityType = DEFAULTACTIVITYTYPE; public static String activityType = DEFAULT_ACTIVITY_TYPE;
public static String RELATIVE_STARTTIME_POSTFIX = ""; public static String RELATIVE_START_TIME_POSTFIX = "";
public static String KM = ""; public static String KM = "";
public static String MILE = ""; public static String MILE = "";
public static String deviceLanguage = "";
public static String trackName; public static String trackName;
public static String trackDesc; public static String trackDescription;
static { static {
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("en", "mins ago"); RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("en", "mins ago");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("de", "Minuten"); RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("de", "Minuten");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("fr", "minute"); RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("fr", "minute");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("ar", "دقيقة"); RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("ar", "دقيقة");
RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.put("zh", "分钟前"); RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.put("zh", "分钟前");
KM_MULTILINGUAL.put("en", "km"); KM_MULTILINGUAL.put("en", "km");
KM_MULTILINGUAL.put("de", "km"); KM_MULTILINGUAL.put("de", "km");
@@ -128,7 +126,7 @@ public class EndToEndTestUtils {
public static com.robotium.solo.Solo SOLO; public static com.robotium.solo.Solo SOLO;
public static Instrumentation instrumentation; public static Instrumentation instrumentation;
public static TrackListActivity activityMytracks; public static TrackListActivity trackListActivity;
/* /*
* Check whether the UI has an action bar which is related with the version of * Check whether the UI has an action bar which is related with the version of
@@ -137,8 +135,8 @@ public class EndToEndTestUtils {
public static boolean hasActionBar = false; public static boolean hasActionBar = false;
public static boolean isEmulator = true; public static boolean isEmulator = true;
public static boolean hasGpsSingal = true; public static boolean hasGpsSingal = true;
public static boolean isCheckedFirstLaunch = false; private static boolean isCheckedFirstLaunch = false;
public static boolean isGooglePlayServicesLatest = true; private static boolean isGooglePlayServicesLatest = true;
private EndToEndTestUtils() {}; private EndToEndTestUtils() {};
@@ -146,23 +144,23 @@ public class EndToEndTestUtils {
* Checks the language, then sets the fields with right string. * Checks the language, then sets the fields with right string.
*/ */
private static void checkLanguage() { private static void checkLanguage() {
Locale locale = null; Locale locale = new Locale("en");
Configuration config = null;
config = activityMytracks.getBaseContext().getResources().getConfiguration();
locale = new Locale("en");
Locale.setDefault(locale); Locale.setDefault(locale);
config.locale = locale;
deviceLanguage = instrumentation.getContext().getResources().getConfiguration().locale Configuration configuration = trackListActivity.getBaseContext()
.getResources().getConfiguration();
configuration.locale = locale;
String language = instrumentation.getContext().getResources().getConfiguration().locale
.getLanguage(); .getLanguage();
if (RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.get(deviceLanguage) != null) { if (RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.get(language) != null) {
RELATIVE_STARTTIME_POSTFIX = RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.get(deviceLanguage); RELATIVE_START_TIME_POSTFIX = RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.get(language);
KM = KM_MULTILINGUAL.get(deviceLanguage); KM = KM_MULTILINGUAL.get(language);
MILE = MILE_MULTILINGUAL.get(deviceLanguage); MILE = MILE_MULTILINGUAL.get(language);
} else { } else {
RELATIVE_STARTTIME_POSTFIX = RELATIVE_STARTTIME_POSTFIX_MULTILINGUAL.get("es"); RELATIVE_START_TIME_POSTFIX = RELATIVE_START_TIME_POSTFIX_MULTILINGUAL.get("en");
KM = KM_MULTILINGUAL.get("es"); KM = KM_MULTILINGUAL.get("en");
MILE = MILE_MULTILINGUAL.get("es"); MILE = MILE_MULTILINGUAL.get("en");
} }
} }
@@ -252,14 +250,13 @@ public class EndToEndTestUtils {
/** /**
* A setup for debugging end-to-end tests. * A setup for debugging end-to-end tests.
* *
* @param instrumentation the instrumentation is used for test * @param inst the instrumentation
* @param activityMyTracks the startup activity * @param activity the track list activity
*/ */
public static void setupForDebug(Instrumentation instrumentation, public static void setupForDebug(Instrumentation inst, TrackListActivity activity) {
TrackListActivity activityMyTracks) { instrumentation = inst;
EndToEndTestUtils.instrumentation = instrumentation; trackListActivity = activity;
EndToEndTestUtils.activityMytracks = activityMyTracks; SOLO = new Solo(instrumentation, trackListActivity);
SOLO = new Solo(EndToEndTestUtils.instrumentation, EndToEndTestUtils.activityMytracks);
setIsEmulator(); setIsEmulator();
hasActionBar = setHasActionBar(); hasActionBar = setHasActionBar();
checkLanguage(); checkLanguage();
@@ -268,19 +265,18 @@ public class EndToEndTestUtils {
/** /**
* 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 inst the instrumentation
* @param activityMyTracks the startup activity * @param activity the track list activity
*/ */
public static void setupForAllTest(Instrumentation instrumentation, public static void setupForAllTest(Instrumentation inst, TrackListActivity activity) {
TrackListActivity activityMyTracks) { instrumentation = inst;
EndToEndTestUtils.instrumentation = instrumentation; trackListActivity = activity;
EndToEndTestUtils.activityMytracks = activityMyTracks; SOLO = new Solo(instrumentation, trackListActivity);
SOLO = new Solo(EndToEndTestUtils.instrumentation, EndToEndTestUtils.activityMytracks);
if (!isGooglePlayServicesLatest) { if (!isGooglePlayServicesLatest) {
SOLO.finishOpenedActivities(); SOLO.finishOpenedActivities();
Assert.fail(); Assert.fail();
Log.e(LOG_TAG, "Need update Google Play Services"); Log.e(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
@@ -290,7 +286,7 @@ public class EndToEndTestUtils {
if (!isGooglePlayServicesLatest) { if (!isGooglePlayServicesLatest) {
SOLO.finishOpenedActivities(); SOLO.finishOpenedActivities();
Assert.fail(); Assert.fail();
Log.e(LOG_TAG, "Need update Google Play Services"); Log.e(TAG, "Need update Google Play Services");
} }
setIsEmulator(); setIsEmulator();
@@ -299,10 +295,10 @@ public class EndToEndTestUtils {
checkLanguage(); checkLanguage();
isCheckedFirstLaunch = true; isCheckedFirstLaunch = true;
instrumentation.waitForIdleSync(); inst.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) {
findAndClickMyLocation(activityMyTracks); findAndClickMyLocation(activity);
hasGpsSingal = !SOLO.waitForText(NO_GPS_MESSAGE_PREFIX, 1, SHORT_WAIT_TIME); hasGpsSingal = !SOLO.waitForText(NO_GPS_MESSAGE_PREFIX, 1, SHORT_WAIT_TIME);
SOLO.goBack(); SOLO.goBack();
} }
@@ -321,8 +317,8 @@ public class EndToEndTestUtils {
stopRecording(true); stopRecording(true);
} }
resetAllSettings(activityMyTracks, false); resetAllSettings(activity, false);
instrumentation.waitForIdleSync(); inst.waitForIdleSync();
} }
/** /**
@@ -340,8 +336,8 @@ public class EndToEndTestUtils {
* Accepts terms and configures units. * Accepts terms and configures units.
*/ */
private static void verifyFirstLaunch() { private static void verifyFirstLaunch() {
if ((getButtonOnScreen(activityMytracks.getString(R.string.eula_accept), false, false) != null)) { if ((getButtonOnScreen(trackListActivity.getString(R.string.eula_accept), false, false) != null)) {
getButtonOnScreen(activityMytracks.getString(R.string.eula_accept), true, true); getButtonOnScreen(trackListActivity.getString(R.string.eula_accept), true, true);
} }
} }
@@ -403,7 +399,7 @@ public class EndToEndTestUtils {
if (isClick) { if (isClick) {
SOLO.scrollUp(); SOLO.scrollUp();
SOLO.clickOnView(oneTrack); SOLO.clickOnView(oneTrack);
SOLO.waitForText(activityMytracks.getString(R.string.track_detail_chart_tab)); SOLO.waitForText(trackListActivity.getString(R.string.track_detail_chart_tab));
} }
return false; return false;
} }
@@ -475,17 +471,17 @@ public class EndToEndTestUtils {
if (stopButton != null && stopButton.isShown()) { if (stopButton != null && stopButton.isShown()) {
SOLO.clickOnView(stopButton); SOLO.clickOnView(stopButton);
if (isSave) { if (isSave) {
SOLO.waitForText(activityMytracks.getString(R.string.generic_save), 1, 5000); SOLO.waitForText(trackListActivity.getString(R.string.generic_save), 1, 5000);
// Make every track name is unique to make sure every check can be // Make every track name is unique to make sure every check can be
// trusted. // trusted.
long currentMillis = System.currentTimeMillis(); long currentMillis = System.currentTimeMillis();
trackName = TRACK_NAME_PREFIX + currentMillis; trackName = TRACK_NAME_PREFIX + currentMillis;
trackDesc = TRACK_DESC_PREFIX + currentMillis; trackDescription = TRACK_DESCRIPTION_PREFIX + currentMillis;
SOLO.sendKey(KeyEvent.KEYCODE_DEL); SOLO.sendKey(KeyEvent.KEYCODE_DEL);
enterTextAvoidSoftKeyBoard(0, trackName); enterTextAvoidSoftKeyBoard(0, trackName);
enterTextAvoidSoftKeyBoard(1, activityType); enterTextAvoidSoftKeyBoard(1, activityType);
enterTextAvoidSoftKeyBoard(2, trackDesc); enterTextAvoidSoftKeyBoard(2, trackDescription);
SOLO.clickOnText(activityMytracks.getString(R.string.generic_save)); SOLO.clickOnText(trackListActivity.getString(R.string.generic_save));
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
} }
} }
@@ -497,7 +493,7 @@ public class EndToEndTestUtils {
* @param trackKind the kind of track * @param trackKind the kind of track
*/ */
public static void deleteExportedFiles(String trackKind) { public static void deleteExportedFiles(String trackKind) {
File[] allFiles = (new File(FileUtils.getPath(trackKind.toLowerCase()))).listFiles(); File[] allFiles = (new File(FileUtils.getPath(trackKind))).listFiles();
if (allFiles != null) { if (allFiles != null) {
for (File oneFile : allFiles) { for (File oneFile : allFiles) {
oneFile.delete(); oneFile.delete();
@@ -511,9 +507,9 @@ public class EndToEndTestUtils {
*/ */
public static void deleteAllTracks() { public static void deleteAllTracks() {
if (!isTrackListEmpty(false)) { if (!isTrackListEmpty(false)) {
findMenuItem(activityMytracks.getString(R.string.menu_delete_all), true); findMenuItem(trackListActivity.getString(R.string.menu_delete_all), true);
getButtonOnScreen(activityMytracks.getString(R.string.generic_yes), true, true); getButtonOnScreen(trackListActivity.getString(R.string.generic_yes), true, true);
waitTextToDisappear(activityMytracks.getString(R.string.generic_progress_title)); waitTextToDisappear(trackListActivity.getString(R.string.generic_progress_title));
} }
} }
@@ -528,8 +524,7 @@ public class EndToEndTestUtils {
FileFilter filter = new FileFilter() { FileFilter filter = new FileFilter() {
@Override @Override
public boolean accept(File pathname) { public boolean accept(File pathname) {
String postFix = trackKind.equalsIgnoreCase(EndToEndTestUtils.KML) ? EndToEndTestUtils.KMZ String postFix = trackKind.equalsIgnoreCase(KML) ? KMZ : trackKind;
: trackKind;
return pathname.getName().indexOf("." + postFix) > 0; return pathname.getName().indexOf("." + postFix) > 0;
} }
}; };
@@ -544,11 +539,11 @@ public class EndToEndTestUtils {
public static void saveAllTrackToSdCard(String trackKind) { public static void saveAllTrackToSdCard(String trackKind) {
deleteExportedFiles(trackKind); deleteExportedFiles(trackKind);
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
findMenuItem(activityMytracks.getString(R.string.menu_export_all), true); findMenuItem(trackListActivity.getString(R.string.menu_export_all), true);
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
SOLO.clickOnText(trackKind.toUpperCase()); SOLO.clickOnText(trackKind.toUpperCase(Locale.US));
getButtonOnScreen(activityMytracks.getString(R.string.generic_ok), true, true); getButtonOnScreen(trackListActivity.getString(R.string.generic_ok), true, true);
SOLO.waitForText(activityMytracks.getString(R.string.generic_success_title)); SOLO.waitForText(trackListActivity.getString(R.string.generic_success_title));
} }
/** /**
@@ -598,7 +593,7 @@ public class EndToEndTestUtils {
} }
if (button == null && isClick) { if (button == null && isClick) {
Log.d(LOG_TAG, "Don't find the button " + buttonName); Log.d(TAG, "Don't find the button " + buttonName);
} }
return button; return button;
@@ -612,7 +607,7 @@ public class EndToEndTestUtils {
@SuppressLint("NewApi") @SuppressLint("NewApi")
private static boolean setHasActionBar() { private static boolean setHasActionBar() {
try { try {
return activityMytracks.getActionBar() == null ? false : true; return trackListActivity.getActionBar() == null ? false : true;
} catch (Throwable e) { } catch (Throwable e) {
// For in Android which does not has action bar, here will meet a error. // For in Android which does not has action bar, here will meet a error.
return false; return false;
@@ -723,7 +718,7 @@ public class EndToEndTestUtils {
* Finds the more option menu. It should match following conditions: * Finds the more option menu. It should match following conditions:
* <ul> * <ul>
* <li>The view extends ImageButton.</li> * <li>The view extends ImageButton.</li>
* <li>The view name equals {@link #MOREOPTION_CLASSNAME}.</li> * <li>The view name equals {@link #MORE_OPTION_CLASSNAME}.</li>
* </ul> * </ul>
* *
* @return the more option view. Null means can not find it. * @return the more option view. Null means can not find it.
@@ -733,7 +728,7 @@ public class EndToEndTestUtils {
if (hasActionBar) { if (hasActionBar) {
ArrayList<View> allViews = SOLO.getViews(); ArrayList<View> allViews = SOLO.getViews();
for (View view : allViews) { for (View view : allViews) {
if (view instanceof ImageButton && view.getClass().getName().equals(MOREOPTION_CLASSNAME)) { if (view instanceof ImageButton && view.getClass().getName().equals(MORE_OPTION_CLASSNAME)) {
viewResult = view; viewResult = view;
break; break;
} }
@@ -842,7 +837,7 @@ public class EndToEndTestUtils {
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_advanced)); SOLO.clickOnText(activityMyTracks.getString(R.string.settings_advanced));
Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset))); Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset)));
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset)); SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset));
getButtonOnScreen(activityMytracks.getString(R.string.generic_yes), true, true); getButtonOnScreen(trackListActivity.getString(R.string.generic_yes), true, true);
Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset_done))); Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset_done)));
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
SOLO.goBack(); SOLO.goBack();
@@ -866,7 +861,7 @@ public class EndToEndTestUtils {
// Above line does not work every time. And it is should be a Robotium // Above line does not work every time. And it is should be a Robotium
// issue. // issue.
InputMethodManager imm = (InputMethodManager) activityMytracks.getApplicationContext() InputMethodManager imm = (InputMethodManager) trackListActivity.getApplicationContext()
.getSystemService(Context.INPUT_METHOD_SERVICE); .getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
} }
@@ -880,7 +875,7 @@ public class EndToEndTestUtils {
try { try {
Thread.sleep(milliseconds); Thread.sleep(milliseconds);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(LOG_TAG, "Unable to sleep " + milliseconds, e); Log.e(TAG, "Unable to sleep " + milliseconds, e);
} }
} }
@@ -889,12 +884,12 @@ public class EndToEndTestUtils {
*/ */
public static void checkNotRecording() { public static void checkNotRecording() {
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
Assert.assertEquals(activityMytracks.getString(R.string.image_record), (String) SOLO Assert.assertEquals(trackListActivity.getString(R.string.image_record), (String) SOLO
.getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription()); .getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription());
Assert.assertFalse(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop) Assert.assertFalse(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop)
.isEnabled()); .isEnabled());
Assert.assertNull(findTextView(activityMytracks.getString(R.string.generic_recording))); Assert.assertNull(findTextView(trackListActivity.getString(R.string.generic_recording)));
Assert.assertNull(findTextView(activityMytracks.getString(R.string.generic_paused))); Assert.assertNull(findTextView(trackListActivity.getString(R.string.generic_paused)));
TextView totalTime = (TextView) SOLO.getCurrentActivity().findViewById( TextView totalTime = (TextView) SOLO.getCurrentActivity().findViewById(
R.id.track_controller_total_time); R.id.track_controller_total_time);
Assert.assertEquals(StringUtils.formatElapsedTimeWithHour(0), totalTime.getText().toString()); Assert.assertEquals(StringUtils.formatElapsedTimeWithHour(0), totalTime.getText().toString());
@@ -905,12 +900,12 @@ public class EndToEndTestUtils {
*/ */
public static void checkUnderRecording() { public static void checkUnderRecording() {
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
Assert.assertEquals(activityMytracks.getString(R.string.image_pause), (String) SOLO Assert.assertEquals(trackListActivity.getString(R.string.image_pause), (String) SOLO
.getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription()); .getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription());
Assert.assertTrue(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop) Assert.assertTrue(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop)
.isEnabled()); .isEnabled());
Assert.assertNotNull(findTextView(activityMytracks.getString(R.string.generic_recording))); Assert.assertNotNull(findTextView(trackListActivity.getString(R.string.generic_recording)));
Assert.assertNull(findTextView(activityMytracks.getString(R.string.generic_paused))); Assert.assertNull(findTextView(trackListActivity.getString(R.string.generic_paused)));
String totalTimeOld = ((TextView) SOLO.getCurrentActivity().findViewById( String totalTimeOld = ((TextView) SOLO.getCurrentActivity().findViewById(
R.id.track_controller_total_time)).getText().toString(); R.id.track_controller_total_time)).getText().toString();
@@ -925,12 +920,12 @@ public class EndToEndTestUtils {
*/ */
public static void checkUnderPaused() { public static void checkUnderPaused() {
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
Assert.assertEquals(activityMytracks.getString(R.string.image_record), (String) SOLO Assert.assertEquals(trackListActivity.getString(R.string.image_record), (String) SOLO
.getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription()); .getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription());
Assert.assertTrue(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop) Assert.assertTrue(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop)
.isEnabled()); .isEnabled());
Assert.assertNull(findTextView(activityMytracks.getString(R.string.generic_recording))); Assert.assertNull(findTextView(trackListActivity.getString(R.string.generic_recording)));
Assert.assertNotNull(findTextView(activityMytracks.getString(R.string.generic_paused))); Assert.assertNotNull(findTextView(trackListActivity.getString(R.string.generic_paused)));
String totalTimeOld = ((TextView) SOLO.getCurrentActivity().findViewById( String totalTimeOld = ((TextView) SOLO.getCurrentActivity().findViewById(
R.id.track_controller_total_time)).getText().toString(); R.id.track_controller_total_time)).getText().toString();
@@ -946,20 +941,20 @@ public class EndToEndTestUtils {
* @param markerNumber of number of previous markers * @param markerNumber of number of previous markers
*/ */
public static void createWaypoint(int markerNumber) { public static void createWaypoint(int markerNumber) {
findMenuItem(activityMytracks.getString(R.string.menu_markers), true); findMenuItem(trackListActivity.getString(R.string.menu_markers), true);
if (markerNumber > 0 && hasGpsSingal) { if (markerNumber > 0 && hasGpsSingal) {
SOLO.waitForText(WAYPOINT_NAME); SOLO.waitForText(WAYPOINT_NAME);
int actualMarkerNumber = SOLO.getCurrentViews(ListView.class).get(0).getCount(); int actualMarkerNumber = SOLO.getCurrentViews(ListView.class).get(0).getCount();
Assert.assertEquals(markerNumber, actualMarkerNumber); Assert.assertEquals(markerNumber, actualMarkerNumber);
} else { } else {
Assert.assertTrue(SOLO.waitForText(activityMytracks Assert.assertTrue(SOLO.waitForText(trackListActivity
.getString(R.string.marker_list_empty_message))); .getString(R.string.marker_list_empty_message)));
} }
findMenuItem(activityMytracks.getString(R.string.menu_insert_marker), true); findMenuItem(trackListActivity.getString(R.string.menu_insert_marker), true);
enterTextAvoidSoftKeyBoard(0, WAYPOINT_NAME + (markerNumber + 1)); enterTextAvoidSoftKeyBoard(0, WAYPOINT_NAME + (markerNumber + 1));
enterTextAvoidSoftKeyBoard(1, WAYPOINT_TYPE + (markerNumber + 1)); enterTextAvoidSoftKeyBoard(1, WAYPOINT_TYPE + (markerNumber + 1));
enterTextAvoidSoftKeyBoard(2, WAYPOINT_DESC + (markerNumber + 1)); enterTextAvoidSoftKeyBoard(2, WAYPOINT_DESCRIPTION + (markerNumber + 1));
SOLO.clickOnButton(activityMytracks.getString(R.string.generic_add)); SOLO.clickOnButton(trackListActivity.getString(R.string.generic_add));
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
if (hasGpsSingal) { if (hasGpsSingal) {
Assert.assertTrue(SOLO.waitForText(WAYPOINT_NAME, 1, LONG_WAIT_TIME, true)); Assert.assertTrue(SOLO.waitForText(WAYPOINT_NAME, 1, LONG_WAIT_TIME, true));
@@ -68,10 +68,10 @@ public class GoogleUtils {
public static final String ACCOUNT_1 = "mytrackstest@gmail.com"; public static final String ACCOUNT_1 = "mytrackstest@gmail.com";
public static final String ACCOUNT_2 = "mytrackstest2@gmail.com"; public static final String ACCOUNT_2 = "mytrackstest2@gmail.com";
private static final String TAG = GoogleUtils.class.getSimpleName();
private static final String MY_TRACKS_PREFIX = "My Tracks"; private static final String MY_TRACKS_PREFIX = "My Tracks";
private static final String SPREADSHEETS_NAME = MY_TRACKS_PREFIX + "-" private static final String SPREADSHEETS_NAME = MY_TRACKS_PREFIX + "-"
+ EndToEndTestUtils.activityType; + EndToEndTestUtils.activityType;
private static final String SPREADSHEETS_WORKSHEET_NAME = "Log"; private static final String SPREADSHEETS_WORKSHEET_NAME = "Log";
private static final String SPREADSHEETS_TRANCK_NAME_COLUMN = "Name"; private static final String SPREADSHEETS_TRANCK_NAME_COLUMN = "Name";
private static final String DRIVE_TEST_FILES_QUERY = "'root' in parents and title contains '" private static final String DRIVE_TEST_FILES_QUERY = "'root' in parents and title contains '"
@@ -101,7 +101,7 @@ public class GoogleUtils {
drive.files().delete(file.getId()).execute(); drive.files().delete(file.getId()).execute();
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to delete Google Drive test files.", e); Log.e(TAG, "Unable to delete Google Drive test files.", e);
} }
} }
@@ -129,7 +129,7 @@ public class GoogleUtils {
.blockingGetAuthToken(account, MapsConstants.SERVICE_NAME, false)); .blockingGetAuthToken(account, MapsConstants.SERVICE_NAME, false));
return true; return true;
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to delete maps.", e); Log.e(TAG, "Unable to delete maps.", e);
return false; return false;
} }
} }
@@ -146,7 +146,7 @@ public class GoogleUtils {
public static void deleteAllMaps(Context context, String accountName) { public static void deleteAllMaps(Context context, String accountName) {
Account account = getGoogleAccount(context, accountName); Account account = getGoogleAccount(context, accountName);
if (account == null) { if (account == null) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to get account."); Log.e(TAG, "Unable to get account.");
return; return;
} }
MapsClient mapsClient = new MapsClient(GDataClientFactory.getGDataClient(context), MapsClient mapsClient = new MapsClient(GDataClientFactory.getGDataClient(context),
@@ -157,7 +157,7 @@ public class GoogleUtils {
mapsClient.deleteEntry(oneData.getGDataEditUri(), AccountManager.get(context) mapsClient.deleteEntry(oneData.getGDataEditUri(), AccountManager.get(context)
.blockingGetAuthToken(account, MapsConstants.SERVICE_NAME, false)); .blockingGetAuthToken(account, MapsConstants.SERVICE_NAME, false));
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to delete maps.", e); Log.e(TAG, "Unable to delete maps.", e);
} }
} }
} }
@@ -190,7 +190,7 @@ public class GoogleUtils {
} }
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to search fusion tables.", e); Log.e(TAG, "Unable to search fusion tables.", e);
} }
return false; return false;
} }
@@ -216,7 +216,7 @@ public class GoogleUtils {
Locale.US, SendSpreadsheetsAsyncTask.GET_SPREADSHEET_QUERY, SPREADSHEETS_NAME)); Locale.US, SendSpreadsheetsAsyncTask.GET_SPREADSHEET_QUERY, SPREADSHEETS_NAME));
return list.execute().getItems(); return list.execute().getItems();
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to search spreadsheets.", e); Log.e(TAG, "Unable to search spreadsheets.", e);
} }
return null; return null;
} }
@@ -247,7 +247,7 @@ public class GoogleUtils {
} }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to delete spreadsheets.", e); Log.e(TAG, "Unable to delete spreadsheets.", e);
} }
return false; return false;
} }
@@ -301,7 +301,7 @@ public class GoogleUtils {
} }
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to delete spreadsheets row.", e); Log.e(TAG, "Unable to delete spreadsheets row.", e);
} }
return false; return false;
} }
@@ -312,25 +312,25 @@ public class GoogleUtils {
public static boolean isAccountAvailable() { public static boolean isAccountAvailable() {
// Check the no account dialog // Check the no account dialog
if (EndToEndTestUtils.SOLO.waitForText( if (EndToEndTestUtils.SOLO.waitForText(
EndToEndTestUtils.activityMytracks.getString(R.string.send_google_no_account_title), 1, EndToEndTestUtils.trackListActivity.getString(R.string.send_google_no_account_title), 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) { EndToEndTestUtils.SHORT_WAIT_TIME)) {
EndToEndTestUtils.getButtonOnScreen( EndToEndTestUtils.getButtonOnScreen(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), false, true); EndToEndTestUtils.trackListActivity.getString(R.string.generic_ok), false, true);
return false; return false;
} }
// Check the choose account dialog // Check the choose account dialog
if (EndToEndTestUtils.SOLO.waitForText( if (EndToEndTestUtils.SOLO.waitForText(
EndToEndTestUtils.activityMytracks.getString(R.string.send_google_choose_account_title), 1, EndToEndTestUtils.trackListActivity.getString(R.string.send_google_choose_account_title), 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) { EndToEndTestUtils.SHORT_WAIT_TIME)) {
EndToEndTestUtils.SOLO.clickOnText(ACCOUNT_1); EndToEndTestUtils.SOLO.clickOnText(ACCOUNT_1);
EndToEndTestUtils.getButtonOnScreen( EndToEndTestUtils.getButtonOnScreen(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), false, true); EndToEndTestUtils.trackListActivity.getString(R.string.generic_ok), false, true);
} }
// Check the no account permission dialog // Check the no account permission dialog
if (EndToEndTestUtils.SOLO.waitForText( if (EndToEndTestUtils.SOLO.waitForText(
EndToEndTestUtils.activityMytracks.getString(R.string.send_google_no_account_permission), 1, EndToEndTestUtils.trackListActivity.getString(R.string.send_google_no_account_permission), 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) { EndToEndTestUtils.SHORT_WAIT_TIME)) {
return false; return false;
} }
@@ -372,7 +372,7 @@ public class GoogleUtils {
authToken = AccountManager.get(context) authToken = AccountManager.get(context)
.blockingGetAuthToken(account, MapsConstants.SERVICE_NAME, false); .blockingGetAuthToken(account, MapsConstants.SERVICE_NAME, false);
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to get auth token.", e); Log.e(TAG, "Unable to get auth token.", e);
return mapMetadata; return mapMetadata;
} }
@@ -387,7 +387,7 @@ public class GoogleUtils {
mapMetadata.add(MapsGDataConverter.getMapMetadataForEntry(entry)); mapMetadata.add(MapsGDataConverter.getMapMetadataForEntry(entry));
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to get maps.", e); Log.e(TAG, "Unable to get maps.", e);
} finally { } finally {
if (gDataParser != null) { if (gDataParser != null) {
gDataParser.close(); gDataParser.close();
@@ -121,13 +121,13 @@ public class RunConfiguration {
*/ */
private boolean canRunSyncTest() { private boolean canRunSyncTest() {
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_drive), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_drive), true);
boolean canRun = EndToEndTestUtils.SOLO.waitForText( boolean canRun = EndToEndTestUtils.SOLO.waitForText(
GoogleUtils.ACCOUNT_1, 1, EndToEndTestUtils.SHORT_WAIT_TIME) GoogleUtils.ACCOUNT_1, 1, EndToEndTestUtils.SHORT_WAIT_TIME)
&& EndToEndTestUtils.SOLO.waitForText( && EndToEndTestUtils.SOLO.waitForText(
GoogleUtils.ACCOUNT_2, 1, EndToEndTestUtils.TINY_WAIT_TIME); GoogleUtils.ACCOUNT_2, 1, EndToEndTestUtils.TINY_WAIT_TIME);
EndToEndTestUtils.SOLO.clickOnText( EndToEndTestUtils.SOLO.clickOnText(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_cancel)); EndToEndTestUtils.trackListActivity.getString(R.string.generic_cancel));
return canRun; return canRun;
} }
} }
@@ -178,7 +178,7 @@ public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListA
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
// Make sure "mins ago" is displayed // Make sure "mins ago" is displayed
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.RELATIVE_STARTTIME_POSTFIX, 1, assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.RELATIVE_START_TIME_POSTFIX, 1,
false, true)); false, true));
} }
@@ -33,6 +33,7 @@ import android.widget.TextView;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Locale;
/** /**
* Tests the import and export of MyTracks. * Tests the import and export of MyTracks.
@@ -45,9 +46,10 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
private TrackListActivity activityMyTracks; private TrackListActivity activityMyTracks;
private int trackNumber = 0; private int trackNumber = 0;
private final static String tracksName = "testTrackName1373523959524"; private static final String TAG = ExportAllAndImportAllTest.class.getSimpleName();
private final static String maxAltitude = "33.3"; private static final String TRACK_NAME = "testTrackName1373523959524";
private final static String minAltitude = "22.2"; private static final String MAX_ALTITUDE = "33.3";
private static final String MIN_ALTITUDE = "22.2";
public ExportAllAndImportAllTest() { public ExportAllAndImportAllTest() {
super(TrackListActivity.class); super(TrackListActivity.class);
@@ -143,7 +145,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.trackName)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.trackName));
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.activityType)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.activityType));
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.trackDesc)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.trackDescription));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.generic_cancel)); EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.generic_cancel));
if (EndToEndTestUtils.hasGpsSingal) { if (EndToEndTestUtils.hasGpsSingal) {
@@ -153,12 +155,12 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
// The first marker. // The first marker.
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_NAME + 1)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_NAME + 1));
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_TYPE + 1)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_TYPE + 1));
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_DESC + 1)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_DESCRIPTION + 1));
// The second marker. // The second marker.
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_NAME + 2)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_NAME + 2));
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_TYPE + 2)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_TYPE + 2));
assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_DESC + 2)); assertTrue(EndToEndTestUtils.SOLO.searchText(EndToEndTestUtils.WAYPOINT_DESCRIPTION + 2));
} }
} }
@@ -288,9 +290,9 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
*/ */
private void importTracks(String fileType) { private void importTracks(String fileType) {
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_import_all), true); EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_import_all), true);
EndToEndTestUtils.SOLO.clickOnText(fileType.toUpperCase()); EndToEndTestUtils.SOLO.clickOnText(fileType.toUpperCase(Locale.US));
EndToEndTestUtils.getButtonOnScreen( EndToEndTestUtils.getButtonOnScreen(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), true, true); EndToEndTestUtils.trackListActivity.getString(R.string.generic_ok), true, true);
} }
/** /**
@@ -300,9 +302,9 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
*/ */
private void exportTracks(String fileType) { private void exportTracks(String fileType) {
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true); EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true);
EndToEndTestUtils.SOLO.clickOnText(fileType.toUpperCase()); EndToEndTestUtils.SOLO.clickOnText(fileType.toUpperCase(Locale.US));
EndToEndTestUtils.getButtonOnScreen( EndToEndTestUtils.getButtonOnScreen(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_ok), true, true); EndToEndTestUtils.trackListActivity.getString(R.string.generic_ok), true, true);
EndToEndTestUtils.SOLO.waitForText(getSaveSuccessMessage(2, fileType)); EndToEndTestUtils.SOLO.waitForText(getSaveSuccessMessage(2, fileType));
EndToEndTestUtils EndToEndTestUtils
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true); .getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
@@ -381,7 +383,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
} }
PreferencesUtils.setBoolean(activityMyTracks, R.string.stats_show_grade_elevation_key, true); PreferencesUtils.setBoolean(activityMyTracks, R.string.stats_show_grade_elevation_key, true);
EndToEndTestUtils.SOLO.clickOnText(tracksName); EndToEndTestUtils.SOLO.clickOnText(TRACK_NAME);
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
EndToEndTestUtils.SOLO.waitForActivity(TrackDetailActivity.class, EndToEndTestUtils.SOLO.waitForActivity(TrackDetailActivity.class,
EndToEndTestUtils.LONG_WAIT_TIME); EndToEndTestUtils.LONG_WAIT_TIME);
@@ -417,9 +419,9 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
// KM/H // KM/H
float averageSpeed = distance * 3600 / timeSpan; float averageSpeed = distance * 3600 / timeSpan;
assertEquals(Float.parseFloat(minAltitude), minAltitudeActual); assertEquals(Float.parseFloat(MIN_ALTITUDE), minAltitudeActual);
assertEquals(Float.parseFloat(maxAltitude), maxAltitudeActual); assertEquals(Float.parseFloat(MAX_ALTITUDE), maxAltitudeActual);
Log.i(EndToEndTestUtils.LOG_TAG, distance + ":" + distanceActual); Log.d(TAG, distance + ":" + distanceActual);
assertTrue((distance - distanceActual) / distance < acceptDeviation); assertTrue((distance - distanceActual) / distance < acceptDeviation);
assertTrue((averageSpeed - averageSpeedActual) / averageSpeed < acceptDeviation); assertTrue((averageSpeed - averageSpeedActual) / averageSpeed < acceptDeviation);
@@ -430,7 +432,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
* Writes a GPX track file to MyTracks folder. * Writes a GPX track file to MyTracks folder.
*/ */
private void writeGPXTrackFile() { private void writeGPXTrackFile() {
String fileName = tracksName + ".gpx"; String fileName = TRACK_NAME + ".gpx";
String fileContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " String fileContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> "
+ "<gpx " + "<gpx "
+ "version=\"1.1\" " + "version=\"1.1\" "
@@ -446,7 +448,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
+ "<type><![CDATA[TestActivity]]></type> " + "<type><![CDATA[TestActivity]]></type> "
+ "<extensions><topografix:color>c0c0c0</topografix:color></extensions> " + "<trkseg> " + "<extensions><topografix:color>c0c0c0</topografix:color></extensions> " + "<trkseg> "
+ "<trkpt lat=\"39.30\" lon=\"116\"> " + "<time>2013-07-10T08:00:00.000Z</time> <ele>" + "<trkpt lat=\"39.30\" lon=\"116\"> " + "<time>2013-07-10T08:00:00.000Z</time> <ele>"
+ minAltitude + MIN_ALTITUDE
+ "</ele>" + "</ele>"
+ "</trkpt> " + "</trkpt> "
+ "<trkpt lat=\"39.2995\" lon=\"116.0005\"> " + "<trkpt lat=\"39.2995\" lon=\"116.0005\"> "
@@ -475,13 +477,13 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
+ "</trkpt> " + "</trkpt> "
+ "<trkpt lat=\"39.2955\" lon=\"116.0045\"> " + "<trkpt lat=\"39.2955\" lon=\"116.0045\"> "
+ "<time>2013-07-10T08:00:09.000Z</time> <ele>" + "<time>2013-07-10T08:00:09.000Z</time> <ele>"
+ maxAltitude + MAX_ALTITUDE
+ "</ele>" + "</ele>"
+ "</trkpt> " + "</trkpt> "
+ "</trkseg> " + "</trk> " + "</gpx>"; + "</trkseg> " + "</trk> " + "</gpx>";
try { try {
File file = new File(FileUtils.getPath(EndToEndTestUtils.GPX.toLowerCase()) + File.separator File file = new File(FileUtils.getPath(EndToEndTestUtils.GPX) + File.separator
+ fileName); + fileName);
FileOutputStream fop = new FileOutputStream(file); FileOutputStream fop = new FileOutputStream(file);
// if file doesnt exists, then create it // if file doesnt exists, then create it
@@ -493,7 +495,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
fop.write(contentInBytes); fop.write(contentInBytes);
fop.flush(); fop.flush();
fop.close(); fop.close();
Log.i(EndToEndTestUtils.LOG_TAG, file.getAbsolutePath()); Log.d(TAG, file.getAbsolutePath());
} catch (IOException e) { } catch (IOException e) {
fail(); fail();
} }
@@ -81,7 +81,7 @@ public class ExportSingleTrackTest extends ActivityInstrumentationTestCase2<Trac
String testActivity = "(TestActivity)"; String testActivity = "(TestActivity)";
EndToEndTestUtils.activityType = testActivity; EndToEndTestUtils.activityType = testActivity;
GoogleUtils.deleteSpreadsheets( GoogleUtils.deleteSpreadsheets(
EndToEndTestUtils.activityMytracks.getApplicationContext(), GoogleUtils.ACCOUNT_1); EndToEndTestUtils.trackListActivity.getApplicationContext(), GoogleUtils.ACCOUNT_1);
EndToEndTestUtils.createSimpleTrack(1, false); EndToEndTestUtils.createSimpleTrack(1, false);
boolean result = sendToGoogle(activityMyTracks.getString(R.string.export_google_maps)) boolean result = sendToGoogle(activityMyTracks.getString(R.string.export_google_maps))
&& sendToGoogle(activityMyTracks.getString(R.string.export_google_fusion_tables)) && sendToGoogle(activityMyTracks.getString(R.string.export_google_fusion_tables))
@@ -188,7 +188,7 @@ public class ExportSingleTrackTest extends ActivityInstrumentationTestCase2<Trac
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
EndToEndTestUtils.activityType = EndToEndTestUtils.DEFAULTACTIVITYTYPE; EndToEndTestUtils.activityType = EndToEndTestUtils.DEFAULT_ACTIVITY_TYPE;
EndToEndTestUtils.SOLO.finishOpenedActivities(); EndToEndTestUtils.SOLO.finishOpenedActivities();
super.tearDown(); super.tearDown();
} }
@@ -37,6 +37,8 @@ import java.util.ArrayList;
*/ */
public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActivity> { public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
private static final String TAG = SettingTest.class.getSimpleName();
private Instrumentation instrumentation; private Instrumentation instrumentation;
private TrackListActivity activityMyTracks; private TrackListActivity activityMyTracks;
@@ -116,7 +118,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
activityMyTracks.getString(R.string.settings_stats_units_title), 1, activityMyTracks.getString(R.string.settings_stats_units_title), 1,
EndToEndTestUtils.LONG_WAIT_TIME)); EndToEndTestUtils.LONG_WAIT_TIME));
displayCheckBoxs = EndToEndTestUtils.SOLO.getCurrentViews(CheckBox.class); displayCheckBoxs = EndToEndTestUtils.SOLO.getCurrentViews(CheckBox.class);
Log.i(EndToEndTestUtils.LOG_TAG, "useMetric:" + useMetric); Log.d(TAG, "useMetric:" + useMetric);
assertEquals(useMetric, displayCheckBoxs.get(0).isChecked()); assertEquals(useMetric, displayCheckBoxs.get(0).isChecked());
EndToEndTestUtils.SOLO.goBack(); EndToEndTestUtils.SOLO.goBack();
@@ -113,7 +113,7 @@ public class ShareTest extends ActivityInstrumentationTestCase2<TrackListActivit
EndToEndTestUtils.SOLO.goBack(); EndToEndTestUtils.SOLO.goBack();
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_2); SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_2);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
assertTrue(EndToEndTestUtils.SOLO.waitForText( assertTrue(EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.track_list_shared_with_me), 1, activityMyTracks.getString(R.string.track_list_shared_with_me), 1,
@@ -20,6 +20,7 @@ import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
import com.google.android.apps.mytracks.fragments.MyTracksMapFragment; import com.google.android.apps.mytracks.fragments.MyTracksMapFragment;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.annotation.SuppressLint;
import android.app.Instrumentation; import android.app.Instrumentation;
import android.graphics.Point; import android.graphics.Point;
import android.os.Build; import android.os.Build;
@@ -38,6 +39,7 @@ import junit.framework.Assert;
*/ */
public class ViewsTest extends ActivityInstrumentationTestCase2<TrackListActivity> { public class ViewsTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
private static final String TAG = ViewsTest.class.getSimpleName();
private Instrumentation instrumentation; private Instrumentation instrumentation;
private TrackListActivity activityMyTracks; private TrackListActivity activityMyTracks;
@@ -140,6 +142,7 @@ public class ViewsTest extends ActivityInstrumentationTestCase2<TrackListActivit
* Checks the position of track controller in landscape view and portrait * Checks the position of track controller in landscape view and portrait
* view. * view.
*/ */
@SuppressLint("NewApi")
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void checkTrackController() { private void checkTrackController() {
View controller = EndToEndTestUtils.SOLO.getCurrentActivity().findViewById( View controller = EndToEndTestUtils.SOLO.getCurrentActivity().findViewById(
@@ -157,7 +160,7 @@ public class ViewsTest extends ActivityInstrumentationTestCase2<TrackListActivit
int width = size.x; int width = size.x;
int height = size.y; int height = size.y;
Log.i(EndToEndTestUtils.LOG_TAG, width + ":" + height); Log.d(TAG, width + ":" + height);
// In landscape view // In landscape view
if (width > height) { if (width > height) {
@@ -169,7 +172,7 @@ public class ViewsTest extends ActivityInstrumentationTestCase2<TrackListActivit
// In portrait view // In portrait view
else { else {
Assert.assertTrue(controller.getWidth() > controller.getHeight()); Assert.assertTrue(controller.getWidth() > controller.getHeight());
Log.i(EndToEndTestUtils.LOG_TAG, controller.getTop() + ":" + controller.getRight()); Log.d(TAG, controller.getTop() + ":" + controller.getRight());
Assert.assertTrue(controller.getTop() > height / 2); Assert.assertTrue(controller.getTop() > height / 2);
Assert.assertTrue(controller.getRight() > width / 2); Assert.assertTrue(controller.getRight() > width / 2);
@@ -18,6 +18,7 @@ import java.io.FileOutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import junit.framework.Assert; import junit.framework.Assert;
@@ -34,6 +35,8 @@ public class BigTestUtils {
public static final String MYTRACKS_PROCESS_NAME = "com.google.android.maps.mytracks"; public static final String MYTRACKS_PROCESS_NAME = "com.google.android.maps.mytracks";
public static final String MYTRACKS_TEST_INFO_FILE = "MyTracksTestInfo.txt"; public static final String MYTRACKS_TEST_INFO_FILE = "MyTracksTestInfo.txt";
private static final String TAG = BigTestUtils.class.getSimpleName();
/** /**
* Gets the memory usage of MyTracks process. This method would get the Pss * Gets the memory usage of MyTracks process. This method would get the Pss
* memory. Pss is the amount of memory shared with other processes, accounted * memory. Pss is the amount of memory shared with other processes, accounted
@@ -62,7 +65,7 @@ public class BigTestUtils {
int pids[] = { MyTracksProcessId }; int pids[] = { MyTracksProcessId };
android.os.Debug.MemoryInfo[] memoryInfoArray = activityManager.getProcessMemoryInfo(pids); android.os.Debug.MemoryInfo[] memoryInfoArray = activityManager.getProcessMemoryInfo(pids);
int memoryUsage = memoryInfoArray[0].getTotalPss(); int memoryUsage = memoryInfoArray[0].getTotalPss();
return String.format(" MyTracks TotalPss Memory: %d (kB) ", memoryUsage); return String.format(Locale.US, " MyTracks TotalPss Memory: %d (kB) ", memoryUsage);
} }
/** /**
@@ -100,7 +103,7 @@ public class BigTestUtils {
osw.close(); osw.close();
} }
} catch (Exception e) { } catch (Exception e) {
Log.i(EndToEndTestUtils.LOG_TAG, "Meet error when write test info to file."); Log.e(TAG, "Meet error when write test info to file.", e);
} }
return; return;
} }
@@ -123,7 +126,7 @@ public class BigTestUtils {
String.format("{%1$tm/%1$td/%1$tY %1$tH:%1$tM:%1$tS", new Date()), memoryUsageString, String.format("{%1$tm/%1$td/%1$tY %1$tH:%1$tM:%1$tS", new Date()), memoryUsageString,
batteryUsageString); batteryUsageString);
writeToFile(oneInfo, true); writeToFile(oneInfo, true);
Log.i(EndToEndTestUtils.LOG_TAG, oneInfo); Log.d(TAG, oneInfo);
EndToEndTestUtils.sleep(interval); EndToEndTestUtils.sleep(interval);
} }
} }
@@ -145,8 +148,7 @@ public class BigTestUtils {
}); });
} catch (Exception e) { } catch (Exception e) {
Log.i(EndToEndTestUtils.LOG_TAG, Log.e(TAG, "Meet error when unlock device screen, may the device is not locked.", e);
"Meet error when unlock device screen, may the device is not locked.");
} }
} }
@@ -37,6 +37,8 @@ import android.util.Log;
*/ */
public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackListActivity> { public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
private static final String TAG = ResourceUsageTest.class.getSimpleName();
public ResourceUsageTest() { public ResourceUsageTest() {
super(TrackListActivity.class); super(TrackListActivity.class);
} }
@@ -102,7 +104,7 @@ public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackLis
} }
}); });
} catch (Throwable e) { } catch (Throwable e) {
Log.i(EndToEndTestUtils.LOG_TAG, "Meet error when create confirm dialog."); Log.e(TAG, "Meet error when create confirm dialog.", e);
} }
// Waiting user confirm the testing // Waiting user confirm the testing
while (!isUserConfirmed) { while (!isUserConfirmed) {
@@ -148,7 +150,7 @@ public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackLis
*/ */
public void recordingLongTrack(boolean isShowTracksList, int tabNameId) { public void recordingLongTrack(boolean isShowTracksList, int tabNameId) {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
@@ -35,6 +35,10 @@ import java.util.ArrayList;
*/ */
public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivity> { public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
private static final String TAG = SensorTest.class.getSimpleName();
private static final String ZEPHYR_NAME = "HXM";
private static final String POLAR_NAME = "Polar";
public SensorTest() { public SensorTest() {
super(TrackListActivity.class); super(TrackListActivity.class);
} }
@@ -42,8 +46,6 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
private Instrumentation instrumentation; private Instrumentation instrumentation;
private TrackListActivity trackListActivity; private TrackListActivity trackListActivity;
private boolean runTest = false; private boolean runTest = false;
private static final String ZEPHYR_NAME = "HXM";
private static final String POLAR_NAME = "Polar";
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
@@ -63,7 +65,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testConnectZephyrBluetoothSensor_notRecording() { public void testConnectZephyrBluetoothSensor_notRecording() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
bluetoothSensorTest(R.string.settings_sensor_type_zephyr, ZEPHYR_NAME, false); bluetoothSensorTest(R.string.settings_sensor_type_zephyr, ZEPHYR_NAME, false);
@@ -75,7 +77,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testConnectZephyrBluetoothSensor_underRecording() { public void testConnectZephyrBluetoothSensor_underRecording() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
bluetoothSensorTest(R.string.settings_sensor_type_zephyr, ZEPHYR_NAME, true); bluetoothSensorTest(R.string.settings_sensor_type_zephyr, ZEPHYR_NAME, true);
@@ -87,7 +89,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testConnectPolarBluetoothSensor_notRecording() { public void testConnectPolarBluetoothSensor_notRecording() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
bluetoothSensorTest(R.string.settings_sensor_type_polar, POLAR_NAME, false); bluetoothSensorTest(R.string.settings_sensor_type_polar, POLAR_NAME, false);
@@ -99,7 +101,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testConnectPolarBluetoothSensor_underRecording() { public void testConnectPolarBluetoothSensor_underRecording() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
bluetoothSensorTest(R.string.settings_sensor_type_polar, POLAR_NAME, true); bluetoothSensorTest(R.string.settings_sensor_type_polar, POLAR_NAME, true);
@@ -145,7 +147,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
return; return;
} }
Log.i(EndToEndTestUtils.LOG_TAG, "No sensor is paried"); Log.d(TAG, "No sensor is paried");
fail("No bluetooth sensor is paired. Please pair at Settings->Bluetooth before running the test."); fail("No bluetooth sensor is paired. Please pair at Settings->Bluetooth before running the test.");
} }
@@ -154,7 +156,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testConnectANTSensor_Cadence() { public void testConnectANTSensor_Cadence() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
useANTSeonsor(); useANTSeonsor();
@@ -167,7 +169,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testConnectTwoANTSensors() { public void testConnectTwoANTSensors() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
useANTSeonsor(); useANTSeonsor();
@@ -32,6 +32,7 @@ import android.widget.ListView;
*/ */
public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivity> { public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
private static final String TAG = StressTest.class.getSimpleName();
private static final int TEST_DURATION_IN_MILLISECONDS = 30 * 60 * 1000; private static final int TEST_DURATION_IN_MILLISECONDS = 30 * 60 * 1000;
private static final int MAX_TRACK_NUMBER = 30; private static final int MAX_TRACK_NUMBER = 30;
private boolean runTest = false; private boolean runTest = false;
@@ -67,7 +68,7 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testRecordAndDeleteTracks() { public void testRecordAndDeleteTracks() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
for (int i = 0; (System.currentTimeMillis() - startTime) < TEST_DURATION_IN_MILLISECONDS; i++) { for (int i = 0; (System.currentTimeMillis() - startTime) < TEST_DURATION_IN_MILLISECONDS; i++) {
@@ -91,14 +92,14 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testRotateMapViewInTrackDetailActivity() { public void testRotateMapViewInTrackDetailActivity() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
EndToEndTestUtils.startRecording(); EndToEndTestUtils.startRecording();
for (int i = 0; (System.currentTimeMillis() - startTime) < TEST_DURATION_IN_MILLISECONDS; i++) { for (int i = 0; (System.currentTimeMillis() - startTime) < TEST_DURATION_IN_MILLISECONDS; i++) {
EndToEndTestUtils.sendGps(10, i * 10); EndToEndTestUtils.sendGps(10, i * 10);
EndToEndTestUtils.rotateCurrentActivity(); EndToEndTestUtils.rotateCurrentActivity();
Log.i(EndToEndTestUtils.LOG_TAG, String.format("Totate %d times in %d minutes!", i, Log.d(TAG, String.format("Totate %d times in %d minutes!", i,
(System.currentTimeMillis() - startTime) / 1000 / 60)); (System.currentTimeMillis() - startTime) / 1000 / 60));
} }
} }
@@ -108,7 +109,7 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testSwitchTabs() { public void testSwitchTabs() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
EndToEndTestUtils.startRecording(); EndToEndTestUtils.startRecording();
@@ -133,7 +134,7 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testRecordLongTrack() { public void testRecordLongTrack() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
EndToEndTestUtils.startRecording(); EndToEndTestUtils.startRecording();
@@ -150,7 +151,7 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
*/ */
public void testSwitchTabs_wayPoints() { public void testSwitchTabs_wayPoints() {
if (!runTest) { if (!runTest) {
Log.i(EndToEndTestUtils.LOG_TAG, BigTestUtils.DISABLE_MESSAGE); Log.d(TAG, BigTestUtils.DISABLE_MESSAGE);
return; return;
} }
EndToEndTestUtils.startRecording(); EndToEndTestUtils.startRecording();
@@ -186,9 +187,11 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
* @param times the number of times this test has been run * @param times the number of times this test has been run
*/ */
private void logStatus(int times) { private void logStatus(int times) {
int minutes = (int) (TEST_DURATION_IN_MILLISECONDS - (System.currentTimeMillis() - startTime)) / 60 / 1000; int minutes =
Log.i(EndToEndTestUtils.LOG_TAG, String.format( (int) (TEST_DURATION_IN_MILLISECONDS - (System.currentTimeMillis() - startTime)) / 60
/ 1000;
Log.d(TAG, String.format(
"This test has run %d times and will be finished in %d minutes!", times, minutes)); "This test has run %d times and will be finished in %d minutes!", times, minutes));
Log.i(EndToEndTestUtils.LOG_TAG, String.format("There are %d tracks!", numberOfTracks)); Log.d(TAG, String.format("There are %d tracks!", numberOfTracks));
} }
} }
@@ -49,7 +49,7 @@ public class MultiAccountsSyncTest extends ActivityInstrumentationTestCase2<Trac
SyncTestUtils.setUpForSyncTest(instrumentation, trackListActivity); SyncTestUtils.setUpForSyncTest(instrumentation, trackListActivity);
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1); SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1);
drive = SyncTestUtils drive = SyncTestUtils
.getGoogleDrive(EndToEndTestUtils.activityMytracks.getApplicationContext()); .getGoogleDrive(EndToEndTestUtils.trackListActivity.getApplicationContext());
} }
/** /**
@@ -81,14 +81,14 @@ public class MultiAccountsSyncTest extends ActivityInstrumentationTestCase2<Trac
// Sync with Google Drive and then check it of the second account. // Sync with Google Drive and then check it of the second account.
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
drive = SyncTestUtils.getGoogleDrive(trackListActivity.getApplicationContext()); drive = SyncTestUtils.getGoogleDrive(trackListActivity.getApplicationContext());
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
// Check Google Drive of the first account. // Check Google Drive of the first account.
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1); SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
drive = SyncTestUtils.getGoogleDrive(trackListActivity.getApplicationContext()); drive = SyncTestUtils.getGoogleDrive(trackListActivity.getApplicationContext());
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
@@ -122,31 +122,31 @@ public class MultiAccountsSyncTest extends ActivityInstrumentationTestCase2<Trac
EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getCurrentViews(ListView.class) EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getCurrentViews(ListView.class)
.get(0).getChildAt(0)); .get(0).getChildAt(0));
EndToEndTestUtils.instrumentation.waitForIdleSync(); EndToEndTestUtils.instrumentation.waitForIdleSync();
EndToEndTestUtils.SOLO.clickOnMenuItem(EndToEndTestUtils.activityMytracks EndToEndTestUtils.SOLO.clickOnMenuItem(EndToEndTestUtils.trackListActivity
.getString(R.string.menu_delete)); .getString(R.string.menu_delete));
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.activityMytracks EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.trackListActivity
.getString(R.string.generic_yes)); .getString(R.string.generic_yes));
// Switch account and delete another track. // Switch account and delete another track.
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_2); SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_2);
EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getCurrentViews(ListView.class) EndToEndTestUtils.SOLO.clickOnView(EndToEndTestUtils.SOLO.getCurrentViews(ListView.class)
.get(0).getChildAt(0)); .get(0).getChildAt(0));
EndToEndTestUtils.SOLO.clickOnMenuItem(EndToEndTestUtils.activityMytracks EndToEndTestUtils.SOLO.clickOnMenuItem(EndToEndTestUtils.trackListActivity
.getString(R.string.menu_delete)); .getString(R.string.menu_delete));
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.activityMytracks EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.trackListActivity
.getString(R.string.generic_yes)); .getString(R.string.generic_yes));
// Check Google Drive of the first account. // Check Google Drive of the first account.
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1); SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
drive = SyncTestUtils.getGoogleDrive(trackListActivity.getApplicationContext()); drive = SyncTestUtils.getGoogleDrive(trackListActivity.getApplicationContext());
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
// Check Google Drive of the second account. // Check Google Drive of the second account.
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_2); SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_2);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
drive = SyncTestUtils.getGoogleDrive(trackListActivity.getApplicationContext()); drive = SyncTestUtils.getGoogleDrive(trackListActivity.getApplicationContext());
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
} }
@@ -52,7 +52,7 @@ public class SyncDriveWithMyTracksTest extends ActivityInstrumentationTestCase2<
SyncTestUtils.setUpForSyncTest(instrumentation, trackListActivity); SyncTestUtils.setUpForSyncTest(instrumentation, trackListActivity);
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1); SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1);
drive = SyncTestUtils drive = SyncTestUtils
.getGoogleDrive(EndToEndTestUtils.activityMytracks.getApplicationContext()); .getGoogleDrive(EndToEndTestUtils.trackListActivity.getApplicationContext());
} }
/** /**
@@ -65,7 +65,7 @@ public class SyncDriveWithMyTracksTest extends ActivityInstrumentationTestCase2<
return; return;
} }
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
} }
@@ -79,12 +79,12 @@ public class SyncDriveWithMyTracksTest extends ActivityInstrumentationTestCase2<
return; return;
} }
EndToEndTestUtils.createTrackIfEmpty(2, false); EndToEndTestUtils.createTrackIfEmpty(2, false);
EndToEndTestUtils.SOLO.clickOnMenuItem(EndToEndTestUtils.activityMytracks EndToEndTestUtils.SOLO.clickOnMenuItem(EndToEndTestUtils.trackListActivity
.getString(R.string.menu_delete)); .getString(R.string.menu_delete));
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.activityMytracks EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.trackListActivity
.getString(R.string.generic_yes)); .getString(R.string.generic_yes));
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkFile(EndToEndTestUtils.trackName, false, drive); SyncTestUtils.checkFile(EndToEndTestUtils.trackName, false, drive);
} }
@@ -101,7 +101,7 @@ public class SyncDriveWithMyTracksTest extends ActivityInstrumentationTestCase2<
EndToEndTestUtils.createSimpleTrack(0, true); EndToEndTestUtils.createSimpleTrack(0, true);
EndToEndTestUtils.createSimpleTrack(3, true); EndToEndTestUtils.createSimpleTrack(3, true);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
} }
@@ -118,7 +118,7 @@ public class SyncDriveWithMyTracksTest extends ActivityInstrumentationTestCase2<
// Sync this track. // Sync this track.
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkFile(EndToEndTestUtils.trackName, true, drive); SyncTestUtils.checkFile(EndToEndTestUtils.trackName, true, drive);
String oldTrack = SyncTestUtils.getContentOfFile( String oldTrack = SyncTestUtils.getContentOfFile(
SyncTestUtils.getFile(EndToEndTestUtils.trackName, drive), drive); SyncTestUtils.getFile(EndToEndTestUtils.trackName, drive), drive);
@@ -144,7 +144,7 @@ public class SyncDriveWithMyTracksTest extends ActivityInstrumentationTestCase2<
// Sync again. // Sync again.
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
// Check. // Check.
SyncTestUtils.checkFile(oldTrackName, false, drive); SyncTestUtils.checkFile(oldTrackName, false, drive);
@@ -52,7 +52,7 @@ public class SyncMyTracksWithDriveTest extends ActivityInstrumentationTestCase2<
SyncTestUtils.setUpForSyncTest(instrumentation, trackListActivity); SyncTestUtils.setUpForSyncTest(instrumentation, trackListActivity);
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1); SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1);
drive = SyncTestUtils drive = SyncTestUtils
.getGoogleDrive(EndToEndTestUtils.activityMytracks.getApplicationContext()); .getGoogleDrive(EndToEndTestUtils.trackListActivity.getApplicationContext());
} }
/** /**
@@ -66,12 +66,12 @@ public class SyncMyTracksWithDriveTest extends ActivityInstrumentationTestCase2<
} }
EndToEndTestUtils.createTrackIfEmpty(0, true); EndToEndTestUtils.createTrackIfEmpty(0, true);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
SyncTestUtils.removeKMLFiles(drive); SyncTestUtils.removeKMLFiles(drive);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkTracksNumber(0); SyncTestUtils.checkTracksNumber(0);
} }
@@ -88,14 +88,14 @@ public class SyncMyTracksWithDriveTest extends ActivityInstrumentationTestCase2<
EndToEndTestUtils.createSimpleTrack(0, true); EndToEndTestUtils.createSimpleTrack(0, true);
EndToEndTestUtils.createSimpleTrack(0, true); EndToEndTestUtils.createSimpleTrack(0, true);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
// Remove one track from Google Drive // Remove one track from Google Drive
File file = SyncTestUtils.getFile(EndToEndTestUtils.trackName, drive); File file = SyncTestUtils.getFile(EndToEndTestUtils.trackName, drive);
SyncTestUtils.removeFile(file, drive); SyncTestUtils.removeFile(file, drive);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
SyncTestUtils.checkTracksNumber(1); SyncTestUtils.checkTracksNumber(1);
} }
@@ -113,7 +113,7 @@ public class SyncMyTracksWithDriveTest extends ActivityInstrumentationTestCase2<
EndToEndTestUtils.createSimpleTrack(0, true); EndToEndTestUtils.createSimpleTrack(0, true);
EndToEndTestUtils.createSimpleTrack(0, true); EndToEndTestUtils.createSimpleTrack(0, true);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
File folder = SyncUtils.getMyTracksFolder(trackListActivity.getApplicationContext(), drive); File folder = SyncUtils.getMyTracksFolder(trackListActivity.getApplicationContext(), drive);
@@ -121,7 +121,7 @@ public class SyncMyTracksWithDriveTest extends ActivityInstrumentationTestCase2<
SyncTestUtils.removeFile(folder, drive); SyncTestUtils.removeFile(folder, drive);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
SyncTestUtils.checkFilesNumber(drive); SyncTestUtils.checkFilesNumber(drive);
} }
} }
@@ -52,6 +52,7 @@ import junit.framework.Assert;
*/ */
public class SyncTestUtils { public class SyncTestUtils {
private static final String TAG = SyncTestUtils.class.getSimpleName();
public static boolean isCheckedRunSyncTest = false; public static boolean isCheckedRunSyncTest = false;
public static final String KML_FILE_POSTFIX = ".kml"; public static final String KML_FILE_POSTFIX = ".kml";
public static final long MAX_TIME_TO_WAIT_SYNC = 100000; public static final long MAX_TIME_TO_WAIT_SYNC = 100000;
@@ -72,14 +73,12 @@ public class SyncTestUtils {
isCheckedRunSyncTest = true; isCheckedRunSyncTest = true;
} }
if (RunConfiguration.getInstance().getRunSyncTest()) { if (RunConfiguration.getInstance().getRunSyncTest()) {
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_1); enableSync(GoogleUtils.ACCOUNT_1);
Drive drive1 = SyncTestUtils.getGoogleDrive(EndToEndTestUtils.activityMytracks Drive drive1 = getGoogleDrive(EndToEndTestUtils.trackListActivity.getApplicationContext());
.getApplicationContext());
removeKMLFiles(drive1); removeKMLFiles(drive1);
EndToEndTestUtils.deleteAllTracks(); EndToEndTestUtils.deleteAllTracks();
SyncTestUtils.enableSync(GoogleUtils.ACCOUNT_2); enableSync(GoogleUtils.ACCOUNT_2);
Drive drive2 = SyncTestUtils.getGoogleDrive(EndToEndTestUtils.activityMytracks Drive drive2 = getGoogleDrive(EndToEndTestUtils.trackListActivity.getApplicationContext());
.getApplicationContext());
removeKMLFiles(drive2); removeKMLFiles(drive2);
EndToEndTestUtils.deleteAllTracks(); EndToEndTestUtils.deleteAllTracks();
return drive2; return drive2;
@@ -129,7 +128,7 @@ public class SyncTestUtils {
* @throws IOException * @throws IOException
*/ */
public static File getFile(String trackName, Drive drive) throws IOException { public static File getFile(String trackName, Drive drive) throws IOException {
List<File> files = getDriveFiles(EndToEndTestUtils.activityMytracks.getApplicationContext(), List<File> files = getDriveFiles(EndToEndTestUtils.trackListActivity.getApplicationContext(),
drive); drive);
for (int i = 0; i < files.size(); i++) { for (int i = 0; i < files.size(); i++) {
File file = files.get(i); File file = files.get(i);
@@ -148,8 +147,8 @@ public class SyncTestUtils {
* @throws IOException * @throws IOException
*/ */
public static void removeKMLFiles(Drive drive) throws IOException { public static void removeKMLFiles(Drive drive) throws IOException {
List<File> files = SyncTestUtils.getDriveFiles( List<File> files = getDriveFiles(
EndToEndTestUtils.activityMytracks.getApplicationContext(), drive); EndToEndTestUtils.trackListActivity.getApplicationContext(), drive);
for (int i = 0; i < files.size(); i++) { for (int i = 0; i < files.size(); i++) {
File file = files.get(i); File file = files.get(i);
removeFile(file, drive); removeFile(file, drive);
@@ -229,7 +228,7 @@ public class SyncTestUtils {
EndToEndTestUtils.instrumentation.waitForIdleSync(); EndToEndTestUtils.instrumentation.waitForIdleSync();
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
int trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount(); int trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount();
List<File> files = getDriveFiles(EndToEndTestUtils.activityMytracks.getApplicationContext(), List<File> files = getDriveFiles(EndToEndTestUtils.trackListActivity.getApplicationContext(),
drive); drive);
while (System.currentTimeMillis() - startTime < MAX_TIME_TO_WAIT_SYNC) { while (System.currentTimeMillis() - startTime < MAX_TIME_TO_WAIT_SYNC) {
try { try {
@@ -237,12 +236,12 @@ public class SyncTestUtils {
return; return;
} }
trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount(); trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount();
files = getDriveFiles(EndToEndTestUtils.activityMytracks.getApplicationContext(), drive); files = getDriveFiles(EndToEndTestUtils.trackListActivity.getApplicationContext(), drive);
EndToEndTestUtils.sleep(EndToEndTestUtils.SHORT_WAIT_TIME); EndToEndTestUtils.sleep(EndToEndTestUtils.SHORT_WAIT_TIME);
EndToEndTestUtils.findMenuItem( EndToEndTestUtils.findMenuItem(
EndToEndTestUtils.activityMytracks.getString(R.string.menu_sync_now), true); EndToEndTestUtils.trackListActivity.getString(R.string.menu_sync_now), true);
} catch (GoogleJsonResponseException e) { } catch (GoogleJsonResponseException e) {
Log.i(EndToEndTestUtils.LOG_TAG, e.getMessage()); Log.e(TAG, e.getMessage(), e);
} }
} }
Assert.assertEquals(files.size(), trackNumber); Assert.assertEquals(files.size(), trackNumber);
@@ -261,7 +260,7 @@ public class SyncTestUtils {
return; return;
} }
trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount(); trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount();
Log.i(EndToEndTestUtils.LOG_TAG, trackNumber + ":" + number); Log.d(TAG, trackNumber + ":" + number);
} }
Assert.assertEquals(trackNumber, number); Assert.assertEquals(trackNumber, number);
} }