| 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/file_util.h" | 
 |    7 #include "base/platform_file.h" | 
|    6 #include "base/scoped_temp_dir.h" |    8 #include "base/scoped_temp_dir.h" | 
|    7 #include "base/stl_util-inl.h" |    9 #include "base/stl_util-inl.h" | 
|    8 #include "base/string_util.h" |   10 #include "base/string_util.h" | 
|    9 #include "base/synchronization/waitable_event.h" |   11 #include "base/synchronization/waitable_event.h" | 
|   10 #include "base/time.h" |   12 #include "base/time.h" | 
 |   13 #include "base/utf_string_conversions.h" | 
|   11 #include "chrome/browser/password_manager/password_form_data.h" |   14 #include "chrome/browser/password_manager/password_form_data.h" | 
|   12 #include "chrome/browser/password_manager/password_store_change.h" |   15 #include "chrome/browser/password_manager/password_store_change.h" | 
 |   16 #include "chrome/browser/password_manager/password_store_consumer.h" | 
|   13 #include "chrome/browser/password_manager/password_store_x.h" |   17 #include "chrome/browser/password_manager/password_store_x.h" | 
 |   18 #include "chrome/browser/prefs/pref_service.h" | 
|   14 #include "chrome/browser/webdata/web_data_service.h" |   19 #include "chrome/browser/webdata/web_data_service.h" | 
 |   20 #include "chrome/common/chrome_notification_types.h" | 
|   15 #include "chrome/common/pref_names.h" |   21 #include "chrome/common/pref_names.h" | 
|   16 #include "chrome/test/signaling_task.h" |   22 #include "chrome/test/signaling_task.h" | 
|   17 #include "chrome/test/testing_profile.h" |   23 #include "chrome/test/testing_profile.h" | 
 |   24 #include "content/common/notification_details.h" | 
|   18 #include "content/common/notification_observer_mock.h" |   25 #include "content/common/notification_observer_mock.h" | 
|   19 #include "content/common/notification_service.h" |   26 #include "content/common/notification_registrar.h" | 
 |   27 #include "content/common/notification_source.h" | 
|   20 #include "testing/gmock/include/gmock/gmock.h" |   28 #include "testing/gmock/include/gmock/gmock.h" | 
|   21 #include "testing/gtest/include/gtest/gtest.h" |   29 #include "testing/gtest/include/gtest/gtest.h" | 
|   22  |   30  | 
|   23 using base::WaitableEvent; |   31 using base::WaitableEvent; | 
|   24 using testing::_; |   32 using testing::_; | 
|   25 using testing::DoAll; |   33 using testing::DoAll; | 
|   26 using testing::ElementsAreArray; |   34 using testing::ElementsAreArray; | 
|   27 using testing::Pointee; |   35 using testing::Pointee; | 
|   28 using testing::Property; |   36 using testing::Property; | 
|   29 using testing::WithArg; |   37 using testing::WithArg; | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|   47 }; |   55 }; | 
|   48  |   56  | 
|   49 // This class will add and remove a mock notification observer from |   57 // This class will add and remove a mock notification observer from | 
|   50 // the DB thread. |   58 // the DB thread. | 
|   51 class DBThreadObserverHelper |   59 class DBThreadObserverHelper | 
|   52     : public base::RefCountedThreadSafe<DBThreadObserverHelper, |   60     : public base::RefCountedThreadSafe<DBThreadObserverHelper, | 
|   53                                         BrowserThread::DeleteOnDBThread> { |   61                                         BrowserThread::DeleteOnDBThread> { | 
|   54  public: |   62  public: | 
|   55   DBThreadObserverHelper() : done_event_(true, false) {} |   63   DBThreadObserverHelper() : done_event_(true, false) {} | 
|   56  |   64  | 
|   57   void Init() { |   65   void Init(PasswordStore* password_store) { | 
|   58     DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |   66     DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
|   59     BrowserThread::PostTask( |   67     BrowserThread::PostTask( | 
|   60         BrowserThread::DB, |   68         BrowserThread::DB, | 
|   61         FROM_HERE, |   69         FROM_HERE, | 
|   62         NewRunnableMethod(this, &DBThreadObserverHelper::AddObserverTask)); |   70         NewRunnableMethod(this, | 
 |   71                           &DBThreadObserverHelper::AddObserverTask, | 
 |   72                           make_scoped_refptr(password_store))); | 
|   63     done_event_.Wait(); |   73     done_event_.Wait(); | 
|   64   } |   74   } | 
|   65  |   75  | 
|   66   virtual ~DBThreadObserverHelper() { |   76   virtual ~DBThreadObserverHelper() { | 
|   67     DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |   77     DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 
|   68     registrar_.RemoveAll(); |   78     registrar_.RemoveAll(); | 
|   69   } |   79   } | 
|   70  |   80  | 
|   71   NotificationObserverMock& observer() { |   81   NotificationObserverMock& observer() { | 
|   72     return observer_; |   82     return observer_; | 
|   73   } |   83   } | 
|   74  |   84  | 
|   75  protected: |   85  protected: | 
|   76   friend class base::RefCountedThreadSafe<DBThreadObserverHelper>; |   86   friend class base::RefCountedThreadSafe<DBThreadObserverHelper>; | 
|   77  |   87  | 
|   78   void AddObserverTask() { |   88   void AddObserverTask(PasswordStore* password_store) { | 
|   79     DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |   89     DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 
|   80     registrar_.Add(&observer_, |   90     registrar_.Add(&observer_, | 
|   81                    chrome::LOGINS_CHANGED, |   91                    chrome::NOTIFICATION_LOGINS_CHANGED, | 
|   82                    NotificationService::AllSources()); |   92                    Source<PasswordStore>(password_store)); | 
|   83     done_event_.Signal(); |   93     done_event_.Signal(); | 
|   84   } |   94   } | 
|   85  |   95  | 
|   86   WaitableEvent done_event_; |   96   WaitableEvent done_event_; | 
|   87   NotificationRegistrar registrar_; |   97   NotificationRegistrar registrar_; | 
|   88   NotificationObserverMock observer_; |   98   NotificationObserverMock observer_; | 
|   89 }; |   99 }; | 
|   90  |  100  | 
|   91 class FailingBackend : public PasswordStoreX::NativeBackend { |  101 class FailingBackend : public PasswordStoreX::NativeBackend { | 
|   92  public: |  102  public: | 
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  350   // The WDS schedules tasks to run on the DB thread so we schedule yet another |  360   // The WDS schedules tasks to run on the DB thread so we schedule yet another | 
|  351   // task to notify us that it's safe to carry on with the test. |  361   // task to notify us that it's safe to carry on with the test. | 
|  352   WaitableEvent done(false, false); |  362   WaitableEvent done(false, false); | 
|  353   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |  363   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 
|  354       new SignalingTask(&done)); |  364       new SignalingTask(&done)); | 
|  355   done.Wait(); |  365   done.Wait(); | 
|  356  |  366  | 
|  357   // Initializing the PasswordStore should trigger a migration. |  367   // Initializing the PasswordStore should trigger a migration. | 
|  358   scoped_refptr<PasswordStoreX> store( |  368   scoped_refptr<PasswordStoreX> store( | 
|  359       new PasswordStoreX(login_db_.release(), |  369       new PasswordStoreX(login_db_.release(), | 
|  360                            profile_.get(), |  370                          profile_.get(), | 
|  361                            wds_.get(), |  371                          wds_.get(), | 
|  362                            GetBackend())); |  372                          GetBackend())); | 
|  363   store->Init(); |  373   store->Init(); | 
|  364  |  374  | 
|  365   // Check that the migration preference has not been initialized. |  375   // Check that the migration preference has not been initialized. | 
|  366   ASSERT_TRUE(NULL == profile_->GetPrefs()->FindPreference( |  376   ASSERT_TRUE(NULL == profile_->GetPrefs()->FindPreference( | 
|  367       prefs::kLoginDatabaseMigrated)); |  377       prefs::kLoginDatabaseMigrated)); | 
|  368  |  378  | 
|  369   // Again, the WDS schedules tasks to run on the DB thread, so schedule a task |  379   // Again, the WDS schedules tasks to run on the DB thread, so schedule a task | 
|  370   // to signal us when it is safe to continue. |  380   // to signal us when it is safe to continue. | 
|  371   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |  381   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 
|  372       new SignalingTask(&done)); |  382       new SignalingTask(&done)); | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  430   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |  440   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 
|  431       new SignalingTask(&done)); |  441       new SignalingTask(&done)); | 
|  432   done.Wait(); |  442   done.Wait(); | 
|  433  |  443  | 
|  434   // Handle the callback from the WDS. |  444   // Handle the callback from the WDS. | 
|  435   MessageLoop::current()->RunAllPending(); |  445   MessageLoop::current()->RunAllPending(); | 
|  436  |  446  | 
|  437   STLDeleteElements(&expected_autofillable); |  447   STLDeleteElements(&expected_autofillable); | 
|  438   STLDeleteElements(&expected_blacklisted); |  448   STLDeleteElements(&expected_blacklisted); | 
|  439  |  449  | 
|  440   store->Shutdown(); |  450   // Public in PasswordStore, protected in PasswordStoreX. | 
 |  451   static_cast<PasswordStore*>(store)->Shutdown(); | 
|  441 } |  452 } | 
|  442  |  453  | 
|  443 TEST_P(PasswordStoreXTest, WDSMigrationAlreadyDone) { |  454 TEST_P(PasswordStoreXTest, WDSMigrationAlreadyDone) { | 
|  444   PasswordFormData wds_data[] = { |  455   PasswordFormData wds_data[] = { | 
|  445     { PasswordForm::SCHEME_HTML, |  456     { PasswordForm::SCHEME_HTML, | 
|  446       "http://bar.example.com", |  457       "http://bar.example.com", | 
|  447       "http://bar.example.com/origin", |  458       "http://bar.example.com/origin", | 
|  448       "http://bar.example.com/action", |  459       "http://bar.example.com/action", | 
|  449       L"submit_element", |  460       L"submit_element", | 
|  450       L"username_element", |  461       L"username_element", | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  466     wds_->AddLogin(**it); |  477     wds_->AddLogin(**it); | 
|  467   } |  478   } | 
|  468  |  479  | 
|  469   // The WDS schedules tasks to run on the DB thread so we schedule yet another |  480   // 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. |  481   // task to notify us that it's safe to carry on with the test. | 
|  471   WaitableEvent done(false, false); |  482   WaitableEvent done(false, false); | 
|  472   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |  483   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 
|  473       new SignalingTask(&done)); |  484       new SignalingTask(&done)); | 
|  474   done.Wait(); |  485   done.Wait(); | 
|  475  |  486  | 
|  476   // Prentend that the migration has already taken place. |  487   // Pretend that the migration has already taken place. | 
|  477   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |  488   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 
|  478                                             true, |  489                                             true, | 
|  479                                             PrefService::UNSYNCABLE_PREF); |  490                                             PrefService::UNSYNCABLE_PREF); | 
|  480  |  491  | 
|  481   // Initializing the PasswordStore shouldn't trigger a migration. |  492   // Initializing the PasswordStore shouldn't trigger a migration. | 
|  482   scoped_refptr<PasswordStoreX> store( |  493   scoped_refptr<PasswordStoreX> store( | 
|  483       new PasswordStoreX(login_db_.release(), |  494       new PasswordStoreX(login_db_.release(), | 
|  484                            profile_.get(), |  495                          profile_.get(), | 
|  485                            wds_.get(), |  496                          wds_.get(), | 
|  486                            GetBackend())); |  497                          GetBackend())); | 
|  487   store->Init(); |  498   store->Init(); | 
|  488  |  499  | 
|  489   MockPasswordStoreConsumer consumer; |  500   MockPasswordStoreConsumer consumer; | 
|  490   // Make sure we quit the MessageLoop even if the test fails. |  501   // Make sure we quit the MessageLoop even if the test fails. | 
|  491   ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) |  502   ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) | 
|  492       .WillByDefault(QuitUIMessageLoop()); |  503       .WillByDefault(QuitUIMessageLoop()); | 
|  493  |  504  | 
|  494   // No forms should be migrated. |  505   // No forms should be migrated. | 
|  495   VectorOfForms empty; |  506   VectorOfForms empty; | 
|  496   EXPECT_CALL(consumer, |  507   EXPECT_CALL(consumer, | 
|  497       OnPasswordStoreRequestDone(_, |  508       OnPasswordStoreRequestDone(_, | 
|  498           ContainsAllPasswordForms(empty))) |  509           ContainsAllPasswordForms(empty))) | 
|  499       .WillOnce(QuitUIMessageLoop()); |  510       .WillOnce(QuitUIMessageLoop()); | 
|  500  |  511  | 
|  501   store->GetAutofillableLogins(&consumer); |  512   store->GetAutofillableLogins(&consumer); | 
|  502   MessageLoop::current()->Run(); |  513   MessageLoop::current()->Run(); | 
|  503  |  514  | 
|  504   STLDeleteElements(&unexpected_autofillable); |  515   STLDeleteElements(&unexpected_autofillable); | 
|  505  |  516  | 
|  506   store->Shutdown(); |  517   // Public in PasswordStore, protected in PasswordStoreX. | 
 |  518   static_cast<PasswordStore*>(store)->Shutdown(); | 
|  507 } |  519 } | 
|  508  |  520  | 
|  509 TEST_P(PasswordStoreXTest, Notifications) { |  521 TEST_P(PasswordStoreXTest, Notifications) { | 
|  510   // Pretend that the migration has already taken place. |  522   // Pretend that the migration has already taken place. | 
|  511   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |  523   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 
|  512                                             true, |  524                                             true, | 
|  513                                             PrefService::UNSYNCABLE_PREF); |  525                                             PrefService::UNSYNCABLE_PREF); | 
|  514  |  526  | 
|  515   // Initializing the PasswordStore shouldn't trigger a migration. |  527   // Initializing the PasswordStore shouldn't trigger a migration. | 
|  516   scoped_refptr<PasswordStoreX> store( |  528   scoped_refptr<PasswordStoreX> store( | 
|  517       new PasswordStoreX(login_db_.release(), |  529       new PasswordStoreX(login_db_.release(), | 
|  518                            profile_.get(), |  530                          profile_.get(), | 
|  519                            wds_.get(), |  531                          wds_.get(), | 
|  520                            GetBackend())); |  532                          GetBackend())); | 
|  521   store->Init(); |  533   store->Init(); | 
|  522  |  534  | 
|  523   PasswordFormData form_data = |  535   PasswordFormData form_data = | 
|  524   { PasswordForm::SCHEME_HTML, |  536   { PasswordForm::SCHEME_HTML, | 
|  525     "http://bar.example.com", |  537     "http://bar.example.com", | 
|  526     "http://bar.example.com/origin", |  538     "http://bar.example.com/origin", | 
|  527     "http://bar.example.com/action", |  539     "http://bar.example.com/action", | 
|  528     L"submit_element", |  540     L"submit_element", | 
|  529     L"username_element", |  541     L"username_element", | 
|  530     L"password_element", |  542     L"password_element", | 
|  531     L"username_value", |  543     L"username_value", | 
|  532     L"password_value", |  544     L"password_value", | 
|  533     true, false, 1 }; |  545     true, false, 1 }; | 
|  534   scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data)); |  546   scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data)); | 
|  535  |  547  | 
|  536   scoped_refptr<DBThreadObserverHelper> helper = new DBThreadObserverHelper; |  548   scoped_refptr<DBThreadObserverHelper> helper = new DBThreadObserverHelper; | 
|  537   helper->Init(); |  549   helper->Init(store); | 
|  538  |  550  | 
|  539   const PasswordStoreChange expected_add_changes[] = { |  551   const PasswordStoreChange expected_add_changes[] = { | 
|  540     PasswordStoreChange(PasswordStoreChange::ADD, *form), |  552     PasswordStoreChange(PasswordStoreChange::ADD, *form), | 
|  541   }; |  553   }; | 
|  542  |  554  | 
|  543   EXPECT_CALL(helper->observer(), |  555   EXPECT_CALL(helper->observer(), | 
|  544               Observe(int(chrome::LOGINS_CHANGED), |  556               Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED), | 
|  545                       NotificationService::AllSources(), |  557                       Source<PasswordStore>(store), | 
|  546                       Property(&Details<const PasswordStoreChangeList>::ptr, |  558                       Property(&Details<const PasswordStoreChangeList>::ptr, | 
|  547                                Pointee(ElementsAreArray( |  559                                Pointee(ElementsAreArray( | 
|  548                                    expected_add_changes))))); |  560                                    expected_add_changes))))); | 
|  549  |  561  | 
|  550   // Adding a login should trigger a notification. |  562   // Adding a login should trigger a notification. | 
|  551   store->AddLogin(*form); |  563   store->AddLogin(*form); | 
|  552  |  564  | 
|  553   // The PasswordStore schedules tasks to run on the DB thread so we schedule |  565   // The PasswordStore schedules tasks to run on the DB thread so we schedule | 
|  554   // yet another task to notify us that it's safe to carry on with the test. |  566   // yet another task to notify us that it's safe to carry on with the test. | 
|  555   WaitableEvent done(false, false); |  567   WaitableEvent done(false, false); | 
|  556   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |  568   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 
|  557       new SignalingTask(&done)); |  569       new SignalingTask(&done)); | 
|  558   done.Wait(); |  570   done.Wait(); | 
|  559  |  571  | 
|  560   // Change the password. |  572   // Change the password. | 
|  561   form->password_value = WideToUTF16(L"a different password"); |  573   form->password_value = WideToUTF16(L"a different password"); | 
|  562  |  574  | 
|  563   const PasswordStoreChange expected_update_changes[] = { |  575   const PasswordStoreChange expected_update_changes[] = { | 
|  564     PasswordStoreChange(PasswordStoreChange::UPDATE, *form), |  576     PasswordStoreChange(PasswordStoreChange::UPDATE, *form), | 
|  565   }; |  577   }; | 
|  566  |  578  | 
|  567   EXPECT_CALL(helper->observer(), |  579   EXPECT_CALL(helper->observer(), | 
|  568               Observe(int(chrome::LOGINS_CHANGED), |  580               Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED), | 
|  569                       NotificationService::AllSources(), |  581                       Source<PasswordStore>(store), | 
|  570                       Property(&Details<const PasswordStoreChangeList>::ptr, |  582                       Property(&Details<const PasswordStoreChangeList>::ptr, | 
|  571                                Pointee(ElementsAreArray( |  583                                Pointee(ElementsAreArray( | 
|  572                                    expected_update_changes))))); |  584                                    expected_update_changes))))); | 
|  573  |  585  | 
|  574   // Updating the login with the new password should trigger a notification. |  586   // Updating the login with the new password should trigger a notification. | 
|  575   store->UpdateLogin(*form); |  587   store->UpdateLogin(*form); | 
|  576  |  588  | 
|  577   // Wait for PasswordStore to send the notification. |  589   // Wait for PasswordStore to send the notification. | 
|  578   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |  590   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 
|  579       new SignalingTask(&done)); |  591       new SignalingTask(&done)); | 
|  580   done.Wait(); |  592   done.Wait(); | 
|  581  |  593  | 
|  582   const PasswordStoreChange expected_delete_changes[] = { |  594   const PasswordStoreChange expected_delete_changes[] = { | 
|  583     PasswordStoreChange(PasswordStoreChange::REMOVE, *form), |  595     PasswordStoreChange(PasswordStoreChange::REMOVE, *form), | 
|  584   }; |  596   }; | 
|  585  |  597  | 
|  586   EXPECT_CALL(helper->observer(), |  598   EXPECT_CALL(helper->observer(), | 
|  587               Observe(int(chrome::LOGINS_CHANGED), |  599               Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED), | 
|  588                       NotificationService::AllSources(), |  600                       Source<PasswordStore>(store), | 
|  589                       Property(&Details<const PasswordStoreChangeList>::ptr, |  601                       Property(&Details<const PasswordStoreChangeList>::ptr, | 
|  590                                Pointee(ElementsAreArray( |  602                                Pointee(ElementsAreArray( | 
|  591                                    expected_delete_changes))))); |  603                                    expected_delete_changes))))); | 
|  592  |  604  | 
|  593   // Deleting the login should trigger a notification. |  605   // Deleting the login should trigger a notification. | 
|  594   store->RemoveLogin(*form); |  606   store->RemoveLogin(*form); | 
|  595  |  607  | 
|  596   // Wait for PasswordStore to send the notification. |  608   // Wait for PasswordStore to send the notification. | 
|  597   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |  609   BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 
|  598       new SignalingTask(&done)); |  610       new SignalingTask(&done)); | 
|  599   done.Wait(); |  611   done.Wait(); | 
|  600  |  612  | 
|  601   store->Shutdown(); |  613   // Public in PasswordStore, protected in PasswordStoreX. | 
 |  614   static_cast<PasswordStore*>(store)->Shutdown(); | 
|  602 } |  615 } | 
|  603  |  616  | 
|  604 TEST_P(PasswordStoreXTest, NativeMigration) { |  617 TEST_P(PasswordStoreXTest, NativeMigration) { | 
|  605   VectorOfForms expected_autofillable; |  618   VectorOfForms expected_autofillable; | 
|  606   InitExpectedForms(true, 50, &expected_autofillable); |  619   InitExpectedForms(true, 50, &expected_autofillable); | 
|  607  |  620  | 
|  608   VectorOfForms expected_blacklisted; |  621   VectorOfForms expected_blacklisted; | 
|  609   InitExpectedForms(false, 50, &expected_blacklisted); |  622   InitExpectedForms(false, 50, &expected_blacklisted); | 
|  610  |  623  | 
|  611   // Get the initial size of the login DB file, before we populate it. |  624   // Get the initial size of the login DB file, before we populate it. | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  647   EXPECT_GT(db_file_full_info.size, db_file_start_info.size); |  660   EXPECT_GT(db_file_full_info.size, db_file_start_info.size); | 
|  648  |  661  | 
|  649   // Pretend that the WDS migration has already taken place. |  662   // Pretend that the WDS migration has already taken place. | 
|  650   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |  663   profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 
|  651                                             true, |  664                                             true, | 
|  652                                             PrefService::UNSYNCABLE_PREF); |  665                                             PrefService::UNSYNCABLE_PREF); | 
|  653  |  666  | 
|  654   // Initializing the PasswordStore shouldn't trigger a native migration (yet). |  667   // Initializing the PasswordStore shouldn't trigger a native migration (yet). | 
|  655   scoped_refptr<PasswordStoreX> store( |  668   scoped_refptr<PasswordStoreX> store( | 
|  656       new PasswordStoreX(login_db_.release(), |  669       new PasswordStoreX(login_db_.release(), | 
|  657                            profile_.get(), |  670                          profile_.get(), | 
|  658                            wds_.get(), |  671                          wds_.get(), | 
|  659                            GetBackend())); |  672                          GetBackend())); | 
|  660   store->Init(); |  673   store->Init(); | 
|  661  |  674  | 
|  662   MockPasswordStoreConsumer consumer; |  675   MockPasswordStoreConsumer consumer; | 
|  663  |  676  | 
|  664   // Make sure we quit the MessageLoop even if the test fails. |  677   // Make sure we quit the MessageLoop even if the test fails. | 
|  665   ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) |  678   ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) | 
|  666       .WillByDefault(QuitUIMessageLoop()); |  679       .WillByDefault(QuitUIMessageLoop()); | 
|  667  |  680  | 
|  668   // The autofillable forms should have been migrated to the native backend. |  681   // The autofillable forms should have been migrated to the native backend. | 
|  669   EXPECT_CALL(consumer, |  682   EXPECT_CALL(consumer, | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  733     // size is equal to the size before we populated it, even though it was |  746     // size is equal to the size before we populated it, even though it was | 
|  734     // larger after populating it. |  747     // larger after populating it. | 
|  735     base::PlatformFileInfo db_file_end_info; |  748     base::PlatformFileInfo db_file_end_info; | 
|  736     ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_end_info)); |  749     ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_end_info)); | 
|  737     EXPECT_EQ(db_file_start_info.size, db_file_end_info.size); |  750     EXPECT_EQ(db_file_start_info.size, db_file_end_info.size); | 
|  738   } |  751   } | 
|  739  |  752  | 
|  740   STLDeleteElements(&expected_autofillable); |  753   STLDeleteElements(&expected_autofillable); | 
|  741   STLDeleteElements(&expected_blacklisted); |  754   STLDeleteElements(&expected_blacklisted); | 
|  742  |  755  | 
|  743   store->Shutdown(); |  756   // Public in PasswordStore, protected in PasswordStoreX. | 
 |  757   static_cast<PasswordStore*>(store)->Shutdown(); | 
|  744 } |  758 } | 
|  745  |  759  | 
|  746 INSTANTIATE_TEST_CASE_P(NoBackend, |  760 INSTANTIATE_TEST_CASE_P(NoBackend, | 
|  747                         PasswordStoreXTest, |  761                         PasswordStoreXTest, | 
|  748                         testing::Values(NO_BACKEND)); |  762                         testing::Values(NO_BACKEND)); | 
|  749 INSTANTIATE_TEST_CASE_P(FailingBackend, |  763 INSTANTIATE_TEST_CASE_P(FailingBackend, | 
|  750                         PasswordStoreXTest, |  764                         PasswordStoreXTest, | 
|  751                         testing::Values(FAILING_BACKEND)); |  765                         testing::Values(FAILING_BACKEND)); | 
|  752 INSTANTIATE_TEST_CASE_P(WorkingBackend, |  766 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 
|  753                         PasswordStoreXTest, |  767                         PasswordStoreXTest, | 
|  754                         testing::Values(WORKING_BACKEND)); |  768                         testing::Values(WORKING_BACKEND)); | 
| OLD | NEW |