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 // This file contains download browser tests that are known to be runnable | 5 // This file contains download browser tests that are known to be runnable |
6 // in a pure content context. Over time tests should be migrated here. | 6 // in a pure content context. Over time tests should be migrated here. |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <utility> | 10 #include <utility> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "content/shell/browser/shell_browser_context.h" | 56 #include "content/shell/browser/shell_browser_context.h" |
57 #include "content/shell/browser/shell_download_manager_delegate.h" | 57 #include "content/shell/browser/shell_download_manager_delegate.h" |
58 #include "content/shell/browser/shell_network_delegate.h" | 58 #include "content/shell/browser/shell_network_delegate.h" |
59 #include "content/test/content_browser_test_utils_internal.h" | 59 #include "content/test/content_browser_test_utils_internal.h" |
60 #include "net/dns/mock_host_resolver.h" | 60 #include "net/dns/mock_host_resolver.h" |
61 #include "net/test/embedded_test_server/embedded_test_server.h" | 61 #include "net/test/embedded_test_server/embedded_test_server.h" |
62 #include "net/test/embedded_test_server/http_request.h" | 62 #include "net/test/embedded_test_server/http_request.h" |
63 #include "net/test/embedded_test_server/http_response.h" | 63 #include "net/test/embedded_test_server/http_response.h" |
64 #include "net/test/url_request/url_request_mock_http_job.h" | 64 #include "net/test/url_request/url_request_mock_http_job.h" |
65 #include "net/test/url_request/url_request_slow_download_job.h" | 65 #include "net/test/url_request/url_request_slow_download_job.h" |
| 66 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
66 #include "ppapi/features/features.h" | 67 #include "ppapi/features/features.h" |
67 #include "testing/gmock/include/gmock/gmock.h" | 68 #include "testing/gmock/include/gmock/gmock.h" |
68 #include "testing/gtest/include/gtest/gtest.h" | 69 #include "testing/gtest/include/gtest/gtest.h" |
69 #include "url/gurl.h" | 70 #include "url/gurl.h" |
70 | 71 |
71 #if BUILDFLAG(ENABLE_PLUGINS) | 72 #if BUILDFLAG(ENABLE_PLUGINS) |
72 #include "content/browser/plugin_service_impl.h" | 73 #include "content/browser/plugin_service_impl.h" |
73 #endif | 74 #endif |
74 | 75 |
75 using ::testing::AllOf; | 76 using ::testing::AllOf; |
(...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 origin_two.RegisterRequestHandler( | 2341 origin_two.RegisterRequestHandler( |
2341 CreateRedirectHandler("/bar", origin_one.GetURL("/foo"))); | 2342 CreateRedirectHandler("/bar", origin_one.GetURL("/foo"))); |
2342 ASSERT_TRUE(origin_two.Start()); | 2343 ASSERT_TRUE(origin_two.Start()); |
2343 | 2344 |
2344 // Download the file. | 2345 // Download the file. |
2345 SetupEnsureNoPendingDownloads(); | 2346 SetupEnsureNoPendingDownloads(); |
2346 std::unique_ptr<DownloadUrlParameters> download_parameters( | 2347 std::unique_ptr<DownloadUrlParameters> download_parameters( |
2347 DownloadUrlParameters::CreateForWebContentsMainFrame( | 2348 DownloadUrlParameters::CreateForWebContentsMainFrame( |
2348 shell()->web_contents(), origin_two.GetURL("/bar"))); | 2349 shell()->web_contents(), origin_two.GetURL("/bar"))); |
2349 std::unique_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1)); | 2350 std::unique_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1)); |
2350 DownloadManagerForShell(shell())->DownloadUrl(std::move(download_parameters)); | 2351 DownloadManagerForShell(shell())->DownloadUrl(std::move(download_parameters), |
| 2352 TRAFFIC_ANNOTATION_FOR_TESTS); |
2351 observer->WaitForFinished(); | 2353 observer->WaitForFinished(); |
2352 | 2354 |
2353 // Get the important info from other threads and check it. | 2355 // Get the important info from other threads and check it. |
2354 EXPECT_TRUE(EnsureNoPendingDownloads()); | 2356 EXPECT_TRUE(EnsureNoPendingDownloads()); |
2355 | 2357 |
2356 std::vector<DownloadItem*> downloads; | 2358 std::vector<DownloadItem*> downloads; |
2357 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 2359 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
2358 ASSERT_EQ(1u, downloads.size()); | 2360 ASSERT_EQ(1u, downloads.size()); |
2359 ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); | 2361 ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); |
2360 | 2362 |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2723 | 2725 |
2724 std::vector<DownloadItem*> downloads; | 2726 std::vector<DownloadItem*> downloads; |
2725 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 2727 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
2726 ASSERT_EQ(1u, downloads.size()); | 2728 ASSERT_EQ(1u, downloads.size()); |
2727 | 2729 |
2728 EXPECT_EQ(FILE_PATH_LITERAL("foo"), | 2730 EXPECT_EQ(FILE_PATH_LITERAL("foo"), |
2729 downloads[0]->GetTargetFilePath().BaseName().value()); | 2731 downloads[0]->GetTargetFilePath().BaseName().value()); |
2730 } | 2732 } |
2731 | 2733 |
2732 } // namespace content | 2734 } // namespace content |
OLD | NEW |