forked from upstream-mirrors/OpenTracks
Change code style.
This commit is contained in:
+4
-21
@@ -27,7 +27,7 @@ import android.util.Log;
|
||||
* @author Youtao Liu
|
||||
*/
|
||||
public class EndToEndTestRunner extends InstrumentationTestRunner {
|
||||
|
||||
|
||||
/**
|
||||
* Gets the parameter port which is used to fix GPS signal to emulators.
|
||||
*/
|
||||
@@ -43,26 +43,9 @@ public class EndToEndTestRunner extends InstrumentationTestRunner {
|
||||
}
|
||||
}
|
||||
|
||||
String isStressTest = arguments.getString("stress");
|
||||
if (isStressTest != null && isStressTest.equalsIgnoreCase("true")) {
|
||||
BigTestUtils.runStressTest = true;
|
||||
} else {
|
||||
BigTestUtils.runStressTest = false;
|
||||
}
|
||||
|
||||
String isSensorTest = arguments.getString("sensor");
|
||||
if (isSensorTest != null && isSensorTest.equalsIgnoreCase("true")) {
|
||||
BigTestUtils.runSensorTest = true;
|
||||
} else {
|
||||
BigTestUtils.runSensorTest = false;
|
||||
}
|
||||
|
||||
String isResourceUsageTest = arguments.getString("resource");
|
||||
if (isResourceUsageTest != null && isResourceUsageTest.equalsIgnoreCase("true")) {
|
||||
BigTestUtils.runResourceUsageTest = true;
|
||||
} else {
|
||||
BigTestUtils.runResourceUsageTest = false;
|
||||
}
|
||||
BigTestUtils.runStressTest = "true".equalsIgnoreCase(arguments.getString("stress"));
|
||||
BigTestUtils.runSensorTest = "true".equalsIgnoreCase(arguments.getString("sensor"));
|
||||
BigTestUtils.runResourceUsageTest = "true".equalsIgnoreCase(arguments.getString("resource"));
|
||||
|
||||
Log.d(EndToEndTestUtils.LOG_TAG, "Use port number when run test on emulator:"
|
||||
+ EndToEndTestUtils.emulatorPort);
|
||||
|
||||
-1
@@ -548,7 +548,6 @@ public class EndToEndTestUtils {
|
||||
findMenuItem(activityMytracks.getString(R.string.menu_save), true);
|
||||
instrumentation.waitForIdleSync();
|
||||
SOLO.clickOnText(trackKind.toUpperCase());
|
||||
// rotateAllActivities();
|
||||
SOLO.waitForText(activityMytracks.getString(R.string.generic_success_title));
|
||||
}
|
||||
|
||||
|
||||
+15
-9
@@ -37,12 +37,17 @@ public class BigTestUtils {
|
||||
public static boolean runStressTest = true;
|
||||
public static boolean runSensorTest = true;
|
||||
public static boolean runResourceUsageTest = true;
|
||||
protected static final String DISABLE_MESSAGE = "This test is disabled";
|
||||
protected final static String MYTRACKS_PROCESS_NAME = "com.google.android.maps.mytracks";
|
||||
protected final static String MYTRACKS_TEST_INFO_FILE = "MyTracksTestInfo.txt";
|
||||
public static final String DISABLE_MESSAGE = "This test is disabled";
|
||||
public static final String MYTRACKS_PROCESS_NAME = "com.google.android.maps.mytracks";
|
||||
public static final String MYTRACKS_TEST_INFO_FILE = "MyTracksTestInfo.txt";
|
||||
|
||||
/**
|
||||
* Gets the memory usage of MyTracks process.
|
||||
* 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
|
||||
* in a way that the amount is divided evenly between the processes that share
|
||||
* it. This is memory that would not be released if the process was
|
||||
* terminated, but is indicative of the amount that this process is
|
||||
* "contributing" to the overall memory load.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
@@ -77,7 +82,7 @@ public class BigTestUtils {
|
||||
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
int rawlevel = batteryIntent.getIntExtra("level", -1);
|
||||
double scale = batteryIntent.getIntExtra("scale", -1);
|
||||
return "Device has " + rawlevel + " of " + scale + " battery left";
|
||||
return String.format("Device has %s of %s battery left", rawlevel, scale);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,13 +121,14 @@ public class BigTestUtils {
|
||||
* @param testTime the total test milliseconds
|
||||
*/
|
||||
public static void moniterTest(Context context, int interval, int testTime) {
|
||||
long startTime = (new Date()).getTime();
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
while (((new Date()).getTime() - startTime) < testTime) {
|
||||
while ((System.currentTimeMillis() - startTime) < testTime) {
|
||||
String memoryUsageString = getMyTracksPssMemoryInfo(context);
|
||||
String batteryUsageString = getBatteryUsageInfo(context);
|
||||
String oneInfo = (new java.util.Date()).toString() + ":" + memoryUsageString + ", "
|
||||
+ batteryUsageString + ".\r\n";
|
||||
String oneInfo = String.format("{%s: memory use %s, battery left %s. \r\n",
|
||||
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);
|
||||
EndToEndTestUtils.sleep(interval);
|
||||
|
||||
+7
-7
@@ -53,8 +53,8 @@ public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackLis
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
runTest = BigTestUtils.runResourceUsageTest;
|
||||
super.setUp();
|
||||
runTest = BigTestUtils.runResourceUsageTest;
|
||||
if (!runTest) {
|
||||
return;
|
||||
}
|
||||
@@ -81,10 +81,10 @@ public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackLis
|
||||
new AlertDialog.Builder(EndToEndTestUtils.SOLO.getCurrentActivity())
|
||||
.setTitle("Confirm long time test.")
|
||||
.setMessage(
|
||||
"Please disconnect the power cord of your device and click 'Start' button. Each case need run "
|
||||
+ TEST_DURATION_IN_MILLISECONDS / 1000 / 60
|
||||
+ " minutes, and the battery/memory usage will be recorded in every "
|
||||
+ INTERVALE_TO_CHECK / 60 / 1000 + "minutes.")
|
||||
String
|
||||
.format(
|
||||
"Please disconnect the power cord of your device and click 'Start' button. Each case need run %d minutes, and the battery/memory usage will be recorded in every %d minutes.",
|
||||
TEST_DURATION_IN_MILLISECONDS / 1000 / 60, INTERVALE_TO_CHECK / 60 / 1000))
|
||||
.setPositiveButton("Start Test", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
isUserConfirmed = true;
|
||||
@@ -142,8 +142,8 @@ public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackLis
|
||||
* during recording.
|
||||
*
|
||||
* @param isShowTracksList true means show tracks list
|
||||
* @param tabNameId the name string id of tab, it's useless when the first parameter is
|
||||
* true.
|
||||
* @param tabNameId the name string id of tab, it's useless when the first
|
||||
* parameter is true.
|
||||
*/
|
||||
public void recordingLongTrack(boolean isShowTracksList, int tabNameId) {
|
||||
if (!runTest) {
|
||||
|
||||
Reference in New Issue
Block a user