Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: chrome/browser/sync/profile_sync_service_password_unittest.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android build Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 16 matching lines...) Expand all
236 // When the password store is unavailable, password sync components must 238 // When the password store is unavailable, password sync components must
237 // not be created. 239 // not be created.
238 EXPECT_CALL(*components, CreatePasswordSyncComponents(_, _, _)) 240 EXPECT_CALL(*components, CreatePasswordSyncComponents(_, _, _))
239 .Times(0); 241 .Times(0);
240 } 242 }
241 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _, _)). 243 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _, _)).
242 WillOnce(ReturnNewDataTypeManager()); 244 WillOnce(ReturnNewDataTypeManager());
243 245
244 // We need tokens to get the tests going 246 // We need tokens to get the tests going
245 token_service_->IssueAuthTokenForTest( 247 token_service_->IssueAuthTokenForTest(
246 GaiaConstants::kSyncService, "token"); 248 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token");
247 249
248 sync_service_->RegisterDataTypeController(data_type_controller); 250 sync_service_->RegisterDataTypeController(data_type_controller);
249 sync_service_->Initialize(); 251 sync_service_->Initialize();
250 base::MessageLoop::current()->Run(); 252 base::MessageLoop::current()->Run();
251 FlushLastDBTask(); 253 FlushLastDBTask();
252 254
253 sync_service_->SetEncryptionPassphrase("foo", 255 sync_service_->SetEncryptionPassphrase("foo",
254 ProfileSyncService::IMPLICIT); 256 ProfileSyncService::IMPLICIT);
255 base::MessageLoop::current()->Run(); 257 base::MessageLoop::current()->Run();
256 } 258 }
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698