| OLD | NEW | 
|---|
| 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 468 | 468 | 
| 469   // The WDS schedules tasks to run on the DB thread so we schedule yet another | 469   // The WDS schedules tasks to run on the DB thread so we schedule yet another | 
| 470   // task to notify us that it's safe to carry on with the test. | 470   // task to notify us that it's safe to carry on with the test. | 
| 471   WaitableEvent done(false, false); | 471   WaitableEvent done(false, false); | 
| 472   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 472   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 
| 473       new SignalingTask(&done)); | 473       new SignalingTask(&done)); | 
| 474   done.Wait(); | 474   done.Wait(); | 
| 475 | 475 | 
| 476   // Prentend that the migration has already taken place. | 476   // Prentend that the migration has already taken place. | 
| 477   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 477   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 
| 478                                             true); | 478                                             true, | 
|  | 479                                             false /* don't sync pref */); | 
| 479 | 480 | 
| 480   // Initializing the PasswordStore shouldn't trigger a migration. | 481   // Initializing the PasswordStore shouldn't trigger a migration. | 
| 481   scoped_refptr<PasswordStoreX> store( | 482   scoped_refptr<PasswordStoreX> store( | 
| 482       new PasswordStoreX(login_db_.release(), | 483       new PasswordStoreX(login_db_.release(), | 
| 483                            profile_.get(), | 484                            profile_.get(), | 
| 484                            wds_.get(), | 485                            wds_.get(), | 
| 485                            GetBackend())); | 486                            GetBackend())); | 
| 486   store->Init(); | 487   store->Init(); | 
| 487 | 488 | 
| 488   MockPasswordStoreConsumer consumer; | 489   MockPasswordStoreConsumer consumer; | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 501   MessageLoop::current()->Run(); | 502   MessageLoop::current()->Run(); | 
| 502 | 503 | 
| 503   STLDeleteElements(&unexpected_autofillable); | 504   STLDeleteElements(&unexpected_autofillable); | 
| 504 | 505 | 
| 505   store->Shutdown(); | 506   store->Shutdown(); | 
| 506 } | 507 } | 
| 507 | 508 | 
| 508 TEST_P(PasswordStoreXTest, Notifications) { | 509 TEST_P(PasswordStoreXTest, Notifications) { | 
| 509   // Pretend that the migration has already taken place. | 510   // Pretend that the migration has already taken place. | 
| 510   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 511   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 
| 511                                             true); | 512                                             true, | 
|  | 513                                             false /* don't sync pref */); | 
| 512 | 514 | 
| 513   // Initializing the PasswordStore shouldn't trigger a migration. | 515   // Initializing the PasswordStore shouldn't trigger a migration. | 
| 514   scoped_refptr<PasswordStoreX> store( | 516   scoped_refptr<PasswordStoreX> store( | 
| 515       new PasswordStoreX(login_db_.release(), | 517       new PasswordStoreX(login_db_.release(), | 
| 516                            profile_.get(), | 518                            profile_.get(), | 
| 517                            wds_.get(), | 519                            wds_.get(), | 
| 518                            GetBackend())); | 520                            GetBackend())); | 
| 519   store->Init(); | 521   store->Init(); | 
| 520 | 522 | 
| 521   PasswordFormData form_data = | 523   PasswordFormData form_data = | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 639       new SignalingTask(&done)); | 641       new SignalingTask(&done)); | 
| 640   done.Wait(); | 642   done.Wait(); | 
| 641 | 643 | 
| 642   // Get the new size of the login DB file. We expect it to be larger. | 644   // Get the new size of the login DB file. We expect it to be larger. | 
| 643   base::PlatformFileInfo db_file_full_info; | 645   base::PlatformFileInfo db_file_full_info; | 
| 644   ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_full_info)); | 646   ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_full_info)); | 
| 645   EXPECT_GT(db_file_full_info.size, db_file_start_info.size); | 647   EXPECT_GT(db_file_full_info.size, db_file_start_info.size); | 
| 646 | 648 | 
| 647   // Pretend that the WDS migration has already taken place. | 649   // Pretend that the WDS migration has already taken place. | 
| 648   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 650   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 
| 649                                             true); | 651                                             true, | 
|  | 652                                             false /* don't sync pref */); | 
| 650 | 653 | 
| 651   // Initializing the PasswordStore shouldn't trigger a native migration (yet). | 654   // Initializing the PasswordStore shouldn't trigger a native migration (yet). | 
| 652   scoped_refptr<PasswordStoreX> store( | 655   scoped_refptr<PasswordStoreX> store( | 
| 653       new PasswordStoreX(login_db_.release(), | 656       new PasswordStoreX(login_db_.release(), | 
| 654                            profile_.get(), | 657                            profile_.get(), | 
| 655                            wds_.get(), | 658                            wds_.get(), | 
| 656                            GetBackend())); | 659                            GetBackend())); | 
| 657   store->Init(); | 660   store->Init(); | 
| 658 | 661 | 
| 659   MockPasswordStoreConsumer consumer; | 662   MockPasswordStoreConsumer consumer; | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 742 | 745 | 
| 743 INSTANTIATE_TEST_CASE_P(NoBackend, | 746 INSTANTIATE_TEST_CASE_P(NoBackend, | 
| 744                         PasswordStoreXTest, | 747                         PasswordStoreXTest, | 
| 745                         testing::Values(NO_BACKEND)); | 748                         testing::Values(NO_BACKEND)); | 
| 746 INSTANTIATE_TEST_CASE_P(FailingBackend, | 749 INSTANTIATE_TEST_CASE_P(FailingBackend, | 
| 747                         PasswordStoreXTest, | 750                         PasswordStoreXTest, | 
| 748                         testing::Values(FAILING_BACKEND)); | 751                         testing::Values(FAILING_BACKEND)); | 
| 749 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 752 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 
| 750                         PasswordStoreXTest, | 753                         PasswordStoreXTest, | 
| 751                         testing::Values(WORKING_BACKEND)); | 754                         testing::Values(WORKING_BACKEND)); | 
| OLD | NEW | 
|---|