Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
| 6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/test_simple_task_runner.h" | 9 #include "base/test/test_simple_task_runner.h" |
| 10 #include "components/safe_browsing_db/v4_database.h" | 10 #include "components/safe_browsing_db/v4_database.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 ReplaceV4Database(store_and_hash_prefixes); | 129 ReplaceV4Database(store_and_hash_prefixes); |
| 130 | 130 |
| 131 // The same URL returns |false| in the previous test because | 131 // The same URL returns |false| in the previous test because |
| 132 // v4_local_database_manager_ is enabled. | 132 // v4_local_database_manager_ is enabled. |
| 133 ForceDisableLocalDatabaseManager(); | 133 ForceDisableLocalDatabaseManager(); |
| 134 | 134 |
| 135 EXPECT_TRUE(v4_local_database_manager_->CheckBrowseUrl( | 135 EXPECT_TRUE(v4_local_database_manager_->CheckBrowseUrl( |
| 136 GURL("http://example.com/a/"), nullptr)); | 136 GURL("http://example.com/a/"), nullptr)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST_F(V4LocalDatabaseManagerTest, TestGetSeverestThreatTypeAndMetadata) { | |
| 140 FullHashInfo fhi_malware(FullHash("Malware"), GetUrlMalwareId(), | |
| 141 base::Time::Now()); | |
| 142 fhi_malware.metadata.population_id = "malware_popid"; | |
| 143 | |
| 144 FullHashInfo fhi_api(FullHash("api"), GetChromeUrlApiId(), base::Time::Now()); | |
| 145 fhi_api.metadata.population_id = "api_popid"; | |
| 146 | |
| 147 std::vector<FullHashInfo> fhis({fhi_malware, fhi_api}); | |
| 148 | |
| 149 SBThreatType result_threat_type; | |
| 150 ThreatMetadata metadata; | |
| 151 | |
| 152 V4LocalDatabaseManager::GetSeverestThreatTypeAndMetadata(&result_threat_type, | |
| 153 &metadata, fhis); | |
| 154 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, result_threat_type); | |
| 155 EXPECT_EQ("malware_popid", metadata.population_id); | |
| 156 | |
| 157 // Reversing the list has no effect. | |
| 158 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
| |
| 159 V4LocalDatabaseManager::GetSeverestThreatTypeAndMetadata(&result_threat_type, | |
| 160 &metadata, fhis); | |
| 161 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, result_threat_type); | |
| 162 EXPECT_EQ("malware_popid", metadata.population_id); | |
| 163 } | |
| 164 | |
| 139 } // namespace safe_browsing | 165 } // namespace safe_browsing |
| OLD | NEW |