Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 2925693003: Making CSD ReportType enum consistent. (Closed)
Patch Set: Handling SBThreatType enums as well Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck* check) { 226 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck* check) {
227 check->OnSafeBrowsingResult(); 227 check->OnSafeBrowsingResult();
228 } 228 }
229 229
230 ACTION_P(CheckDownloadUrlDone, threat_type) { 230 ACTION_P(CheckDownloadUrlDone, threat_type) {
231 // TODO(nparker): Remove use of SafeBrowsingCheck and instead call 231 // TODO(nparker): Remove use of SafeBrowsingCheck and instead call
232 // client->OnCheckDownloadUrlResult(..) directly. 232 // client->OnCheckDownloadUrlResult(..) directly.
233 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck* check = 233 LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck* check =
234 new LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck( 234 new LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck(
235 arg0, std::vector<SBFullHash>(), arg1, BINURL, 235 arg0, std::vector<SBFullHash>(), arg1, BINURL,
236 std::vector<SBThreatType>(1, SB_THREAT_TYPE_BINARY_MALWARE_URL)); 236 std::vector<SBThreatType>(1, SB_THREAT_TYPE_URL_BINARY_MALWARE));
237 for (size_t i = 0; i < check->url_results.size(); ++i) 237 for (size_t i = 0; i < check->url_results.size(); ++i)
238 check->url_results[i] = threat_type; 238 check->url_results[i] = threat_type;
239 BrowserThread::PostTask( 239 BrowserThread::PostTask(
240 BrowserThread::IO, FROM_HERE, 240 BrowserThread::IO, FROM_HERE,
241 base::BindOnce(&OnSafeBrowsingResult, base::Owned(check))); 241 base::BindOnce(&OnSafeBrowsingResult, base::Owned(check)));
242 } 242 }
243 243
244 class DownloadProtectionServiceTest : public testing::Test { 244 class DownloadProtectionServiceTest : public testing::Test {
245 protected: 245 protected:
246 DownloadProtectionServiceTest() 246 DownloadProtectionServiceTest()
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 download_service_->CheckDownloadUrl( 1790 download_service_->CheckDownloadUrl(
1791 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 1791 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
1792 base::Unretained(this), run_loop.QuitClosure())); 1792 base::Unretained(this), run_loop.QuitClosure()));
1793 run_loop.Run(); 1793 run_loop.Run();
1794 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); 1794 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
1795 Mock::VerifyAndClearExpectations(sb_service_.get()); 1795 Mock::VerifyAndClearExpectations(sb_service_.get());
1796 } 1796 }
1797 { 1797 {
1798 EXPECT_CALL(*sb_service_->mock_database_manager(), 1798 EXPECT_CALL(*sb_service_->mock_database_manager(),
1799 CheckDownloadUrl(ContainerEq(url_chain), NotNull())) 1799 CheckDownloadUrl(ContainerEq(url_chain), NotNull()))
1800 .WillOnce(DoAll(CheckDownloadUrlDone(SB_THREAT_TYPE_BINARY_MALWARE_URL), 1800 .WillOnce(DoAll(CheckDownloadUrlDone(SB_THREAT_TYPE_URL_BINARY_MALWARE),
1801 Return(false))); 1801 Return(false)));
1802 RunLoop run_loop; 1802 RunLoop run_loop;
1803 download_service_->CheckDownloadUrl( 1803 download_service_->CheckDownloadUrl(
1804 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 1804 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
1805 base::Unretained(this), run_loop.QuitClosure())); 1805 base::Unretained(this), run_loop.QuitClosure()));
1806 run_loop.Run(); 1806 run_loop.Run();
1807 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 1807 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
1808 } 1808 }
1809 } 1809 }
1810 1810
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2345 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2346 base::Unretained(this), run_loop.QuitClosure())); 2346 base::Unretained(this), run_loop.QuitClosure()));
2347 run_loop.Run(); 2347 run_loop.Run();
2348 2348
2349 EXPECT_FALSE(HasClientDownloadRequest()); 2349 EXPECT_FALSE(HasClientDownloadRequest());
2350 // Overriden by flag: 2350 // Overriden by flag:
2351 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2351 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2352 } 2352 }
2353 2353
2354 } // namespace safe_browsing 2354 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service.cc ('k') | chrome/browser/safe_browsing/local_database_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698