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

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerStartupTest.java

Issue 273873003: Adds Asynchronous APIs to CookieManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview.test; 5 package org.chromium.android_webview.test;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.test.suitebuilder.annotation.MediumTest; 8 import android.test.suitebuilder.annotation.MediumTest;
9 import android.test.suitebuilder.annotation.SmallTest;
9 10
10 import org.chromium.android_webview.AwBrowserProcess; 11 import org.chromium.android_webview.AwBrowserProcess;
11 import org.chromium.android_webview.AwContents; 12 import org.chromium.android_webview.AwContents;
12 import org.chromium.android_webview.AwCookieManager; 13 import org.chromium.android_webview.AwCookieManager;
13 import org.chromium.android_webview.test.util.CommonResources; 14 import org.chromium.android_webview.test.util.CommonResources;
15 import org.chromium.android_webview.test.util.CookieUtils;
14 import org.chromium.base.test.util.Feature; 16 import org.chromium.base.test.util.Feature;
15 import org.chromium.content.app.ContentMain; 17 import org.chromium.content.app.ContentMain;
16 import org.chromium.net.test.util.TestWebServer; 18 import org.chromium.net.test.util.TestWebServer;
17 19
18 /** 20 /**
19 * Test for the CookieManager in the case where it's used before Chromium is sta rted. 21 * Test for the CookieManager in the case where it's used before Chromium is sta rted.
20 */ 22 */
21 public class CookieManagerStartupTest extends AwTestBase { 23 public class CookieManagerStartupTest extends AwTestBase {
22 24
23 private AwCookieManager mCookieManager; 25 private AwCookieManager mCookieManager;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 59
58 @MediumTest 60 @MediumTest
59 @Feature({"AndroidWebView"}) 61 @Feature({"AndroidWebView"})
60 public void testStartup() throws Throwable { 62 public void testStartup() throws Throwable {
61 TestWebServer webServer = null; 63 TestWebServer webServer = null;
62 try { 64 try {
63 webServer = new TestWebServer(false); 65 webServer = new TestWebServer(false);
64 String path = "/cookie_test.html"; 66 String path = "/cookie_test.html";
65 String url = webServer.setResponse(path, CommonResources.ABOUT_HTML, null); 67 String url = webServer.setResponse(path, CommonResources.ABOUT_HTML, null);
66 68
69 CookieUtils.clearCookies(this, mCookieManager);
70
67 mCookieManager.setAcceptCookie(true); 71 mCookieManager.setAcceptCookie(true);
68 mCookieManager.removeAllCookie();
69 assertTrue(mCookieManager.acceptCookie()); 72 assertTrue(mCookieManager.acceptCookie());
70 assertFalse(mCookieManager.hasCookies()); 73
71 mCookieManager.setCookie(url, "count=41"); 74 mCookieManager.setCookie(url, "count=41");
72 75
73 startChromium(); 76 startChromium();
74 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), url); 77 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), url);
75 executeJavaScriptAndWaitForResult( 78 executeJavaScriptAndWaitForResult(
76 mAwContents, 79 mAwContents,
77 mContentsClient, 80 mContentsClient,
78 "var c=document.cookie.split('=');document.cookie=c[0]+'='+( 1+(+c[1]));"); 81 "var c=document.cookie.split('=');document.cookie=c[0]+'='+( 1+(+c[1]));");
79 82
80 assertEquals("count=42", mCookieManager.getCookie(url)); 83 assertEquals("count=42", mCookieManager.getCookie(url));
81 } finally { 84 } finally {
82 if (webServer != null) webServer.shutdown(); 85 if (webServer != null) webServer.shutdown();
83 } 86 }
84 } 87 }
85 88
89 @SmallTest
90 @Feature({"AndroidWebView", "Privacy"})
91 public void testAllowFileSchemeCookies() throws Throwable {
92 assertFalse(mCookieManager.allowFileSchemeCookies());
93 mCookieManager.setAcceptFileSchemeCookies(true);
94 assertTrue(mCookieManager.allowFileSchemeCookies());
95 mCookieManager.setAcceptFileSchemeCookies(false);
96 assertFalse(mCookieManager.allowFileSchemeCookies());
97 }
98
99 @SmallTest
100 @Feature({"AndroidWebView", "Privacy"})
101 public void testAllowCookies() throws Throwable {
102 assertTrue(mCookieManager.acceptCookie());
103 mCookieManager.setAcceptCookie(false);
104 assertFalse(mCookieManager.acceptCookie());
105 mCookieManager.setAcceptCookie(true);
106 assertTrue(mCookieManager.acceptCookie());
107 }
86 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698