Fix some tests in TaskbarScrimViewController for bubble bar
When taskbar is in pinned mode with bubble bar expanded, in some
scenarios, we hide taskbar contents (i.e. when bubbles overlaps with
taskbar) and the scrim still shows.
One of the existing tests in TaskbarScrimViewController checks that
the scrim would be 0 when taskbar is not visible, however, in the
bubble bar case this isn't always true... I think there probably are
cases where taskbar isn't visible for other reasons (e.g. shade is
pulled down, but there are other tests specific to that). I'm
setting this test to only run when bubble bar isn't running, because
in that case bubbles never impacts taskbar visibility.
I added a test case to ensure scrim is hidden when pinned BUT bubble
bar is on home -- in this case we shouldn't show the scrim.
When adding the enableFlag/disableFlag I saw some NPEs in onDestroy
methods of some controllers so I protect against those as well.
Flag: EXEMPT test change
Test: atest NexusLauncherTest:TaskbarScrimViewControllerTest
atest NexusLauncherRoboTest:TaskbarScrimViewControllerTest
Bug: 377764181
Change-Id: I71001222aa8a4393b341dd2b43a4b2e46e617a70
diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
index 7273fac..eb47bb0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
@@ -192,7 +192,9 @@
public void onDestroy() {
- mRegionSamplingHelper.stopAndDestroy();
+ if (mRegionSamplingHelper != null) {
+ mRegionSamplingHelper.stopAndDestroy();
+ }
mRegionSamplingHelper = null;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarForceVisibleImmersiveController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarForceVisibleImmersiveController.java
index 8a86402..b7f5575 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarForceVisibleImmersiveController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarForceVisibleImmersiveController.java
@@ -108,8 +108,10 @@
/** Clean up animations. */
public void onDestroy() {
startIconUndimming();
- mControllers.navbarButtonsViewController.setHomeButtonAccessibilityDelegate(null);
- mControllers.navbarButtonsViewController.setBackButtonAccessibilityDelegate(null);
+ if (mControllers != null) {
+ mControllers.navbarButtonsViewController.setHomeButtonAccessibilityDelegate(null);
+ mControllers.navbarButtonsViewController.setBackButtonAccessibilityDelegate(null);
+ }
}
private void startIconUndimming() {
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarScrimViewControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarScrimViewControllerTest.kt
index 436dfd3..4c94067 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarScrimViewControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarScrimViewControllerTest.kt
@@ -17,10 +17,14 @@
package com.android.launcher3.taskbar
import android.animation.AnimatorTestRule
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
+import android.platform.test.flag.junit.SetFlagsRule
import android.view.KeyEvent
import android.view.View.GONE
import android.view.View.VISIBLE
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
+import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController
import com.android.launcher3.taskbar.rules.TaskbarModeRule
import com.android.launcher3.taskbar.rules.TaskbarModeRule.Mode.PINNED
import com.android.launcher3.taskbar.rules.TaskbarModeRule.Mode.TRANSIENT
@@ -34,6 +38,7 @@
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE
+import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR
import com.android.wm.shell.shared.bubbles.BubbleConstants.BUBBLE_EXPANDED_SCRIM_ALPHA
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -43,7 +48,8 @@
@RunWith(LauncherMultivalentJUnit::class)
@EmulatedDevices(["pixelTablet2023"])
class TaskbarScrimViewControllerTest {
- @get:Rule(order = 0)
+ @get:Rule(order = 0) val setFlagsRule = SetFlagsRule()
+ @get:Rule(order = 1)
val context =
TaskbarWindowSandboxContext.create { builder ->
builder.bindSystemUiProxy(
@@ -55,9 +61,9 @@
}
)
}
- @get:Rule(order = 1) val taskbarModeRule = TaskbarModeRule(context)
- @get:Rule(order = 2) val animatorTestRule = AnimatorTestRule(this)
- @get:Rule(order = 3) val taskbarUnitTestRule = TaskbarUnitTestRule(this, context)
+ @get:Rule(order = 2) val taskbarModeRule = TaskbarModeRule(context)
+ @get:Rule(order = 3) val animatorTestRule = AnimatorTestRule(this)
+ @get:Rule(order = 4) val taskbarUnitTestRule = TaskbarUnitTestRule(this, context)
@InjectController lateinit var scrimViewController: TaskbarScrimViewController
@@ -90,6 +96,7 @@
}
@Test
+ @DisableFlags(FLAG_ENABLE_BUBBLE_BAR)
@TaskbarMode(PINNED)
fun testOnTaskbarVisibilityChanged_pinnedTaskbarHiddenDuringScrim_hidesScrim() {
getInstrumentation().runOnMainSync {
@@ -106,6 +113,26 @@
}
@Test
+ @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
+ @TaskbarMode(PINNED)
+ fun testOnTaskbarVisibilityChanged_pinnedTaskbarOnHomeHiddenDuringScrim_hidesScrim() {
+ getInstrumentation().runOnMainSync {
+ scrimViewController.onTaskbarVisibilityChanged(VISIBLE)
+ taskbarUnitTestRule.activityContext.bubbleControllers!!
+ .bubbleStashController
+ .launcherState = BubbleStashController.BubbleLauncherState.HOME
+ scrimViewController.updateStateForSysuiFlags(SYSUI_STATE_BUBBLES_EXPANDED, true)
+ }
+ assertThat(scrimViewController.scrimAlpha).isEqualTo(BUBBLE_EXPANDED_SCRIM_ALPHA)
+
+ getInstrumentation().runOnMainSync {
+ scrimViewController.onTaskbarVisibilityChanged(GONE)
+ animatorTestRule.advanceTimeBy(animationDuration)
+ }
+ assertThat(scrimViewController.scrimAlpha).isEqualTo(0)
+ }
+
+ @Test
@TaskbarMode(PINNED)
fun testOnTaskbarVisibilityChanged_notificationsOverPinnedTaskbarAndBubbles_noScrim() {
getInstrumentation().runOnMainSync {