mobile/android/base/tests/testFlingCorrectness.java

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 package org.mozilla.gecko.tests;
michael@0 2
michael@0 3 import org.mozilla.gecko.Actions;
michael@0 4 import org.mozilla.gecko.PaintedSurface;
michael@0 5
michael@0 6 /**
michael@0 7 * Basic fling correctness test.
michael@0 8 * - Loads a page and verifies it draws
michael@0 9 * - Drags page upwards by 200 pixels to get ready for a fling
michael@0 10 * - Fling the page downwards so we get back to the top and verify.
michael@0 11 */
michael@0 12 public class testFlingCorrectness extends PixelTest {
michael@0 13 public void testFlingCorrectness() {
michael@0 14 String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
michael@0 15
michael@0 16 MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
michael@0 17
michael@0 18 blockForGeckoReady();
michael@0 19
michael@0 20 // load page and check we're at 0,0
michael@0 21 loadAndVerifyBoxes(url);
michael@0 22
michael@0 23 // drag page upwards by 200 pixels (use two drags instead of one in case
michael@0 24 // the screen size is small)
michael@0 25 Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
michael@0 26 meh.dragSync(10, 150, 10, 50);
michael@0 27 meh.dragSync(10, 150, 10, 50);
michael@0 28 PaintedSurface painted = waitForPaint(paintExpecter);
michael@0 29 paintExpecter.unregisterListener();
michael@0 30 try {
michael@0 31 checkScrollWithBoxes(painted, 0, 200);
michael@0 32 } finally {
michael@0 33 painted.close();
michael@0 34 }
michael@0 35
michael@0 36 // now fling page downwards using a 100-pixel drag but a velocity of 15px/sec, so that
michael@0 37 // we scroll the full 200 pixels back to the top of the page
michael@0 38 paintExpecter = mActions.expectPaint();
michael@0 39 meh.flingSync(10, 50, 10, 150, 15);
michael@0 40 painted = waitForPaint(paintExpecter);
michael@0 41 paintExpecter.unregisterListener();
michael@0 42 try {
michael@0 43 checkScrollWithBoxes(painted, 0, 0);
michael@0 44 } finally {
michael@0 45 painted.close();
michael@0 46 }
michael@0 47 }
michael@0 48 }

mercurial