Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/sync/profile_sync_service_autofill_unittest.cc

Issue 12695015: Split Autofill webdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Win build Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <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 22 matching lines...) Expand all
33 #include "chrome/browser/sync/profile_sync_components_factory.h" 33 #include "chrome/browser/sync/profile_sync_components_factory.h"
34 #include "chrome/browser/sync/profile_sync_service.h" 34 #include "chrome/browser/sync/profile_sync_service.h"
35 #include "chrome/browser/sync/profile_sync_service_factory.h" 35 #include "chrome/browser/sync/profile_sync_service_factory.h"
36 #include "chrome/browser/sync/profile_sync_test_util.h" 36 #include "chrome/browser/sync/profile_sync_test_util.h"
37 #include "chrome/browser/sync/test_profile_sync_service.h" 37 #include "chrome/browser/sync/test_profile_sync_service.h"
38 #include "chrome/browser/webdata/autocomplete_syncable_service.h" 38 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
39 #include "chrome/browser/webdata/autofill_change.h" 39 #include "chrome/browser/webdata/autofill_change.h"
40 #include "chrome/browser/webdata/autofill_entry.h" 40 #include "chrome/browser/webdata/autofill_entry.h"
41 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 41 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
42 #include "chrome/browser/webdata/autofill_table.h" 42 #include "chrome/browser/webdata/autofill_table.h"
43 #include "chrome/browser/webdata/web_data_service.h" 43 #include "chrome/browser/webdata/autofill_web_data_service_impl.h"
44 #include "chrome/browser/webdata/web_data_service_factory.h" 44 #include "chrome/browser/webdata/web_data_service_factory.h"
45 #include "chrome/browser/webdata/web_data_service_test_util.h" 45 #include "chrome/browser/webdata/web_data_service_test_util.h"
46 #include "chrome/browser/webdata/web_database.h" 46 #include "chrome/browser/webdata/web_database.h"
47 #include "chrome/common/chrome_notification_types.h" 47 #include "chrome/common/chrome_notification_types.h"
48 #include "components/autofill/browser/autofill_common_test.h" 48 #include "components/autofill/browser/autofill_common_test.h"
49 #include "components/autofill/browser/personal_data_manager.h" 49 #include "components/autofill/browser/personal_data_manager.h"
50 #include "content/public/browser/notification_source.h" 50 #include "content/public/browser/notification_source.h"
51 #include "content/public/test/test_browser_thread.h" 51 #include "content/public/test/test_browser_thread.h"
52 #include "google_apis/gaia/gaia_constants.h" 52 #include "google_apis/gaia/gaia_constants.h"
53 #include "sync/internal_api/public/base/model_type.h" 53 #include "sync/internal_api/public/base/model_type.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 template<> 137 template<>
138 syncer::ModelType GetModelType<AutofillEntry>() { 138 syncer::ModelType GetModelType<AutofillEntry>() {
139 return syncer::AUTOFILL; 139 return syncer::AUTOFILL;
140 } 140 }
141 141
142 template<> 142 template<>
143 syncer::ModelType GetModelType<AutofillProfile>() { 143 syncer::ModelType GetModelType<AutofillProfile>() {
144 return syncer::AUTOFILL_PROFILE; 144 return syncer::AUTOFILL_PROFILE;
145 } 145 }
146 146
147 class WebDataServiceFake : public WebDataService { 147 class TokenWebDataServiceFake : public WebDataService {
148 public:
149 TokenWebDataServiceFake()
150 : WebDataService() {
151 }
152
153 virtual bool IsDatabaseLoaded() OVERRIDE {
154 return true;
155 }
156
157 virtual WebDataService::Handle GetAllTokens(
158 WebDataServiceConsumer* consumer) OVERRIDE {
159 // TODO(tim): It would be nice if WebDataService was injected on
160 // construction of TokenService rather than fetched by Initialize so that
161 // this isn't necessary (we could pass a NULL service). We currently do
162 // return it via EXPECT_CALLs, but without depending on order-of-
163 // initialization (which seems way more fragile) we can't tell which
164 // component is asking at what time, and some components in these Autofill
165 // tests require a WebDataService.
166 return 0;
167 }
168
169 private:
170 virtual ~TokenWebDataServiceFake() {}
171
172 DISALLOW_COPY_AND_ASSIGN(TokenWebDataServiceFake);
173 };
174
175 class WebDataServiceFake : public AutofillWebDataServiceImpl {
148 public: 176 public:
149 WebDataServiceFake() 177 WebDataServiceFake()
150 : web_database_(NULL), 178 : AutofillWebDataServiceImpl(
179 NULL, WebDataServiceBase::ProfileErrorCallback()),
180 web_database_(NULL),
151 syncable_service_created_or_destroyed_(false, false) { 181 syncable_service_created_or_destroyed_(false, false) {
152 } 182 }
153 183
154 void SetDatabase(WebDatabase* web_database) { 184 void SetDatabase(WebDatabase* web_database) {
155 web_database_ = web_database; 185 web_database_ = web_database;
156 } 186 }
157 187
158 void StartSyncableService() { 188 void StartSyncableService() {
159 // The |autofill_profile_syncable_service_| must be constructed on the DB 189 // The |autofill_profile_syncable_service_| must be constructed on the DB
160 // thread. 190 // thread.
(...skipping 13 matching lines...) Expand all
174 } 204 }
175 205
176 virtual bool IsDatabaseLoaded() OVERRIDE { 206 virtual bool IsDatabaseLoaded() OVERRIDE {
177 return true; 207 return true;
178 } 208 }
179 209
180 virtual WebDatabase* GetDatabase() OVERRIDE { 210 virtual WebDatabase* GetDatabase() OVERRIDE {
181 return web_database_; 211 return web_database_;
182 } 212 }
183 213
184 virtual WebDataService::Handle GetAllTokens(
185 WebDataServiceConsumer* consumer) OVERRIDE {
186 // TODO(tim): It would be nice if WebDataService was injected on
187 // construction of TokenService rather than fetched by Initialize so that
188 // this isn't necessary (we could pass a NULL service). We currently do
189 // return it via EXPECT_CALLs, but without depending on order-of-
190 // initialization (which seems way more fragile) we can't tell which
191 // component is asking at what time, and some components in these Autofill
192 // tests require a WebDataService.
193 return 0;
194 }
195
196 virtual void ShutdownOnUIThread() OVERRIDE {} 214 virtual void ShutdownOnUIThread() OVERRIDE {}
197 215
198 private: 216 private:
199 virtual ~WebDataServiceFake() {} 217 virtual ~WebDataServiceFake() {}
200 218
201 void CreateSyncableService() { 219 void CreateSyncableService() {
202 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 220 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
203 // These services are deleted in DestroySyncableService(). 221 // These services are deleted in DestroySyncableService().
204 AutocompleteSyncableService::CreateForWebDataService(this); 222 AutocompleteSyncableService::CreateForWebDataService(this);
205 AutofillProfileSyncableService::CreateForWebDataService(this); 223 AutofillProfileSyncableService::CreateForWebDataService(this);
206 syncable_service_created_or_destroyed_.Signal(); 224 syncable_service_created_or_destroyed_.Signal();
207 } 225 }
208 226
209 void DestroySyncableService() { 227 void DestroySyncableService() {
210 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 228 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
211 WebDataServiceBase::ShutdownOnDBThread(); 229 WebDataServiceBase::ShutdownOnDBThread();
212 syncable_service_created_or_destroyed_.Signal(); 230 syncable_service_created_or_destroyed_.Signal();
213 } 231 }
214 232
215 WebDatabase* web_database_; 233 WebDatabase* web_database_;
216 234
217 WaitableEvent syncable_service_created_or_destroyed_; 235 WaitableEvent syncable_service_created_or_destroyed_;
236
237 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFake);
218 }; 238 };
219 239
220 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) { 240 ProfileKeyedService* BuildMockWebDataServiceWrapper(Profile* profile) {
221 return new MockWebDataServiceWrapper(new WebDataServiceFake()); 241 return new MockWebDataServiceWrapper(
242 new TokenWebDataServiceFake(),
243 new WebDataServiceFake());
222 } 244 }
223 245
224 ACTION_P(MakeAutocompleteSyncComponents, wds) { 246 ACTION_P(MakeAutocompleteSyncComponents, wds) {
225 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 247 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
226 if (!BrowserThread::CurrentlyOn(BrowserThread::DB)) 248 if (!BrowserThread::CurrentlyOn(BrowserThread::DB))
227 return base::WeakPtr<syncer::SyncableService>(); 249 return base::WeakPtr<syncer::SyncableService>();
228 return AutocompleteSyncableService::FromWebDataService(wds)->AsWeakPtr(); 250 return AutocompleteSyncableService::FromWebDataService(wds)->AsWeakPtr();
229 } 251 }
230 252
231 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) { 253 ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) {
(...skipping 26 matching lines...) Expand all
258 } 280 }
259 281
260 class AbstractAutofillFactory { 282 class AbstractAutofillFactory {
261 public: 283 public:
262 virtual DataTypeController* CreateDataTypeController( 284 virtual DataTypeController* CreateDataTypeController(
263 ProfileSyncComponentsFactory* factory, 285 ProfileSyncComponentsFactory* factory,
264 ProfileMock* profile, 286 ProfileMock* profile,
265 ProfileSyncService* service) = 0; 287 ProfileSyncService* service) = 0;
266 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 288 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
267 ProfileSyncService* service, 289 ProfileSyncService* service,
268 WebDataService* wds, 290 AutofillWebDataService* wds,
269 DataTypeController* dtc) = 0; 291 DataTypeController* dtc) = 0;
270 virtual ~AbstractAutofillFactory() {} 292 virtual ~AbstractAutofillFactory() {}
271 }; 293 };
272 294
273 class AutofillEntryFactory : public AbstractAutofillFactory { 295 class AutofillEntryFactory : public AbstractAutofillFactory {
274 public: 296 public:
275 virtual browser_sync::DataTypeController* CreateDataTypeController( 297 virtual browser_sync::DataTypeController* CreateDataTypeController(
276 ProfileSyncComponentsFactory* factory, 298 ProfileSyncComponentsFactory* factory,
277 ProfileMock* profile, 299 ProfileMock* profile,
278 ProfileSyncService* service) OVERRIDE { 300 ProfileSyncService* service) OVERRIDE {
279 return new AutofillDataTypeController(factory, profile, service); 301 return new AutofillDataTypeController(factory, profile, service);
280 } 302 }
281 303
282 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 304 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
283 ProfileSyncService* service, 305 ProfileSyncService* service,
284 WebDataService* wds, 306 AutofillWebDataService* wds,
285 DataTypeController* dtc) OVERRIDE { 307 DataTypeController* dtc) OVERRIDE {
286 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)). 308 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
287 WillOnce(MakeGenericChangeProcessor()); 309 WillOnce(MakeGenericChangeProcessor());
288 EXPECT_CALL(*factory, CreateSharedChangeProcessor()). 310 EXPECT_CALL(*factory, CreateSharedChangeProcessor()).
289 WillOnce(MakeSharedChangeProcessor()); 311 WillOnce(MakeSharedChangeProcessor());
290 EXPECT_CALL(*factory, GetSyncableServiceForType(syncer::AUTOFILL)). 312 EXPECT_CALL(*factory, GetSyncableServiceForType(syncer::AUTOFILL)).
291 WillOnce(MakeAutocompleteSyncComponents(wds)); 313 WillOnce(MakeAutocompleteSyncComponents(wds));
292 } 314 }
293 }; 315 };
294 316
295 class AutofillProfileFactory : public AbstractAutofillFactory { 317 class AutofillProfileFactory : public AbstractAutofillFactory {
296 public: 318 public:
297 virtual browser_sync::DataTypeController* CreateDataTypeController( 319 virtual browser_sync::DataTypeController* CreateDataTypeController(
298 ProfileSyncComponentsFactory* factory, 320 ProfileSyncComponentsFactory* factory,
299 ProfileMock* profile, 321 ProfileMock* profile,
300 ProfileSyncService* service) OVERRIDE { 322 ProfileSyncService* service) OVERRIDE {
301 return new AutofillProfileDataTypeController(factory, profile, service); 323 return new AutofillProfileDataTypeController(factory, profile, service);
302 } 324 }
303 325
304 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory, 326 virtual void SetExpectation(ProfileSyncComponentsFactoryMock* factory,
305 ProfileSyncService* service, 327 ProfileSyncService* service,
306 WebDataService* wds, 328 AutofillWebDataService* wds,
307 DataTypeController* dtc) OVERRIDE { 329 DataTypeController* dtc) OVERRIDE {
308 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)). 330 EXPECT_CALL(*factory, CreateGenericChangeProcessor(_,_,_,_)).
309 WillOnce(MakeGenericChangeProcessor()); 331 WillOnce(MakeGenericChangeProcessor());
310 EXPECT_CALL(*factory, CreateSharedChangeProcessor()). 332 EXPECT_CALL(*factory, CreateSharedChangeProcessor()).
311 WillOnce(MakeSharedChangeProcessor()); 333 WillOnce(MakeSharedChangeProcessor());
312 EXPECT_CALL(*factory, 334 EXPECT_CALL(*factory,
313 GetSyncableServiceForType(syncer::AUTOFILL_PROFILE)). 335 GetSyncableServiceForType(syncer::AUTOFILL_PROFILE)).
314 WillOnce(MakeAutofillProfileSyncComponents(wds)); 336 WillOnce(MakeAutofillProfileSyncComponents(wds));
315 } 337 }
316 }; 338 };
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 virtual void SetUp() OVERRIDE { 402 virtual void SetUp() OVERRIDE {
381 AbstractProfileSyncServiceTest::SetUp(); 403 AbstractProfileSyncServiceTest::SetUp();
382 profile_.reset(new ProfileMock()); 404 profile_.reset(new ProfileMock());
383 profile_->CreateRequestContext(); 405 profile_->CreateRequestContext();
384 web_database_.reset(new WebDatabaseFake(&autofill_table_)); 406 web_database_.reset(new WebDatabaseFake(&autofill_table_));
385 MockWebDataServiceWrapper* wrapper = 407 MockWebDataServiceWrapper* wrapper =
386 static_cast<MockWebDataServiceWrapper*>( 408 static_cast<MockWebDataServiceWrapper*>(
387 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse( 409 WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse(
388 profile_.get(), BuildMockWebDataServiceWrapper)); 410 profile_.get(), BuildMockWebDataServiceWrapper));
389 web_data_service_ = 411 web_data_service_ =
390 static_cast<WebDataServiceFake*>(wrapper->GetWebData().get()); 412 static_cast<WebDataServiceFake*>(wrapper->GetAutofillWebData().get());
391 web_data_service_->SetDatabase(web_database_.get()); 413 web_data_service_->SetDatabase(web_database_.get());
392 414
393 MockPersonalDataManagerService* personal_data_manager_service = 415 MockPersonalDataManagerService* personal_data_manager_service =
394 static_cast<MockPersonalDataManagerService*>( 416 static_cast<MockPersonalDataManagerService*>(
395 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse( 417 PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse(
396 profile_.get(), MockPersonalDataManagerService::Build)); 418 profile_.get(), MockPersonalDataManagerService::Build));
397 personal_data_manager_ = 419 personal_data_manager_ =
398 personal_data_manager_service->GetPersonalDataManager(); 420 personal_data_manager_service->GetPersonalDataManager();
399 421
400 token_service_ = static_cast<TokenService*>( 422 token_service_ = static_cast<TokenService*>(
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 std::vector<base::Time> timestamps(added_entry.timestamps()); 1125 std::vector<base::Time> timestamps(added_entry.timestamps());
1104 1126
1105 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). 1127 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).
1106 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 1128 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
1107 1129
1108 AutofillChangeList changes; 1130 AutofillChangeList changes;
1109 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key())); 1131 changes.push_back(AutofillChange(AutofillChange::ADD, added_entry.key()));
1110 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1132 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1111 db_thread_.DeprecatedGetThreadObject())); 1133 db_thread_.DeprecatedGetThreadObject()));
1112 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1134 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1113 content::Source<WebDataService>(web_data_service_.get()), 1135 content::Source<AutofillWebDataService>(
1136 web_data_service_.get()),
1114 content::Details<AutofillChangeList>(&changes)); 1137 content::Details<AutofillChangeList>(&changes));
1115 1138
1116 std::vector<AutofillEntry> new_sync_entries; 1139 std::vector<AutofillEntry> new_sync_entries;
1117 std::vector<AutofillProfile> new_sync_profiles; 1140 std::vector<AutofillProfile> new_sync_profiles;
1118 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1141 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1119 &new_sync_profiles)); 1142 &new_sync_profiles));
1120 ASSERT_EQ(1U, new_sync_entries.size()); 1143 ASSERT_EQ(1U, new_sync_entries.size());
1121 EXPECT_TRUE(added_entry == new_sync_entries[0]); 1144 EXPECT_TRUE(added_entry == new_sync_entries[0]);
1122 } 1145 }
1123 1146
1124 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { 1147 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) {
1125 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); 1148 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true));
1126 EXPECT_CALL(*personal_data_manager_, Refresh()); 1149 EXPECT_CALL(*personal_data_manager_, Refresh());
1127 SetIdleChangeProcessorExpectations(); 1150 SetIdleChangeProcessorExpectations();
1128 CreateRootHelper create_root(this, syncer::AUTOFILL_PROFILE); 1151 CreateRootHelper create_root(this, syncer::AUTOFILL_PROFILE);
1129 StartSyncService(create_root.callback(), false, syncer::AUTOFILL_PROFILE); 1152 StartSyncService(create_root.callback(), false, syncer::AUTOFILL_PROFILE);
1130 ASSERT_TRUE(create_root.success()); 1153 ASSERT_TRUE(create_root.success());
1131 1154
1132 AutofillProfile added_profile; 1155 AutofillProfile added_profile;
1133 autofill_test::SetProfileInfoWithGuid(&added_profile, 1156 autofill_test::SetProfileInfoWithGuid(&added_profile,
1134 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz", 1157 "D6ADA912-D374-4C0A-917D-F5C8EBE43011", "Josephine", "Alicia", "Saenz",
1135 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 1158 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
1136 "32801", "US", "19482937549"); 1159 "32801", "US", "19482937549");
1137 1160
1138 AutofillProfileChange change(AutofillProfileChange::ADD, 1161 AutofillProfileChange change(AutofillProfileChange::ADD,
1139 added_profile.guid(), &added_profile); 1162 added_profile.guid(), &added_profile);
1140 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1163 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1141 db_thread_.DeprecatedGetThreadObject())); 1164 db_thread_.DeprecatedGetThreadObject()));
1142 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, 1165 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
1143 content::Source<WebDataService>(web_data_service_.get()), 1166 content::Source<AutofillWebDataService>(
1167 web_data_service_.get()),
1144 content::Details<AutofillProfileChange>(&change)); 1168 content::Details<AutofillProfileChange>(&change));
1145 1169
1146 std::vector<AutofillProfile> new_sync_profiles; 1170 std::vector<AutofillProfile> new_sync_profiles;
1147 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 1171 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
1148 &new_sync_profiles)); 1172 &new_sync_profiles));
1149 ASSERT_EQ(1U, new_sync_profiles.size()); 1173 ASSERT_EQ(1U, new_sync_profiles.size());
1150 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0])); 1174 EXPECT_EQ(0, added_profile.Compare(new_sync_profiles[0]));
1151 } 1175 }
1152 1176
1153 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) { 1177 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeUpdateEntry) {
(...skipping 13 matching lines...) Expand all
1167 1191
1168 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)). 1192 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).
1169 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true))); 1193 WillOnce(DoAll(SetArgumentPointee<2>(timestamps), Return(true)));
1170 1194
1171 AutofillChangeList changes; 1195 AutofillChangeList changes;
1172 changes.push_back(AutofillChange(AutofillChange::UPDATE, 1196 changes.push_back(AutofillChange(AutofillChange::UPDATE,
1173 updated_entry.key())); 1197 updated_entry.key()));
1174 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1198 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1175 db_thread_.DeprecatedGetThreadObject())); 1199 db_thread_.DeprecatedGetThreadObject()));
1176 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1200 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1177 content::Source<WebDataService>(web_data_service_.get()), 1201 content::Source<AutofillWebDataService>(
1202 web_data_service_.get()),
1178 content::Details<AutofillChangeList>(&changes)); 1203 content::Details<AutofillChangeList>(&changes));
1179 1204
1180 std::vector<AutofillEntry> new_sync_entries; 1205 std::vector<AutofillEntry> new_sync_entries;
1181 std::vector<AutofillProfile> new_sync_profiles; 1206 std::vector<AutofillProfile> new_sync_profiles;
1182 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1207 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1183 &new_sync_profiles)); 1208 &new_sync_profiles));
1184 ASSERT_EQ(1U, new_sync_entries.size()); 1209 ASSERT_EQ(1U, new_sync_entries.size());
1185 EXPECT_TRUE(updated_entry == new_sync_entries[0]); 1210 EXPECT_TRUE(updated_entry == new_sync_entries[0]);
1186 } 1211 }
1187 1212
1188 1213
1189 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) { 1214 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveEntry) {
1190 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1)); 1215 AutofillEntry original_entry(MakeAutofillEntry("my", "entry", 1));
1191 std::vector<AutofillEntry> original_entries; 1216 std::vector<AutofillEntry> original_entries;
1192 original_entries.push_back(original_entry); 1217 original_entries.push_back(original_entry);
1193 1218
1194 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). 1219 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).
1195 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true))); 1220 WillOnce(DoAll(SetArgumentPointee<0>(original_entries), Return(true)));
1196 EXPECT_CALL(*personal_data_manager_, Refresh()); 1221 EXPECT_CALL(*personal_data_manager_, Refresh());
1197 CreateRootHelper create_root(this, syncer::AUTOFILL); 1222 CreateRootHelper create_root(this, syncer::AUTOFILL);
1198 StartSyncService(create_root.callback(), false, syncer::AUTOFILL); 1223 StartSyncService(create_root.callback(), false, syncer::AUTOFILL);
1199 ASSERT_TRUE(create_root.success()); 1224 ASSERT_TRUE(create_root.success());
1200 1225
1201 AutofillChangeList changes; 1226 AutofillChangeList changes;
1202 changes.push_back(AutofillChange(AutofillChange::REMOVE, 1227 changes.push_back(AutofillChange(AutofillChange::REMOVE,
1203 original_entry.key())); 1228 original_entry.key()));
1204 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1229 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1205 db_thread_.DeprecatedGetThreadObject())); 1230 db_thread_.DeprecatedGetThreadObject()));
1206 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1231 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1207 content::Source<WebDataService>(web_data_service_.get()), 1232 content::Source<AutofillWebDataService>(
1233 web_data_service_.get()),
1208 content::Details<AutofillChangeList>(&changes)); 1234 content::Details<AutofillChangeList>(&changes));
1209 1235
1210 std::vector<AutofillEntry> new_sync_entries; 1236 std::vector<AutofillEntry> new_sync_entries;
1211 std::vector<AutofillProfile> new_sync_profiles; 1237 std::vector<AutofillProfile> new_sync_profiles;
1212 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries, 1238 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&new_sync_entries,
1213 &new_sync_profiles)); 1239 &new_sync_profiles));
1214 ASSERT_EQ(0U, new_sync_entries.size()); 1240 ASSERT_EQ(0U, new_sync_entries.size());
1215 } 1241 }
1216 1242
1217 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) { 1243 TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) {
(...skipping 18 matching lines...) Expand all
1236 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles); 1262 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles);
1237 EXPECT_CALL(*personal_data_manager_, Refresh()); 1263 EXPECT_CALL(*personal_data_manager_, Refresh());
1238 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE); 1264 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE);
1239 ASSERT_TRUE(add_autofill.success()); 1265 ASSERT_TRUE(add_autofill.success());
1240 1266
1241 AutofillProfileChange change(AutofillProfileChange::REMOVE, 1267 AutofillProfileChange change(AutofillProfileChange::REMOVE,
1242 sync_profile.guid(), NULL); 1268 sync_profile.guid(), NULL);
1243 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier( 1269 scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(
1244 db_thread_.DeprecatedGetThreadObject())); 1270 db_thread_.DeprecatedGetThreadObject()));
1245 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, 1271 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
1246 content::Source<WebDataService>(web_data_service_.get()), 1272 content::Source<AutofillWebDataService>(
1273 web_data_service_.get()),
1247 content::Details<AutofillProfileChange>(&change)); 1274 content::Details<AutofillProfileChange>(&change));
1248 1275
1249 std::vector<AutofillProfile> new_sync_profiles; 1276 std::vector<AutofillProfile> new_sync_profiles;
1250 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 1277 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
1251 &new_sync_profiles)); 1278 &new_sync_profiles));
1252 ASSERT_EQ(0U, new_sync_profiles.size()); 1279 ASSERT_EQ(0U, new_sync_profiles.size());
1253 } 1280 }
1254 1281
1255 // http://crbug.com/57884 1282 // http://crbug.com/57884
1256 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { 1283 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 std::vector<AutofillEntry> sync_entries; 1320 std::vector<AutofillEntry> sync_entries;
1294 std::vector<AutofillProfile> sync_profiles; 1321 std::vector<AutofillProfile> sync_profiles;
1295 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1322 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1296 EXPECT_EQ(3U, sync_entries.size()); 1323 EXPECT_EQ(3U, sync_entries.size());
1297 EXPECT_EQ(0U, sync_profiles.size()); 1324 EXPECT_EQ(0U, sync_profiles.size());
1298 for (size_t i = 0; i < sync_entries.size(); i++) { 1325 for (size_t i = 0; i < sync_entries.size(); i++) {
1299 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1326 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1300 << ", " << sync_entries[i].key().value(); 1327 << ", " << sync_entries[i].key().value();
1301 } 1328 }
1302 } 1329 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_components_factory_impl.cc ('k') | chrome/browser/sync/test/integration/autofill_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698