Loading packages/Shell/res/values/strings.xml +5 −6 Original line number Diff line number Diff line Loading @@ -13,14 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. --> <resources> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="app_label">Shell</string> <!-- Title of notification indicating a bugreport is being generated. [CHAR LIMIT=50] --> <string name="bugreport_in_progress_title">Bug report is being generated</string> <string name="bugreport_in_progress_title">Bug report <xliff:g id="id">#%d</xliff:g> is being generated</string> <!-- Title of notification indicating a bugreport has been successfully captured. [CHAR LIMIT=50] --> <string name="bugreport_finished_title">Bug report captured</string> <string name="bugreport_finished_title">Bug report <xliff:g id="id">#%d</xliff:g> captured</string> <!-- Title of notification indicating a bugreport is being updated before it can be shared. [CHAR LIMIT=50] --> <string name="bugreport_updating_title">Adding details to the bug report</string> <!-- Content notification indicating a bugreport is being updated before it can be shared, asking the user to wait [CHAR LIMIT=50] --> Loading Loading @@ -53,12 +52,12 @@ <string name="bugreport_screenshot_action">Screenshot</string> <!-- Toast message sent when the a screenshot for the bug report was taken successfully. --> <string name="bugreport_screenshot_taken">Screenshot taken succesfully.</string> <string name="bugreport_screenshot_taken">Screenshot taken successfully.</string> <!-- Toast message sent when the a screenshot for the bug report was not taken due to an error. --> <string name="bugreport_screenshot_failed">Screenshot could not be taken.</string> <!-- Title of the dialog asking for user-defined bug report details like name, title, and description. --> <string name="bugreport_info_dialog_title">Bug report details</string> <string name="bugreport_info_dialog_title">Bug report <xliff:g id="id">#%d</xliff:g> details</string> <!-- Text of the hint asking for the bug report name, which when set will define a suffix in the bug report file names. [CHAR LIMIT=30] --> Loading packages/Shell/src/com/android/shell/BugreportProgressService.java +3 −3 Original line number Diff line number Diff line Loading @@ -438,7 +438,7 @@ public class BugreportProgressService extends Service { mContext.getString(R.string.bugreport_screenshot_action), screenshotPendingIntent).build(); final String title = mContext.getString(R.string.bugreport_in_progress_title); final String title = mContext.getString(R.string.bugreport_in_progress_title, info.pid); final String name = info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed); Loading Loading @@ -880,7 +880,7 @@ public class BugreportProgressService extends Service { shareIntent.putExtra(EXTRA_PID, info.pid); shareIntent.putExtra(EXTRA_INFO, info); final String title = context.getString(R.string.bugreport_finished_title); final String title = context.getString(R.string.bugreport_finished_title, info.pid); final Notification.Builder builder = new Notification.Builder(context) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setContentTitle(title) Loading Loading @@ -1232,7 +1232,7 @@ public class BugreportProgressService extends Service { mDialog = new AlertDialog.Builder(context) .setView(view) .setTitle(context.getString(R.string.bugreport_info_dialog_title)) .setTitle(context.getString(R.string.bugreport_info_dialog_title, pid)) .setCancelable(false) .setPositiveButton(context.getString(com.android.internal.R.string.ok), null) Loading packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +44 −35 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.SortedSet; Loading @@ -58,6 +59,7 @@ import android.os.SystemProperties; import android.service.notification.StatusBarNotification; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject; import android.support.test.uiautomator.UiObjectNotFoundException; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.text.TextUtils; Loading Loading @@ -113,7 +115,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { private static final String NO_NAME = null; private static final String NO_SCREENSHOT = null; private static final String NO_TITLE = null; private static final Integer NO_PID = null; private static final int NO_PID = 0; private static final boolean RENAMED_SCREENSHOTS = true; private static final boolean DIDNT_RENAME_SCREENSHOTS = false; Loading Loading @@ -159,16 +161,20 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); assertProgressNotification(NAME, "0.00%"); final NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); assertProgressNotification(NAME, nf.format(0)); SystemProperties.set(PROGRESS_PROPERTY, "108"); assertProgressNotification(NAME, "10.80%"); assertProgressNotification(NAME, nf.format(0.108)); SystemProperties.set(PROGRESS_PROPERTY, "500"); assertProgressNotification(NAME, "50.00%"); assertProgressNotification(NAME, nf.format(0.50)); SystemProperties.set(MAX_PROPERTY, "2000"); assertProgressNotification(NAME, "25.00%"); assertProgressNotification(NAME, nf.format(0.25)); Bundle extras = sendBugreportFinishedAndGetSharedIntent(PID, mPlainTextPath, mScreenshotPath); Loading Loading @@ -198,11 +204,11 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportFinished(PID, mPlainTextPath, mScreenshotPath); if (serviceDies) { waitShareNotification(); waitShareNotification(PID); killService(); } Bundle extras = acceptBugreportAndGetSharedIntent(); Bundle extras = acceptBugreportAndGetSharedIntent(PID); assertActionSendMultiple(extras, BUGREPORT_CONTENT, SCREENSHOT_CONTENT, PID, ZIP_FILE, NAME, NO_TITLE, NO_DESCRIPTION, 2, RENAMED_SCREENSHOTS); Loading @@ -222,7 +228,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); sendBugreportFinished(PID, mPlainTextPath, NO_SCREENSHOT); waitShareNotification(); waitShareNotification(PID); // There's no indication in the UI about the screenshot finish, so just sleep like a baby... Thread.sleep(SAFE_SCREENSHOT_DELAY * DateUtils.SECOND_IN_MILLIS); Loading @@ -231,7 +237,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { killService(); } Bundle extras = acceptBugreportAndGetSharedIntent(); Bundle extras = acceptBugreportAndGetSharedIntent(PID); assertActionSendMultiple(extras, BUGREPORT_CONTENT, NO_SCREENSHOT, PID, ZIP_FILE, NAME, NO_TITLE, NO_DESCRIPTION, 1, RENAMED_SCREENSHOTS); Loading @@ -243,7 +249,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); DetailsUi detailsUi = new DetailsUi(mUiBot); DetailsUi detailsUi = new DetailsUi(mUiBot, PID); // Check initial name. String actualName = detailsUi.nameField.getText().toString(); Loading Loading @@ -296,7 +302,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); DetailsUi detailsUi = new DetailsUi(mUiBot); DetailsUi detailsUi = new DetailsUi(mUiBot, PID); // Check initial name. String actualName = detailsUi.nameField.getText().toString(); Loading Loading @@ -326,7 +332,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); DetailsUi detailsUi = new DetailsUi(mUiBot); DetailsUi detailsUi = new DetailsUi(mUiBot, PID); detailsUi.nameField.setText(""); detailsUi.titleField.setText(""); Loading Loading @@ -363,14 +369,14 @@ public class BugreportReceiverTest extends InstrumentationTestCase { waitForScreenshotButtonEnabled(true); } DetailsUi detailsUi = new DetailsUi(mUiBot); DetailsUi detailsUi = new DetailsUi(mUiBot, PID); // Finish the bugreport while user's still typing the name. detailsUi.nameField.setText(NEW_NAME); sendBugreportFinished(PID, mPlainTextPath, mScreenshotPath); // Wait until the share notification is received... mUiBot.getNotification(mContext.getString(R.string.bugreport_finished_title)); waitShareNotification(PID); // ...then close notification bar. mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Loading @@ -384,7 +390,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { detailsUi.clickOk(); // Finally, share bugreport. Bundle extras = acceptBugreportAndGetSharedIntent(); Bundle extras = acceptBugreportAndGetSharedIntent(PID); assertActionSendMultiple(extras, BUGREPORT_CONTENT, SCREENSHOT_CONTENT, PID, TITLE, NAME, TITLE, mDescription, 1, RENAMED_SCREENSHOTS); Loading @@ -397,7 +403,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { // Send notification and click on share. sendBugreportFinished(NO_PID, mPlainTextPath, null); acceptBugreport(); acceptBugreport(NO_PID); // Handle the warning mUiBot.getVisibleObject(mContext.getString(R.string.bugreport_confirm)); Loading @@ -421,7 +427,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { public void testShareBugreportAfterServiceDies() throws Exception { sendBugreportFinished(NO_PID, mPlainTextPath, NO_SCREENSHOT); killService(); Bundle extras = acceptBugreportAndGetSharedIntent(); Bundle extras = acceptBugreportAndGetSharedIntent(NO_PID); assertActionSendMultiple(extras, BUGREPORT_CONTENT, NO_SCREENSHOT); } Loading Loading @@ -457,14 +463,14 @@ public class BugreportReceiverTest extends InstrumentationTestCase { private void assertProgressNotification(String name, String percent) { // TODO: it currently looks for 3 distinct objects, without taking advantage of their // relationship. openProgressNotification(); openProgressNotification(PID); Log.v(TAG, "Looking for progress notification details: '" + name + "-" + percent + "'"); mUiBot.getObject(name); mUiBot.getObject(percent); } private void openProgressNotification() { String title = mContext.getString(R.string.bugreport_in_progress_title); private void openProgressNotification(int pid) { String title = mContext.getString(R.string.bugreport_in_progress_title, pid); Log.v(TAG, "Looking for progress notification title: '" + title + "'"); mUiBot.getNotification(title); } Loading Loading @@ -494,7 +500,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { */ private Bundle sendBugreportFinishedAndGetSharedIntent(String bugreportPath, String screenshotPath) { return sendBugreportFinishedAndGetSharedIntent(null, bugreportPath, screenshotPath); return sendBugreportFinishedAndGetSharedIntent(NO_PID, bugreportPath, screenshotPath); } /** Loading @@ -502,10 +508,10 @@ public class BugreportReceiverTest extends InstrumentationTestCase { * * @return extras sent in the shared intent. */ private Bundle sendBugreportFinishedAndGetSharedIntent(Integer pid, String bugreportPath, private Bundle sendBugreportFinishedAndGetSharedIntent(int pid, String bugreportPath, String screenshotPath) { sendBugreportFinished(pid, bugreportPath, screenshotPath); return acceptBugreportAndGetSharedIntent(); return acceptBugreportAndGetSharedIntent(pid); } /** Loading @@ -513,8 +519,8 @@ public class BugreportReceiverTest extends InstrumentationTestCase { * * @return extras sent in the shared intent. */ private Bundle acceptBugreportAndGetSharedIntent() { acceptBugreport(); private Bundle acceptBugreportAndGetSharedIntent(int pid) { acceptBugreport(pid); mUiBot.chooseActivity(UI_NAME); return mListener.getExtras(); } Loading @@ -522,24 +528,24 @@ public class BugreportReceiverTest extends InstrumentationTestCase { /** * Waits for the notification to share the finished bugreport. */ private void waitShareNotification() { mUiBot.getNotification(mContext.getString(R.string.bugreport_finished_title)); private void waitShareNotification(int pid) { mUiBot.getNotification(mContext.getString(R.string.bugreport_finished_title, pid)); } /** * Accepts the notification to share the finished bugreport. */ private void acceptBugreport() { mUiBot.clickOnNotification(mContext.getString(R.string.bugreport_finished_title)); private void acceptBugreport(int pid) { mUiBot.clickOnNotification(mContext.getString(R.string.bugreport_finished_title, pid)); } /** * Sends a "bugreport finished" intent. */ private void sendBugreportFinished(Integer pid, String bugreportPath, String screenshotPath) { private void sendBugreportFinished(int pid, String bugreportPath, String screenshotPath) { Intent intent = new Intent(INTENT_BUGREPORT_FINISHED); intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); if (pid != null) { if (pid != NO_PID) { intent.putExtra(EXTRA_PID, pid); } if (bugreportPath != null) { Loading Loading @@ -775,7 +781,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { * Gets the notification button used to take a screenshot. */ private UiObject getScreenshotButton() { openProgressNotification(); openProgressNotification(PID); return mUiBot.getVisibleObject( mContext.getString(R.string.bugreport_screenshot_action).toUpperCase()); } Loading Loading @@ -827,12 +833,15 @@ public class BugreportReceiverTest extends InstrumentationTestCase { /** * Gets the UI objects by opening the progress notification and clicking DETAILS. */ DetailsUi(UiBot uiBot) { openProgressNotification(); DetailsUi(UiBot uiBot, int pid) throws UiObjectNotFoundException { openProgressNotification(pid); detailsButton = mUiBot.getVisibleObject( mContext.getString(R.string.bugreport_info_action).toUpperCase()); mUiBot.click(detailsButton, "details_button"); // TODO: unhardcode resource ids UiObject dialogTitle = mUiBot.getVisibleObjectById("android:id/alertTitle"); assertEquals("Wrong title", mContext.getString(R.string.bugreport_info_dialog_title, pid), dialogTitle.getText().toString()); nameField = mUiBot.getVisibleObjectById("com.android.shell:id/name"); titleField = mUiBot.getVisibleObjectById("com.android.shell:id/title"); descField = mUiBot.getVisibleObjectById("com.android.shell:id/description"); Loading @@ -849,7 +858,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { } void reOpen() { openProgressNotification(); openProgressNotification(PID); mUiBot.click(detailsButton, "details_button"); } Loading Loading
packages/Shell/res/values/strings.xml +5 −6 Original line number Diff line number Diff line Loading @@ -13,14 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. --> <resources> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="app_label">Shell</string> <!-- Title of notification indicating a bugreport is being generated. [CHAR LIMIT=50] --> <string name="bugreport_in_progress_title">Bug report is being generated</string> <string name="bugreport_in_progress_title">Bug report <xliff:g id="id">#%d</xliff:g> is being generated</string> <!-- Title of notification indicating a bugreport has been successfully captured. [CHAR LIMIT=50] --> <string name="bugreport_finished_title">Bug report captured</string> <string name="bugreport_finished_title">Bug report <xliff:g id="id">#%d</xliff:g> captured</string> <!-- Title of notification indicating a bugreport is being updated before it can be shared. [CHAR LIMIT=50] --> <string name="bugreport_updating_title">Adding details to the bug report</string> <!-- Content notification indicating a bugreport is being updated before it can be shared, asking the user to wait [CHAR LIMIT=50] --> Loading Loading @@ -53,12 +52,12 @@ <string name="bugreport_screenshot_action">Screenshot</string> <!-- Toast message sent when the a screenshot for the bug report was taken successfully. --> <string name="bugreport_screenshot_taken">Screenshot taken succesfully.</string> <string name="bugreport_screenshot_taken">Screenshot taken successfully.</string> <!-- Toast message sent when the a screenshot for the bug report was not taken due to an error. --> <string name="bugreport_screenshot_failed">Screenshot could not be taken.</string> <!-- Title of the dialog asking for user-defined bug report details like name, title, and description. --> <string name="bugreport_info_dialog_title">Bug report details</string> <string name="bugreport_info_dialog_title">Bug report <xliff:g id="id">#%d</xliff:g> details</string> <!-- Text of the hint asking for the bug report name, which when set will define a suffix in the bug report file names. [CHAR LIMIT=30] --> Loading
packages/Shell/src/com/android/shell/BugreportProgressService.java +3 −3 Original line number Diff line number Diff line Loading @@ -438,7 +438,7 @@ public class BugreportProgressService extends Service { mContext.getString(R.string.bugreport_screenshot_action), screenshotPendingIntent).build(); final String title = mContext.getString(R.string.bugreport_in_progress_title); final String title = mContext.getString(R.string.bugreport_in_progress_title, info.pid); final String name = info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed); Loading Loading @@ -880,7 +880,7 @@ public class BugreportProgressService extends Service { shareIntent.putExtra(EXTRA_PID, info.pid); shareIntent.putExtra(EXTRA_INFO, info); final String title = context.getString(R.string.bugreport_finished_title); final String title = context.getString(R.string.bugreport_finished_title, info.pid); final Notification.Builder builder = new Notification.Builder(context) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setContentTitle(title) Loading Loading @@ -1232,7 +1232,7 @@ public class BugreportProgressService extends Service { mDialog = new AlertDialog.Builder(context) .setView(view) .setTitle(context.getString(R.string.bugreport_info_dialog_title)) .setTitle(context.getString(R.string.bugreport_info_dialog_title, pid)) .setCancelable(false) .setPositiveButton(context.getString(com.android.internal.R.string.ok), null) Loading
packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +44 −35 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.SortedSet; Loading @@ -58,6 +59,7 @@ import android.os.SystemProperties; import android.service.notification.StatusBarNotification; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject; import android.support.test.uiautomator.UiObjectNotFoundException; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.text.TextUtils; Loading Loading @@ -113,7 +115,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { private static final String NO_NAME = null; private static final String NO_SCREENSHOT = null; private static final String NO_TITLE = null; private static final Integer NO_PID = null; private static final int NO_PID = 0; private static final boolean RENAMED_SCREENSHOTS = true; private static final boolean DIDNT_RENAME_SCREENSHOTS = false; Loading Loading @@ -159,16 +161,20 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); assertProgressNotification(NAME, "0.00%"); final NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); assertProgressNotification(NAME, nf.format(0)); SystemProperties.set(PROGRESS_PROPERTY, "108"); assertProgressNotification(NAME, "10.80%"); assertProgressNotification(NAME, nf.format(0.108)); SystemProperties.set(PROGRESS_PROPERTY, "500"); assertProgressNotification(NAME, "50.00%"); assertProgressNotification(NAME, nf.format(0.50)); SystemProperties.set(MAX_PROPERTY, "2000"); assertProgressNotification(NAME, "25.00%"); assertProgressNotification(NAME, nf.format(0.25)); Bundle extras = sendBugreportFinishedAndGetSharedIntent(PID, mPlainTextPath, mScreenshotPath); Loading Loading @@ -198,11 +204,11 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportFinished(PID, mPlainTextPath, mScreenshotPath); if (serviceDies) { waitShareNotification(); waitShareNotification(PID); killService(); } Bundle extras = acceptBugreportAndGetSharedIntent(); Bundle extras = acceptBugreportAndGetSharedIntent(PID); assertActionSendMultiple(extras, BUGREPORT_CONTENT, SCREENSHOT_CONTENT, PID, ZIP_FILE, NAME, NO_TITLE, NO_DESCRIPTION, 2, RENAMED_SCREENSHOTS); Loading @@ -222,7 +228,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); sendBugreportFinished(PID, mPlainTextPath, NO_SCREENSHOT); waitShareNotification(); waitShareNotification(PID); // There's no indication in the UI about the screenshot finish, so just sleep like a baby... Thread.sleep(SAFE_SCREENSHOT_DELAY * DateUtils.SECOND_IN_MILLIS); Loading @@ -231,7 +237,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { killService(); } Bundle extras = acceptBugreportAndGetSharedIntent(); Bundle extras = acceptBugreportAndGetSharedIntent(PID); assertActionSendMultiple(extras, BUGREPORT_CONTENT, NO_SCREENSHOT, PID, ZIP_FILE, NAME, NO_TITLE, NO_DESCRIPTION, 1, RENAMED_SCREENSHOTS); Loading @@ -243,7 +249,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); DetailsUi detailsUi = new DetailsUi(mUiBot); DetailsUi detailsUi = new DetailsUi(mUiBot, PID); // Check initial name. String actualName = detailsUi.nameField.getText().toString(); Loading Loading @@ -296,7 +302,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); DetailsUi detailsUi = new DetailsUi(mUiBot); DetailsUi detailsUi = new DetailsUi(mUiBot, PID); // Check initial name. String actualName = detailsUi.nameField.getText().toString(); Loading Loading @@ -326,7 +332,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); DetailsUi detailsUi = new DetailsUi(mUiBot); DetailsUi detailsUi = new DetailsUi(mUiBot, PID); detailsUi.nameField.setText(""); detailsUi.titleField.setText(""); Loading Loading @@ -363,14 +369,14 @@ public class BugreportReceiverTest extends InstrumentationTestCase { waitForScreenshotButtonEnabled(true); } DetailsUi detailsUi = new DetailsUi(mUiBot); DetailsUi detailsUi = new DetailsUi(mUiBot, PID); // Finish the bugreport while user's still typing the name. detailsUi.nameField.setText(NEW_NAME); sendBugreportFinished(PID, mPlainTextPath, mScreenshotPath); // Wait until the share notification is received... mUiBot.getNotification(mContext.getString(R.string.bugreport_finished_title)); waitShareNotification(PID); // ...then close notification bar. mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Loading @@ -384,7 +390,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { detailsUi.clickOk(); // Finally, share bugreport. Bundle extras = acceptBugreportAndGetSharedIntent(); Bundle extras = acceptBugreportAndGetSharedIntent(PID); assertActionSendMultiple(extras, BUGREPORT_CONTENT, SCREENSHOT_CONTENT, PID, TITLE, NAME, TITLE, mDescription, 1, RENAMED_SCREENSHOTS); Loading @@ -397,7 +403,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { // Send notification and click on share. sendBugreportFinished(NO_PID, mPlainTextPath, null); acceptBugreport(); acceptBugreport(NO_PID); // Handle the warning mUiBot.getVisibleObject(mContext.getString(R.string.bugreport_confirm)); Loading @@ -421,7 +427,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { public void testShareBugreportAfterServiceDies() throws Exception { sendBugreportFinished(NO_PID, mPlainTextPath, NO_SCREENSHOT); killService(); Bundle extras = acceptBugreportAndGetSharedIntent(); Bundle extras = acceptBugreportAndGetSharedIntent(NO_PID); assertActionSendMultiple(extras, BUGREPORT_CONTENT, NO_SCREENSHOT); } Loading Loading @@ -457,14 +463,14 @@ public class BugreportReceiverTest extends InstrumentationTestCase { private void assertProgressNotification(String name, String percent) { // TODO: it currently looks for 3 distinct objects, without taking advantage of their // relationship. openProgressNotification(); openProgressNotification(PID); Log.v(TAG, "Looking for progress notification details: '" + name + "-" + percent + "'"); mUiBot.getObject(name); mUiBot.getObject(percent); } private void openProgressNotification() { String title = mContext.getString(R.string.bugreport_in_progress_title); private void openProgressNotification(int pid) { String title = mContext.getString(R.string.bugreport_in_progress_title, pid); Log.v(TAG, "Looking for progress notification title: '" + title + "'"); mUiBot.getNotification(title); } Loading Loading @@ -494,7 +500,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { */ private Bundle sendBugreportFinishedAndGetSharedIntent(String bugreportPath, String screenshotPath) { return sendBugreportFinishedAndGetSharedIntent(null, bugreportPath, screenshotPath); return sendBugreportFinishedAndGetSharedIntent(NO_PID, bugreportPath, screenshotPath); } /** Loading @@ -502,10 +508,10 @@ public class BugreportReceiverTest extends InstrumentationTestCase { * * @return extras sent in the shared intent. */ private Bundle sendBugreportFinishedAndGetSharedIntent(Integer pid, String bugreportPath, private Bundle sendBugreportFinishedAndGetSharedIntent(int pid, String bugreportPath, String screenshotPath) { sendBugreportFinished(pid, bugreportPath, screenshotPath); return acceptBugreportAndGetSharedIntent(); return acceptBugreportAndGetSharedIntent(pid); } /** Loading @@ -513,8 +519,8 @@ public class BugreportReceiverTest extends InstrumentationTestCase { * * @return extras sent in the shared intent. */ private Bundle acceptBugreportAndGetSharedIntent() { acceptBugreport(); private Bundle acceptBugreportAndGetSharedIntent(int pid) { acceptBugreport(pid); mUiBot.chooseActivity(UI_NAME); return mListener.getExtras(); } Loading @@ -522,24 +528,24 @@ public class BugreportReceiverTest extends InstrumentationTestCase { /** * Waits for the notification to share the finished bugreport. */ private void waitShareNotification() { mUiBot.getNotification(mContext.getString(R.string.bugreport_finished_title)); private void waitShareNotification(int pid) { mUiBot.getNotification(mContext.getString(R.string.bugreport_finished_title, pid)); } /** * Accepts the notification to share the finished bugreport. */ private void acceptBugreport() { mUiBot.clickOnNotification(mContext.getString(R.string.bugreport_finished_title)); private void acceptBugreport(int pid) { mUiBot.clickOnNotification(mContext.getString(R.string.bugreport_finished_title, pid)); } /** * Sends a "bugreport finished" intent. */ private void sendBugreportFinished(Integer pid, String bugreportPath, String screenshotPath) { private void sendBugreportFinished(int pid, String bugreportPath, String screenshotPath) { Intent intent = new Intent(INTENT_BUGREPORT_FINISHED); intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); if (pid != null) { if (pid != NO_PID) { intent.putExtra(EXTRA_PID, pid); } if (bugreportPath != null) { Loading Loading @@ -775,7 +781,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { * Gets the notification button used to take a screenshot. */ private UiObject getScreenshotButton() { openProgressNotification(); openProgressNotification(PID); return mUiBot.getVisibleObject( mContext.getString(R.string.bugreport_screenshot_action).toUpperCase()); } Loading Loading @@ -827,12 +833,15 @@ public class BugreportReceiverTest extends InstrumentationTestCase { /** * Gets the UI objects by opening the progress notification and clicking DETAILS. */ DetailsUi(UiBot uiBot) { openProgressNotification(); DetailsUi(UiBot uiBot, int pid) throws UiObjectNotFoundException { openProgressNotification(pid); detailsButton = mUiBot.getVisibleObject( mContext.getString(R.string.bugreport_info_action).toUpperCase()); mUiBot.click(detailsButton, "details_button"); // TODO: unhardcode resource ids UiObject dialogTitle = mUiBot.getVisibleObjectById("android:id/alertTitle"); assertEquals("Wrong title", mContext.getString(R.string.bugreport_info_dialog_title, pid), dialogTitle.getText().toString()); nameField = mUiBot.getVisibleObjectById("com.android.shell:id/name"); titleField = mUiBot.getVisibleObjectById("com.android.shell:id/title"); descField = mUiBot.getVisibleObjectById("com.android.shell:id/description"); Loading @@ -849,7 +858,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { } void reOpen() { openProgressNotification(); openProgressNotification(PID); mUiBot.click(detailsButton, "details_button"); } Loading