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/time.h" | 15 #include "base/time/time.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 17 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
18 #include "chrome/browser/password_manager/mock_password_store.h" | 18 #include "chrome/browser/password_manager/mock_password_store.h" |
19 #include "chrome/browser/password_manager/password_store.h" | 19 #include "chrome/browser/password_manager/password_store.h" |
20 #include "chrome/browser/password_manager/password_store_factory.h" | 20 #include "chrome/browser/password_manager/password_store_factory.h" |
21 #include "chrome/browser/signin/signin_manager.h" | 21 #include "chrome/browser/signin/signin_manager.h" |
22 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
23 #include "chrome/browser/signin/token_service_factory.h" | |
24 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 23 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
25 #include "chrome/browser/sync/fake_oauth2_token_service.h" | 24 #include "chrome/browser/sync/fake_oauth2_token_service.h" |
26 #include "chrome/browser/sync/glue/password_change_processor.h" | 25 #include "chrome/browser/sync/glue/password_change_processor.h" |
27 #include "chrome/browser/sync/glue/password_data_type_controller.h" | 26 #include "chrome/browser/sync/glue/password_data_type_controller.h" |
28 #include "chrome/browser/sync/glue/password_model_associator.h" | 27 #include "chrome/browser/sync/glue/password_model_associator.h" |
29 #include "chrome/browser/sync/profile_sync_components_factory.h" | 28 #include "chrome/browser/sync/profile_sync_components_factory.h" |
30 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 29 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
31 #include "chrome/browser/sync/profile_sync_service.h" | 30 #include "chrome/browser/sync/profile_sync_service.h" |
32 #include "chrome/browser/sync/profile_sync_service_factory.h" | 31 #include "chrome/browser/sync/profile_sync_service_factory.h" |
33 #include "chrome/browser/sync/profile_sync_test_util.h" | 32 #include "chrome/browser/sync/profile_sync_test_util.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); | 189 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); |
191 done.TimedWait(TestTimeouts::action_timeout()); | 190 done.TimedWait(TestTimeouts::action_timeout()); |
192 } | 191 } |
193 | 192 |
194 void StartSyncService(const base::Closure& root_callback, | 193 void StartSyncService(const base::Closure& root_callback, |
195 const base::Closure& node_callback) { | 194 const base::Closure& node_callback) { |
196 if (!sync_service_) { | 195 if (!sync_service_) { |
197 SigninManagerBase* signin = | 196 SigninManagerBase* signin = |
198 SigninManagerFactory::GetForProfile(profile_.get()); | 197 SigninManagerFactory::GetForProfile(profile_.get()); |
199 signin->SetAuthenticatedUsername("test_user@gmail.com"); | 198 signin->SetAuthenticatedUsername("test_user@gmail.com"); |
200 token_service_ = static_cast<TokenService*>( | |
201 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( | |
202 profile_.get(), BuildTokenService)); | |
203 | 199 |
204 PasswordTestProfileSyncService* sync = | 200 PasswordTestProfileSyncService* sync = |
205 static_cast<PasswordTestProfileSyncService*>( | 201 static_cast<PasswordTestProfileSyncService*>( |
206 ProfileSyncServiceFactory::GetInstance()-> | 202 ProfileSyncServiceFactory::GetInstance()-> |
207 SetTestingFactoryAndUse(profile_.get(), | 203 SetTestingFactoryAndUse(profile_.get(), |
208 &PasswordTestProfileSyncService::Build)); | 204 &PasswordTestProfileSyncService::Build)); |
209 sync->set_backend_init_callback(root_callback); | 205 sync->set_backend_init_callback(root_callback); |
210 sync->set_passphrase_accept_callback(node_callback); | 206 sync->set_passphrase_accept_callback(node_callback); |
211 sync_service_ = sync; | 207 sync_service_ = sync; |
212 | 208 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 CreateRootHelper create_root(this, syncer::PASSWORDS); | 648 CreateRootHelper create_root(this, syncer::PASSWORDS); |
653 StartSyncService(create_root.callback(), | 649 StartSyncService(create_root.callback(), |
654 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 650 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
655 | 651 |
656 std::vector<PasswordForm> new_sync_forms; | 652 std::vector<PasswordForm> new_sync_forms; |
657 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 653 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
658 | 654 |
659 EXPECT_EQ(1U, new_sync_forms.size()); | 655 EXPECT_EQ(1U, new_sync_forms.size()); |
660 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 656 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
661 } | 657 } |
OLD | NEW |