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

Commit c0fc0d2b authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Waiting for wallpaper animation in widget tests only for Nexus Launcher

Bug: 313926097
Flag: N/A
Test: presubmit
Change-Id: I6235b2ffc66db9f32ce998523cad74bb239588d0
parent 42476cc3
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
@@ -2188,7 +2188,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());
        }