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

Commit 693466f1 authored by ktanojo's avatar ktanojo
Browse files

Fix SinglePanning tests to be device dependent

Test: atest FullScreenMagnificationGestureHandlerTest
Bug: 293446624
Change-Id: Ia01ba4b10245a61c841a0aae86f6f60d67d362a5
parent 7e9ded60
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.server.testutils.TestUtils.strictMock;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
@@ -43,6 +44,7 @@ import static org.mockito.Mockito.when;

import android.animation.ValueAnimator;
import android.annotation.NonNull;
import android.content.pm.PackageManager;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Region;
@@ -252,7 +254,11 @@ public class FullScreenMagnificationGestureHandlerTest {
                detectTripleTap, detectShortcutTrigger,
                mWindowMagnificationPromptController, DISPLAY_0,
                mMockFullScreenMagnificationVibrationHelper);
        if (isWatch()) {
            h.setSinglePanningEnabled(true);
        } else {
            h.setSinglePanningEnabled(false);
        }
        mHandler = new TestHandler(h.mDetectingState, mClock) {
            @Override
            protected String messageToString(Message m) {
@@ -569,6 +575,7 @@ public class FullScreenMagnificationGestureHandlerTest {

    @Test
    public void testActionUpNotAtEdge_singlePanningState_detectingState() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        goFromStateIdleTo(STATE_SINGLE_PANNING);

        send(upEvent());
@@ -579,6 +586,7 @@ public class FullScreenMagnificationGestureHandlerTest {

    @Test
    public void testScroll_SinglePanningDisabled_delegatingState() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        mMgh.setSinglePanningEnabled(false);

        goFromStateIdleTo(STATE_ACTIVATED);
@@ -591,6 +599,7 @@ public class FullScreenMagnificationGestureHandlerTest {
    @Test
    @FlakyTest
    public void testScroll_singleHorizontalPanningAndAtEdge_leftEdgeOverscroll() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        goFromStateIdleTo(STATE_SINGLE_PANNING);
        float centerY =
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.bottom) / 2.0f;
@@ -614,6 +623,7 @@ public class FullScreenMagnificationGestureHandlerTest {
    @Test
    @FlakyTest
    public void testScroll_singleHorizontalPanningAndAtEdge_rightEdgeOverscroll() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        goFromStateIdleTo(STATE_SINGLE_PANNING);
        float centerY =
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.bottom) / 2.0f;
@@ -637,6 +647,7 @@ public class FullScreenMagnificationGestureHandlerTest {
    @Test
    @FlakyTest
    public void testScroll_singleVerticalPanningAndAtEdge_verticalOverscroll() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        goFromStateIdleTo(STATE_SINGLE_PANNING);
        float centerX =
                (INITIAL_MAGNIFICATION_BOUNDS.right + INITIAL_MAGNIFICATION_BOUNDS.left) / 2.0f;
@@ -658,6 +669,7 @@ public class FullScreenMagnificationGestureHandlerTest {

    @Test
    public void testScroll_singlePanningAndAtEdge_noOverscroll() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        goFromStateIdleTo(STATE_SINGLE_PANNING);
        float centerY =
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.bottom) / 2.0f;
@@ -679,6 +691,7 @@ public class FullScreenMagnificationGestureHandlerTest {

    @Test
    public void testScroll_singleHorizontalPanningAndAtEdge_vibrate() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        goFromStateIdleTo(STATE_SINGLE_PANNING);
        mFullScreenMagnificationController.setCenter(
                DISPLAY_0,
@@ -702,6 +715,7 @@ public class FullScreenMagnificationGestureHandlerTest {

    @Test
    public void testScroll_singleVerticalPanningAndAtEdge_doNotVibrate() {
        assumeTrue(mMgh.mIsSinglePanningEnabled);
        goFromStateIdleTo(STATE_SINGLE_PANNING);
        mFullScreenMagnificationController.setCenter(
                DISPLAY_0,
@@ -868,6 +882,10 @@ public class FullScreenMagnificationGestureHandlerTest {
        mFullScreenMagnificationController.onUserContextChanged(DISPLAY_0);
    }

    private boolean isWatch() {
        return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
    }

    /**
     * Asserts that {@link #mMgh the handler} is in the given {@code state}
     */