Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(659)

Side by Side Diff: components/safe_browsing_db/v4_local_database_manager_unittest.cc

Issue 2421703002: Tiny: Post PerformFullHashCheck on IO thread, instead of calling it synchronously. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698