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

Side by Side Diff: chrome/browser/password_manager/password_store_x_unittest.cc

Issue 6905044: Refactor preference syncing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the previous fix Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_temp_dir.h" 6 #include "base/memory/scoped_temp_dir.h"
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 466
467 // The WDS schedules tasks to run on the DB thread so we schedule yet another 467 // The WDS schedules tasks to run on the DB thread so we schedule yet another
468 // task to notify us that it's safe to carry on with the test. 468 // task to notify us that it's safe to carry on with the test.
469 WaitableEvent done(false, false); 469 WaitableEvent done(false, false);
470 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 470 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
471 new SignalingTask(&done)); 471 new SignalingTask(&done));
472 done.Wait(); 472 done.Wait();
473 473
474 // Prentend that the migration has already taken place. 474 // Prentend that the migration has already taken place.
475 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, 475 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated,
476 true); 476 true,
477 false /* don't sync pref */);
477 478
478 // Initializing the PasswordStore shouldn't trigger a migration. 479 // Initializing the PasswordStore shouldn't trigger a migration.
479 scoped_refptr<PasswordStoreX> store( 480 scoped_refptr<PasswordStoreX> store(
480 new PasswordStoreX(login_db_.release(), 481 new PasswordStoreX(login_db_.release(),
481 profile_.get(), 482 profile_.get(),
482 wds_.get(), 483 wds_.get(),
483 GetBackend())); 484 GetBackend()));
484 store->Init(); 485 store->Init();
485 486
486 MockPasswordStoreConsumer consumer; 487 MockPasswordStoreConsumer consumer;
(...skipping 10 matching lines...) Expand all
497 498
498 store->GetAutofillableLogins(&consumer); 499 store->GetAutofillableLogins(&consumer);
499 MessageLoop::current()->Run(); 500 MessageLoop::current()->Run();
500 501
501 STLDeleteElements(&unexpected_autofillable); 502 STLDeleteElements(&unexpected_autofillable);
502 } 503 }
503 504
504 TEST_P(PasswordStoreXTest, Notifications) { 505 TEST_P(PasswordStoreXTest, Notifications) {
505 // Pretend that the migration has already taken place. 506 // Pretend that the migration has already taken place.
506 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, 507 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated,
507 true); 508 true,
509 false /* don't sync pref */);
508 510
509 // Initializing the PasswordStore shouldn't trigger a migration. 511 // Initializing the PasswordStore shouldn't trigger a migration.
510 scoped_refptr<PasswordStoreX> store( 512 scoped_refptr<PasswordStoreX> store(
511 new PasswordStoreX(login_db_.release(), 513 new PasswordStoreX(login_db_.release(),
512 profile_.get(), 514 profile_.get(),
513 wds_.get(), 515 wds_.get(),
514 GetBackend())); 516 GetBackend()));
515 store->Init(); 517 store->Init();
516 518
517 PasswordFormData form_data = 519 PasswordFormData form_data =
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 new SignalingTask(&done)); 635 new SignalingTask(&done));
634 done.Wait(); 636 done.Wait();
635 637
636 // Get the new size of the login DB file. We expect it to be larger. 638 // Get the new size of the login DB file. We expect it to be larger.
637 base::PlatformFileInfo db_file_full_info; 639 base::PlatformFileInfo db_file_full_info;
638 ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_full_info)); 640 ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_full_info));
639 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); 641 EXPECT_GT(db_file_full_info.size, db_file_start_info.size);
640 642
641 // Pretend that the WDS migration has already taken place. 643 // Pretend that the WDS migration has already taken place.
642 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, 644 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated,
643 true); 645 true,
646 false /* don't sync pref */);
644 647
645 // Initializing the PasswordStore shouldn't trigger a native migration (yet). 648 // Initializing the PasswordStore shouldn't trigger a native migration (yet).
646 scoped_refptr<PasswordStoreX> store( 649 scoped_refptr<PasswordStoreX> store(
647 new PasswordStoreX(login_db_.release(), 650 new PasswordStoreX(login_db_.release(),
648 profile_.get(), 651 profile_.get(),
649 wds_.get(), 652 wds_.get(),
650 GetBackend())); 653 GetBackend()));
651 store->Init(); 654 store->Init();
652 655
653 MockPasswordStoreConsumer consumer; 656 MockPasswordStoreConsumer consumer;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 737
735 INSTANTIATE_TEST_CASE_P(NoBackend, 738 INSTANTIATE_TEST_CASE_P(NoBackend,
736 PasswordStoreXTest, 739 PasswordStoreXTest,
737 testing::Values(NO_BACKEND)); 740 testing::Values(NO_BACKEND));
738 INSTANTIATE_TEST_CASE_P(FailingBackend, 741 INSTANTIATE_TEST_CASE_P(FailingBackend,
739 PasswordStoreXTest, 742 PasswordStoreXTest,
740 testing::Values(FAILING_BACKEND)); 743 testing::Values(FAILING_BACKEND));
741 INSTANTIATE_TEST_CASE_P(WorkingBackend, 744 INSTANTIATE_TEST_CASE_P(WorkingBackend,
742 PasswordStoreXTest, 745 PasswordStoreXTest,
743 testing::Values(WORKING_BACKEND)); 746 testing::Values(WORKING_BACKEND));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698