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