| Index: chrome/browser/safe_browsing/local_database_manager_unittest.cc
|
| diff --git a/chrome/browser/safe_browsing/local_database_manager_unittest.cc b/chrome/browser/safe_browsing/local_database_manager_unittest.cc
|
| index 5ea449d2140c04639caeaa9787fcca294b5d2aae..96f32363aa11bb75661b40fc25d5a91a984ebfb3 100644
|
| --- a/chrome/browser/safe_browsing/local_database_manager_unittest.cc
|
| +++ b/chrome/browser/safe_browsing/local_database_manager_unittest.cc
|
| @@ -149,6 +149,9 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
|
| const GURL kUnwantedUrl("http://www.unwanted.com/page.html");
|
| const GURL kUnwantedAndMalwareUrl(
|
| "http://www.unwantedandmalware.com/page.html");
|
| + const GURL kBlacklistedResourceUrl("http://www.blacklisted.com/script.js");
|
| + const GURL kUnwantedResourceUrl("http://www.unwantedresource.com/script.js");
|
| + const GURL kMalwareResourceUrl("http://www.malwareresource.com/script.js");
|
| const GURL kSafeUrl("http://www.safe.com/page.html");
|
|
|
| const SBFullHash kMalwareHostHash = SBFullHashForString("malware.com/");
|
| @@ -156,6 +159,12 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
|
| const SBFullHash kUnwantedHostHash = SBFullHashForString("unwanted.com/");
|
| const SBFullHash kUnwantedAndMalwareHostHash =
|
| SBFullHashForString("unwantedandmalware.com/");
|
| + const SBFullHash kBlacklistedResourceHostHash =
|
| + SBFullHashForString("blacklisted.com/");
|
| + const SBFullHash kUnwantedResourceHostHash =
|
| + SBFullHashForString("unwantedresource.com/");
|
| + const SBFullHash kMalwareResourceHostHash =
|
| + SBFullHashForString("malwareresource.com/");
|
| const SBFullHash kSafeHostHash = SBFullHashForString("www.safe.com/");
|
|
|
| {
|
| @@ -180,6 +189,13 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
|
| }
|
|
|
| {
|
| + SBFullHashResult full_hash;
|
| + full_hash.hash = kBlacklistedResourceHostHash;
|
| + full_hash.list_id = static_cast<int>(RESOURCEBLACKLIST);
|
| + full_hashes.push_back(full_hash);
|
| + }
|
| +
|
| + {
|
| // Add both MALWARE and UNWANTEDURL list IDs for
|
| // kUnwantedAndMalwareHostHash.
|
| SBFullHashResult full_hash_malware;
|
| @@ -193,6 +209,26 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
|
| full_hashes.push_back(full_hash_unwanted);
|
| }
|
|
|
| + {
|
| + SBFullHashResult full_hash_unwanted =
|
| + {kUnwantedResourceHostHash, static_cast<int>(UNWANTEDURL)};
|
| + full_hashes.push_back(full_hash_unwanted);
|
| +
|
| + SBFullHashResult full_hash_resource =
|
| + {kUnwantedResourceHostHash, static_cast<int>(RESOURCEBLACKLIST)};
|
| + full_hashes.push_back(full_hash_resource);
|
| + }
|
| +
|
| + {
|
| + SBFullHashResult full_hash_malware =
|
| + {kMalwareResourceHostHash, static_cast<int>(MALWARE)};
|
| + full_hashes.push_back(full_hash_malware);
|
| +
|
| + SBFullHashResult full_hash_resource =
|
| + {kMalwareResourceHostHash, static_cast<int>(RESOURCEBLACKLIST)};
|
| + full_hashes.push_back(full_hash_resource);
|
| + }
|
| +
|
| EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE,
|
| LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
|
| kMalwareHostHash, full_hashes));
|
| @@ -209,6 +245,18 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
|
| LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
|
| kUnwantedAndMalwareHostHash, full_hashes));
|
|
|
| + EXPECT_EQ(SB_THREAT_TYPE_BLACKLISTED_RESOURCE,
|
| + LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
|
| + kBlacklistedResourceHostHash, full_hashes));
|
| +
|
| + EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED,
|
| + LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
|
| + kUnwantedResourceHostHash, full_hashes));
|
| +
|
| + EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE,
|
| + LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
|
| + kMalwareResourceHostHash, full_hashes));
|
| +
|
| EXPECT_EQ(SB_THREAT_TYPE_SAFE,
|
| LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
|
| kSafeHostHash, full_hashes));
|
| @@ -230,10 +278,25 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
|
| kUnwantedUrl, full_hashes, &index));
|
| EXPECT_EQ(2U, index);
|
|
|
| + EXPECT_EQ(SB_THREAT_TYPE_BLACKLISTED_RESOURCE,
|
| + LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType(
|
| + kBlacklistedResourceUrl, full_hashes, &index));
|
| + EXPECT_EQ(3U, index);
|
| +
|
| EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE,
|
| LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType(
|
| kUnwantedAndMalwareUrl, full_hashes, &index));
|
| - EXPECT_EQ(3U, index);
|
| + EXPECT_EQ(4U, index);
|
| +
|
| + EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED,
|
| + LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType(
|
| + kUnwantedResourceUrl, full_hashes, &index));
|
| + EXPECT_EQ(6U, index);
|
| +
|
| + EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE,
|
| + LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType(
|
| + kMalwareResourceUrl, full_hashes, &index));
|
| + EXPECT_EQ(8U, index);
|
|
|
| index = kArbitraryValue;
|
| EXPECT_EQ(SB_THREAT_TYPE_SAFE,
|
|
|