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

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

Issue 2425703004: Destroy store on task runner. That's where all store operations happen. (Closed)
Patch Set: shess@feedback. WaitForTasksOnTaskRunner at the end of the test that calls ApplyUpdate and expects … 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
« no previous file with comments | « components/safe_browsing_db/v4_database.cc ('k') | components/safe_browsing_db/v4_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 new_store_map->at(identifier).get()); 180 new_store_map->at(identifier).get());
181 } 181 }
182 } 182 }
183 } 183 }
184 184
185 void VerifyChecksumCallback(const std::vector<ListIdentifier>& stores) { 185 void VerifyChecksumCallback(const std::vector<ListIdentifier>& stores) {
186 EXPECT_FALSE(verify_checksum_called_back_); 186 EXPECT_FALSE(verify_checksum_called_back_);
187 verify_checksum_called_back_ = true; 187 verify_checksum_called_back_ = true;
188 } 188 }
189 189
190 void WaitForTasksOnTaskRunner() {
191 task_runner_->RunPendingTasks();
192 base::RunLoop().RunUntilIdle();
193 }
194
190 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 195 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
191 std::unique_ptr<V4Database> v4_database_; 196 std::unique_ptr<V4Database> v4_database_;
192 base::FilePath database_dirname_; 197 base::FilePath database_dirname_;
193 base::ScopedTempDir temp_dir_; 198 base::ScopedTempDir temp_dir_;
194 content::TestBrowserThreadBundle thread_bundle_; 199 content::TestBrowserThreadBundle thread_bundle_;
195 bool created_but_not_called_back_; 200 bool created_but_not_called_back_;
196 bool created_and_called_back_; 201 bool created_and_called_back_;
197 bool verify_checksum_called_back_; 202 bool verify_checksum_called_back_;
198 ListInfos list_infos_; 203 ListInfos list_infos_;
199 std::vector<ListIdentifier> expected_identifiers_; 204 std::vector<ListIdentifier> expected_identifiers_;
200 std::vector<base::FilePath> expected_store_paths_; 205 std::vector<base::FilePath> expected_store_paths_;
201 std::unique_ptr<FakeV4StoreFactory> factory_; 206 std::unique_ptr<FakeV4StoreFactory> factory_;
202 DatabaseUpdatedCallback callback_db_updated_; 207 DatabaseUpdatedCallback callback_db_updated_;
203 NewDatabaseReadyCallback callback_db_ready_; 208 NewDatabaseReadyCallback callback_db_ready_;
204 StoreStateMap expected_store_state_map_; 209 StoreStateMap expected_store_state_map_;
205 base::hash_map<ListIdentifier, V4Store*> old_stores_map_; 210 base::hash_map<ListIdentifier, V4Store*> old_stores_map_;
206 const ListIdentifier linux_malware_id_, win_malware_id_; 211 const ListIdentifier linux_malware_id_, win_malware_id_;
207 }; 212 };
208 213
209 // Test to set up the database with fake stores. 214 // Test to set up the database with fake stores.
210 TEST_F(V4DatabaseTest, TestSetupDatabaseWithFakeStores) { 215 TEST_F(V4DatabaseTest, TestSetupDatabaseWithFakeStores) {
211 RegisterFactory(); 216 RegisterFactory();
212 217
213 V4Database::Create(task_runner_, database_dirname_, list_infos_, 218 V4Database::Create(task_runner_, database_dirname_, list_infos_,
214 callback_db_ready_); 219 callback_db_ready_);
215 created_but_not_called_back_ = true; 220 created_but_not_called_back_ = true;
216 task_runner_->RunPendingTasks(); 221 WaitForTasksOnTaskRunner();
217
218 base::RunLoop().RunUntilIdle();
219 EXPECT_EQ(true, created_and_called_back_); 222 EXPECT_EQ(true, created_and_called_back_);
220 } 223 }
221 224
222 // Test to check database updates as expected. 225 // Test to check database updates as expected.
223 TEST_F(V4DatabaseTest, TestApplyUpdateWithNewStates) { 226 TEST_F(V4DatabaseTest, TestApplyUpdateWithNewStates) {
224 RegisterFactory(); 227 RegisterFactory();
225 228
226 V4Database::Create(task_runner_, database_dirname_, list_infos_, 229 V4Database::Create(task_runner_, database_dirname_, list_infos_,
227 callback_db_ready_); 230 callback_db_ready_);
228 created_but_not_called_back_ = true; 231 created_but_not_called_back_ = true;
229 task_runner_->RunPendingTasks(); 232 WaitForTasksOnTaskRunner();
230 base::RunLoop().RunUntilIdle();
231 233
232 // The database has now been created. Time to try to update it. 234 // The database has now been created. Time to try to update it.
233 EXPECT_TRUE(v4_database_); 235 EXPECT_TRUE(v4_database_);
234 const StoreMap* db_stores = v4_database_->store_map_.get(); 236 const StoreMap* db_stores = v4_database_->store_map_.get();
235 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); 237 EXPECT_EQ(expected_store_paths_.size(), db_stores->size());
236 for (const auto& store_iter : *db_stores) { 238 for (const auto& store_iter : *db_stores) {
237 V4Store* store = store_iter.second.get(); 239 V4Store* store = store_iter.second.get();
238 expected_store_state_map_[store_iter.first] = store->state() + "_fake"; 240 expected_store_state_map_[store_iter.first] = store->state() + "_fake";
239 old_stores_map_[store_iter.first] = store; 241 old_stores_map_[store_iter.first] = store;
240 } 242 }
241 243
242 v4_database_->ApplyUpdate( 244 v4_database_->ApplyUpdate(
243 CreateFakeServerResponse(expected_store_state_map_, true), 245 CreateFakeServerResponse(expected_store_state_map_, true),
244 callback_db_updated_); 246 callback_db_updated_);
245 247
246 task_runner_->RunPendingTasks(); 248 // Wait for the ApplyUpdate callback to get called.
247 base::RunLoop().RunUntilIdle(); 249 WaitForTasksOnTaskRunner();
248 250
249 VerifyExpectedStoresState(true); 251 VerifyExpectedStoresState(true);
252
253 // Wait for the old stores to get destroyed on task runner.
254 WaitForTasksOnTaskRunner();
250 } 255 }
251 256
252 // Test to ensure no state updates leads to no store updates. 257 // Test to ensure no state updates leads to no store updates.
253 TEST_F(V4DatabaseTest, TestApplyUpdateWithNoNewState) { 258 TEST_F(V4DatabaseTest, TestApplyUpdateWithNoNewState) {
254 RegisterFactory(); 259 RegisterFactory();
255 260
256 V4Database::Create(task_runner_, database_dirname_, list_infos_, 261 V4Database::Create(task_runner_, database_dirname_, list_infos_,
257 callback_db_ready_); 262 callback_db_ready_);
258 created_but_not_called_back_ = true; 263 created_but_not_called_back_ = true;
259 task_runner_->RunPendingTasks(); 264 WaitForTasksOnTaskRunner();
260 base::RunLoop().RunUntilIdle();
261 265
262 // The database has now been created. Time to try to update it. 266 // The database has now been created. Time to try to update it.
263 EXPECT_TRUE(v4_database_); 267 EXPECT_TRUE(v4_database_);
264 const StoreMap* db_stores = v4_database_->store_map_.get(); 268 const StoreMap* db_stores = v4_database_->store_map_.get();
265 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); 269 EXPECT_EQ(expected_store_paths_.size(), db_stores->size());
266 for (const auto& store_iter : *db_stores) { 270 for (const auto& store_iter : *db_stores) {
267 V4Store* store = store_iter.second.get(); 271 V4Store* store = store_iter.second.get();
268 expected_store_state_map_[store_iter.first] = store->state(); 272 expected_store_state_map_[store_iter.first] = store->state();
269 old_stores_map_[store_iter.first] = store; 273 old_stores_map_[store_iter.first] = store;
270 } 274 }
271 275
272 v4_database_->ApplyUpdate( 276 v4_database_->ApplyUpdate(
273 CreateFakeServerResponse(expected_store_state_map_, true), 277 CreateFakeServerResponse(expected_store_state_map_, true),
274 callback_db_updated_); 278 callback_db_updated_);
275 279
276 task_runner_->RunPendingTasks(); 280 WaitForTasksOnTaskRunner();
277 base::RunLoop().RunUntilIdle();
278 281
279 VerifyExpectedStoresState(false); 282 VerifyExpectedStoresState(false);
280 } 283 }
281 284
282 // Test to ensure no updates leads to no store updates. 285 // Test to ensure no updates leads to no store updates.
283 TEST_F(V4DatabaseTest, TestApplyUpdateWithEmptyUpdate) { 286 TEST_F(V4DatabaseTest, TestApplyUpdateWithEmptyUpdate) {
284 RegisterFactory(); 287 RegisterFactory();
285 288
286 V4Database::Create(task_runner_, database_dirname_, list_infos_, 289 V4Database::Create(task_runner_, database_dirname_, list_infos_,
287 callback_db_ready_); 290 callback_db_ready_);
288 created_but_not_called_back_ = true; 291 created_but_not_called_back_ = true;
289 task_runner_->RunPendingTasks(); 292 WaitForTasksOnTaskRunner();
290 base::RunLoop().RunUntilIdle();
291 293
292 // The database has now been created. Time to try to update it. 294 // The database has now been created. Time to try to update it.
293 EXPECT_TRUE(v4_database_); 295 EXPECT_TRUE(v4_database_);
294 const StoreMap* db_stores = v4_database_->store_map_.get(); 296 const StoreMap* db_stores = v4_database_->store_map_.get();
295 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); 297 EXPECT_EQ(expected_store_paths_.size(), db_stores->size());
296 for (const auto& store_iter : *db_stores) { 298 for (const auto& store_iter : *db_stores) {
297 V4Store* store = store_iter.second.get(); 299 V4Store* store = store_iter.second.get();
298 expected_store_state_map_[store_iter.first] = store->state(); 300 expected_store_state_map_[store_iter.first] = store->state();
299 old_stores_map_[store_iter.first] = store; 301 old_stores_map_[store_iter.first] = store;
300 } 302 }
301 303
302 std::unique_ptr<ParsedServerResponse> parsed_server_response( 304 std::unique_ptr<ParsedServerResponse> parsed_server_response(
303 new ParsedServerResponse); 305 new ParsedServerResponse);
304 v4_database_->ApplyUpdate(std::move(parsed_server_response), 306 v4_database_->ApplyUpdate(std::move(parsed_server_response),
305 callback_db_updated_); 307 callback_db_updated_);
306 308
307 task_runner_->RunPendingTasks(); 309 WaitForTasksOnTaskRunner();
308 base::RunLoop().RunUntilIdle();
309 310
310 VerifyExpectedStoresState(false); 311 VerifyExpectedStoresState(false);
311 } 312 }
312 313
313 // Test to ensure invalid update leads to no store changes. 314 // Test to ensure invalid update leads to no store changes.
314 TEST_F(V4DatabaseTest, TestApplyUpdateWithInvalidUpdate) { 315 TEST_F(V4DatabaseTest, TestApplyUpdateWithInvalidUpdate) {
315 RegisterFactory(); 316 RegisterFactory();
316 317
317 V4Database::Create(task_runner_, database_dirname_, list_infos_, 318 V4Database::Create(task_runner_, database_dirname_, list_infos_,
318 callback_db_ready_); 319 callback_db_ready_);
319 created_but_not_called_back_ = true; 320 created_but_not_called_back_ = true;
320 task_runner_->RunPendingTasks(); 321 WaitForTasksOnTaskRunner();
321 base::RunLoop().RunUntilIdle();
322 322
323 // The database has now been created. Time to try to update it. 323 // The database has now been created. Time to try to update it.
324 EXPECT_TRUE(v4_database_); 324 EXPECT_TRUE(v4_database_);
325 const StoreMap* db_stores = v4_database_->store_map_.get(); 325 const StoreMap* db_stores = v4_database_->store_map_.get();
326 EXPECT_EQ(expected_store_paths_.size(), db_stores->size()); 326 EXPECT_EQ(expected_store_paths_.size(), db_stores->size());
327 for (const auto& store_iter : *db_stores) { 327 for (const auto& store_iter : *db_stores) {
328 V4Store* store = store_iter.second.get(); 328 V4Store* store = store_iter.second.get();
329 expected_store_state_map_[store_iter.first] = store->state(); 329 expected_store_state_map_[store_iter.first] = store->state();
330 old_stores_map_[store_iter.first] = store; 330 old_stores_map_[store_iter.first] = store;
331 } 331 }
332 332
333 v4_database_->ApplyUpdate( 333 v4_database_->ApplyUpdate(
334 CreateFakeServerResponse(expected_store_state_map_, false), 334 CreateFakeServerResponse(expected_store_state_map_, false),
335 callback_db_updated_); 335 callback_db_updated_);
336 task_runner_->RunPendingTasks(); 336 WaitForTasksOnTaskRunner();
337 base::RunLoop().RunUntilIdle();
338 337
339 VerifyExpectedStoresState(false); 338 VerifyExpectedStoresState(false);
340 } 339 }
341 340
342 // Test to ensure the case that all stores match a given full hash. 341 // Test to ensure the case that all stores match a given full hash.
343 TEST_F(V4DatabaseTest, TestAllStoresMatchFullHash) { 342 TEST_F(V4DatabaseTest, TestAllStoresMatchFullHash) {
344 bool hash_prefix_matches = true; 343 bool hash_prefix_matches = true;
345 RegisterFactory(hash_prefix_matches); 344 RegisterFactory(hash_prefix_matches);
346 345
347 V4Database::Create(task_runner_, database_dirname_, list_infos_, 346 V4Database::Create(task_runner_, database_dirname_, list_infos_,
348 callback_db_ready_); 347 callback_db_ready_);
349 created_but_not_called_back_ = true; 348 created_but_not_called_back_ = true;
350 task_runner_->RunPendingTasks(); 349 WaitForTasksOnTaskRunner();
351
352 base::RunLoop().RunUntilIdle();
353 EXPECT_EQ(true, created_and_called_back_); 350 EXPECT_EQ(true, created_and_called_back_);
354 351
355 StoresToCheck stores_to_check({linux_malware_id_, win_malware_id_}); 352 StoresToCheck stores_to_check({linux_malware_id_, win_malware_id_});
356 StoreAndHashPrefixes store_and_hash_prefixes; 353 StoreAndHashPrefixes store_and_hash_prefixes;
357 v4_database_->GetStoresMatchingFullHash("anything", stores_to_check, 354 v4_database_->GetStoresMatchingFullHash("anything", stores_to_check,
358 &store_and_hash_prefixes); 355 &store_and_hash_prefixes);
359 EXPECT_EQ(2u, store_and_hash_prefixes.size()); 356 EXPECT_EQ(2u, store_and_hash_prefixes.size());
360 StoresToCheck stores_found; 357 StoresToCheck stores_found;
361 for (const auto& it : store_and_hash_prefixes) { 358 for (const auto& it : store_and_hash_prefixes) {
362 stores_found.insert(it.list_id); 359 stores_found.insert(it.list_id);
363 } 360 }
364 EXPECT_EQ(stores_to_check, stores_found); 361 EXPECT_EQ(stores_to_check, stores_found);
365 } 362 }
366 363
367 // Test to ensure the case that no stores match a given full hash. 364 // Test to ensure the case that no stores match a given full hash.
368 TEST_F(V4DatabaseTest, TestNoStoreMatchesFullHash) { 365 TEST_F(V4DatabaseTest, TestNoStoreMatchesFullHash) {
369 bool hash_prefix_matches = false; 366 bool hash_prefix_matches = false;
370 RegisterFactory(hash_prefix_matches); 367 RegisterFactory(hash_prefix_matches);
371 368
372 V4Database::Create(task_runner_, database_dirname_, list_infos_, 369 V4Database::Create(task_runner_, database_dirname_, list_infos_,
373 callback_db_ready_); 370 callback_db_ready_);
374 created_but_not_called_back_ = true; 371 created_but_not_called_back_ = true;
375 task_runner_->RunPendingTasks(); 372 WaitForTasksOnTaskRunner();
376
377 base::RunLoop().RunUntilIdle();
378 EXPECT_EQ(true, created_and_called_back_); 373 EXPECT_EQ(true, created_and_called_back_);
379 374
380 StoreAndHashPrefixes store_and_hash_prefixes; 375 StoreAndHashPrefixes store_and_hash_prefixes;
381 v4_database_->GetStoresMatchingFullHash( 376 v4_database_->GetStoresMatchingFullHash(
382 "anything", StoresToCheck({linux_malware_id_, win_malware_id_}), 377 "anything", StoresToCheck({linux_malware_id_, win_malware_id_}),
383 &store_and_hash_prefixes); 378 &store_and_hash_prefixes);
384 EXPECT_TRUE(store_and_hash_prefixes.empty()); 379 EXPECT_TRUE(store_and_hash_prefixes.empty());
385 } 380 }
386 381
387 // Test to ensure the case that some stores match a given full hash. 382 // Test to ensure the case that some stores match a given full hash.
388 TEST_F(V4DatabaseTest, TestSomeStoresMatchFullHash) { 383 TEST_F(V4DatabaseTest, TestSomeStoresMatchFullHash) {
389 // Setup stores to not match the full hash. 384 // Setup stores to not match the full hash.
390 bool hash_prefix_matches = false; 385 bool hash_prefix_matches = false;
391 RegisterFactory(hash_prefix_matches); 386 RegisterFactory(hash_prefix_matches);
392 387
393 V4Database::Create(task_runner_, database_dirname_, list_infos_, 388 V4Database::Create(task_runner_, database_dirname_, list_infos_,
394 callback_db_ready_); 389 callback_db_ready_);
395 created_but_not_called_back_ = true; 390 created_but_not_called_back_ = true;
396 task_runner_->RunPendingTasks(); 391 WaitForTasksOnTaskRunner();
397
398 base::RunLoop().RunUntilIdle();
399 EXPECT_EQ(true, created_and_called_back_); 392 EXPECT_EQ(true, created_and_called_back_);
400 393
401 // Set the store corresponding to linux_malware_id_ to match the full hash. 394 // Set the store corresponding to linux_malware_id_ to match the full hash.
402 FakeV4Store* store = static_cast<FakeV4Store*>( 395 FakeV4Store* store = static_cast<FakeV4Store*>(
403 v4_database_->store_map_->at(win_malware_id_).get()); 396 v4_database_->store_map_->at(win_malware_id_).get());
404 store->set_hash_prefix_matches(true); 397 store->set_hash_prefix_matches(true);
405 398
406 StoreAndHashPrefixes store_and_hash_prefixes; 399 StoreAndHashPrefixes store_and_hash_prefixes;
407 v4_database_->GetStoresMatchingFullHash( 400 v4_database_->GetStoresMatchingFullHash(
408 "anything", StoresToCheck({linux_malware_id_, win_malware_id_}), 401 "anything", StoresToCheck({linux_malware_id_, win_malware_id_}),
409 &store_and_hash_prefixes); 402 &store_and_hash_prefixes);
410 EXPECT_EQ(1u, store_and_hash_prefixes.size()); 403 EXPECT_EQ(1u, store_and_hash_prefixes.size());
411 EXPECT_EQ(store_and_hash_prefixes.begin()->list_id, win_malware_id_); 404 EXPECT_EQ(store_and_hash_prefixes.begin()->list_id, win_malware_id_);
412 EXPECT_FALSE(store_and_hash_prefixes.begin()->hash_prefix.empty()); 405 EXPECT_FALSE(store_and_hash_prefixes.begin()->hash_prefix.empty());
413 } 406 }
414 407
415 // Test to ensure the case that only some stores are reported to match a given 408 // Test to ensure the case that only some stores are reported to match a given
416 // full hash because of StoresToCheck. 409 // full hash because of StoresToCheck.
417 TEST_F(V4DatabaseTest, TestSomeStoresMatchFullHashBecauseOfStoresToMatch) { 410 TEST_F(V4DatabaseTest, TestSomeStoresMatchFullHashBecauseOfStoresToMatch) {
418 // Setup all stores to match the full hash. 411 // Setup all stores to match the full hash.
419 bool hash_prefix_matches = true; 412 bool hash_prefix_matches = true;
420 RegisterFactory(hash_prefix_matches); 413 RegisterFactory(hash_prefix_matches);
421 414
422 V4Database::Create(task_runner_, database_dirname_, list_infos_, 415 V4Database::Create(task_runner_, database_dirname_, list_infos_,
423 callback_db_ready_); 416 callback_db_ready_);
424 created_but_not_called_back_ = true; 417 created_but_not_called_back_ = true;
425 task_runner_->RunPendingTasks(); 418 WaitForTasksOnTaskRunner();
426
427 base::RunLoop().RunUntilIdle();
428 EXPECT_EQ(true, created_and_called_back_); 419 EXPECT_EQ(true, created_and_called_back_);
429 420
430 // Don't add win_malware_id_ to the StoresToCheck. 421 // Don't add win_malware_id_ to the StoresToCheck.
431 StoreAndHashPrefixes store_and_hash_prefixes; 422 StoreAndHashPrefixes store_and_hash_prefixes;
432 v4_database_->GetStoresMatchingFullHash( 423 v4_database_->GetStoresMatchingFullHash(
433 "anything", StoresToCheck({linux_malware_id_}), &store_and_hash_prefixes); 424 "anything", StoresToCheck({linux_malware_id_}), &store_and_hash_prefixes);
434 EXPECT_EQ(1u, store_and_hash_prefixes.size()); 425 EXPECT_EQ(1u, store_and_hash_prefixes.size());
435 EXPECT_EQ(store_and_hash_prefixes.begin()->list_id, linux_malware_id_); 426 EXPECT_EQ(store_and_hash_prefixes.begin()->list_id, linux_malware_id_);
436 EXPECT_FALSE(store_and_hash_prefixes.begin()->hash_prefix.empty()); 427 EXPECT_FALSE(store_and_hash_prefixes.begin()->hash_prefix.empty());
437 } 428 }
438 429
439 TEST_F(V4DatabaseTest, VerifyChecksumCalledAsync) { 430 TEST_F(V4DatabaseTest, VerifyChecksumCalledAsync) {
440 bool hash_prefix_matches = true; 431 bool hash_prefix_matches = true;
441 RegisterFactory(hash_prefix_matches); 432 RegisterFactory(hash_prefix_matches);
442 433
443 V4Database::Create(task_runner_, database_dirname_, list_infos_, 434 V4Database::Create(task_runner_, database_dirname_, list_infos_,
444 callback_db_ready_); 435 callback_db_ready_);
445 created_but_not_called_back_ = true; 436 created_but_not_called_back_ = true;
446 task_runner_->RunPendingTasks(); 437 WaitForTasksOnTaskRunner();
447
448 base::RunLoop().RunUntilIdle();
449 EXPECT_EQ(true, created_and_called_back_); 438 EXPECT_EQ(true, created_and_called_back_);
450 439
451 // verify_checksum_called_back_ set to false in the constructor. 440 // verify_checksum_called_back_ set to false in the constructor.
452 EXPECT_FALSE(verify_checksum_called_back_); 441 EXPECT_FALSE(verify_checksum_called_back_);
453 // Now call VerifyChecksum and pass the callback that sets 442 // Now call VerifyChecksum and pass the callback that sets
454 // verify_checksum_called_back_ to true. 443 // verify_checksum_called_back_ to true.
455 v4_database_->VerifyChecksum(base::Bind( 444 v4_database_->VerifyChecksum(base::Bind(
456 &V4DatabaseTest::VerifyChecksumCallback, base::Unretained(this))); 445 &V4DatabaseTest::VerifyChecksumCallback, base::Unretained(this)));
457 // verify_checksum_called_back_ should still be false since the checksum 446 // verify_checksum_called_back_ should still be false since the checksum
458 // verification is async. 447 // verification is async.
459 EXPECT_FALSE(verify_checksum_called_back_); 448 EXPECT_FALSE(verify_checksum_called_back_);
460 task_runner_->RunPendingTasks(); 449 WaitForTasksOnTaskRunner();
461 base::RunLoop().RunUntilIdle();
462 EXPECT_TRUE(verify_checksum_called_back_); 450 EXPECT_TRUE(verify_checksum_called_back_);
463 } 451 }
464 452
465 } // namespace safe_browsing 453 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing_db/v4_database.cc ('k') | components/safe_browsing_db/v4_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698