Merge "Fix scroll task off screen to support different screen dimensions." into sc-v2-dev

This commit is contained in:
Alex Chau 2021-10-28 10:27:30 +00:00 committed by Android (Google) Code Review
commit 14c8f45b5e
4 changed files with 31 additions and 9 deletions

View File

@ -43,7 +43,6 @@ import com.android.quickstep.views.RecentsView;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -289,7 +288,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
@Test
@PortraitLandscape
@Ignore("b/203781041")
public void testOverviewForTablet() throws Exception {
if (!mLauncher.isTablet()) {
return;

View File

@ -54,18 +54,14 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
}
private void flingForwardImpl() {
flingForwardImpl(0);
}
private void flingForwardImpl(int rightMargin) {
try (LauncherInstrumentation.Closable c =
mLauncher.addContextLayer("want to fling forward in overview")) {
LauncherInstrumentation.log("Overview.flingForward before fling");
final UiObject2 overview = verifyActiveContainer();
final int leftMargin =
mLauncher.getTargetInsets().left + mLauncher.getEdgeSensitivityWidth();
mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin + 1, 0, rightMargin, 0),
20, false);
mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin + 1, 0, 0, 0), 20,
false);
try (LauncherInstrumentation.Closable c2 =
mLauncher.addContextLayer("flung forwards")) {
verifyActiveContainer();
@ -131,7 +127,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
OverviewTask task = getCurrentTask();
mLauncher.assertNotNull("current task is null", task);
flingForwardImpl(task.getTaskCenterX());
mLauncher.scrollLeftByDistance(verifyActiveContainer(), task.getVisibleWidth());
try (LauncherInstrumentation.Closable c2 =
mLauncher.addContextLayer("scrolled task off screen")) {

View File

@ -1190,10 +1190,19 @@ public final class LauncherInstrumentation {
return getVisibleBounds(container).bottom - bottomGestureStartOnScreen;
}
int getRightGestureMarginInContainer(UiObject2 container) {
final int rightGestureStartOnScreen = getRightGestureStartOnScreen();
return getVisibleBounds(container).right - rightGestureStartOnScreen;
}
int getBottomGestureStartOnScreen() {
return getRealDisplaySize().y - getBottomGestureSize();
}
int getRightGestureStartOnScreen() {
return getRealDisplaySize().x - getWindowInsets().right;
}
void clickLauncherObject(UiObject2 object) {
waitForObjectEnabled(object, "clickLauncherObject");
expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_TOUCH_DOWN);
@ -1235,6 +1244,21 @@ public final class LauncherInstrumentation {
true);
}
void scrollLeftByDistance(UiObject2 container, int distance) {
final Rect containerRect = getVisibleBounds(container);
final int rightGestureMarginInContainer = getRightGestureMarginInContainer(container);
scroll(
container,
Direction.LEFT,
new Rect(
0,
containerRect.width() - distance - rightGestureMarginInContainer,
0,
rightGestureMarginInContainer),
10,
true);
}
void scroll(
UiObject2 container, Direction direction, Rect margins, int steps, boolean slowDown) {
final Rect rect = getVisibleBounds(container);

View File

@ -53,6 +53,10 @@ public final class OverviewTask {
return mTask.getVisibleBounds().height();
}
int getVisibleWidth() {
return mTask.getVisibleBounds().width();
}
int getTaskCenterX() {
return mTask.getVisibleCenter().x;
}