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); |