OSDN Git Service

Updating AppLaunchWear to correctly parse the launch message.
authorKevin Neas <kneas@google.com>
Wed, 21 Feb 2018 23:37:21 +0000 (15:37 -0800)
committerKevin Neas <kneas@google.com>
Wed, 21 Feb 2018 23:38:50 +0000 (15:38 -0800)
When we don't kill Home, we get an Warning message:
"Warning: Activity not started, its current task has ben brought to
the front"

This causes the current parser to think the app didn't launch, because
it's looking in the wrong line. Adding +1 to each line, in the cases
where we launch Home

Test: locally
Change-Id: Ie232a57921ed7cf82a6f17b607fbb47591bcdbed

tests/AppLaunchWear/src/com/android/tests/applaunch/AppLaunch.java

index b3f2686..38c298c 100644 (file)
@@ -103,6 +103,7 @@ public class AppLaunch extends InstrumentationTestCase {
     private static final String DROP_CACHE_SCRIPT = "/data/local/tmp/dropCache.sh";
     private static final String APP_LAUNCH_CMD = "am start -W -n";
     private static final String SUCCESS_MESSAGE = "Status: ok";
+    private static final String WARNING_MESSAGE = "Warning: Activity not started";
     private static final String COMPILE_SUCCESS = "Success";
     private static final String THIS_TIME = "ThisTime:";
     private static final String LAUNCH_ITERATION = "LAUNCH_ITERATION - %d";
@@ -790,6 +791,17 @@ public class AppLaunch extends InstrumentationTestCase {
                 TotalTime: 357
                 WaitTime: 377
                 Complete*/
+                /* WHEN NOT KILLING HOME :
+                Starting: Intent { cmp=com.google.android.wearable.app/
+                    com.google.android.clockwork.home.calendar.AgendaActivity }
+                Warning: Activity not started, its current task has been brought to the front
+                Status: ok
+                Activity: com.google.android.wearable.app/
+                    com.google.android.clockwork.home.calendar.AgendaActivity
+                ThisTime: 209
+                TotalTime: 209
+                WaitTime: 285
+                Complete*/
                 /* WITH SIMPLEPERF :
                 Performance counter statistics,
                 6595722690,cpu-cycles,4.511040,GHz,(100%),
@@ -799,28 +811,32 @@ public class AppLaunch extends InstrumentationTestCase {
                         inputStream));
                 String line = null;
                 int lineCount = 1;
+                int addLineForWarning = 0;
                 mBufferedWriter.newLine();
                 mBufferedWriter.write(headerInfo);
                 mBufferedWriter.newLine();
                 while ((line = bufferedReader.readLine()) != null) {
-                    if (lineCount == 2 && line.contains(SUCCESS_MESSAGE)) {
+                    if (lineCount == 2 && line.contains(WARNING_MESSAGE)) {
+                        addLineForWarning = 1;
+                    }
+                    if (lineCount == (2 + addLineForWarning) && line.contains(SUCCESS_MESSAGE)) {
                         launchSuccess = true;
                     }
                     // Parse TotalTime which is the launch time
-                    if (launchSuccess && lineCount == 5) {
+                    if (launchSuccess && lineCount == (5 + addLineForWarning)) {
                         String launchSplit[] = line.split(":");
                         launchTime = launchSplit[1].trim();
                     }
 
                     if (mSimplePerfAppOnly) {
                         // Parse simpleperf output.
-                        if (lineCount == 9) {
+                        if (lineCount == (9 + addLineForWarning)) {
                             if (!line.contains("cpu-cycles")) {
                                 Log.e(TAG, "Error in simpleperf output");
                             } else {
                                 cpuCycles = line.split(",")[0].trim();
                             }
-                        } else if (lineCount == 10) {
+                        } else if (lineCount == (10 + addLineForWarning)) {
                             if (!line.contains("major-faults")) {
                                 Log.e(TAG, "Error in simpleperf output");
                             } else {