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

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

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android fixes. Created 7 years, 4 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 | Annotate | Revision Log
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 node.InitUniqueByCreation(syncer::PASSWORDS, password_root, tag); 147 node.InitUniqueByCreation(syncer::PASSWORDS, password_root, tag);
148 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); 148 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result);
149 PasswordModelAssociator::WriteToSyncNode(entry, &node); 149 PasswordModelAssociator::WriteToSyncNode(entry, &node);
150 } 150 }
151 151
152 protected: 152 protected:
153 ProfileSyncServicePasswordTest() {} 153 ProfileSyncServicePasswordTest() {}
154 154
155 virtual void SetUp() { 155 virtual void SetUp() {
156 AbstractProfileSyncServiceTest::SetUp(); 156 AbstractProfileSyncServiceTest::SetUp();
157 profile_.reset(new ProfileMock()); 157 TestingProfile::Builder builder;
158 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
159 FakeOAuth2TokenService::BuildTokenService);
160 profile_ = builder.Build().Pass();
158 invalidation::InvalidationServiceFactory::GetInstance()-> 161 invalidation::InvalidationServiceFactory::GetInstance()->
159 SetBuildOnlyFakeInvalidatorsForTest(true); 162 SetBuildOnlyFakeInvalidatorsForTest(true);
160 password_store_ = static_cast<MockPasswordStore*>( 163 password_store_ = static_cast<MockPasswordStore*>(
161 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( 164 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
162 profile_.get(), MockPasswordStore::Build).get()); 165 profile_.get(), MockPasswordStore::Build).get());
163 } 166 }
164 167
165 virtual void TearDown() { 168 virtual void TearDown() {
166 if (password_store_.get()) 169 if (password_store_.get())
167 password_store_->ShutdownOnUIThread(); 170 password_store_->ShutdownOnUIThread();
(...skipping 17 matching lines...) Expand all
185 188
186 void StartSyncService(const base::Closure& root_callback, 189 void StartSyncService(const base::Closure& root_callback,
187 const base::Closure& node_callback) { 190 const base::Closure& node_callback) {
188 if (!sync_service_) { 191 if (!sync_service_) {
189 SigninManagerBase* signin = 192 SigninManagerBase* signin =
190 SigninManagerFactory::GetForProfile(profile_.get()); 193 SigninManagerFactory::GetForProfile(profile_.get());
191 signin->SetAuthenticatedUsername("test_user@gmail.com"); 194 signin->SetAuthenticatedUsername("test_user@gmail.com");
192 token_service_ = static_cast<TokenService*>( 195 token_service_ = static_cast<TokenService*>(
193 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( 196 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
194 profile_.get(), BuildTokenService)); 197 profile_.get(), BuildTokenService));
195 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
196 profile_.get(), FakeOAuth2TokenService::BuildTokenService);
197 198
198 PasswordTestProfileSyncService* sync = 199 PasswordTestProfileSyncService* sync =
199 static_cast<PasswordTestProfileSyncService*>( 200 static_cast<PasswordTestProfileSyncService*>(
200 ProfileSyncServiceFactory::GetInstance()-> 201 ProfileSyncServiceFactory::GetInstance()->
201 SetTestingFactoryAndUse(profile_.get(), 202 SetTestingFactoryAndUse(profile_.get(),
202 &PasswordTestProfileSyncService::Build)); 203 &PasswordTestProfileSyncService::Build));
203 sync->set_backend_init_callback(root_callback); 204 sync->set_backend_init_callback(root_callback);
204 sync->set_passphrase_accept_callback(node_callback); 205 sync->set_passphrase_accept_callback(node_callback);
205 sync_service_ = sync; 206 sync_service_ = sync;
206 207
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 lhs.blacklisted_by_user == rhs.blacklisted_by_user; 308 lhs.blacklisted_by_user == rhs.blacklisted_by_user;
308 } 309 }
309 310
310 void SetIdleChangeProcessorExpectations() { 311 void SetIdleChangeProcessorExpectations() {
311 EXPECT_CALL(*password_store_.get(), AddLoginImpl(_)).Times(0); 312 EXPECT_CALL(*password_store_.get(), AddLoginImpl(_)).Times(0);
312 EXPECT_CALL(*password_store_.get(), UpdateLoginImpl(_)).Times(0); 313 EXPECT_CALL(*password_store_.get(), UpdateLoginImpl(_)).Times(0);
313 EXPECT_CALL(*password_store_.get(), RemoveLoginImpl(_)).Times(0); 314 EXPECT_CALL(*password_store_.get(), RemoveLoginImpl(_)).Times(0);
314 } 315 }
315 316
316 content::MockNotificationObserver observer_; 317 content::MockNotificationObserver observer_;
317 scoped_ptr<ProfileMock> profile_; 318 scoped_ptr<TestingProfile> profile_;
318 scoped_refptr<MockPasswordStore> password_store_; 319 scoped_refptr<MockPasswordStore> password_store_;
319 content::NotificationRegistrar registrar_; 320 content::NotificationRegistrar registrar_;
320 }; 321 };
321 322
322 void AddPasswordEntriesCallback(ProfileSyncServicePasswordTest* test, 323 void AddPasswordEntriesCallback(ProfileSyncServicePasswordTest* test,
323 const std::vector<PasswordForm>& entries) { 324 const std::vector<PasswordForm>& entries) {
324 for (size_t i = 0; i < entries.size(); ++i) 325 for (size_t i = 0; i < entries.size(); ++i)
325 test->AddPasswordSyncNode(entries[i]); 326 test->AddPasswordSyncNode(entries[i]);
326 } 327 }
327 328
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 CreateRootHelper create_root(this, syncer::PASSWORDS); 651 CreateRootHelper create_root(this, syncer::PASSWORDS);
651 StartSyncService(create_root.callback(), 652 StartSyncService(create_root.callback(),
652 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); 653 base::Bind(&AddPasswordEntriesCallback, this, sync_forms));
653 654
654 std::vector<PasswordForm> new_sync_forms; 655 std::vector<PasswordForm> new_sync_forms;
655 GetPasswordEntriesFromSyncDB(&new_sync_forms); 656 GetPasswordEntriesFromSyncDB(&new_sync_forms);
656 657
657 EXPECT_EQ(1U, new_sync_forms.size()); 658 EXPECT_EQ(1U, new_sync_forms.size());
658 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); 659 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0]));
659 } 660 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698