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" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/invalidation_service_factory.h" |
16 #include "chrome/browser/password_manager/mock_password_store.h" | 17 #include "chrome/browser/password_manager/mock_password_store.h" |
17 #include "chrome/browser/password_manager/password_store.h" | 18 #include "chrome/browser/password_manager/password_store.h" |
18 #include "chrome/browser/password_manager/password_store_factory.h" | 19 #include "chrome/browser/password_manager/password_store_factory.h" |
19 #include "chrome/browser/signin/signin_manager.h" | 20 #include "chrome/browser/signin/signin_manager.h" |
20 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
21 #include "chrome/browser/signin/token_service_factory.h" | 22 #include "chrome/browser/signin/token_service_factory.h" |
22 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 23 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
23 #include "chrome/browser/sync/glue/password_change_processor.h" | 24 #include "chrome/browser/sync/glue/password_change_processor.h" |
24 #include "chrome/browser/sync/glue/password_data_type_controller.h" | 25 #include "chrome/browser/sync/glue/password_data_type_controller.h" |
25 #include "chrome/browser/sync/glue/password_model_associator.h" | 26 #include "chrome/browser/sync/glue/password_model_associator.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); | 163 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); |
163 PasswordModelAssociator::WriteToSyncNode(entry, &node); | 164 PasswordModelAssociator::WriteToSyncNode(entry, &node); |
164 } | 165 } |
165 | 166 |
166 protected: | 167 protected: |
167 ProfileSyncServicePasswordTest() {} | 168 ProfileSyncServicePasswordTest() {} |
168 | 169 |
169 virtual void SetUp() { | 170 virtual void SetUp() { |
170 AbstractProfileSyncServiceTest::SetUp(); | 171 AbstractProfileSyncServiceTest::SetUp(); |
171 profile_.CreateRequestContext(); | 172 profile_.CreateRequestContext(); |
| 173 InvalidationServiceFactory::GetInstance()->SetTestingFactory( |
| 174 &profile_, InvalidationServiceFactory::BuildTestServiceInstanceFor); |
172 password_store_ = static_cast<MockPasswordStore*>( | 175 password_store_ = static_cast<MockPasswordStore*>( |
173 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( | 176 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( |
174 &profile_, MockPasswordStore::Build).get()); | 177 &profile_, MockPasswordStore::Build).get()); |
175 } | 178 } |
176 | 179 |
177 virtual void TearDown() { | 180 virtual void TearDown() { |
178 if (password_store_.get()) | 181 if (password_store_.get()) |
179 password_store_->ShutdownOnUIThread(); | 182 password_store_->ShutdownOnUIThread(); |
180 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( | 183 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( |
181 &profile_, NULL); | 184 &profile_, NULL); |
(...skipping 10 matching lines...) Expand all Loading... |
192 BrowserThread::PostTask( | 195 BrowserThread::PostTask( |
193 BrowserThread::DB, FROM_HERE, | 196 BrowserThread::DB, FROM_HERE, |
194 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); | 197 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); |
195 done.TimedWait(TestTimeouts::action_timeout()); | 198 done.TimedWait(TestTimeouts::action_timeout()); |
196 } | 199 } |
197 | 200 |
198 void StartSyncService(const base::Closure& root_callback, | 201 void StartSyncService(const base::Closure& root_callback, |
199 const base::Closure& node_callback) { | 202 const base::Closure& node_callback) { |
200 if (!sync_service_) { | 203 if (!sync_service_) { |
201 SigninManager* signin = SigninManagerFactory::GetForProfile(&profile_); | 204 SigninManager* signin = SigninManagerFactory::GetForProfile(&profile_); |
202 signin->SetAuthenticatedUsername("test_user"); | 205 signin->SetAuthenticatedUsername("testuser@gmail.com"); |
203 token_service_ = static_cast<TokenService*>( | 206 token_service_ = static_cast<TokenService*>( |
204 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 207 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
205 &profile_, BuildTokenService)); | 208 &profile_, BuildTokenService)); |
206 | 209 |
207 PasswordTestProfileSyncService* sync = | 210 PasswordTestProfileSyncService* sync = |
208 static_cast<PasswordTestProfileSyncService*>( | 211 static_cast<PasswordTestProfileSyncService*>( |
209 ProfileSyncServiceFactory::GetInstance()-> | 212 ProfileSyncServiceFactory::GetInstance()-> |
210 SetTestingFactoryAndUse(&profile_, | 213 SetTestingFactoryAndUse(&profile_, |
211 &PasswordTestProfileSyncService::Build)); | 214 &PasswordTestProfileSyncService::Build)); |
212 sync->set_backend_init_callback(root_callback); | 215 sync->set_backend_init_callback(root_callback); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 CreateRootHelper create_root(this, syncer::PASSWORDS); | 636 CreateRootHelper create_root(this, syncer::PASSWORDS); |
634 StartSyncService(create_root.callback(), | 637 StartSyncService(create_root.callback(), |
635 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 638 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
636 | 639 |
637 std::vector<PasswordForm> new_sync_forms; | 640 std::vector<PasswordForm> new_sync_forms; |
638 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 641 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
639 | 642 |
640 EXPECT_EQ(1U, new_sync_forms.size()); | 643 EXPECT_EQ(1U, new_sync_forms.size()); |
641 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 644 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
642 } | 645 } |
OLD | NEW |