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

Unified Diff: base/test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java

Issue 2859053004: [Android] Tweak ChromeTabUtils.waitForTabPageLoaded loading state logic. (Closed)
Patch Set: typos & copy edits Created 3 years, 7 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 | chrome/test/android/javatests/src/org/chromium/chrome/test/util/ChromeTabUtils.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java
diff --git a/base/test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java b/base/test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java
index 37bafb72ae70a6357d23aa422acbd8a396f5987a..bf064c4fce9e6660ea27350eb6d824705935cbab 100644
--- a/base/test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java
+++ b/base/test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java
@@ -6,6 +6,8 @@ package org.chromium.base.test.util;
import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
+import org.junit.Assert;
+
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -128,6 +130,7 @@ public class CallbackHelper {
private final Object mLock = new Object();
private int mCallCount;
+ private String mFailureString;
/**
* Gets the number of times the callback has been called.
@@ -179,6 +182,11 @@ public class CallbackHelper {
while (callCountWhenDoneWaiting > mCallCount) {
int callCountBeforeWait = mCallCount;
mLock.wait(unit.toMillis(timeout));
+ if (mFailureString != null) {
+ String s = mFailureString;
+ mFailureString = null;
+ Assert.fail(s);
+ }
if (callCountBeforeWait == mCallCount) {
throw new TimeoutException(msg == null ? "waitForCallback timed out!" : msg);
}
@@ -228,4 +236,17 @@ public class CallbackHelper {
mLock.notifyAll();
}
}
+
+ /**
+ * Should be called when the callback associated with this helper object wants to
+ * indicate a failure.
+ *
+ * @param s The failure message.
+ */
+ public void notifyFailed(String s) {
+ synchronized (mLock) {
+ mFailureString = s;
+ mLock.notifyAll();
+ }
+ }
}
« no previous file with comments | « no previous file | chrome/test/android/javatests/src/org/chromium/chrome/test/util/ChromeTabUtils.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698