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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/GeolocationTest.java

Issue 131743020: [android_webivew] Refactor polling checks in test code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
Index: android_webview/javatests/src/org/chromium/android_webview/test/GeolocationTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/GeolocationTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/GeolocationTest.java
index fc9752771ab61af82ff60deed423ac52e5c45535..06d13b5d7afe3143eba53172e990aac3015c581b 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/GeolocationTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/GeolocationTest.java
@@ -10,20 +10,16 @@ import android.webkit.GeolocationPermissions;
import org.chromium.android_webview.AwContents;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.LocationProviderFactory;
-import org.chromium.content.browser.test.util.Criteria;
-import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.MockLocationProvider;
+import java.util.concurrent.Callable;
+
/**
* Test suite for Geolocation in AwContents. Smoke tests for
* basic functionality, and tests to ensure the AwContents.onPause
* and onResume APIs affect Geolocation as expected.
*/
public class GeolocationTest extends AwTestBase {
-
- private static final long TEST_TIMEOUT_MS = 5000L;
- private static final int CHECK_INTERVAL_MS = 100;
-
private TestAwContentsClient mContentsClient;
private AwContents mAwContents;
private MockLocationProvider mMockLocationProvider;
@@ -97,12 +93,12 @@ public class GeolocationTest extends AwTestBase {
}
private void ensureGeolocationRunning(final boolean running) throws Exception {
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ poll(new Callable<Boolean>() {
@Override
- public boolean isSatisfied() {
+ public Boolean call() throws Exception {
return mMockLocationProvider.isRunning() == running;
}
- }, TEST_TIMEOUT_MS, CHECK_INTERVAL_MS));
+ });
}
@@ -117,20 +113,20 @@ public class GeolocationTest extends AwTestBase {
mAwContents.evaluateJavaScript("initiate_getCurrentPosition();", null);
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ poll(new Callable<Boolean>() {
@Override
- public boolean isSatisfied() {
+ public Boolean call() throws Exception {
return getPositionCountFromJS() == 1;
}
- }, TEST_TIMEOUT_MS, CHECK_INTERVAL_MS));
+ });
mAwContents.evaluateJavaScript("initiate_getCurrentPosition();", null);
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ poll(new Callable<Boolean>() {
@Override
- public boolean isSatisfied() {
+ public Boolean call() throws Exception {
return getPositionCountFromJS() == 2;
}
- }, TEST_TIMEOUT_MS, CHECK_INTERVAL_MS));
+ });
}
/**
@@ -144,12 +140,12 @@ public class GeolocationTest extends AwTestBase {
mAwContents.evaluateJavaScript("initiate_watchPosition();", null);
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ poll(new Callable<Boolean>() {
@Override
- public boolean isSatisfied() {
+ public Boolean call() throws Exception {
return getPositionCountFromJS() > 1;
}
- }, TEST_TIMEOUT_MS, CHECK_INTERVAL_MS));
+ });
}
@MediumTest
@@ -161,12 +157,12 @@ public class GeolocationTest extends AwTestBase {
mAwContents.evaluateJavaScript("initiate_watchPosition();", null);
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ poll(new Callable<Boolean>() {
@Override
- public boolean isSatisfied() {
+ public Boolean call() throws Exception {
return getPositionCountFromJS() > 1;
}
- }, TEST_TIMEOUT_MS, CHECK_INTERVAL_MS));
+ });
ensureGeolocationRunning(true);
@@ -195,12 +191,12 @@ public class GeolocationTest extends AwTestBase {
ensureGeolocationRunning(true);
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ poll(new Callable<Boolean>() {
@Override
- public boolean isSatisfied() {
+ public Boolean call() throws Exception {
return getPositionCountFromJS() > 1;
}
- }, TEST_TIMEOUT_MS, CHECK_INTERVAL_MS));
+ });
}
@MediumTest
@@ -232,13 +228,12 @@ public class GeolocationTest extends AwTestBase {
ensureGeolocationRunning(true);
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ poll(new Callable<Boolean>() {
@Override
- public boolean isSatisfied() {
+ public Boolean call() throws Exception {
return getPositionCountFromJS() > 1;
}
- }, TEST_TIMEOUT_MS, CHECK_INTERVAL_MS));
-
+ });
}
@MediumTest

Powered by Google App Engine
This is Rietveld 408576698