| 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/location.h" |
| 8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 9 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" |
| 11 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 14 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 12 #include "chrome/browser/download/download_prefs.h" | 15 #include "chrome/browser/download/download_prefs.h" |
| 13 #include "chrome/browser/download/download_target_info.h" | 16 #include "chrome/browser/download/download_target_info.h" |
| 14 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 16 #include "chrome/test/base/testing_pref_service_syncable.h" | 19 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 18 #include "content/public/browser/download_interrupt_reasons.h" | 21 #include "content/public/browser/download_interrupt_reasons.h" |
| 19 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_delegate.h" | 23 #include "content/public/browser/web_contents_delegate.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 93 |
| 91 void ReserveVirtualPath( | 94 void ReserveVirtualPath( |
| 92 content::DownloadItem* download, | 95 content::DownloadItem* download, |
| 93 const base::FilePath& virtual_path, | 96 const base::FilePath& virtual_path, |
| 94 bool create_directory, | 97 bool create_directory, |
| 95 DownloadPathReservationTracker::FilenameConflictAction conflict_action, | 98 DownloadPathReservationTracker::FilenameConflictAction conflict_action, |
| 96 const DownloadPathReservationTracker::ReservedPathCallback& callback) | 99 const DownloadPathReservationTracker::ReservedPathCallback& callback) |
| 97 override { | 100 override { |
| 98 // Pretend the path reservation succeeded without any change to | 101 // Pretend the path reservation succeeded without any change to |
| 99 // |target_path|. | 102 // |target_path|. |
| 100 base::MessageLoop::current()->PostTask( | 103 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 101 FROM_HERE, base::Bind(callback, virtual_path, true)); | 104 FROM_HERE, base::Bind(callback, virtual_path, true)); |
| 102 } | 105 } |
| 103 | 106 |
| 104 void PromptUserForDownloadPath( | 107 void PromptUserForDownloadPath( |
| 105 DownloadItem* download, | 108 DownloadItem* download, |
| 106 const base::FilePath& suggested_path, | 109 const base::FilePath& suggested_path, |
| 107 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) | 110 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) |
| 108 override { | 111 override { |
| 109 base::FilePath return_path = MockPromptUserForDownloadPath(download, | 112 base::FilePath return_path = MockPromptUserForDownloadPath(download, |
| 110 suggested_path, | 113 suggested_path, |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 CreateActiveDownloadItem(1)); | 394 CreateActiveDownloadItem(1)); |
| 392 EXPECT_CALL(*download_item, GetTargetFilePath()) | 395 EXPECT_CALL(*download_item, GetTargetFilePath()) |
| 393 .WillRepeatedly(ReturnRef(existing_path)); | 396 .WillRepeatedly(ReturnRef(existing_path)); |
| 394 EXPECT_TRUE(CheckForFileExistence(download_item.get())); | 397 EXPECT_TRUE(CheckForFileExistence(download_item.get())); |
| 395 | 398 |
| 396 download_item.reset(CreateActiveDownloadItem(1)); | 399 download_item.reset(CreateActiveDownloadItem(1)); |
| 397 EXPECT_CALL(*download_item, GetTargetFilePath()) | 400 EXPECT_CALL(*download_item, GetTargetFilePath()) |
| 398 .WillRepeatedly(ReturnRef(non_existent_path)); | 401 .WillRepeatedly(ReturnRef(non_existent_path)); |
| 399 EXPECT_FALSE(CheckForFileExistence(download_item.get())); | 402 EXPECT_FALSE(CheckForFileExistence(download_item.get())); |
| 400 } | 403 } |
| OLD | NEW |