Chromium Code Reviews| Index: chrome/browser/download/chrome_download_manager_delegate_unittest.cc |
| diff --git a/chrome/browser/download/chrome_download_manager_delegate_unittest.cc b/chrome/browser/download/chrome_download_manager_delegate_unittest.cc |
| index ed6f7b6df6918371a43f614a23102951aa426fcf..4109a81fb766f10b48e4da024051b9676c2ac9ab 100644 |
| --- a/chrome/browser/download/chrome_download_manager_delegate_unittest.cc |
| +++ b/chrome/browser/download/chrome_download_manager_delegate_unittest.cc |
| @@ -7,6 +7,7 @@ |
| #include <string> |
| +#include "base/command_line.h" |
| #include "base/files/file_path.h" |
| #include "base/files/file_util.h" |
| #include "base/files/scoped_temp_dir.h" |
| @@ -20,6 +21,7 @@ |
| #include "chrome/browser/download/download_item_model.h" |
| #include "chrome/browser/download/download_prefs.h" |
| #include "chrome/browser/download/download_target_info.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/common/features.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| @@ -883,6 +885,44 @@ TEST_P(ChromeDownloadManagerDelegateTestWithSafeBrowsing, CheckClientDownload) { |
| run_loop.Run(); |
| } |
| +TEST_F(ChromeDownloadManagerDelegateTestWithSafeBrowsing, |
| + TrustedSourcesPolicyNotTrusted) { |
| + GURL download_url("http://untrusted.com/best-download-ever.exe"); |
|
David Trainor- moved to gerrit
2017/06/23 07:32:47
Haha :)
MAD
2017/06/29 14:44:53
Acknowledged.
|
| + pref_service()->SetBoolean(prefs::kSafeBrowsingForTrustedSourcesEnabled, |
| + false); |
| + std::unique_ptr<content::MockDownloadItem> download_item = |
| + CreateActiveDownloadItem(0); |
| + EXPECT_CALL(*download_item, GetURL()).WillRepeatedly(ReturnRef(download_url)); |
| + |
| + EXPECT_CALL(*delegate(), GetDownloadProtectionService()); |
| + EXPECT_CALL(*download_protection_service(), MockCheckClientDownload()) |
| + .WillOnce(Return(safe_browsing::DownloadProtectionService::SAFE)); |
| + EXPECT_CALL(*download_item, GetDangerType()) |
| + .WillRepeatedly(Return(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)); |
| + |
| + base::RunLoop run_loop; |
| + ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(), |
| + run_loop.QuitClosure())); |
| + run_loop.Run(); |
| +} |
| + |
| +TEST_F(ChromeDownloadManagerDelegateTestWithSafeBrowsing, |
| + TrustedSourcesPolicyTrusted) { |
| + base::CommandLine* command_line(base::CommandLine::ForCurrentProcess()); |
| + DCHECK(command_line); |
| + command_line->AppendSwitchASCII(switches::kTrustedDownloadSources, |
| + "trusted.com"); |
| + GURL download_url("http://trusted.com/best-download-ever.exe"); |
| + pref_service()->SetBoolean(prefs::kSafeBrowsingForTrustedSourcesEnabled, |
| + false); |
| + std::unique_ptr<content::MockDownloadItem> download_item = |
| + CreateActiveDownloadItem(0); |
| + EXPECT_CALL(*download_item, GetURL()).WillRepeatedly(ReturnRef(download_url)); |
| + EXPECT_CALL(*delegate(), GetDownloadProtectionService()).Times(0); |
| + EXPECT_TRUE( |
| + delegate()->ShouldCompleteDownload(download_item.get(), base::Closure())); |
| +} |
| + |
| #endif // FULL_SAFE_BROWSING |
| #if defined(OS_ANDROID) |