Fix launcher scroll distance for TAPL tests.

Test is passing correctly but for the wrong reasons. If we attempted to use a different distance it would have failed.

Bug: 197630182
Test: manual
Change-Id: Ib275b89c86cdb9f75d40b9d25c8c498098b543b7
diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
index 95ab62f..ae2583b 100644
--- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
+++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
@@ -74,6 +74,12 @@
                 response.putParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD, gridTaskRect);
                 return response;
             }
+
+            case TestProtocol.REQUEST_GET_OVERVIEW_PAGE_SPACING: {
+                response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD,
+                        mDeviceProfile.overviewPageSpacing);
+                return response;
+            }
         }
 
         return super.call(method, arg);
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index 237e426..b4917f3 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -345,7 +345,7 @@
         // Test opening the task.
         overview.getCurrentTask().open();
         assertTrue("Test activity didn't open from Overview",
-                mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity8")),
+                mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity10")),
                         DEFAULT_UI_TIMEOUT));
 
         // Scroll the task offscreen as it is now first
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index 673b011..7c6ad9f 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -108,6 +108,7 @@
             "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_GET_OVERVIEW_PAGE_SPACING = "get-overview-page-spacing";
     public static final String REQUEST_ENABLE_ROTATION = "enable_rotation";
 
     public static Long sForcePauseTimeout;
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index 3eb8cf1..b7bca02 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -127,7 +127,8 @@
 
             OverviewTask task = getCurrentTask();
             mLauncher.assertNotNull("current task is null", task);
-            mLauncher.scrollLeftByDistance(verifyActiveContainer(), task.getVisibleWidth());
+            mLauncher.scrollLeftByDistance(verifyActiveContainer(),
+                    task.getVisibleWidth() + mLauncher.getOverviewPageSpacing());
 
             try (LauncherInstrumentation.Closable c2 =
                          mLauncher.addContextLayer("scrolled task off screen")) {
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 631e8f1..2564e97 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -342,6 +342,11 @@
                 .getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD));
     }
 
+    int getOverviewPageSpacing() {
+        return getTestInfo(TestProtocol.REQUEST_GET_OVERVIEW_PAGE_SPACING)
+                .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+    }
+
     float getExactScreenCenterX() {
         return getRealDisplaySize().x / 2f;
     }
@@ -1323,14 +1328,12 @@
     void scrollLeftByDistance(UiObject2 container, int distance) {
         final Rect containerRect = getVisibleBounds(container);
         final int rightGestureMarginInContainer = getRightGestureMarginInContainer(container);
+        final int leftGestureMargin = getTargetInsets().left + getEdgeSensitivityWidth();
         scroll(
                 container,
                 Direction.LEFT,
-                new Rect(
-                        0,
-                        containerRect.width() - distance - rightGestureMarginInContainer,
-                        0,
-                        rightGestureMarginInContainer),
+                new Rect(leftGestureMargin, 0,
+                        containerRect.width() - distance - rightGestureMarginInContainer, 0),
                 10,
                 true);
     }