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

Commit 86d8386a authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Add TaplTestsQuickstep#testExcludeFromRecents" into main

parents 2bbbc2a3 b84b8524
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52,5 +52,6 @@ filegroup {
        "tests/src/com/android/quickstep/TaplOverviewIconTest.java",
        "tests/src/com/android/quickstep/TaplTestsQuickstep.java",
        "tests/src/com/android/quickstep/TaplTestsSplitscreen.java",
        "tests/src/com/android/launcher3/testcomponent/ExcludeFromRecentsTestActivity.java"
    ],
}
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.launcher3.testcomponent;

/**
 * Extension of BaseTestingActivity to help test excludeFromRecents="true".
 */
public class ExcludeFromRecentsTestActivity extends BaseTestingActivity {}
+23 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUB
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
@@ -37,6 +38,7 @@ import androidx.test.uiautomator.Until;

import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.tapl.BaseOverview;
import com.android.launcher3.tapl.LaunchedAppState;
import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel;
import com.android.launcher3.tapl.Overview;
@@ -581,4 +583,25 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
            mLauncher.getDevice().setOrientationNatural();
        }
    }

    @Test
    public void testExcludeFromRecents() throws Exception {
        startExcludeFromRecentsTestActivity();
        OverviewTask currentTask = getAndAssertLaunchedApp().switchToOverview().getCurrentTask();
        // TODO(b/326565120): the expected content description shouldn't be null but for now there
        // is a bug that causes it to sometimes be for excludeForRecents tasks.
        assertTrue("Can't find ExcludeFromRecentsTestActivity after entering Overview from it",
                currentTask.containsContentDescription("ExcludeFromRecents")
                        || currentTask.containsContentDescription(null));
        // Going home should clear out the excludeFromRecents task.
        BaseOverview overview = mLauncher.goHome().switchToOverview();
        if (overview.hasTasks()) {
            currentTask = overview.getCurrentTask();
            assertFalse("Found ExcludeFromRecentsTestActivity after entering Overview from Home",
                    currentTask.containsContentDescription("ExcludeFromRecents")
                            || currentTask.containsContentDescription(null));
        } else {
            // Presumably the test started with 0 tasks and remains that way after going home.
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -388,6 +388,15 @@
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity-alias>
        <activity android:name="com.android.launcher3.testcomponent.ExcludeFromRecentsTestActivity"
            android:label="ExcludeFromRecentsTestActivity"
            android:exported="true"
            android:excludeFromRecents="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <!-- [b/197780098] Disable eager initialization of Jetpack libraries. -->
        <provider
+11 −0
Original line number Diff line number Diff line
@@ -589,6 +589,17 @@ public abstract class AbstractLauncherUiTest {
                false /* newTask */);
    }

    /** Starts ExcludeFromRecentsTestActivity, which has excludeFromRecents="true". */
    public static void startExcludeFromRecentsTestActivity() {
        final String packageName = getAppPackageName();
        final Intent intent = getInstrumentation().getContext().getPackageManager()
                .getLaunchIntentForPackage(packageName);
        intent.setComponent(new ComponentName(packageName,
                "com.android.launcher3.testcomponent.ExcludeFromRecentsTestActivity"));
        startIntent(intent, By.pkg(packageName).text("ExcludeFromRecentsTestActivity"),
                false /* newTask */);
    }

    private static void startIntent(Intent intent, BySelector selector, boolean newTask) {
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        if (newTask) {
Loading