OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/tracked.h" | 13 #include "base/tracked.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/password_manager/password_store.h" | 15 #include "chrome/browser/password_manager/password_store.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 17 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
18 #include "chrome/browser/sync/engine/syncapi.h" | 18 #include "chrome/browser/sync/engine/syncapi.h" |
19 #include "chrome/browser/sync/glue/password_change_processor.h" | 19 #include "chrome/browser/sync/glue/password_change_processor.h" |
20 #include "chrome/browser/sync/glue/password_data_type_controller.h" | 20 #include "chrome/browser/sync/glue/password_data_type_controller.h" |
21 #include "chrome/browser/sync/glue/password_model_associator.h" | 21 #include "chrome/browser/sync/glue/password_model_associator.h" |
22 #include "chrome/browser/sync/profile_sync_factory.h" | 22 #include "chrome/browser/sync/profile_sync_factory.h" |
23 #include "chrome/browser/sync/profile_sync_factory_mock.h" | 23 #include "chrome/browser/sync/profile_sync_factory_mock.h" |
24 #include "chrome/browser/sync/profile_sync_service.h" | 24 #include "chrome/browser/sync/profile_sync_service.h" |
25 #include "chrome/browser/sync/profile_sync_test_util.h" | 25 #include "chrome/browser/sync/profile_sync_test_util.h" |
26 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | 26 #include "chrome/browser/sync/protocol/password_specifics.pb.h" |
27 #include "chrome/browser/sync/syncable/directory_manager.h" | 27 #include "chrome/browser/sync/syncable/directory_manager.h" |
28 #include "chrome/browser/sync/syncable/syncable.h" | 28 #include "chrome/browser/sync/syncable/syncable.h" |
29 #include "chrome/browser/sync/test_profile_sync_service.h" | 29 #include "chrome/browser/sync/test_profile_sync_service.h" |
| 30 #include "chrome/common/chrome_notification_types.h" |
30 #include "chrome/common/net/gaia/gaia_constants.h" | 31 #include "chrome/common/net/gaia/gaia_constants.h" |
31 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
32 #include "chrome/test/sync/engine/test_id_factory.h" | 33 #include "chrome/test/sync/engine/test_id_factory.h" |
33 #include "chrome/test/profile_mock.h" | 34 #include "chrome/test/profile_mock.h" |
34 #include "content/browser/browser_thread.h" | 35 #include "content/browser/browser_thread.h" |
35 #include "content/common/notification_observer_mock.h" | 36 #include "content/common/notification_observer_mock.h" |
36 #include "content/common/notification_source.h" | 37 #include "content/common/notification_source.h" |
37 #include "content/common/notification_type.h" | |
38 #include "testing/gmock/include/gmock/gmock.h" | 38 #include "testing/gmock/include/gmock/gmock.h" |
39 #include "webkit/glue/password_form.h" | 39 #include "webkit/glue/password_form.h" |
40 | 40 |
41 using base::Time; | 41 using base::Time; |
42 using browser_sync::PasswordChangeProcessor; | 42 using browser_sync::PasswordChangeProcessor; |
43 using browser_sync::PasswordDataTypeController; | 43 using browser_sync::PasswordDataTypeController; |
44 using browser_sync::PasswordModelAssociator; | 44 using browser_sync::PasswordModelAssociator; |
45 using browser_sync::TestIdFactory; | 45 using browser_sync::TestIdFactory; |
46 using browser_sync::UnrecoverableErrorHandler; | 46 using browser_sync::UnrecoverableErrorHandler; |
47 using sync_api::SyncManager; | 47 using sync_api::SyncManager; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 ProfileSyncServicePasswordTest() {} | 154 ProfileSyncServicePasswordTest() {} |
155 | 155 |
156 virtual void SetUp() { | 156 virtual void SetUp() { |
157 AbstractProfileSyncServiceTest::SetUp(); | 157 AbstractProfileSyncServiceTest::SetUp(); |
158 profile_.CreateRequestContext(); | 158 profile_.CreateRequestContext(); |
159 password_store_ = new MockPasswordStore(); | 159 password_store_ = new MockPasswordStore(); |
160 | 160 |
161 notification_service_ = new ThreadNotificationService(&db_thread_); | 161 notification_service_ = new ThreadNotificationService(&db_thread_); |
162 notification_service_->Init(); | 162 notification_service_->Init(); |
163 registrar_.Add(&observer_, | 163 registrar_.Add(&observer_, |
164 NotificationType::SYNC_CONFIGURE_DONE, | 164 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, |
165 NotificationService::AllSources()); | 165 NotificationService::AllSources()); |
166 registrar_.Add(&observer_, | 166 registrar_.Add(&observer_, |
167 NotificationType::SYNC_CONFIGURE_BLOCKED, | 167 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED, |
168 NotificationService::AllSources()); | 168 NotificationService::AllSources()); |
169 } | 169 } |
170 | 170 |
171 virtual void TearDown() { | 171 virtual void TearDown() { |
172 password_store_->Shutdown(); | 172 password_store_->Shutdown(); |
173 service_.reset(); | 173 service_.reset(); |
174 notification_service_->TearDown(); | 174 notification_service_->TearDown(); |
175 profile_.ResetRequestContext(); | 175 profile_.ResetRequestContext(); |
176 AbstractProfileSyncServiceTest::TearDown(); | 176 AbstractProfileSyncServiceTest::TearDown(); |
177 } | 177 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 EXPECT_CALL(profile_, GetTokenService()). | 216 EXPECT_CALL(profile_, GetTokenService()). |
217 WillRepeatedly(Return(&token_service_)); | 217 WillRepeatedly(Return(&token_service_)); |
218 | 218 |
219 EXPECT_CALL(profile_, GetPasswordStore(_)). | 219 EXPECT_CALL(profile_, GetPasswordStore(_)). |
220 Times(AtLeast(2)). // Can be more if we hit NEEDS_CRYPTO. | 220 Times(AtLeast(2)). // Can be more if we hit NEEDS_CRYPTO. |
221 WillRepeatedly(Return(password_store_.get())); | 221 WillRepeatedly(Return(password_store_.get())); |
222 | 222 |
223 EXPECT_CALL(observer_, | 223 EXPECT_CALL(observer_, |
224 Observe( | 224 Observe( |
225 NotificationType(NotificationType::SYNC_CONFIGURE_DONE),_,_)); | 225 int(chrome::NOTIFICATION_SYNC_CONFIGURE_DONE),_,_)); |
226 EXPECT_CALL(observer_, | 226 EXPECT_CALL(observer_, |
227 Observe( | 227 Observe( |
228 NotificationType( | 228 int( |
229 NotificationType::SYNC_CONFIGURE_BLOCKED),_,_)) | 229 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED),_,_)) |
230 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 230 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
231 | 231 |
232 service_->RegisterDataTypeController(data_type_controller); | 232 service_->RegisterDataTypeController(data_type_controller); |
233 service_->Initialize(); | 233 service_->Initialize(); |
234 MessageLoop::current()->Run(); | 234 MessageLoop::current()->Run(); |
235 FlushLastDBTask(); | 235 FlushLastDBTask(); |
236 | 236 |
237 service_->SetPassphrase("foo", false, true); | 237 service_->SetPassphrase("foo", false, true); |
238 MessageLoop::current()->Run(); | 238 MessageLoop::current()->Run(); |
239 } | 239 } |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 AddPasswordEntriesTask node_task(this, sync_forms); | 612 AddPasswordEntriesTask node_task(this, sync_forms); |
613 | 613 |
614 StartSyncService(&root_task, &node_task); | 614 StartSyncService(&root_task, &node_task); |
615 | 615 |
616 std::vector<PasswordForm> new_sync_forms; | 616 std::vector<PasswordForm> new_sync_forms; |
617 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 617 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
618 | 618 |
619 EXPECT_EQ(1U, new_sync_forms.size()); | 619 EXPECT_EQ(1U, new_sync_forms.size()); |
620 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 620 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
621 } | 621 } |
OLD | NEW |