Loading libs/WindowManager/Shell/multivalentTests/AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ <activity android:name="com.android.wm.shell.bubbles.bar.BubbleBarAnimationHelperTest$TestActivity" android:exported="true"/> <activity android:name="com.android.wm.shell.bubbles.bar.BubbleBarMenuViewControllerTest$TestActivity" android:exported="true"/> <activity android:name=".bubbles.TestActivity" android:allowEmbedded="true" android:documentLaunchMode="always" Loading libs/WindowManager/Shell/multivalentTests/AndroidManifestRobolectric.xml +2 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ <application> <activity android:name="com.android.wm.shell.bubbles.bar.BubbleBarAnimationHelperTest$TestActivity" android:exported="true"/> <activity android:name="com.android.wm.shell.bubbles.bar.BubbleBarMenuViewControllerTest$TestActivity" android:exported="true"/> </application> </manifest> libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuViewControllerTest.kt 0 → 100644 +128 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.bubbles.bar import android.animation.AnimatorTestRule import android.app.Activity import android.content.Context import android.os.Bundle import android.widget.FrameLayout import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.platform.app.InstrumentationRegistry import com.android.wm.shell.bubbles.Bubble import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith /** Tests for [BubbleBarMenuViewController]. */ @SmallTest @RunWith(AndroidJUnit4::class) class BubbleBarMenuViewControllerTest { @get:Rule val animatorTestRule: AnimatorTestRule = AnimatorTestRule(this) private lateinit var activityScenario: ActivityScenario<TestActivity> private val context = ApplicationProvider.getApplicationContext<Context>() private lateinit var menuViewController: BubbleBarMenuViewController private val listener = TestListener() private lateinit var container: FrameLayout @Before fun setUp() { activityScenario = ActivityScenario.launch(TestActivity::class.java) activityScenario.onActivity { activity -> container = activity.container } val handleView = BubbleBarHandleView(context) menuViewController = BubbleBarMenuViewController(context, handleView, container) menuViewController.setListener(listener) } @Test fun showMenu_immediatelyUpdatesVisibility() { activityScenario.onActivity { menuViewController.showMenu(/* animated= */ true) } InstrumentationRegistry.getInstrumentation().waitForIdleSync() assertThat(listener.visible).isTrue() // advance the animator timer since the actual visibility of the menu is updated in the // middle of the animation activityScenario.onActivity { animatorTestRule.advanceTimeBy(600) } assertThat(menuViewController.isMenuVisible).isTrue() } @Test fun hideMenu_updatesVisibilityAfterAnimationEnds() { activityScenario.onActivity { menuViewController.showMenu(/* animated= */ true) } InstrumentationRegistry.getInstrumentation().waitForIdleSync() assertThat(listener.visible).isTrue() activityScenario.onActivity { animatorTestRule.advanceTimeBy(600) } assertThat(menuViewController.isMenuVisible).isTrue() activityScenario.onActivity { menuViewController.hideMenu(/* animated= */ true) } InstrumentationRegistry.getInstrumentation().waitForIdleSync() // check that the listener hasn't been notified yet assertThat(listener.visible).isTrue() activityScenario.onActivity { animatorTestRule.advanceTimeBy(600) } assertThat(listener.visible).isFalse() assertThat(menuViewController.isMenuVisible).isFalse() } private class TestListener : BubbleBarMenuViewController.Listener { var visible = false override fun onMenuVisibilityChanged(visible: Boolean) { this.visible = visible } override fun onUnBubbleConversation(bubble: Bubble?) {} override fun onOpenAppSettings(bubble: Bubble?) {} override fun onDismissBubble(bubble: Bubble?) {} override fun onMoveToFullscreen(bubble: Bubble?) {} } class TestActivity : Activity() { lateinit var container: FrameLayout override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) container = FrameLayout(applicationContext) setContentView(container) } } } libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ public class BubbleBarAnimationHelper { bbev.setAnimationMatrix(mExpandedViewContainerMatrix); bbev.animateExpansionWhenTaskViewVisible(() -> { bbev.getHandleView().setAlpha(1); ObjectAnimator alphaAnim = createAlphaAnimator(bbev, /* visible= */ true); alphaAnim.setDuration(EXPANDED_VIEW_EXPAND_ALPHA_DURATION); alphaAnim.setInterpolator(Interpolators.PANEL_CLOSE_ACCELERATED); Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuViewController.java +4 −6 Original line number Diff line number Diff line Loading @@ -86,12 +86,10 @@ class BubbleBarMenuViewController { runOnMenuIsMeasured(() -> { mMenuView.setVisibility(View.VISIBLE); mScrimView.setVisibility(View.VISIBLE); Runnable endActions = () -> { mMenuView.getChildAt(0).requestAccessibilityFocus(); if (mListener != null) { mListener.onMenuVisibilityChanged(true /* isShown */); } }; Runnable endActions = () -> mMenuView.getChildAt(0).requestAccessibilityFocus(); if (animated) { animateTransition(true /* show */, endActions); } else { Loading Loading
libs/WindowManager/Shell/multivalentTests/AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ <activity android:name="com.android.wm.shell.bubbles.bar.BubbleBarAnimationHelperTest$TestActivity" android:exported="true"/> <activity android:name="com.android.wm.shell.bubbles.bar.BubbleBarMenuViewControllerTest$TestActivity" android:exported="true"/> <activity android:name=".bubbles.TestActivity" android:allowEmbedded="true" android:documentLaunchMode="always" Loading
libs/WindowManager/Shell/multivalentTests/AndroidManifestRobolectric.xml +2 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ <application> <activity android:name="com.android.wm.shell.bubbles.bar.BubbleBarAnimationHelperTest$TestActivity" android:exported="true"/> <activity android:name="com.android.wm.shell.bubbles.bar.BubbleBarMenuViewControllerTest$TestActivity" android:exported="true"/> </application> </manifest>
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuViewControllerTest.kt 0 → 100644 +128 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.bubbles.bar import android.animation.AnimatorTestRule import android.app.Activity import android.content.Context import android.os.Bundle import android.widget.FrameLayout import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import androidx.test.platform.app.InstrumentationRegistry import com.android.wm.shell.bubbles.Bubble import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith /** Tests for [BubbleBarMenuViewController]. */ @SmallTest @RunWith(AndroidJUnit4::class) class BubbleBarMenuViewControllerTest { @get:Rule val animatorTestRule: AnimatorTestRule = AnimatorTestRule(this) private lateinit var activityScenario: ActivityScenario<TestActivity> private val context = ApplicationProvider.getApplicationContext<Context>() private lateinit var menuViewController: BubbleBarMenuViewController private val listener = TestListener() private lateinit var container: FrameLayout @Before fun setUp() { activityScenario = ActivityScenario.launch(TestActivity::class.java) activityScenario.onActivity { activity -> container = activity.container } val handleView = BubbleBarHandleView(context) menuViewController = BubbleBarMenuViewController(context, handleView, container) menuViewController.setListener(listener) } @Test fun showMenu_immediatelyUpdatesVisibility() { activityScenario.onActivity { menuViewController.showMenu(/* animated= */ true) } InstrumentationRegistry.getInstrumentation().waitForIdleSync() assertThat(listener.visible).isTrue() // advance the animator timer since the actual visibility of the menu is updated in the // middle of the animation activityScenario.onActivity { animatorTestRule.advanceTimeBy(600) } assertThat(menuViewController.isMenuVisible).isTrue() } @Test fun hideMenu_updatesVisibilityAfterAnimationEnds() { activityScenario.onActivity { menuViewController.showMenu(/* animated= */ true) } InstrumentationRegistry.getInstrumentation().waitForIdleSync() assertThat(listener.visible).isTrue() activityScenario.onActivity { animatorTestRule.advanceTimeBy(600) } assertThat(menuViewController.isMenuVisible).isTrue() activityScenario.onActivity { menuViewController.hideMenu(/* animated= */ true) } InstrumentationRegistry.getInstrumentation().waitForIdleSync() // check that the listener hasn't been notified yet assertThat(listener.visible).isTrue() activityScenario.onActivity { animatorTestRule.advanceTimeBy(600) } assertThat(listener.visible).isFalse() assertThat(menuViewController.isMenuVisible).isFalse() } private class TestListener : BubbleBarMenuViewController.Listener { var visible = false override fun onMenuVisibilityChanged(visible: Boolean) { this.visible = visible } override fun onUnBubbleConversation(bubble: Bubble?) {} override fun onOpenAppSettings(bubble: Bubble?) {} override fun onDismissBubble(bubble: Bubble?) {} override fun onMoveToFullscreen(bubble: Bubble?) {} } class TestActivity : Activity() { lateinit var container: FrameLayout override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) container = FrameLayout(applicationContext) setContentView(container) } } }
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ public class BubbleBarAnimationHelper { bbev.setAnimationMatrix(mExpandedViewContainerMatrix); bbev.animateExpansionWhenTaskViewVisible(() -> { bbev.getHandleView().setAlpha(1); ObjectAnimator alphaAnim = createAlphaAnimator(bbev, /* visible= */ true); alphaAnim.setDuration(EXPANDED_VIEW_EXPAND_ALPHA_DURATION); alphaAnim.setInterpolator(Interpolators.PANEL_CLOSE_ACCELERATED); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuViewController.java +4 −6 Original line number Diff line number Diff line Loading @@ -86,12 +86,10 @@ class BubbleBarMenuViewController { runOnMenuIsMeasured(() -> { mMenuView.setVisibility(View.VISIBLE); mScrimView.setVisibility(View.VISIBLE); Runnable endActions = () -> { mMenuView.getChildAt(0).requestAccessibilityFocus(); if (mListener != null) { mListener.onMenuVisibilityChanged(true /* isShown */); } }; Runnable endActions = () -> mMenuView.getChildAt(0).requestAccessibilityFocus(); if (animated) { animateTransition(true /* show */, endActions); } else { Loading