Deflake WebViewTest#testPageScroll
The test was flaky because it checks every 50ms after calling
pageUp(true) or pageDown(true). The page scroll offset on UI thread may
not change with 50ms.
Instead, a polling check for the new scroll offset is in place, until
the polling check times out.
BUG:crbug.com/534643
Change-Id: I25f9806b24b3f17a85fc5f5e43e2296a1793d38a
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 494cdef..a79e5ba 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -1625,7 +1625,7 @@
} while (mOnUiThread.pageDown(false));
waitForFlingDone(mOnUiThread);
- int bottomScrollY = mOnUiThread.getScrollY();
+ final int bottomScrollY = mOnUiThread.getScrollY();
assertTrue(mOnUiThread.pageUp(false));
@@ -1634,17 +1634,25 @@
} while (mOnUiThread.pageUp(false));
waitForFlingDone(mOnUiThread);
- int topScrollY = mOnUiThread.getScrollY();
+ final int topScrollY = mOnUiThread.getScrollY();
// jump to the bottom
assertTrue(mOnUiThread.pageDown(true));
- waitForFlingDone(mOnUiThread);
- assertEquals(bottomScrollY, mOnUiThread.getScrollY());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return bottomScrollY == mOnUiThread.getScrollY();
+ }
+ }.run();
// jump to the top
assertTrue(mOnUiThread.pageUp(true));
- waitForFlingDone(mOnUiThread);
- assertEquals(topScrollY, mOnUiThread.getScrollY());
+ new PollingCheck() {
+ @Override
+ protected boolean check() {
+ return topScrollY == mOnUiThread.getScrollY();
+ }
+ }.run();
}
public void testGetContentHeight() throws Throwable {