Merge "Decrease TAPL All Apps scrolling flakiness" into tm-qpr-dev am: 6b32ce07b1

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/19560161

Change-Id: I01104af26034497aa989b81e856495aa1454f9e8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Tony Wickham
2022-11-02 16:25:32 +00:00
committed by Automerger Merge Worker
8 changed files with 86 additions and 11 deletions

View File

@@ -928,4 +928,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mControllers.dumpLogs(prefix + "\t", pw);
mDeviceProfile.dump(this, prefix, pw);
}
@VisibleForTesting
public int getTaskbarAllAppsTopPadding() {
return mControllers.taskbarAllAppsController.getTaskbarAllAppsTopPadding();
}
}

View File

@@ -16,6 +16,7 @@
package com.android.launcher3.taskbar.allapps;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.R;
import com.android.launcher3.appprediction.PredictionRowView;
@@ -123,4 +124,11 @@ public final class TaskbarAllAppsController {
.findFixedRowByType(PredictionRowView.class)
.setPredictedApps(mPredictedApps);
}
@VisibleForTesting
public int getTaskbarAllAppsTopPadding() {
// Allow null-pointer since this should only be null if the apps view is not showing.
return mAppsView.getActiveRecyclerView().getClipBounds().top;
}
}

View File

@@ -20,6 +20,7 @@ import com.android.quickstep.util.TISBindHelper;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import java.util.function.Function;
public class QuickstepTestInformationHandler extends TestInformationHandler {
@@ -112,6 +113,13 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
resources.getDimensionPixelSize(R.dimen.taskbar_stashed_size));
return response;
}
case TestProtocol.REQUEST_TASKBAR_ALL_APPS_TOP_PADDING: {
return getTISBinderUIProperty(Bundle::putInt, tisBinder ->
tisBinder.getTaskbarManager()
.getCurrentActivityContext()
.getTaskbarAllAppsTopPadding());
}
}
return super.call(method, arg, extras);
@@ -159,4 +167,16 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
throw new RuntimeException(e);
}
}
private <T> Bundle getTISBinderUIProperty(
BundleSetter<T> bundleSetter, Function<TouchInteractionService.TISBinder, T> provider) {
Bundle response = new Bundle();
runOnTISBinder(tisBinder -> bundleSetter.set(
response,
TestProtocol.TEST_INFO_RESPONSE_FIELD,
provider.apply(tisBinder)));
return response;
}
}

View File

@@ -219,6 +219,11 @@ public class TestInformationHandler implements ResourceBasedOverride {
return response;
}
case TestProtocol.REQUEST_ALL_APPS_TOP_PADDING: {
return getLauncherUIProperty(Bundle::putInt,
l -> l.getAppsView().getActiveRecyclerView().getClipBounds().top);
}
default:
return null;
}

View File

@@ -112,6 +112,9 @@ public final class TestProtocol {
"get-activities-created-count";
public static final String REQUEST_GET_ACTIVITIES = "get-activities";
public static final String REQUEST_HAS_TIS = "has-touch-interaction-service";
public static final String REQUEST_TASKBAR_ALL_APPS_TOP_PADDING =
"taskbar-all-apps-top-padding";
public static final String REQUEST_ALL_APPS_TOP_PADDING = "all-apps-top-padding";
public static final String REQUEST_WORKSPACE_CELL_LAYOUT_SIZE = "workspace-cell-layout-size";
public static final String REQUEST_WORKSPACE_CELL_CENTER = "workspace-cell-center";

View File

@@ -46,8 +46,7 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
super(launcher);
final UiObject2 allAppsContainer = verifyActiveContainer();
mHeight = mLauncher.getVisibleBounds(allAppsContainer).height();
final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
"apps_list_view");
final UiObject2 appListRecycler = getAppListRecycler(allAppsContainer);
// Wait for the recycler to populate.
mLauncher.waitForObjectInContainer(appListRecycler, By.clazz(TextView.class));
verifyNotFrozen("All apps freeze flags upon opening all apps");
@@ -78,6 +77,11 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
LauncherInstrumentation.log("hasClickableIcon: icon center is under search box");
return false;
}
if (iconCenterInRecyclerTopPadding(appListRecycler, icon)) {
LauncherInstrumentation.log(
"hasClickableIcon: icon center is under the app list recycler's top padding.");
return false;
}
if (iconBounds.bottom > displayBottom) {
LauncherInstrumentation.log("hasClickableIcon: icon bottom below bottom offset");
return false;
@@ -92,6 +96,13 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
iconCenter.x, iconCenter.y);
}
private boolean iconCenterInRecyclerTopPadding(UiObject2 appListRecycler, UiObject2 icon) {
final Point iconCenter = icon.getVisibleCenter();
return iconCenter.y <= mLauncher.getVisibleBounds(appListRecycler).top
+ getAppsListRecyclerTopPadding();
}
/**
* Finds an icon. If the icon doesn't exist, return null.
* Scrolls the app list when needed to make sure the icon is visible.
@@ -105,9 +116,7 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"getting app icon " + appName + " on all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
"apps_list_view");
final UiObject2 searchBox = hasSearchBox() ? getSearchBox(allAppsContainer) : null;
final UiObject2 appListRecycler = getAppListRecycler(allAppsContainer);
int deviceHeight = mLauncher.getRealDisplaySize().y;
int bottomGestureStartOnScreen = mLauncher.getBottomGestureStartOnScreen();
@@ -128,10 +137,9 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
mLauncher.getVisibleBounds(icon).top
< bottomGestureStartOnScreen)
.collect(Collectors.toList()),
hasSearchBox()
? mLauncher.getVisibleBounds(searchBox).bottom
- mLauncher.getVisibleBounds(allAppsContainer).top
: 0);
mLauncher.getVisibleBounds(appListRecycler).top
+ getAppsListRecyclerTopPadding()
- mLauncher.getVisibleBounds(allAppsContainer).top);
verifyActiveContainer();
final int newScroll = getAllAppsScroll();
mLauncher.assertTrue(
@@ -180,16 +188,22 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
protected abstract boolean hasSearchBox();
protected abstract int getAppsListRecyclerTopPadding();
private void scrollBackToBeginning() {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to scroll back in all apps")) {
LauncherInstrumentation.log("Scrolling to the beginning");
final UiObject2 allAppsContainer = verifyActiveContainer();
final UiObject2 searchBox = hasSearchBox() ? getSearchBox(allAppsContainer) : null;
final UiObject2 appListRecycler = getAppListRecycler(allAppsContainer);
int attempts = 0;
final Rect margins = new Rect(
0, hasSearchBox() ? mLauncher.getVisibleBounds(searchBox).bottom + 1 : 0, 0, 5);
/* left= */ 0,
mLauncher.getVisibleBounds(appListRecycler).top
+ getAppsListRecyclerTopPadding() + 1,
/* right= */ 0,
/* bottom= */ 5);
for (int scroll = getAllAppsScroll();
scroll != 0;
@@ -220,6 +234,10 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
private UiObject2 getAppListRecycler(UiObject2 allAppsContainer) {
return mLauncher.waitForObjectInContainer(allAppsContainer, "apps_list_view");
}
private UiObject2 getSearchBox(UiObject2 allAppsContainer) {
return mLauncher.waitForObjectInContainer(allAppsContainer, "search_container_all_apps");
}

View File

@@ -18,6 +18,8 @@ package com.android.launcher3.tapl;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.testing.shared.TestProtocol;
/**
* Operations on AllApps opened from the Taskbar.
*/
@@ -48,4 +50,10 @@ public class AllAppsFromTaskbar extends AllApps {
protected boolean hasSearchBox() {
return false;
}
@Override
protected int getAppsListRecyclerTopPadding() {
return mLauncher.getTestInfo(TestProtocol.REQUEST_TASKBAR_ALL_APPS_TOP_PADDING)
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
}

View File

@@ -18,6 +18,8 @@ package com.android.launcher3.tapl;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.testing.shared.TestProtocol;
public class HomeAllApps extends AllApps {
private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
@@ -47,6 +49,12 @@ public class HomeAllApps extends AllApps {
return true;
}
@Override
protected int getAppsListRecyclerTopPadding() {
return mLauncher.getTestInfo(TestProtocol.REQUEST_ALL_APPS_TOP_PADDING)
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
/**
* Taps outside bottom sheet to dismiss and return to workspace. Available on tablets only.
* @param tapRight Tap on the right of bottom sheet if true, or left otherwise.