Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2268)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java

Issue 131743020: [android_webivew] Refactor polling checks in test code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldOverrideUrlLoadingTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java
index 8df51eb378d3f087fff228c8b4aee80fe619c77e..0634f59d478a12900ec5b616744681d9d1496b58 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java
@@ -15,8 +15,6 @@ import org.chromium.android_webview.test.util.JavascriptEventObserver;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.CallbackHelper;
-import org.chromium.content.browser.test.util.Criteria;
-import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.ui.gfx.DeviceDisplayInfo;
import java.util.concurrent.Callable;
@@ -193,43 +191,31 @@ public class AndroidScrollIntegrationTest extends AwTestBase {
private void assertScrollInJs(final AwContents awContents,
final TestAwContentsClient contentsClient,
final int xCss, final int yCss) throws Exception {
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
- @Override
- public boolean isSatisfied() {
- try {
- String x = executeJavaScriptAndWaitForResult(awContents, contentsClient,
- "window.scrollX");
- String y = executeJavaScriptAndWaitForResult(awContents, contentsClient,
- "window.scrollY");
- return (Integer.toString(xCss).equals(x) &&
- Integer.toString(yCss).equals(y));
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Failed to get window.scroll(X/Y): " + t.toString());
- return false;
- }
- }
- }, WAIT_TIMEOUT_MS, CHECK_INTERVAL));
+ poll(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ String x = executeJavaScriptAndWaitForResult(awContents, contentsClient,
+ "window.scrollX");
+ String y = executeJavaScriptAndWaitForResult(awContents, contentsClient,
+ "window.scrollY");
+ return (Integer.toString(xCss).equals(x) &&
+ Integer.toString(yCss).equals(y));
+ }
+ });
}
private void assertScrolledToBottomInJs(final AwContents awContents,
final TestAwContentsClient contentsClient) throws Exception {
final String isBottomScript = "window.scrollY == " +
"(window.document.documentElement.scrollHeight - window.innerHeight)";
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
- @Override
- public boolean isSatisfied() {
- try {
- String r = executeJavaScriptAndWaitForResult(awContents, contentsClient,
- isBottomScript);
- return r.equals("true");
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Failed to get window.scroll(X/Y): " + t.toString());
- return false;
- }
- }
- }, WAIT_TIMEOUT_MS, CHECK_INTERVAL));
+ poll(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ String r = executeJavaScriptAndWaitForResult(awContents, contentsClient,
+ isBottomScript);
+ return r.equals("true");
+ }
+ });
}
private void loadTestPageAndWaitForFirstFrame(final ScrollTestContainerView testContainerView,
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldOverrideUrlLoadingTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698