| 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 "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "content/browser/download/download_file_factory.h" | 11 #include "content/browser/download/download_file_factory.h" |
| 12 #include "content/browser/download/download_file_impl.h" | 12 #include "content/browser/download/download_file_impl.h" |
| 13 #include "content/browser/download/download_item_impl.h" | 13 #include "content/browser/download/download_item_impl.h" |
| 14 #include "content/browser/download/download_manager_impl.h" | 14 #include "content/browser/download/download_manager_impl.h" |
| 15 #include "content/browser/power_save_blocker.h" | |
| 16 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
| 16 #include "content/public/browser/power_save_blocker.h" |
| 17 #include "content/public/test/download_test_observer.h" | 17 #include "content/public/test/download_test_observer.h" |
| 18 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
| 19 #include "content/shell/shell.h" | 19 #include "content/shell/shell.h" |
| 20 #include "content/shell/shell_browser_context.h" | 20 #include "content/shell/shell_browser_context.h" |
| 21 #include "content/shell/shell_download_manager_delegate.h" | 21 #include "content/shell/shell_download_manager_delegate.h" |
| 22 #include "content/test/content_browser_test.h" | 22 #include "content/test/content_browser_test.h" |
| 23 #include "content/test/content_browser_test_utils.h" | 23 #include "content/test/content_browser_test_utils.h" |
| 24 #include "content/test/net/url_request_mock_http_job.h" | 24 #include "content/test/net/url_request_mock_http_job.h" |
| 25 #include "content/test/net/url_request_slow_download_job.h" | 25 #include "content/test/net/url_request_slow_download_job.h" |
| 26 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 DownloadFile* DownloadFileWithDelayFactory::CreateFile( | 197 DownloadFile* DownloadFileWithDelayFactory::CreateFile( |
| 198 scoped_ptr<DownloadSaveInfo> save_info, | 198 scoped_ptr<DownloadSaveInfo> save_info, |
| 199 const FilePath& default_download_directory, | 199 const FilePath& default_download_directory, |
| 200 const GURL& url, | 200 const GURL& url, |
| 201 const GURL& referrer_url, | 201 const GURL& referrer_url, |
| 202 bool calculate_hash, | 202 bool calculate_hash, |
| 203 scoped_ptr<ByteStreamReader> stream, | 203 scoped_ptr<ByteStreamReader> stream, |
| 204 const net::BoundNetLog& bound_net_log, | 204 const net::BoundNetLog& bound_net_log, |
| 205 base::WeakPtr<DownloadDestinationObserver> observer) { | 205 base::WeakPtr<DownloadDestinationObserver> observer) { |
| 206 scoped_ptr<PowerSaveBlocker> psb( | 206 scoped_ptr<PowerSaveBlocker> psb( |
| 207 new PowerSaveBlocker( | 207 PowerSaveBlocker::Create( |
| 208 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 208 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 209 "Download in progress")); | 209 "Download in progress")); |
| 210 return new DownloadFileWithDelay( | 210 return new DownloadFileWithDelay( |
| 211 save_info.Pass(), default_download_directory, url, referrer_url, | 211 save_info.Pass(), default_download_directory, url, referrer_url, |
| 212 calculate_hash, stream.Pass(), bound_net_log, | 212 calculate_hash, stream.Pass(), bound_net_log, |
| 213 psb.Pass(), observer, weak_ptr_factory_.GetWeakPtr()); | 213 psb.Pass(), observer, weak_ptr_factory_.GetWeakPtr()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) { | 216 void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) { |
| 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 virtual DownloadFile* CreateFile( | 296 virtual DownloadFile* CreateFile( |
| 297 scoped_ptr<DownloadSaveInfo> save_info, | 297 scoped_ptr<DownloadSaveInfo> save_info, |
| 298 const FilePath& default_downloads_directory, | 298 const FilePath& default_downloads_directory, |
| 299 const GURL& url, | 299 const GURL& url, |
| 300 const GURL& referrer_url, | 300 const GURL& referrer_url, |
| 301 bool calculate_hash, | 301 bool calculate_hash, |
| 302 scoped_ptr<ByteStreamReader> stream, | 302 scoped_ptr<ByteStreamReader> stream, |
| 303 const net::BoundNetLog& bound_net_log, | 303 const net::BoundNetLog& bound_net_log, |
| 304 base::WeakPtr<DownloadDestinationObserver> observer) OVERRIDE { | 304 base::WeakPtr<DownloadDestinationObserver> observer) OVERRIDE { |
| 305 scoped_ptr<PowerSaveBlocker> psb( | 305 scoped_ptr<PowerSaveBlocker> psb( |
| 306 new PowerSaveBlocker( | 306 PowerSaveBlocker::Create( |
| 307 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 307 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 308 "Download in progress")); | 308 "Download in progress")); |
| 309 return new CountingDownloadFile( | 309 return new CountingDownloadFile( |
| 310 save_info.Pass(), default_downloads_directory, url, referrer_url, | 310 save_info.Pass(), default_downloads_directory, url, referrer_url, |
| 311 calculate_hash, stream.Pass(), bound_net_log, | 311 calculate_hash, stream.Pass(), bound_net_log, |
| 312 psb.Pass(), observer); | 312 psb.Pass(), observer); |
| 313 } | 313 } |
| 314 }; | 314 }; |
| 315 | 315 |
| 316 class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate { | 316 class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 MockDownloadItemObserver observer; | 727 MockDownloadItemObserver observer; |
| 728 items[0]->AddObserver(&observer); | 728 items[0]->AddObserver(&observer); |
| 729 EXPECT_CALL(observer, OnDownloadDestroyed(items[0])); | 729 EXPECT_CALL(observer, OnDownloadDestroyed(items[0])); |
| 730 | 730 |
| 731 // Shutdown the download manager. Mostly this is confirming a lack of | 731 // Shutdown the download manager. Mostly this is confirming a lack of |
| 732 // crashes. | 732 // crashes. |
| 733 DownloadManagerForShell(shell())->Shutdown(); | 733 DownloadManagerForShell(shell())->Shutdown(); |
| 734 } | 734 } |
| 735 | 735 |
| 736 } // namespace content | 736 } // namespace content |
| OLD | NEW |