1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/base/tests/testFlingCorrectness.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 fling correctness test. 1.11 + * - Loads a page and verifies it draws 1.12 + * - Drags page upwards by 200 pixels to get ready for a fling 1.13 + * - Fling the page downwards so we get back to the top and verify. 1.14 + */ 1.15 +public class testFlingCorrectness extends PixelTest { 1.16 + public void testFlingCorrectness() { 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 upwards by 200 pixels (use two drags instead of one in case 1.27 + // the screen size is small) 1.28 + Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint(); 1.29 + meh.dragSync(10, 150, 10, 50); 1.30 + meh.dragSync(10, 150, 10, 50); 1.31 + PaintedSurface painted = waitForPaint(paintExpecter); 1.32 + paintExpecter.unregisterListener(); 1.33 + try { 1.34 + checkScrollWithBoxes(painted, 0, 200); 1.35 + } finally { 1.36 + painted.close(); 1.37 + } 1.38 + 1.39 + // now fling page downwards using a 100-pixel drag but a velocity of 15px/sec, so that 1.40 + // we scroll the full 200 pixels back to the top of the page 1.41 + paintExpecter = mActions.expectPaint(); 1.42 + meh.flingSync(10, 50, 10, 150, 15); 1.43 + painted = waitForPaint(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 +}