michael@0: package org.mozilla.gecko.tests; michael@0: michael@0: import org.mozilla.gecko.Actions; michael@0: import org.mozilla.gecko.PaintedSurface; michael@0: michael@0: /** michael@0: * Basic test for axis locking behaviour. michael@0: * - Load page and verify it draws michael@0: * - Drag page upwards 100 pixels at a 5-degree angle off the vertical axis michael@0: * - Verify that the 5-degree angle was thrown out and it dragged vertically michael@0: * - Drag page upwards at a 45-degree angle michael@0: * - Verify that the 45-degree angle was not thrown out and it dragged diagonally michael@0: */ michael@0: public class testAxisLocking extends PixelTest { michael@0: public void testAxisLocking() { michael@0: String url = getAbsoluteUrl("/robocop/robocop_boxes.html"); michael@0: michael@0: MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop()); michael@0: michael@0: blockForGeckoReady(); michael@0: michael@0: // load page and check we're at 0,0 michael@0: loadAndVerifyBoxes(url); michael@0: michael@0: // drag page upwards by 100 pixels with a slight angle. verify that michael@0: // axis locking prevents any horizontal scrolling michael@0: Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint(); michael@0: meh.dragSync(20, 150, 10, 50); michael@0: PaintedSurface painted = waitForPaint(paintExpecter); michael@0: paintExpecter.unregisterListener(); michael@0: try { michael@0: checkScrollWithBoxes(painted, 0, 100); michael@0: // since checkScrollWithBoxes only checks 4 points, it may not pick up a michael@0: // sub-100 pixel horizontal shift. so we check another point manually to make sure. michael@0: int[] color = getBoxColorAt(0, 100); michael@0: mAsserter.ispixel(painted.getPixelAt(99, 0), color[0], color[1], color[2], "Pixel at 99, 0 indicates no horizontal scroll"); michael@0: michael@0: // now drag at a 45-degree angle to ensure we break the axis lock, and michael@0: // verify that we have both horizontal and vertical scrolling michael@0: paintExpecter = mActions.expectPaint(); michael@0: meh.dragSync(150, 150, 50, 50); michael@0: } finally { michael@0: painted.close(); michael@0: } michael@0: michael@0: painted = waitForPaint(paintExpecter); michael@0: paintExpecter.unregisterListener(); michael@0: try { michael@0: checkScrollWithBoxes(painted, 100, 200); michael@0: } finally { michael@0: painted.close(); michael@0: } michael@0: } michael@0: }