From 41f99abeb5df95310383edfb906477a25b46f4c7 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 3 Nov 2021 18:10:37 -0700 Subject: [PATCH] Allowing OOP tests to enable home screen rotation. Bug: 202567877 Test: local runs Change-Id: Ifb711a3071a26e2d8e690e0378b6e74146ac722c (cherry picked from commit 462fe7c007bac6f9f91102c465ab81712b64e739) --- .../android/launcher3/testing/TestInformationHandler.java | 6 ++++++ src/com/android/launcher3/testing/TestProtocol.java | 1 + .../com/android/launcher3/tapl/LauncherInstrumentation.java | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 17d925c1f9..8ebfd62b69 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -157,6 +157,12 @@ public class TestInformationHandler implements ResourceBasedOverride { return response; } + case TestProtocol.REQUEST_ENABLE_ROTATION: + MAIN_EXECUTOR.submit(() -> + Launcher.ACTIVITY_TRACKER.getCreatedActivity().getRotationHelper() + .forceAllowRotationForTesting(Boolean.parseBoolean(arg))); + return null; + default: return null; } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 91c7221313..9a74fb1577 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -108,6 +108,7 @@ public final class TestProtocol { "get-focused-task-height-for-tablet"; public static final String REQUEST_GET_GRID_TASK_SIZE_RECT_FOR_TABLET = "get-grid-task-size-rect-for-tablet"; + public static final String REQUEST_ENABLE_ROTATION = "enable_rotation"; public static Long sForcePauseTimeout; public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout"; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index e2d023825c..5a807caa13 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -350,6 +350,10 @@ public final class LauncherInstrumentation { getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout)); } + public void setEnableRotation(boolean on) { + getTestInfo(TestProtocol.REQUEST_ENABLE_ROTATION, Boolean.toString(on)); + } + public boolean hadNontestEvents() { return getTestInfo(TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS) .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);