| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void ChromeDownloadManagerDelegateTest::SetUp() { | 202 void ChromeDownloadManagerDelegateTest::SetUp() { |
| 203 ChromeRenderViewHostTestHarness::SetUp(); | 203 ChromeRenderViewHostTestHarness::SetUp(); |
| 204 | 204 |
| 205 CHECK(profile()); | 205 CHECK(profile()); |
| 206 delegate_.reset(new TestChromeDownloadManagerDelegate(profile())); | 206 delegate_.reset(new TestChromeDownloadManagerDelegate(profile())); |
| 207 delegate_->SetDownloadManager(download_manager_.get()); | 207 delegate_->SetDownloadManager(download_manager_.get()); |
| 208 pref_service_ = profile()->GetTestingPrefService(); | 208 pref_service_ = profile()->GetTestingPrefService(); |
| 209 web_contents()->SetDelegate(&web_contents_delegate_); | 209 web_contents()->SetDelegate(&web_contents_delegate_); |
| 210 | 210 |
| 211 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir()); | 211 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir()); |
| 212 SetDefaultDownloadPath(test_download_dir_.path()); | 212 SetDefaultDownloadPath(test_download_dir_.GetPath()); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void ChromeDownloadManagerDelegateTest::TearDown() { | 215 void ChromeDownloadManagerDelegateTest::TearDown() { |
| 216 base::RunLoop().RunUntilIdle(); | 216 base::RunLoop().RunUntilIdle(); |
| 217 delegate_->Shutdown(); | 217 delegate_->Shutdown(); |
| 218 ChromeRenderViewHostTestHarness::TearDown(); | 218 ChromeRenderViewHostTestHarness::TearDown(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void ChromeDownloadManagerDelegateTest::VerifyAndClearExpectations() { | 221 void ChromeDownloadManagerDelegateTest::VerifyAndClearExpectations() { |
| 222 ::testing::Mock::VerifyAndClearExpectations(delegate_.get()); | 222 ::testing::Mock::VerifyAndClearExpectations(delegate_.get()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 ON_CALL(*item, IsTemporary()) | 257 ON_CALL(*item, IsTemporary()) |
| 258 .WillByDefault(Return(false)); | 258 .WillByDefault(Return(false)); |
| 259 EXPECT_CALL(*download_manager_, GetDownload(id)) | 259 EXPECT_CALL(*download_manager_, GetDownload(id)) |
| 260 .WillRepeatedly(Return(item.get())); | 260 .WillRepeatedly(Return(item.get())); |
| 261 return item; | 261 return item; |
| 262 } | 262 } |
| 263 | 263 |
| 264 base::FilePath ChromeDownloadManagerDelegateTest::GetPathInDownloadDir( | 264 base::FilePath ChromeDownloadManagerDelegateTest::GetPathInDownloadDir( |
| 265 const char* relative_path) { | 265 const char* relative_path) { |
| 266 base::FilePath full_path = | 266 base::FilePath full_path = |
| 267 test_download_dir_.path().AppendASCII(relative_path); | 267 test_download_dir_.GetPath().AppendASCII(relative_path); |
| 268 return full_path.NormalizePathSeparators(); | 268 return full_path.NormalizePathSeparators(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void ChromeDownloadManagerDelegateTest::SetDefaultDownloadPath( | 271 void ChromeDownloadManagerDelegateTest::SetDefaultDownloadPath( |
| 272 const base::FilePath& path) { | 272 const base::FilePath& path) { |
| 273 pref_service_->SetFilePath(prefs::kDownloadDefaultDirectory, path); | 273 pref_service_->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
| 274 pref_service_->SetFilePath(prefs::kSaveFileDefaultDirectory, path); | 274 pref_service_->SetFilePath(prefs::kSaveFileDefaultDirectory, path); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void StoreDownloadTargetInfo(const base::Closure& closure, | 277 void StoreDownloadTargetInfo(const base::Closure& closure, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 bool result = false; | 310 bool result = false; |
| 311 delegate()->CheckForFileExistence( | 311 delegate()->CheckForFileExistence( |
| 312 download_item, | 312 download_item, |
| 313 base::Bind(&StoreBoolAndRunClosure, loop_runner.QuitClosure(), &result)); | 313 base::Bind(&StoreBoolAndRunClosure, loop_runner.QuitClosure(), &result)); |
| 314 loop_runner.Run(); | 314 loop_runner.Run(); |
| 315 return result; | 315 return result; |
| 316 } | 316 } |
| 317 | 317 |
| 318 const base::FilePath& ChromeDownloadManagerDelegateTest::default_download_path() | 318 const base::FilePath& ChromeDownloadManagerDelegateTest::default_download_path() |
| 319 const { | 319 const { |
| 320 return test_download_dir_.path(); | 320 return test_download_dir_.GetPath(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 TestChromeDownloadManagerDelegate* | 323 TestChromeDownloadManagerDelegate* |
| 324 ChromeDownloadManagerDelegateTest::delegate() { | 324 ChromeDownloadManagerDelegateTest::delegate() { |
| 325 return delegate_.get(); | 325 return delegate_.get(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 content::MockDownloadManager* | 328 content::MockDownloadManager* |
| 329 ChromeDownloadManagerDelegateTest::download_manager() { | 329 ChromeDownloadManagerDelegateTest::download_manager() { |
| 330 return download_manager_.get(); | 330 return download_manager_.get(); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 EXPECT_CALL(*download_item, OnContentCheckCompleted(_)).Times(0); | 675 EXPECT_CALL(*download_item, OnContentCheckCompleted(_)).Times(0); |
| 676 } | 676 } |
| 677 | 677 |
| 678 base::RunLoop run_loop; | 678 base::RunLoop run_loop; |
| 679 ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(), | 679 ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(), |
| 680 run_loop.QuitClosure())); | 680 run_loop.QuitClosure())); |
| 681 run_loop.Run(); | 681 run_loop.Run(); |
| 682 } | 682 } |
| 683 | 683 |
| 684 #endif // FULL_SAFE_BROWSING | 684 #endif // FULL_SAFE_BROWSING |
| OLD | NEW |