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

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

Issue 568873002: Start server thread in new TestWebServer.start() method rather than constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: silence findbugs static assignment warning Created 6 years, 3 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 import android.test.suitebuilder.annotation.SmallTest;
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 mContentsClient = contentsClient; 54 mContentsClient = contentsClient;
55 final AwTestContainerView testContainerView = 55 final AwTestContainerView testContainerView =
56 createAwTestContainerViewOnMainSync(mContentsClient); 56 createAwTestContainerViewOnMainSync(mContentsClient);
57 mAwContents = testContainerView.getAwContents(); 57 mAwContents = testContainerView.getAwContents();
58 mAwContents.getSettings().setJavaScriptEnabled(true); 58 mAwContents.getSettings().setJavaScriptEnabled(true);
59 } 59 }
60 60
61 @MediumTest 61 @MediumTest
62 @Feature({"AndroidWebView"}) 62 @Feature({"AndroidWebView"})
63 public void testStartup() throws Throwable { 63 public void testStartup() throws Throwable {
64 TestWebServer webServer = null; 64 TestWebServer webServer = TestWebServer.start();
65 try { 65 try {
66 webServer = new TestWebServer(false);
67 String path = "/cookie_test.html"; 66 String path = "/cookie_test.html";
68 String url = webServer.setResponse(path, CommonResources.ABOUT_HTML, null); 67 String url = webServer.setResponse(path, CommonResources.ABOUT_HTML, null);
69 68
70 AwCookieManager cookieManager = new AwCookieManager(); 69 AwCookieManager cookieManager = new AwCookieManager();
71 assertNotNull(cookieManager); 70 assertNotNull(cookieManager);
72 71
73 CookieUtils.clearCookies(this, cookieManager); 72 CookieUtils.clearCookies(this, cookieManager);
74 assertFalse(cookieManager.hasCookies()); 73 assertFalse(cookieManager.hasCookies());
75 74
76 cookieManager.setAcceptCookie(true); 75 cookieManager.setAcceptCookie(true);
77 assertTrue(cookieManager.acceptCookie()); 76 assertTrue(cookieManager.acceptCookie());
78 77
79 cookieManager.setCookie(url, "count=41"); 78 cookieManager.setCookie(url, "count=41");
80 79
81 startChromium(); 80 startChromium();
82 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), url); 81 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), url);
83 executeJavaScriptAndWaitForResult( 82 executeJavaScriptAndWaitForResult(
84 mAwContents, 83 mAwContents,
85 mContentsClient, 84 mContentsClient,
86 "var c=document.cookie.split('=');document.cookie=c[0]+'='+( 1+(+c[1]));"); 85 "var c=document.cookie.split('=');document.cookie=c[0]+'='+( 1+(+c[1]));");
87 86
88 assertEquals("count=42", cookieManager.getCookie(url)); 87 assertEquals("count=42", cookieManager.getCookie(url));
89 } finally { 88 } finally {
90 if (webServer != null) webServer.shutdown(); 89 webServer.shutdown();
91 } 90 }
92 } 91 }
93 92
94 @SmallTest 93 @SmallTest
95 @Feature({"AndroidWebView", "Privacy"}) 94 @Feature({"AndroidWebView", "Privacy"})
96 public void testAllowFileSchemeCookies() throws Throwable { 95 public void testAllowFileSchemeCookies() throws Throwable {
97 AwCookieManager cookieManager = new AwCookieManager(); 96 AwCookieManager cookieManager = new AwCookieManager();
98 assertFalse(cookieManager.allowFileSchemeCookies()); 97 assertFalse(cookieManager.allowFileSchemeCookies());
99 cookieManager.setAcceptFileSchemeCookies(true); 98 cookieManager.setAcceptFileSchemeCookies(true);
100 assertTrue(cookieManager.allowFileSchemeCookies()); 99 assertTrue(cookieManager.allowFileSchemeCookies());
(...skipping 22 matching lines...) Expand all
123 public AwWebResourceResponse shouldInterceptRequest( 122 public AwWebResourceResponse shouldInterceptRequest(
124 ShouldInterceptRequestParams params) { 123 ShouldInterceptRequestParams params) {
125 (new AwCookieManager()).getCookie("www.example.com"); 124 (new AwCookieManager()).getCookie("www.example.com");
126 return null; 125 return null;
127 } 126 }
128 }; 127 };
129 startChromiumWithClient(contentsClient); 128 startChromiumWithClient(contentsClient);
130 loadUrlSync(mAwContents, contentsClient.getOnPageFinishedHelper(), url); 129 loadUrlSync(mAwContents, contentsClient.getOnPageFinishedHelper(), url);
131 } 130 }
132 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698