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 12 matching lines...) Expand all Loading... |
23 #include "base/threading/platform_thread.h" | 23 #include "base/threading/platform_thread.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "content/browser/byte_stream.h" | 26 #include "content/browser/byte_stream.h" |
27 #include "content/browser/download/download_file_factory.h" | 27 #include "content/browser/download/download_file_factory.h" |
28 #include "content/browser/download/download_file_impl.h" | 28 #include "content/browser/download/download_file_impl.h" |
29 #include "content/browser/download/download_item_impl.h" | 29 #include "content/browser/download/download_item_impl.h" |
30 #include "content/browser/download/download_manager_impl.h" | 30 #include "content/browser/download/download_manager_impl.h" |
31 #include "content/browser/download/download_resource_handler.h" | 31 #include "content/browser/download/download_resource_handler.h" |
32 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 32 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
33 #include "content/browser/power_save_blocker_factory.h" | |
34 #include "content/browser/web_contents/web_contents_impl.h" | 33 #include "content/browser/web_contents/web_contents_impl.h" |
35 #include "content/public/browser/download_danger_type.h" | 34 #include "content/public/browser/download_danger_type.h" |
36 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 35 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
37 #include "content/public/browser/resource_throttle.h" | 36 #include "content/public/browser/resource_throttle.h" |
38 #include "content/public/common/content_features.h" | 37 #include "content/public/common/content_features.h" |
39 #include "content/public/common/webplugininfo.h" | 38 #include "content/public/common/webplugininfo.h" |
40 #include "content/public/test/browser_test_utils.h" | 39 #include "content/public/test/browser_test_utils.h" |
41 #include "content/public/test/content_browser_test.h" | 40 #include "content/public/test/content_browser_test.h" |
42 #include "content/public/test/content_browser_test_utils.h" | 41 #include "content/public/test/content_browser_test_utils.h" |
43 #include "content/public/test/download_test_observer.h" | 42 #include "content/public/test/download_test_observer.h" |
44 #include "content/public/test/test_download_request_handler.h" | 43 #include "content/public/test/test_download_request_handler.h" |
45 #include "content/public/test/test_file_error_injector.h" | 44 #include "content/public/test/test_file_error_injector.h" |
46 #include "content/public/test/test_utils.h" | 45 #include "content/public/test/test_utils.h" |
47 #include "content/shell/browser/shell.h" | 46 #include "content/shell/browser/shell.h" |
48 #include "content/shell/browser/shell_browser_context.h" | 47 #include "content/shell/browser/shell_browser_context.h" |
49 #include "content/shell/browser/shell_download_manager_delegate.h" | 48 #include "content/shell/browser/shell_download_manager_delegate.h" |
50 #include "content/shell/browser/shell_network_delegate.h" | 49 #include "content/shell/browser/shell_network_delegate.h" |
| 50 #include "device/power_save_blocker/power_save_blocker.h" |
51 #include "net/test/embedded_test_server/embedded_test_server.h" | 51 #include "net/test/embedded_test_server/embedded_test_server.h" |
52 #include "net/test/embedded_test_server/http_request.h" | 52 #include "net/test/embedded_test_server/http_request.h" |
53 #include "net/test/embedded_test_server/http_response.h" | 53 #include "net/test/embedded_test_server/http_response.h" |
54 #include "net/test/url_request/url_request_mock_http_job.h" | 54 #include "net/test/url_request/url_request_mock_http_job.h" |
55 #include "net/test/url_request/url_request_slow_download_job.h" | 55 #include "net/test/url_request/url_request_slow_download_job.h" |
56 #include "testing/gmock/include/gmock/gmock.h" | 56 #include "testing/gmock/include/gmock/gmock.h" |
57 #include "testing/gtest/include/gtest/gtest.h" | 57 #include "testing/gtest/include/gtest/gtest.h" |
58 #include "url/gurl.h" | 58 #include "url/gurl.h" |
59 | 59 |
60 #if defined(ENABLE_PLUGINS) | 60 #if defined(ENABLE_PLUGINS) |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 weak_ptr_factory_(this) {} | 248 weak_ptr_factory_(this) {} |
249 | 249 |
250 DownloadFileWithDelayFactory::~DownloadFileWithDelayFactory() {} | 250 DownloadFileWithDelayFactory::~DownloadFileWithDelayFactory() {} |
251 | 251 |
252 DownloadFile* DownloadFileWithDelayFactory::CreateFile( | 252 DownloadFile* DownloadFileWithDelayFactory::CreateFile( |
253 std::unique_ptr<DownloadSaveInfo> save_info, | 253 std::unique_ptr<DownloadSaveInfo> save_info, |
254 const base::FilePath& default_download_directory, | 254 const base::FilePath& default_download_directory, |
255 std::unique_ptr<ByteStreamReader> stream, | 255 std::unique_ptr<ByteStreamReader> stream, |
256 const net::BoundNetLog& bound_net_log, | 256 const net::BoundNetLog& bound_net_log, |
257 base::WeakPtr<DownloadDestinationObserver> observer) { | 257 base::WeakPtr<DownloadDestinationObserver> observer) { |
258 std::unique_ptr<device::PowerSaveBlocker> psb(CreatePowerSaveBlocker( | 258 std::unique_ptr<device::PowerSaveBlocker> psb( |
259 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 259 device::PowerSaveBlocker::CreateWithTaskRunners( |
260 device::PowerSaveBlocker::kReasonOther, "Download in progress")); | 260 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 261 device::PowerSaveBlocker::kReasonOther, "Download in progress", |
| 262 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 263 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); |
261 return new DownloadFileWithDelay(std::move(save_info), | 264 return new DownloadFileWithDelay(std::move(save_info), |
262 default_download_directory, | 265 default_download_directory, |
263 std::move(stream), | 266 std::move(stream), |
264 bound_net_log, | 267 bound_net_log, |
265 std::move(psb), | 268 std::move(psb), |
266 observer, | 269 observer, |
267 weak_ptr_factory_.GetWeakPtr()); | 270 weak_ptr_factory_.GetWeakPtr()); |
268 } | 271 } |
269 | 272 |
270 void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) { | 273 void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 CountingDownloadFileFactory() {} | 348 CountingDownloadFileFactory() {} |
346 ~CountingDownloadFileFactory() override {} | 349 ~CountingDownloadFileFactory() override {} |
347 | 350 |
348 // DownloadFileFactory interface. | 351 // DownloadFileFactory interface. |
349 DownloadFile* CreateFile( | 352 DownloadFile* CreateFile( |
350 std::unique_ptr<DownloadSaveInfo> save_info, | 353 std::unique_ptr<DownloadSaveInfo> save_info, |
351 const base::FilePath& default_downloads_directory, | 354 const base::FilePath& default_downloads_directory, |
352 std::unique_ptr<ByteStreamReader> stream, | 355 std::unique_ptr<ByteStreamReader> stream, |
353 const net::BoundNetLog& bound_net_log, | 356 const net::BoundNetLog& bound_net_log, |
354 base::WeakPtr<DownloadDestinationObserver> observer) override { | 357 base::WeakPtr<DownloadDestinationObserver> observer) override { |
355 std::unique_ptr<device::PowerSaveBlocker> psb(CreatePowerSaveBlocker( | 358 std::unique_ptr<device::PowerSaveBlocker> psb( |
356 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 359 device::PowerSaveBlocker::CreateWithTaskRunners( |
357 device::PowerSaveBlocker::kReasonOther, "Download in progress")); | 360 device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 361 device::PowerSaveBlocker::kReasonOther, "Download in progress", |
| 362 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 363 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); |
358 return new CountingDownloadFile(std::move(save_info), | 364 return new CountingDownloadFile(std::move(save_info), |
359 default_downloads_directory, | 365 default_downloads_directory, |
360 std::move(stream), | 366 std::move(stream), |
361 bound_net_log, | 367 bound_net_log, |
362 std::move(psb), | 368 std::move(psb), |
363 observer); | 369 observer); |
364 } | 370 } |
365 }; | 371 }; |
366 | 372 |
367 class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate { | 373 class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate { |
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 | 2474 |
2469 std::vector<DownloadItem*> downloads; | 2475 std::vector<DownloadItem*> downloads; |
2470 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 2476 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
2471 ASSERT_EQ(1u, downloads.size()); | 2477 ASSERT_EQ(1u, downloads.size()); |
2472 | 2478 |
2473 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), | 2479 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), |
2474 downloads[0]->GetTargetFilePath().BaseName().value()); | 2480 downloads[0]->GetTargetFilePath().BaseName().value()); |
2475 } | 2481 } |
2476 | 2482 |
2477 } // namespace content | 2483 } // namespace content |
OLD | NEW |