Index: testing/android/reporter/java/src/org/chromium/test/reporter/TestStatusReceiver.java |
diff --git a/testing/android/reporter/java/src/org/chromium/test/reporter/TestStatusReceiver.java b/testing/android/reporter/java/src/org/chromium/test/reporter/TestStatusReceiver.java |
index e4af9b652e2ba93c530c50d05567ed8eae325349..1f410a9fa817bc358a882a6408590ac006fde063 100644 |
--- a/testing/android/reporter/java/src/org/chromium/test/reporter/TestStatusReceiver.java |
+++ b/testing/android/reporter/java/src/org/chromium/test/reporter/TestStatusReceiver.java |
@@ -8,7 +8,8 @@ import android.content.BroadcastReceiver; |
import android.content.Context; |
import android.content.Intent; |
import android.content.IntentFilter; |
-import android.util.Log; |
+ |
+import org.chromium.base.Log; |
import java.util.ArrayList; |
import java.util.List; |
@@ -18,12 +19,13 @@ import java.util.List; |
*/ |
public class TestStatusReceiver extends BroadcastReceiver { |
- private static final String TAG = "ResultReceiver"; |
+ private static final String TAG = "cr.test.reporter"; |
private final List<FailCallback> mFailCallbacks = new ArrayList<FailCallback>(); |
private final List<HeartbeatCallback> mHeartbeatCallbacks = new ArrayList<HeartbeatCallback>(); |
private final List<PassCallback> mPassCallbacks = new ArrayList<PassCallback>(); |
private final List<StartCallback> mStartCallbacks = new ArrayList<StartCallback>(); |
+ private final List<TestRunCallback> mTestRunCallbacks = new ArrayList<TestRunCallback>(); |
/** An IntentFilter that matches the intents that this class can receive. */ |
private static final IntentFilter INTENT_FILTER; |
@@ -33,6 +35,8 @@ public class TestStatusReceiver extends BroadcastReceiver { |
filter.addAction(TestStatusReporter.ACTION_TEST_FAILED); |
filter.addAction(TestStatusReporter.ACTION_TEST_PASSED); |
filter.addAction(TestStatusReporter.ACTION_TEST_STARTED); |
+ filter.addAction(TestStatusReporter.ACTION_TEST_RUN_STARTED); |
+ filter.addAction(TestStatusReporter.ACTION_TEST_RUN_FINISHED); |
try { |
filter.addDataType(TestStatusReporter.DATA_TYPE_HEARTBEAT); |
filter.addDataType(TestStatusReporter.DATA_TYPE_RESULT); |
@@ -62,6 +66,12 @@ public class TestStatusReceiver extends BroadcastReceiver { |
void testStarted(String testClass, String testMethod); |
} |
+ /** A callback used when a test run has started or finished. */ |
+ public interface TestRunCallback { |
+ void testRunStarted(int pid); |
+ void testRunFinished(int pid); |
+ } |
+ |
/** Register a callback for when a test has failed. */ |
public void registerCallback(FailCallback c) { |
mFailCallbacks.add(c); |
@@ -82,6 +92,11 @@ public class TestStatusReceiver extends BroadcastReceiver { |
mStartCallbacks.add(c); |
} |
+ /** Register a callback for when a test run has started or finished. */ |
+ public void registerCallback(TestRunCallback c) { |
+ mTestRunCallbacks.add(c); |
+ } |
+ |
/** Register this receiver using the provided context. */ |
public void register(Context c) { |
c.registerReceiver(this, INTENT_FILTER); |
@@ -94,6 +109,7 @@ public class TestStatusReceiver extends BroadcastReceiver { |
*/ |
@Override |
public void onReceive(Context context, Intent intent) { |
+ int pid = intent.getIntExtra(TestStatusReporter.EXTRA_PID, 0); |
String testClass = intent.getStringExtra(TestStatusReporter.EXTRA_TEST_CLASS); |
String testMethod = intent.getStringExtra(TestStatusReporter.EXTRA_TEST_METHOD); |
@@ -118,8 +134,18 @@ public class TestStatusReceiver extends BroadcastReceiver { |
c.heartbeat(); |
} |
break; |
+ case TestStatusReporter.ACTION_TEST_RUN_STARTED: |
+ for (TestRunCallback c: mTestRunCallbacks) { |
+ c.testRunStarted(pid); |
+ } |
+ break; |
+ case TestStatusReporter.ACTION_TEST_RUN_FINISHED: |
+ for (TestRunCallback c: mTestRunCallbacks) { |
+ c.testRunFinished(pid); |
+ } |
+ break; |
default: |
- Log.e(TAG, "Unrecognized intent received: " + intent.toString()); |
+ Log.e(TAG, "Unrecognized intent received: %s", intent.toString()); |
break; |
} |
} |