| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // login credentials. | 109 // login credentials. |
| 110 } | 110 } |
| 111 | 111 |
| 112 virtual void OnPassphraseAccepted() OVERRIDE { | 112 virtual void OnPassphraseAccepted() OVERRIDE { |
| 113 if (!callback_.is_null()) | 113 if (!callback_.is_null()) |
| 114 callback_.Run(); | 114 callback_.Run(); |
| 115 | 115 |
| 116 TestProfileSyncService::OnPassphraseAccepted(); | 116 TestProfileSyncService::OnPassphraseAccepted(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 virtual void OnConfigureBlocked() OVERRIDE { |
| 120 QuitMessageLoop(); |
| 121 } |
| 122 |
| 119 private: | 123 private: |
| 120 base::Closure callback_; | 124 base::Closure callback_; |
| 121 }; | 125 }; |
| 122 | 126 |
| 123 class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest { | 127 class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest { |
| 124 public: | 128 public: |
| 125 syncer::UserShare* GetUserShare() { | 129 syncer::UserShare* GetUserShare() { |
| 126 return service_->GetUserShare(); | 130 return service_->GetUserShare(); |
| 127 } | 131 } |
| 128 | 132 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 142 | 146 |
| 143 protected: | 147 protected: |
| 144 ProfileSyncServicePasswordTest() {} | 148 ProfileSyncServicePasswordTest() {} |
| 145 | 149 |
| 146 virtual void SetUp() { | 150 virtual void SetUp() { |
| 147 AbstractProfileSyncServiceTest::SetUp(); | 151 AbstractProfileSyncServiceTest::SetUp(); |
| 148 profile_.CreateRequestContext(); | 152 profile_.CreateRequestContext(); |
| 149 password_store_ = static_cast<MockPasswordStore*>( | 153 password_store_ = static_cast<MockPasswordStore*>( |
| 150 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( | 154 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( |
| 151 &profile_, MockPasswordStore::Build).get()); | 155 &profile_, MockPasswordStore::Build).get()); |
| 152 | |
| 153 registrar_.Add(&observer_, | |
| 154 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, | |
| 155 content::NotificationService::AllSources()); | |
| 156 registrar_.Add(&observer_, | |
| 157 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED, | |
| 158 content::NotificationService::AllSources()); | |
| 159 } | 156 } |
| 160 | 157 |
| 161 virtual void TearDown() { | 158 virtual void TearDown() { |
| 162 password_store_->ShutdownOnUIThread(); | 159 password_store_->ShutdownOnUIThread(); |
| 163 service_.reset(); | 160 service_.reset(); |
| 164 profile_.ResetRequestContext(); | 161 profile_.ResetRequestContext(); |
| 165 AbstractProfileSyncServiceTest::TearDown(); | 162 AbstractProfileSyncServiceTest::TearDown(); |
| 166 } | 163 } |
| 167 | 164 |
| 168 static void SignalEvent(base::WaitableEvent* done) { | 165 static void SignalEvent(base::WaitableEvent* done) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 WillRepeatedly(MakePasswordSyncComponents(service_.get(), | 200 WillRepeatedly(MakePasswordSyncComponents(service_.get(), |
| 204 password_store_.get(), | 201 password_store_.get(), |
| 205 data_type_controller)); | 202 data_type_controller)); |
| 206 EXPECT_CALL(*factory, CreateDataTypeManager(_, _)). | 203 EXPECT_CALL(*factory, CreateDataTypeManager(_, _)). |
| 207 WillOnce(ReturnNewDataTypeManager()); | 204 WillOnce(ReturnNewDataTypeManager()); |
| 208 | 205 |
| 209 // We need tokens to get the tests going | 206 // We need tokens to get the tests going |
| 210 token_service_->IssueAuthTokenForTest( | 207 token_service_->IssueAuthTokenForTest( |
| 211 GaiaConstants::kSyncService, "token"); | 208 GaiaConstants::kSyncService, "token"); |
| 212 | 209 |
| 213 EXPECT_CALL(observer_, | |
| 214 Observe( | |
| 215 int(chrome::NOTIFICATION_SYNC_CONFIGURE_DONE),_,_)); | |
| 216 EXPECT_CALL(observer_, | |
| 217 Observe( | |
| 218 int( | |
| 219 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED),_,_)) | |
| 220 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | |
| 221 | |
| 222 service_->RegisterDataTypeController(data_type_controller); | 210 service_->RegisterDataTypeController(data_type_controller); |
| 223 service_->Initialize(); | 211 service_->Initialize(); |
| 224 MessageLoop::current()->Run(); | 212 MessageLoop::current()->Run(); |
| 225 FlushLastDBTask(); | 213 FlushLastDBTask(); |
| 226 | 214 |
| 227 service_->SetEncryptionPassphrase("foo", ProfileSyncService::IMPLICIT); | 215 service_->SetEncryptionPassphrase("foo", ProfileSyncService::IMPLICIT); |
| 228 MessageLoop::current()->Run(); | 216 MessageLoop::current()->Run(); |
| 229 } | 217 } |
| 230 } | 218 } |
| 231 | 219 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 CreateRootHelper create_root(this, syncer::PASSWORDS); | 563 CreateRootHelper create_root(this, syncer::PASSWORDS); |
| 576 StartSyncService(create_root.callback(), | 564 StartSyncService(create_root.callback(), |
| 577 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 565 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
| 578 | 566 |
| 579 std::vector<PasswordForm> new_sync_forms; | 567 std::vector<PasswordForm> new_sync_forms; |
| 580 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 568 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 581 | 569 |
| 582 EXPECT_EQ(1U, new_sync_forms.size()); | 570 EXPECT_EQ(1U, new_sync_forms.size()); |
| 583 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 571 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 584 } | 572 } |
| OLD | NEW |