2013-11-07 16:18:51 +00:00
|
|
|
package org.mozilla.gecko.tests;
|
2012-02-07 19:11:00 +00:00
|
|
|
|
2013-11-07 16:18:51 +00:00
|
|
|
import org.mozilla.gecko.*;
|
2012-02-07 19:11:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Basic fling correctness test.
|
|
|
|
* - Loads a page and verifies it draws
|
|
|
|
* - Drags page upwards by 200 pixels to get ready for a fling
|
|
|
|
* - Fling the page downwards so we get back to the top and verify.
|
|
|
|
*/
|
|
|
|
public class testFlingCorrectness extends PixelTest {
|
2012-06-27 23:56:49 +00:00
|
|
|
@Override
|
|
|
|
protected int getTestType() {
|
|
|
|
return TEST_MOCHITEST;
|
|
|
|
}
|
|
|
|
|
2012-02-07 19:11:00 +00:00
|
|
|
public void testFlingCorrectness() {
|
|
|
|
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
|
|
|
|
|
|
|
|
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
|
|
|
|
|
2012-10-25 19:37:39 +00:00
|
|
|
blockForGeckoReady();
|
2012-02-10 14:44:06 +00:00
|
|
|
|
2012-02-07 19:11:00 +00:00
|
|
|
// load page and check we're at 0,0
|
|
|
|
loadAndVerifyBoxes(url);
|
|
|
|
|
|
|
|
// drag page upwards by 200 pixels (use two drags instead of one in case
|
|
|
|
// the screen size is small)
|
|
|
|
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
|
|
|
meh.dragSync(10, 150, 10, 50);
|
|
|
|
meh.dragSync(10, 150, 10, 50);
|
2012-03-06 20:08:45 +00:00
|
|
|
PaintedSurface painted = waitForPaint(paintExpecter);
|
2013-04-19 03:18:09 +00:00
|
|
|
paintExpecter.unregisterListener();
|
2012-08-27 17:44:58 +00:00
|
|
|
try {
|
|
|
|
checkScrollWithBoxes(painted, 0, 200);
|
|
|
|
} finally {
|
|
|
|
painted.close();
|
|
|
|
}
|
2012-02-07 19:11:00 +00:00
|
|
|
|
|
|
|
// now fling page downwards using a 100-pixel drag but a velocity of 15px/sec, so that
|
|
|
|
// we scroll the full 200 pixels back to the top of the page
|
2013-04-19 03:18:09 +00:00
|
|
|
paintExpecter = mActions.expectPaint();
|
2012-02-07 19:11:00 +00:00
|
|
|
meh.flingSync(10, 50, 10, 150, 15);
|
|
|
|
painted = waitForPaint(paintExpecter);
|
2013-04-19 03:18:09 +00:00
|
|
|
paintExpecter.unregisterListener();
|
2012-08-27 17:44:58 +00:00
|
|
|
try {
|
|
|
|
checkScrollWithBoxes(painted, 0, 0);
|
|
|
|
} finally {
|
|
|
|
painted.close();
|
|
|
|
}
|
2012-02-07 19:11:00 +00:00
|
|
|
}
|
|
|
|
}
|