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

Side by Side Diff: chrome/browser/autofill/autofill_merge_unittest.cc

Issue 8043027: AutofillMergeTest doesn't need scoped_ptr for PersonalDataManager mock (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 virtual void SetUp(); 121 virtual void SetUp();
122 122
123 // DataDrivenTest: 123 // DataDrivenTest:
124 virtual void GenerateResults(const std::string& input, 124 virtual void GenerateResults(const std::string& input,
125 std::string* output) OVERRIDE; 125 std::string* output) OVERRIDE;
126 126
127 // Deserializes a set of Autofill profiles from |profiles|, imports each 127 // Deserializes a set of Autofill profiles from |profiles|, imports each
128 // sequentially, and fills |merged_profiles| with the serialized result. 128 // sequentially, and fills |merged_profiles| with the serialized result.
129 void MergeProfiles(const std::string& profiles, std::string* merged_profiles); 129 void MergeProfiles(const std::string& profiles, std::string* merged_profiles);
130 130
131 scoped_ptr<PersonalDataManagerMock> personal_data_; 131 PersonalDataManagerMock personal_data_;
132 132
133 private: 133 private:
134 DISALLOW_COPY_AND_ASSIGN(AutofillMergeTest); 134 DISALLOW_COPY_AND_ASSIGN(AutofillMergeTest);
135 }; 135 };
136 136
137 AutofillMergeTest::AutofillMergeTest() : DataDrivenTest() { 137 AutofillMergeTest::AutofillMergeTest() : DataDrivenTest() {
138 } 138 }
139 139
140 AutofillMergeTest::~AutofillMergeTest() { 140 AutofillMergeTest::~AutofillMergeTest() {
141 } 141 }
142 142
143 void AutofillMergeTest::SetUp() { 143 void AutofillMergeTest::SetUp() {
144 autofill_test::DisableSystemServices(NULL); 144 autofill_test::DisableSystemServices(NULL);
145
146 personal_data_.reset(new PersonalDataManagerMock);
147 } 145 }
148 146
149 void AutofillMergeTest::GenerateResults(const std::string& input, 147 void AutofillMergeTest::GenerateResults(const std::string& input,
150 std::string* output) { 148 std::string* output) {
151 MergeProfiles(input, output); 149 MergeProfiles(input, output);
152 } 150 }
153 151
154 void AutofillMergeTest::MergeProfiles(const std::string& profiles, 152 void AutofillMergeTest::MergeProfiles(const std::string& profiles,
155 std::string* merged_profiles) { 153 std::string* merged_profiles) {
156 // Start with no saved profiles. 154 // Start with no saved profiles.
157 personal_data_->Reset(); 155 personal_data_.Reset();
158 156
159 // Create a test form. 157 // Create a test form.
160 webkit_glue::FormData form; 158 webkit_glue::FormData form;
161 form.name = ASCIIToUTF16("MyTestForm"); 159 form.name = ASCIIToUTF16("MyTestForm");
162 form.method = ASCIIToUTF16("POST"); 160 form.method = ASCIIToUTF16("POST");
163 form.origin = GURL("https://www.example.com/origin.html"); 161 form.origin = GURL("https://www.example.com/origin.html");
164 form.action = GURL("https://www.example.com/action.html"); 162 form.action = GURL("https://www.example.com/action.html");
165 form.user_submitted = true; 163 form.user_submitted = true;
166 164
167 // Parse the input line by line. 165 // Parse the input line by line.
(...skipping 27 matching lines...) Expand all
195 // into the field's name. 193 // into the field's name.
196 AutofillField* field = 194 AutofillField* field =
197 const_cast<AutofillField*>(form_structure.field(i)); 195 const_cast<AutofillField*>(form_structure.field(i));
198 AutofillFieldType type = 196 AutofillFieldType type =
199 AutofillType::StringToFieldType(UTF16ToUTF8(field->name)); 197 AutofillType::StringToFieldType(UTF16ToUTF8(field->name));
200 field->set_heuristic_type(type); 198 field->set_heuristic_type(type);
201 } 199 }
202 200
203 // Import the profile. 201 // Import the profile.
204 const CreditCard* imported_credit_card; 202 const CreditCard* imported_credit_card;
205 personal_data_->ImportFormData(form_structure, &imported_credit_card); 203 personal_data_.ImportFormData(form_structure, &imported_credit_card);
206 EXPECT_FALSE(imported_credit_card); 204 EXPECT_EQ(static_cast<const CreditCard*>(NULL), imported_credit_card);
207 205
208 // Clear the |form| to start a new profile. 206 // Clear the |form| to start a new profile.
209 form.fields.clear(); 207 form.fields.clear();
210 } 208 }
211 } 209 }
212 210
213 *merged_profiles = SerializeProfiles(personal_data_->web_profiles()); 211 *merged_profiles = SerializeProfiles(personal_data_.web_profiles());
214 } 212 }
215 213
216 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { 214 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) {
217 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), 215 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName),
218 kFileNamePattern); 216 kFileNamePattern);
219 } 217 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698