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

Commit 9c524db4 authored by vadimt's avatar vadimt Committed by android-build-merger
Browse files

Reenabling some widget tests

am: 599b1fc4

Change-Id: I9d00e745ea026a796a0edd1c3c65d057349098ad
parents 627e0aef 599b1fc4
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -70,14 +70,12 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {


    @Test
    @Test
    @PortraitLandscape
    @PortraitLandscape
    @Ignore
    public void testWidgetConfig() throws Throwable {
    public void testWidgetConfig() throws Throwable {
        runTest(true);
        runTest(true);
    }
    }


    @Test
    @Test
    @PortraitLandscape
    @PortraitLandscape
    @Ignore
    public void testConfigCancelled() throws Throwable {
    public void testConfigCancelled() throws Throwable {
        runTest(false);
        runTest(false);
    }
    }
+0 −1
Original line number Original line Diff line number Diff line
@@ -42,7 +42,6 @@ public class AddWidgetTest extends AbstractLauncherUiTest {


    @Test
    @Test
    @PortraitLandscape
    @PortraitLandscape
    @Ignore
    public void testDragIcon() throws Throwable {
    public void testDragIcon() throws Throwable {
        clearHomescreen();
        clearHomescreen();
        mDevice.pressHome();
        mDevice.pressHome();
+1 −1
Original line number Original line Diff line number Diff line
@@ -368,7 +368,7 @@ public final class LauncherInstrumentation {
        }
        }
    }
    }


    private void assertEquals(String message, String expected, String actual) {
    void assertEquals(String message, String expected, String actual) {
        if (!TextUtils.equals(expected, actual)) {
        if (!TextUtils.equals(expected, actual)) {
            fail(message + " expected: '" + expected + "' but was: '" + actual + "'");
            fail(message + " expected: '" + expected + "' but was: '" + actual + "'");
        }
        }
+15 −8
Original line number Original line Diff line number Diff line
@@ -77,7 +77,7 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
        return LauncherInstrumentation.ContainerType.WIDGETS;
        return LauncherInstrumentation.ContainerType.WIDGETS;
    }
    }


    public Widget getWidget(String label) {
    public Widget getWidget(String labelText) {
        final int margin = ResourceUtils.getNavbarSize(
        final int margin = ResourceUtils.getNavbarSize(
                ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1;
                ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1;
        final UiObject2 widgetsContainer = verifyActiveContainer();
        final UiObject2 widgetsContainer = verifyActiveContainer();
@@ -86,17 +86,24 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
        final Point displaySize = mLauncher.getRealDisplaySize();
        final Point displaySize = mLauncher.getRealDisplaySize();


        int i = 0;
        int i = 0;
        final BySelector selector = By.
        final BySelector selector = By.clazz("android.widget.TextView").text(labelText);
                clazz("com.android.launcher3.widget.WidgetCell").
                hasDescendant(By.text(label));


        for (; ; ) {
        for (; ; ) {
            final UiObject2 widget = mLauncher.tryWaitForLauncherObject(selector, 300);
            final UiObject2 label = mLauncher.tryWaitForLauncherObject(selector, 300);
            if (widget != null && widget.getVisibleBounds().bottom <= displaySize.y - margin) {
            if (label != null) {
                final UiObject2 widget = label.getParent().getParent();
                mLauncher.assertEquals(
                        "View is not WidgetCell",
                        "com.android.launcher3.widget.WidgetCell",
                        widget.getClassName());

                if (widget.getVisibleBounds().bottom <= displaySize.y - margin) {
                    return new Widget(mLauncher, widget);
                    return new Widget(mLauncher, widget);
                }
                }
            }

            if (++i > 40) fail("Too many attempts");
            if (++i > 40) fail("Too many attempts");
            mLauncher.scroll(widgetsContainer, Direction.DOWN, 1f, MARGINS, 50);
            mLauncher.scroll(widgetsContainer, Direction.DOWN, 0.8f, MARGINS, 50);
        }
        }
    }
    }
}
}