|
1 package org.mozilla.gecko.tests; |
|
2 |
|
3 import org.mozilla.gecko.Actions; |
|
4 import org.mozilla.gecko.PaintedSurface; |
|
5 |
|
6 /** |
|
7 * Basic test for axis locking behaviour. |
|
8 * - Load page and verify it draws |
|
9 * - Drag page upwards 100 pixels at a 5-degree angle off the vertical axis |
|
10 * - Verify that the 5-degree angle was thrown out and it dragged vertically |
|
11 * - Drag page upwards at a 45-degree angle |
|
12 * - Verify that the 45-degree angle was not thrown out and it dragged diagonally |
|
13 */ |
|
14 public class testAxisLocking extends PixelTest { |
|
15 public void testAxisLocking() { |
|
16 String url = getAbsoluteUrl("/robocop/robocop_boxes.html"); |
|
17 |
|
18 MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop()); |
|
19 |
|
20 blockForGeckoReady(); |
|
21 |
|
22 // load page and check we're at 0,0 |
|
23 loadAndVerifyBoxes(url); |
|
24 |
|
25 // drag page upwards by 100 pixels with a slight angle. verify that |
|
26 // axis locking prevents any horizontal scrolling |
|
27 Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint(); |
|
28 meh.dragSync(20, 150, 10, 50); |
|
29 PaintedSurface painted = waitForPaint(paintExpecter); |
|
30 paintExpecter.unregisterListener(); |
|
31 try { |
|
32 checkScrollWithBoxes(painted, 0, 100); |
|
33 // since checkScrollWithBoxes only checks 4 points, it may not pick up a |
|
34 // sub-100 pixel horizontal shift. so we check another point manually to make sure. |
|
35 int[] color = getBoxColorAt(0, 100); |
|
36 mAsserter.ispixel(painted.getPixelAt(99, 0), color[0], color[1], color[2], "Pixel at 99, 0 indicates no horizontal scroll"); |
|
37 |
|
38 // now drag at a 45-degree angle to ensure we break the axis lock, and |
|
39 // verify that we have both horizontal and vertical scrolling |
|
40 paintExpecter = mActions.expectPaint(); |
|
41 meh.dragSync(150, 150, 50, 50); |
|
42 } finally { |
|
43 painted.close(); |
|
44 } |
|
45 |
|
46 painted = waitForPaint(paintExpecter); |
|
47 paintExpecter.unregisterListener(); |
|
48 try { |
|
49 checkScrollWithBoxes(painted, 100, 200); |
|
50 } finally { |
|
51 painted.close(); |
|
52 } |
|
53 } |
|
54 } |