Split up tests by actual hardware keyboard status.

Flag: TEST_ONLY
Bug: 230027385
Test: TaskbarStashControllerTest
Change-Id: I63fc433810af3993db5655571a11887eb2c68422
This commit is contained in:
Brian Isganitis
2024-12-10 19:06:28 -05:00
parent b172e86472
commit a481af5779
2 changed files with 28 additions and 25 deletions
@@ -84,8 +84,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
private static final String TAG = "TaskbarStashController";
private static final boolean DEBUG = false;
private static boolean sEnableSoftwareImeForTests = false;
/**
* Def. value for @param shouldBubblesFollow in
* {@link #updateAndAnimateTransientTaskbar(boolean)} */
@@ -1172,13 +1170,13 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
}
// Do not stash if pinned taskbar, hardware keyboard is attached and no IME is docked
if (isHardwareKeyboard() && DisplayController.isPinnedTaskbar(mActivity)
if (mActivity.isHardwareKeyboard() && DisplayController.isPinnedTaskbar(mActivity)
&& !mActivity.isImeDocked()) {
return false;
}
// Do not stash if hardware keyboard is attached, in 3 button nav and desktop windowing mode
if (isHardwareKeyboard()
if (mActivity.isHardwareKeyboard()
&& mActivity.isThreeButtonNav()
&& mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) {
return false;
@@ -1192,21 +1190,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
return mIsImeShowing || mIsImeSwitcherShowing;
}
private boolean isHardwareKeyboard() {
return mActivity.isHardwareKeyboard() && !sEnableSoftwareImeForTests;
}
/**
* Overrides {@link #isHardwareKeyboard()} to {@code false} for testing, if enabled.
* <p>
* Virtual devices are sometimes in hardware keyboard mode, leading to an inconsistent
* testing environment.
*/
@VisibleForTesting
static void enableSoftwareImeForTests(boolean enable) {
sEnableSoftwareImeForTests = enable;
}
/**
* Updates the proper flag to indicate whether the task bar should be stashed.
*
@@ -56,8 +56,8 @@ import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING
import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.TruthJUnit.assume
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -82,11 +82,6 @@ class TaskbarStashControllerTest {
private val activityContext by taskbarUnitTestRule::activityContext
// Disable hardware keyboard mode during tests.
@Before fun enableSoftwareIme() = TaskbarStashController.enableSoftwareImeForTests(true)
@After fun resetIme() = TaskbarStashController.enableSoftwareImeForTests(false)
@After fun cancelTimeoutIfExists() = stashController.cancelTimeoutIfExists()
@Test
@@ -544,6 +539,8 @@ class TaskbarStashControllerTest {
@Test
@TaskbarMode(PINNED)
fun testAnimatePinnedTaskbar_imeShown_replacesIconsWithHandle() {
assume().that(activityContext.isHardwareKeyboard).isFalse()
getInstrumentation().runOnMainSync {
stashController.updateStateForSysuiFlags(SYSUI_STATE_IME_SHOWING, false)
animatorTestRule.advanceTimeBy(TASKBAR_STASH_DURATION_FOR_IME)
@@ -555,6 +552,8 @@ class TaskbarStashControllerTest {
@Test
@TaskbarMode(PINNED)
fun testAnimatePinnedTaskbar_imeHidden_replacesHandleWithIcons() {
assume().that(activityContext.isHardwareKeyboard).isFalse()
getInstrumentation().runOnMainSync {
stashController.updateStateForSysuiFlags(SYSUI_STATE_IME_SHOWING, true)
animatorTestRule.advanceTimeBy(0)
@@ -571,6 +570,8 @@ class TaskbarStashControllerTest {
@Test
@TaskbarMode(PINNED)
fun testAnimatePinnedTaskbar_imeHidden_verifyAnimationDuration() {
assume().that(activityContext.isHardwareKeyboard).isFalse()
// Start with IME shown.
getInstrumentation().runOnMainSync {
stashController.updateStateForSysuiFlags(SYSUI_STATE_IME_SHOWING, true)
@@ -596,6 +597,8 @@ class TaskbarStashControllerTest {
@Test
@TaskbarMode(THREE_BUTTONS)
fun testAnimateThreeButtonsTaskbar_imeShown_hidesIconsAndBg() {
assume().that(activityContext.isHardwareKeyboard).isFalse()
getInstrumentation().runOnMainSync {
stashController.updateStateForSysuiFlags(SYSUI_STATE_IME_SHOWING, false)
animatorTestRule.advanceTimeBy(TASKBAR_STASH_DURATION_FOR_IME)
@@ -607,6 +610,8 @@ class TaskbarStashControllerTest {
@Test
@TaskbarMode(THREE_BUTTONS)
fun testAnimateThreeButtonsTaskbar_imeHidden_showsIconsAndBg() {
assume().that(activityContext.isHardwareKeyboard).isFalse()
getInstrumentation().runOnMainSync {
stashController.updateStateForSysuiFlags(SYSUI_STATE_IME_SHOWING, false)
animatorTestRule.advanceTimeBy(TASKBAR_STASH_DURATION_FOR_IME)
@@ -625,6 +630,8 @@ class TaskbarStashControllerTest {
@Test
@TaskbarMode(PINNED)
fun testSetSystemGestureInProgress_whileImeShown_unstashesTaskbar() {
assume().that(activityContext.isHardwareKeyboard).isFalse()
getInstrumentation().runOnMainSync {
stashController.updateStateForSysuiFlags(SYSUI_STATE_IME_SHOWING, true)
animatorTestRule.advanceTimeBy(0)
@@ -639,6 +646,19 @@ class TaskbarStashControllerTest {
assertThat(stashController.isStashed).isFalse()
}
@Test
@TaskbarMode(PINNED)
fun testSysuiStateImeShowingInApp_hardwareKeyboardWithPinnedMode_notStashedForIme() {
assume().that(activityContext.isHardwareKeyboard).isTrue()
getInstrumentation().runOnMainSync {
stashController.updateStateForFlag(FLAG_IN_APP, true)
stashController.updateStateForSysuiFlags(SYSUI_STATE_IME_SHOWING, true)
}
assertThat(stashController.isStashed).isFalse()
}
@Test
@TaskbarMode(PINNED)
fun testUnlockTransition_pinnedMode_fadesOutHandle() {