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

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

Merge "Waiting for wallpaper animation in widget tests only for Nexus Launcher" into main

parents 5aac28a0 c0fc0d2b
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
        runTest(false);
    }


    /**
     * @param acceptConfig accept the config activity
     */
@@ -101,7 +100,7 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
        // Verify that the widget id is valid and bound
        assertNotNull(mAppWidgetManager.getAppWidgetInfo(mWidgetId));

        setResult(acceptConfig);
        setResultAndWaitForAnimation(acceptConfig);
        if (acceptConfig) {
            Wait.atMost("", new WidgetSearchCondition(), DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
            assertNotNull(mAppWidgetManager.getAppWidgetInfo(mWidgetId));
@@ -112,13 +111,21 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
        }
    }

    private void setResult(boolean success) {
        mLauncher.executeAndWaitForWallpaperAnimation(() ->
    private static void setResult(boolean success) {
        getInstrumentation().getTargetContext().sendBroadcast(
                WidgetConfigActivity.getCommandIntent(WidgetConfigActivity.class,
                                        success ? "clickOK" : "clickCancel")),
                        success ? "clickOK" : "clickCancel"));
    }

    private void setResultAndWaitForAnimation(boolean success) {
        if (mLauncher.isLauncher3()) {
            setResult(success);
        } else {
            mLauncher.executeAndWaitForWallpaperAnimation(
                    () -> setResult(success),
                    "setting widget coinfig result");
        }
    }

    /**
     * Condition for searching widget id
+2 −1
Original line number Diff line number Diff line
@@ -2180,7 +2180,8 @@ public final class LauncherInstrumentation {
        };
    }

    boolean isLauncher3() {
    /** Returns whether the Launcher is a Launcher3 one */
    public boolean isLauncher3() {
        if (mIsLauncher3 == null) {
            mIsLauncher3 = "com.android.launcher3".equals(getLauncherPackageName());
        }