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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/leak_annotations.h" | 8 #include "base/debug/leak_annotations.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 V4Database::Create(task_runner_, database_dirname_, list_infos_, | 461 V4Database::Create(task_runner_, database_dirname_, list_infos_, |
462 callback_db_ready_); | 462 callback_db_ready_); |
463 created_but_not_called_back_ = true; | 463 created_but_not_called_back_ = true; |
464 WaitForTasksOnTaskRunner(); | 464 WaitForTasksOnTaskRunner(); |
465 EXPECT_EQ(true, created_and_called_back_); | 465 EXPECT_EQ(true, created_and_called_back_); |
466 | 466 |
467 // Doesn't exist in out list | 467 // Doesn't exist in out list |
468 const ListIdentifier bogus_id(LINUX_PLATFORM, CHROME_EXTENSION, | 468 const ListIdentifier bogus_id(LINUX_PLATFORM, CHROME_EXTENSION, |
469 CSD_WHITELIST); | 469 CSD_WHITELIST); |
470 | 470 |
471 EXPECT_TRUE(v4_database_->AreStoresAvailable( | 471 EXPECT_TRUE(v4_database_->AreAllStoresAvailable( |
| 472 StoresToCheck({linux_malware_id_, win_malware_id_}))); |
| 473 EXPECT_TRUE(v4_database_->AreAnyStoresAvailable( |
472 StoresToCheck({linux_malware_id_, win_malware_id_}))); | 474 StoresToCheck({linux_malware_id_, win_malware_id_}))); |
473 | 475 |
474 EXPECT_FALSE(v4_database_->AreStoresAvailable( | 476 EXPECT_TRUE( |
| 477 v4_database_->AreAllStoresAvailable(StoresToCheck({linux_malware_id_}))); |
| 478 EXPECT_TRUE( |
| 479 v4_database_->AreAnyStoresAvailable(StoresToCheck({linux_malware_id_}))); |
| 480 |
| 481 EXPECT_FALSE(v4_database_->AreAllStoresAvailable( |
| 482 StoresToCheck({linux_malware_id_, bogus_id}))); |
| 483 EXPECT_TRUE(v4_database_->AreAnyStoresAvailable( |
475 StoresToCheck({linux_malware_id_, bogus_id}))); | 484 StoresToCheck({linux_malware_id_, bogus_id}))); |
476 | 485 |
477 EXPECT_FALSE(v4_database_->AreStoresAvailable(StoresToCheck({bogus_id}))); | 486 EXPECT_FALSE(v4_database_->AreAllStoresAvailable(StoresToCheck({bogus_id}))); |
478 } | 487 } |
479 | 488 |
480 // Test to ensure that the callback to the database is dropped when the database | 489 // Test to ensure that the callback to the database is dropped when the database |
481 // gets destroyed. See http://crbug.com/683147#c5 for more details. | 490 // gets destroyed. See http://crbug.com/683147#c5 for more details. |
482 TEST_F(V4DatabaseTest, UsingWeakPtrDropsCallback) { | 491 TEST_F(V4DatabaseTest, UsingWeakPtrDropsCallback) { |
483 RegisterFactory(); | 492 RegisterFactory(); |
484 | 493 |
485 // Step 1: Create the database. | 494 // Step 1: Create the database. |
486 V4Database::Create(task_runner_, database_dirname_, list_infos_, | 495 V4Database::Create(task_runner_, database_dirname_, list_infos_, |
487 callback_db_ready_); | 496 callback_db_ready_); |
(...skipping 20 matching lines...) Expand all Loading... |
508 // Step 3: Before V4Store::ApplyUpdate gets executed on the task runner, | 517 // Step 3: Before V4Store::ApplyUpdate gets executed on the task runner, |
509 // destroy the database. This posts ~V4Database() on the task runner. | 518 // destroy the database. This posts ~V4Database() on the task runner. |
510 V4Database::Destroy(std::move(v4_database_)); | 519 V4Database::Destroy(std::move(v4_database_)); |
511 | 520 |
512 // Step 4: Wait for the task runner to go to completion. The test should | 521 // Step 4: Wait for the task runner to go to completion. The test should |
513 // finish to completion and the |null_callback| should not get called. | 522 // finish to completion and the |null_callback| should not get called. |
514 WaitForTasksOnTaskRunner(); | 523 WaitForTasksOnTaskRunner(); |
515 } | 524 } |
516 | 525 |
517 } // namespace safe_browsing | 526 } // namespace safe_browsing |
OLD | NEW |