Chromium Code Reviews| Index: content/browser/download/download_browsertest.cc |
| diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc |
| index 93a9c9a72725e6943be542b912922d6d3b7d61d1..a3dba26cacca63b789908ca6331b8cf722ba2285 100644 |
| --- a/content/browser/download/download_browsertest.cc |
| +++ b/content/browser/download/download_browsertest.cc |
| @@ -37,7 +37,6 @@ |
| #include "net/test/embedded_test_server/embedded_test_server.h" |
| #include "net/test/embedded_test_server/http_request.h" |
| #include "net/test/embedded_test_server/http_response.h" |
| -#include "net/test/spawned_test_server/spawned_test_server.h" |
| #include "net/test/url_request/url_request_mock_http_job.h" |
|
mmenke
2015/11/03 19:12:57
Why did you remove the spawned_test_server header?
svaldez
2015/11/03 19:33:16
Done.
|
| #include "net/test/url_request/url_request_slow_download_job.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| @@ -48,7 +47,6 @@ |
| #include "content/browser/plugin_service_impl.h" |
| #endif |
| -using ::net::test_server::EmbeddedTestServer; |
| using ::testing::AllOf; |
| using ::testing::Field; |
| using ::testing::InSequence; |
| @@ -521,7 +519,7 @@ scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendRedirectResponse( |
| // Creates a request handler for EmbeddedTestServer that responds with a HTTP |
| // 302 redirect if the request URL matches |relative_url|. |
| -EmbeddedTestServer::HandleRequestCallback CreateRedirectHandler( |
| +net::EmbeddedTestServer::HandleRequestCallback CreateRedirectHandler( |
| const std::string& relative_url, |
| const GURL& target_url) { |
| return base::Bind( |
| @@ -545,7 +543,7 @@ scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendBasicResponse( |
| // Creates a request handler for an EmbeddedTestServer that response with an |
| // HTTP 200 status code, a Content-Type header and a body. |
| -EmbeddedTestServer::HandleRequestCallback CreateBasicResponseHandler( |
| +net::EmbeddedTestServer::HandleRequestCallback CreateBasicResponseHandler( |
| const std::string& relative_url, |
| const std::string& content_type, |
| const std::string& body) { |
| @@ -702,7 +700,7 @@ class DownloadContentTest : public ContentBrowserTest { |
| void ReleaseRSTAndConfirmInterruptForResume(DownloadItem* download) { |
| scoped_ptr<DownloadTestObserver> rst_observer( |
| CreateInterruptedWaiter(shell(), 1)); |
| - NavigateToURL(shell(), test_server()->GetURL("download-finish")); |
| + NavigateToURL(shell(), spawned_test_server()->GetURL("download-finish")); |
| rst_observer->WaitForFinished(); |
| EXPECT_EQ(DownloadItem::INTERRUPTED, download->GetState()); |
| } |
| @@ -1072,11 +1070,11 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, ShutdownAtRelease) { |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownload) { |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| - GURL url = test_server()->GetURL( |
| + GURL url = spawned_test_server()->GetURL( |
| base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| - GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| + GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell())); |
| EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); |
| @@ -1139,15 +1137,14 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownload) { |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownloadNoRange) { |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| // Auto-restart if server doesn't handle ranges. |
| - GURL url = test_server()->GetURL( |
| - base::StringPrintf( |
| - // First download hits an RST, rest don't, no ranges. |
| - "rangereset?size=%d&rst_boundary=%d&" |
| - "token=NoRange&rst_limit=1&bounce_range", |
| - GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| + GURL url = spawned_test_server()->GetURL(base::StringPrintf( |
| + // First download hits an RST, rest don't, no ranges. |
| + "rangereset?size=%d&rst_boundary=%d&" |
| + "token=NoRange&rst_limit=1&bounce_range", |
| + GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| // Start the download and wait for first data chunk. |
| DownloadItem* download(StartDownloadAndReturnItem(url)); |
| @@ -1188,14 +1185,13 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| ResumeInterruptedDownloadBadPrecondition) { |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| - GURL url = test_server()->GetURL(base::StringPrintf( |
| + GURL url = spawned_test_server()->GetURL(base::StringPrintf( |
| // First download hits an RST, rest don't, precondition fail. |
| "rangereset?size=%d&rst_boundary=%d&" |
| "token=BadPrecondition&rst_limit=1&fail_precondition=2", |
| - GetSafeBufferChunk() * 3, |
| - GetSafeBufferChunk())); |
| + GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| // Start the download and wait for first data chunk. |
| DownloadItem* download(StartDownloadAndReturnItem(url)); |
| @@ -1240,14 +1236,13 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| ResumeInterruptedDownloadNoVerifiers) { |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| - GURL url = test_server()->GetURL( |
| - base::StringPrintf( |
| - // First download hits an RST, rest don't, no verifiers. |
| - "rangereset?size=%d&rst_boundary=%d&" |
| - "token=NoRange&rst_limit=1&no_verifiers", |
| - GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| + GURL url = spawned_test_server()->GetURL(base::StringPrintf( |
| + // First download hits an RST, rest don't, no verifiers. |
| + "rangereset?size=%d&rst_boundary=%d&" |
| + "token=NoRange&rst_limit=1&no_verifiers", |
| + GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| // Start the download and wait for first data chunk. |
| DownloadItem* download(StartDownloadAndReturnItem(url)); |
| @@ -1284,14 +1279,13 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithDeletedFile) { |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| - GURL url = test_server()->GetURL( |
| - base::StringPrintf( |
| - // First download hits an RST, rest don't |
| - "rangereset?size=%d&rst_boundary=%d&" |
| - "token=NoRange&rst_limit=1", |
| - GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| + GURL url = spawned_test_server()->GetURL(base::StringPrintf( |
| + // First download hits an RST, rest don't |
| + "rangereset?size=%d&rst_boundary=%d&" |
| + "token=NoRange&rst_limit=1", |
| + GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| // Start the download and wait for first data chunk. |
| DownloadItem* download(StartDownloadAndReturnItem(url)); |
| @@ -1488,9 +1482,9 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithFileFinalRenameError) { |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelInterruptedDownload) { |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| - GURL url1 = test_server()->GetURL( |
| + GURL url1 = spawned_test_server()->GetURL( |
| base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| @@ -1518,12 +1512,12 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelInterruptedDownload) { |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveDownload) { |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| // An interrupted download should remove the intermediate file when it is |
| // removed. |
| { |
| - GURL url1 = test_server()->GetURL( |
| + GURL url1 = spawned_test_server()->GetURL( |
| base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| @@ -1572,9 +1566,9 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveResumingDownload) { |
| SetupEnsureNoPendingDownloads(); |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| - GURL url = test_server()->GetURL( |
| + GURL url = spawned_test_server()->GetURL( |
| base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| @@ -1609,7 +1603,8 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveResumingDownload) { |
| // Start the second download and wait until it's done. The test server is |
| // single threaded. The response to this download request should follow the |
| // response to the previous resumption request. |
| - GURL url2(test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); |
| + GURL url2( |
| + spawned_test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); |
| NavigateToURLAndWaitForDownload(shell(), url2, DownloadItem::COMPLETE); |
| EXPECT_TRUE(EnsureNoPendingDownloads()); |
| @@ -1619,9 +1614,9 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelResumingDownload) { |
| SetupEnsureNoPendingDownloads(); |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableDownloadResumption); |
| - ASSERT_TRUE(test_server()->Start()); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| - GURL url = test_server()->GetURL( |
| + GURL url = spawned_test_server()->GetURL( |
| base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| @@ -1657,7 +1652,8 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelResumingDownload) { |
| // Start the second download and wait until it's done. The test server is |
| // single threaded. The response to this download request should follow the |
| // response to the previous resumption request. |
| - GURL url2(test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); |
| + GURL url2( |
| + spawned_test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); |
| NavigateToURLAndWaitForDownload(shell(), url2, DownloadItem::COMPLETE); |
| EXPECT_TRUE(EnsureNoPendingDownloads()); |
| @@ -1666,8 +1662,8 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelResumingDownload) { |
| // Check that the cookie policy is correctly updated when downloading a file |
| // that redirects cross origin. |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) { |
| - ASSERT_TRUE(test_server()->Start()); |
| - net::HostPortPair host_port = test_server()->host_port_pair(); |
| + ASSERT_TRUE(spawned_test_server()->Start()); |
| + net::HostPortPair host_port = spawned_test_server()->host_port_pair(); |
| DCHECK_EQ(host_port.host(), std::string("127.0.0.1")); |
| // Block third-party cookies. |
| @@ -1677,7 +1673,7 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) { |
| // cookie. |
| std::string download(base::StringPrintf( |
| "http://localhost:%d/set-cookie?A=B", host_port.port())); |
| - GURL url(test_server()->GetURL("server-redirect?" + download)); |
| + GURL url(spawned_test_server()->GetURL("server-redirect?" + download)); |
| // Download the file. |
| SetupEnsureNoPendingDownloads(); |
| @@ -1706,10 +1702,10 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) { |
| // download URL. |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| DownloadAttributeCrossOriginRedirect) { |
| - EmbeddedTestServer origin_one; |
| - EmbeddedTestServer origin_two; |
| - ASSERT_TRUE(origin_one.InitializeAndWaitUntilReady()); |
| - ASSERT_TRUE(origin_two.InitializeAndWaitUntilReady()); |
| + net::EmbeddedTestServer origin_one; |
| + net::EmbeddedTestServer origin_two; |
| + ASSERT_TRUE(origin_one.Start()); |
| + ASSERT_TRUE(origin_two.Start()); |
| // The download-attribute.html page contains an anchor element whose href is |
| // set to the value of the query parameter (specified as |target| in the URL |
| @@ -1751,10 +1747,10 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| // of the redirect chain. |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| DownloadAttributeSameOriginRedirect) { |
| - EmbeddedTestServer origin_one; |
| - EmbeddedTestServer origin_two; |
| - ASSERT_TRUE(origin_one.InitializeAndWaitUntilReady()); |
| - ASSERT_TRUE(origin_two.InitializeAndWaitUntilReady()); |
| + net::EmbeddedTestServer origin_one; |
| + net::EmbeddedTestServer origin_two; |
| + ASSERT_TRUE(origin_one.Start()); |
| + ASSERT_TRUE(origin_two.Start()); |
| // The download-attribute.html page contains an anchor element whose href is |
| // set to the value of the query parameter (specified as |target| in the URL |
| @@ -1797,8 +1793,8 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| // The content body is empty. Make sure this case is handled properly and we |
| // don't regress on http://crbug.com/320394. |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadGZipWithNoContent) { |
| - EmbeddedTestServer test_server; |
| - ASSERT_TRUE(test_server.InitializeAndWaitUntilReady()); |
| + net::EmbeddedTestServer test_server; |
| + ASSERT_TRUE(test_server.Start()); |
| GURL url = test_server.GetURL("/empty.bin"); |
| test_server.ServeFilesFromDirectory(GetTestFilePath("download", "")); |
| @@ -1808,7 +1804,7 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadGZipWithNoContent) { |
| } |
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, Spam) { |
| - ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| + ASSERT_TRUE(embedded_test_server()->Start()); |
| NavigateToURLAndWaitForDownload( |
| shell(), |