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

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: Merge with ToT 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 14 matching lines...) Expand all
25 #include "chrome/browser/sync/glue/password_change_processor.h" 25 #include "chrome/browser/sync/glue/password_change_processor.h"
26 #include "chrome/browser/sync/glue/password_data_type_controller.h" 26 #include "chrome/browser/sync/glue/password_data_type_controller.h"
27 #include "chrome/browser/sync/glue/password_model_associator.h" 27 #include "chrome/browser/sync/glue/password_model_associator.h"
28 #include "chrome/browser/sync/profile_sync_components_factory.h" 28 #include "chrome/browser/sync/profile_sync_components_factory.h"
29 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" 29 #include "chrome/browser/sync/profile_sync_components_factory_mock.h"
30 #include "chrome/browser/sync/profile_sync_service.h" 30 #include "chrome/browser/sync/profile_sync_service.h"
31 #include "chrome/browser/sync/profile_sync_service_factory.h" 31 #include "chrome/browser/sync/profile_sync_service_factory.h"
32 #include "chrome/browser/sync/profile_sync_test_util.h" 32 #include "chrome/browser/sync/profile_sync_test_util.h"
33 #include "chrome/browser/sync/test_profile_sync_service.h" 33 #include "chrome/browser/sync/test_profile_sync_service.h"
34 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "chrome/test/base/profile_mock.h"
36 #include "content/public/browser/notification_source.h" 35 #include "content/public/browser/notification_source.h"
37 #include "content/public/common/password_form.h" 36 #include "content/public/common/password_form.h"
38 #include "content/public/test/mock_notification_observer.h" 37 #include "content/public/test/mock_notification_observer.h"
39 #include "content/public/test/test_browser_thread.h" 38 #include "content/public/test/test_browser_thread.h"
40 #include "google_apis/gaia/gaia_constants.h" 39 #include "google_apis/gaia/gaia_constants.h"
41 #include "sync/internal_api/public/read_node.h" 40 #include "sync/internal_api/public/read_node.h"
42 #include "sync/internal_api/public/read_transaction.h" 41 #include "sync/internal_api/public/read_transaction.h"
43 #include "sync/internal_api/public/write_node.h" 42 #include "sync/internal_api/public/write_node.h"
44 #include "sync/internal_api/public/write_transaction.h" 43 #include "sync/internal_api/public/write_transaction.h"
45 #include "sync/protocol/password_specifics.pb.h" 44 #include "sync/protocol/password_specifics.pb.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 node.InitUniqueByCreation(syncer::PASSWORDS, password_root, tag); 146 node.InitUniqueByCreation(syncer::PASSWORDS, password_root, tag);
148 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); 147 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result);
149 PasswordModelAssociator::WriteToSyncNode(entry, &node); 148 PasswordModelAssociator::WriteToSyncNode(entry, &node);
150 } 149 }
151 150
152 protected: 151 protected:
153 ProfileSyncServicePasswordTest() {} 152 ProfileSyncServicePasswordTest() {}
154 153
155 virtual void SetUp() { 154 virtual void SetUp() {
156 AbstractProfileSyncServiceTest::SetUp(); 155 AbstractProfileSyncServiceTest::SetUp();
157 profile_.reset(new ProfileMock()); 156 TestingProfile::Builder builder;
157 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
158 FakeOAuth2TokenService::BuildTokenService);
159 profile_ = builder.Build().Pass();
158 invalidation::InvalidationServiceFactory::GetInstance()-> 160 invalidation::InvalidationServiceFactory::GetInstance()->
159 SetBuildOnlyFakeInvalidatorsForTest(true); 161 SetBuildOnlyFakeInvalidatorsForTest(true);
160 password_store_ = static_cast<MockPasswordStore*>( 162 password_store_ = static_cast<MockPasswordStore*>(
161 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( 163 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
162 profile_.get(), MockPasswordStore::Build).get()); 164 profile_.get(), MockPasswordStore::Build).get());
163 } 165 }
164 166
165 virtual void TearDown() { 167 virtual void TearDown() {
166 if (password_store_.get()) 168 if (password_store_.get())
167 password_store_->ShutdownOnUIThread(); 169 password_store_->ShutdownOnUIThread();
(...skipping 17 matching lines...) Expand all
185 187
186 void StartSyncService(const base::Closure& root_callback, 188 void StartSyncService(const base::Closure& root_callback,
187 const base::Closure& node_callback) { 189 const base::Closure& node_callback) {
188 if (!sync_service_) { 190 if (!sync_service_) {
189 SigninManagerBase* signin = 191 SigninManagerBase* signin =
190 SigninManagerFactory::GetForProfile(profile_.get()); 192 SigninManagerFactory::GetForProfile(profile_.get());
191 signin->SetAuthenticatedUsername("test_user@gmail.com"); 193 signin->SetAuthenticatedUsername("test_user@gmail.com");
192 token_service_ = static_cast<TokenService*>( 194 token_service_ = static_cast<TokenService*>(
193 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( 195 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
194 profile_.get(), BuildTokenService)); 196 profile_.get(), BuildTokenService));
195 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
196 profile_.get(), FakeOAuth2TokenService::BuildTokenService);
197 197
198 PasswordTestProfileSyncService* sync = 198 PasswordTestProfileSyncService* sync =
199 static_cast<PasswordTestProfileSyncService*>( 199 static_cast<PasswordTestProfileSyncService*>(
200 ProfileSyncServiceFactory::GetInstance()-> 200 ProfileSyncServiceFactory::GetInstance()->
201 SetTestingFactoryAndUse(profile_.get(), 201 SetTestingFactoryAndUse(profile_.get(),
202 &PasswordTestProfileSyncService::Build)); 202 &PasswordTestProfileSyncService::Build));
203 sync->set_backend_init_callback(root_callback); 203 sync->set_backend_init_callback(root_callback);
204 sync->set_passphrase_accept_callback(node_callback); 204 sync->set_passphrase_accept_callback(node_callback);
205 sync_service_ = sync; 205 sync_service_ = sync;
206 206
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 lhs.blacklisted_by_user == rhs.blacklisted_by_user; 307 lhs.blacklisted_by_user == rhs.blacklisted_by_user;
308 } 308 }
309 309
310 void SetIdleChangeProcessorExpectations() { 310 void SetIdleChangeProcessorExpectations() {
311 EXPECT_CALL(*password_store_.get(), AddLoginImpl(_)).Times(0); 311 EXPECT_CALL(*password_store_.get(), AddLoginImpl(_)).Times(0);
312 EXPECT_CALL(*password_store_.get(), UpdateLoginImpl(_)).Times(0); 312 EXPECT_CALL(*password_store_.get(), UpdateLoginImpl(_)).Times(0);
313 EXPECT_CALL(*password_store_.get(), RemoveLoginImpl(_)).Times(0); 313 EXPECT_CALL(*password_store_.get(), RemoveLoginImpl(_)).Times(0);
314 } 314 }
315 315
316 content::MockNotificationObserver observer_; 316 content::MockNotificationObserver observer_;
317 scoped_ptr<ProfileMock> profile_; 317 scoped_ptr<TestingProfile> profile_;
318 scoped_refptr<MockPasswordStore> password_store_; 318 scoped_refptr<MockPasswordStore> password_store_;
319 content::NotificationRegistrar registrar_; 319 content::NotificationRegistrar registrar_;
320 }; 320 };
321 321
322 void AddPasswordEntriesCallback(ProfileSyncServicePasswordTest* test, 322 void AddPasswordEntriesCallback(ProfileSyncServicePasswordTest* test,
323 const std::vector<PasswordForm>& entries) { 323 const std::vector<PasswordForm>& entries) {
324 for (size_t i = 0; i < entries.size(); ++i) 324 for (size_t i = 0; i < entries.size(); ++i)
325 test->AddPasswordSyncNode(entries[i]); 325 test->AddPasswordSyncNode(entries[i]);
326 } 326 }
327 327
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 CreateRootHelper create_root(this, syncer::PASSWORDS); 650 CreateRootHelper create_root(this, syncer::PASSWORDS);
651 StartSyncService(create_root.callback(), 651 StartSyncService(create_root.callback(),
652 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); 652 base::Bind(&AddPasswordEntriesCallback, this, sync_forms));
653 653
654 std::vector<PasswordForm> new_sync_forms; 654 std::vector<PasswordForm> new_sync_forms;
655 GetPasswordEntriesFromSyncDB(&new_sync_forms); 655 GetPasswordEntriesFromSyncDB(&new_sync_forms);
656 656
657 EXPECT_EQ(1U, new_sync_forms.size()); 657 EXPECT_EQ(1U, new_sync_forms.size());
658 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); 658 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0]));
659 } 659 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698