diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index dfbae657dd..b4b8c5b82c 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -198,6 +198,12 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { .unstashBubbleBarIfStashed(); }); return response; + case TestProtocol.REQUEST_INJECT_FAKE_TRACKPAD: + runOnTISBinder(tisBinder -> tisBinder.injectFakeTrackpadForTesting()); + return response; + case TestProtocol.REQUEST_EJECT_FAKE_TRACKPAD: + runOnTISBinder(tisBinder -> tisBinder.ejectFakeTrackpadForTesting()); + return response; } return super.call(method, arg, extras); diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index b153396154..58bb8fc7c4 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -85,6 +85,7 @@ import androidx.annotation.BinderThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; +import androidx.annotation.VisibleForTesting; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.ConstantItem; @@ -399,6 +400,25 @@ public class TouchInteractionService extends Service { return tis.mTaskbarManager; } + @VisibleForTesting + public void injectFakeTrackpadForTesting() { + TouchInteractionService tis = mTis.get(); + if (tis == null) return; + tis.mTrackpadsConnected.add(1000); + tis.initInputMonitor("tapl testing"); + } + + @VisibleForTesting + public void ejectFakeTrackpadForTesting() { + TouchInteractionService tis = mTis.get(); + if (tis == null) return; + tis.mTrackpadsConnected.clear(); + // This method destroys the current input monitor if set up, and only init a new one + // in 3-button mode if {@code mTrackpadsConnected} is not empty. So in other words, + // it will destroy the input monitor. + tis.initInputMonitor("tapl testing"); + } + /** * Sets whether a predictive back-to-home animation is in progress in the device state */ diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java index 106e590e16..2c23f867cb 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java @@ -37,6 +37,7 @@ import com.android.launcher3.util.rule.TestStabilityRule; import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch; import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -47,14 +48,20 @@ public class TaplTestsTrackpad extends AbstractQuickStepTest { private static final String READ_DEVICE_CONFIG_PERMISSION = "android.permission.READ_DEVICE_CONFIG"; + @Before + public void setup() { + mLauncher.injectFakeTrackpad(); + } + @After public void tearDown() { + mLauncher.ejectFakeTrackpad(); mLauncher.setTrackpadGestureType(TrackpadGestureType.NONE); } @Test @PortraitLandscape - @NavigationModeSwitch(mode = ZERO_BUTTON) + @NavigationModeSwitch public void goHome() throws Exception { assumeTrue(mLauncher.isTablet()); @@ -87,7 +94,7 @@ public class TaplTestsTrackpad extends AbstractQuickStepTest { @Test @PortraitLandscape - @NavigationModeSwitch(mode = ZERO_BUTTON) + @NavigationModeSwitch @ScreenRecordRule.ScreenRecord // b/336606166 @TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/336606166 public void switchToOverview() throws Exception { @@ -100,7 +107,7 @@ public class TaplTestsTrackpad extends AbstractQuickStepTest { @Test @PortraitLandscape - @NavigationModeSwitch(mode = ZERO_BUTTON) + @NavigationModeSwitch public void testAllAppsFromHome() throws Exception { assumeTrue(mLauncher.isTablet()); @@ -110,8 +117,8 @@ public class TaplTestsTrackpad extends AbstractQuickStepTest { } @Test - @NavigationModeSwitch(mode = ZERO_BUTTON) @PortraitLandscape + @NavigationModeSwitch public void testQuickSwitchFromHome() throws Exception { assumeTrue(mLauncher.isTablet()); diff --git a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java index c3b7a2af4f..d20d0fac2c 100644 --- a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -183,6 +183,9 @@ public final class TestProtocol { public static final String REQUEST_UNSTASH_BUBBLE_BAR_IF_STASHED = "unstash-bubble-bar-if-stashed"; + public static final String REQUEST_INJECT_FAKE_TRACKPAD = "inject-fake-trackpad"; + public static final String REQUEST_EJECT_FAKE_TRACKPAD = "eject-fake-trackpad"; + /** Logs {@link Log#d(String, String)} if {@link #sDebugTracing} is true. */ public static void testLogD(String tag, String message) { if (!sDebugTracing) { diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index d85f6303d9..f02a0c2296 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -2318,6 +2318,14 @@ public final class LauncherInstrumentation { getTestInfo(TestProtocol.REQUEST_UNSTASH_BUBBLE_BAR_IF_STASHED); } + public void injectFakeTrackpad() { + getTestInfo(TestProtocol.REQUEST_INJECT_FAKE_TRACKPAD); + } + + public void ejectFakeTrackpad() { + getTestInfo(TestProtocol.REQUEST_EJECT_FAKE_TRACKPAD); + } + /** Blocks the taskbar from automatically stashing based on time. */ public void enableBlockTimeout(boolean enable) { getTestInfo(enable