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

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

Issue 2487683003: Convert InfoBarTestAnimationListener to CallbackHelper. (Closed)
Patch Set: Created 4 years, 1 month 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/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarContainerTest.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 4eed3c0ca97a5e5c32fc819e103eb685ad73e75a..81476f5815f82881e7c423710bc29a4e5f1fb358 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
@@ -159,6 +159,7 @@ public class CallbackHelper {
* call count was obtained but before the method was called, otherwise the method will
* block until the specified call count is reached.
*
+ * @param msg The error message to use if the callback times out.
* @param currentCallCount the value obtained by calling getCallCount().
* @param numberOfCallsToWaitFor number of calls (counting since
* currentCallCount was obtained) that we will wait for.
@@ -169,8 +170,8 @@ public class CallbackHelper {
* @throws InterruptedException
* @throws TimeoutException Thrown if the method times out before onPageFinished is called.
*/
- public void waitForCallback(int currentCallCount, int numberOfCallsToWaitFor, long timeout,
- TimeUnit unit) throws InterruptedException, TimeoutException {
+ public void waitForCallback(String msg, int currentCallCount, int numberOfCallsToWaitFor,
+ long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
assert mCallCount >= currentCallCount;
assert numberOfCallsToWaitFor > 0;
synchronized (mLock) {
@@ -179,21 +180,43 @@ public class CallbackHelper {
int callCountBeforeWait = mCallCount;
mLock.wait(unit.toMillis(timeout));
if (callCountBeforeWait == mCallCount) {
- throw new TimeoutException("waitForCallback timed out!");
+ throw new TimeoutException(msg == null ? "waitForCallback timed out!" : msg);
}
}
}
}
+ /**
+ * @see #waitForCallback(String, int, int, long, TimeUnit)
+ */
+ public void waitForCallback(int currentCallCount, int numberOfCallsToWaitFor, long timeout,
+ TimeUnit unit) throws InterruptedException, TimeoutException {
+ waitForCallback(null, currentCallCount, numberOfCallsToWaitFor, timeout, unit);
+ }
+
+ /**
+ * @see #waitForCallback(String, int, int, long, TimeUnit)
+ */
public void waitForCallback(int currentCallCount, int numberOfCallsToWaitFor)
jbudorick 2016/11/08 18:41:44 I guess we'll add waitForCallback(String, int, int
throws InterruptedException, TimeoutException {
- waitForCallback(currentCallCount, numberOfCallsToWaitFor,
+ waitForCallback(null, currentCallCount, numberOfCallsToWaitFor,
WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
+ /**
+ * @see #waitForCallback(String, int, int, long, TimeUnit)
+ */
+ public void waitForCallback(String msg, int currentCallCount)
+ throws InterruptedException, TimeoutException {
+ waitForCallback(msg, currentCallCount, 1, WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ }
+
+ /**
+ * @see #waitForCallback(String, int, int, long, TimeUnit)
+ */
public void waitForCallback(int currentCallCount)
throws InterruptedException, TimeoutException {
- waitForCallback(currentCallCount, 1);
+ waitForCallback(null, currentCallCount, 1, WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
/**
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarContainerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698