Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c647ff3 authored by Pat Manning's avatar Pat Manning Committed by Android (Google) Code Review
Browse files

Merge "Add new quickstep test for many tasks open at once." into sc-v2-dev

parents f0f2b75a ccec1de6
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -63,6 +63,17 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
                response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.height());
                return response;
            }

            case TestProtocol.REQUEST_GET_GRID_TASK_SIZE_RECT_FOR_TABLET: {
                if (!mDeviceProfile.isTablet) {
                    return null;
                }
                Rect gridTaskRect = new Rect();
                LauncherActivityInterface.INSTANCE.calculateGridTaskSize(mContext, mDeviceProfile,
                        gridTaskRect, PagedOrientationHandler.PORTRAIT);
                response.putParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD, gridTaskRect);
                return response;
            }
        }

        return super.call(method, arg);
+15 −1
Original line number Diff line number Diff line
@@ -1484,6 +1484,20 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        return groupViewCount;
    }

    /**
     * Returns the number of tasks in the top row of the overview grid.
     */
    public int getTopRowTaskCountForTablet() {
        return mTopRowIdSet.size();
    }

    /**
     * Returns the number of tasks in the bottom row of the overview grid.
     */
    public int getBottomRowTaskCountForTablet() {
        return getTaskViewCount() - mTopRowIdSet.size() - 1;
    }

    protected void onTaskStackUpdated() {
        // Lazily update the empty message only when the task stack is reapplied
        updateEmptyMessage();
@@ -3170,7 +3184,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     * Returns all the tasks in the bottom row, without the focused task
     */
    private IntArray getBottomRowIdArray() {
        int bottomRowIdArraySize = getTaskViewCount() - mTopRowIdSet.size() - 1;
        int bottomRowIdArraySize = getBottomRowTaskCountForTablet();
        if (bottomRowIdArraySize <= 0) {
            return new IntArray(0);
        }
+76 −1
Original line number Diff line number Diff line
@@ -146,7 +146,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {

        // Test dismissing all tasks.
        mLauncher.pressHome().switchToOverview().dismissAllTasks();
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
        assertTrue("Launcher internal state is not Home",
                isInState(() -> LauncherState.NORMAL));
        executeOnLauncher(
                launcher -> assertEquals("Still have tasks after dismissing all",
                        0, getTaskCount(launcher)));
@@ -180,6 +181,14 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        return launcher.<RecentsView>getOverviewPanel().getTaskViewCount();
    }

    private int getTopRowTaskCountForTablet(Launcher launcher) {
        return launcher.<RecentsView>getOverviewPanel().getTopRowTaskCountForTablet();
    }

    private int getBottomRowTaskCountForTablet(Launcher launcher) {
        return launcher.<RecentsView>getOverviewPanel().getBottomRowTaskCountForTablet();
    }

    @Test
    @NavigationModeSwitch
    @PortraitLandscape
@@ -276,4 +285,70 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
                isTestActivityRunning(2));
        getAndAssertBackground();
    }

    @Test
    @PortraitLandscape
    public void testOverviewForTablet() throws Exception {
        if (!mLauncher.isTablet()) {
            return;
        }
        for (int i = 2; i <= 12; i++) {
            startTestActivity(i);
        }

        Overview overview = mLauncher.pressHome().switchToOverview();
        executeOnLauncher(
                launcher -> assertTrue("Don't have at least 11 tasks",
                        getTaskCount(launcher) >= 11));

        // Test scroll the first task off screen
        overview.scrollCurrentTaskOffScreen();
        assertTrue("Launcher internal state is not Overview",
                isInState(() -> LauncherState.OVERVIEW));
        executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0",
                getCurrentOverviewPage(launcher) > 0));

        // Test opening the task.
        overview.getCurrentTask().open();
        assertTrue("Test activity didn't open from Overview",
                mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity8")),
                        DEFAULT_UI_TIMEOUT));

        // Scroll the task offscreen as it is now first
        overview = mLauncher.pressHome().switchToOverview();
        overview.scrollCurrentTaskOffScreen();
        assertTrue("Launcher internal state is not Overview",
                isInState(() -> LauncherState.OVERVIEW));
        executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0",
                getCurrentOverviewPage(launcher) > 0));

        // Test dismissing the later task.
        final Integer numTasks = getFromLauncher(this::getTaskCount);
        overview.getCurrentTask().dismiss();
        executeOnLauncher(
                launcher -> assertEquals("Dismissing a task didn't remove 1 task from Overview",
                        numTasks - 1, getTaskCount(launcher)));
        executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after dismissal",
                (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet(
                        launcher)) <= 1)));

        // Test dismissing more tasks.
        assertTrue("Launcher internal state didn't remain in Overview",
                isInState(() -> LauncherState.OVERVIEW));
        overview.getCurrentTask().dismiss();
        assertTrue("Launcher internal state didn't remain in Overview",
                isInState(() -> LauncherState.OVERVIEW));
        overview.getCurrentTask().dismiss();
        executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after multiple dismissals",
                (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet(
                        launcher)) <= 1)));

        // Test dismissing all tasks.
        mLauncher.pressHome().switchToOverview().dismissAllTasks();
        assertTrue("Launcher internal state is not Home",
                isInState(() -> LauncherState.NORMAL));
        executeOnLauncher(
                launcher -> assertEquals("Still have tasks after dismissing all",
                        0, getTaskCount(launcher)));
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -104,6 +104,8 @@ public final class TestProtocol {
    public static final String REQUEST_GET_ACTIVITIES = "get-activities";
    public static final String REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET =
            "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 Long sForcePauseTimeout;
    public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout";
+33 −18
Original line number Diff line number Diff line
@@ -145,6 +145,16 @@
            <meta-data android:name="android.app.shortcuts"
                       android:resource="@xml/shortcuts"/>
        </activity>
        <activity
            android:name="com.android.launcher3.testcomponent.OtherBaseTestingActivity"
            android:label="OtherLauncherTestApp"
            android:exported="true"
            android:taskAffinity="com.android.launcher3.testcomponent.Affinity2">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity-alias android:name="Activity2"
                        android:label="TestActivity2"
                        android:exported="true"
@@ -208,28 +218,33 @@
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity-alias>
        <activity-alias android:name="Activity9"
        <activity-alias android:name="Activity9" android:exported="true"
            android:label="TestActivity9"
                        android:exported="true"
                        android:targetActivity="com.android.launcher3.testcomponent.BaseTestingActivity">
            android:targetActivity="com.android.launcher3.testcomponent.OtherBaseTestingActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>
        <activity-alias android:name="Activity10"
        <activity-alias android:name="Activity10" android:exported="true"
            android:label="TestActivity10"
                        android:exported="true"
                        android:targetActivity="com.android.launcher3.testcomponent.BaseTestingActivity">
            android:targetActivity="com.android.launcher3.testcomponent.OtherBaseTestingActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>
        <activity-alias android:name="Activity11"
        <activity-alias android:name="Activity11" android:exported="true"
            android:label="TestActivity11"
                        android:exported="true"
                        android:targetActivity="com.android.launcher3.testcomponent.BaseTestingActivity">
            android:targetActivity="com.android.launcher3.testcomponent.OtherBaseTestingActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>
        <activity-alias android:name="Activity12" android:exported="true"
            android:label="TestActivity12"
            android:targetActivity="com.android.launcher3.testcomponent.OtherBaseTestingActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
Loading