mobile/android/base/tests/testOverscroll.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/tests/testOverscroll.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +package org.mozilla.gecko.tests;
     1.5 +
     1.6 +import org.mozilla.gecko.Actions;
     1.7 +import org.mozilla.gecko.PaintedSurface;
     1.8 +
     1.9 +/**
    1.10 + * Basic test to check bounce-back from overscroll.
    1.11 + * - Load the page and verify it draws
    1.12 + * - Drag page downwards by 100 pixels into overscroll, verify it snaps back.
    1.13 + * - Drag page rightwards by 100 pixels into overscroll, verify it snaps back.
    1.14 + */
    1.15 +public class testOverscroll extends PixelTest {
    1.16 +    public void testOverscroll() {
    1.17 +        String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
    1.18 +
    1.19 +        MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
    1.20 +
    1.21 +        blockForGeckoReady();
    1.22 +
    1.23 +        // load page and check we're at 0,0
    1.24 +        loadAndVerifyBoxes(url);
    1.25 +
    1.26 +        // drag page downwards by 100 pixels so that it goes into overscroll.
    1.27 +        // wait for it to bounce back and check we're at the right spot.
    1.28 +        // the screen size is small). Note that since we only go into overscroll
    1.29 +        // and back this should NOT trigger a gecko-paint
    1.30 +        Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
    1.31 +        meh.dragSync(10, 50, 10, 150);
    1.32 +        PaintedSurface painted = waitWithNoPaint(paintExpecter);
    1.33 +        paintExpecter.unregisterListener();
    1.34 +        try {
    1.35 +            checkScrollWithBoxes(painted, 0, 0);
    1.36 +        } finally {
    1.37 +            painted.close();
    1.38 +        }
    1.39 +
    1.40 +        // drag page rightwards to go into overscroll on the left. let it bounce and verify.
    1.41 +        paintExpecter = mActions.expectPaint();
    1.42 +        meh.dragSync(50, 10, 150, 10);
    1.43 +        painted = waitWithNoPaint(paintExpecter);
    1.44 +        paintExpecter.unregisterListener();
    1.45 +        try {
    1.46 +            checkScrollWithBoxes(painted, 0, 0);
    1.47 +        } finally {
    1.48 +            painted.close();
    1.49 +        }
    1.50 +    }
    1.51 +}

mercurial