Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/render/RenderStageManagerTest.kt +27 −14 Original line number Diff line number Diff line Loading @@ -19,9 +19,10 @@ package com.android.systemui.statusbar.notification.collection.render import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.statusbar.notification.collection.BundleEntry import com.android.systemui.statusbar.notification.collection.GroupEntry import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder import com.android.systemui.statusbar.notification.collection.ListEntry import com.android.systemui.statusbar.notification.collection.InternalNotificationsApi import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder import com.android.systemui.statusbar.notification.collection.PipelineEntry Loading @@ -29,6 +30,7 @@ import com.android.systemui.statusbar.notification.collection.ShadeListBuilder import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderEntryListener import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderGroupListener import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderListListener import com.android.systemui.statusbar.notification.row.data.repository.TEST_BUNDLE_SPEC import com.android.systemui.util.mockito.withArgCaptor import org.junit.Before import org.junit.Test Loading @@ -41,7 +43,6 @@ import org.mockito.kotlin.spy import org.mockito.kotlin.times import org.mockito.kotlin.verify import org.mockito.kotlin.verifyNoMoreInteractions import java.nio.channels.Pipe @SmallTest @RunWith(AndroidJUnit4::class) Loading Loading @@ -82,7 +83,7 @@ class RenderStageManagerTest : SysuiTestCase() { setUpListeners() // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that no listeners are called verifyNoMoreInteractions( Loading @@ -98,7 +99,7 @@ class RenderStageManagerTest : SysuiTestCase() { setUpRenderer() // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that the renderer is not queried for group or row controllers inOrder(spyViewRenderer).apply { Loading @@ -117,13 +118,13 @@ class RenderStageManagerTest : SysuiTestCase() { setUpListeners() // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that the renderer is queried once per group/entry inOrder(spyViewRenderer).apply { verify(spyViewRenderer, times(1)).onRenderList(any()) verify(spyViewRenderer, times(2)).getGroupController(any()) verify(spyViewRenderer, times(8)).getRowController(any()) verify(spyViewRenderer, times(3)).getGroupController(any()) verify(spyViewRenderer, times(10)).getRowController(any()) verify(spyViewRenderer, times(1)).onDispatchComplete() verifyNoMoreInteractions(spyViewRenderer) } Loading @@ -139,13 +140,13 @@ class RenderStageManagerTest : SysuiTestCase() { renderStageManager.addOnAfterRenderEntryListener(mock()) // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that the renderer is queried once per group/entry inOrder(spyViewRenderer).apply { verify(spyViewRenderer, times(1)).onRenderList(any()) verify(spyViewRenderer, times(2)).getGroupController(any()) verify(spyViewRenderer, times(8)).getRowController(any()) verify(spyViewRenderer, times(3)).getGroupController(any()) verify(spyViewRenderer, times(10)).getRowController(any()) verify(spyViewRenderer, times(1)).onDispatchComplete() verifyNoMoreInteractions(spyViewRenderer) } Loading @@ -158,12 +159,12 @@ class RenderStageManagerTest : SysuiTestCase() { setUpListeners() // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that the listeners are invoked once per group and once per entry verify(onAfterRenderListListener, times(1)).onAfterRenderList(any()) verify(onAfterRenderGroupListener, times(2)).onAfterRenderGroup(any(), any()) verify(onAfterRenderEntryListener, times(8)).onAfterRenderEntry(any(), any()) verify(onAfterRenderGroupListener, times(3)).onAfterRenderGroup(any(), any()) verify(onAfterRenderEntryListener, times(10)).onAfterRenderEntry(any(), any()) verifyNoMoreInteractions( onAfterRenderListListener, onAfterRenderGroupListener, Loading Loading @@ -191,12 +192,13 @@ class RenderStageManagerTest : SysuiTestCase() { ) } private fun listWith2Groups8Entries() = private fun listWith3Groups1Bundle10Entries() = listOf( group(notif(1), notif(2), notif(3)), notif(4), group(notif(5), notif(6), notif(7)), notif(8), bundle(group(notif(9)), notif(10)) ) private class FakeNotifViewRenderer : NotifViewRenderer { Loading @@ -213,4 +215,15 @@ class RenderStageManagerTest : SysuiTestCase() { private fun group(summary: NotificationEntry, vararg children: NotificationEntry): GroupEntry = GroupEntryBuilder().setSummary(summary).setChildren(children.toList()).build() @OptIn(InternalNotificationsApi::class) private fun bundle(group: GroupEntry, vararg children: NotificationEntry) : BundleEntry { var bundle = BundleEntry(TEST_BUNDLE_SPEC) bundle.addChild(group) for (child in children) { bundle.addChild(child) } return bundle } } packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/RenderStageManager.kt +26 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ class RenderStageManager @Inject constructor() : PipelineDumpable { if (onAfterRenderGroupListeners.isEmpty()) { return } entries.asSequence().filterIsInstance<GroupEntry>().forEach { group -> entries.forEachGroupEntry { group -> val controller = viewRenderer.getGroupController(group) onAfterRenderGroupListeners.forEach { listener -> listener.onAfterRenderGroup(group, controller) Loading Loading @@ -154,4 +154,29 @@ class RenderStageManager @Inject constructor() : PipelineDumpable { } } } /** * Performs an action on all group entries, even if they are in a bundle */ private inline fun List<PipelineEntry>.forEachGroupEntry( action: (GroupEntry) -> Unit ) { forEach { entry -> when (entry) { is GroupEntry -> { action(entry) } is BundleEntry -> { for (bundleChild in entry.children) { if (bundleChild is GroupEntry) { action(bundleChild) } } } else -> { // Do nothing for leaf nodes } } } } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/collection/render/RenderStageManagerTest.kt +27 −14 Original line number Diff line number Diff line Loading @@ -19,9 +19,10 @@ package com.android.systemui.statusbar.notification.collection.render import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.statusbar.notification.collection.BundleEntry import com.android.systemui.statusbar.notification.collection.GroupEntry import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder import com.android.systemui.statusbar.notification.collection.ListEntry import com.android.systemui.statusbar.notification.collection.InternalNotificationsApi import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder import com.android.systemui.statusbar.notification.collection.PipelineEntry Loading @@ -29,6 +30,7 @@ import com.android.systemui.statusbar.notification.collection.ShadeListBuilder import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderEntryListener import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderGroupListener import com.android.systemui.statusbar.notification.collection.listbuilder.OnAfterRenderListListener import com.android.systemui.statusbar.notification.row.data.repository.TEST_BUNDLE_SPEC import com.android.systemui.util.mockito.withArgCaptor import org.junit.Before import org.junit.Test Loading @@ -41,7 +43,6 @@ import org.mockito.kotlin.spy import org.mockito.kotlin.times import org.mockito.kotlin.verify import org.mockito.kotlin.verifyNoMoreInteractions import java.nio.channels.Pipe @SmallTest @RunWith(AndroidJUnit4::class) Loading Loading @@ -82,7 +83,7 @@ class RenderStageManagerTest : SysuiTestCase() { setUpListeners() // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that no listeners are called verifyNoMoreInteractions( Loading @@ -98,7 +99,7 @@ class RenderStageManagerTest : SysuiTestCase() { setUpRenderer() // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that the renderer is not queried for group or row controllers inOrder(spyViewRenderer).apply { Loading @@ -117,13 +118,13 @@ class RenderStageManagerTest : SysuiTestCase() { setUpListeners() // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that the renderer is queried once per group/entry inOrder(spyViewRenderer).apply { verify(spyViewRenderer, times(1)).onRenderList(any()) verify(spyViewRenderer, times(2)).getGroupController(any()) verify(spyViewRenderer, times(8)).getRowController(any()) verify(spyViewRenderer, times(3)).getGroupController(any()) verify(spyViewRenderer, times(10)).getRowController(any()) verify(spyViewRenderer, times(1)).onDispatchComplete() verifyNoMoreInteractions(spyViewRenderer) } Loading @@ -139,13 +140,13 @@ class RenderStageManagerTest : SysuiTestCase() { renderStageManager.addOnAfterRenderEntryListener(mock()) // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that the renderer is queried once per group/entry inOrder(spyViewRenderer).apply { verify(spyViewRenderer, times(1)).onRenderList(any()) verify(spyViewRenderer, times(2)).getGroupController(any()) verify(spyViewRenderer, times(8)).getRowController(any()) verify(spyViewRenderer, times(3)).getGroupController(any()) verify(spyViewRenderer, times(10)).getRowController(any()) verify(spyViewRenderer, times(1)).onDispatchComplete() verifyNoMoreInteractions(spyViewRenderer) } Loading @@ -158,12 +159,12 @@ class RenderStageManagerTest : SysuiTestCase() { setUpListeners() // WHEN a shade list is built onRenderListListener.onRenderList(listWith2Groups8Entries()) onRenderListListener.onRenderList(listWith3Groups1Bundle10Entries()) // VERIFY that the listeners are invoked once per group and once per entry verify(onAfterRenderListListener, times(1)).onAfterRenderList(any()) verify(onAfterRenderGroupListener, times(2)).onAfterRenderGroup(any(), any()) verify(onAfterRenderEntryListener, times(8)).onAfterRenderEntry(any(), any()) verify(onAfterRenderGroupListener, times(3)).onAfterRenderGroup(any(), any()) verify(onAfterRenderEntryListener, times(10)).onAfterRenderEntry(any(), any()) verifyNoMoreInteractions( onAfterRenderListListener, onAfterRenderGroupListener, Loading Loading @@ -191,12 +192,13 @@ class RenderStageManagerTest : SysuiTestCase() { ) } private fun listWith2Groups8Entries() = private fun listWith3Groups1Bundle10Entries() = listOf( group(notif(1), notif(2), notif(3)), notif(4), group(notif(5), notif(6), notif(7)), notif(8), bundle(group(notif(9)), notif(10)) ) private class FakeNotifViewRenderer : NotifViewRenderer { Loading @@ -213,4 +215,15 @@ class RenderStageManagerTest : SysuiTestCase() { private fun group(summary: NotificationEntry, vararg children: NotificationEntry): GroupEntry = GroupEntryBuilder().setSummary(summary).setChildren(children.toList()).build() @OptIn(InternalNotificationsApi::class) private fun bundle(group: GroupEntry, vararg children: NotificationEntry) : BundleEntry { var bundle = BundleEntry(TEST_BUNDLE_SPEC) bundle.addChild(group) for (child in children) { bundle.addChild(child) } return bundle } }
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/render/RenderStageManager.kt +26 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ class RenderStageManager @Inject constructor() : PipelineDumpable { if (onAfterRenderGroupListeners.isEmpty()) { return } entries.asSequence().filterIsInstance<GroupEntry>().forEach { group -> entries.forEachGroupEntry { group -> val controller = viewRenderer.getGroupController(group) onAfterRenderGroupListeners.forEach { listener -> listener.onAfterRenderGroup(group, controller) Loading Loading @@ -154,4 +154,29 @@ class RenderStageManager @Inject constructor() : PipelineDumpable { } } } /** * Performs an action on all group entries, even if they are in a bundle */ private inline fun List<PipelineEntry>.forEachGroupEntry( action: (GroupEntry) -> Unit ) { forEach { entry -> when (entry) { is GroupEntry -> { action(entry) } is BundleEntry -> { for (bundleChild in entry.children) { if (bundleChild is GroupEntry) { action(bundleChild) } } } else -> { // Do nothing for leaf nodes } } } } }