Merge "Support trackpad tapl tests in 3-button mode" into main

This commit is contained in:
Tracy Zhou
2024-05-30 17:59:13 +00:00
committed by Android (Google) Code Review
5 changed files with 48 additions and 4 deletions

View File

@@ -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);

View File

@@ -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
*/

View File

@@ -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());

View File

@@ -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) {

View File

@@ -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