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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/notifications/ChannelsInitializerTest.java

Issue 2814603003: [Android O] Split out browser notification channels (Closed)
Patch Set: Fix up ChannelsUpdaterTest expectations Created 3 years, 8 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/junit/src/org/chromium/chrome/browser/notifications/ChannelsInitializerTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/notifications/ChannelsInitializerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/notifications/ChannelsInitializerTest.java
index 7a161b01f613d9071141bff96ccffe46bd6dec17..a658c5ac9e4b3a50f853a6d1ce0565e4b9ea43ee 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/notifications/ChannelsInitializerTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/notifications/ChannelsInitializerTest.java
@@ -4,7 +4,7 @@
package org.chromium.chrome.browser.notifications;
-import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@@ -34,7 +34,12 @@ public class ChannelsInitializerTest {
@Test
public void testInitializeStartupChannels() throws Exception {
mChannelsInitializer.initializeStartupChannels();
- assertThat(mMockNotificationManager.getChannels().size(), is(greaterThan(0)));
+ assertThat(mMockNotificationManager.getNotificationChannelIds(),
+ containsInAnyOrder(ChannelsInitializer.CHANNEL_ID_BROWSER,
+ ChannelsInitializer.CHANNEL_ID_DOWNLOADS,
+ ChannelsInitializer.CHANNEL_ID_INCOGNITO,
+ ChannelsInitializer.CHANNEL_ID_SITES,
+ ChannelsInitializer.CHANNEL_ID_MEDIA));
}
@Test
@@ -58,6 +63,66 @@ public class ChannelsInitializerTest {
}
@Test
+ public void testEnsureInitialized_downloadsChannel() throws Exception {
+ mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_DOWNLOADS);
+
+ assertThat(mMockNotificationManager.getChannels().size(), is(1));
+ ChannelsInitializer.Channel channel = mMockNotificationManager.getChannels().get(0);
+ assertThat(channel.mId, is(ChannelsInitializer.CHANNEL_ID_DOWNLOADS));
+ assertThat(channel.mNameResId,
+ is(org.chromium.chrome.R.string.notification_category_downloads));
+ assertThat(channel.mImportance, is(NotificationManager.IMPORTANCE_LOW));
+ assertThat(channel.mGroupId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GENERAL));
+
+ assertThat(mMockNotificationManager.getNotificationChannelGroups().size(), is(1));
+ ChannelsInitializer.ChannelGroup group =
+ mMockNotificationManager.getNotificationChannelGroups().get(0);
+ assertThat(group.mId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GENERAL));
+ assertThat(group.mNameResId,
+ is(org.chromium.chrome.R.string.notification_category_group_general));
+ }
+
+ @Test
+ public void testEnsureInitialized_incognitoChannel() throws Exception {
+ mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_INCOGNITO);
+
+ assertThat(mMockNotificationManager.getChannels().size(), is(1));
+ ChannelsInitializer.Channel channel = mMockNotificationManager.getChannels().get(0);
+ assertThat(channel.mId, is(ChannelsInitializer.CHANNEL_ID_INCOGNITO));
+ assertThat(channel.mNameResId,
+ is(org.chromium.chrome.R.string.notification_category_incognito));
+ assertThat(channel.mImportance, is(NotificationManager.IMPORTANCE_LOW));
+ assertThat(channel.mGroupId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GENERAL));
+
+ assertThat(mMockNotificationManager.getNotificationChannelGroups().size(), is(1));
+ ChannelsInitializer.ChannelGroup group =
+ mMockNotificationManager.getNotificationChannelGroups().get(0);
+ assertThat(group.mId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GENERAL));
+ assertThat(group.mNameResId,
+ is(org.chromium.chrome.R.string.notification_category_group_general));
+ }
+
+ @Test
+ public void testEnsureInitialized_mediaChannel() throws Exception {
+ mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_MEDIA);
+
+ assertThat(mMockNotificationManager.getChannels().size(), is(1));
+ ChannelsInitializer.Channel channel = mMockNotificationManager.getChannels().get(0);
+ assertThat(channel.mId, is(ChannelsInitializer.CHANNEL_ID_MEDIA));
+ assertThat(
+ channel.mNameResId, is(org.chromium.chrome.R.string.notification_category_media));
+ assertThat(channel.mImportance, is(NotificationManager.IMPORTANCE_LOW));
+ assertThat(channel.mGroupId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GENERAL));
+
+ assertThat(mMockNotificationManager.getNotificationChannelGroups().size(), is(1));
+ ChannelsInitializer.ChannelGroup group =
+ mMockNotificationManager.getNotificationChannelGroups().get(0);
+ assertThat(group.mId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GENERAL));
+ assertThat(group.mNameResId,
+ is(org.chromium.chrome.R.string.notification_category_group_general));
+ }
+
+ @Test
public void testEnsureInitialized_sitesChannel() throws Exception {
mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_SITES);

Powered by Google App Engine
This is Rietveld 408576698