Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | |
| 17 | package com.android.systemui.statusbar; |
| 18 | |
| 19 | import static junit.framework.Assert.assertTrue; |
| 20 | |
| 21 | import static org.junit.Assert.assertEquals; |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 22 | import static org.mockito.ArgumentMatchers.any; |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 23 | import static org.mockito.ArgumentMatchers.anyInt; |
| 24 | import static org.mockito.Mockito.clearInvocations; |
| 25 | import static org.mockito.Mockito.doAnswer; |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 26 | import static org.mockito.Mockito.mock; |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 27 | import static org.mockito.Mockito.spy; |
| 28 | import static org.mockito.Mockito.times; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 29 | import static org.mockito.Mockito.verify; |
| 30 | import static org.mockito.Mockito.when; |
| 31 | |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 32 | import android.os.Handler; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 33 | import android.testing.AndroidTestingRunner; |
| 34 | import android.testing.TestableLooper; |
| 35 | import android.view.View; |
| 36 | import android.view.ViewGroup; |
| 37 | import android.widget.LinearLayout; |
| 38 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 39 | import androidx.test.filters.SmallTest; |
| 40 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 41 | import com.android.systemui.Dependency; |
| 42 | import com.android.systemui.InitController; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 43 | import com.android.systemui.SysuiTestCase; |
Mady Mellor | ce23c46 | 2019-06-17 17:30:07 -0700 | [diff] [blame] | 44 | import com.android.systemui.bubbles.BubbleController; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 45 | import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper; |
Selim Cinek | 6f0a62a | 2019-04-09 18:40:12 -0700 | [diff] [blame] | 46 | import com.android.systemui.statusbar.notification.DynamicPrivacyController; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 47 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 48 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 49 | import com.android.systemui.statusbar.notification.collection.NotificationData; |
| 50 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 51 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
| 52 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
| 53 | import com.android.systemui.statusbar.notification.row.ExpandableView; |
| 54 | import com.android.systemui.statusbar.notification.stack.NotificationListContainer; |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 55 | import com.android.systemui.statusbar.phone.KeyguardBypassController; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 56 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 57 | import com.android.systemui.statusbar.phone.ShadeController; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 58 | import com.android.systemui.util.Assert; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 59 | |
| 60 | import com.google.android.collect.Lists; |
| 61 | |
| 62 | import org.junit.Before; |
| 63 | import org.junit.Test; |
| 64 | import org.junit.runner.RunWith; |
| 65 | import org.mockito.Mock; |
| 66 | import org.mockito.MockitoAnnotations; |
| 67 | import org.mockito.Spy; |
| 68 | |
| 69 | import java.util.List; |
| 70 | |
| 71 | @SmallTest |
| 72 | @RunWith(AndroidTestingRunner.class) |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 73 | @TestableLooper.RunWithLooper |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 74 | public class NotificationViewHierarchyManagerTest extends SysuiTestCase { |
| 75 | @Mock private NotificationPresenter mPresenter; |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 76 | @Mock private NotificationData mNotificationData; |
| 77 | @Spy private FakeListContainer mListContainer = new FakeListContainer(); |
| 78 | |
| 79 | // Dependency mocks: |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 80 | @Mock private NotificationEntryManager mEntryManager; |
| 81 | @Mock private NotificationLockscreenUserManager mLockscreenUserManager; |
| 82 | @Mock private NotificationGroupManager mGroupManager; |
| 83 | @Mock private VisualStabilityManager mVisualStabilityManager; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 84 | @Mock private ShadeController mShadeController; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 85 | |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 86 | private TestableLooper mTestableLooper; |
| 87 | private Handler mHandler; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 88 | private NotificationViewHierarchyManager mViewHierarchyManager; |
Ned Burns | 01e3821 | 2019-01-03 16:32:52 -0500 | [diff] [blame] | 89 | private NotificationTestHelper mHelper; |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 90 | private boolean mMadeReentrantCall = false; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 91 | |
| 92 | @Before |
| 93 | public void setUp() { |
| 94 | MockitoAnnotations.initMocks(this); |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 95 | mTestableLooper = TestableLooper.get(this); |
| 96 | Assert.sMainLooper = mTestableLooper.getLooper(); |
| 97 | mHandler = Handler.createAsync(mTestableLooper.getLooper()); |
| 98 | |
Eliot Courtney | 8f56b0e | 2017-12-14 18:54:28 +0900 | [diff] [blame] | 99 | mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager); |
| 100 | mDependency.injectTestDependency(NotificationLockscreenUserManager.class, |
| 101 | mLockscreenUserManager); |
| 102 | mDependency.injectTestDependency(NotificationGroupManager.class, mGroupManager); |
| 103 | mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 104 | mDependency.injectTestDependency(ShadeController.class, mShadeController); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 105 | |
Ned Burns | 01e3821 | 2019-01-03 16:32:52 -0500 | [diff] [blame] | 106 | mHelper = new NotificationTestHelper(mContext); |
| 107 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 108 | when(mEntryManager.getNotificationData()).thenReturn(mNotificationData); |
| 109 | |
Jason Monk | 09f4d37 | 2018-12-20 15:30:54 -0500 | [diff] [blame] | 110 | mViewHierarchyManager = new NotificationViewHierarchyManager(mContext, |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 111 | mHandler, mLockscreenUserManager, mGroupManager, mVisualStabilityManager, |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 112 | mock(StatusBarStateControllerImpl.class), mEntryManager, |
Mady Mellor | ce23c46 | 2019-06-17 17:30:07 -0700 | [diff] [blame] | 113 | () -> mShadeController, |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 114 | mock(KeyguardBypassController.class), |
Mady Mellor | ce23c46 | 2019-06-17 17:30:07 -0700 | [diff] [blame] | 115 | mock(BubbleController.class), |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 116 | mock(DynamicPrivacyController.class)); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 117 | Dependency.get(InitController.class).executePostInitTasks(); |
| 118 | mViewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 119 | } |
| 120 | |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 121 | private NotificationEntry createEntry() throws Exception { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 122 | ExpandableNotificationRow row = mHelper.createRow(); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 123 | NotificationEntry entry = new NotificationEntry(row.getStatusBarNotification()); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 124 | entry.setRow(row); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 125 | return entry; |
| 126 | } |
| 127 | |
| 128 | @Test |
| 129 | public void testNotificationsBecomingBundled() throws Exception { |
| 130 | // Tests 3 top level notifications becoming a single bundled notification with |entry0| as |
| 131 | // the summary. |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 132 | NotificationEntry entry0 = createEntry(); |
| 133 | NotificationEntry entry1 = createEntry(); |
| 134 | NotificationEntry entry2 = createEntry(); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 135 | |
| 136 | // Set up the prior state to look like three top level notifications. |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 137 | mListContainer.addContainerView(entry0.getRow()); |
| 138 | mListContainer.addContainerView(entry1.getRow()); |
| 139 | mListContainer.addContainerView(entry2.getRow()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 140 | when(mNotificationData.getActiveNotifications()).thenReturn( |
| 141 | Lists.newArrayList(entry0, entry1, entry2)); |
| 142 | |
| 143 | // Set up group manager to report that they should be bundled now. |
| 144 | when(mGroupManager.isChildInGroupWithSummary(entry0.notification)).thenReturn(false); |
| 145 | when(mGroupManager.isChildInGroupWithSummary(entry1.notification)).thenReturn(true); |
| 146 | when(mGroupManager.isChildInGroupWithSummary(entry2.notification)).thenReturn(true); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 147 | when(mGroupManager.getGroupSummary(entry1.notification)).thenReturn(entry0); |
| 148 | when(mGroupManager.getGroupSummary(entry2.notification)).thenReturn(entry0); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 149 | |
| 150 | // Run updateNotifications - the view hierarchy should be reorganized. |
| 151 | mViewHierarchyManager.updateNotificationViews(); |
| 152 | |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 153 | verify(mListContainer).notifyGroupChildAdded(entry1.getRow()); |
| 154 | verify(mListContainer).notifyGroupChildAdded(entry2.getRow()); |
| 155 | assertTrue(Lists.newArrayList(entry0.getRow()).equals(mListContainer.mRows)); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | @Test |
| 159 | public void testNotificationsBecomingUnbundled() throws Exception { |
| 160 | // Tests a bundled notification becoming three top level notifications. |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 161 | NotificationEntry entry0 = createEntry(); |
| 162 | NotificationEntry entry1 = createEntry(); |
| 163 | NotificationEntry entry2 = createEntry(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 164 | entry0.getRow().addChildNotification(entry1.getRow()); |
| 165 | entry0.getRow().addChildNotification(entry2.getRow()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 166 | |
| 167 | // Set up the prior state to look like one top level notification. |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 168 | mListContainer.addContainerView(entry0.getRow()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 169 | when(mNotificationData.getActiveNotifications()).thenReturn( |
| 170 | Lists.newArrayList(entry0, entry1, entry2)); |
| 171 | |
| 172 | // Set up group manager to report that they should not be bundled now. |
| 173 | when(mGroupManager.isChildInGroupWithSummary(entry0.notification)).thenReturn(false); |
| 174 | when(mGroupManager.isChildInGroupWithSummary(entry1.notification)).thenReturn(false); |
| 175 | when(mGroupManager.isChildInGroupWithSummary(entry2.notification)).thenReturn(false); |
| 176 | |
| 177 | // Run updateNotifications - the view hierarchy should be reorganized. |
| 178 | mViewHierarchyManager.updateNotificationViews(); |
| 179 | |
| 180 | verify(mListContainer).notifyGroupChildRemoved( |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 181 | entry1.getRow(), entry0.getRow().getChildrenContainer()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 182 | verify(mListContainer).notifyGroupChildRemoved( |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 183 | entry2.getRow(), entry0.getRow().getChildrenContainer()); |
| 184 | assertTrue( |
| 185 | Lists.newArrayList(entry0.getRow(), entry1.getRow(), entry2.getRow()) |
| 186 | .equals(mListContainer.mRows)); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | @Test |
| 190 | public void testNotificationsBecomingSuppressed() throws Exception { |
| 191 | // Tests two top level notifications becoming a suppressed summary and a child. |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 192 | NotificationEntry entry0 = createEntry(); |
| 193 | NotificationEntry entry1 = createEntry(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 194 | entry0.getRow().addChildNotification(entry1.getRow()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 195 | |
| 196 | // Set up the prior state to look like a top level notification. |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 197 | mListContainer.addContainerView(entry0.getRow()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 198 | when(mNotificationData.getActiveNotifications()).thenReturn( |
| 199 | Lists.newArrayList(entry0, entry1)); |
| 200 | |
| 201 | // Set up group manager to report a suppressed summary now. |
| 202 | when(mGroupManager.isChildInGroupWithSummary(entry0.notification)).thenReturn(false); |
| 203 | when(mGroupManager.isChildInGroupWithSummary(entry1.notification)).thenReturn(false); |
| 204 | when(mGroupManager.isSummaryOfSuppressedGroup(entry0.notification)).thenReturn(true); |
| 205 | |
| 206 | // Run updateNotifications - the view hierarchy should be reorganized. |
| 207 | mViewHierarchyManager.updateNotificationViews(); |
| 208 | |
| 209 | verify(mListContainer).notifyGroupChildRemoved( |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 210 | entry1.getRow(), entry0.getRow().getChildrenContainer()); |
| 211 | assertTrue(Lists.newArrayList(entry0.getRow(), entry1.getRow()).equals(mListContainer.mRows)); |
| 212 | assertEquals(View.GONE, entry0.getRow().getVisibility()); |
| 213 | assertEquals(View.VISIBLE, entry1.getRow().getVisibility()); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 214 | } |
| 215 | |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 216 | @Test |
| 217 | public void testUpdateNotificationViews_appOps() throws Exception { |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 218 | NotificationEntry entry0 = createEntry(); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 219 | entry0.setRow(spy(entry0.getRow())); |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 220 | when(mNotificationData.getActiveNotifications()).thenReturn( |
| 221 | Lists.newArrayList(entry0)); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 222 | mListContainer.addContainerView(entry0.getRow()); |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 223 | |
| 224 | mViewHierarchyManager.updateNotificationViews(); |
| 225 | |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 226 | verify(entry0.getRow(), times(1)).showAppOpsIcons(any()); |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 227 | } |
| 228 | |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 229 | @Test |
| 230 | public void testReentrantCallsToOnDynamicPrivacyChangedPostForLater() { |
| 231 | // GIVEN a ListContainer that will make a re-entrant call to updateNotificationViews() |
| 232 | mMadeReentrantCall = false; |
| 233 | doAnswer((invocation) -> { |
| 234 | if (!mMadeReentrantCall) { |
| 235 | mMadeReentrantCall = true; |
| 236 | mViewHierarchyManager.onDynamicPrivacyChanged(); |
| 237 | } |
| 238 | return null; |
| 239 | }).when(mListContainer).setMaxDisplayedNotifications(anyInt()); |
| 240 | |
| 241 | // WHEN we call updateNotificationViews() |
| 242 | mViewHierarchyManager.updateNotificationViews(); |
| 243 | |
| 244 | // THEN onNotificationViewUpdateFinished() is only called once |
| 245 | verify(mListContainer).onNotificationViewUpdateFinished(); |
| 246 | |
| 247 | // WHEN we drain the looper |
| 248 | mTestableLooper.processAllMessages(); |
| 249 | |
| 250 | // THEN updateNotificationViews() is called a second time (for the reentrant call) |
| 251 | verify(mListContainer, times(2)).onNotificationViewUpdateFinished(); |
| 252 | } |
| 253 | |
| 254 | @Test |
| 255 | public void testMultipleReentrantCallsToOnDynamicPrivacyChangedOnlyPostOnce() { |
| 256 | // GIVEN a ListContainer that will make many re-entrant calls to updateNotificationViews() |
| 257 | mMadeReentrantCall = false; |
| 258 | doAnswer((invocation) -> { |
| 259 | if (!mMadeReentrantCall) { |
| 260 | mMadeReentrantCall = true; |
| 261 | mViewHierarchyManager.onDynamicPrivacyChanged(); |
| 262 | mViewHierarchyManager.onDynamicPrivacyChanged(); |
| 263 | mViewHierarchyManager.onDynamicPrivacyChanged(); |
| 264 | mViewHierarchyManager.onDynamicPrivacyChanged(); |
| 265 | } |
| 266 | return null; |
| 267 | }).when(mListContainer).setMaxDisplayedNotifications(anyInt()); |
| 268 | |
| 269 | // WHEN we call updateNotificationViews() and drain the looper |
| 270 | mViewHierarchyManager.updateNotificationViews(); |
| 271 | verify(mListContainer).onNotificationViewUpdateFinished(); |
| 272 | clearInvocations(mListContainer); |
| 273 | mTestableLooper.processAllMessages(); |
| 274 | |
| 275 | // THEN updateNotificationViews() is called only one more time |
| 276 | verify(mListContainer).onNotificationViewUpdateFinished(); |
| 277 | } |
| 278 | |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 279 | private class FakeListContainer implements NotificationListContainer { |
| 280 | final LinearLayout mLayout = new LinearLayout(mContext); |
| 281 | final List<View> mRows = Lists.newArrayList(); |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 282 | private boolean mMakeReentrantCallDuringSetMaxDisplayedNotifications; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 283 | |
| 284 | @Override |
| 285 | public void setChildTransferInProgress(boolean childTransferInProgress) {} |
| 286 | |
| 287 | @Override |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 288 | public void changeViewPosition(ExpandableView child, int newIndex) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 289 | mRows.remove(child); |
| 290 | mRows.add(newIndex, child); |
| 291 | } |
| 292 | |
| 293 | @Override |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 294 | public void notifyGroupChildAdded(ExpandableView row) {} |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 295 | |
| 296 | @Override |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 297 | public void notifyGroupChildRemoved(ExpandableView row, ViewGroup childrenContainer) {} |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 298 | |
| 299 | @Override |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 300 | public void generateAddAnimation(ExpandableView child, boolean fromMoreCard) {} |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 301 | |
| 302 | @Override |
| 303 | public void generateChildOrderChangedEvent() {} |
| 304 | |
| 305 | @Override |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 306 | public void onReset(ExpandableView view) {} |
| 307 | |
| 308 | @Override |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 309 | public int getContainerChildCount() { |
| 310 | return mRows.size(); |
| 311 | } |
| 312 | |
| 313 | @Override |
| 314 | public View getContainerChildAt(int i) { |
| 315 | return mRows.get(i); |
| 316 | } |
| 317 | |
| 318 | @Override |
| 319 | public void removeContainerView(View v) { |
| 320 | mLayout.removeView(v); |
| 321 | mRows.remove(v); |
| 322 | } |
| 323 | |
| 324 | @Override |
| 325 | public void addContainerView(View v) { |
| 326 | mLayout.addView(v); |
| 327 | mRows.add(v); |
| 328 | } |
| 329 | |
| 330 | @Override |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 331 | public void setMaxDisplayedNotifications(int maxNotifications) { |
| 332 | if (mMakeReentrantCallDuringSetMaxDisplayedNotifications) { |
| 333 | mViewHierarchyManager.onDynamicPrivacyChanged(); |
| 334 | } |
| 335 | } |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 336 | |
| 337 | @Override |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 338 | public ViewGroup getViewParentForNotification(NotificationEntry entry) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 339 | return null; |
| 340 | } |
| 341 | |
| 342 | @Override |
| 343 | public void onHeightChanged(ExpandableView view, boolean animate) {} |
| 344 | |
| 345 | @Override |
| 346 | public void resetExposedMenuView(boolean animate, boolean force) {} |
| 347 | |
| 348 | @Override |
| 349 | public NotificationSwipeActionHelper getSwipeActionHelper() { |
| 350 | return null; |
| 351 | } |
| 352 | |
| 353 | @Override |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 354 | public void cleanUpViewStateForEntry(NotificationEntry entry) { } |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 355 | |
| 356 | @Override |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 357 | public boolean isInVisibleLocation(NotificationEntry entry) { |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 358 | return true; |
| 359 | } |
| 360 | |
| 361 | @Override |
| 362 | public void setChildLocationsChangedListener( |
| 363 | NotificationLogger.OnChildLocationsChangedListener listener) {} |
| 364 | |
| 365 | @Override |
| 366 | public boolean hasPulsingNotifications() { |
| 367 | return false; |
| 368 | } |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 369 | |
Ned Burns | b3b4bd3 | 2019-06-27 19:36:58 -0400 | [diff] [blame] | 370 | @Override |
| 371 | public void onNotificationViewUpdateFinished() { } |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 372 | } |
| 373 | } |