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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 void StartSyncService(const base::Closure& root_callback, | 201 void StartSyncService(const base::Closure& root_callback, |
202 const base::Closure& node_callback) { | 202 const base::Closure& node_callback) { |
203 if (!sync_service_) { | 203 if (!sync_service_) { |
204 SigninManagerBase* signin = | 204 SigninManagerBase* signin = |
205 SigninManagerFactory::GetForProfile(&profile_); | 205 SigninManagerFactory::GetForProfile(&profile_); |
206 signin->SetAuthenticatedUsername("test_user"); | 206 signin->SetAuthenticatedUsername("test_user"); |
207 token_service_ = static_cast<TokenService*>( | 207 token_service_ = static_cast<TokenService*>( |
208 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 208 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
209 &profile_, BuildTokenService)); | 209 &profile_, BuildTokenService)); |
| 210 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( |
| 211 &profile_, FakeOAuth2TokenService::BuildTokenService); |
210 | 212 |
211 PasswordTestProfileSyncService* sync = | 213 PasswordTestProfileSyncService* sync = |
212 static_cast<PasswordTestProfileSyncService*>( | 214 static_cast<PasswordTestProfileSyncService*>( |
213 ProfileSyncServiceFactory::GetInstance()-> | 215 ProfileSyncServiceFactory::GetInstance()-> |
214 SetTestingFactoryAndUse(&profile_, | 216 SetTestingFactoryAndUse(&profile_, |
215 &PasswordTestProfileSyncService::Build)); | 217 &PasswordTestProfileSyncService::Build)); |
216 sync->set_backend_init_callback(root_callback); | 218 sync->set_backend_init_callback(root_callback); |
217 sync->set_passphrase_accept_callback(node_callback); | 219 sync->set_passphrase_accept_callback(node_callback); |
218 sync_service_ = sync; | 220 sync_service_ = sync; |
219 | 221 |
(...skipping 17 matching lines...) Expand all Loading... |
237 // When the password store is unavailable, password sync components must | 239 // When the password store is unavailable, password sync components must |
238 // not be created. | 240 // not be created. |
239 EXPECT_CALL(*components, CreatePasswordSyncComponents(_, _, _)) | 241 EXPECT_CALL(*components, CreatePasswordSyncComponents(_, _, _)) |
240 .Times(0); | 242 .Times(0); |
241 } | 243 } |
242 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _)). | 244 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _)). |
243 WillOnce(ReturnNewDataTypeManager()); | 245 WillOnce(ReturnNewDataTypeManager()); |
244 | 246 |
245 // We need tokens to get the tests going | 247 // We need tokens to get the tests going |
246 token_service_->IssueAuthTokenForTest( | 248 token_service_->IssueAuthTokenForTest( |
247 GaiaConstants::kSyncService, "token"); | 249 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); |
248 | 250 |
249 sync_service_->RegisterDataTypeController(data_type_controller); | 251 sync_service_->RegisterDataTypeController(data_type_controller); |
250 sync_service_->Initialize(); | 252 sync_service_->Initialize(); |
251 base::MessageLoop::current()->Run(); | 253 base::MessageLoop::current()->Run(); |
252 FlushLastDBTask(); | 254 FlushLastDBTask(); |
253 | 255 |
254 sync_service_->SetEncryptionPassphrase("foo", | 256 sync_service_->SetEncryptionPassphrase("foo", |
255 ProfileSyncService::IMPLICIT); | 257 ProfileSyncService::IMPLICIT); |
256 base::MessageLoop::current()->Run(); | 258 base::MessageLoop::current()->Run(); |
257 } | 259 } |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 CreateRootHelper create_root(this, syncer::PASSWORDS); | 663 CreateRootHelper create_root(this, syncer::PASSWORDS); |
662 StartSyncService(create_root.callback(), | 664 StartSyncService(create_root.callback(), |
663 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 665 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
664 | 666 |
665 std::vector<PasswordForm> new_sync_forms; | 667 std::vector<PasswordForm> new_sync_forms; |
666 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 668 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
667 | 669 |
668 EXPECT_EQ(1U, new_sync_forms.size()); | 670 EXPECT_EQ(1U, new_sync_forms.size()); |
669 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 671 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
670 } | 672 } |
OLD | NEW |