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

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

Issue 11280250: Add waitUntilHasValue() to simplify usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase.. Created 8 years 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/JavaScriptUtils.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 f7bd45470395a7b69760ed82f50224b61bd7f102..841787a372dcfbb371fe9cf404386bfbcc1773f8 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
@@ -10,6 +10,9 @@ import android.util.Log;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewCore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
/**
* This class is used to provide callback hooks for tests and related classes.
*/
@@ -110,11 +113,37 @@ 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.
+ */
+ public void waitUntilHasValue(long timeout, TimeUnit timeoutUnits)
+ throws InterruptedException, TimeoutException {
+ waitUntilCriteria(getHasValueCriteria(), timeout, timeoutUnits);
+ }
+
+ public void waitUntilHasValue() throws InterruptedException, TimeoutException {
+ waitUntilCriteria(getHasValueCriteria());
+ }
+
private void setRequestId(Integer requestId) {
mRequestId = requestId;
mId = null;
mJsonResult = null;
}
+
public void notifyCalled(int id, String jsonResult) {
if (mRequestId == null) {
Log.w("TestCallbackHelperContainer",
« no previous file with comments | « content/public/test/android/javatests/src/org/chromium/content/browser/test/util/JavaScriptUtils.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698