Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [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.stack; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 18 | |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 19 | import static org.mockito.Mockito.atLeast; |
| 20 | import static org.mockito.Mockito.mock; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 21 | import static org.mockito.Mockito.never; |
| 22 | import static org.mockito.Mockito.reset; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 23 | import static org.mockito.Mockito.verify; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 24 | import static org.mockito.Mockito.when; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 25 | |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 26 | import android.testing.AndroidTestingRunner; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 27 | import android.testing.TestableLooper; |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 28 | import android.testing.TestableLooper.RunWithLooper; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 29 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 30 | import androidx.test.filters.SmallTest; |
| 31 | |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 32 | import com.android.systemui.SysuiTestCase; |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 33 | import com.android.systemui.statusbar.AmbientPulseManager; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 34 | import com.android.systemui.statusbar.NotificationTestHelper; |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 35 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 36 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 37 | import com.android.systemui.statusbar.notification.row.ExpandableView; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 38 | |
| 39 | import org.junit.Assert; |
| 40 | import org.junit.Before; |
| 41 | import org.junit.Test; |
| 42 | import org.junit.runner.RunWith; |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 43 | import org.mockito.Mock; |
| 44 | import org.mockito.MockitoAnnotations; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 45 | |
| 46 | import java.util.HashSet; |
| 47 | |
| 48 | @SmallTest |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 49 | @RunWith(AndroidTestingRunner.class) |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 50 | @RunWithLooper |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 51 | public class NotificationRoundnessManagerTest extends SysuiTestCase { |
| 52 | |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 53 | private NotificationRoundnessManager mRoundnessManager; |
Dave Mankoff | a4d195d | 2018-11-16 13:33:27 -0500 | [diff] [blame] | 54 | private HashSet<ExpandableView> mAnimatedChildren = new HashSet<>(); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 55 | private Runnable mRoundnessCallback = mock(Runnable.class); |
| 56 | private ExpandableNotificationRow mFirst; |
| 57 | private ExpandableNotificationRow mSecond; |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 58 | @Mock |
| 59 | private AmbientPulseManager mAmbientPulseManager; |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 60 | |
| 61 | @Before |
| 62 | public void setUp() throws Exception { |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 63 | MockitoAnnotations.initMocks(this); |
| 64 | mRoundnessManager = new NotificationRoundnessManager(mAmbientPulseManager); |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 65 | com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 66 | NotificationTestHelper testHelper = new NotificationTestHelper(getContext()); |
| 67 | mFirst = testHelper.createRow(); |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 68 | mFirst.setHeadsUpAnimatingAwayListener(animatingAway |
| 69 | -> mRoundnessManager.onHeadsupAnimatingAwayChanged(mFirst, animatingAway)); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 70 | mSecond = testHelper.createRow(); |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 71 | mSecond.setHeadsUpAnimatingAwayListener(animatingAway |
| 72 | -> mRoundnessManager.onHeadsupAnimatingAwayChanged(mSecond, animatingAway)); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 73 | mRoundnessManager.setOnRoundingChangedCallback(mRoundnessCallback); |
| 74 | mRoundnessManager.setAnimatedChildren(mAnimatedChildren); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 75 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 76 | createSection(mFirst, mFirst), |
| 77 | createSection(null, null) |
| 78 | }); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 79 | mRoundnessManager.setExpanded(1.0f, 1.0f); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 80 | reset(mRoundnessCallback); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | @Test |
| 84 | public void testCallbackCalledWhenSecondChanged() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 85 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 86 | createSection(mFirst, mSecond), |
| 87 | createSection(null, null) |
| 88 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 89 | verify(mRoundnessCallback, atLeast(1)).run(); |
| 90 | } |
| 91 | |
| 92 | @Test |
| 93 | public void testCallbackCalledWhenFirstChanged() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 94 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 95 | createSection(mSecond, mFirst), |
| 96 | createSection(null, null) |
| 97 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 98 | verify(mRoundnessCallback, atLeast(1)).run(); |
| 99 | } |
| 100 | |
| 101 | @Test |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 102 | public void testCallbackCalledWhenSecondSectionFirstChanged() { |
| 103 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 104 | createSection(mFirst, mFirst), |
| 105 | createSection(mSecond, null) |
| 106 | }); |
| 107 | verify(mRoundnessCallback, atLeast(1)).run(); |
| 108 | } |
| 109 | |
| 110 | @Test |
| 111 | public void testCallbackCalledWhenSecondSectionLastChanged() { |
| 112 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 113 | createSection(mFirst, mFirst), |
| 114 | createSection(null, mSecond) |
| 115 | }); |
| 116 | verify(mRoundnessCallback, atLeast(1)).run(); |
| 117 | } |
| 118 | |
| 119 | @Test |
| 120 | public void testCallbackNotCalledWhenFirstChangesSections() { |
| 121 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 122 | createSection(null, mFirst), |
| 123 | createSection(mFirst, null) |
| 124 | }); |
| 125 | verify(mRoundnessCallback, never()).run(); |
| 126 | } |
| 127 | |
| 128 | @Test |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 129 | public void testRoundnessSetOnLast() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 130 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 131 | createSection(mFirst, mSecond), |
| 132 | createSection(null, null) |
| 133 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 134 | Assert.assertEquals(1.0f, mSecond.getCurrentBottomRoundness(), 0.0f); |
| 135 | Assert.assertEquals(0.0f, mSecond.getCurrentTopRoundness(), 0.0f); |
| 136 | } |
| 137 | |
| 138 | @Test |
Lucas Dupin | 00be88f | 2019-01-03 17:50:52 -0800 | [diff] [blame] | 139 | public void testRoundnessPulsing() throws Exception { |
| 140 | // Let's create a notification that's neither the first or last item of the stack, |
| 141 | // this way we'll ensure that it won't have any rounded corners by default. |
| 142 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 143 | createSection(mFirst, mSecond), |
| 144 | createSection(null, null) |
| 145 | }); |
| 146 | ExpandableNotificationRow row = new NotificationTestHelper(getContext()).createRow(); |
| 147 | NotificationEntry entry = mock(NotificationEntry.class); |
| 148 | when(entry.getRow()).thenReturn(row); |
| 149 | |
| 150 | mRoundnessManager.onAmbientStateChanged(entry, true); |
| 151 | Assert.assertEquals(1f, row.getCurrentBottomRoundness(), 0.0f); |
| 152 | Assert.assertEquals(1f, row.getCurrentTopRoundness(), 0.0f); |
| 153 | |
| 154 | mRoundnessManager.onAmbientStateChanged(entry, false); |
| 155 | Assert.assertEquals(0f, row.getCurrentBottomRoundness(), 0.0f); |
| 156 | Assert.assertEquals(0f, row.getCurrentTopRoundness(), 0.0f); |
| 157 | } |
| 158 | |
| 159 | @Test |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 160 | public void testRoundnessSetOnSecondSectionLast() { |
| 161 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 162 | createSection(mFirst, mFirst), |
| 163 | createSection(null, mSecond) |
| 164 | }); |
| 165 | Assert.assertEquals(1.0f, mSecond.getCurrentBottomRoundness(), 0.0f); |
| 166 | Assert.assertEquals(0.0f, mSecond.getCurrentTopRoundness(), 0.0f); |
| 167 | } |
| 168 | |
| 169 | @Test |
| 170 | public void testRoundnessSetOnSecondSectionFirst() { |
| 171 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 172 | createSection(mFirst, mFirst), |
| 173 | createSection(mSecond, null) |
| 174 | }); |
| 175 | Assert.assertEquals(0.0f, mSecond.getCurrentBottomRoundness(), 0.0f); |
| 176 | Assert.assertEquals(1.0f, mSecond.getCurrentTopRoundness(), 0.0f); |
| 177 | } |
| 178 | |
| 179 | @Test |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 180 | public void testRoundnessSetOnNew() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 181 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 182 | createSection(mFirst, null), |
| 183 | createSection(null, null) |
| 184 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 185 | Assert.assertEquals(0.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 186 | Assert.assertEquals(1.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 187 | } |
| 188 | |
| 189 | @Test |
| 190 | public void testCompleteReplacement() { |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 191 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 192 | createSection(mSecond, mSecond), |
| 193 | createSection(null, null) |
| 194 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 195 | Assert.assertEquals(0.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 196 | Assert.assertEquals(0.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 197 | } |
| 198 | |
| 199 | @Test |
| 200 | public void testNotCalledWhenRemoved() { |
| 201 | mFirst.setRemoved(); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 202 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 203 | createSection(mSecond, mSecond), |
| 204 | createSection(null, null) |
| 205 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 206 | Assert.assertEquals(1.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 207 | Assert.assertEquals(1.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 208 | } |
| 209 | |
| 210 | @Test |
| 211 | public void testRoundedWhenPinnedAndCollapsed() { |
| 212 | mFirst.setPinned(true); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 213 | mRoundnessManager.setExpanded(0.0f /* expandedHeight */, 0.0f /* appearFraction */); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 214 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 215 | createSection(mSecond, mSecond), |
| 216 | createSection(null, null) |
| 217 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 218 | Assert.assertEquals(1.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 219 | Assert.assertEquals(1.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 220 | } |
| 221 | |
| 222 | @Test |
| 223 | public void testRoundedWhenGoingAwayAndCollapsed() { |
| 224 | mFirst.setHeadsUpAnimatingAway(true); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 225 | mRoundnessManager.setExpanded(0.0f /* expandedHeight */, 0.0f /* appearFraction */); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 226 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 227 | createSection(mSecond, mSecond), |
| 228 | createSection(null, null) |
| 229 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 230 | Assert.assertEquals(1.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 231 | Assert.assertEquals(1.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 232 | } |
| 233 | |
| 234 | @Test |
| 235 | public void testRoundedNormalRoundingWhenExpanded() { |
| 236 | mFirst.setHeadsUpAnimatingAway(true); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 237 | mRoundnessManager.setExpanded(1.0f /* expandedHeight */, 0.0f /* appearFraction */); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 238 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 239 | createSection(mSecond, mSecond), |
| 240 | createSection(null, null) |
| 241 | }); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 242 | Assert.assertEquals(0.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 243 | Assert.assertEquals(0.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 244 | } |
| 245 | |
| 246 | @Test |
| 247 | public void testTrackingHeadsUpRoundedIfPushingUp() { |
| 248 | mRoundnessManager.setExpanded(1.0f /* expandedHeight */, -0.5f /* appearFraction */); |
| 249 | mRoundnessManager.setTrackingHeadsUp(mFirst); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 250 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 251 | createSection(mSecond, mSecond), |
| 252 | createSection(null, null) |
| 253 | }); |
Selim Cinek | aa9db1f | 2018-02-27 17:35:47 -0800 | [diff] [blame] | 254 | Assert.assertEquals(1.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 255 | Assert.assertEquals(1.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 256 | } |
| 257 | |
| 258 | @Test |
| 259 | public void testTrackingHeadsUpNotRoundedIfPushingDown() { |
| 260 | mRoundnessManager.setExpanded(1.0f /* expandedHeight */, 0.5f /* appearFraction */); |
| 261 | mRoundnessManager.setTrackingHeadsUp(mFirst); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 262 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 263 | createSection(mSecond, mSecond), |
| 264 | createSection(null, null) |
| 265 | }); |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 266 | Assert.assertEquals(0.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 267 | Assert.assertEquals(0.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 268 | } |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 269 | |
| 270 | @Test |
| 271 | public void testRoundingUpdatedWhenAnimatingAwayTrue() { |
| 272 | mRoundnessManager.setExpanded(0.0f, 0.0f); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 273 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 274 | createSection(mSecond, mSecond), |
| 275 | createSection(null, null) |
| 276 | }); |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 277 | mFirst.setHeadsUpAnimatingAway(true); |
| 278 | Assert.assertEquals(1.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 279 | Assert.assertEquals(1.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 280 | } |
| 281 | |
| 282 | |
| 283 | @Test |
| 284 | public void testRoundingUpdatedWhenAnimatingAwayFalse() { |
| 285 | mRoundnessManager.setExpanded(0.0f, 0.0f); |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 286 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 287 | createSection(mSecond, mSecond), |
| 288 | createSection(null, null) |
| 289 | }); |
Selim Cinek | 8875de1 | 2018-03-22 10:14:32 -0700 | [diff] [blame] | 290 | mFirst.setHeadsUpAnimatingAway(true); |
| 291 | mFirst.setHeadsUpAnimatingAway(false); |
| 292 | Assert.assertEquals(0.0f, mFirst.getCurrentBottomRoundness(), 0.0f); |
| 293 | Assert.assertEquals(0.0f, mFirst.getCurrentTopRoundness(), 0.0f); |
| 294 | } |
Gus Prevas | e2d6f04 | 2018-10-17 15:25:30 -0400 | [diff] [blame] | 295 | |
| 296 | @Test |
| 297 | public void testNoViewsFirstOrLastInSectionWhenSecondSectionEmpty() { |
| 298 | Assert.assertFalse(mFirst.isFirstInSection()); |
| 299 | Assert.assertFalse(mFirst.isLastInSection()); |
| 300 | } |
| 301 | |
| 302 | @Test |
| 303 | public void testNoViewsFirstOrLastInSectionWhenFirstSectionEmpty() { |
| 304 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 305 | createSection(null, null), |
| 306 | createSection(mSecond, mSecond) |
| 307 | }); |
| 308 | Assert.assertFalse(mSecond.isFirstInSection()); |
| 309 | Assert.assertFalse(mSecond.isLastInSection()); |
| 310 | } |
| 311 | |
| 312 | @Test |
| 313 | public void testFirstAndLastViewsInSectionSetWhenBothSectionsNonEmpty() { |
| 314 | mRoundnessManager.updateRoundedChildren(new NotificationSection[]{ |
| 315 | createSection(mFirst, mFirst), |
| 316 | createSection(mSecond, mSecond) |
| 317 | }); |
| 318 | Assert.assertFalse(mFirst.isFirstInSection()); |
| 319 | Assert.assertTrue(mFirst.isLastInSection()); |
| 320 | Assert.assertTrue(mSecond.isFirstInSection()); |
| 321 | Assert.assertFalse(mSecond.isLastInSection()); |
| 322 | } |
| 323 | |
| 324 | private NotificationSection createSection(ExpandableNotificationRow first, |
| 325 | ExpandableNotificationRow last) { |
| 326 | NotificationSection section = mock(NotificationSection.class); |
| 327 | when(section.getFirstVisibleChild()).thenReturn(first); |
| 328 | when(section.getLastVisibleChild()).thenReturn(last); |
| 329 | return section; |
| 330 | } |
Selim Cinek | 29aab96 | 2018-02-27 17:05:45 -0800 | [diff] [blame] | 331 | } |