| Index: chrome/browser/safe_browsing/download_protection_service_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/safe_browsing/download_protection_service_unittest.cc (revision 106761)
|
| +++ 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,18 +44,20 @@
|
| 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(),
|
| - NULL);
|
| + download_service_ = sb_service_->download_protection_service();
|
| download_service_->SetEnabled(true);
|
| msg_loop_.RunAllPending();
|
| }
|
|
|
| virtual void TearDown() {
|
| msg_loop_.RunAllPending();
|
| - download_service_ = NULL;
|
| sb_service_ = NULL;
|
| + // Allow the DownloadProtectionService to be deleted.
|
| + msg_loop_.RunAllPending();
|
| io_thread_.reset();
|
| + file_thread_.reset();
|
| ui_thread_.reset();
|
| }
|
|
|
| @@ -81,10 +84,11 @@
|
|
|
| protected:
|
| scoped_refptr<MockSafeBrowsingService> sb_service_;
|
| - scoped_refptr<DownloadProtectionService> download_service_;
|
| + DownloadProtectionService* download_service_;
|
| 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/");
|
|
|