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

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

Issue 13488009: Remove application locale cache in autofill code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 void RunAndSignal(const base::Closure& cb, WaitableEvent* event) { 96 void RunAndSignal(const base::Closure& cb, WaitableEvent* event) {
97 cb.Run(); 97 cb.Run();
98 event->Signal(); 98 event->Signal();
99 } 99 }
100 100
101 } // namespace 101 } // namespace
102 102
103 class AutofillTableMock : public AutofillTable { 103 class AutofillTableMock : public AutofillTable {
104 public: 104 public:
105 AutofillTableMock() : AutofillTable() {} 105 AutofillTableMock() : AutofillTable("en-US") {}
106 MOCK_METHOD2(RemoveFormElement, 106 MOCK_METHOD2(RemoveFormElement,
107 bool(const string16& name, const string16& value)); // NOLINT 107 bool(const string16& name, const string16& value)); // NOLINT
108 MOCK_METHOD1(GetAllAutofillEntries, 108 MOCK_METHOD1(GetAllAutofillEntries,
109 bool(std::vector<AutofillEntry>* entries)); // NOLINT 109 bool(std::vector<AutofillEntry>* entries)); // NOLINT
110 MOCK_METHOD3(GetAutofillTimestamps, 110 MOCK_METHOD3(GetAutofillTimestamps,
111 bool(const string16& name, // NOLINT 111 bool(const string16& name, // NOLINT
112 const string16& value, 112 const string16& value,
113 std::vector<base::Time>* timestamps)); 113 std::vector<base::Time>* timestamps));
114 MOCK_METHOD1(UpdateAutofillEntries, 114 MOCK_METHOD1(UpdateAutofillEntries,
115 bool(const std::vector<AutofillEntry>&)); // NOLINT 115 bool(const std::vector<AutofillEntry>&)); // NOLINT
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 EXPECT_CALL(*factory, CreateSharedChangeProcessor()). 379 EXPECT_CALL(*factory, CreateSharedChangeProcessor()).
380 WillOnce(MakeSharedChangeProcessor()); 380 WillOnce(MakeSharedChangeProcessor());
381 EXPECT_CALL(*factory, 381 EXPECT_CALL(*factory,
382 GetSyncableServiceForType(syncer::AUTOFILL_PROFILE)). 382 GetSyncableServiceForType(syncer::AUTOFILL_PROFILE)).
383 WillOnce(MakeAutofillProfileSyncComponents(wds)); 383 WillOnce(MakeAutofillProfileSyncComponents(wds));
384 } 384 }
385 }; 385 };
386 386
387 class MockPersonalDataManager : public PersonalDataManager { 387 class MockPersonalDataManager : public PersonalDataManager {
388 public: 388 public:
389 MockPersonalDataManager() : PersonalDataManager("en-US") {}
389 MOCK_CONST_METHOD0(IsDataLoaded, bool()); 390 MOCK_CONST_METHOD0(IsDataLoaded, bool());
390 MOCK_METHOD0(LoadProfiles, void()); 391 MOCK_METHOD0(LoadProfiles, void());
391 MOCK_METHOD0(LoadCreditCards, void()); 392 MOCK_METHOD0(LoadCreditCards, void());
392 MOCK_METHOD0(Refresh, void()); 393 MOCK_METHOD0(Refresh, void());
393 }; 394 };
394 395
395 class MockPersonalDataManagerService : public PersonalDataManagerService { 396 class MockPersonalDataManagerService : public PersonalDataManagerService {
396 public: 397 public:
397 static ProfileKeyedService* Build(Profile* profile) { 398 static ProfileKeyedService* Build(Profile* profile) {
398 return new MockPersonalDataManagerService(); 399 return new MockPersonalDataManagerService();
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 "91601", "US", "12345678910"); 1083 "91601", "US", "12345678910");
1083 1084
1084 AutofillProfile* native_profile = new AutofillProfile; 1085 AutofillProfile* native_profile = new AutofillProfile;
1085 // Same address, but different names, phones and e-mails. 1086 // Same address, but different names, phones and e-mails.
1086 autofill_test::SetProfileInfoWithGuid(native_profile, 1087 autofill_test::SetProfileInfoWithGuid(native_profile,
1087 "23355099-1170-4B71-8ED4-144470CC9EBF", "Billing", "Alicia", "Saenz", 1088 "23355099-1170-4B71-8ED4-144470CC9EBF", "Billing", "Alicia", "Saenz",
1088 "joewayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 1089 "joewayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
1089 "91601", "US", "19482937549"); 1090 "91601", "US", "19482937549");
1090 1091
1091 AutofillProfile expected_profile(sync_profile); 1092 AutofillProfile expected_profile(sync_profile);
1092 expected_profile.OverwriteWithOrAddTo(*native_profile); 1093 expected_profile.OverwriteWithOrAddTo(*native_profile, "en-US");
1093 1094
1094 std::vector<AutofillProfile*> native_profiles; 1095 std::vector<AutofillProfile*> native_profiles;
1095 native_profiles.push_back(native_profile); 1096 native_profiles.push_back(native_profile);
1096 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)). 1097 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).
1097 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true))); 1098 WillOnce(DoAll(SetArgumentPointee<0>(native_profiles), Return(true)));
1098 EXPECT_CALL(autofill_table_, 1099 EXPECT_CALL(autofill_table_,
1099 AddAutofillProfile(MatchProfiles(expected_profile))). 1100 AddAutofillProfile(MatchProfiles(expected_profile))).
1100 WillOnce(Return(true)); 1101 WillOnce(Return(true));
1101 EXPECT_CALL(autofill_table_, 1102 EXPECT_CALL(autofill_table_,
1102 RemoveAutofillProfile("23355099-1170-4B71-8ED4-144470CC9EBF")). 1103 RemoveAutofillProfile("23355099-1170-4B71-8ED4-144470CC9EBF")).
1103 WillOnce(Return(true)); 1104 WillOnce(Return(true));
1104 std::vector<AutofillProfile> sync_profiles; 1105 std::vector<AutofillProfile> sync_profiles;
1105 sync_profiles.push_back(sync_profile); 1106 sync_profiles.push_back(sync_profile);
1106 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles); 1107 AddAutofillHelper<AutofillProfile> add_autofill(this, sync_profiles);
1107 1108
1108 EXPECT_CALL(*personal_data_manager_, Refresh()); 1109 EXPECT_CALL(*personal_data_manager_, Refresh());
1109 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE); 1110 StartSyncService(add_autofill.callback(), false, syncer::AUTOFILL_PROFILE);
1110 ASSERT_TRUE(add_autofill.success()); 1111 ASSERT_TRUE(add_autofill.success());
1111 1112
1112 std::vector<AutofillProfile> new_sync_profiles; 1113 std::vector<AutofillProfile> new_sync_profiles;
1113 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( 1114 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode(
1114 &new_sync_profiles)); 1115 &new_sync_profiles));
1115 ASSERT_EQ(1U, new_sync_profiles.size()); 1116 ASSERT_EQ(1U, new_sync_profiles.size());
1116 // Check that key fields are the same. 1117 // Check that key fields are the same.
1117 EXPECT_TRUE(new_sync_profiles[0].IsSubsetOf(sync_profile)); 1118 EXPECT_TRUE(new_sync_profiles[0].IsSubsetOf(sync_profile, "en-US"));
1118 // Check that multivalued fields of the synced back data include original 1119 // Check that multivalued fields of the synced back data include original
1119 // data. 1120 // data.
1120 EXPECT_TRUE(IncludesField(new_sync_profiles[0], sync_profile, NAME_FULL)); 1121 EXPECT_TRUE(IncludesField(new_sync_profiles[0], sync_profile, NAME_FULL));
1121 EXPECT_TRUE(IncludesField(new_sync_profiles[0], sync_profile, EMAIL_ADDRESS)); 1122 EXPECT_TRUE(IncludesField(new_sync_profiles[0], sync_profile, EMAIL_ADDRESS));
1122 EXPECT_TRUE(IncludesField(new_sync_profiles[0], sync_profile, 1123 EXPECT_TRUE(IncludesField(new_sync_profiles[0], sync_profile,
1123 PHONE_HOME_WHOLE_NUMBER)); 1124 PHONE_HOME_WHOLE_NUMBER));
1124 } 1125 }
1125 1126
1126 TEST_F(ProfileSyncServiceAutofillTest, MergeProfileWithDifferentGuid) { 1127 TEST_F(ProfileSyncServiceAutofillTest, MergeProfileWithDifferentGuid) {
1127 AutofillProfile sync_profile; 1128 AutofillProfile sync_profile;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 std::vector<AutofillEntry> sync_entries; 1349 std::vector<AutofillEntry> sync_entries;
1349 std::vector<AutofillProfile> sync_profiles; 1350 std::vector<AutofillProfile> sync_profiles;
1350 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1351 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1351 EXPECT_EQ(3U, sync_entries.size()); 1352 EXPECT_EQ(3U, sync_entries.size());
1352 EXPECT_EQ(0U, sync_profiles.size()); 1353 EXPECT_EQ(0U, sync_profiles.size());
1353 for (size_t i = 0; i < sync_entries.size(); i++) { 1354 for (size_t i = 0; i < sync_entries.size(); i++) {
1354 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1355 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1355 << ", " << sync_entries[i].key().value(); 1356 << ", " << sync_entries[i].key().value();
1356 } 1357 }
1357 } 1358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698