Loading packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +15 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 { Loading Loading @@ -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( Loading packages/Shell/tests/src/com/android/shell/UiBot.java +2 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading
packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +15 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 { Loading Loading @@ -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( Loading
packages/Shell/tests/src/com/android/shell/UiBot.java +2 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading