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

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

Issue 1726403006: Switch Safe Browsing's metadata from string to struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ParseJson in test Created 4 years, 9 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 // This test creates a safebrowsing service using test safebrowsing database 5 // This test creates a safebrowsing service using test safebrowsing database
6 // and a test protocol manager. It is used to test logics in safebrowsing 6 // and a test protocol manager. It is used to test logics in safebrowsing
7 // service. 7 // service.
8 8
9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
10 10
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 public: 698 public:
699 SafeBrowsingServiceMetadataTest() {} 699 SafeBrowsingServiceMetadataTest() {}
700 700
701 void GenUrlFullhashResultWithMetadata(const GURL& url, 701 void GenUrlFullhashResultWithMetadata(const GURL& url,
702 SBFullHashResult* full_hash) { 702 SBFullHashResult* full_hash) {
703 GenUrlFullhashResult(url, MALWARE, full_hash); 703 GenUrlFullhashResult(url, MALWARE, full_hash);
704 704
705 MalwarePatternType proto; 705 MalwarePatternType proto;
706 switch (GetParam()) { 706 switch (GetParam()) {
707 case METADATA_NONE: 707 case METADATA_NONE:
708 full_hash->metadata = std::string(); 708 full_hash->metadata.raw_metadata = std::string();
709 break; 709 break;
710 case METADATA_LANDING: 710 case METADATA_LANDING:
711 proto.set_pattern_type(MalwarePatternType::LANDING); 711 proto.set_pattern_type(MalwarePatternType::LANDING);
712 full_hash->metadata = proto.SerializeAsString(); 712 full_hash->metadata.raw_metadata = proto.SerializeAsString();
713 break; 713 break;
714 case METADATA_DISTRIBUTION: 714 case METADATA_DISTRIBUTION:
715 proto.set_pattern_type(MalwarePatternType::DISTRIBUTION); 715 proto.set_pattern_type(MalwarePatternType::DISTRIBUTION);
716 full_hash->metadata = proto.SerializeAsString(); 716 full_hash->metadata.raw_metadata = proto.SerializeAsString();
717 break; 717 break;
718 } 718 }
719 } 719 }
720 720
721 private: 721 private:
722 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceMetadataTest); 722 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceMetadataTest);
723 }; 723 };
724 724
725 IN_PROC_BROWSER_TEST_P(SafeBrowsingServiceMetadataTest, MalwareMainFrame) { 725 IN_PROC_BROWSER_TEST_P(SafeBrowsingServiceMetadataTest, MalwareMainFrame) {
726 GURL url = embedded_test_server()->GetURL(kEmptyPage); 726 GURL url = embedded_test_server()->GetURL(kEmptyPage);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 void OnCheckDownloadUrlResult(const std::vector<GURL>& /* url_chain */, 1212 void OnCheckDownloadUrlResult(const std::vector<GURL>& /* url_chain */,
1213 SBThreatType threat_type) override { 1213 SBThreatType threat_type) override {
1214 threat_type_ = threat_type; 1214 threat_type_ = threat_type;
1215 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 1215 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
1216 base::Bind(&TestSBClient::CheckDone, this)); 1216 base::Bind(&TestSBClient::CheckDone, this));
1217 } 1217 }
1218 1218
1219 // Called when the result of checking a browse URL is known. 1219 // Called when the result of checking a browse URL is known.
1220 void OnCheckBrowseUrlResult(const GURL& /* url */, 1220 void OnCheckBrowseUrlResult(const GURL& /* url */,
1221 SBThreatType threat_type, 1221 SBThreatType threat_type,
1222 const std::string& /* metadata */) override { 1222 const ThreatMetadata& /* metadata */) override {
1223 threat_type_ = threat_type; 1223 threat_type_ = threat_type;
1224 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 1224 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
1225 base::Bind(&TestSBClient::CheckDone, this)); 1225 base::Bind(&TestSBClient::CheckDone, this));
1226 } 1226 }
1227 1227
1228 // Called when the result of checking a resource URL is known. 1228 // Called when the result of checking a resource URL is known.
1229 void OnCheckResourceUrlResult(const GURL& /* url */, 1229 void OnCheckResourceUrlResult(const GURL& /* url */,
1230 SBThreatType threat_type, 1230 SBThreatType threat_type,
1231 const std::string& threat_hash) override { 1231 const std::string& threat_hash) override {
1232 threat_type_ = threat_type; 1232 threat_type_ = threat_type;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, 1749 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
1750 content::Source<SafeBrowsingDatabaseManager>( 1750 content::Source<SafeBrowsingDatabaseManager>(
1751 sb_service_->database_manager().get())); 1751 sb_service_->database_manager().get()));
1752 BrowserThread::PostTask( 1752 BrowserThread::PostTask(
1753 BrowserThread::IO, FROM_HERE, 1753 BrowserThread::IO, FROM_HERE,
1754 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); 1754 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this));
1755 observer.Wait(); 1755 observer.Wait();
1756 } 1756 }
1757 1757
1758 } // namespace safe_browsing 1758 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_parser_unittest.cc ('k') | chrome/browser/safe_browsing/safe_browsing_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698