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

Side by Side Diff: content/renderer/resource_fetcher_browsertest.cc

Issue 21955003: Cleanup: Use content::kAboutBlankURL instead of the raw string in contents/. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix build Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/renderer/fetchers/resource_fetcher.h" 5 #include "content/renderer/fetchers/resource_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "content/public/common/url_constants.h"
13 #include "content/public/renderer/render_view.h" 14 #include "content/public/renderer/render_view.h"
14 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
15 #include "content/shell/shell.h" 16 #include "content/shell/shell.h"
16 #include "content/test/content_browser_test.h" 17 #include "content/test/content_browser_test.h"
17 #include "content/test/content_browser_test_utils.h" 18 #include "content/test/content_browser_test_utils.h"
18 #include "third_party/WebKit/public/platform/WebURLResponse.h" 19 #include "third_party/WebKit/public/platform/WebURLResponse.h"
19 #include "third_party/WebKit/public/web/WebFrame.h" 20 #include "third_party/WebKit/public/web/WebFrame.h"
20 #include "third_party/WebKit/public/web/WebView.h" 21 #include "third_party/WebKit/public/web/WebView.h"
21 22
22 using WebKit::WebFrame; 23 using WebKit::WebFrame;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 211
211 delegate->WaitForResponse(); 212 delegate->WaitForResponse();
212 EXPECT_FALSE(delegate->timed_out()); 213 EXPECT_FALSE(delegate->timed_out());
213 } 214 }
214 }; 215 };
215 216
216 // Test a fetch from the test server. 217 // Test a fetch from the test server.
217 // If this flakes, use http://crbug.com/51622. 218 // If this flakes, use http://crbug.com/51622.
218 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDownload) { 219 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDownload) {
219 // Need to spin up the renderer. 220 // Need to spin up the renderer.
220 NavigateToURL(shell(), GURL("about:blank")); 221 NavigateToURL(shell(), GURL(kAboutBlankURL));
221 222
222 ASSERT_TRUE(test_server()->Start()); 223 ASSERT_TRUE(test_server()->Start());
223 GURL url(test_server()->GetURL("files/simple_page.html")); 224 GURL url(test_server()->GetURL("files/simple_page.html"));
224 225
225 PostTaskToInProcessRendererAndWait( 226 PostTaskToInProcessRendererAndWait(
226 base::Bind(&ResourceFetcherTests::ResourceFetcherDownloadOnRenderer, 227 base::Bind(&ResourceFetcherTests::ResourceFetcherDownloadOnRenderer,
227 base::Unretained(this), url)); 228 base::Unretained(this), url));
228 } 229 }
229 230
230 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcher404) { 231 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcher404) {
231 // Need to spin up the renderer. 232 // Need to spin up the renderer.
232 NavigateToURL(shell(), GURL("about:blank")); 233 NavigateToURL(shell(), GURL(kAboutBlankURL));
233 234
234 // Test 404 response. 235 // Test 404 response.
235 ASSERT_TRUE(test_server()->Start()); 236 ASSERT_TRUE(test_server()->Start());
236 GURL url = test_server()->GetURL("files/thisfiledoesntexist.html"); 237 GURL url = test_server()->GetURL("files/thisfiledoesntexist.html");
237 238
238 PostTaskToInProcessRendererAndWait( 239 PostTaskToInProcessRendererAndWait(
239 base::Bind(&ResourceFetcherTests::ResourceFetcher404OnRenderer, 240 base::Bind(&ResourceFetcherTests::ResourceFetcher404OnRenderer,
240 base::Unretained(this), url)); 241 base::Unretained(this), url));
241 } 242 }
242 243
243 // If this flakes, use http://crbug.com/51622. 244 // If this flakes, use http://crbug.com/51622.
244 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDidFail) { 245 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDidFail) {
245 // Need to spin up the renderer. 246 // Need to spin up the renderer.
246 NavigateToURL(shell(), GURL("about:blank")); 247 NavigateToURL(shell(), GURL(kAboutBlankURL));
247 248
248 PostTaskToInProcessRendererAndWait( 249 PostTaskToInProcessRendererAndWait(
249 base::Bind(&ResourceFetcherTests::ResourceFetcherDidFailOnRenderer, 250 base::Bind(&ResourceFetcherTests::ResourceFetcherDidFailOnRenderer,
250 base::Unretained(this))); 251 base::Unretained(this)));
251 } 252 }
252 253
253 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherTimeout) { 254 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherTimeout) {
254 // Need to spin up the renderer. 255 // Need to spin up the renderer.
255 NavigateToURL(shell(), GURL("about:blank")); 256 NavigateToURL(shell(), GURL(kAboutBlankURL));
256 257
257 // Grab a page that takes at least 1 sec to respond, but set the fetcher to 258 // Grab a page that takes at least 1 sec to respond, but set the fetcher to
258 // timeout in 0 sec. 259 // timeout in 0 sec.
259 ASSERT_TRUE(test_server()->Start()); 260 ASSERT_TRUE(test_server()->Start());
260 GURL url(test_server()->GetURL("slow?1")); 261 GURL url(test_server()->GetURL("slow?1"));
261 262
262 PostTaskToInProcessRendererAndWait( 263 PostTaskToInProcessRendererAndWait(
263 base::Bind(&ResourceFetcherTests::ResourceFetcherTimeoutOnRenderer, 264 base::Bind(&ResourceFetcherTests::ResourceFetcherTimeoutOnRenderer,
264 base::Unretained(this), url)); 265 base::Unretained(this), url));
265 } 266 }
266 267
267 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDeletedInCallback) { 268 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDeletedInCallback) {
268 // Need to spin up the renderer. 269 // Need to spin up the renderer.
269 NavigateToURL(shell(), GURL("about:blank")); 270 NavigateToURL(shell(), GURL(kAboutBlankURL));
270 271
271 // Grab a page that takes at least 1 sec to respond, but set the fetcher to 272 // Grab a page that takes at least 1 sec to respond, but set the fetcher to
272 // timeout in 0 sec. 273 // timeout in 0 sec.
273 ASSERT_TRUE(test_server()->Start()); 274 ASSERT_TRUE(test_server()->Start());
274 GURL url(test_server()->GetURL("slow?1")); 275 GURL url(test_server()->GetURL("slow?1"));
275 276
276 PostTaskToInProcessRendererAndWait( 277 PostTaskToInProcessRendererAndWait(
277 base::Bind( 278 base::Bind(
278 &ResourceFetcherTests::ResourceFetcherDeletedInCallbackOnRenderer, 279 &ResourceFetcherTests::ResourceFetcherDeletedInCallbackOnRenderer,
279 base::Unretained(this), url)); 280 base::Unretained(this), url));
280 } 281 }
281 282
282 } // namespace content 283 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/cpp_bound_class_unittest.cc ('k') | content/shell/renderer/webkit_test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698