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

40 lines
1.5 KiB
Java

#filter substitution
package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
import android.app.Instrumentation;
/**
* 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 {
public void testFlingCorrectness() {
setTestType("mochitest");
String url = getAbsoluteUrl("/robocop/robocop_boxes.html");
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
// 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);
checkScrollWithBoxes(painted, 0, 200);
// 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
meh.flingSync(10, 50, 10, 150, 15);
painted = waitForPaint(paintExpecter);
checkScrollWithBoxes(painted, 0, 0);
}
}