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

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

Merge "TAPL: Simplifying BaseOverview" into ub-launcher3-qt-dev

parents 695e8df5 90b420a6
Loading
Loading
Loading
Loading
+0 −6
Original line number Original line Diff line number Diff line
@@ -17,16 +17,12 @@
package com.android.launcher3.tapl;
package com.android.launcher3.tapl;


import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;


import android.graphics.Point;
import android.graphics.Point;
import android.os.SystemClock;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.MotionEvent;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.Until;


import com.android.launcher3.TestProtocol;
import com.android.launcher3.TestProtocol;


@@ -59,8 +55,6 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                "want to switch from background to overview")) {
                "want to switch from background to overview")) {
            verifyActiveContainer();
            verifyActiveContainer();
            goToOverviewUnchecked(BACKGROUND_APP_STATE_ORDINAL);
            goToOverviewUnchecked(BACKGROUND_APP_STATE_ORDINAL);
            mLauncher.assertTrue("Overview not visible", mLauncher.getDevice().wait(
                    Until.hasObject(By.pkg(getOverviewPackageName())), WAIT_TIME_MS));
            return new BaseOverview(mLauncher);
            return new BaseOverview(mLauncher);
        }
        }
    }
    }
+1 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {


    BaseOverview(LauncherInstrumentation launcher) {
    BaseOverview(LauncherInstrumentation launcher) {
        super(launcher);
        super(launcher);
        verifyActiveContainer();
    }
    }


    @Override
    @Override
+16 −3
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.tapl;


import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;


import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.Instrumentation;
@@ -296,14 +297,14 @@ public final class LauncherInstrumentation {
                    } else {
                    } else {
                        waitUntilGone(APPS_RES_ID);
                        waitUntilGone(APPS_RES_ID);
                    }
                    }
                    // Fall through
                }
                case BASE_OVERVIEW: {
                    waitUntilGone(WORKSPACE_RES_ID);
                    waitUntilGone(WORKSPACE_RES_ID);
                    waitUntilGone(WIDGETS_RES_ID);
                    waitUntilGone(WIDGETS_RES_ID);


                    return waitForLauncherObject(OVERVIEW_RES_ID);
                    return waitForLauncherObject(OVERVIEW_RES_ID);
                }
                }
                case BASE_OVERVIEW: {
                    return waitForFallbackLauncherObject(OVERVIEW_RES_ID);
                }
                case BACKGROUND: {
                case BACKGROUND: {
                    waitUntilGone(WORKSPACE_RES_ID);
                    waitUntilGone(WORKSPACE_RES_ID);
                    waitUntilGone(APPS_RES_ID);
                    waitUntilGone(APPS_RES_ID);
@@ -528,10 +529,22 @@ public final class LauncherInstrumentation {
        return object;
        return object;
    }
    }


    @NonNull
    UiObject2 waitForFallbackLauncherObject(String resName) {
        final BySelector selector = getFallbackLauncherObjectSelector(resName);
        final UiObject2 object = mDevice.wait(Until.findObject(selector), WAIT_TIME_MS);
        assertNotNull("Can't find a fallback launcher object; selector: " + selector, object);
        return object;
    }

    BySelector getLauncherObjectSelector(String resName) {
    BySelector getLauncherObjectSelector(String resName) {
        return By.res(getLauncherPackageName(), resName);
        return By.res(getLauncherPackageName(), resName);
    }
    }


    BySelector getFallbackLauncherObjectSelector(String resName) {
        return By.res(getOverviewPackageName(), resName);
    }

    String getLauncherPackageName() {
    String getLauncherPackageName() {
        return mDevice.getLauncherPackageName();
        return mDevice.getLauncherPackageName();
    }
    }