| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 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 <vector> |    5 #include <vector> | 
|    6  |    6  | 
|    7 #include "testing/gtest/include/gtest/gtest.h" |    7 #include "testing/gtest/include/gtest/gtest.h" | 
|    8  |    8  | 
|    9 #include "base/bind.h" |    9 #include "base/bind.h" | 
|   10 #include "base/location.h" |   10 #include "base/location.h" | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  174   } |  174   } | 
|  175  |  175  | 
|  176  protected: |  176  protected: | 
|  177   ProfileSyncServicePasswordTest() {} |  177   ProfileSyncServicePasswordTest() {} | 
|  178  |  178  | 
|  179   virtual void SetUp() { |  179   virtual void SetUp() { | 
|  180     AbstractProfileSyncServiceTest::SetUp(); |  180     AbstractProfileSyncServiceTest::SetUp(); | 
|  181     profile_.CreateRequestContext(); |  181     profile_.CreateRequestContext(); | 
|  182     password_store_ = new MockPasswordStore(); |  182     password_store_ = new MockPasswordStore(); | 
|  183  |  183  | 
|  184     notification_service_ = new ThreadNotificationService( |  | 
|  185         db_thread_.DeprecatedGetThreadObject()); |  | 
|  186     notification_service_->Init(); |  | 
|  187     registrar_.Add(&observer_, |  184     registrar_.Add(&observer_, | 
|  188         chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, |  185         chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, | 
|  189         content::NotificationService::AllSources()); |  186         content::NotificationService::AllSources()); | 
|  190     registrar_.Add(&observer_, |  187     registrar_.Add(&observer_, | 
|  191         chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED, |  188         chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED, | 
|  192         content::NotificationService::AllSources()); |  189         content::NotificationService::AllSources()); | 
|  193   } |  190   } | 
|  194  |  191  | 
|  195   virtual void TearDown() { |  192   virtual void TearDown() { | 
|  196     password_store_->Shutdown(); |  193     password_store_->Shutdown(); | 
|  197     service_.reset(); |  194     service_.reset(); | 
|  198     notification_service_->TearDown(); |  | 
|  199     profile_.ResetRequestContext(); |  195     profile_.ResetRequestContext(); | 
|  200     AbstractProfileSyncServiceTest::TearDown(); |  196     AbstractProfileSyncServiceTest::TearDown(); | 
|  201   } |  197   } | 
|  202  |  198  | 
|  203   static void SignalEvent(base::WaitableEvent* done) { |  199   static void SignalEvent(base::WaitableEvent* done) { | 
|  204     done->Signal(); |  200     done->Signal(); | 
|  205   } |  201   } | 
|  206  |  202  | 
|  207   void FlushLastDBTask() { |  203   void FlushLastDBTask() { | 
|  208     base::WaitableEvent done(false, false); |  204     base::WaitableEvent done(false, false); | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  308            lhs.date_created == rhs.date_created && |  304            lhs.date_created == rhs.date_created && | 
|  309            lhs.blacklisted_by_user == rhs.blacklisted_by_user; |  305            lhs.blacklisted_by_user == rhs.blacklisted_by_user; | 
|  310   } |  306   } | 
|  311  |  307  | 
|  312   void SetIdleChangeProcessorExpectations() { |  308   void SetIdleChangeProcessorExpectations() { | 
|  313     EXPECT_CALL(*password_store_, AddLoginImpl(_)).Times(0); |  309     EXPECT_CALL(*password_store_, AddLoginImpl(_)).Times(0); | 
|  314     EXPECT_CALL(*password_store_, UpdateLoginImpl(_)).Times(0); |  310     EXPECT_CALL(*password_store_, UpdateLoginImpl(_)).Times(0); | 
|  315     EXPECT_CALL(*password_store_, RemoveLoginImpl(_)).Times(0); |  311     EXPECT_CALL(*password_store_, RemoveLoginImpl(_)).Times(0); | 
|  316   } |  312   } | 
|  317  |  313  | 
|  318   scoped_refptr<ThreadNotificationService> notification_service_; |  | 
|  319   content::NotificationObserverMock observer_; |  314   content::NotificationObserverMock observer_; | 
|  320   ProfileMock profile_; |  315   ProfileMock profile_; | 
|  321   scoped_refptr<MockPasswordStore> password_store_; |  316   scoped_refptr<MockPasswordStore> password_store_; | 
|  322   content::NotificationRegistrar registrar_; |  317   content::NotificationRegistrar registrar_; | 
|  323 }; |  318 }; | 
|  324  |  319  | 
|  325 void AddPasswordEntriesCallback(ProfileSyncServicePasswordTest* test, |  320 void AddPasswordEntriesCallback(ProfileSyncServicePasswordTest* test, | 
|  326                                 const std::vector<PasswordForm>& entries) { |  321                                 const std::vector<PasswordForm>& entries) { | 
|  327   for (size_t i = 0; i < entries.size(); ++i) |  322   for (size_t i = 0; i < entries.size(); ++i) | 
|  328     test->AddPasswordSyncNode(entries[i]); |  323     test->AddPasswordSyncNode(entries[i]); | 
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  617   CreateRootHelper create_root(this, syncable::PASSWORDS); |  612   CreateRootHelper create_root(this, syncable::PASSWORDS); | 
|  618   StartSyncService(create_root.callback(), |  613   StartSyncService(create_root.callback(), | 
|  619                    base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |  614                    base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 
|  620  |  615  | 
|  621   std::vector<PasswordForm> new_sync_forms; |  616   std::vector<PasswordForm> new_sync_forms; | 
|  622   GetPasswordEntriesFromSyncDB(&new_sync_forms); |  617   GetPasswordEntriesFromSyncDB(&new_sync_forms); | 
|  623  |  618  | 
|  624   EXPECT_EQ(1U, new_sync_forms.size()); |  619   EXPECT_EQ(1U, new_sync_forms.size()); | 
|  625   EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |  620   EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 
|  626 } |  621 } | 
| OLD | NEW |