summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java16
-rw-r--r--packages/Shell/tests/src/com/android/shell/UiBot.java3
2 files changed, 17 insertions, 2 deletions
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index 0e31cdf4a0e2..44018a024432 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -40,6 +40,8 @@ import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import libcore.io.Streams;
+import android.app.ActivityManager;
+import android.app.ActivityManager.RunningServiceInfo;
import android.app.Instrumentation;
import android.app.NotificationManager;
import android.content.Context;
@@ -130,7 +132,8 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
Bundle extras = sendBugreportFinishedIntent(42, PLAIN_TEXT_PATH, SCREENSHOT_PATH);
assertActionSendMultiple(extras, BUGREPORT_CONTENT, SCREENSHOT_CONTENT);
- // TODO: assert service is down
+ String service = BugreportProgressService.class.getName();
+ assertFalse("Service '" + service + "' is still running", isServiceRunning(service));
}
public void testBugreportFinished_withWarning() throws Exception {
@@ -306,6 +309,17 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
fail("Did not find entry '" + entryName + "' on file '" + uri + "'");
}
+ private boolean isServiceRunning(String name) {
+ ActivityManager manager = (ActivityManager) mContext
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
+ if (service.service.getClassName().equals(name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private static void createTextFile(String path, String content) throws IOException {
Log.v(TAG, "createFile(" + path + ")");
try (Writer writer = new BufferedWriter(new OutputStreamWriter(
diff --git a/packages/Shell/tests/src/com/android/shell/UiBot.java b/packages/Shell/tests/src/com/android/shell/UiBot.java
index 5e8bab1d7a3c..7d3713724e76 100644
--- a/packages/Shell/tests/src/com/android/shell/UiBot.java
+++ b/packages/Shell/tests/src/com/android/shell/UiBot.java
@@ -118,7 +118,8 @@ final class UiBot {
// TODO: UI Automator should provide such logic.
public void chooseActivity(String name) {
// First check if the activity is the default option.
- String shareText = String.format("Share with %s", name);
+ String shareText = "Share with " + name;
+ Log.v(TAG, "Waiting for ActivityChooser text: '" + shareText + "'");
boolean gotIt = mDevice.wait(Until.hasObject(By.text(shareText)), mTimeout);
if (gotIt) {