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 "base/location.h" | 5 #include "base/location.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autofill/autofill_profile.h" | 8 #include "chrome/browser/autofill/autofill_profile.h" |
9 #include "chrome/browser/webdata/autofill_change.h" | 9 #include "chrome/browser/webdata/autofill_change.h" |
10 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | 10 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 AutofillProfile profile2(guid_synced2); | 138 AutofillProfile profile2(guid_synced2); |
139 profile2.SetInfo(NAME_FIRST, UTF8ToUTF16("Harry")); | 139 profile2.SetInfo(NAME_FIRST, UTF8ToUTF16("Harry")); |
140 data_list.push_back(autofill_syncable_service_.CreateData(profile2)); | 140 data_list.push_back(autofill_syncable_service_.CreateData(profile2)); |
141 // This one will have the name updated. | 141 // This one will have the name updated. |
142 AutofillProfile profile3(guid_present2); | 142 AutofillProfile profile3(guid_present2); |
143 profile3.SetInfo(NAME_FIRST, UTF8ToUTF16("Tom Doe")); | 143 profile3.SetInfo(NAME_FIRST, UTF8ToUTF16("Tom Doe")); |
144 data_list.push_back(autofill_syncable_service_.CreateData(profile3)); | 144 data_list.push_back(autofill_syncable_service_.CreateData(profile3)); |
145 | 145 |
146 syncer::SyncChangeList expected_change_list; | 146 syncer::SyncChangeList expected_change_list; |
147 expected_change_list.push_back( | 147 expected_change_list.push_back( |
148 syncer::SyncChange(FROM_HERE, | 148 syncer::SyncChange(syncer::SyncChange::ACTION_ADD, |
149 syncer::SyncChange::ACTION_ADD, | 149 AutofillProfileSyncableService::CreateData( |
150 AutofillProfileSyncableService::CreateData( | 150 (*profiles_from_web_db.front())))); |
151 (*profiles_from_web_db.front())))); | |
152 | 151 |
153 AutofillProfileSyncableService::DataBundle expected_bundle; | 152 AutofillProfileSyncableService::DataBundle expected_bundle; |
154 expected_bundle.profiles_to_add.push_back(&profile1); | 153 expected_bundle.profiles_to_add.push_back(&profile1); |
155 expected_bundle.profiles_to_add.push_back(&profile2); | 154 expected_bundle.profiles_to_add.push_back(&profile2); |
156 expected_bundle.profiles_to_update.push_back(&profile3); | 155 expected_bundle.profiles_to_update.push_back(&profile3); |
157 | 156 |
158 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_)) | 157 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_)) |
159 .Times(1) | 158 .Times(1) |
160 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true))); | 159 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true))); |
161 EXPECT_CALL(autofill_syncable_service_, | 160 EXPECT_CALL(autofill_syncable_service_, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 220 |
222 TEST_F(AutofillProfileSyncableServiceTest, ProcessSyncChanges) { | 221 TEST_F(AutofillProfileSyncableServiceTest, ProcessSyncChanges) { |
223 std::vector<AutofillProfile *> profiles_from_web_db; | 222 std::vector<AutofillProfile *> profiles_from_web_db; |
224 std::string guid_present = kGuid1; | 223 std::string guid_present = kGuid1; |
225 std::string guid_synced = kGuid2; | 224 std::string guid_synced = kGuid2; |
226 | 225 |
227 syncer::SyncChangeList change_list; | 226 syncer::SyncChangeList change_list; |
228 AutofillProfile profile(guid_synced); | 227 AutofillProfile profile(guid_synced); |
229 profile.SetInfo(NAME_FIRST, UTF8ToUTF16("Jane")); | 228 profile.SetInfo(NAME_FIRST, UTF8ToUTF16("Jane")); |
230 change_list.push_back( | 229 change_list.push_back( |
231 syncer::SyncChange(FROM_HERE, | 230 syncer::SyncChange(syncer::SyncChange::ACTION_ADD, |
232 syncer::SyncChange::ACTION_ADD, | 231 AutofillProfileSyncableService::CreateData(profile))); |
233 AutofillProfileSyncableService::CreateData(profile))); | |
234 AutofillProfile empty_profile(guid_present); | 232 AutofillProfile empty_profile(guid_present); |
235 change_list.push_back( | 233 change_list.push_back( |
236 syncer::SyncChange( | 234 syncer::SyncChange(syncer::SyncChange::ACTION_DELETE, |
237 FROM_HERE, | 235 AutofillProfileSyncableService::CreateData(empty_profile))); |
238 syncer::SyncChange::ACTION_DELETE, | |
239 AutofillProfileSyncableService::CreateData(empty_profile))); | |
240 | 236 |
241 AutofillProfileSyncableService::DataBundle expected_bundle; | 237 AutofillProfileSyncableService::DataBundle expected_bundle; |
242 expected_bundle.profiles_to_delete.push_back(guid_present); | 238 expected_bundle.profiles_to_delete.push_back(guid_present); |
243 expected_bundle.profiles_to_add.push_back(&profile); | 239 expected_bundle.profiles_to_add.push_back(&profile); |
244 | 240 |
245 EXPECT_CALL(autofill_syncable_service_, SaveChangesToWebData( | 241 EXPECT_CALL(autofill_syncable_service_, SaveChangesToWebData( |
246 DataBundleCheck(expected_bundle))) | 242 DataBundleCheck(expected_bundle))) |
247 .Times(1) | 243 .Times(1) |
248 .WillOnce(Return(true)); | 244 .WillOnce(Return(true)); |
249 | 245 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 profile1.GetMultiInfo(EMAIL_ADDRESS, &values); | 406 profile1.GetMultiInfo(EMAIL_ADDRESS, &values); |
411 ASSERT_EQ(values.size(), 3U); | 407 ASSERT_EQ(values.size(), 3U); |
412 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com")); | 408 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com")); |
413 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com")); | 409 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com")); |
414 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com")); | 410 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com")); |
415 | 411 |
416 profile1.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); | 412 profile1.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); |
417 ASSERT_EQ(values.size(), 1U); | 413 ASSERT_EQ(values.size(), 1U); |
418 EXPECT_EQ(values[0], UTF8ToUTF16("650234567")); | 414 EXPECT_EQ(values[0], UTF8ToUTF16("650234567")); |
419 } | 415 } |
OLD | NEW |