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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "base/task.h" | 12 #include "base/task.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/password_manager/password_store.h" | 16 #include "chrome/browser/password_manager/password_store.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 18 #include "chrome/browser/sync/abstract_profile_sync_service_test.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/internal_api/read_node.h" | 22 #include "chrome/browser/sync/internal_api/read_node.h" |
23 #include "chrome/browser/sync/internal_api/read_transaction.h" | 23 #include "chrome/browser/sync/internal_api/read_transaction.h" |
24 #include "chrome/browser/sync/internal_api/write_node.h" | 24 #include "chrome/browser/sync/internal_api/write_node.h" |
25 #include "chrome/browser/sync/internal_api/write_transaction.h" | 25 #include "chrome/browser/sync/internal_api/write_transaction.h" |
26 #include "chrome/browser/sync/profile_sync_factory.h" | 26 #include "chrome/browser/sync/profile_sync_components_factory.h" |
27 #include "chrome/browser/sync/profile_sync_factory_mock.h" | 27 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
28 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
29 #include "chrome/browser/sync/profile_sync_test_util.h" | 29 #include "chrome/browser/sync/profile_sync_test_util.h" |
30 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | 30 #include "chrome/browser/sync/protocol/password_specifics.pb.h" |
31 #include "chrome/browser/sync/syncable/directory_manager.h" | 31 #include "chrome/browser/sync/syncable/directory_manager.h" |
32 #include "chrome/browser/sync/syncable/syncable.h" | 32 #include "chrome/browser/sync/syncable/syncable.h" |
33 #include "chrome/browser/sync/test/engine/test_id_factory.h" | 33 #include "chrome/browser/sync/test/engine/test_id_factory.h" |
34 #include "chrome/browser/sync/test_profile_sync_service.h" | 34 #include "chrome/browser/sync/test_profile_sync_service.h" |
35 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
36 #include "chrome/common/net/gaia/gaia_constants.h" | 36 #include "chrome/common/net/gaia/gaia_constants.h" |
37 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 using testing::SaveArg; | 78 using testing::SaveArg; |
79 using testing::SetArgumentPointee; | 79 using testing::SetArgumentPointee; |
80 using webkit_glue::PasswordForm; | 80 using webkit_glue::PasswordForm; |
81 | 81 |
82 ACTION_P3(MakePasswordSyncComponents, service, ps, dtc) { | 82 ACTION_P3(MakePasswordSyncComponents, service, ps, dtc) { |
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
84 PasswordModelAssociator* model_associator = | 84 PasswordModelAssociator* model_associator = |
85 new PasswordModelAssociator(service, ps); | 85 new PasswordModelAssociator(service, ps); |
86 PasswordChangeProcessor* change_processor = | 86 PasswordChangeProcessor* change_processor = |
87 new PasswordChangeProcessor(model_associator, ps, dtc); | 87 new PasswordChangeProcessor(model_associator, ps, dtc); |
88 return ProfileSyncFactory::SyncComponents(model_associator, | 88 return ProfileSyncComponentsFactory::SyncComponents(model_associator, |
89 change_processor); | 89 change_processor); |
Nicolas Zea
2011/11/22 00:01:03
indent
| |
90 } | 90 } |
91 | 91 |
92 ACTION_P(AcquireSyncTransaction, password_test_service) { | 92 ACTION_P(AcquireSyncTransaction, password_test_service) { |
93 // Check to make sure we can aquire a transaction (will crash if a transaction | 93 // Check to make sure we can aquire a transaction (will crash if a transaction |
94 // is already held by this thread, deadlock if held by another thread). | 94 // is already held by this thread, deadlock if held by another thread). |
95 sync_api::WriteTransaction trans( | 95 sync_api::WriteTransaction trans( |
96 FROM_HERE, password_test_service->GetUserShare()); | 96 FROM_HERE, password_test_service->GetUserShare()); |
97 VLOG(1) << "Sync transaction acquired."; | 97 VLOG(1) << "Sync transaction acquired."; |
98 } | 98 } |
99 | 99 |
(...skipping 18 matching lines...) Expand all Loading... | |
118 MOCK_METHOD1(GetAutofillableLoginsImpl, void(GetLoginsRequest*)); | 118 MOCK_METHOD1(GetAutofillableLoginsImpl, void(GetLoginsRequest*)); |
119 MOCK_METHOD1(GetBlacklistLoginsImpl, void(GetLoginsRequest*)); | 119 MOCK_METHOD1(GetBlacklistLoginsImpl, void(GetLoginsRequest*)); |
120 MOCK_METHOD1(FillAutofillableLogins, | 120 MOCK_METHOD1(FillAutofillableLogins, |
121 bool(std::vector<PasswordForm*>*)); | 121 bool(std::vector<PasswordForm*>*)); |
122 MOCK_METHOD1(FillBlacklistLogins, | 122 MOCK_METHOD1(FillBlacklistLogins, |
123 bool(std::vector<PasswordForm*>*)); | 123 bool(std::vector<PasswordForm*>*)); |
124 }; | 124 }; |
125 | 125 |
126 class PasswordTestProfileSyncService : public TestProfileSyncService { | 126 class PasswordTestProfileSyncService : public TestProfileSyncService { |
127 public: | 127 public: |
128 PasswordTestProfileSyncService(ProfileSyncFactory* factory, | 128 PasswordTestProfileSyncService(ProfileSyncComponentsFactory* factory, |
129 Profile* profile, | 129 Profile* profile, |
130 const std::string& test_user, | 130 const std::string& test_user, |
131 bool synchronous_backend_initialization, | 131 bool synchronous_backend_initialization, |
132 Task* initial_condition_setup_task, | 132 Task* initial_condition_setup_task, |
133 Task* passphrase_accept_task) | 133 Task* passphrase_accept_task) |
134 : TestProfileSyncService(factory, profile, test_user, | 134 : TestProfileSyncService(factory, profile, test_user, |
135 synchronous_backend_initialization, | 135 synchronous_backend_initialization, |
136 initial_condition_setup_task), | 136 initial_condition_setup_task), |
137 passphrase_accept_task_(passphrase_accept_task) {} | 137 passphrase_accept_task_(passphrase_accept_task) {} |
138 | 138 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 AddPasswordEntriesTask node_task(this, sync_forms); | 620 AddPasswordEntriesTask node_task(this, sync_forms); |
621 | 621 |
622 StartSyncService(&root_task, &node_task); | 622 StartSyncService(&root_task, &node_task); |
623 | 623 |
624 std::vector<PasswordForm> new_sync_forms; | 624 std::vector<PasswordForm> new_sync_forms; |
625 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 625 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
626 | 626 |
627 EXPECT_EQ(1U, new_sync_forms.size()); | 627 EXPECT_EQ(1U, new_sync_forms.size()); |
628 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 628 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
629 } | 629 } |
OLD | NEW |