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