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/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
16 #include "chrome/browser/password_manager/mock_password_store.h" | 18 #include "chrome/browser/password_manager/mock_password_store.h" |
17 #include "chrome/browser/password_manager/password_store.h" | 19 #include "chrome/browser/password_manager/password_store.h" |
18 #include "chrome/browser/password_manager/password_store_factory.h" | 20 #include "chrome/browser/password_manager/password_store_factory.h" |
19 #include "chrome/browser/signin/signin_manager.h" | 21 #include "chrome/browser/signin/signin_manager.h" |
20 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
21 #include "chrome/browser/signin/token_service_factory.h" | 23 #include "chrome/browser/signin/token_service_factory.h" |
22 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 24 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
23 #include "chrome/browser/sync/glue/password_change_processor.h" | 25 #include "chrome/browser/sync/glue/password_change_processor.h" |
24 #include "chrome/browser/sync/glue/password_data_type_controller.h" | 26 #include "chrome/browser/sync/glue/password_data_type_controller.h" |
25 #include "chrome/browser/sync/glue/password_model_associator.h" | 27 #include "chrome/browser/sync/glue/password_model_associator.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); | 149 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); |
148 PasswordModelAssociator::WriteToSyncNode(entry, &node); | 150 PasswordModelAssociator::WriteToSyncNode(entry, &node); |
149 } | 151 } |
150 | 152 |
151 protected: | 153 protected: |
152 ProfileSyncServicePasswordTest() {} | 154 ProfileSyncServicePasswordTest() {} |
153 | 155 |
154 virtual void SetUp() { | 156 virtual void SetUp() { |
155 AbstractProfileSyncServiceTest::SetUp(); | 157 AbstractProfileSyncServiceTest::SetUp(); |
156 profile_.CreateRequestContext(); | 158 profile_.CreateRequestContext(); |
| 159 invalidation::InvalidationServiceFactory::GetInstance()-> |
| 160 SetBuildOnlyFakeInvalidatorsForTest(true); |
157 password_store_ = static_cast<MockPasswordStore*>( | 161 password_store_ = static_cast<MockPasswordStore*>( |
158 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( | 162 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( |
159 &profile_, MockPasswordStore::Build).get()); | 163 &profile_, MockPasswordStore::Build).get()); |
160 } | 164 } |
161 | 165 |
162 virtual void TearDown() { | 166 virtual void TearDown() { |
163 if (password_store_.get()) | 167 if (password_store_.get()) |
164 password_store_->ShutdownOnUIThread(); | 168 password_store_->ShutdownOnUIThread(); |
165 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( | 169 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( |
166 &profile_, NULL); | 170 &profile_, NULL); |
(...skipping 11 matching lines...) Expand all Loading... |
178 BrowserThread::DB, FROM_HERE, | 182 BrowserThread::DB, FROM_HERE, |
179 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); | 183 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); |
180 done.TimedWait(TestTimeouts::action_timeout()); | 184 done.TimedWait(TestTimeouts::action_timeout()); |
181 } | 185 } |
182 | 186 |
183 void StartSyncService(const base::Closure& root_callback, | 187 void StartSyncService(const base::Closure& root_callback, |
184 const base::Closure& node_callback) { | 188 const base::Closure& node_callback) { |
185 if (!sync_service_) { | 189 if (!sync_service_) { |
186 SigninManagerBase* signin = | 190 SigninManagerBase* signin = |
187 SigninManagerFactory::GetForProfile(&profile_); | 191 SigninManagerFactory::GetForProfile(&profile_); |
188 signin->SetAuthenticatedUsername("test_user"); | 192 signin->SetAuthenticatedUsername("test_user@gmail.com"); |
189 token_service_ = static_cast<TokenService*>( | 193 token_service_ = static_cast<TokenService*>( |
190 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 194 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
191 &profile_, BuildTokenService)); | 195 &profile_, BuildTokenService)); |
192 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( | 196 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( |
193 &profile_, FakeOAuth2TokenService::BuildTokenService); | 197 &profile_, FakeOAuth2TokenService::BuildTokenService); |
194 | 198 |
195 PasswordTestProfileSyncService* sync = | 199 PasswordTestProfileSyncService* sync = |
196 static_cast<PasswordTestProfileSyncService*>( | 200 static_cast<PasswordTestProfileSyncService*>( |
197 ProfileSyncServiceFactory::GetInstance()-> | 201 ProfileSyncServiceFactory::GetInstance()-> |
198 SetTestingFactoryAndUse(&profile_, | 202 SetTestingFactoryAndUse(&profile_, |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 CreateRootHelper create_root(this, syncer::PASSWORDS); | 651 CreateRootHelper create_root(this, syncer::PASSWORDS); |
648 StartSyncService(create_root.callback(), | 652 StartSyncService(create_root.callback(), |
649 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 653 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
650 | 654 |
651 std::vector<PasswordForm> new_sync_forms; | 655 std::vector<PasswordForm> new_sync_forms; |
652 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 656 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
653 | 657 |
654 EXPECT_EQ(1U, new_sync_forms.size()); | 658 EXPECT_EQ(1U, new_sync_forms.size()); |
655 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 659 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
656 } | 660 } |
OLD | NEW |