| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 WaitForTasksOnTaskRunner(); | 198 WaitForTasksOnTaskRunner(); |
| 199 net::TestURLFetcherFactory factory; | 199 net::TestURLFetcherFactory factory; |
| 200 | 200 |
| 201 StoreAndHashPrefixes store_and_hash_prefixes; | 201 StoreAndHashPrefixes store_and_hash_prefixes; |
| 202 store_and_hash_prefixes.emplace_back(GetUrlMalwareId(), HashPrefix("aaaa")); | 202 store_and_hash_prefixes.emplace_back(GetUrlMalwareId(), HashPrefix("aaaa")); |
| 203 ReplaceV4Database(store_and_hash_prefixes); | 203 ReplaceV4Database(store_and_hash_prefixes); |
| 204 | 204 |
| 205 // The fake database returns a matched hash prefix. | 205 // The fake database returns a matched hash prefix. |
| 206 EXPECT_FALSE(v4_local_database_manager_->CheckBrowseUrl( | 206 EXPECT_FALSE(v4_local_database_manager_->CheckBrowseUrl( |
| 207 GURL("http://example.com/a/"), nullptr)); | 207 GURL("http://example.com/a/"), nullptr)); |
| 208 |
| 209 // Wait for PerformFullHashCheck to complete. |
| 210 WaitForTasksOnTaskRunner(); |
| 208 } | 211 } |
| 209 | 212 |
| 210 TEST_F(V4LocalDatabaseManagerTest, | 213 TEST_F(V4LocalDatabaseManagerTest, |
| 211 TestCheckBrowseUrlReturnsNoMatchWhenDisabled) { | 214 TestCheckBrowseUrlReturnsNoMatchWhenDisabled) { |
| 212 WaitForTasksOnTaskRunner(); | 215 WaitForTasksOnTaskRunner(); |
| 213 | 216 |
| 214 // The same URL returns |false| in the previous test because | 217 // The same URL returns |false| in the previous test because |
| 215 // v4_local_database_manager_ is enabled. | 218 // v4_local_database_manager_ is enabled. |
| 216 ForceDisableLocalDatabaseManager(); | 219 ForceDisableLocalDatabaseManager(); |
| 217 | 220 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 ResetV4Database(); | 265 ResetV4Database(); |
| 263 v4_local_database_manager_->CheckBrowseUrl(url, &client); | 266 v4_local_database_manager_->CheckBrowseUrl(url, &client); |
| 264 // The database is unavailable so the check should get queued. | 267 // The database is unavailable so the check should get queued. |
| 265 EXPECT_EQ(1ul, GetQueuedChecks().size()); | 268 EXPECT_EQ(1ul, GetQueuedChecks().size()); |
| 266 | 269 |
| 267 StopLocalDatabaseManager(); | 270 StopLocalDatabaseManager(); |
| 268 EXPECT_TRUE(GetQueuedChecks().empty()); | 271 EXPECT_TRUE(GetQueuedChecks().empty()); |
| 269 } | 272 } |
| 270 | 273 |
| 271 } // namespace safe_browsing | 274 } // namespace safe_browsing |
| OLD | NEW |