| OLD | NEW |
| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 field.name = field_type; | 206 field.name = field_type; |
| 207 field.value = value; | 207 field.value = value; |
| 208 field.form_control_type = "text"; | 208 field.form_control_type = "text"; |
| 209 form.fields.push_back(field); | 209 form.fields.push_back(field); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // The first line is always a profile separator, and the last profile is not | 212 // The first line is always a profile separator, and the last profile is not |
| 213 // followed by an explicit separator. | 213 // followed by an explicit separator. |
| 214 if ((i > 0 && line == kProfileSeparator) || i == lines.size() - 1) { | 214 if ((i > 0 && line == kProfileSeparator) || i == lines.size() - 1) { |
| 215 // Reached the end of a profile. Try to import it. | 215 // Reached the end of a profile. Try to import it. |
| 216 FormStructure form_structure(form, std::string()); | 216 FormStructure form_structure(form); |
| 217 for (size_t i = 0; i < form_structure.field_count(); ++i) { | 217 for (size_t i = 0; i < form_structure.field_count(); ++i) { |
| 218 // Set the heuristic type for each field, which is currently serialized | 218 // Set the heuristic type for each field, which is currently serialized |
| 219 // into the field's name. | 219 // into the field's name. |
| 220 AutofillField* field = | 220 AutofillField* field = |
| 221 const_cast<AutofillField*>(form_structure.field(i)); | 221 const_cast<AutofillField*>(form_structure.field(i)); |
| 222 ServerFieldType type = StringToFieldType(UTF16ToUTF8(field->name)); | 222 ServerFieldType type = StringToFieldType(UTF16ToUTF8(field->name)); |
| 223 field->set_heuristic_type(type); | 223 field->set_heuristic_type(type); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // Import the profile. | 226 // Import the profile. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 239 ServerFieldType AutofillMergeTest::StringToFieldType(const std::string& str) { | 239 ServerFieldType AutofillMergeTest::StringToFieldType(const std::string& str) { |
| 240 return string_to_field_type_map_[str]; | 240 return string_to_field_type_map_[str]; |
| 241 } | 241 } |
| 242 | 242 |
| 243 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { | 243 TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { |
| 244 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), | 244 RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), |
| 245 kFileNamePattern); | 245 kFileNamePattern); |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace autofill | 248 } // namespace autofill |
| OLD | NEW |