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

Commit 6183c4dd authored by Becky Qiu's avatar Becky Qiu
Browse files

[Toast] Create one search tapl tests for opening qsb and calculator app.

Test design doc: https://docs.google.com/document/d/1aPtMvegzn4hdwC0CNuIkfkalqG7v0FNCfyoO7qIOfN4/edit?usp=sharing&resourcekey=0-71oNHp1KKOdDKxr7Vd4dGQ

Bug: 225935921
Bug: 225935929
Test: ran test in android studio
Change-Id: I74197a9d81fc75a44269ab3bc1bba910de5e17fe
parent a717d162
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import androidx.annotation.AnyThread;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;

import com.android.launcher3.Utilities;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
import com.android.launcher3.logger.LauncherAtom.FolderContainer;
@@ -116,7 +117,8 @@ public class AppEventProducer implements StatsLogConsumer {
    @AnyThread
    private void sendEvent(AppTarget target, LauncherAtom.ItemInfo locationInfo, int eventId,
            int targetPredictor) {
        if (target != null) {
        // TODO: remove the running test check when b/231648228 is fixed.
        if (target != null && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
            AppTargetEvent event = new AppTargetEvent.Builder(target, eventId)
                    .setLaunchLocation(getContainer(locationInfo))
                    .build();
+14 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ public class StatsLogCompatManager extends StatsLogManager {
        if (IS_VERBOSE) {
            Log.d(TAG, String.format("\nwriteSnapshot(%d):\n%s", instanceId.getId(), info));
        }
        if (!Utilities.ATLEAST_R) {
        if (!Utilities.ATLEAST_R || Utilities.IS_RUNNING_IN_TEST_HARNESS) {
            return;
        }
        SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_SNAPSHOT,
@@ -415,6 +415,10 @@ public class StatsLogCompatManager extends StatsLogManager {
                consumer.consume(event, atomInfo);
            }

            // TODO: remove this when b/231648228 is fixed.
            if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
                return;
            }
            SysUiStatsLog.write(
                    SysUiStatsLog.LAUNCHER_EVENT,
                    SysUiStatsLog.LAUNCHER_UICHANGED__ACTION__DEFAULT_ACTION /* deprecated */,
@@ -510,6 +514,9 @@ public class StatsLogCompatManager extends StatsLogManager {
    }

    private static int getCardinality(LauncherAtom.ItemInfo info) {
        if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
            return 0;
        }
        switch (info.getContainerInfo().getContainerCase()) {
            case PREDICTED_HOTSEAT_CONTAINER:
                return info.getContainerInfo().getPredictedHotseatContainer().getCardinality();
@@ -625,6 +632,9 @@ public class StatsLogCompatManager extends StatsLogManager {
    }

    private static int getHierarchy(LauncherAtom.ItemInfo info) {
        if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
            return 0;
        }
        if (info.getContainerInfo().getContainerCase() == FOLDER) {
            return info.getContainerInfo().getFolder().getParentContainerCase().getNumber()
                    + FOLDER_HIERARCHY_OFFSET;
@@ -665,6 +675,9 @@ public class StatsLogCompatManager extends StatsLogManager {
    }

    private static int getSearchAttributes(LauncherAtom.ItemInfo info) {
        if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
            return 0;
        }
        ContainerInfo containerInfo = info.getContainerInfo();
        if (containerInfo.getContainerCase() == EXTENDED_CONTAINERS
                && containerInfo.getExtendedContainers().getContainerCase()
+5 −3
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ import org.junit.runner.RunWith;
public class TaplTestsQuickstep extends AbstractQuickStepTest {

    private static final String APP_NAME = "LauncherTestApp";
    private static final String CALCULATOR_APP_PACKAGE =
            resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);

    @Before
    public void setUp() throws Exception {
@@ -73,7 +75,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {

    public static void startTestApps() throws Exception {
        startAppFast(getAppPackageName());
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        startAppFast(CALCULATOR_APP_PACKAGE);
        startTestActivity(2);
    }

@@ -207,7 +209,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
    @NavigationModeSwitch
    @PortraitLandscape
    public void testBackground() throws Exception {
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        startAppFast(CALCULATOR_APP_PACKAGE);
        final LaunchedAppState launchedAppState = getAndAssertLaunchedApp();

        assertNotNull("Background.switchToOverview() returned null",
@@ -302,7 +304,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        mLauncher.getWorkspace();
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);

        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        startAppFast(CALCULATOR_APP_PACKAGE);
        mLauncher.pressBack();
        mLauncher.getWorkspace();
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.tapl;

/**
 * Operations on home screen qsb.
 */
public class HomeQsb {

    private final LauncherInstrumentation mLauncher;

    HomeQsb(LauncherInstrumentation launcher) {
        mLauncher = launcher;
        mLauncher.waitForLauncherObject("search_container_hotseat");
    }

    /**
     * Show search result page from tapping qsb.
     */
    public SearchResultFromQsb showSearchResult() {
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "want to open search result page");
             LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
            mLauncher.clickLauncherObject(
                    mLauncher.waitForLauncherObject("search_container_hotseat"));
            try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer(
                    "clicked qsb to open search result page")) {
                return new SearchResultFromQsb(mLauncher);
            }
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import com.android.launcher3.testing.TestProtocol;
/**
 * Ancestor for AppIcon and AppMenuItem.
 */
abstract class Launchable {
public abstract class Launchable {

    protected static final int DEFAULT_DRAG_STEPS = 10;

Loading