forked from upstream-mirrors/OpenTracks
Add a stress test case. Switch views when track has mwrkers.
This commit is contained in:
+1
-19
@@ -32,7 +32,6 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
||||||
|
|
||||||
private static final String WAYPOINT_NAME = "testWaypoint";
|
|
||||||
private Instrumentation instrumentation;
|
private Instrumentation instrumentation;
|
||||||
private TrackListActivity activityMyTracks;
|
private TrackListActivity activityMyTracks;
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListA
|
|||||||
.getString(R.string.generic_recording)));
|
.getString(R.string.generic_recording)));
|
||||||
}
|
}
|
||||||
|
|
||||||
createWaypoint();
|
EndToEndTestUtils.createWaypoint(0);
|
||||||
EndToEndTestUtils.sendGps(2, 2);
|
EndToEndTestUtils.sendGps(2, 2);
|
||||||
// Back to tracks list.
|
// Back to tracks list.
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
@@ -206,23 +205,6 @@ public class CreateTrackTest extends ActivityInstrumentationTestCase2<TrackListA
|
|||||||
|
|
||||||
EndToEndTestUtils.stopRecording(true);
|
EndToEndTestUtils.stopRecording(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a way point and a split maker during track recording.
|
|
||||||
*/
|
|
||||||
private void createWaypoint() {
|
|
||||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_markers), true);
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks.getString(R.string.marker_list_empty_message)));
|
|
||||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_insert_marker), true);
|
|
||||||
EndToEndTestUtils.enterTextAvoidSoftKeyBoard(0, WAYPOINT_NAME);
|
|
||||||
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_add));
|
|
||||||
if (EndToEndTestUtils.hasGpsSingal) {
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(WAYPOINT_NAME, 1, EndToEndTestUtils.LONG_WAIT_TIME, true));
|
|
||||||
} else {
|
|
||||||
assertFalse(EndToEndTestUtils.SOLO.searchText(WAYPOINT_NAME));
|
|
||||||
}
|
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
|||||||
+33
-3
@@ -66,6 +66,7 @@ public class EndToEndTestUtils {
|
|||||||
static final double START_LATITUDE = -1.3f;
|
static final double START_LATITUDE = -1.3f;
|
||||||
static final double DELTA_LONGITUDE = 0.0005f;
|
static final double DELTA_LONGITUDE = 0.0005f;
|
||||||
static final double DELTA_LADITUDE = 0.0005f;
|
static final double DELTA_LADITUDE = 0.0005f;
|
||||||
|
private static final String WAYPOINT_NAME = "testWaypoint";
|
||||||
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 MOREOPTION_CLASSNAME = "com.android.internal.view.menu.ActionMenuPresenter$OverflowMenuButton";
|
||||||
@@ -250,6 +251,9 @@ public class EndToEndTestUtils {
|
|||||||
EndToEndTestUtils.instrumentation = instrumentation;
|
EndToEndTestUtils.instrumentation = instrumentation;
|
||||||
EndToEndTestUtils.activityMytracks = activityMyTracks;
|
EndToEndTestUtils.activityMytracks = activityMyTracks;
|
||||||
SOLO = new Solo(EndToEndTestUtils.instrumentation, EndToEndTestUtils.activityMytracks);
|
SOLO = new Solo(EndToEndTestUtils.instrumentation, EndToEndTestUtils.activityMytracks);
|
||||||
|
setIsEmulator();
|
||||||
|
hasActionBar = setHasActionBar();
|
||||||
|
checkLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -280,7 +284,7 @@ public class EndToEndTestUtils {
|
|||||||
Log.e(LOG_TAG, "Need update Google Play Services");
|
Log.e(LOG_TAG, "Need update Google Play Services");
|
||||||
}
|
}
|
||||||
setIsEmulator();
|
setIsEmulator();
|
||||||
if ((getButtonOnScreen(EndToEndTestUtils.activityMytracks.getString(R.string.eula_accept),
|
if ((getButtonOnScreen(activityMytracks.getString(R.string.eula_accept),
|
||||||
false, false) != null)) {
|
false, false) != null)) {
|
||||||
verifyFirstLaunch();
|
verifyFirstLaunch();
|
||||||
} else if (SOLO.waitForText(
|
} else if (SOLO.waitForText(
|
||||||
@@ -299,7 +303,7 @@ public class EndToEndTestUtils {
|
|||||||
if (!isEmulator) {
|
if (!isEmulator) {
|
||||||
GoToMyLocationTest.findAndClickMyLocation(activityMyTracks);
|
GoToMyLocationTest.findAndClickMyLocation(activityMyTracks);
|
||||||
hasGpsSingal = !SOLO.waitForText(NO_GPS_MESSAGE_PREFIX, 1,
|
hasGpsSingal = !SOLO.waitForText(NO_GPS_MESSAGE_PREFIX, 1,
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME);
|
SHORT_WAIT_TIME);
|
||||||
SOLO.goBack();
|
SOLO.goBack();
|
||||||
}
|
}
|
||||||
} else if (SOLO.waitForText(
|
} else if (SOLO.waitForText(
|
||||||
@@ -730,7 +734,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 EndToEndTestUtils#MOREOPTION_CLASSNAME}.</li>
|
* <li>The view name equals {@link #MOREOPTION_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.
|
||||||
*/
|
*/
|
||||||
@@ -935,5 +939,31 @@ public class EndToEndTestUtils {
|
|||||||
.findViewById(R.id.track_controller_total_time)).getText().toString();
|
.findViewById(R.id.track_controller_total_time)).getText().toString();
|
||||||
Assert.assertTrue(totalTimeOld.equalsIgnoreCase(totalTimeNew));
|
Assert.assertTrue(totalTimeOld.equalsIgnoreCase(totalTimeNew));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a way point and a split maker during track recording.
|
||||||
|
*
|
||||||
|
* @param markerNumber of number of previous markers
|
||||||
|
*/
|
||||||
|
public static void createWaypoint(int markerNumber) {
|
||||||
|
findMenuItem(activityMytracks.getString(R.string.menu_markers), true);
|
||||||
|
if (markerNumber > 0) {
|
||||||
|
int actualMarkerNumber = SOLO.getCurrentListViews().get(0).getCount();
|
||||||
|
Assert.assertEquals(markerNumber, actualMarkerNumber);
|
||||||
|
} else {
|
||||||
|
Assert.assertTrue(SOLO.waitForText(activityMytracks
|
||||||
|
.getString(R.string.marker_list_empty_message)));
|
||||||
|
}
|
||||||
|
findMenuItem(activityMytracks.getString(R.string.menu_insert_marker), true);
|
||||||
|
enterTextAvoidSoftKeyBoard(0, WAYPOINT_NAME);
|
||||||
|
SOLO.clickOnButton(activityMytracks.getString(R.string.generic_add));
|
||||||
|
if (hasGpsSingal) {
|
||||||
|
Assert.assertTrue(SOLO.waitForText(WAYPOINT_NAME, 1, LONG_WAIT_TIME, true));
|
||||||
|
} else {
|
||||||
|
Assert.assertFalse(SOLO.searchText(WAYPOINT_NAME));
|
||||||
|
}
|
||||||
|
SOLO.goBack();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@ public class SecondaryTestUtils {
|
|||||||
* Set to false as default. True to run the test. Default to false since this
|
* Set to false as default. True to run the test. Default to false since this
|
||||||
* test can take a long time.
|
* test can take a long time.
|
||||||
*/
|
*/
|
||||||
protected static boolean runTest = false;
|
protected static boolean runTest = true;
|
||||||
|
|
||||||
protected static final String DISABLE_MESSAGE = "This test is disabled";
|
protected static final String DISABLE_MESSAGE = "This test is disabled";
|
||||||
|
|
||||||
|
|||||||
+33
-3
@@ -52,7 +52,6 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
|||||||
trackListActivity = getActivity();
|
trackListActivity = getActivity();
|
||||||
EndToEndTestUtils.setupForAllTest(instrumentation, trackListActivity);
|
EndToEndTestUtils.setupForAllTest(instrumentation, trackListActivity);
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
EndToEndTestUtils.emulatorPort = 5568;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,15 +119,46 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switches view between MAP, CHART and STAT.
|
||||||
|
*/
|
||||||
|
public void testSwitchTabs_wayPoints() {
|
||||||
|
if (!SecondaryTestUtils.runTest) {
|
||||||
|
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EndToEndTestUtils.startRecording();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while ((System.currentTimeMillis() - startTime) < TEST_DURATION_IN_MILLISECONDS) {
|
||||||
|
// Create one way points.
|
||||||
|
EndToEndTestUtils.sendGps(10, 10 * i);
|
||||||
|
EndToEndTestUtils.createWaypoint(i);
|
||||||
|
EndToEndTestUtils.pauseRecording();
|
||||||
|
|
||||||
|
EndToEndTestUtils.SOLO
|
||||||
|
.clickOnText(trackListActivity.getString(R.string.track_detail_map_tab));
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
EndToEndTestUtils.SOLO.clickOnText(trackListActivity
|
||||||
|
.getString(R.string.track_detail_chart_tab));
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
EndToEndTestUtils.SOLO.clickOnText(trackListActivity
|
||||||
|
.getString(R.string.track_detail_stats_tab));
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
EndToEndTestUtils.resumeRecording();
|
||||||
|
logStatus(++i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs status.
|
* Logs status.
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
Log.i(EndToEndTestUtils.LOG_TAG, String.format(
|
Log.i(EndToEndTestUtils.LOG_TAG, String.format(
|
||||||
"This test has run d% times and will be finished in d% millis seconds!", times,
|
"This test has run %d times and will be finished in %d minutes!", times, minutes));
|
||||||
TEST_DURATION_IN_MILLISECONDS - (System.currentTimeMillis() - startTime)));
|
|
||||||
Log.i(EndToEndTestUtils.LOG_TAG, String.format("There are %d tracks!", numberOfTracks));
|
Log.i(EndToEndTestUtils.LOG_TAG, String.format("There are %d tracks!", numberOfTracks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user