| Index: chrome/browser/safe_browsing/download_protection_service_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/safe_browsing/download_protection_service_unittest.cc (revision 106177)
|
| +++ chrome/browser/safe_browsing/download_protection_service_unittest.cc (working copy)
|
| @@ -9,6 +9,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| +#include "base/file_path.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop.h"
|
| @@ -43,8 +44,9 @@
|
| virtual void SetUp() {
|
| ui_thread_.reset(new BrowserThread(BrowserThread::UI, &msg_loop_));
|
| io_thread_.reset(new BrowserThread(BrowserThread::IO, &msg_loop_));
|
| + file_thread_.reset(new BrowserThread(BrowserThread::FILE, &msg_loop_));
|
| sb_service_ = new MockSafeBrowsingService();
|
| - download_service_ = new DownloadProtectionService(sb_service_.get(),
|
| + download_service_ = new DownloadProtectionService(sb_service_->AsWeakPtr(),
|
| NULL);
|
| download_service_->SetEnabled(true);
|
| msg_loop_.RunAllPending();
|
| @@ -55,6 +57,7 @@
|
| download_service_ = NULL;
|
| sb_service_ = NULL;
|
| io_thread_.reset();
|
| + file_thread_.reset();
|
| ui_thread_.reset();
|
| }
|
|
|
| @@ -85,6 +88,7 @@
|
| MessageLoop msg_loop_;
|
| DownloadProtectionService::DownloadCheckResult result_;
|
| scoped_ptr<BrowserThread> io_thread_;
|
| + scoped_ptr<BrowserThread> file_thread_;
|
| scoped_ptr<BrowserThread> ui_thread_;
|
| };
|
|
|
| @@ -95,6 +99,7 @@
|
| base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
|
| base::Unretained(this))));
|
| // Only http is supported for now.
|
| + info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
|
| info.download_url_chain.push_back(GURL("https://www.google.com/"));
|
| EXPECT_TRUE(download_service_->CheckClientDownload(
|
| info,
|
| @@ -109,6 +114,7 @@
|
|
|
| TEST_F(DownloadProtectionServiceTest, CheckClientDownloadWhitelistedUrl) {
|
| DownloadProtectionService::DownloadInfo info;
|
| + info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
|
| info.download_url_chain.push_back(GURL("http://www.evil.com/bla.exe"));
|
| info.download_url_chain.push_back(GURL("http://www.google.com/a.exe"));
|
| info.referrer_url = GURL("http://www.google.com/");
|
| @@ -147,6 +153,7 @@
|
| .WillRepeatedly(Return(false));
|
|
|
| DownloadProtectionService::DownloadInfo info;
|
| + info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
|
| info.download_url_chain.push_back(GURL("http://www.evil.com/a.exe"));
|
| info.referrer_url = GURL("http://www.google.com/");
|
| EXPECT_FALSE(download_service_->CheckClientDownload(
|
| @@ -167,6 +174,7 @@
|
| .WillRepeatedly(Return(false));
|
|
|
| DownloadProtectionService::DownloadInfo info;
|
| + info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
|
| info.download_url_chain.push_back(GURL("http://www.evil.com/a.exe"));
|
| info.referrer_url = GURL("http://www.google.com/");
|
| EXPECT_FALSE(download_service_->CheckClientDownload(
|
| @@ -192,6 +200,7 @@
|
| TestURLFetcherFactory factory;
|
|
|
| DownloadProtectionService::DownloadInfo info;
|
| + info.local_file = FilePath(FILE_PATH_LITERAL("bla.exe"));
|
| info.download_url_chain.push_back(GURL("http://www.google.com/"));
|
| info.download_url_chain.push_back(GURL("http://www.google.com/bla.exe"));
|
| info.referrer_url = GURL("http://www.google.com/");
|
|
|