mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Add two parameters to EndToEndTestRunner to control the sensor test and stress test for these two test need long time to run.
This commit is contained in:
+30
-6
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks.endtoendtest;
|
||||
|
||||
import com.google.android.apps.mytracks.endtoendtest.others.SecondaryTestUtils;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.test.InstrumentationTestRunner;
|
||||
import android.util.Log;
|
||||
@@ -31,13 +33,35 @@ public class EndToEndTestRunner extends InstrumentationTestRunner {
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(Bundle arguments) {
|
||||
try {
|
||||
EndToEndTestUtils.emulatorPort = Integer.parseInt(arguments.getString("port"));
|
||||
} catch (Exception e) {
|
||||
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to get port parameter, use default value." + EndToEndTestUtils.emulatorPort, e);
|
||||
String portNumber = arguments.getString("port");
|
||||
if (portNumber != null) {
|
||||
try {
|
||||
EndToEndTestUtils.emulatorPort = Integer.parseInt(portNumber);
|
||||
} catch (Exception e) {
|
||||
Log.e(EndToEndTestUtils.LOG_TAG, "Unable to get port parameter, use default value."
|
||||
+ EndToEndTestUtils.emulatorPort, e);
|
||||
}
|
||||
}
|
||||
Log.d(EndToEndTestUtils.LOG_TAG, "Use port number when run test on emulator:" + EndToEndTestUtils.emulatorPort);
|
||||
|
||||
|
||||
String isStressTest = arguments.getString("stress");
|
||||
if (isStressTest != null && isStressTest.equalsIgnoreCase("true")) {
|
||||
SecondaryTestUtils.runStressTest = true;
|
||||
} else {
|
||||
SecondaryTestUtils.runStressTest = false;
|
||||
}
|
||||
|
||||
String isSensorTest = arguments.getString("sensor");
|
||||
if (isSensorTest != null && isSensorTest.equalsIgnoreCase("true")) {
|
||||
SecondaryTestUtils.runSensorTest = true;
|
||||
} else {
|
||||
SecondaryTestUtils.runSensorTest = false;
|
||||
}
|
||||
|
||||
Log.d(EndToEndTestUtils.LOG_TAG, "Use port number when run test on emulator:"
|
||||
+ EndToEndTestUtils.emulatorPort);
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, "Run stress test:" + SecondaryTestUtils.runStressTest);
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, "Run sensor test:" + SecondaryTestUtils.runSensorTest);
|
||||
|
||||
super.onCreate(arguments);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -6,7 +6,9 @@ public class SecondaryTestUtils {
|
||||
* Set to false as default. True to run the test. Default to false since this
|
||||
* test can take a long time.
|
||||
*/
|
||||
protected static boolean runTest = true;
|
||||
public static boolean runStressTest = false;
|
||||
public static boolean runSensorTest = false;
|
||||
|
||||
|
||||
protected static final String DISABLE_MESSAGE = "This test is disabled";
|
||||
|
||||
|
||||
+10
-8
@@ -40,13 +40,15 @@ 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 {
|
||||
runTest = SecondaryTestUtils.runSensorTest;
|
||||
super.setUp();
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
return;
|
||||
}
|
||||
instrumentation = getInstrumentation();
|
||||
@@ -59,7 +61,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* sensor must be paired with the device.
|
||||
*/
|
||||
public void testConnectZephyrBluetoothSensor_notRecording() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -71,7 +73,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* sensor must be paired with the device.
|
||||
*/
|
||||
public void testConnectZephyrBluetoothSensor_underRecording() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -83,7 +85,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* sensor must be paired with the device.
|
||||
*/
|
||||
public void testConnectPolarBluetoothSensor_notRecording() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -95,7 +97,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* sensor must be paired with the device.
|
||||
*/
|
||||
public void testConnectPolarBluetoothSensor_underRecording() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -150,7 +152,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* Tests connecting to a cadence ANT+ sensor.
|
||||
*/
|
||||
public void testConnectANTSensor_Cadence() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -163,7 +165,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* Tests connecting to cadence and heart rate ANT+ sensors at the same time.
|
||||
*/
|
||||
public void testConnectTwoANTSensors() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -232,7 +234,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
return;
|
||||
}
|
||||
EndToEndTestUtils.SOLO.finishOpenedActivities();
|
||||
|
||||
+8
-5
@@ -32,6 +32,8 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
|
||||
private static final int TEST_DURATION_IN_MILLISECONDS = 30 * 60 * 1000;
|
||||
private static final int MAX_TRACK_NUMBER = 30;
|
||||
private boolean runTest = false;
|
||||
|
||||
private long startTime = 0;
|
||||
private int numberOfTracks;
|
||||
|
||||
@@ -44,8 +46,9 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
runTest = SecondaryTestUtils.runStressTest;
|
||||
super.setUp();
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
return;
|
||||
}
|
||||
instrumentation = getInstrumentation();
|
||||
@@ -60,7 +63,7 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* each track, making it closer to the real stress.
|
||||
*/
|
||||
public void testRecordAndDeleteTracks() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -84,7 +87,7 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* in each track, making it closer to the real stress.
|
||||
*/
|
||||
public void testRotateMapViewInTrackDetailActivity() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -99,7 +102,7 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* Switches view between MAP, CHART and STAT.
|
||||
*/
|
||||
public void testSwitchTabs() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
@@ -123,7 +126,7 @@ public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
* Switches view between MAP, CHART and STAT.
|
||||
*/
|
||||
public void testSwitchTabs_wayPoints() {
|
||||
if (!SecondaryTestUtils.runTest) {
|
||||
if (!runTest) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SecondaryTestUtils.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user