Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleControllerBubbleBarTest.kt +88 −4 Original line number Diff line number Diff line Loading @@ -18,8 +18,11 @@ package com.android.wm.shell.bubbles import android.content.Context import android.content.pm.LauncherApps import android.content.pm.ShortcutInfo import android.graphics.Color import android.graphics.Insets import android.graphics.Rect import android.graphics.drawable.Icon import android.os.Handler import android.os.UserManager import android.platform.test.annotations.EnableFlags Loading @@ -32,7 +35,9 @@ import androidx.test.filters.SmallTest import com.android.internal.logging.testing.UiEventLoggerFake import com.android.internal.protolog.ProtoLog import com.android.internal.statusbar.IStatusBarService import com.android.launcher3.icons.BubbleIconFactory import com.android.wm.shell.Flags import com.android.wm.shell.R import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.bubbles.Bubbles.SysuiProxy import com.android.wm.shell.bubbles.storage.BubblePersistentRepository Loading Loading @@ -65,6 +70,8 @@ import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.whenever import java.util.Optional import java.util.concurrent.Semaphore import java.util.concurrent.TimeUnit /** Tests for [BubbleController] when using bubble bar */ @SmallTest Loading @@ -87,6 +94,9 @@ class BubbleControllerBubbleBarTest { private lateinit var bubbleData: BubbleData private lateinit var mainExecutor: TestShellExecutor private lateinit var bgExecutor: TestShellExecutor private lateinit var expandedViewManager: FakeBubbleExpandedViewManager private lateinit var iconFactory: BubbleIconFactory private lateinit var bubbleTaskViewFactory: BubbleTaskViewFactory @Before fun setUp() { Loading @@ -99,6 +109,19 @@ class BubbleControllerBubbleBarTest { uiEventLoggerFake = UiEventLoggerFake() val bubbleLogger = BubbleLogger(uiEventLoggerFake) bubbleTaskViewFactory = FakeBubbleTaskViewFactory(context, mainExecutor) expandedViewManager = FakeBubbleExpandedViewManager() iconFactory = BubbleIconFactory( context, context.resources.getDimensionPixelSize(R.dimen.bubble_size), context.resources.getDimensionPixelSize(R.dimen.bubble_badge_size), Color.BLACK, context.resources.getDimensionPixelSize( com.android.internal.R.dimen.importance_ring_stroke_width ) ) val deviceConfig = DeviceConfig( windowBounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), Loading @@ -110,7 +133,6 @@ class BubbleControllerBubbleBarTest { ) bubblePositioner = BubblePositioner(context, deviceConfig) bubblePositioner.isShowingInBubbleBar = true bubbleData = BubbleData( Loading Loading @@ -139,8 +161,6 @@ class BubbleControllerBubbleBarTest { mainExecutor.flushAll() bgExecutor.flushAll() bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) } @After Loading @@ -151,6 +171,8 @@ class BubbleControllerBubbleBarTest { @Test fun testEventLogging_bubbleBar_dragBarLeft() { bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) addBubble() bubblePositioner.bubbleBarLocation = BubbleBarLocation.RIGHT Loading @@ -168,6 +190,8 @@ class BubbleControllerBubbleBarTest { @Test fun testEventLogging_bubbleBar_dragBarRight() { bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) addBubble() bubblePositioner.bubbleBarLocation = BubbleBarLocation.LEFT Loading @@ -185,6 +209,8 @@ class BubbleControllerBubbleBarTest { @Test fun testEventLogging_bubbleBar_dragBubbleLeft() { bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) addBubble() bubblePositioner.bubbleBarLocation = BubbleBarLocation.RIGHT Loading @@ -202,6 +228,8 @@ class BubbleControllerBubbleBarTest { @Test fun testEventLogging_bubbleBar_dragBubbleRight() { bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) addBubble() bubblePositioner.bubbleBarLocation = BubbleBarLocation.LEFT Loading @@ -217,8 +245,44 @@ class BubbleControllerBubbleBarTest { .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_BUBBLE.id) } @Test fun registerBubbleBarListener_switchToBarAndBackToStack() { val bubble = addBubble() inflateBubble(bubble) assertThat(bubbleController.hasBubbles()).isTrue() assertFloatingMode(bubble) bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) assertBarMode(bubble) bubbleController.unregisterBubbleStateListener() assertFloatingMode(bubble) } private fun assertFloatingMode(bubble: Bubble) { assertThat(bubbleController.stackView).isNotNull() assertThat(bubbleController.layerView).isNull() assertThat(bubble.iconView).isNotNull() assertThat(bubble.expandedView).isNotNull() assertThat(bubble.bubbleBarExpandedView).isNull() } private fun assertBarMode(bubble: Bubble) { assertThat(bubbleController.stackView).isNull() assertThat(bubbleController.layerView).isNotNull() assertThat(bubble.iconView).isNull() assertThat(bubble.expandedView).isNull() assertThat(bubble.bubbleBarExpandedView).isNotNull() } private fun addBubble(): Bubble { val bubble = FakeBubbleFactory.createChatBubble(context) val icon = Icon.createWithResource(context.resources, R.drawable.bubble_ic_overflow_button) val shortcutInfo = ShortcutInfo.Builder(context, "key").setIcon(icon).build() val bubble = FakeBubbleFactory.createChatBubble(context, shortcutInfo = shortcutInfo) bubble.setInflateSynchronously(true) bubbleData.notificationEntryUpdated( bubble, Loading @@ -228,6 +292,26 @@ class BubbleControllerBubbleBarTest { return bubble } private fun inflateBubble(bubble: Bubble) { val semaphore = Semaphore(0) val callback: BubbleViewInfoTask.Callback = BubbleViewInfoTask.Callback { semaphore.release() } bubble.inflate( callback, context, expandedViewManager, bubbleTaskViewFactory, bubblePositioner, bubbleController.stackView, bubbleController.layerView, iconFactory, false ) assertThat(semaphore.tryAcquire(5, TimeUnit.SECONDS)).isTrue() assertThat(bubble.isInflated).isTrue() } private fun createBubbleController( shellInit: ShellInit, bubbleData: BubbleData, Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/FakeBubbleFactory.kt +2 −1 Original line number Diff line number Diff line Loading @@ -66,12 +66,13 @@ class FakeBubbleFactory { fun createChatBubble( context: Context, key: String = "key", shortcutInfo: ShortcutInfo = ShortcutInfo.Builder(context, "id").build(), viewInfo: BubbleViewInfo? = null, ): Bubble { val bubble = Bubble( key, ShortcutInfo.Builder(context, "id").build(), shortcutInfo, 100, /* desiredHeight */ Resources.ID_NULL, /* desiredHeightResId */ "title", Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelperTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -353,7 +353,7 @@ class BubbleBarAnimationHelperTest { bubbleLogger, ) val viewInfo = FakeBubbleFactory.createViewInfo(bubbleBarExpandedView) return FakeBubbleFactory.createChatBubble(context, key, viewInfo) return FakeBubbleFactory.createChatBubble(context, key, viewInfo = viewInfo) } private fun createOverflow(): BubbleOverflow { Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerViewTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -490,7 +490,7 @@ class BubbleBarLayerViewTest { bubbleBarExpandedView.onContentVisibilityChanged(true /* visible */) val viewInfo = FakeBubbleFactory.createViewInfo(bubbleBarExpandedView) return FakeBubbleFactory.createChatBubble(context, key, viewInfo).also { return FakeBubbleFactory.createChatBubble(context, key, viewInfo = viewInfo).also { testBubblesList.add(it) } } Loading packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +0 −32 Original line number Diff line number Diff line Loading @@ -2424,38 +2424,6 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleController.getStackView().getBubbleCount()).isEqualTo(1); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void registerBubbleBarListener_switchToBarAndBackToStack() { mPositioner.setIsLargeScreen(true); mEntryListener.onEntryAdded(mEntry); mBubbleController.updateBubble(mBubbleEntry); assertTrue(mBubbleController.hasBubbles()); assertStackMode(); assertThat(mBubbleData.getBubbles()).hasSize(1); assertBubbleIsInflatedForStack(mBubbleData.getBubbles().get(0)); assertBubbleIsInflatedForStack(mBubbleData.getOverflow()); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); assertBarMode(); assertThat(mBubbleData.getBubbles()).hasSize(1); assertBubbleIsInflatedForBar(mBubbleData.getBubbles().get(0)); assertBubbleIsInflatedForBar(mBubbleData.getOverflow()); mBubbleController.unregisterBubbleStateListener(); assertStackMode(); assertThat(mBubbleData.getBubbles()).hasSize(1); assertBubbleIsInflatedForStack(mBubbleData.getBubbles().get(0)); assertBubbleIsInflatedForStack(mBubbleData.getOverflow()); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void registerBubbleBarListener_switchToBarWhileExpanded() { Loading Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleControllerBubbleBarTest.kt +88 −4 Original line number Diff line number Diff line Loading @@ -18,8 +18,11 @@ package com.android.wm.shell.bubbles import android.content.Context import android.content.pm.LauncherApps import android.content.pm.ShortcutInfo import android.graphics.Color import android.graphics.Insets import android.graphics.Rect import android.graphics.drawable.Icon import android.os.Handler import android.os.UserManager import android.platform.test.annotations.EnableFlags Loading @@ -32,7 +35,9 @@ import androidx.test.filters.SmallTest import com.android.internal.logging.testing.UiEventLoggerFake import com.android.internal.protolog.ProtoLog import com.android.internal.statusbar.IStatusBarService import com.android.launcher3.icons.BubbleIconFactory import com.android.wm.shell.Flags import com.android.wm.shell.R import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.bubbles.Bubbles.SysuiProxy import com.android.wm.shell.bubbles.storage.BubblePersistentRepository Loading Loading @@ -65,6 +70,8 @@ import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.whenever import java.util.Optional import java.util.concurrent.Semaphore import java.util.concurrent.TimeUnit /** Tests for [BubbleController] when using bubble bar */ @SmallTest Loading @@ -87,6 +94,9 @@ class BubbleControllerBubbleBarTest { private lateinit var bubbleData: BubbleData private lateinit var mainExecutor: TestShellExecutor private lateinit var bgExecutor: TestShellExecutor private lateinit var expandedViewManager: FakeBubbleExpandedViewManager private lateinit var iconFactory: BubbleIconFactory private lateinit var bubbleTaskViewFactory: BubbleTaskViewFactory @Before fun setUp() { Loading @@ -99,6 +109,19 @@ class BubbleControllerBubbleBarTest { uiEventLoggerFake = UiEventLoggerFake() val bubbleLogger = BubbleLogger(uiEventLoggerFake) bubbleTaskViewFactory = FakeBubbleTaskViewFactory(context, mainExecutor) expandedViewManager = FakeBubbleExpandedViewManager() iconFactory = BubbleIconFactory( context, context.resources.getDimensionPixelSize(R.dimen.bubble_size), context.resources.getDimensionPixelSize(R.dimen.bubble_badge_size), Color.BLACK, context.resources.getDimensionPixelSize( com.android.internal.R.dimen.importance_ring_stroke_width ) ) val deviceConfig = DeviceConfig( windowBounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), Loading @@ -110,7 +133,6 @@ class BubbleControllerBubbleBarTest { ) bubblePositioner = BubblePositioner(context, deviceConfig) bubblePositioner.isShowingInBubbleBar = true bubbleData = BubbleData( Loading Loading @@ -139,8 +161,6 @@ class BubbleControllerBubbleBarTest { mainExecutor.flushAll() bgExecutor.flushAll() bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) } @After Loading @@ -151,6 +171,8 @@ class BubbleControllerBubbleBarTest { @Test fun testEventLogging_bubbleBar_dragBarLeft() { bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) addBubble() bubblePositioner.bubbleBarLocation = BubbleBarLocation.RIGHT Loading @@ -168,6 +190,8 @@ class BubbleControllerBubbleBarTest { @Test fun testEventLogging_bubbleBar_dragBarRight() { bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) addBubble() bubblePositioner.bubbleBarLocation = BubbleBarLocation.LEFT Loading @@ -185,6 +209,8 @@ class BubbleControllerBubbleBarTest { @Test fun testEventLogging_bubbleBar_dragBubbleLeft() { bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) addBubble() bubblePositioner.bubbleBarLocation = BubbleBarLocation.RIGHT Loading @@ -202,6 +228,8 @@ class BubbleControllerBubbleBarTest { @Test fun testEventLogging_bubbleBar_dragBubbleRight() { bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) addBubble() bubblePositioner.bubbleBarLocation = BubbleBarLocation.LEFT Loading @@ -217,8 +245,44 @@ class BubbleControllerBubbleBarTest { .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_BUBBLE.id) } @Test fun registerBubbleBarListener_switchToBarAndBackToStack() { val bubble = addBubble() inflateBubble(bubble) assertThat(bubbleController.hasBubbles()).isTrue() assertFloatingMode(bubble) bubblePositioner.isShowingInBubbleBar = true bubbleController.registerBubbleStateListener(FakeBubblesStateListener()) assertBarMode(bubble) bubbleController.unregisterBubbleStateListener() assertFloatingMode(bubble) } private fun assertFloatingMode(bubble: Bubble) { assertThat(bubbleController.stackView).isNotNull() assertThat(bubbleController.layerView).isNull() assertThat(bubble.iconView).isNotNull() assertThat(bubble.expandedView).isNotNull() assertThat(bubble.bubbleBarExpandedView).isNull() } private fun assertBarMode(bubble: Bubble) { assertThat(bubbleController.stackView).isNull() assertThat(bubbleController.layerView).isNotNull() assertThat(bubble.iconView).isNull() assertThat(bubble.expandedView).isNull() assertThat(bubble.bubbleBarExpandedView).isNotNull() } private fun addBubble(): Bubble { val bubble = FakeBubbleFactory.createChatBubble(context) val icon = Icon.createWithResource(context.resources, R.drawable.bubble_ic_overflow_button) val shortcutInfo = ShortcutInfo.Builder(context, "key").setIcon(icon).build() val bubble = FakeBubbleFactory.createChatBubble(context, shortcutInfo = shortcutInfo) bubble.setInflateSynchronously(true) bubbleData.notificationEntryUpdated( bubble, Loading @@ -228,6 +292,26 @@ class BubbleControllerBubbleBarTest { return bubble } private fun inflateBubble(bubble: Bubble) { val semaphore = Semaphore(0) val callback: BubbleViewInfoTask.Callback = BubbleViewInfoTask.Callback { semaphore.release() } bubble.inflate( callback, context, expandedViewManager, bubbleTaskViewFactory, bubblePositioner, bubbleController.stackView, bubbleController.layerView, iconFactory, false ) assertThat(semaphore.tryAcquire(5, TimeUnit.SECONDS)).isTrue() assertThat(bubble.isInflated).isTrue() } private fun createBubbleController( shellInit: ShellInit, bubbleData: BubbleData, Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/FakeBubbleFactory.kt +2 −1 Original line number Diff line number Diff line Loading @@ -66,12 +66,13 @@ class FakeBubbleFactory { fun createChatBubble( context: Context, key: String = "key", shortcutInfo: ShortcutInfo = ShortcutInfo.Builder(context, "id").build(), viewInfo: BubbleViewInfo? = null, ): Bubble { val bubble = Bubble( key, ShortcutInfo.Builder(context, "id").build(), shortcutInfo, 100, /* desiredHeight */ Resources.ID_NULL, /* desiredHeightResId */ "title", Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelperTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -353,7 +353,7 @@ class BubbleBarAnimationHelperTest { bubbleLogger, ) val viewInfo = FakeBubbleFactory.createViewInfo(bubbleBarExpandedView) return FakeBubbleFactory.createChatBubble(context, key, viewInfo) return FakeBubbleFactory.createChatBubble(context, key, viewInfo = viewInfo) } private fun createOverflow(): BubbleOverflow { Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerViewTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -490,7 +490,7 @@ class BubbleBarLayerViewTest { bubbleBarExpandedView.onContentVisibilityChanged(true /* visible */) val viewInfo = FakeBubbleFactory.createViewInfo(bubbleBarExpandedView) return FakeBubbleFactory.createChatBubble(context, key, viewInfo).also { return FakeBubbleFactory.createChatBubble(context, key, viewInfo = viewInfo).also { testBubblesList.add(it) } } Loading
packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +0 −32 Original line number Diff line number Diff line Loading @@ -2424,38 +2424,6 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleController.getStackView().getBubbleCount()).isEqualTo(1); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void registerBubbleBarListener_switchToBarAndBackToStack() { mPositioner.setIsLargeScreen(true); mEntryListener.onEntryAdded(mEntry); mBubbleController.updateBubble(mBubbleEntry); assertTrue(mBubbleController.hasBubbles()); assertStackMode(); assertThat(mBubbleData.getBubbles()).hasSize(1); assertBubbleIsInflatedForStack(mBubbleData.getBubbles().get(0)); assertBubbleIsInflatedForStack(mBubbleData.getOverflow()); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); assertBarMode(); assertThat(mBubbleData.getBubbles()).hasSize(1); assertBubbleIsInflatedForBar(mBubbleData.getBubbles().get(0)); assertBubbleIsInflatedForBar(mBubbleData.getOverflow()); mBubbleController.unregisterBubbleStateListener(); assertStackMode(); assertThat(mBubbleData.getBubbles()).hasSize(1); assertBubbleIsInflatedForStack(mBubbleData.getBubbles().get(0)); assertBubbleIsInflatedForStack(mBubbleData.getOverflow()); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void registerBubbleBarListener_switchToBarWhileExpanded() { Loading