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