mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Merge "Fix integration tests with multi-desks on" into main
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user