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

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

Issue 2573263002: Catch InterruptedException in CriteriaHelper (Closed)
Patch Set: Change OverviewModeBehaviorWatcher back to try/finally Created 4 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
Index: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CriteriaHelper.java
diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CriteriaHelper.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CriteriaHelper.java
index a7f8aaa40f1d2b1456b784bccedd71960b25500b..0213b6980434d7ede56e39dc6c2f3aa284f6e467 100644
--- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CriteriaHelper.java
+++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/CriteriaHelper.java
@@ -64,11 +64,16 @@ public class CriteriaHelper {
* @param checkIntervalMs The number of ms between checks.
*/
public static void pollInstrumentationThread(Criteria criteria, long maxTimeoutMs,
- long checkIntervalMs) throws InterruptedException {
+ long checkIntervalMs) {
boolean isSatisfied = criteria.isSatisfied();
long startTime = SystemClock.uptimeMillis();
while (!isSatisfied && SystemClock.uptimeMillis() - startTime < maxTimeoutMs) {
- Thread.sleep(checkIntervalMs);
+ try {
+ Thread.sleep(checkIntervalMs);
+ } catch (InterruptedException e) {
+ // Catch the InterruptedException. If the exception occurs before maxTimeoutMs
+ // and the criteria is not satisfied, the while loop will run again.
+ }
isSatisfied = criteria.isSatisfied();
}
Assert.assertTrue(criteria.getFailureReason(), isSatisfied);
@@ -85,7 +90,7 @@ public class CriteriaHelper {
*
* @see #pollInstrumentationThread(Criteria, long, long)
*/
- public static void pollInstrumentationThread(Criteria criteria) throws InterruptedException {
+ public static void pollInstrumentationThread(Criteria criteria) {
pollInstrumentationThread(criteria, DEFAULT_MAX_TIME_TO_POLL, DEFAULT_POLLING_INTERVAL);
}
@@ -101,7 +106,7 @@ public class CriteriaHelper {
* @see #pollInstrumentationThread(Criteria)
*/
public static void pollUiThread(final Criteria criteria, long maxTimeoutMs,
- long checkIntervalMs) throws InterruptedException {
+ long checkIntervalMs) {
final Callable<Boolean> callable = new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
@@ -129,7 +134,7 @@ public class CriteriaHelper {
*
* @see #pollInstrumentationThread(Criteria)
*/
- public static void pollUiThread(final Criteria criteria) throws InterruptedException {
+ public static void pollUiThread(final Criteria criteria) {
pollUiThread(criteria, DEFAULT_MAX_TIME_TO_POLL, DEFAULT_POLLING_INTERVAL);
}
}

Powered by Google App Engine
This is Rietveld 408576698