Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java

Issue 1681123002: Plumb Notification action icons through to the UI layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ActionIconResourceFetching
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java
index e6b8ee6b07bb47e2d25229fb28624cd31b155218..52319d39e3e0883bcf11b8e7a2d07d4437efafea 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java
@@ -43,24 +43,26 @@ public void testSetAll() {
Bitmap largeIcon = Bitmap.createBitmap(
new int[] {Color.RED}, 1 /* width */, 1 /* height */, Bitmap.Config.ARGB_8888);
- Notification notification = new CustomNotificationBuilder(context)
- .setSmallIcon(R.drawable.ic_chrome)
- .setLargeIcon(largeIcon)
- .setTitle("title")
- .setBody("body")
- .setOrigin("origin")
- .setTicker("ticker")
- .setDefaults(Notification.DEFAULT_ALL)
- .setVibrate(new long[] {100L})
- .setContentIntent(contentIntent)
- .setDeleteIntent(deleteIntent)
- .addAction(0 /* iconId */, "button",
- createIntent(context, "ActionButtonOne"))
- .addAction(0 /* iconId */, "button",
- createIntent(context, "ActionButtonTwo"))
- .addSettingsAction(0 /* iconId */, "settings",
- createIntent(context, "SettingsButton"))
- .build();
+ Bitmap actionIcon = Bitmap.createBitmap(
+ new int[] {Color.WHITE}, 1 /* width */, 1 /* height */, Bitmap.Config.ARGB_8888);
+
+ Notification notification =
+ new CustomNotificationBuilder(context)
+ .setSmallIcon(R.drawable.ic_chrome)
+ .setLargeIcon(largeIcon)
+ .setTitle("title")
+ .setBody("body")
+ .setOrigin("origin")
+ .setTicker("ticker")
+ .setDefaults(Notification.DEFAULT_ALL)
+ .setVibrate(new long[] {100L})
+ .setContentIntent(contentIntent)
+ .setDeleteIntent(deleteIntent)
+ .addAction(actionIcon, "button", createIntent(context, "ActionButtonOne"))
+ .addAction(actionIcon, "button", createIntent(context, "ActionButtonTwo"))
+ .addSettingsAction(
+ 0 /* iconId */, "settings", createIntent(context, "SettingsButton"))
+ .build();
View compactView = notification.contentView.apply(context, new LinearLayout(context));
View bigView = notification.bigContentView.apply(context, new LinearLayout(context));
@@ -111,24 +113,23 @@ public void testZeroActionButtons() {
public void testMaxActionButtons() {
Context context = getInstrumentation().getTargetContext();
NotificationBuilderBase builder = new CustomNotificationBuilder(context)
- .addAction(0 /* iconId */, "button",
- createIntent(context, "ActionButtonOne"))
- .addAction(0 /* iconId */, "button",
- createIntent(context, "ActionButtonTwo"))
- .addAction(0 /* iconId */, "button",
- createIntent(context, "ActionButtonThree"));
+ .addAction(null /* iconBitmap */, "button",
+ createIntent(context, "ActionButtonOne"))
+ .addAction(null /* iconBitmap */, "button",
+ createIntent(context, "ActionButtonTwo"));
try {
- builder.addAction(0 /* iconId */, "button", createIntent(context, "ActionButtonFour"));
+ builder.addAction(
+ null /* iconBitmap */, "button", createIntent(context, "ActionButtonThree"));
fail("This statement should not be reached as the previous statement should throw.");
} catch (IllegalStateException e) {
- assertEquals("Cannot add more than 3 actions.", e.getMessage());
+ assertEquals("Cannot add more than 2 actions.", e.getMessage());
}
Notification notification = builder.build();
View bigView = notification.bigContentView.apply(context, new LinearLayout(context));
ArrayList<View> buttons = new ArrayList<>();
bigView.findViewsWithText(buttons, "button", View.FIND_VIEWS_WITH_TEXT);
- assertEquals("There is a maximum of 3 buttons", 3, buttons.size());
+ assertEquals("There is a maximum of 2 buttons", 2, buttons.size());
}
@SmallTest
@@ -142,7 +143,7 @@ public void testCharSequenceLimits() {
.setBody(createString('b', maxLength + 1))
.setOrigin(createString('c', maxLength + 1))
.setTicker(createString('d', maxLength + 1))
- .addAction(0 /* iconId */, createString('e', maxLength + 1),
+ .addAction(null /* iconBitmap */, createString('e', maxLength + 1),
createIntent(context, "ActionButtonOne"))
.build();
View compactView = notification.contentView.apply(context, new LinearLayout(context));

Powered by Google App Engine
This is Rietveld 408576698