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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "content/public/test/download_test_observer.h" | 24 #include "content/public/test/download_test_observer.h" |
25 #include "extensions/browser/event_router.h" | 25 #include "extensions/browser/event_router.h" |
26 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_system.h" |
27 #include "extensions/common/manifest_handlers/mime_types_handler.h" | 27 #include "extensions/common/manifest_handlers/mime_types_handler.h" |
28 #include "extensions/test/result_catcher.h" | 28 #include "extensions/test/result_catcher.h" |
29 #include "net/dns/mock_host_resolver.h" | 29 #include "net/dns/mock_host_resolver.h" |
30 #include "net/test/embedded_test_server/embedded_test_server.h" | 30 #include "net/test/embedded_test_server/embedded_test_server.h" |
31 #include "net/test/embedded_test_server/http_request.h" | 31 #include "net/test/embedded_test_server/http_request.h" |
32 #include "net/test/embedded_test_server/http_response.h" | 32 #include "net/test/embedded_test_server/http_response.h" |
| 33 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
34 | 35 |
35 using content::BrowserContext; | 36 using content::BrowserContext; |
36 using content::BrowserThread; | 37 using content::BrowserThread; |
37 using content::DownloadItem; | 38 using content::DownloadItem; |
38 using content::DownloadManager; | 39 using content::DownloadManager; |
39 using content::DownloadUrlParameters; | 40 using content::DownloadUrlParameters; |
40 using content::WebContents; | 41 using content::WebContents; |
41 using extensions::Event; | 42 using extensions::Event; |
42 using extensions::ExtensionSystem; | 43 using extensions::ExtensionSystem; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // Set the downloads parameters. | 384 // Set the downloads parameters. |
384 content::WebContents* web_contents = | 385 content::WebContents* web_contents = |
385 browser()->tab_strip_model()->GetActiveWebContents(); | 386 browser()->tab_strip_model()->GetActiveWebContents(); |
386 ASSERT_TRUE(web_contents); | 387 ASSERT_TRUE(web_contents); |
387 std::unique_ptr<DownloadUrlParameters> params( | 388 std::unique_ptr<DownloadUrlParameters> params( |
388 DownloadUrlParameters::CreateForWebContentsMainFrame( | 389 DownloadUrlParameters::CreateForWebContentsMainFrame( |
389 web_contents, url)); | 390 web_contents, url)); |
390 params->set_file_path(target_path); | 391 params->set_file_path(target_path); |
391 | 392 |
392 // Start download of the URL with a path "/text_path.txt" on the test server. | 393 // Start download of the URL with a path "/text_path.txt" on the test server. |
393 download_manager->DownloadUrl(std::move(params)); | 394 download_manager->DownloadUrl(std::move(params), |
| 395 TRAFFIC_ANNOTATION_FOR_TESTS); |
394 | 396 |
395 // Wait for the download to start. | 397 // Wait for the download to start. |
396 download_observer->WaitForFinished(); | 398 download_observer->WaitForFinished(); |
397 | 399 |
398 // There should have been one download. | 400 // There should have been one download. |
399 std::vector<DownloadItem*> downloads; | 401 std::vector<DownloadItem*> downloads; |
400 download_manager->GetAllDownloads(&downloads); | 402 download_manager->GetAllDownloads(&downloads); |
401 ASSERT_EQ(1u, downloads.size()); | 403 ASSERT_EQ(1u, downloads.size()); |
402 | 404 |
403 // Cancel and delete the download statred in the test. | 405 // Cancel and delete the download statred in the test. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 base::RunLoop().RunUntilIdle(); | 448 base::RunLoop().RunUntilIdle(); |
447 EXPECT_TRUE(catcher.GetNextResult()); | 449 EXPECT_TRUE(catcher.GetNextResult()); |
448 | 450 |
449 ui_test_utils::NavigateToURL(browser(), | 451 ui_test_utils::NavigateToURL(browser(), |
450 test_server_->GetURL("/abort.rtf")); | 452 test_server_->GetURL("/abort.rtf")); |
451 base::RunLoop().RunUntilIdle(); | 453 base::RunLoop().RunUntilIdle(); |
452 EXPECT_TRUE(catcher.GetNextResult()); | 454 EXPECT_TRUE(catcher.GetNextResult()); |
453 } | 455 } |
454 | 456 |
455 } // namespace | 457 } // namespace |
OLD | NEW |