Index: android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java |
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java |
index ea099993d6d572ee8402da0c1d9504928c20fa3c..18cde687786914e7475f42e5f06f1eca475d6d7c 100644 |
--- a/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java |
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java |
@@ -13,8 +13,6 @@ import org.chromium.android_webview.AwContents; |
import org.chromium.android_webview.AwCookieManager; |
import org.chromium.android_webview.test.util.JSUtils; |
import org.chromium.base.test.util.Feature; |
-import org.chromium.content.browser.test.util.Criteria; |
-import org.chromium.content.browser.test.util.CriteriaHelper; |
import org.chromium.net.test.util.TestWebServer; |
import java.util.ArrayList; |
@@ -23,6 +21,7 @@ import java.util.Date; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
+import java.util.concurrent.Callable; |
/** |
* Tests for the CookieManager. |
@@ -122,13 +121,13 @@ public class CookieManagerTest extends AwTestBase { |
"; expires=' + expirationDate.toUTCString();"); |
} |
- private void waitForCookie(final String url) throws InterruptedException { |
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
+ private void waitForCookie(final String url) throws Exception { |
+ poll(new Callable<Boolean>() { |
@Override |
- public boolean isSatisfied() { |
+ public Boolean call() throws Exception { |
return mCookieManager.getCookie(url) != null; |
} |
- })); |
+ }); |
} |
private void validateCookies(String responseCookie, String... expectedCookieNames) { |
@@ -143,7 +142,7 @@ public class CookieManagerTest extends AwTestBase { |
@MediumTest |
@Feature({"AndroidWebView", "Privacy"}) |
- public void testRemoveAllCookie() throws InterruptedException { |
+ public void testRemoveAllCookie() throws Exception { |
// enable cookie |
mCookieManager.setAcceptCookie(true); |
assertTrue(mCookieManager.acceptCookie()); |
@@ -158,27 +157,27 @@ public class CookieManagerTest extends AwTestBase { |
mCookieManager.setCookie(url, cookie); |
assertEquals(cookie, mCookieManager.getCookie(url)); |
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
+ poll(new Callable<Boolean>() { |
@Override |
- public boolean isSatisfied() { |
+ public Boolean call() throws Exception { |
return mCookieManager.hasCookies(); |
} |
- })); |
+ }); |
// clean up all cookies |
mCookieManager.removeAllCookie(); |
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
+ poll(new Callable<Boolean>() { |
@Override |
- public boolean isSatisfied() { |
+ public Boolean call() throws Exception { |
return !mCookieManager.hasCookies(); |
} |
- })); |
+ }); |
} |
@MediumTest |
@Feature({"AndroidWebView", "Privacy"}) |
@SuppressWarnings("deprecation") |
- public void testCookieExpiration() throws InterruptedException { |
+ public void testCookieExpiration() throws Exception { |
// enable cookie |
mCookieManager.setAcceptCookie(true); |
assertTrue(mCookieManager.acceptCookie()); |
@@ -209,30 +208,30 @@ public class CookieManagerTest extends AwTestBase { |
assertTrue(allCookies.contains(cookie3)); |
mCookieManager.removeSessionCookie(); |
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
+ poll(new Callable<Boolean>() { |
@Override |
- public boolean isSatisfied() { |
+ public Boolean call() throws Exception { |
String c = mCookieManager.getCookie(url); |
return !c.contains(cookie1) && c.contains(cookie2) && c.contains(cookie3); |
} |
- })); |
+ }); |
Thread.sleep(expiration + 1000); // wait for cookie to expire |
mCookieManager.removeExpiredCookie(); |
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
+ poll(new Callable<Boolean>() { |
@Override |
- public boolean isSatisfied() { |
+ public Boolean call() throws Exception { |
String c = mCookieManager.getCookie(url); |
return !c.contains(cookie1) && c.contains(cookie2) && !c.contains(cookie3); |
} |
- })); |
+ }); |
mCookieManager.removeAllCookie(); |
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
+ poll(new Callable<Boolean>() { |
@Override |
- public boolean isSatisfied() { |
+ public Boolean call() throws Exception { |
return mCookieManager.getCookie(url) == null; |
} |
- })); |
+ }); |
} |
} |