| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 void StartSyncService(const base::Closure& root_callback, | 183 void StartSyncService(const base::Closure& root_callback, |
| 184 const base::Closure& node_callback) { | 184 const base::Closure& node_callback) { |
| 185 if (!sync_service_) { | 185 if (!sync_service_) { |
| 186 SigninManagerBase* signin = | 186 SigninManagerBase* signin = |
| 187 SigninManagerFactory::GetForProfile(&profile_); | 187 SigninManagerFactory::GetForProfile(&profile_); |
| 188 signin->SetAuthenticatedUsername("test_user"); | 188 signin->SetAuthenticatedUsername("test_user"); |
| 189 token_service_ = static_cast<TokenService*>( | 189 token_service_ = static_cast<TokenService*>( |
| 190 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 190 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 191 &profile_, BuildTokenService)); | 191 &profile_, BuildTokenService)); |
| 192 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( |
| 193 &profile_, FakeOAuth2TokenService::BuildTokenService); |
| 192 | 194 |
| 193 PasswordTestProfileSyncService* sync = | 195 PasswordTestProfileSyncService* sync = |
| 194 static_cast<PasswordTestProfileSyncService*>( | 196 static_cast<PasswordTestProfileSyncService*>( |
| 195 ProfileSyncServiceFactory::GetInstance()-> | 197 ProfileSyncServiceFactory::GetInstance()-> |
| 196 SetTestingFactoryAndUse(&profile_, | 198 SetTestingFactoryAndUse(&profile_, |
| 197 &PasswordTestProfileSyncService::Build)); | 199 &PasswordTestProfileSyncService::Build)); |
| 198 sync->set_backend_init_callback(root_callback); | 200 sync->set_backend_init_callback(root_callback); |
| 199 sync->set_passphrase_accept_callback(node_callback); | 201 sync->set_passphrase_accept_callback(node_callback); |
| 200 sync_service_ = sync; | 202 sync_service_ = sync; |
| 201 | 203 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 218 // When the password store is unavailable, password sync components must | 220 // When the password store is unavailable, password sync components must |
| 219 // not be created. | 221 // not be created. |
| 220 EXPECT_CALL(*components, CreatePasswordSyncComponents(_, _, _)) | 222 EXPECT_CALL(*components, CreatePasswordSyncComponents(_, _, _)) |
| 221 .Times(0); | 223 .Times(0); |
| 222 } | 224 } |
| 223 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _, _)). | 225 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _, _)). |
| 224 WillOnce(ReturnNewDataTypeManager()); | 226 WillOnce(ReturnNewDataTypeManager()); |
| 225 | 227 |
| 226 // We need tokens to get the tests going | 228 // We need tokens to get the tests going |
| 227 token_service_->IssueAuthTokenForTest( | 229 token_service_->IssueAuthTokenForTest( |
| 230 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); |
| 231 token_service_->IssueAuthTokenForTest( |
| 228 GaiaConstants::kSyncService, "token"); | 232 GaiaConstants::kSyncService, "token"); |
| 229 | 233 |
| 230 sync_service_->RegisterDataTypeController(data_type_controller); | 234 sync_service_->RegisterDataTypeController(data_type_controller); |
| 231 sync_service_->Initialize(); | 235 sync_service_->Initialize(); |
| 232 base::MessageLoop::current()->Run(); | 236 base::MessageLoop::current()->Run(); |
| 233 FlushLastDBTask(); | 237 FlushLastDBTask(); |
| 234 | 238 |
| 235 sync_service_->SetEncryptionPassphrase("foo", | 239 sync_service_->SetEncryptionPassphrase("foo", |
| 236 ProfileSyncService::IMPLICIT); | 240 ProfileSyncService::IMPLICIT); |
| 237 base::MessageLoop::current()->Run(); | 241 base::MessageLoop::current()->Run(); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 CreateRootHelper create_root(this, syncer::PASSWORDS); | 647 CreateRootHelper create_root(this, syncer::PASSWORDS); |
| 644 StartSyncService(create_root.callback(), | 648 StartSyncService(create_root.callback(), |
| 645 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 649 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
| 646 | 650 |
| 647 std::vector<PasswordForm> new_sync_forms; | 651 std::vector<PasswordForm> new_sync_forms; |
| 648 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 652 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 649 | 653 |
| 650 EXPECT_EQ(1U, new_sync_forms.size()); | 654 EXPECT_EQ(1U, new_sync_forms.size()); |
| 651 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 655 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 652 } | 656 } |
| OLD | NEW |