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

Unified Diff: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java

Issue 2434473002: refactor waitUntilCriteria out of CallbackHelper (Closed)
Patch Set: nit Created 4 years, 2 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 | « content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CallbackHelper.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java
diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java
index d97e1ef9f72e18d4e5706d6dba25f977cfc05192..9ecb59d72cb87b553459f064e5d561fac393564b 100644
--- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java
+++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java
@@ -4,7 +4,6 @@
package org.chromium.content.browser.test.util;
-
import org.chromium.base.ThreadUtils;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_public.browser.JavaScriptCallback;
@@ -134,8 +133,8 @@ public class TestCallbackHelperContainer {
notifyCalled(jsonResult);
}
};
- webContents.evaluateJavaScriptForTests(code, callback);
mJsonResult = null;
+ webContents.evaluateJavaScriptForTests(code, callback);
}
/**
@@ -157,32 +156,21 @@ public class TestCallbackHelperContainer {
return result;
}
-
- /**
- * Returns a criteria that checks that the evaluation has finished.
- */
- public Criteria getHasValueCriteria() {
- return new Criteria() {
- @Override
- public boolean isSatisfied() {
- return hasValue();
- }
- };
- }
-
/**
* Waits till the JavaScript evaluation finishes and returns true if a value was returned,
* false if it timed-out.
*/
- public boolean waitUntilHasValue(long timeout, TimeUnit timeoutUnits)
+ public boolean waitUntilHasValue(long timeout, TimeUnit unit)
throws InterruptedException, TimeoutException {
- waitUntilCriteria(getHasValueCriteria(), timeout, timeoutUnits);
+ int count = getCallCount();
+ // Reads and writes are atomic for reference variables in java, this is thread safe
+ if (hasValue()) return true;
+ waitForCallback(count, 1, timeout, unit);
return hasValue();
}
public boolean waitUntilHasValue() throws InterruptedException, TimeoutException {
- waitUntilCriteria(getHasValueCriteria());
- return hasValue();
+ return waitUntilHasValue(CallbackHelper.WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
public void notifyCalled(String jsonResult) {
« no previous file with comments | « content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CallbackHelper.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698