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 14 matching lines...) Expand all Loading... | |
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" | 35 #include "chrome/test/base/profile_mock.h" |
Raghu Simha
2013/08/20 00:16:29
This include seems unnecessary now.
Andrew T Wilson (Slow)
2013/08/20 09:28:35
Done.
| |
36 #include "content/public/browser/notification_source.h" | 36 #include "content/public/browser/notification_source.h" |
37 #include "content/public/common/password_form.h" | 37 #include "content/public/common/password_form.h" |
38 #include "content/public/test/mock_notification_observer.h" | 38 #include "content/public/test/mock_notification_observer.h" |
39 #include "content/public/test/test_browser_thread.h" | 39 #include "content/public/test/test_browser_thread.h" |
40 #include "google_apis/gaia/gaia_constants.h" | 40 #include "google_apis/gaia/gaia_constants.h" |
41 #include "sync/internal_api/public/read_node.h" | 41 #include "sync/internal_api/public/read_node.h" |
42 #include "sync/internal_api/public/read_transaction.h" | 42 #include "sync/internal_api/public/read_transaction.h" |
43 #include "sync/internal_api/public/write_node.h" | 43 #include "sync/internal_api/public/write_node.h" |
44 #include "sync/internal_api/public/write_transaction.h" | 44 #include "sync/internal_api/public/write_transaction.h" |
45 #include "sync/protocol/password_specifics.pb.h" | 45 #include "sync/protocol/password_specifics.pb.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 } |
OLD | NEW |