Merge "Change TAPL to swipe to stash taskbar (instead of deprecated long press)" into main

This commit is contained in:
Tony Wickham authored and Android (Google) Code Review committed 2023-12-05 02:40:02 +00:00
commit 2f334e9ca7
12 files changed
+150 -114

No files matched your search

@@ -106,10 +106,10 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
});
return response;
case TestProtocol.REQUEST_STASHED_TASKBAR_HEIGHT: {
case TestProtocol.REQUEST_TASKBAR_FROM_NAV_THRESHOLD: {
final Resources resources = mContext.getResources();
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD,
resources.getDimensionPixelSize(R.dimen.taskbar_stashed_size));
resources.getDimensionPixelSize(R.dimen.taskbar_from_nav_threshold));
return response;
}
@@ -20,9 +20,10 @@ import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,17 +33,10 @@ public class TaplTestsPersistentTaskbar extends AbstractTaplTestsTaskbar {
@Test
@TaskbarModeSwitch(mode = PERSISTENT)
public void testHideShowTaskbar() {
getTaskbar().hide();
mLauncher.getLaunchedAppState().showTaskbar();
}
@Test
@TaskbarModeSwitch(mode = PERSISTENT)
@Ignore // b/301575789
public void testHideTaskbarPersistsOnRecreate() {
getTaskbar().hide();
mLauncher.recreateTaskbar();
mLauncher.getLaunchedAppState().assertTaskbarHidden();
@PortraitLandscape
@NavigationModeSwitch
public void testTaskbarFillsWidth() {
// Width check is performed inside TAPL whenever getTaskbar() is called.
getTaskbar();
}
}
@@ -18,7 +18,6 @@ package com.android.quickstep;
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT;
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
import static org.junit.Assert.assertEquals;
@@ -295,7 +294,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
}
@Test
@TaskbarModeSwitch(mode = PERSISTENT)
@TaskbarModeSwitch
public void testQuickSwitchToPreviousAppForTablet() throws Exception {
assumeTrue(mLauncher.isTablet());
startTestActivity(2);
@@ -304,22 +303,33 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Set ignoreTaskbarVisibility to true to verify the task bar visibility explicitly.
mLauncher.setIgnoreTaskbarVisibility(true);
// Expect task bar invisible when the launched app was the IME activity.
LaunchedAppState launchedAppState = getAndAssertLaunchedApp();
if (isHardwareKeyboard()) {
launchedAppState.assertTaskbarVisible();
} else {
launchedAppState.assertTaskbarHidden();
try {
boolean isTransientTaskbar = mLauncher.isTransientTaskbar();
// Expect task bar invisible when the launched app was the IME activity.
LaunchedAppState launchedAppState = getAndAssertLaunchedApp();
if (!isTransientTaskbar && isHardwareKeyboard()) {
launchedAppState.assertTaskbarVisible();
} else {
launchedAppState.assertTaskbarHidden();
}
// Quick-switch to the test app with swiping to right.
quickSwitchToPreviousAppAndAssert(true /* toRight */);
assertTestActivityIsRunning(2,
"The first app we should have quick switched to is not running");
launchedAppState = getAndAssertLaunchedApp();
if (isTransientTaskbar) {
launchedAppState.assertTaskbarHidden();
} else {
// Expect taskbar visible when the launched app was the test activity.
launchedAppState.assertTaskbarVisible();
}
} finally {
// Reset ignoreTaskbarVisibility to ensure other tests still verify it.
mLauncher.setIgnoreTaskbarVisibility(false);
}
// Quick-switch to the test app with swiping to right.
quickSwitchToPreviousAppAndAssert(true /* toRight */);
assertTestActivityIsRunning(2,
"The first app we should have quick switched to is not running");
// Expect task bar visible when the launched app was the test activity.
launchedAppState = getAndAssertLaunchedApp();
launchedAppState.assertTaskbarVisible();
}
private boolean isHardwareKeyboard() {
@@ -358,7 +368,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
@Test
@PortraitLandscape
@TaskbarModeSwitch(mode = PERSISTENT)
@TaskbarModeSwitch()
@PlatinumTest(focusArea = "launcher")
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/309820115
@ScreenRecord // b/309820115
@@ -454,6 +464,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
@Test
@PortraitLandscape
@TaskbarModeSwitch
public void testTaskbarDeadzonesForTablet() throws Exception {
assumeTrue(mLauncher.isTablet());
@@ -466,15 +477,29 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
launcher -> assertTrue("Should have at least 3 tasks",
getTaskCount(launcher) >= 3));
// On persistent taskbar, it should not dismiss when tapping the taskbar
overview.touchTaskbarBottomCorner(/* tapRight= */ false);
assertTrue("Launcher internal state should be Overview",
isInState(() -> LauncherState.OVERVIEW));
if (mLauncher.isTransientTaskbar()) {
// On transient taskbar, it should dismiss when tapping outside taskbar bounds.
overview.touchTaskbarBottomCorner(/* tapRight= */ false);
assertTrue("Launcher internal state should be Normal",
isInState(() -> LauncherState.NORMAL));
// On persistent taskbar, it should not dismiss when tapping the taskbar
overview.touchTaskbarBottomCorner(/* tapRight= */ true);
assertTrue("Launcher internal state should be Overview",
isInState(() -> LauncherState.OVERVIEW));
overview = mLauncher.getWorkspace().switchToOverview();
// On transient taskbar, it should dismiss when tapping outside taskbar bounds.
overview.touchTaskbarBottomCorner(/* tapRight= */ true);
assertTrue("Launcher internal state should be Normal",
isInState(() -> LauncherState.NORMAL));
} else {
// On persistent taskbar, it should not dismiss when tapping the taskbar
overview.touchTaskbarBottomCorner(/* tapRight= */ false);
assertTrue("Launcher internal state should be Overview",
isInState(() -> LauncherState.OVERVIEW));
// On persistent taskbar, it should not dismiss when tapping the taskbar
overview.touchTaskbarBottomCorner(/* tapRight= */ true);
assertTrue("Launcher internal state should be Overview",
isInState(() -> LauncherState.OVERVIEW));
}
}
@Test
@@ -24,6 +24,7 @@ import static org.junit.Assume.assumeTrue;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
import org.junit.Test;
@@ -64,4 +65,12 @@ public class TaplTestsTransientTaskbar extends AbstractTaplTestsTaskbar {
getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
mLauncher.getLaunchedAppState().clickStashedTaskbarToGoHome();
}
@Test
@TaskbarModeSwitch(mode = TRANSIENT)
@PortraitLandscape
public void testSwipeToStashAndUnstash() {
getTaskbar().swipeDownToStash();
mLauncher.getLaunchedAppState().swipeUpToUnstashTaskbar();
}
}
@@ -47,6 +47,7 @@ import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.testing.shared.HotseatCellCenterRequest;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.testing.shared.WorkspaceCellCenterRequest;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.ResourceBasedOverride;
import com.android.launcher3.widget.picker.WidgetsFullSheet;
@@ -179,6 +180,11 @@ public class TestInformationHandler implements ResourceBasedOverride {
mDeviceProfile.numShownAllAppsColumns);
return response;
case TestProtocol.REQUEST_IS_TRANSIENT_TASKBAR:
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
DisplayController.isTransientTaskbar(mContext));
return response;
case TestProtocol.REQUEST_IS_TWO_PANELS:
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
FOLDABLE_SINGLE_PAGE.get() ? false : mDeviceProfile.isTwoPanels);
@@ -71,7 +71,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
private static final String TAG = "DisplayController";
private static final boolean DEBUG = false;
private static boolean sTransientTaskbarStatusForTests;
private static boolean sTransientTaskbarStatusForTests = true;
// TODO(b/254119092) remove all logs with this tag
public static final String TASKBAR_NOT_DESTROYED_TAG = "b/254119092";
@@ -41,6 +41,7 @@ import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.Utilities;
import com.android.launcher3.testing.shared.ResourceUtils;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.TouchController;
@@ -559,7 +560,8 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
DeviceProfile dp = mActivity.getDeviceProfile();
if (dp.isTaskbarPresent) {
// Ignore taskbar gesture insets to avoid interfering with TouchControllers.
gestureInsetBottom = Math.max(0, gestureInsetBottom - dp.taskbarHeight);
gestureInsetBottom = ResourceUtils.getNavbarSize(
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources());
}
mSystemGestureRegion.set(
Math.max(gestureInsets.left, imeInset.left),
@@ -96,8 +96,9 @@ public final class TestProtocol {
public static final String REQUEST_DISABLE_BLOCK_TIMEOUT = "disable-block-timeout";
public static final String REQUEST_ENABLE_TRANSIENT_TASKBAR = "enable-transient-taskbar";
public static final String REQUEST_DISABLE_TRANSIENT_TASKBAR = "disable-transient-taskbar";
public static final String REQUEST_IS_TRANSIENT_TASKBAR = "is-transient-taskbar";
public static final String REQUEST_UNSTASH_TASKBAR_IF_STASHED = "unstash-taskbar-if-stashed";
public static final String REQUEST_STASHED_TASKBAR_HEIGHT = "stashed-taskbar-height";
public static final String REQUEST_TASKBAR_FROM_NAV_THRESHOLD = "taskbar-from-nav-threshold";
public static final String REQUEST_STASHED_TASKBAR_SCALE = "taskbar-stash-handle-scale";
public static final String REQUEST_RECREATE_TASKBAR = "recreate-taskbar";
public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags";
@@ -186,7 +186,14 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
Taskbar taskbar = new Taskbar(mLauncher);
taskbar.touchBottomCorner(tapRight);
verifyActiveContainer();
if (mLauncher.isTransientTaskbar()) {
// Tapping outside Transient Taskbar returns to Workspace, wait for that state.
new Workspace(mLauncher);
} else {
// Should stay in Overview.
verifyActiveContainer();
verifyActionsViewVisibility();
}
}
}
@@ -20,12 +20,11 @@ import static com.android.launcher3.tapl.LauncherInstrumentation.DEFAULT_POLL_IN
import static com.android.launcher3.tapl.LauncherInstrumentation.TASKBAR_RES_ID;
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_BLOCK_TIMEOUT;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_BLOCK_TIMEOUT;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_SHELL_DRAG_READY;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_STASHED_TASKBAR_HEIGHT;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_STASHED_TASKBAR_SCALE;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_TASKBAR_FROM_NAV_THRESHOLD;
import static com.android.launcher3.testing.shared.TestProtocol.TEST_INFO_RESPONSE_FIELD;
import android.graphics.Point;
import android.graphics.Rect;
@@ -84,8 +83,6 @@ public final class LaunchedAppState extends Background {
public Taskbar getTaskbar() {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to get the taskbar")) {
mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
return new Taskbar(mLauncher);
}
}
@@ -113,37 +110,32 @@ public final class LaunchedAppState extends Background {
/**
* Returns the Taskbar in a visible state.
*
* The taskbar must already be hidden when calling this method.
* The taskbar must already be hidden and in transient mode when calling this method.
*/
public Taskbar showTaskbar() {
mLauncher.getTestInfo(REQUEST_ENABLE_MANUAL_TASKBAR_STASHING);
public Taskbar swipeUpToUnstashTaskbar() {
mLauncher.assertTrue("Taskbar is not transient, swipe up not supported",
mLauncher.isTransientTaskbar());
mLauncher.getTestInfo(REQUEST_ENABLE_BLOCK_TIMEOUT);
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"want to show the taskbar")) {
"want to swipe up to unstash the taskbar")) {
mLauncher.waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
final long downTime = SystemClock.uptimeMillis();
final int unstashTargetY = mLauncher.getRealDisplaySize().y
- (mLauncher.getTestInfo(REQUEST_STASHED_TASKBAR_HEIGHT)
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD) / 2);
final Point unstashTarget = new Point(
mLauncher.getRealDisplaySize().x / 2, unstashTargetY);
int taskbarFromNavThreshold = mLauncher.getTestInfo(REQUEST_TASKBAR_FROM_NAV_THRESHOLD)
.getInt(TEST_INFO_RESPONSE_FIELD);
int startX = mLauncher.getRealDisplaySize().x / 2;
int startY = mLauncher.getRealDisplaySize().y - 1;
int endX = startX;
int endY = startY - taskbarFromNavThreshold;
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, unstashTarget,
mLauncher.linearGesture(startX, startY, endX, endY, 10, /* slowDown= */ true,
LauncherInstrumentation.GestureScope.EXPECT_PILFER);
LauncherInstrumentation.log("showTaskbar: sent down");
LauncherInstrumentation.log("swipeUpToUnstashTaskbar: sent linear swipe up gesture");
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) {
mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, unstashTarget,
LauncherInstrumentation.GestureScope.EXPECT_PILFER);
return new Taskbar(mLauncher);
}
return new Taskbar(mLauncher);
} finally {
mLauncher.getTestInfo(REQUEST_DISABLE_MANUAL_TASKBAR_STASHING);
mLauncher.getTestInfo(REQUEST_DISABLE_BLOCK_TIMEOUT);
}
}
@@ -824,12 +824,7 @@ public final class LauncherInstrumentation {
waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID);
waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID);
waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID);
if (is3PLauncher() && isTablet()) {
waitForSystemLauncherObject(TASKBAR_RES_ID);
} else {
waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
}
waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
return waitForLauncherObject(WORKSPACE_RES_ID);
}
@@ -839,12 +834,7 @@ public final class LauncherInstrumentation {
waitUntilSystemLauncherObjectGone(OVERVIEW_RES_ID);
waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID);
waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID);
if (is3PLauncher() && isTablet()) {
waitForSystemLauncherObject(TASKBAR_RES_ID);
} else {
waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
}
waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
return waitForLauncherObject(WIDGETS_RES_ID);
}
@@ -865,7 +855,7 @@ public final class LauncherInstrumentation {
waitUntilSystemLauncherObjectGone(SPLIT_PLACEHOLDER_RES_ID);
waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID);
if (is3PLauncher() && isTablet()) {
if (is3PLauncher() && isTablet() && !isTransientTaskbar()) {
waitForSystemLauncherObject(TASKBAR_RES_ID);
} else {
waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
@@ -878,7 +868,7 @@ public final class LauncherInstrumentation {
waitUntilLauncherObjectGone(APPS_RES_ID);
waitUntilLauncherObjectGone(WORKSPACE_RES_ID);
waitUntilLauncherObjectGone(WIDGETS_RES_ID);
if (isTablet()) {
if (isTablet() && !is3PLauncher()) {
waitForSystemLauncherObject(TASKBAR_RES_ID);
} else {
waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
@@ -915,7 +905,11 @@ public final class LauncherInstrumentation {
}
if (isTablet()) {
waitForSystemLauncherObject(TASKBAR_RES_ID);
// Only check that Persistent Taskbar is visible, since Transient Taskbar
// may or may not be visible by design.
if (!isTransientTaskbar()) {
waitForSystemLauncherObject(TASKBAR_RES_ID);
}
} else {
waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
}
@@ -995,7 +989,7 @@ public final class LauncherInstrumentation {
/**
* Using swiping up gesture to dismiss closable floating views, such as Menu or Folder Content.
*/
private void swipeUpToCloseFloatingView(boolean gestureStartFromLauncher) {
private void swipeUpToCloseFloatingView() {
final Point displaySize = getRealDisplaySize();
final Optional<String> floatingRes = getFloatingResId();
@@ -1004,16 +998,11 @@ public final class LauncherInstrumentation {
return;
}
GestureScope gestureScope = gestureStartFromLauncher
// Without the navigation bar layer, the gesture scope on tablets remains inside the
// launcher process.
? (isTablet() ? GestureScope.DONT_EXPECT_PILFER : GestureScope.EXPECT_PILFER)
: GestureScope.EXPECT_PILFER;
linearGesture(
displaySize.x / 2, displaySize.y - 1,
displaySize.x / 2, 0,
ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME,
false, gestureScope);
false, GestureScope.EXPECT_PILFER);
try (LauncherInstrumentation.Closable c1 = addContextLayer(
String.format("Swiped up from floating view %s to home", floatingRes.get()))) {
@@ -1081,11 +1070,8 @@ public final class LauncherInstrumentation {
final Point displaySize = getRealDisplaySize();
boolean gestureStartFromLauncher =
isTablet() ? !isLauncher3() : isLauncherVisible();
// CLose floating views before going back to home.
swipeUpToCloseFloatingView(gestureStartFromLauncher);
swipeUpToCloseFloatingView();
if (hasLauncherObject(WORKSPACE_RES_ID)) {
log(action = "already at home");
@@ -2039,6 +2025,7 @@ public final class LauncherInstrumentation {
}
}
/** Returns the bounds of the display as a Point where x is width and y is height. */
Point getRealDisplaySize() {
final Rect displayBounds = getContext().getSystemService(WindowManager.class)
.getMaximumWindowMetrics()
@@ -2101,6 +2088,11 @@ public final class LauncherInstrumentation {
: TestProtocol.REQUEST_DISABLE_BLOCK_TIMEOUT);
}
public boolean isTransientTaskbar() {
return getTestInfo(TestProtocol.REQUEST_IS_TRANSIENT_TASKBAR)
.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
/** Enables transient taskbar for testing purposes only. */
public void enableTransientTaskbar(boolean enable) {
getTestInfo(enable
@@ -18,8 +18,6 @@ package com.android.launcher3.tapl;
import static android.view.KeyEvent.KEYCODE_META_RIGHT;
import static com.android.launcher3.tapl.LauncherInstrumentation.TASKBAR_RES_ID;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING;
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING;
import android.graphics.Point;
import android.graphics.Rect;
@@ -33,6 +31,8 @@ import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiObject2;
import org.junit.Assert;
import java.util.List;
import java.util.stream.Collectors;
@@ -45,6 +45,15 @@ public final class Taskbar {
Taskbar(LauncherInstrumentation launcher) {
mLauncher = launcher;
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"expect new taskbar to be visible")) {
mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
}
if (!mLauncher.isTransientTaskbar()) {
Assert.assertEquals("Persistent taskbar should fill screen width",
getVisibleBounds().width(), mLauncher.getRealDisplaySize().x);
}
}
/**
@@ -61,33 +70,32 @@ public final class Taskbar {
}
/**
* Hides this taskbar.
*
* The taskbar must already be visible when calling this method.
* Stashes this taskbar.
* <p>
* The taskbar must already be unstashed and in transient mode when calling this method.
*/
public void hide() {
mLauncher.getTestInfo(REQUEST_ENABLE_MANUAL_TASKBAR_STASHING);
public void swipeDownToStash() {
mLauncher.assertTrue("Taskbar is not transient, swipe down not supported",
mLauncher.isTransientTaskbar());
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to hide the taskbar");
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
final long downTime = SystemClock.uptimeMillis();
Point stashTarget = new Point(
mLauncher.getRealDisplaySize().x - 1, mLauncher.getRealDisplaySize().y - 1);
Rect taskbarBounds = getVisibleBounds();
int startX = taskbarBounds.centerX();
int startY = taskbarBounds.centerY();
int endX = startX;
int endY = mLauncher.getRealDisplaySize().y - 1;
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, stashTarget,
mLauncher.linearGesture(startX, startY, endX, endY, 10, false,
LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
LauncherInstrumentation.log("hideTaskbar: sent down");
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) {
LauncherInstrumentation.log("swipeDownToStash: sent linear swipe down gesture");
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"expect transient taskbar to be hidden after swipe down")) {
mLauncher.waitUntilSystemLauncherObjectGone(TASKBAR_RES_ID);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, stashTarget,
LauncherInstrumentation.GestureScope.DONT_EXPECT_PILFER);
}
} finally {
mLauncher.getTestInfo(REQUEST_DISABLE_MANUAL_TASKBAR_STASHING);
}
}