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

Commit 00308342 authored by vadimt's avatar vadimt
Browse files

Temporary hacks to make tests pass on Taimen

Change-Id: I66a81a0407be13c15596c63f21773f8e2dea5d2d
parent a3c0a082
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -114,7 +114,8 @@ public class TestViewHelpers {
        Point center = icon.getVisibleCenter();

        // Action Down
        sendPointer(MotionEvent.ACTION_DOWN, center);
        final long downTime = SystemClock.uptimeMillis();
        sendPointer(downTime, MotionEvent.ACTION_DOWN, center);

        UiObject2 dragLayer = findViewById(R.id.drag_layer);

@@ -131,7 +132,7 @@ public class TestViewHelpers {
            } else {
                moveLocation.y += distanceToMove;
            }
            movePointer(center, moveLocation);
            movePointer(downTime, center, moveLocation);

            assertNull(findViewById(R.id.deep_shortcuts_container));
        }
@@ -142,19 +143,24 @@ public class TestViewHelpers {
        Point moveLocation = dragLayer.getVisibleCenter();

        // Move to center
        movePointer(center, moveLocation);
        sendPointer(MotionEvent.ACTION_UP, center);
        movePointer(downTime, center, moveLocation);
        sendPointer(downTime, MotionEvent.ACTION_UP, moveLocation);

        // Wait until remove target is gone.
        getDevice().wait(Until.gone(getSelectorForId(R.id.delete_target_text)),
                AbstractLauncherUiTest.DEFAULT_UI_TIMEOUT);
    }

    private static void movePointer(Point from, Point to) {
    private static void movePointer(long downTime, Point from, Point to) {
        while (!from.equals(to)) {
            try {
                Thread.sleep(20);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            from.x = getNextMoveValue(to.x, from.x);
            from.y = getNextMoveValue(to.y, from.y);
            sendPointer(MotionEvent.ACTION_MOVE, from);
            sendPointer(downTime, MotionEvent.ACTION_MOVE, from);
        }
    }

@@ -168,8 +174,8 @@ public class TestViewHelpers {
        }
    }

    public static void sendPointer(int action, Point point) {
        MotionEvent event = MotionEvent.obtain(SystemClock.uptimeMillis(),
    public static void sendPointer(long downTime, int action, Point point) {
        MotionEvent event = MotionEvent.obtain(downTime,
                SystemClock.uptimeMillis(), action, point.x, point.y, 0);
        getInstrumentation().sendPointerSync(event);
        event.recycle();
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
                final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
                allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height() + 1);
            } else {
                allAppsContainer.setGestureMargins(0, 0, 0, 100);
                allAppsContainer.setGestureMargins(0, 0, 0, 200);
            }
            final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
            if (!hasClickableIcon(allAppsContainer, appIconSelector)) {
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
                "want to fling forward in widgets")) {
            LauncherInstrumentation.log("Widgets.flingForward enter");
            final UiObject2 widgetsContainer = verifyActiveContainer();
            widgetsContainer.setGestureMargin(100);
            widgetsContainer.setGestureMargins(0, 0, 0, 200);
            widgetsContainer.fling(Direction.DOWN,
                    (int) (FLING_SPEED * mLauncher.getDisplayDensity()));
            try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) {