Add TAPL tests for hiding the actions view when scrolling away from

focused task in overview.

Test: TaplTestsQuickstep.java
Bug: 197630182
Change-Id: Ie44a5bd99d7c9ffbc5405973c0ba1950cd90665c
This commit is contained in:
Pat Manning 2021-09-10 09:44:19 +00:00
parent c1359c448d
commit 35231f3041
5 changed files with 85 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package com.android.quickstep;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import com.android.launcher3.LauncherState;
@ -58,6 +59,17 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
FeatureFlags.ENABLE_OVERVIEW_SHARE.get());
return response;
}
case TestProtocol.REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET: {
if (!mDeviceProfile.isTablet) {
return null;
}
Rect focusedTaskRect = new Rect();
LauncherActivityInterface.INSTANCE.calculateTaskSize(mContext, mDeviceProfile,
focusedTaskRect);
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.width());
return response;
}
}
return super.call(method, arg);

View File

@ -102,6 +102,8 @@ public final class TestProtocol {
public static final String REQUEST_GET_ACTIVITIES_CREATED_COUNT =
"get-activities-created-count";
public static final String REQUEST_GET_ACTIVITIES = "get-activities";
public static final String REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET =
"get-focused-task-width-for-tablet";
public static Long sForcePauseTimeout;
public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout";

View File

@ -35,6 +35,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
BaseOverview(LauncherInstrumentation launcher) {
super(launcher);
verifyActiveContainer();
verifyActionsViewVisibility();
}
@Override
@ -59,7 +60,11 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
final int leftMargin = mLauncher.getTargetInsets().left;
mLauncher.scroll(
overview, Direction.LEFT, new Rect(leftMargin + 1, 0, 0, 0), 20, false);
verifyActiveContainer();
try (LauncherInstrumentation.Closable c2 =
mLauncher.addContextLayer("flung forwards")) {
verifyActiveContainer();
verifyActionsViewVisibility();
}
}
}
@ -95,7 +100,11 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
final int rightMargin = mLauncher.getTargetInsets().right;
mLauncher.scroll(
overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20, false);
verifyActiveContainer();
try (LauncherInstrumentation.Closable c2 =
mLauncher.addContextLayer("flung backwards")) {
verifyActiveContainer();
verifyActionsViewVisibility();
}
}
}
@ -150,4 +159,55 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
return new OverviewActions(overviewActions, mLauncher);
}
}
/* TODO(b/197630182): Once b/188790554 is fixed, remove instanceof check. Currently, when
swiping from app to overview in Fallback Recents, taskbar remains and no action buttons
are visible, so we are only testing Overview for now, not BaseOverview. */
private void verifyActionsViewVisibility() {
if (!(this instanceof Overview)) {
return;
}
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to assert overview actions view visibility")) {
if (mLauncher.isTablet() && !isOverviewSnappedToFocusedTask()) {
mLauncher.waitUntilLauncherObjectGone("action_buttons");
} else {
mLauncher.waitForLauncherObject("action_buttons");
}
}
}
/**
* Returns if focused task is currently snapped task in overview.
*/
private boolean isOverviewSnappedToFocusedTask() {
if (!mLauncher.isTablet()) {
// Focused task only exists in tablet's grid-overview
return false;
}
UiObject2 focusedTask = getFocusedTask();
if (focusedTask == null) {
return false;
}
return Math.abs(
focusedTask.getVisibleBounds().exactCenterX() - mLauncher.getExactScreenCenterX())
< 1;
}
/**
* Returns Overview focused task if it exists.
*/
private UiObject2 getFocusedTask() {
final List<UiObject2> taskViews = getTasks();
if (taskViews.size() == 0) {
return null;
}
int focusedTaskWidth = mLauncher.getFocusedTaskWidth();
for (UiObject2 task : taskViews) {
if (task.getVisibleBounds().width() == focusedTaskWidth) {
return task;
}
}
return null;
}
}

View File

@ -321,6 +321,15 @@ public final class LauncherInstrumentation {
.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
int getFocusedTaskWidth() {
return getTestInfo(TestProtocol.REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET).getInt(
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
float getExactScreenCenterX() {
return getRealDisplaySize().x / 2f;
}
private void setForcePauseTimeout(long timeout) {
getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout));
}

View File

@ -30,7 +30,6 @@ public final class Overview extends BaseOverview {
Overview(LauncherInstrumentation launcher) {
super(launcher);
verifyActiveContainer();
}
@Override