diff -r 000000000000 -r 6474c204b198 mobile/android/base/tests/testFlingCorrectness.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mobile/android/base/tests/testFlingCorrectness.java Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,48 @@ +package org.mozilla.gecko.tests; + +import org.mozilla.gecko.Actions; +import org.mozilla.gecko.PaintedSurface; + +/** + * Basic fling correctness test. + * - Loads a page and verifies it draws + * - Drags page upwards by 200 pixels to get ready for a fling + * - Fling the page downwards so we get back to the top and verify. + */ +public class testFlingCorrectness extends PixelTest { + public void testFlingCorrectness() { + String url = getAbsoluteUrl("/robocop/robocop_boxes.html"); + + MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop()); + + blockForGeckoReady(); + + // load page and check we're at 0,0 + loadAndVerifyBoxes(url); + + // drag page upwards by 200 pixels (use two drags instead of one in case + // the screen size is small) + Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint(); + meh.dragSync(10, 150, 10, 50); + meh.dragSync(10, 150, 10, 50); + PaintedSurface painted = waitForPaint(paintExpecter); + paintExpecter.unregisterListener(); + try { + checkScrollWithBoxes(painted, 0, 200); + } finally { + painted.close(); + } + + // now fling page downwards using a 100-pixel drag but a velocity of 15px/sec, so that + // we scroll the full 200 pixels back to the top of the page + paintExpecter = mActions.expectPaint(); + meh.flingSync(10, 50, 10, 150, 15); + painted = waitForPaint(paintExpecter); + paintExpecter.unregisterListener(); + try { + checkScrollWithBoxes(painted, 0, 0); + } finally { + painted.close(); + } + } +}