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;
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 {
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(
// 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) {