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