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

Commit 68f5d6bf authored by Vadim Tryshev's avatar Vadim Tryshev Committed by Android (Google) Code Review
Browse files

Merge "Temporary workaround for UIAutomator not recognizing a new window" into...

Merge "Temporary workaround for UIAutomator not recognizing a new window" into ub-launcher3-qt-qpr1-dev
parents 46463f6a 849b201d
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.launcher3.tapl;

import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;

import android.graphics.Point;

import androidx.test.uiautomator.By;
@@ -23,13 +25,10 @@ import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;

import com.android.launcher3.testing.TestProtocol;

/**
 * Ancestor for AppIcon and AppMenuItem.
 */
abstract class Launchable {
    private static final int WAIT_TIME_MS = 60000;
    protected final LauncherInstrumentation mLauncher;

    protected final UiObject2 mObject;
@@ -53,9 +52,12 @@ abstract class Launchable {
    private Background launch(BySelector selector) {
        LauncherInstrumentation.log("Launchable.launch before click " +
                mObject.getVisibleCenter() + " in " + mObject.getVisibleBounds());
        mLauncher.assertTrue(
                "Launching an app didn't open a new window: " + mObject.getText(),
                mObject.clickAndWait(Until.newWindow(), WAIT_TIME_MS));

        mLauncher.executeAndWaitForEvent(
                () -> mObject.click(),
                event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                "Launching an app didn't open a new window: " + mObject.getText());

        mLauncher.assertTrue(
                "App didn't start: " + selector,
                mLauncher.getDevice().wait(Until.hasObject(selector),
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ public final class LauncherInstrumentation {
    private static final String APPS_RES_ID = "apps_view";
    private static final String OVERVIEW_RES_ID = "overview_panel";
    private static final String WIDGETS_RES_ID = "widgets_list_view";
    public static final int WAIT_TIME_MS = 60000;
    public static final int WAIT_TIME_MS = 10000;
    private static final String SYSTEMUI_PACKAGE = "com.android.systemui";

    private static WeakReference<VisibleContainer> sActiveContainer = new WeakReference<>(null);
+7 −7
Original line number Diff line number Diff line
@@ -16,18 +16,16 @@

package com.android.launcher3.tapl;

import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;

import android.graphics.Rect;

import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;

import com.android.launcher3.testing.TestProtocol;

/**
 * A recent task in the overview panel carousel.
 */
public final class OverviewTask {
    private static final long WAIT_TIME_MS = 60000;
    private final LauncherInstrumentation mLauncher;
    private final UiObject2 mTask;
    private final BaseOverview mOverview;
@@ -66,9 +64,11 @@ public final class OverviewTask {
        verifyActiveContainer();
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "clicking an overview task")) {
            mLauncher.assertTrue("Launching task didn't open a new window: " +
                            mTask.getParent().getContentDescription(),
                    mTask.clickAndWait(Until.newWindow(), WAIT_TIME_MS));
            mLauncher.executeAndWaitForEvent(
                    () -> mTask.click(),
                    event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                    "Launching task didn't open a new window: " +
                            mTask.getParent().getContentDescription());
        }
        return new Background(mLauncher);
    }