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

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

Issue 2922443002: [Web apks] Stop setting channels on web apk notifications (Closed)
Patch Set: Created 3 years, 7 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 e4683ae6ca1526d221a83dab3c586e5b0e2105be..aed645820cc7f7ed28aac735076ea706b9dad0ce 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
@@ -35,6 +35,7 @@ import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions;
import org.chromium.content.browser.test.NativeLibraryTestRule;
import java.util.ArrayList;
@@ -74,24 +75,25 @@ public class CustomNotificationBuilderTest {
new int[] {Color.WHITE}, 1 /* width */, 1 /* height */, Bitmap.Config.ARGB_8888);
actionIcon = actionIcon.copy(Bitmap.Config.ARGB_8888, true /* isMutable */);
- 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)
- .addButtonAction(actionIcon, "button",
- createIntent(context, "ActionButtonOne"))
- .addButtonAction(actionIcon, "button",
- createIntent(context, "ActionButtonTwo"))
- .addSettingsAction(0 /* iconId */, "settings",
- createIntent(context, "SettingsButton"))
- .build();
+ Notification notification =
+ new CustomNotificationBuilder(context, ChannelDefinitions.CHANNEL_ID_SITES)
+ .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)
+ .addButtonAction(
+ actionIcon, "button", createIntent(context, "ActionButtonOne"))
+ .addButtonAction(
+ actionIcon, "button", createIntent(context, "ActionButtonTwo"))
+ .addSettingsAction(
+ 0 /* iconId */, "settings", createIntent(context, "SettingsButton"))
+ .build();
assertSmallNotificationIconAsExpected(context, notification, smallIcon);
assertLargeNotificationIconAsExpected(context, notification, largeIcon);
@@ -144,7 +146,8 @@ public class CustomNotificationBuilderTest {
@Feature({"Browser", "Notifications"})
public void testZeroActionButtons() {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
- Notification notification = new CustomNotificationBuilder(context).build();
+ Notification notification =
+ new CustomNotificationBuilder(context, ChannelDefinitions.CHANNEL_ID_SITES).build();
View bigView = notification.bigContentView.apply(context, new LinearLayout(context));
ArrayList<View> buttons = new ArrayList<>();
bigView.findViewsWithText(buttons, "button", View.FIND_VIEWS_WITH_TEXT);
@@ -160,11 +163,12 @@ public class CustomNotificationBuilderTest {
@Feature({"Browser", "Notifications"})
public void testMaxActionButtons() {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
- NotificationBuilderBase builder = new CustomNotificationBuilder(context)
- .addButtonAction(null /* iconBitmap */, "button",
- createIntent(context, "ActionButtonOne"))
- .addButtonAction(null /* iconBitmap */, "button",
- createIntent(context, "ActionButtonTwo"));
+ NotificationBuilderBase builder =
+ new CustomNotificationBuilder(context, ChannelDefinitions.CHANNEL_ID_SITES)
+ .addButtonAction(null /* iconBitmap */, "button",
+ createIntent(context, "ActionButtonOne"))
+ .addButtonAction(null /* iconBitmap */, "button",
+ createIntent(context, "ActionButtonTwo"));
try {
builder.addButtonAction(
null /* iconBitmap */, "button", createIntent(context, "ActionButtonThree"));
@@ -199,12 +203,13 @@ public class CustomNotificationBuilderTest {
new int[] {Color.RED}, 1 /* width */, 1 /* height */, Bitmap.Config.ARGB_8888);
actionIcon = actionIcon.copy(Bitmap.Config.ARGB_8888, true /* isMutable */);
- Notification notification = new CustomNotificationBuilder(context)
- .setLargeIcon(largeIcon)
- .setSmallIcon(smallIcon)
- .addButtonAction(actionIcon, "button",
- createIntent(context, "ActionButton"))
- .build();
+ Notification notification =
+ new CustomNotificationBuilder(context, ChannelDefinitions.CHANNEL_ID_SITES)
+ .setLargeIcon(largeIcon)
+ .setSmallIcon(smallIcon)
+ .addButtonAction(
+ actionIcon, "button", createIntent(context, "ActionButton"))
+ .build();
// The large icon should be unchanged.
assertLargeNotificationIconAsExpected(context, notification, largeIcon);
@@ -229,7 +234,7 @@ public class CustomNotificationBuilderTest {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
int maxLength = CustomNotificationBuilder.MAX_CHARSEQUENCE_LENGTH;
Notification notification =
- new CustomNotificationBuilder(context)
+ new CustomNotificationBuilder(context, ChannelDefinitions.CHANNEL_ID_SITES)
.setTitle(createString('a', maxLength + 1))
.setBody(createString('b', maxLength + 1))
.setOrigin(createString('c', maxLength + 1))
@@ -285,7 +290,8 @@ public class CustomNotificationBuilderTest {
public void testGeneratesLargeIconFromOriginWhenNoLargeIconProvided() {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
NotificationBuilderBase notificationBuilder =
- new CustomNotificationBuilder(context).setOrigin("https://www.google.com");
+ new CustomNotificationBuilder(context, ChannelDefinitions.CHANNEL_ID_SITES)
+ .setOrigin("https://www.google.com");
Notification notification = notificationBuilder.build();
@@ -300,9 +306,10 @@ public class CustomNotificationBuilderTest {
@Feature({"Browser", "Notifications"})
public void testGeneratesLargeIconFromOriginWhenLargeIconProvidedIsNull() {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
- NotificationBuilderBase notificationBuilder = new CustomNotificationBuilder(context)
- .setOrigin("https://www.chromium.org")
- .setLargeIcon(null);
+ NotificationBuilderBase notificationBuilder =
+ new CustomNotificationBuilder(context, ChannelDefinitions.CHANNEL_ID_SITES)
+ .setOrigin("https://www.chromium.org")
+ .setLargeIcon(null);
Notification notification = notificationBuilder.build();
@@ -325,8 +332,9 @@ public class CustomNotificationBuilderTest {
@Feature({"Browser", "Notifications"})
public void testAddTextActionSetsRemoteInput() {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
- NotificationBuilderBase notificationBuilder = new CustomNotificationBuilder(
- context).addTextAction(null, "Action Title", null, "Placeholder");
+ NotificationBuilderBase notificationBuilder =
+ new CustomNotificationBuilder(context, ChannelDefinitions.CHANNEL_ID_SITES)
+ .addTextAction(null, "Action Title", null, "Placeholder");
Notification notification = notificationBuilder.build();

Powered by Google App Engine
This is Rietveld 408576698