OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/sync/glue/autofill_model_associator.h" | 24 #include "chrome/browser/sync/glue/autofill_model_associator.h" |
25 #include "chrome/browser/sync/profile_sync_factory.h" | 25 #include "chrome/browser/sync/profile_sync_factory.h" |
26 #include "chrome/browser/sync/profile_sync_service.h" | 26 #include "chrome/browser/sync/profile_sync_service.h" |
27 #include "chrome/browser/sync/profile_sync_test_util.h" | 27 #include "chrome/browser/sync/profile_sync_test_util.h" |
28 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" | 28 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" |
29 #include "chrome/browser/sync/syncable/model_type.h" | 29 #include "chrome/browser/sync/syncable/model_type.h" |
30 #include "chrome/browser/sync/test_profile_sync_service.h" | 30 #include "chrome/browser/sync/test_profile_sync_service.h" |
31 #include "chrome/browser/webdata/autofill_change.h" | 31 #include "chrome/browser/webdata/autofill_change.h" |
32 #include "chrome/browser/webdata/autofill_entry.h" | 32 #include "chrome/browser/webdata/autofill_entry.h" |
33 #include "chrome/browser/webdata/web_database.h" | 33 #include "chrome/browser/webdata/web_database.h" |
| 34 #include "chrome/common/net/gaia/gaia_constants.h" |
34 #include "chrome/common/notification_source.h" | 35 #include "chrome/common/notification_source.h" |
35 #include "chrome/common/notification_type.h" | 36 #include "chrome/common/notification_type.h" |
36 #include "chrome/test/profile_mock.h" | 37 #include "chrome/test/profile_mock.h" |
37 #include "testing/gmock/include/gmock/gmock.h" | 38 #include "testing/gmock/include/gmock/gmock.h" |
38 | 39 |
39 using base::Time; | 40 using base::Time; |
40 using browser_sync::AutofillChangeProcessor; | 41 using browser_sync::AutofillChangeProcessor; |
41 using browser_sync::AutofillDataTypeController; | 42 using browser_sync::AutofillDataTypeController; |
42 using browser_sync::AutofillModelAssociator; | 43 using browser_sync::AutofillModelAssociator; |
43 using browser_sync::SyncBackendHostForProfileSyncTest; | 44 using browser_sync::SyncBackendHostForProfileSyncTest; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 virtual void TearDown() { | 131 virtual void TearDown() { |
131 service_.reset(); | 132 service_.reset(); |
132 notification_service_->TearDown(); | 133 notification_service_->TearDown(); |
133 db_thread_.Stop(); | 134 db_thread_.Stop(); |
134 MessageLoop::current()->RunAllPending(); | 135 MessageLoop::current()->RunAllPending(); |
135 } | 136 } |
136 | 137 |
137 void StartSyncService(Task* task, bool will_fail_association) { | 138 void StartSyncService(Task* task, bool will_fail_association) { |
138 if (!service_.get()) { | 139 if (!service_.get()) { |
139 service_.reset( | 140 service_.reset( |
140 new TestProfileSyncService(&factory_, &profile_, false, false, | 141 new TestProfileSyncService(&factory_, &profile_, "test_user", false, |
141 task)); | 142 task)); |
142 AutofillDataTypeController* data_type_controller = | 143 AutofillDataTypeController* data_type_controller = |
143 new AutofillDataTypeController(&factory_, | 144 new AutofillDataTypeController(&factory_, |
144 &profile_, | 145 &profile_, |
145 service_.get()); | 146 service_.get()); |
146 | 147 |
147 SyncBackendHostForProfileSyncTest:: | 148 SyncBackendHostForProfileSyncTest:: |
148 SetDefaultExpectationsForWorkerCreation(&profile_); | 149 SetDefaultExpectationsForWorkerCreation(&profile_); |
149 | 150 |
150 EXPECT_CALL(factory_, CreateAutofillSyncComponents(_, _, _, _)). | 151 EXPECT_CALL(factory_, CreateAutofillSyncComponents(_, _, _, _)). |
151 WillOnce(MakeAutofillSyncComponents(service_.get(), | 152 WillOnce(MakeAutofillSyncComponents(service_.get(), |
152 &web_database_, | 153 &web_database_, |
153 personal_data_manager_.get(), | 154 personal_data_manager_.get(), |
154 data_type_controller)); | 155 data_type_controller)); |
155 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). | 156 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). |
156 WillOnce(ReturnNewDataTypeManager()); | 157 WillOnce(ReturnNewDataTypeManager()); |
157 | 158 |
158 EXPECT_CALL(profile_, GetWebDataService(_)). | 159 EXPECT_CALL(profile_, GetWebDataService(_)). |
159 WillOnce(Return(web_data_service_.get())); | 160 WillOnce(Return(web_data_service_.get())); |
160 | 161 |
161 EXPECT_CALL(profile_, GetPersonalDataManager()). | 162 EXPECT_CALL(profile_, GetPersonalDataManager()). |
162 WillRepeatedly(Return(personal_data_manager_.get())); | 163 WillRepeatedly(Return(personal_data_manager_.get())); |
163 | 164 |
164 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). | 165 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). |
165 WillRepeatedly(Return(true)); | 166 WillRepeatedly(Return(true)); |
166 | 167 |
| 168 // We need tokens to get the tests going |
| 169 token_service_.IssueAuthTokenForTest( |
| 170 GaiaConstants::kSyncService, "token"); |
| 171 |
| 172 EXPECT_CALL(profile_, GetTokenService()). |
| 173 WillRepeatedly(Return(&token_service_)); |
| 174 |
167 service_->set_num_expected_resumes(will_fail_association ? 0 : 1); | 175 service_->set_num_expected_resumes(will_fail_association ? 0 : 1); |
168 service_->RegisterDataTypeController(data_type_controller); | 176 service_->RegisterDataTypeController(data_type_controller); |
169 service_->Initialize(); | 177 service_->Initialize(); |
170 MessageLoop::current()->Run(); | 178 MessageLoop::current()->Run(); |
171 } | 179 } |
172 } | 180 } |
173 | 181 |
174 bool AddAutofillSyncNode(const AutofillEntry& entry) { | 182 bool AddAutofillSyncNode(const AutofillEntry& entry) { |
175 sync_api::WriteTransaction trans( | 183 sync_api::WriteTransaction trans( |
176 service_->backend()->GetUserShareHandle()); | 184 service_->backend()->GetUserShareHandle()); |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 service_->AddObserver(&observer); | 986 service_->AddObserver(&observer); |
979 EXPECT_CALL(observer, OnStateChanged()).WillOnce(QuitUIMessageLoop()); | 987 EXPECT_CALL(observer, OnStateChanged()).WillOnce(QuitUIMessageLoop()); |
980 MessageLoop::current()->Run(); | 988 MessageLoop::current()->Run(); |
981 EXPECT_TRUE(service_->unrecoverable_error_detected()); | 989 EXPECT_TRUE(service_->unrecoverable_error_detected()); |
982 | 990 |
983 // Ensure future autofill notifications don't crash. | 991 // Ensure future autofill notifications don't crash. |
984 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED, | 992 notifier->Notify(NotificationType::AUTOFILL_ENTRIES_CHANGED, |
985 Source<WebDataService>(web_data_service_.get()), | 993 Source<WebDataService>(web_data_service_.get()), |
986 Details<AutofillChangeList>(&changes)); | 994 Details<AutofillChangeList>(&changes)); |
987 } | 995 } |
OLD | NEW |