yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 17 | package com.android.systemui.statusbar.notification.row; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 18 | |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 19 | import static android.app.AppOpsManager.OP_CAMERA; |
| 20 | import static android.app.AppOpsManager.OP_RECORD_AUDIO; |
| 21 | import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 22 | import static android.app.NotificationManager.IMPORTANCE_DEFAULT; |
Beverly | 7c1ad5b | 2019-12-05 17:17:15 -0500 | [diff] [blame] | 23 | import static android.app.NotificationManager.IMPORTANCE_HIGH; |
Gus Prevas | 5a70a4e | 2018-11-26 17:16:05 -0500 | [diff] [blame] | 24 | import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE; |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 25 | |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 26 | import static com.android.systemui.statusbar.NotificationEntryHelper.modifyRanking; |
| 27 | |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 28 | import static junit.framework.Assert.assertNotNull; |
Kevin | a5ff1fa | 2018-08-21 16:35:48 -0700 | [diff] [blame] | 29 | import static junit.framework.Assert.assertNull; |
| 30 | import static junit.framework.Assert.assertTrue; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 31 | |
| 32 | import static org.junit.Assert.assertEquals; |
| 33 | import static org.junit.Assert.fail; |
| 34 | import static org.mockito.ArgumentMatchers.any; |
| 35 | import static org.mockito.ArgumentMatchers.anyBoolean; |
| 36 | import static org.mockito.ArgumentMatchers.anyInt; |
Evan Laird | 47dc454 | 2019-04-24 15:10:52 -0400 | [diff] [blame] | 37 | import static org.mockito.ArgumentMatchers.anySet; |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 38 | import static org.mockito.ArgumentMatchers.eq; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 39 | import static org.mockito.Mockito.doNothing; |
Kevin | a5ff1fa | 2018-08-21 16:35:48 -0700 | [diff] [blame] | 40 | import static org.mockito.Mockito.doReturn; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 41 | import static org.mockito.Mockito.mock; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 42 | import static org.mockito.Mockito.spy; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 43 | import static org.mockito.Mockito.times; |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 44 | import static org.mockito.Mockito.verify; |
| 45 | import static org.mockito.Mockito.when; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 46 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 47 | import android.app.INotificationManager; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 48 | import android.app.Notification; |
| 49 | import android.app.NotificationChannel; |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 50 | import android.content.Intent; |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 51 | import android.content.pm.LauncherApps; |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 52 | import android.content.pm.PackageManager; |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 53 | import android.content.pm.ShortcutManager; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 54 | import android.os.Binder; |
| 55 | import android.os.Handler; |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 56 | import android.provider.Settings; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 57 | import android.service.notification.StatusBarNotification; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 58 | import android.testing.AndroidTestingRunner; |
| 59 | import android.testing.TestableLooper; |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 60 | import android.util.ArraySet; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 61 | import android.view.View; |
Dave Mankoff | 5fe07f7 | 2019-11-19 22:14:41 -0500 | [diff] [blame] | 62 | import android.view.accessibility.AccessibilityManager; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 63 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 64 | import androidx.test.filters.SmallTest; |
| 65 | |
TreeHugger Robot | ee8e1ae | 2019-01-18 19:26:40 +0000 | [diff] [blame] | 66 | import com.android.internal.logging.MetricsLogger; |
Will Brockman | 4567a4c | 2020-06-21 17:19:50 -0400 | [diff] [blame] | 67 | import com.android.internal.logging.UiEventLogger; |
| 68 | import com.android.internal.logging.testing.UiEventLoggerFake; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 69 | import com.android.systemui.SysuiTestCase; |
Lyn Han | b539797 | 2020-06-16 11:56:43 -0700 | [diff] [blame] | 70 | import com.android.systemui.bubbles.BubbleController; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 71 | import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 72 | import com.android.systemui.settings.CurrentUserContextTracker; |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 73 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 74 | import com.android.systemui.statusbar.NotificationPresenter; |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 75 | import com.android.systemui.statusbar.notification.NotificationActivityStarter; |
Ned Burns | 9512e0c | 2019-05-30 19:36:04 -0400 | [diff] [blame] | 76 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 77 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Beverly | e558f1d | 2020-01-07 16:28:58 -0500 | [diff] [blame] | 78 | import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider; |
Steve Elliott | 2304e4a | 2020-04-01 17:03:41 -0400 | [diff] [blame] | 79 | import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier; |
Gus Prevas | 5a70a4e | 2018-11-26 17:16:05 -0500 | [diff] [blame] | 80 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 81 | import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; |
Evan Laird | 03cf350 | 2019-05-31 16:46:48 -0400 | [diff] [blame] | 82 | import com.android.systemui.statusbar.phone.StatusBar; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 83 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 84 | |
| 85 | import org.junit.Before; |
Selim Cinek | 2476ed7 | 2019-03-07 13:19:23 -0800 | [diff] [blame] | 86 | import org.junit.Ignore; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 87 | import org.junit.Rule; |
| 88 | import org.junit.Test; |
| 89 | import org.junit.runner.RunWith; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 90 | import org.mockito.Answers; |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 91 | import org.mockito.ArgumentCaptor; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 92 | import org.mockito.Mock; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 93 | import org.mockito.junit.MockitoJUnit; |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 94 | import org.mockito.junit.MockitoRule; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 95 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 96 | import javax.inject.Provider; |
| 97 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 98 | /** |
| 99 | * Tests for {@link NotificationGutsManager}. |
| 100 | */ |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 101 | @SmallTest |
| 102 | @RunWith(AndroidTestingRunner.class) |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 103 | @TestableLooper.RunWithLooper |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 104 | public class NotificationGutsManagerTest extends SysuiTestCase { |
| 105 | private static final String TEST_CHANNEL_ID = "NotificationManagerServiceTestChannelId"; |
| 106 | |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 107 | private NotificationChannel mTestNotificationChannel = new NotificationChannel( |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 108 | TEST_CHANNEL_ID, TEST_CHANNEL_ID, IMPORTANCE_DEFAULT); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 109 | private TestableLooper mTestableLooper; |
| 110 | private Handler mHandler; |
| 111 | private NotificationTestHelper mHelper; |
| 112 | private NotificationGutsManager mGutsManager; |
| 113 | |
| 114 | @Rule public MockitoRule mockito = MockitoJUnit.rule(); |
TreeHugger Robot | ee8e1ae | 2019-01-18 19:26:40 +0000 | [diff] [blame] | 115 | @Mock private MetricsLogger mMetricsLogger; |
Ned Burns | 9512e0c | 2019-05-30 19:36:04 -0400 | [diff] [blame] | 116 | @Mock private VisualStabilityManager mVisualStabilityManager; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 117 | @Mock private NotificationPresenter mPresenter; |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 118 | @Mock private NotificationActivityStarter mNotificationActivityStarter; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 119 | @Mock private NotificationStackScrollLayout mStackScroller; |
| 120 | @Mock private NotificationInfo.CheckSaveListener mCheckSaveListener; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 121 | @Mock private OnSettingsClickListener mOnSettingsClickListener; |
| 122 | @Mock private DeviceProvisionedController mDeviceProvisionedController; |
Evan Laird | 03cf350 | 2019-05-31 16:46:48 -0400 | [diff] [blame] | 123 | @Mock private StatusBar mStatusBar; |
Dave Mankoff | 5fe07f7 | 2019-11-19 22:14:41 -0500 | [diff] [blame] | 124 | @Mock private AccessibilityManager mAccessibilityManager; |
Beverly | e558f1d | 2020-01-07 16:28:58 -0500 | [diff] [blame] | 125 | @Mock private HighPriorityProvider mHighPriorityProvider; |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 126 | @Mock private INotificationManager mINotificationManager; |
| 127 | @Mock private LauncherApps mLauncherApps; |
| 128 | @Mock private ShortcutManager mShortcutManager; |
Evan Laird | 18bd6e6 | 2019-08-30 16:39:25 -0400 | [diff] [blame] | 129 | @Mock private ChannelEditorDialogController mChannelEditorDialogController; |
Steve Elliott | 2304e4a | 2020-04-01 17:03:41 -0400 | [diff] [blame] | 130 | @Mock private PeopleNotificationIdentifier mPeopleNotificationIdentifier; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 131 | @Mock private CurrentUserContextTracker mContextTracker; |
Lyn Han | b539797 | 2020-06-16 11:56:43 -0700 | [diff] [blame] | 132 | @Mock private BubbleController mBubbleController; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 133 | @Mock(answer = Answers.RETURNS_SELF) |
| 134 | private PriorityOnboardingDialogController.Builder mBuilder; |
| 135 | private Provider<PriorityOnboardingDialogController.Builder> mProvider = () -> mBuilder; |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 136 | |
| 137 | @Before |
| 138 | public void setUp() { |
| 139 | mTestableLooper = TestableLooper.get(this); |
Beverly | 1467c9e | 2020-02-18 13:31:29 -0500 | [diff] [blame] | 140 | allowTestableLooperAsMainThread(); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 141 | mDependency.injectTestDependency(DeviceProvisionedController.class, |
| 142 | mDeviceProvisionedController); |
TreeHugger Robot | ee8e1ae | 2019-01-18 19:26:40 +0000 | [diff] [blame] | 143 | mDependency.injectTestDependency(MetricsLogger.class, mMetricsLogger); |
Ned Burns | 9512e0c | 2019-05-30 19:36:04 -0400 | [diff] [blame] | 144 | mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager); |
Lyn Han | b539797 | 2020-06-16 11:56:43 -0700 | [diff] [blame] | 145 | mDependency.injectTestDependency(BubbleController.class, mBubbleController); |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 146 | mDependency.injectMockDependency(NotificationLockscreenUserManager.class); |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 147 | mHandler = Handler.createAsync(mTestableLooper.getLooper()); |
Kevin Han | a7c21be | 2020-04-01 17:58:35 -0700 | [diff] [blame] | 148 | mHelper = new NotificationTestHelper(mContext, mDependency, TestableLooper.get(this)); |
Dave Mankoff | 5fe07f7 | 2019-11-19 22:14:41 -0500 | [diff] [blame] | 149 | when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 150 | |
Dave Mankoff | 4dd47fa | 2019-11-07 10:44:48 -0500 | [diff] [blame] | 151 | mGutsManager = new NotificationGutsManager(mContext, mVisualStabilityManager, |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 152 | () -> mStatusBar, mHandler, mHandler, mAccessibilityManager, mHighPriorityProvider, |
Evan Laird | 18bd6e6 | 2019-08-30 16:39:25 -0400 | [diff] [blame] | 153 | mINotificationManager, mLauncherApps, mShortcutManager, |
Will Brockman | 4567a4c | 2020-06-21 17:19:50 -0400 | [diff] [blame] | 154 | mChannelEditorDialogController, mContextTracker, mProvider, mBubbleController, |
| 155 | new UiEventLoggerFake()); |
Kevin | a5ff1fa | 2018-08-21 16:35:48 -0700 | [diff] [blame] | 156 | mGutsManager.setUpWithPresenter(mPresenter, mStackScroller, |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 157 | mCheckSaveListener, mOnSettingsClickListener); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 158 | mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 162 | // Test methods: |
| 163 | |
| 164 | @Test |
| 165 | public void testOpenAndCloseGuts() { |
| 166 | NotificationGuts guts = spy(new NotificationGuts(mContext)); |
| 167 | when(guts.post(any())).thenAnswer(invocation -> { |
| 168 | mHandler.post(((Runnable) invocation.getArguments()[0])); |
| 169 | return null; |
| 170 | }); |
| 171 | |
| 172 | // Test doesn't support animation since the guts view is not attached. |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 173 | doNothing().when(guts).openControls( |
| 174 | eq(true) /* shouldDoCircularReveal */, |
| 175 | anyInt(), |
| 176 | anyInt(), |
| 177 | anyBoolean(), |
| 178 | any(Runnable.class)); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 179 | |
| 180 | ExpandableNotificationRow realRow = createTestNotificationRow(); |
| 181 | NotificationMenuRowPlugin.MenuItem menuItem = createTestMenuItem(realRow); |
| 182 | |
| 183 | ExpandableNotificationRow row = spy(realRow); |
| 184 | when(row.getWindowToken()).thenReturn(new Binder()); |
| 185 | when(row.getGuts()).thenReturn(guts); |
| 186 | |
Evan Laird | 03cf350 | 2019-05-31 16:46:48 -0400 | [diff] [blame] | 187 | assertTrue(mGutsManager.openGutsInternal(row, 0, 0, menuItem)); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 188 | assertEquals(View.INVISIBLE, guts.getVisibility()); |
| 189 | mTestableLooper.processAllMessages(); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 190 | verify(guts).openControls( |
| 191 | eq(true), |
| 192 | anyInt(), |
| 193 | anyInt(), |
| 194 | anyBoolean(), |
| 195 | any(Runnable.class)); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 196 | |
| 197 | assertEquals(View.VISIBLE, guts.getVisibility()); |
| 198 | mGutsManager.closeAndSaveGuts(false, false, false, 0, 0, false); |
| 199 | |
| 200 | verify(guts).closeControls(anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyBoolean()); |
| 201 | verify(row, times(1)).setGutsView(any()); |
| 202 | } |
| 203 | |
| 204 | @Test |
| 205 | public void testChangeDensityOrFontScale() { |
| 206 | NotificationGuts guts = spy(new NotificationGuts(mContext)); |
| 207 | when(guts.post(any())).thenAnswer(invocation -> { |
| 208 | mHandler.post(((Runnable) invocation.getArguments()[0])); |
| 209 | return null; |
| 210 | }); |
| 211 | |
| 212 | // Test doesn't support animation since the guts view is not attached. |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 213 | doNothing().when(guts).openControls( |
| 214 | eq(true) /* shouldDoCircularReveal */, |
| 215 | anyInt(), |
| 216 | anyInt(), |
| 217 | anyBoolean(), |
| 218 | any(Runnable.class)); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 219 | |
| 220 | ExpandableNotificationRow realRow = createTestNotificationRow(); |
| 221 | NotificationMenuRowPlugin.MenuItem menuItem = createTestMenuItem(realRow); |
| 222 | |
| 223 | ExpandableNotificationRow row = spy(realRow); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 224 | |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 225 | when(row.getWindowToken()).thenReturn(new Binder()); |
| 226 | when(row.getGuts()).thenReturn(guts); |
Evan Laird | e55c601 | 2019-03-13 12:54:37 -0400 | [diff] [blame] | 227 | doNothing().when(row).ensureGutsInflated(); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 228 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 229 | NotificationEntry realEntry = realRow.getEntry(); |
| 230 | NotificationEntry entry = spy(realEntry); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 231 | |
| 232 | when(entry.getRow()).thenReturn(row); |
| 233 | when(entry.getGuts()).thenReturn(guts); |
| 234 | |
Evan Laird | 03cf350 | 2019-05-31 16:46:48 -0400 | [diff] [blame] | 235 | assertTrue(mGutsManager.openGutsInternal(row, 0, 0, menuItem)); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 236 | mTestableLooper.processAllMessages(); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 237 | verify(guts).openControls( |
| 238 | eq(true), |
| 239 | anyInt(), |
| 240 | anyInt(), |
| 241 | anyBoolean(), |
| 242 | any(Runnable.class)); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 243 | |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 244 | // called once by mGutsManager.bindGuts() in mGutsManager.openGuts() |
| 245 | verify(row).setGutsView(any()); |
| 246 | |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 247 | row.onDensityOrFontScaleChanged(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 248 | mGutsManager.onDensityOrFontScaleChanged(entry); |
| 249 | |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 250 | mTestableLooper.processAllMessages(); |
| 251 | |
| 252 | mGutsManager.closeAndSaveGuts(false, false, false, 0, 0, false); |
| 253 | |
| 254 | verify(guts).closeControls(anyBoolean(), anyBoolean(), anyInt(), anyInt(), anyBoolean()); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 255 | |
| 256 | // called again by mGutsManager.bindGuts(), in mGutsManager.onDensityOrFontScaleChanged() |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 257 | verify(row, times(2)).setGutsView(any()); |
| 258 | } |
| 259 | |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 260 | @Test |
| 261 | public void testAppOpsSettingsIntent_camera() { |
| 262 | ArraySet<Integer> ops = new ArraySet<>(); |
| 263 | ops.add(OP_CAMERA); |
| 264 | mGutsManager.startAppOpsSettingsActivity("", 0, ops, null); |
| 265 | ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 266 | verify(mNotificationActivityStarter, times(1)) |
| 267 | .startNotificationGutsIntent(captor.capture(), anyInt(), any()); |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 268 | assertEquals(Intent.ACTION_MANAGE_APP_PERMISSIONS, captor.getValue().getAction()); |
| 269 | } |
| 270 | |
| 271 | @Test |
| 272 | public void testAppOpsSettingsIntent_mic() { |
| 273 | ArraySet<Integer> ops = new ArraySet<>(); |
| 274 | ops.add(OP_RECORD_AUDIO); |
| 275 | mGutsManager.startAppOpsSettingsActivity("", 0, ops, null); |
| 276 | ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 277 | verify(mNotificationActivityStarter, times(1)) |
| 278 | .startNotificationGutsIntent(captor.capture(), anyInt(), any()); |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 279 | assertEquals(Intent.ACTION_MANAGE_APP_PERMISSIONS, captor.getValue().getAction()); |
| 280 | } |
| 281 | |
| 282 | @Test |
| 283 | public void testAppOpsSettingsIntent_camera_mic() { |
| 284 | ArraySet<Integer> ops = new ArraySet<>(); |
| 285 | ops.add(OP_CAMERA); |
| 286 | ops.add(OP_RECORD_AUDIO); |
| 287 | mGutsManager.startAppOpsSettingsActivity("", 0, ops, null); |
| 288 | ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 289 | verify(mNotificationActivityStarter, times(1)) |
| 290 | .startNotificationGutsIntent(captor.capture(), anyInt(), any()); |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 291 | assertEquals(Intent.ACTION_MANAGE_APP_PERMISSIONS, captor.getValue().getAction()); |
| 292 | } |
| 293 | |
| 294 | @Test |
| 295 | public void testAppOpsSettingsIntent_overlay() { |
| 296 | ArraySet<Integer> ops = new ArraySet<>(); |
| 297 | ops.add(OP_SYSTEM_ALERT_WINDOW); |
| 298 | mGutsManager.startAppOpsSettingsActivity("", 0, ops, null); |
| 299 | ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 300 | verify(mNotificationActivityStarter, times(1)) |
| 301 | .startNotificationGutsIntent(captor.capture(), anyInt(), any()); |
Bernardo Rufino | 8fefb94 | 2019-11-25 19:51:09 +0000 | [diff] [blame] | 302 | assertEquals(Settings.ACTION_MANAGE_APP_OVERLAY_PERMISSION, captor.getValue().getAction()); |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | @Test |
| 306 | public void testAppOpsSettingsIntent_camera_mic_overlay() { |
| 307 | ArraySet<Integer> ops = new ArraySet<>(); |
| 308 | ops.add(OP_CAMERA); |
| 309 | ops.add(OP_RECORD_AUDIO); |
| 310 | ops.add(OP_SYSTEM_ALERT_WINDOW); |
| 311 | mGutsManager.startAppOpsSettingsActivity("", 0, ops, null); |
| 312 | ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 313 | verify(mNotificationActivityStarter, times(1)) |
| 314 | .startNotificationGutsIntent(captor.capture(), anyInt(), any()); |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 315 | assertEquals(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, captor.getValue().getAction()); |
| 316 | } |
| 317 | |
| 318 | @Test |
| 319 | public void testAppOpsSettingsIntent_camera_overlay() { |
| 320 | ArraySet<Integer> ops = new ArraySet<>(); |
| 321 | ops.add(OP_CAMERA); |
| 322 | ops.add(OP_SYSTEM_ALERT_WINDOW); |
| 323 | mGutsManager.startAppOpsSettingsActivity("", 0, ops, null); |
| 324 | ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 325 | verify(mNotificationActivityStarter, times(1)) |
| 326 | .startNotificationGutsIntent(captor.capture(), anyInt(), any()); |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 327 | assertEquals(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, captor.getValue().getAction()); |
| 328 | } |
| 329 | |
| 330 | @Test |
| 331 | public void testAppOpsSettingsIntent_mic_overlay() { |
| 332 | ArraySet<Integer> ops = new ArraySet<>(); |
| 333 | ops.add(OP_RECORD_AUDIO); |
| 334 | ops.add(OP_SYSTEM_ALERT_WINDOW); |
| 335 | mGutsManager.startAppOpsSettingsActivity("", 0, ops, null); |
| 336 | ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); |
Gus Prevas | 21437b3 | 2018-12-05 10:36:13 -0500 | [diff] [blame] | 337 | verify(mNotificationActivityStarter, times(1)) |
| 338 | .startNotificationGutsIntent(captor.capture(), anyInt(), any()); |
Julia Reynolds | b586745 | 2018-02-28 16:31:35 -0500 | [diff] [blame] | 339 | assertEquals(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, captor.getValue().getAction()); |
| 340 | } |
| 341 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 342 | @Test |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 343 | public void testInitializeNotificationInfoView_highPriority() throws Exception { |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 344 | NotificationInfo notificationInfoView = mock(NotificationInfo.class); |
| 345 | ExpandableNotificationRow row = spy(mHelper.createRow()); |
Beverly | 7c1ad5b | 2019-12-05 17:17:15 -0500 | [diff] [blame] | 346 | final NotificationEntry entry = row.getEntry(); |
| 347 | modifyRanking(entry) |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 348 | .setUserSentiment(USER_SENTIMENT_NEGATIVE) |
Beverly | 7c1ad5b | 2019-12-05 17:17:15 -0500 | [diff] [blame] | 349 | .setImportance(IMPORTANCE_HIGH) |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 350 | .build(); |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 351 | |
Beverly | 7c1ad5b | 2019-12-05 17:17:15 -0500 | [diff] [blame] | 352 | when(row.getIsNonblockable()).thenReturn(false); |
Beverly | e558f1d | 2020-01-07 16:28:58 -0500 | [diff] [blame] | 353 | when(mHighPriorityProvider.isHighPriority(entry)).thenReturn(true); |
Beverly | 7c1ad5b | 2019-12-05 17:17:15 -0500 | [diff] [blame] | 354 | StatusBarNotification statusBarNotification = entry.getSbn(); |
Gus Prevas | 5a70a4e | 2018-11-26 17:16:05 -0500 | [diff] [blame] | 355 | mGutsManager.initializeNotificationInfo(row, notificationInfoView); |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 356 | |
| 357 | verify(notificationInfoView).bindNotification( |
| 358 | any(PackageManager.class), |
| 359 | any(INotificationManager.class), |
Ned Burns | 9512e0c | 2019-05-30 19:36:04 -0400 | [diff] [blame] | 360 | eq(mVisualStabilityManager), |
Evan Laird | 18bd6e6 | 2019-08-30 16:39:25 -0400 | [diff] [blame] | 361 | eq(mChannelEditorDialogController), |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 362 | eq(statusBarNotification.getPackageName()), |
| 363 | any(NotificationChannel.class), |
Evan Laird | 47dc454 | 2019-04-24 15:10:52 -0400 | [diff] [blame] | 364 | anySet(), |
Mady Mellor | 53162c1 | 2019-10-22 17:12:59 -0700 | [diff] [blame] | 365 | eq(entry), |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 366 | any(NotificationInfo.OnSettingsClickListener.class), |
| 367 | any(NotificationInfo.OnAppSettingsClickListener.class), |
Will Brockman | 4567a4c | 2020-06-21 17:19:50 -0400 | [diff] [blame] | 368 | any(UiEventLogger.class), |
Gus Prevas | 9abc506 | 2018-10-31 16:11:04 -0400 | [diff] [blame] | 369 | eq(false), |
| 370 | eq(false), |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 371 | eq(true) /* wasShownHighPriority */); |
Julia Reynolds | 35765d8 | 2018-08-17 11:39:19 -0400 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | @Test |
| 375 | public void testInitializeNotificationInfoView_PassesAlongProvisionedState() throws Exception { |
| 376 | NotificationInfo notificationInfoView = mock(NotificationInfo.class); |
| 377 | ExpandableNotificationRow row = spy(mHelper.createRow()); |
| 378 | row.setBlockingHelperShowing(false); |
Ned Burns | 47c98f1 | 2019-09-06 17:12:07 -0400 | [diff] [blame] | 379 | modifyRanking(row.getEntry()) |
| 380 | .setUserSentiment(USER_SENTIMENT_NEGATIVE) |
| 381 | .build(); |
Julia Reynolds | 35765d8 | 2018-08-17 11:39:19 -0400 | [diff] [blame] | 382 | when(row.getIsNonblockable()).thenReturn(false); |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 383 | StatusBarNotification statusBarNotification = row.getEntry().getSbn(); |
Mady Mellor | 53162c1 | 2019-10-22 17:12:59 -0700 | [diff] [blame] | 384 | NotificationEntry entry = row.getEntry(); |
| 385 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 386 | when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true); |
Julia Reynolds | 35765d8 | 2018-08-17 11:39:19 -0400 | [diff] [blame] | 387 | |
Gus Prevas | 5a70a4e | 2018-11-26 17:16:05 -0500 | [diff] [blame] | 388 | mGutsManager.initializeNotificationInfo(row, notificationInfoView); |
Julia Reynolds | 35765d8 | 2018-08-17 11:39:19 -0400 | [diff] [blame] | 389 | |
| 390 | verify(notificationInfoView).bindNotification( |
| 391 | any(PackageManager.class), |
| 392 | any(INotificationManager.class), |
Ned Burns | 9512e0c | 2019-05-30 19:36:04 -0400 | [diff] [blame] | 393 | eq(mVisualStabilityManager), |
Evan Laird | 18bd6e6 | 2019-08-30 16:39:25 -0400 | [diff] [blame] | 394 | eq(mChannelEditorDialogController), |
Julia Reynolds | 35765d8 | 2018-08-17 11:39:19 -0400 | [diff] [blame] | 395 | eq(statusBarNotification.getPackageName()), |
| 396 | any(NotificationChannel.class), |
Evan Laird | 47dc454 | 2019-04-24 15:10:52 -0400 | [diff] [blame] | 397 | anySet(), |
Mady Mellor | 53162c1 | 2019-10-22 17:12:59 -0700 | [diff] [blame] | 398 | eq(entry), |
Julia Reynolds | 35765d8 | 2018-08-17 11:39:19 -0400 | [diff] [blame] | 399 | any(NotificationInfo.OnSettingsClickListener.class), |
| 400 | any(NotificationInfo.OnAppSettingsClickListener.class), |
Will Brockman | 4567a4c | 2020-06-21 17:19:50 -0400 | [diff] [blame] | 401 | any(UiEventLogger.class), |
Julia Reynolds | 35765d8 | 2018-08-17 11:39:19 -0400 | [diff] [blame] | 402 | eq(true), |
| 403 | eq(false), |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 404 | eq(false) /* wasShownHighPriority */); |
Gus Prevas | 894d915 | 2018-11-12 13:51:40 -0500 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | @Test |
| 408 | public void testInitializeNotificationInfoView_withInitialAction() throws Exception { |
| 409 | NotificationInfo notificationInfoView = mock(NotificationInfo.class); |
| 410 | ExpandableNotificationRow row = spy(mHelper.createRow()); |
| 411 | row.setBlockingHelperShowing(true); |
Ned Burns | 47c98f1 | 2019-09-06 17:12:07 -0400 | [diff] [blame] | 412 | modifyRanking(row.getEntry()) |
| 413 | .setUserSentiment(USER_SENTIMENT_NEGATIVE) |
| 414 | .build(); |
Gus Prevas | 894d915 | 2018-11-12 13:51:40 -0500 | [diff] [blame] | 415 | when(row.getIsNonblockable()).thenReturn(false); |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 416 | StatusBarNotification statusBarNotification = row.getEntry().getSbn(); |
Mady Mellor | 53162c1 | 2019-10-22 17:12:59 -0700 | [diff] [blame] | 417 | NotificationEntry entry = row.getEntry(); |
Gus Prevas | 894d915 | 2018-11-12 13:51:40 -0500 | [diff] [blame] | 418 | |
Gus Prevas | 5a70a4e | 2018-11-26 17:16:05 -0500 | [diff] [blame] | 419 | mGutsManager.initializeNotificationInfo(row, notificationInfoView); |
Gus Prevas | 894d915 | 2018-11-12 13:51:40 -0500 | [diff] [blame] | 420 | |
| 421 | verify(notificationInfoView).bindNotification( |
| 422 | any(PackageManager.class), |
| 423 | any(INotificationManager.class), |
Ned Burns | 9512e0c | 2019-05-30 19:36:04 -0400 | [diff] [blame] | 424 | eq(mVisualStabilityManager), |
Evan Laird | 18bd6e6 | 2019-08-30 16:39:25 -0400 | [diff] [blame] | 425 | eq(mChannelEditorDialogController), |
Gus Prevas | 894d915 | 2018-11-12 13:51:40 -0500 | [diff] [blame] | 426 | eq(statusBarNotification.getPackageName()), |
| 427 | any(NotificationChannel.class), |
Evan Laird | 47dc454 | 2019-04-24 15:10:52 -0400 | [diff] [blame] | 428 | anySet(), |
Mady Mellor | 53162c1 | 2019-10-22 17:12:59 -0700 | [diff] [blame] | 429 | eq(entry), |
Gus Prevas | 894d915 | 2018-11-12 13:51:40 -0500 | [diff] [blame] | 430 | any(NotificationInfo.OnSettingsClickListener.class), |
| 431 | any(NotificationInfo.OnAppSettingsClickListener.class), |
Will Brockman | 4567a4c | 2020-06-21 17:19:50 -0400 | [diff] [blame] | 432 | any(UiEventLogger.class), |
Gus Prevas | 894d915 | 2018-11-12 13:51:40 -0500 | [diff] [blame] | 433 | eq(false), |
| 434 | eq(false), |
Gus Prevas | caed15c | 2019-01-18 14:19:51 -0500 | [diff] [blame] | 435 | eq(false) /* wasShownHighPriority */); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 436 | } |
| 437 | |
Kevin | a5ff1fa | 2018-08-21 16:35:48 -0700 | [diff] [blame] | 438 | @Test |
| 439 | public void testShouldExtendLifetime() { |
| 440 | NotificationGuts guts = new NotificationGuts(mContext); |
| 441 | ExpandableNotificationRow row = spy(createTestNotificationRow()); |
| 442 | doReturn(guts).when(row).getGuts(); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 443 | NotificationEntry entry = row.getEntry(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 444 | entry.setRow(row); |
Kevin | a5ff1fa | 2018-08-21 16:35:48 -0700 | [diff] [blame] | 445 | mGutsManager.setExposedGuts(guts); |
| 446 | |
| 447 | assertTrue(mGutsManager.shouldExtendLifetime(entry)); |
| 448 | } |
| 449 | |
| 450 | @Test |
Selim Cinek | 2476ed7 | 2019-03-07 13:19:23 -0800 | [diff] [blame] | 451 | @Ignore |
Kevin | e9e938c | 2018-09-06 13:38:11 -0700 | [diff] [blame] | 452 | public void testSetShouldManageLifetime_setShouldManage() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 453 | NotificationEntry entry = createTestNotificationRow().getEntry(); |
Kevin | e9e938c | 2018-09-06 13:38:11 -0700 | [diff] [blame] | 454 | mGutsManager.setShouldManageLifetime(entry, true /* shouldManage */); |
Kevin | a5ff1fa | 2018-08-21 16:35:48 -0700 | [diff] [blame] | 455 | |
Ned Burns | 00b4b2d | 2019-10-17 22:09:27 -0400 | [diff] [blame] | 456 | assertTrue(entry.getKey().equals(mGutsManager.mKeyToRemoveOnGutsClosed)); |
Kevin | a5ff1fa | 2018-08-21 16:35:48 -0700 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | @Test |
Kevin | e9e938c | 2018-09-06 13:38:11 -0700 | [diff] [blame] | 460 | public void testSetShouldManageLifetime_setShouldNotManage() { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 461 | NotificationEntry entry = createTestNotificationRow().getEntry(); |
Ned Burns | 00b4b2d | 2019-10-17 22:09:27 -0400 | [diff] [blame] | 462 | mGutsManager.mKeyToRemoveOnGutsClosed = entry.getKey(); |
Kevin | e9e938c | 2018-09-06 13:38:11 -0700 | [diff] [blame] | 463 | mGutsManager.setShouldManageLifetime(entry, false /* shouldManage */); |
Kevin | a5ff1fa | 2018-08-21 16:35:48 -0700 | [diff] [blame] | 464 | |
| 465 | assertNull(mGutsManager.mKeyToRemoveOnGutsClosed); |
| 466 | } |
| 467 | |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 468 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 469 | // Utility methods: |
| 470 | |
| 471 | private ExpandableNotificationRow createTestNotificationRow() { |
| 472 | Notification.Builder nb = new Notification.Builder(mContext, |
| 473 | mTestNotificationChannel.getId()) |
| 474 | .setContentTitle("foo") |
| 475 | .setColorized(true) |
| 476 | .setFlag(Notification.FLAG_CAN_COLORIZE, true) |
| 477 | .setSmallIcon(android.R.drawable.sym_def_app_icon); |
| 478 | |
| 479 | try { |
| 480 | ExpandableNotificationRow row = mHelper.createRow(nb.build()); |
Ned Burns | 60e9459 | 2019-09-06 14:47:25 -0400 | [diff] [blame] | 481 | modifyRanking(row.getEntry()) |
| 482 | .setChannel(mTestNotificationChannel) |
| 483 | .build(); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 484 | return row; |
| 485 | } catch (Exception e) { |
| 486 | fail(); |
| 487 | return null; |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | private NotificationMenuRowPlugin.MenuItem createTestMenuItem(ExpandableNotificationRow row) { |
Steve Elliott | 2304e4a | 2020-04-01 17:03:41 -0400 | [diff] [blame] | 492 | NotificationMenuRowPlugin menuRow = |
| 493 | new NotificationMenuRow(mContext, mPeopleNotificationIdentifier); |
Ned Burns | 1c2b85a4 | 2019-11-14 15:37:03 -0500 | [diff] [blame] | 494 | menuRow.createMenu(row, row.getEntry().getSbn()); |
yoshiki iguchi | a85c2a0 | 2018-01-12 11:28:06 +0900 | [diff] [blame] | 495 | |
| 496 | NotificationMenuRowPlugin.MenuItem menuItem = menuRow.getLongpressMenuItem(mContext); |
| 497 | assertNotNull(menuItem); |
| 498 | return menuItem; |
| 499 | } |
| 500 | } |