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

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: 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 8afd7298abe7abb33195a1fce979c0ba7f4af106..a9a451fd62c520c615cced7bd906d1445873bdef 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,6 +4,7 @@
package org.chromium.chrome.browser.notifications;
+import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@@ -17,6 +18,8 @@ import org.junit.runners.BlockJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.notifications.MockNotificationManagerProxy;
+import java.util.List;
+
/**
* Unit tests for ChannelsInitializer.
*/
@@ -32,6 +35,19 @@ public class ChannelsInitializerTest {
}
@Test
+ public void testInitializeStartupChannels() throws Exception {
+ mChannelsInitializer.initializeStartupChannels();
+ List<ChannelsInitializer.Channel> channels = mMockNotificationManager.getChannels();
+ assertThat(channels.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
public void testEnsureInitialized_browserChannel() throws Exception {
mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_BROWSER);
@@ -52,6 +68,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);
@@ -78,10 +154,4 @@ public class ChannelsInitializerTest {
mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_BROWSER);
assertThat(mMockNotificationManager.getChannels().size(), is(2));
}
-
- @Test
- public void testInitializeStartupChannels() throws Exception {
- mChannelsInitializer.initializeStartupChannels();
- assertThat(mMockNotificationManager.getChannels().size(), is(greaterThan(0)));
- }
}

Powered by Google App Engine
This is Rietveld 408576698