gecko/mobile/android/base/tests/testFlingCorrectness.java.in

54 lines
1.7 KiB
Java
Raw Normal View History

#filter substitution
package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
/**
* 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 {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testFlingCorrectness() {
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
blockForGeckoReady();
// 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);
PaintedSurface painted = waitForPaint(paintExpecter);
paintExpecter.unregisterListener();
try {
checkScrollWithBoxes(painted, 0, 200);
} finally {
painted.close();
}
// 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
paintExpecter = mActions.expectPaint();
meh.flingSync(10, 50, 10, 150, 15);
painted = waitForPaint(paintExpecter);
paintExpecter.unregisterListener();
try {
checkScrollWithBoxes(painted, 0, 0);
} finally {
painted.close();
}
}
}