| 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(syncer::SyncChange::ACTION_ADD, | 148 syncer::SyncChange(FROM_HERE, |
| 149 AutofillProfileSyncableService::CreateData( | 149 syncer::SyncChange::ACTION_ADD, |
| 150 (*profiles_from_web_db.front())))); | 150 AutofillProfileSyncableService::CreateData( |
| 151 (*profiles_from_web_db.front())))); |
| 151 | 152 |
| 152 AutofillProfileSyncableService::DataBundle expected_bundle; | 153 AutofillProfileSyncableService::DataBundle expected_bundle; |
| 153 expected_bundle.profiles_to_add.push_back(&profile1); | 154 expected_bundle.profiles_to_add.push_back(&profile1); |
| 154 expected_bundle.profiles_to_add.push_back(&profile2); | 155 expected_bundle.profiles_to_add.push_back(&profile2); |
| 155 expected_bundle.profiles_to_update.push_back(&profile3); | 156 expected_bundle.profiles_to_update.push_back(&profile3); |
| 156 | 157 |
| 157 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_)) | 158 EXPECT_CALL(autofill_syncable_service_, LoadAutofillData(_)) |
| 158 .Times(1) | 159 .Times(1) |
| 159 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true))); | 160 .WillOnce(DoAll(CopyData(&profiles_from_web_db), Return(true))); |
| 160 EXPECT_CALL(autofill_syncable_service_, | 161 EXPECT_CALL(autofill_syncable_service_, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 221 |
| 221 TEST_F(AutofillProfileSyncableServiceTest, ProcessSyncChanges) { | 222 TEST_F(AutofillProfileSyncableServiceTest, ProcessSyncChanges) { |
| 222 std::vector<AutofillProfile *> profiles_from_web_db; | 223 std::vector<AutofillProfile *> profiles_from_web_db; |
| 223 std::string guid_present = kGuid1; | 224 std::string guid_present = kGuid1; |
| 224 std::string guid_synced = kGuid2; | 225 std::string guid_synced = kGuid2; |
| 225 | 226 |
| 226 syncer::SyncChangeList change_list; | 227 syncer::SyncChangeList change_list; |
| 227 AutofillProfile profile(guid_synced); | 228 AutofillProfile profile(guid_synced); |
| 228 profile.SetInfo(NAME_FIRST, UTF8ToUTF16("Jane")); | 229 profile.SetInfo(NAME_FIRST, UTF8ToUTF16("Jane")); |
| 229 change_list.push_back( | 230 change_list.push_back( |
| 230 syncer::SyncChange(syncer::SyncChange::ACTION_ADD, | 231 syncer::SyncChange(FROM_HERE, |
| 231 AutofillProfileSyncableService::CreateData(profile))); | 232 syncer::SyncChange::ACTION_ADD, |
| 233 AutofillProfileSyncableService::CreateData(profile))); |
| 232 AutofillProfile empty_profile(guid_present); | 234 AutofillProfile empty_profile(guid_present); |
| 233 change_list.push_back( | 235 change_list.push_back( |
| 234 syncer::SyncChange(syncer::SyncChange::ACTION_DELETE, | 236 syncer::SyncChange( |
| 235 AutofillProfileSyncableService::CreateData(empty_profile))); | 237 FROM_HERE, |
| 238 syncer::SyncChange::ACTION_DELETE, |
| 239 AutofillProfileSyncableService::CreateData(empty_profile))); |
| 236 | 240 |
| 237 AutofillProfileSyncableService::DataBundle expected_bundle; | 241 AutofillProfileSyncableService::DataBundle expected_bundle; |
| 238 expected_bundle.profiles_to_delete.push_back(guid_present); | 242 expected_bundle.profiles_to_delete.push_back(guid_present); |
| 239 expected_bundle.profiles_to_add.push_back(&profile); | 243 expected_bundle.profiles_to_add.push_back(&profile); |
| 240 | 244 |
| 241 EXPECT_CALL(autofill_syncable_service_, SaveChangesToWebData( | 245 EXPECT_CALL(autofill_syncable_service_, SaveChangesToWebData( |
| 242 DataBundleCheck(expected_bundle))) | 246 DataBundleCheck(expected_bundle))) |
| 243 .Times(1) | 247 .Times(1) |
| 244 .WillOnce(Return(true)); | 248 .WillOnce(Return(true)); |
| 245 | 249 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 profile1.GetMultiInfo(EMAIL_ADDRESS, &values); | 410 profile1.GetMultiInfo(EMAIL_ADDRESS, &values); |
| 407 ASSERT_EQ(values.size(), 3U); | 411 ASSERT_EQ(values.size(), 3U); |
| 408 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com")); | 412 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com")); |
| 409 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com")); | 413 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com")); |
| 410 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com")); | 414 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com")); |
| 411 | 415 |
| 412 profile1.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); | 416 profile1.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); |
| 413 ASSERT_EQ(values.size(), 1U); | 417 ASSERT_EQ(values.size(), 1U); |
| 414 EXPECT_EQ(values[0], UTF8ToUTF16("650234567")); | 418 EXPECT_EQ(values[0], UTF8ToUTF16("650234567")); |
| 415 } | 419 } |
| OLD | NEW |