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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/debug/leak_annotations.h" | 6 #include "base/debug/leak_annotations.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 void RegisterFactory(bool fails_first_reset, | 100 void RegisterFactory(bool fails_first_reset, |
101 bool hash_prefix_matches = true) { | 101 bool hash_prefix_matches = true) { |
102 factory_.reset( | 102 factory_.reset( |
103 new FakeV4StoreFactory(fails_first_reset, hash_prefix_matches)); | 103 new FakeV4StoreFactory(fails_first_reset, hash_prefix_matches)); |
104 V4Database::RegisterStoreFactoryForTest(factory_.get()); | 104 V4Database::RegisterStoreFactoryForTest(factory_.get()); |
105 } | 105 } |
106 | 106 |
107 void SetupInfoMapAndExpectedState() { | 107 void SetupInfoMapAndExpectedState() { |
108 store_file_name_map_[win_malware_id_] = "win_url_malware"; | 108 store_id_file_names_.emplace_back(win_malware_id_, "win_url_malware"); |
109 expected_identifiers_.push_back(win_malware_id_); | 109 expected_identifiers_.push_back(win_malware_id_); |
110 expected_store_paths_.push_back( | 110 expected_store_paths_.push_back( |
111 database_dirname_.AppendASCII("win_url_malware.fake")); | 111 database_dirname_.AppendASCII("win_url_malware.fake")); |
112 | 112 |
113 store_file_name_map_[linux_malware_id_] = "linux_url_malware"; | 113 store_id_file_names_.emplace_back(linux_malware_id_, "linux_url_malware"); |
114 expected_identifiers_.push_back(linux_malware_id_); | 114 expected_identifiers_.push_back(linux_malware_id_); |
115 expected_store_paths_.push_back( | 115 expected_store_paths_.push_back( |
116 database_dirname_.AppendASCII("linux_url_malware.fake")); | 116 database_dirname_.AppendASCII("linux_url_malware.fake")); |
117 } | 117 } |
118 | 118 |
119 void DatabaseUpdated() {} | 119 void DatabaseUpdated() {} |
120 void NewDatabaseReadyWithExpectedStorePathsAndIds( | 120 void NewDatabaseReadyWithExpectedStorePathsAndIds( |
121 std::unique_ptr<V4Database> v4_database) { | 121 std::unique_ptr<V4Database> v4_database) { |
122 ASSERT_TRUE(v4_database); | 122 ASSERT_TRUE(v4_database); |
123 ASSERT_TRUE(v4_database->store_map_); | 123 ASSERT_TRUE(v4_database->store_map_); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 196 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
197 std::unique_ptr<V4Database> v4_database_; | 197 std::unique_ptr<V4Database> v4_database_; |
198 base::FilePath database_dirname_; | 198 base::FilePath database_dirname_; |
199 base::ScopedTempDir temp_dir_; | 199 base::ScopedTempDir temp_dir_; |
200 content::TestBrowserThreadBundle thread_bundle_; | 200 content::TestBrowserThreadBundle thread_bundle_; |
201 bool created_but_not_called_back_; | 201 bool created_but_not_called_back_; |
202 bool created_and_called_back_; | 202 bool created_and_called_back_; |
203 StoreFileNameMap store_file_name_map_; | 203 StoreIdAndFileNames store_id_file_names_; |
204 std::vector<UpdateListIdentifier> expected_identifiers_; | 204 std::vector<UpdateListIdentifier> expected_identifiers_; |
205 std::vector<base::FilePath> expected_store_paths_; | 205 std::vector<base::FilePath> expected_store_paths_; |
206 bool expected_resets_successfully_; | 206 bool expected_resets_successfully_; |
207 std::unique_ptr<FakeV4StoreFactory> factory_; | 207 std::unique_ptr<FakeV4StoreFactory> factory_; |
208 DatabaseUpdatedCallback callback_db_updated_; | 208 DatabaseUpdatedCallback callback_db_updated_; |
209 NewDatabaseReadyCallback callback_db_ready_; | 209 NewDatabaseReadyCallback callback_db_ready_; |
210 StoreStateMap expected_store_state_map_; | 210 StoreStateMap expected_store_state_map_; |
211 base::hash_map<UpdateListIdentifier, V4Store*> old_stores_map_; | 211 base::hash_map<UpdateListIdentifier, V4Store*> old_stores_map_; |
212 const UpdateListIdentifier linux_malware_id_, win_malware_id_; | 212 const UpdateListIdentifier linux_malware_id_, win_malware_id_; |
213 }; | 213 }; |
214 | 214 |
215 // Test to set up the database with fake stores. | 215 // Test to set up the database with fake stores. |
216 TEST_F(V4DatabaseTest, TestSetupDatabaseWithFakeStores) { | 216 TEST_F(V4DatabaseTest, TestSetupDatabaseWithFakeStores) { |
217 expected_resets_successfully_ = true; | 217 expected_resets_successfully_ = true; |
218 RegisterFactory(!expected_resets_successfully_); | 218 RegisterFactory(!expected_resets_successfully_); |
219 | 219 |
220 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 220 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
221 callback_db_ready_); | 221 callback_db_ready_); |
222 created_but_not_called_back_ = true; | 222 created_but_not_called_back_ = true; |
223 task_runner_->RunPendingTasks(); | 223 task_runner_->RunPendingTasks(); |
224 | 224 |
225 base::RunLoop().RunUntilIdle(); | 225 base::RunLoop().RunUntilIdle(); |
226 EXPECT_EQ(true, created_and_called_back_); | 226 EXPECT_EQ(true, created_and_called_back_); |
227 } | 227 } |
228 | 228 |
229 // Test to set up the database with fake stores that fail to reset. | 229 // Test to set up the database with fake stores that fail to reset. |
230 TEST_F(V4DatabaseTest, TestSetupDatabaseWithFakeStoresFailsReset) { | 230 TEST_F(V4DatabaseTest, TestSetupDatabaseWithFakeStoresFailsReset) { |
231 expected_resets_successfully_ = false; | 231 expected_resets_successfully_ = false; |
232 RegisterFactory(!expected_resets_successfully_); | 232 RegisterFactory(!expected_resets_successfully_); |
233 | 233 |
234 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 234 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
235 callback_db_ready_); | 235 callback_db_ready_); |
236 created_but_not_called_back_ = true; | 236 created_but_not_called_back_ = true; |
237 task_runner_->RunPendingTasks(); | 237 task_runner_->RunPendingTasks(); |
238 | 238 |
239 base::RunLoop().RunUntilIdle(); | 239 base::RunLoop().RunUntilIdle(); |
240 EXPECT_EQ(true, created_and_called_back_); | 240 EXPECT_EQ(true, created_and_called_back_); |
241 } | 241 } |
242 | 242 |
243 // Test to check database updates as expected. | 243 // Test to check database updates as expected. |
244 TEST_F(V4DatabaseTest, TestApplyUpdateWithNewStates) { | 244 TEST_F(V4DatabaseTest, TestApplyUpdateWithNewStates) { |
245 expected_resets_successfully_ = true; | 245 expected_resets_successfully_ = true; |
246 RegisterFactory(!expected_resets_successfully_); | 246 RegisterFactory(!expected_resets_successfully_); |
247 | 247 |
248 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 248 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
249 callback_db_ready_); | 249 callback_db_ready_); |
250 created_but_not_called_back_ = true; | 250 created_but_not_called_back_ = true; |
251 task_runner_->RunPendingTasks(); | 251 task_runner_->RunPendingTasks(); |
252 base::RunLoop().RunUntilIdle(); | 252 base::RunLoop().RunUntilIdle(); |
253 | 253 |
254 // The database has now been created. Time to try to update it. | 254 // The database has now been created. Time to try to update it. |
255 EXPECT_TRUE(v4_database_); | 255 EXPECT_TRUE(v4_database_); |
256 const StoreMap* db_stores = v4_database_->store_map_.get(); | 256 const StoreMap* db_stores = v4_database_->store_map_.get(); |
257 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); | 257 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); |
258 for (const auto& store_iter : *db_stores) { | 258 for (const auto& store_iter : *db_stores) { |
(...skipping 10 matching lines...) Expand all Loading... |
269 base::RunLoop().RunUntilIdle(); | 269 base::RunLoop().RunUntilIdle(); |
270 | 270 |
271 VerifyExpectedStoresState(true); | 271 VerifyExpectedStoresState(true); |
272 } | 272 } |
273 | 273 |
274 // Test to ensure no state updates leads to no store updates. | 274 // Test to ensure no state updates leads to no store updates. |
275 TEST_F(V4DatabaseTest, TestApplyUpdateWithNoNewState) { | 275 TEST_F(V4DatabaseTest, TestApplyUpdateWithNoNewState) { |
276 expected_resets_successfully_ = true; | 276 expected_resets_successfully_ = true; |
277 RegisterFactory(!expected_resets_successfully_); | 277 RegisterFactory(!expected_resets_successfully_); |
278 | 278 |
279 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 279 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
280 callback_db_ready_); | 280 callback_db_ready_); |
281 created_but_not_called_back_ = true; | 281 created_but_not_called_back_ = true; |
282 task_runner_->RunPendingTasks(); | 282 task_runner_->RunPendingTasks(); |
283 base::RunLoop().RunUntilIdle(); | 283 base::RunLoop().RunUntilIdle(); |
284 | 284 |
285 // The database has now been created. Time to try to update it. | 285 // The database has now been created. Time to try to update it. |
286 EXPECT_TRUE(v4_database_); | 286 EXPECT_TRUE(v4_database_); |
287 const StoreMap* db_stores = v4_database_->store_map_.get(); | 287 const StoreMap* db_stores = v4_database_->store_map_.get(); |
288 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); | 288 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); |
289 for (const auto& store_iter : *db_stores) { | 289 for (const auto& store_iter : *db_stores) { |
(...skipping 10 matching lines...) Expand all Loading... |
300 base::RunLoop().RunUntilIdle(); | 300 base::RunLoop().RunUntilIdle(); |
301 | 301 |
302 VerifyExpectedStoresState(false); | 302 VerifyExpectedStoresState(false); |
303 } | 303 } |
304 | 304 |
305 // Test to ensure no updates leads to no store updates. | 305 // Test to ensure no updates leads to no store updates. |
306 TEST_F(V4DatabaseTest, TestApplyUpdateWithEmptyUpdate) { | 306 TEST_F(V4DatabaseTest, TestApplyUpdateWithEmptyUpdate) { |
307 expected_resets_successfully_ = true; | 307 expected_resets_successfully_ = true; |
308 RegisterFactory(!expected_resets_successfully_); | 308 RegisterFactory(!expected_resets_successfully_); |
309 | 309 |
310 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 310 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
311 callback_db_ready_); | 311 callback_db_ready_); |
312 created_but_not_called_back_ = true; | 312 created_but_not_called_back_ = true; |
313 task_runner_->RunPendingTasks(); | 313 task_runner_->RunPendingTasks(); |
314 base::RunLoop().RunUntilIdle(); | 314 base::RunLoop().RunUntilIdle(); |
315 | 315 |
316 // The database has now been created. Time to try to update it. | 316 // The database has now been created. Time to try to update it. |
317 EXPECT_TRUE(v4_database_); | 317 EXPECT_TRUE(v4_database_); |
318 const StoreMap* db_stores = v4_database_->store_map_.get(); | 318 const StoreMap* db_stores = v4_database_->store_map_.get(); |
319 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); | 319 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); |
320 for (const auto& store_iter : *db_stores) { | 320 for (const auto& store_iter : *db_stores) { |
(...skipping 11 matching lines...) Expand all Loading... |
332 base::RunLoop().RunUntilIdle(); | 332 base::RunLoop().RunUntilIdle(); |
333 | 333 |
334 VerifyExpectedStoresState(false); | 334 VerifyExpectedStoresState(false); |
335 } | 335 } |
336 | 336 |
337 // Test to ensure invalid update leads to no store changes. | 337 // Test to ensure invalid update leads to no store changes. |
338 TEST_F(V4DatabaseTest, TestApplyUpdateWithInvalidUpdate) { | 338 TEST_F(V4DatabaseTest, TestApplyUpdateWithInvalidUpdate) { |
339 expected_resets_successfully_ = true; | 339 expected_resets_successfully_ = true; |
340 RegisterFactory(!expected_resets_successfully_); | 340 RegisterFactory(!expected_resets_successfully_); |
341 | 341 |
342 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 342 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
343 callback_db_ready_); | 343 callback_db_ready_); |
344 created_but_not_called_back_ = true; | 344 created_but_not_called_back_ = true; |
345 task_runner_->RunPendingTasks(); | 345 task_runner_->RunPendingTasks(); |
346 base::RunLoop().RunUntilIdle(); | 346 base::RunLoop().RunUntilIdle(); |
347 | 347 |
348 // The database has now been created. Time to try to update it. | 348 // The database has now been created. Time to try to update it. |
349 EXPECT_TRUE(v4_database_); | 349 EXPECT_TRUE(v4_database_); |
350 const StoreMap* db_stores = v4_database_->store_map_.get(); | 350 const StoreMap* db_stores = v4_database_->store_map_.get(); |
351 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); | 351 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); |
352 for (const auto& store_iter : *db_stores) { | 352 for (const auto& store_iter : *db_stores) { |
(...skipping 10 matching lines...) Expand all Loading... |
363 | 363 |
364 VerifyExpectedStoresState(false); | 364 VerifyExpectedStoresState(false); |
365 } | 365 } |
366 | 366 |
367 // Test to ensure the case that all stores match a given full hash. | 367 // Test to ensure the case that all stores match a given full hash. |
368 TEST_F(V4DatabaseTest, TestAllStoresMatchFullHash) { | 368 TEST_F(V4DatabaseTest, TestAllStoresMatchFullHash) { |
369 bool hash_prefix_matches = true; | 369 bool hash_prefix_matches = true; |
370 expected_resets_successfully_ = true; | 370 expected_resets_successfully_ = true; |
371 RegisterFactory(!expected_resets_successfully_, hash_prefix_matches); | 371 RegisterFactory(!expected_resets_successfully_, hash_prefix_matches); |
372 | 372 |
373 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 373 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
374 callback_db_ready_); | 374 callback_db_ready_); |
375 created_but_not_called_back_ = true; | 375 created_but_not_called_back_ = true; |
376 task_runner_->RunPendingTasks(); | 376 task_runner_->RunPendingTasks(); |
377 | 377 |
378 base::RunLoop().RunUntilIdle(); | 378 base::RunLoop().RunUntilIdle(); |
379 EXPECT_EQ(true, created_and_called_back_); | 379 EXPECT_EQ(true, created_and_called_back_); |
380 | 380 |
381 base::hash_set<UpdateListIdentifier> stores_to_look( | 381 std::unordered_set<UpdateListIdentifier> stores_to_look( |
382 {linux_malware_id_, win_malware_id_}); | 382 {linux_malware_id_, win_malware_id_}); |
383 StoreAndHashPrefixes store_and_hash_prefixes; | 383 StoreAndHashPrefixes store_and_hash_prefixes; |
384 v4_database_->GetStoresMatchingFullHash("anything", stores_to_look, | 384 v4_database_->GetStoresMatchingFullHash("anything", stores_to_look, |
385 &store_and_hash_prefixes); | 385 &store_and_hash_prefixes); |
386 EXPECT_EQ(2u, store_and_hash_prefixes.size()); | 386 EXPECT_EQ(2u, store_and_hash_prefixes.size()); |
387 base::hash_set<UpdateListIdentifier> stores_found; | 387 std::unordered_set<UpdateListIdentifier> stores_found; |
388 for (const auto& it : store_and_hash_prefixes) { | 388 for (const auto& it : store_and_hash_prefixes) { |
389 stores_found.insert(it.list_id); | 389 stores_found.insert(it.list_id); |
390 } | 390 } |
391 EXPECT_EQ(stores_to_look, stores_found); | 391 EXPECT_EQ(stores_to_look, stores_found); |
392 } | 392 } |
393 | 393 |
394 // Test to ensure the case that no stores match a given full hash. | 394 // Test to ensure the case that no stores match a given full hash. |
395 TEST_F(V4DatabaseTest, TestNoStoreMatchesFullHash) { | 395 TEST_F(V4DatabaseTest, TestNoStoreMatchesFullHash) { |
396 bool hash_prefix_matches = false; | 396 bool hash_prefix_matches = false; |
397 expected_resets_successfully_ = true; | 397 expected_resets_successfully_ = true; |
398 RegisterFactory(!expected_resets_successfully_, hash_prefix_matches); | 398 RegisterFactory(!expected_resets_successfully_, hash_prefix_matches); |
399 | 399 |
400 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 400 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
401 callback_db_ready_); | 401 callback_db_ready_); |
402 created_but_not_called_back_ = true; | 402 created_but_not_called_back_ = true; |
403 task_runner_->RunPendingTasks(); | 403 task_runner_->RunPendingTasks(); |
404 | 404 |
405 base::RunLoop().RunUntilIdle(); | 405 base::RunLoop().RunUntilIdle(); |
406 EXPECT_EQ(true, created_and_called_back_); | 406 EXPECT_EQ(true, created_and_called_back_); |
407 | 407 |
408 base::hash_set<UpdateListIdentifier> stores_to_look( | 408 std::unordered_set<UpdateListIdentifier> stores_to_look( |
409 {linux_malware_id_, win_malware_id_}); | 409 {linux_malware_id_, win_malware_id_}); |
410 StoreAndHashPrefixes store_and_hash_prefixes; | 410 StoreAndHashPrefixes store_and_hash_prefixes; |
411 v4_database_->GetStoresMatchingFullHash("anything", stores_to_look, | 411 v4_database_->GetStoresMatchingFullHash("anything", stores_to_look, |
412 &store_and_hash_prefixes); | 412 &store_and_hash_prefixes); |
413 EXPECT_TRUE(store_and_hash_prefixes.empty()); | 413 EXPECT_TRUE(store_and_hash_prefixes.empty()); |
414 } | 414 } |
415 | 415 |
416 // Test to ensure the case that some stores match a given full hash. | 416 // Test to ensure the case that some stores match a given full hash. |
417 TEST_F(V4DatabaseTest, TestSomeStoresMatchFullHash) { | 417 TEST_F(V4DatabaseTest, TestSomeStoresMatchFullHash) { |
418 // Setup stores to not match the full hash. | 418 // Setup stores to not match the full hash. |
419 bool hash_prefix_matches = false; | 419 bool hash_prefix_matches = false; |
420 expected_resets_successfully_ = true; | 420 expected_resets_successfully_ = true; |
421 RegisterFactory(!expected_resets_successfully_, hash_prefix_matches); | 421 RegisterFactory(!expected_resets_successfully_, hash_prefix_matches); |
422 | 422 |
423 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 423 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
424 callback_db_ready_); | 424 callback_db_ready_); |
425 created_but_not_called_back_ = true; | 425 created_but_not_called_back_ = true; |
426 task_runner_->RunPendingTasks(); | 426 task_runner_->RunPendingTasks(); |
427 | 427 |
428 base::RunLoop().RunUntilIdle(); | 428 base::RunLoop().RunUntilIdle(); |
429 EXPECT_EQ(true, created_and_called_back_); | 429 EXPECT_EQ(true, created_and_called_back_); |
430 | 430 |
431 // Set the store corresponding to linux_malware_id_ to match the full hash. | 431 // Set the store corresponding to linux_malware_id_ to match the full hash. |
432 FakeV4Store* store = static_cast<FakeV4Store*>( | 432 FakeV4Store* store = static_cast<FakeV4Store*>( |
433 v4_database_->store_map_->at(win_malware_id_).get()); | 433 v4_database_->store_map_->at(win_malware_id_).get()); |
434 store->set_hash_prefix_matches(true); | 434 store->set_hash_prefix_matches(true); |
435 | 435 |
436 base::hash_set<UpdateListIdentifier> stores_to_look( | 436 std::unordered_set<UpdateListIdentifier> stores_to_look( |
437 {linux_malware_id_, win_malware_id_}); | 437 {linux_malware_id_, win_malware_id_}); |
438 StoreAndHashPrefixes store_and_hash_prefixes; | 438 StoreAndHashPrefixes store_and_hash_prefixes; |
439 v4_database_->GetStoresMatchingFullHash("anything", stores_to_look, | 439 v4_database_->GetStoresMatchingFullHash("anything", stores_to_look, |
440 &store_and_hash_prefixes); | 440 &store_and_hash_prefixes); |
441 EXPECT_EQ(1u, store_and_hash_prefixes.size()); | 441 EXPECT_EQ(1u, store_and_hash_prefixes.size()); |
442 EXPECT_EQ(store_and_hash_prefixes.begin()->list_id, win_malware_id_); | 442 EXPECT_EQ(store_and_hash_prefixes.begin()->list_id, win_malware_id_); |
443 EXPECT_FALSE(store_and_hash_prefixes.begin()->hash_prefix.empty()); | 443 EXPECT_FALSE(store_and_hash_prefixes.begin()->hash_prefix.empty()); |
444 } | 444 } |
445 | 445 |
446 // Test to ensure the case that only some stores are reported to match a given | 446 // Test to ensure the case that only some stores are reported to match a given |
447 // full hash because of stores_to_look. | 447 // full hash because of stores_to_look. |
448 TEST_F(V4DatabaseTest, TestSomeStoresMatchFullHashBecauseOfStoresToMatch) { | 448 TEST_F(V4DatabaseTest, TestSomeStoresMatchFullHashBecauseOfStoresToMatch) { |
449 // Setup all stores to match the full hash. | 449 // Setup all stores to match the full hash. |
450 bool hash_prefix_matches = true; | 450 bool hash_prefix_matches = true; |
451 expected_resets_successfully_ = true; | 451 expected_resets_successfully_ = true; |
452 RegisterFactory(!expected_resets_successfully_, hash_prefix_matches); | 452 RegisterFactory(!expected_resets_successfully_, hash_prefix_matches); |
453 | 453 |
454 V4Database::Create(task_runner_, database_dirname_, store_file_name_map_, | 454 V4Database::Create(task_runner_, database_dirname_, store_id_file_names_, |
455 callback_db_ready_); | 455 callback_db_ready_); |
456 created_but_not_called_back_ = true; | 456 created_but_not_called_back_ = true; |
457 task_runner_->RunPendingTasks(); | 457 task_runner_->RunPendingTasks(); |
458 | 458 |
459 base::RunLoop().RunUntilIdle(); | 459 base::RunLoop().RunUntilIdle(); |
460 EXPECT_EQ(true, created_and_called_back_); | 460 EXPECT_EQ(true, created_and_called_back_); |
461 | 461 |
462 base::hash_set<UpdateListIdentifier> stores_to_look({linux_malware_id_}); | 462 std::unordered_set<UpdateListIdentifier> stores_to_look({linux_malware_id_}); |
463 // Don't add win_malware_id_ to the stores_to_look. | 463 // Don't add win_malware_id_ to the stores_to_look. |
464 StoreAndHashPrefixes store_and_hash_prefixes; | 464 StoreAndHashPrefixes store_and_hash_prefixes; |
465 v4_database_->GetStoresMatchingFullHash("anything", stores_to_look, | 465 v4_database_->GetStoresMatchingFullHash("anything", stores_to_look, |
466 &store_and_hash_prefixes); | 466 &store_and_hash_prefixes); |
467 EXPECT_EQ(1u, store_and_hash_prefixes.size()); | 467 EXPECT_EQ(1u, store_and_hash_prefixes.size()); |
468 EXPECT_EQ(store_and_hash_prefixes.begin()->list_id, linux_malware_id_); | 468 EXPECT_EQ(store_and_hash_prefixes.begin()->list_id, linux_malware_id_); |
469 EXPECT_FALSE(store_and_hash_prefixes.begin()->hash_prefix.empty()); | 469 EXPECT_FALSE(store_and_hash_prefixes.begin()->hash_prefix.empty()); |
470 } | 470 } |
471 | 471 |
472 } // namespace safe_browsing | 472 } // namespace safe_browsing |
OLD | NEW |