| OLD | NEW |
| 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/public/renderer/resource_fetcher.h" | 5 #include "content/public/renderer/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/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 15 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
| 16 #include "content/public/test/content_browser_test.h" | 16 #include "content/public/test/content_browser_test.h" |
| 17 #include "content/public/test/content_browser_test_utils.h" | 17 #include "content/public/test/content_browser_test_utils.h" |
| 18 #include "content/public/test/routing_id_mangling_disabler.h" |
| 18 #include "content/public/test/test_utils.h" | 19 #include "content/public/test/test_utils.h" |
| 19 #include "content/shell/browser/shell.h" | 20 #include "content/shell/browser/shell.h" |
| 20 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 21 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 21 #include "third_party/WebKit/public/web/WebFrame.h" | 22 #include "third_party/WebKit/public/web/WebFrame.h" |
| 22 #include "third_party/WebKit/public/web/WebView.h" | 23 #include "third_party/WebKit/public/web/WebView.h" |
| 23 | 24 |
| 24 using blink::WebFrame; | 25 using blink::WebFrame; |
| 25 using blink::WebURLRequest; | 26 using blink::WebURLRequest; |
| 26 using blink::WebURLResponse; | 27 using blink::WebURLResponse; |
| 27 | 28 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 WebURLRequest::RequestContextInternal, | 278 WebURLRequest::RequestContextInternal, |
| 278 WebURLRequest::FrameTypeNone, | 279 WebURLRequest::FrameTypeNone, |
| 279 ResourceFetcher::PLATFORM_LOADER, | 280 ResourceFetcher::PLATFORM_LOADER, |
| 280 delegate->NewCallback()); | 281 delegate->NewCallback()); |
| 281 | 282 |
| 282 delegate->WaitForResponse(); | 283 delegate->WaitForResponse(); |
| 283 ASSERT_TRUE(delegate->completed()); | 284 ASSERT_TRUE(delegate->completed()); |
| 284 EXPECT_EQ(delegate->response().httpStatusCode(), 200); | 285 EXPECT_EQ(delegate->response().httpStatusCode(), 200); |
| 285 EXPECT_EQ(kHeader, delegate->data()); | 286 EXPECT_EQ(kHeader, delegate->data()); |
| 286 } | 287 } |
| 288 |
| 289 content::RoutingIDManglingDisabler routing_id_mangling_disabler_; |
| 287 }; | 290 }; |
| 288 | 291 |
| 289 // Test a fetch from the test server. | 292 // Test a fetch from the test server. |
| 290 // If this flakes, use http://crbug.com/51622. | 293 // If this flakes, use http://crbug.com/51622. |
| 291 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDownload) { | 294 IN_PROC_BROWSER_TEST_F(ResourceFetcherTests, ResourceFetcherDownload) { |
| 292 // Need to spin up the renderer. | 295 // Need to spin up the renderer. |
| 293 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 296 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
| 294 | 297 |
| 295 ASSERT_TRUE(test_server()->Start()); | 298 ASSERT_TRUE(test_server()->Start()); |
| 296 GURL url(test_server()->GetURL("files/simple_page.html")); | 299 GURL url(test_server()->GetURL("files/simple_page.html")); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 ASSERT_TRUE(test_server()->Start()); | 381 ASSERT_TRUE(test_server()->Start()); |
| 379 GURL url(test_server()->GetURL("echoheader?header")); | 382 GURL url(test_server()->GetURL("echoheader?header")); |
| 380 | 383 |
| 381 PostTaskToInProcessRendererAndWait( | 384 PostTaskToInProcessRendererAndWait( |
| 382 base::Bind( | 385 base::Bind( |
| 383 &ResourceFetcherTests::ResourceFetcherSetHeader, | 386 &ResourceFetcherTests::ResourceFetcherSetHeader, |
| 384 base::Unretained(this), url)); | 387 base::Unretained(this), url)); |
| 385 } | 388 } |
| 386 | 389 |
| 387 } // namespace content | 390 } // namespace content |
| OLD | NEW |