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

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

Issue 2808163002: [Android O] Refactor channel initialization (Closed)
Patch Set: fix comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.notifications;
6
7 import static org.hamcrest.Matchers.is;
8 import static org.junit.Assert.assertThat;
9
10 import android.app.NotificationManager;
11
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
15 import org.junit.runners.BlockJUnit4ClassRunner;
16
17 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy;
18
19 /**
20 * Unit tests for ChannelsInitializer.
21 */
22 @RunWith(BlockJUnit4ClassRunner.class)
23 public class ChannelsInitializerTest {
24 private ChannelsInitializer mChannelsInitializer;
25 private MockNotificationManagerProxy mMockNotificationManager;
26
27 @Before
28 public void setUp() throws Exception {
29 mMockNotificationManager = new MockNotificationManagerProxy();
30 mChannelsInitializer = new ChannelsInitializer(mMockNotificationManager) ;
31 }
32
33 @Test
34 public void testEnsureInitialized_browserChannel() throws Exception {
35 mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_BR OWSER);
36
37 assertThat(mMockNotificationManager.getChannels().size(), is(1));
38 ChannelsInitializer.Channel channel = mMockNotificationManager.getChanne ls().get(0);
39 assertThat(channel.mId, is(ChannelsInitializer.CHANNEL_ID_BROWSER));
40 assertThat(
41 channel.mNameResId, is(org.chromium.chrome.R.string.notification _category_browser));
42 assertThat(channel.mImportance, is(NotificationManager.IMPORTANCE_LOW));
43 assertThat(channel.mGroupId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GEN ERAL));
44
45 assertThat(mMockNotificationManager.getNotificationChannelGroups().size( ), is(1));
46 ChannelsInitializer.ChannelGroup group =
47 mMockNotificationManager.getNotificationChannelGroups().get(0);
48 assertThat(group.mId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GENERAL));
49 assertThat(group.mNameResId,
50 is(org.chromium.chrome.R.string.notification_category_group_gene ral));
51 }
52
53 @Test
54 public void testEnsureInitialized_sitesChannel() throws Exception {
55 mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_SI TES);
56
57 assertThat(mMockNotificationManager.getChannels().size(), is(1));
58
59 ChannelsInitializer.Channel channel = mMockNotificationManager.getChanne ls().get(0);
60 assertThat(channel.mId, is(ChannelsInitializer.CHANNEL_ID_SITES));
61 assertThat(
62 channel.mNameResId, is(org.chromium.chrome.R.string.notification _category_sites));
63 assertThat(channel.mImportance, is(NotificationManager.IMPORTANCE_DEFAUL T));
64 assertThat(channel.mGroupId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GEN ERAL));
65
66 assertThat(mMockNotificationManager.getNotificationChannelGroups().size( ), is(1));
67 ChannelsInitializer.ChannelGroup group =
68 mMockNotificationManager.getNotificationChannelGroups().get(0);
69 assertThat(group.mId, is(ChannelsInitializer.CHANNEL_GROUP_ID_GENERAL));
70 assertThat(group.mNameResId,
71 is(org.chromium.chrome.R.string.notification_category_group_gene ral));
72 }
73
74 @Test
75 public void testEnsureInitialized_multipleCalls() throws Exception {
76 mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_SI TES);
77 mChannelsInitializer.ensureInitialized(ChannelsInitializer.CHANNEL_ID_BR OWSER);
78 assertThat(mMockNotificationManager.getChannels().size(), is(2));
79 }
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698