Merge "Open bugreport info when touching notification (as well as DETAILS button)." into nyc-dev
am: 1e33af88ed
* commit '1e33af88edf3109bc8e6484c5f66e259a247cd01':
Open bugreport info when touching notification (as well as DETAILS button).
This commit is contained in:
@@ -436,10 +436,12 @@ public class BugreportProgressService extends Service {
|
|||||||
final Intent infoIntent = new Intent(mContext, BugreportProgressService.class);
|
final Intent infoIntent = new Intent(mContext, BugreportProgressService.class);
|
||||||
infoIntent.setAction(INTENT_BUGREPORT_INFO_LAUNCH);
|
infoIntent.setAction(INTENT_BUGREPORT_INFO_LAUNCH);
|
||||||
infoIntent.putExtra(EXTRA_ID, info.id);
|
infoIntent.putExtra(EXTRA_ID, info.id);
|
||||||
|
final PendingIntent infoPendingIntent =
|
||||||
|
PendingIntent.getService(mContext, info.id, infoIntent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
final Action infoAction = new Action.Builder(null,
|
final Action infoAction = new Action.Builder(null,
|
||||||
mContext.getString(R.string.bugreport_info_action),
|
mContext.getString(R.string.bugreport_info_action),
|
||||||
PendingIntent.getService(mContext, info.id, infoIntent,
|
infoPendingIntent).build();
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT)).build();
|
|
||||||
final Intent screenshotIntent = new Intent(mContext, BugreportProgressService.class);
|
final Intent screenshotIntent = new Intent(mContext, BugreportProgressService.class);
|
||||||
screenshotIntent.setAction(INTENT_BUGREPORT_SCREENSHOT);
|
screenshotIntent.setAction(INTENT_BUGREPORT_SCREENSHOT);
|
||||||
screenshotIntent.putExtra(EXTRA_ID, info.id);
|
screenshotIntent.putExtra(EXTRA_ID, info.id);
|
||||||
@@ -466,6 +468,7 @@ public class BugreportProgressService extends Service {
|
|||||||
.setLocalOnly(true)
|
.setLocalOnly(true)
|
||||||
.setColor(mContext.getColor(
|
.setColor(mContext.getColor(
|
||||||
com.android.internal.R.color.system_notification_accent_color))
|
com.android.internal.R.color.system_notification_accent_color))
|
||||||
|
.setContentIntent(infoPendingIntent)
|
||||||
.addAction(infoAction)
|
.addAction(infoAction)
|
||||||
.addAction(screenshotAction)
|
.addAction(screenshotAction)
|
||||||
.addAction(cancelAction)
|
.addAction(cancelAction)
|
||||||
|
|||||||
@@ -198,6 +198,25 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
|
|||||||
assertServiceNotRunning();
|
assertServiceNotRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testProgress_cancel() throws Exception {
|
||||||
|
resetProperties();
|
||||||
|
sendBugreportStarted(1000);
|
||||||
|
waitForScreenshotButtonEnabled(true);
|
||||||
|
|
||||||
|
final NumberFormat nf = NumberFormat.getPercentInstance();
|
||||||
|
nf.setMinimumFractionDigits(2);
|
||||||
|
nf.setMaximumFractionDigits(2);
|
||||||
|
|
||||||
|
assertProgressNotification(NAME, nf.format(0));
|
||||||
|
|
||||||
|
openProgressNotification(ID);
|
||||||
|
UiObject cancelButton = mUiBot.getVisibleObject(mContext.getString(
|
||||||
|
com.android.internal.R.string.cancel).toUpperCase());
|
||||||
|
mUiBot.click(cancelButton, "cancel_button");
|
||||||
|
|
||||||
|
waitForService(false);
|
||||||
|
}
|
||||||
|
|
||||||
public void testProgress_takeExtraScreenshot() throws Exception {
|
public void testProgress_takeExtraScreenshot() throws Exception {
|
||||||
takeExtraScreenshotTest(false);
|
takeExtraScreenshotTest(false);
|
||||||
}
|
}
|
||||||
@@ -339,12 +358,20 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
|
|||||||
assertServiceNotRunning();
|
assertServiceNotRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testProgress_changeJustDetails() throws Exception {
|
public void testProgress_changeJustDetailsTouchingDetails() throws Exception {
|
||||||
|
changeJustDetailsTest(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testProgress_changeJustDetailsTouchingNotification() throws Exception {
|
||||||
|
changeJustDetailsTest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeJustDetailsTest(boolean touchDetails) throws Exception {
|
||||||
resetProperties();
|
resetProperties();
|
||||||
sendBugreportStarted(1000);
|
sendBugreportStarted(1000);
|
||||||
waitForScreenshotButtonEnabled(true);
|
waitForScreenshotButtonEnabled(true);
|
||||||
|
|
||||||
DetailsUi detailsUi = new DetailsUi(mUiBot, ID);
|
DetailsUi detailsUi = new DetailsUi(mUiBot, ID, touchDetails);
|
||||||
|
|
||||||
detailsUi.nameField.setText("");
|
detailsUi.nameField.setText("");
|
||||||
detailsUi.titleField.setText("");
|
detailsUi.titleField.setText("");
|
||||||
@@ -527,10 +554,10 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
|
|||||||
mUiBot.getObject(percent);
|
mUiBot.getObject(percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openProgressNotification(int id) {
|
private UiObject openProgressNotification(int id) {
|
||||||
String title = mContext.getString(R.string.bugreport_in_progress_title, id);
|
String title = mContext.getString(R.string.bugreport_in_progress_title, id);
|
||||||
Log.v(TAG, "Looking for progress notification title: '" + title + "'");
|
Log.v(TAG, "Looking for progress notification title: '" + title + "'");
|
||||||
mUiBot.getNotification(title);
|
return mUiBot.getNotification(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetProperties() {
|
void resetProperties() {
|
||||||
@@ -899,11 +926,23 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
|
|||||||
* Gets the UI objects by opening the progress notification and clicking DETAILS.
|
* Gets the UI objects by opening the progress notification and clicking DETAILS.
|
||||||
*/
|
*/
|
||||||
DetailsUi(UiBot uiBot, int id) throws UiObjectNotFoundException {
|
DetailsUi(UiBot uiBot, int id) throws UiObjectNotFoundException {
|
||||||
openProgressNotification(id);
|
this(uiBot, id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the UI objects by opening the progress notification and clicking on DETAILS or in
|
||||||
|
* the notification itself.
|
||||||
|
*/
|
||||||
|
DetailsUi(UiBot uiBot, int id, boolean clickDetails) throws UiObjectNotFoundException {
|
||||||
|
UiObject notification = openProgressNotification(id);
|
||||||
detailsButton = mUiBot.getVisibleObject(mContext.getString(
|
detailsButton = mUiBot.getVisibleObject(mContext.getString(
|
||||||
R.string.bugreport_info_action).toUpperCase());
|
R.string.bugreport_info_action).toUpperCase());
|
||||||
|
|
||||||
mUiBot.click(detailsButton, "details_button");
|
if (clickDetails) {
|
||||||
|
mUiBot.click(detailsButton, "details_button");
|
||||||
|
} else {
|
||||||
|
mUiBot.click(notification, "notification");
|
||||||
|
}
|
||||||
// TODO: unhardcode resource ids
|
// TODO: unhardcode resource ids
|
||||||
UiObject dialogTitle = mUiBot.getVisibleObjectById("android:id/alertTitle");
|
UiObject dialogTitle = mUiBot.getVisibleObjectById("android:id/alertTitle");
|
||||||
assertEquals("Wrong title", mContext.getString(R.string.bugreport_info_dialog_title,
|
assertEquals("Wrong title", mContext.getString(R.string.bugreport_info_dialog_title,
|
||||||
|
|||||||
Reference in New Issue
Block a user