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

Unified Diff: components/safe_browsing_db/v4_local_database_manager_unittest.cc

Issue 2349603003: V4LDBM: Get response from GetHashManager, detect severest result (Closed)
Patch Set: git pull Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/safe_browsing_db/v4_local_database_manager_unittest.cc
diff --git a/components/safe_browsing_db/v4_local_database_manager_unittest.cc b/components/safe_browsing_db/v4_local_database_manager_unittest.cc
index 82ce7a57b9871516b67438946d2784b9c4d0c85c..dab037673699cd36effefbefe4386117eb4b634c 100644
--- a/components/safe_browsing_db/v4_local_database_manager_unittest.cc
+++ b/components/safe_browsing_db/v4_local_database_manager_unittest.cc
@@ -136,4 +136,30 @@ TEST_F(V4LocalDatabaseManagerTest,
GURL("http://example.com/a/"), nullptr));
}
+TEST_F(V4LocalDatabaseManagerTest, TestGetSeverestThreatTypeAndMetadata) {
+ FullHashInfo fhi_malware(FullHash("Malware"), GetUrlMalwareId(),
+ base::Time::Now());
+ fhi_malware.metadata.population_id = "malware_popid";
+
+ FullHashInfo fhi_api(FullHash("api"), GetChromeUrlApiId(), base::Time::Now());
+ fhi_api.metadata.population_id = "api_popid";
+
+ std::vector<FullHashInfo> fhis({fhi_malware, fhi_api});
+
+ SBThreatType result_threat_type;
+ ThreatMetadata metadata;
+
+ V4LocalDatabaseManager::GetSeverestThreatTypeAndMetadata(&result_threat_type,
+ &metadata, fhis);
+ EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, result_threat_type);
+ EXPECT_EQ("malware_popid", metadata.population_id);
+
+ // Reversing the list has no effect.
+ std::reverse(std::begin(fhis), std::end(fhis));
Scott Hess - ex-Googler 2016/09/20 21:55:56 I may not understand something, here, but a one-el
vakh (use Gerrit instead) 2016/09/21 17:43:40 The list has two elements: fhi_malware, fhi_api
Scott Hess - ex-Googler 2016/09/21 19:15:51 I swear, I checked a couple times before making th
+ V4LocalDatabaseManager::GetSeverestThreatTypeAndMetadata(&result_threat_type,
+ &metadata, fhis);
+ EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, result_threat_type);
+ EXPECT_EQ("malware_popid", metadata.population_id);
+}
+
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698