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

Side by Side Diff: components/autofill/core/browser/autofill_merge_unittest.cc

Issue 23882013: [rAc] Persist selection of newly added cards and addresses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests, add a test Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <map> 5 #include <map>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 class PersonalDataManagerMock : public PersonalDataManager { 82 class PersonalDataManagerMock : public PersonalDataManager {
83 public: 83 public:
84 PersonalDataManagerMock(); 84 PersonalDataManagerMock();
85 virtual ~PersonalDataManagerMock(); 85 virtual ~PersonalDataManagerMock();
86 86
87 // Reset the saved profiles. 87 // Reset the saved profiles.
88 void Reset(); 88 void Reset();
89 89
90 // PersonalDataManager: 90 // PersonalDataManager:
91 virtual void SaveImportedProfile(const AutofillProfile& profile) OVERRIDE; 91 virtual std::string SaveImportedProfile(
92 const AutofillProfile& profile) OVERRIDE;
92 virtual const std::vector<AutofillProfile*>& web_profiles() const OVERRIDE; 93 virtual const std::vector<AutofillProfile*>& web_profiles() const OVERRIDE;
93 94
94 private: 95 private:
95 ScopedVector<AutofillProfile> profiles_; 96 ScopedVector<AutofillProfile> profiles_;
96 97
97 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerMock); 98 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerMock);
98 }; 99 };
99 100
100 PersonalDataManagerMock::PersonalDataManagerMock() 101 PersonalDataManagerMock::PersonalDataManagerMock()
101 : PersonalDataManager("en-US") { 102 : PersonalDataManager("en-US") {
102 } 103 }
103 104
104 PersonalDataManagerMock::~PersonalDataManagerMock() { 105 PersonalDataManagerMock::~PersonalDataManagerMock() {
105 } 106 }
106 107
107 void PersonalDataManagerMock::Reset() { 108 void PersonalDataManagerMock::Reset() {
108 profiles_.clear(); 109 profiles_.clear();
109 } 110 }
110 111
111 void PersonalDataManagerMock::SaveImportedProfile( 112 std::string PersonalDataManagerMock::SaveImportedProfile(
112 const AutofillProfile& profile) { 113 const AutofillProfile& profile) {
113 std::vector<AutofillProfile> profiles; 114 std::vector<AutofillProfile> profiles;
114 if (!MergeProfile(profile, profiles_.get(), "en-US", &profiles)) 115 std::string merged_guid =
116 MergeProfile(profile, profiles_.get(), "en-US", &profiles);
117 if (merged_guid == profile.guid())
115 profiles_.push_back(new AutofillProfile(profile)); 118 profiles_.push_back(new AutofillProfile(profile));
119 return merged_guid;
116 } 120 }
117 121
118 const std::vector<AutofillProfile*>& PersonalDataManagerMock::web_profiles() 122 const std::vector<AutofillProfile*>& PersonalDataManagerMock::web_profiles()
119 const { 123 const {
120 return profiles_.get(); 124 return profiles_.get();
121 } 125 }
122 126
123 } // namespace 127 } // namespace
124 128
125 // A data-driven test for verifying merging of Autofill profiles. Each input is 129 // A data-driven test for verifying merging of Autofill profiles. Each input is
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ServerFieldType AutofillMergeTest::StringToFieldType(const std::string& str) { 243 ServerFieldType AutofillMergeTest::StringToFieldType(const std::string& str) {
240 return string_to_field_type_map_[str]; 244 return string_to_field_type_map_[str];
241 } 245 }
242 246
243 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { 247 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) {
244 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), 248 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName),
245 kFileNamePattern); 249 kFileNamePattern);
246 } 250 }
247 251
248 } // namespace autofill 252 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698