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