Merge "Fix integration tests with multi-desks on" into main

This commit is contained in:
Min Chen
2025-04-28 16:44:30 -07:00
committed by Android (Google) Code Review
6 changed files with 26 additions and 12 deletions

View File

@@ -104,6 +104,13 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
launcher -> launcher.<RecentsView>getOverviewPanel().getCurrentPage());
}
case TestProtocol.REQUEST_GET_OVERVIEW_FIRST_TASKVIEW_INDEX: {
return getLauncherUIProperty(Bundle::putInt,
launcher ->
launcher.<RecentsView<?, ?>>getOverviewPanel()
.getFirstTaskViewIndex());
}
case TestProtocol.REQUEST_HAS_TIS: {
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, true);
return response;

View File

@@ -1046,7 +1046,7 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
pageToSnapTo = indexOfChild(clearAllButton)
} else if (isClearAllHidden) {
// Snap to focused task if clear all is hidden.
pageToSnapTo = indexOfChild(firstTaskView)
pageToSnapTo = firstTaskViewIndex
}
} else {
val snappedTaskView = currentPageTaskView

View File

@@ -879,6 +879,10 @@ public abstract class RecentsView<
return mUtils.getFirstTaskView();
}
public int getFirstTaskViewIndex() {
return indexOfChild(getFirstTaskView());
}
public RecentsView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setEnableFreeScroll(true);
@@ -4079,7 +4083,7 @@ public abstract class RecentsView<
pageToSnapTo = indexOfChild(mClearAllButton);
} else if (isClearAllHidden) {
// Snap to focused task if clear all is hidden.
pageToSnapTo = indexOfChild(getFirstTaskView());
pageToSnapTo = getFirstTaskViewIndex();
}
} else {
// Get the id of the task view we will snap to based on the current
@@ -4097,7 +4101,7 @@ public abstract class RecentsView<
} else {
// Won't focus next task in split select, so snap to the
// first task.
pageToSnapTo = indexOfChild(getFirstTaskView());
pageToSnapTo = getFirstTaskViewIndex();
calculateScrollDiff = false;
}
} else {

View File

@@ -119,16 +119,14 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Test flinging forward and backward.
runOnRecentsView(recentsView -> assertEquals("Current task in Overview is not first",
recentsView.indexOfChild(recentsView.getFirstTaskView()),
recentsView.getCurrentPage()));
recentsView.getFirstTaskViewIndex(), recentsView.getCurrentPage()));
overview.flingForward();
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
final Integer currentTaskAfterFlingForward =
getFromRecentsView(RecentsView::getCurrentPage);
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
currentTaskAfterFlingForward > recentsView.indexOfChild(
recentsView.getFirstTaskView())));
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still first",
currentTaskAfterFlingForward > recentsView.getFirstTaskViewIndex()));
overview.flingBackward();
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
@@ -390,8 +388,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
overview.scrollCurrentTaskOffScreen();
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still first",
recentsView.getCurrentPage() > recentsView.indexOfChild(
recentsView.getFirstTaskView())));
recentsView.getCurrentPage() > recentsView.getFirstTaskViewIndex()));
// Test opening the task.
overview.getCurrentTask().open();
@@ -407,8 +404,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
assertIsInState(
"Launcher internal state is not Overview", LauncherState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still first",
recentsView.getCurrentPage() > recentsView.indexOfChild(
recentsView.getFirstTaskView())));
recentsView.getCurrentPage() > recentsView.getFirstTaskViewIndex()));
// Test dismissing the later task.
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);

View File

@@ -156,6 +156,8 @@ public final class TestProtocol {
public static final String REQUEST_GET_OVERVIEW_PAGE_SPACING = "get-overview-page-spacing";
public static final String REQUEST_GET_OVERVIEW_CURRENT_PAGE_INDEX =
"get-overview-current-page-index";
public static final String REQUEST_GET_OVERVIEW_FIRST_TASKVIEW_INDEX =
"get-overview-first-taskview-index";
public static final String REQUEST_GET_SPLIT_SELECTION_ACTIVE = "get-split-selection-active";
public static final String REQUEST_ENABLE_ROTATION = "enable_rotation";
public static final String REQUEST_MODEL_QUEUE_CLEARED = "model-queue-cleared";

View File

@@ -448,6 +448,11 @@ public final class LauncherInstrumentation {
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
public int getOverviewFirstTaskViewIndex() {
return getTestInfo(TestProtocol.REQUEST_GET_OVERVIEW_FIRST_TASKVIEW_INDEX).getInt(
TEST_INFO_RESPONSE_FIELD);
}
float getExactScreenCenterX() {
return getRealDisplaySize().x / 2f;
}