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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 return files; | 85 return files; |
86 } | 86 } |
87 | 87 |
88 // Serializes the |profiles| into a string. | 88 // Serializes the |profiles| into a string. |
89 std::string SerializeProfiles(const std::vector<AutofillProfile*>& profiles) { | 89 std::string SerializeProfiles(const std::vector<AutofillProfile*>& profiles) { |
90 std::string result; | 90 std::string result; |
91 for (size_t i = 0; i < profiles.size(); ++i) { | 91 for (size_t i = 0; i < profiles.size(); ++i) { |
92 result += kProfileSeparator; | 92 result += kProfileSeparator; |
93 result += "\n"; | 93 result += "\n"; |
94 for (const ServerFieldType& type : kProfileFieldTypes) { | 94 for (size_t j = 0; j < arraysize(kProfileFieldTypes); ++j) { |
| 95 ServerFieldType type = kProfileFieldTypes[j]; |
95 base::string16 value = profiles[i]->GetRawInfo(type); | 96 base::string16 value = profiles[i]->GetRawInfo(type); |
96 result += AutofillType(type).ToString(); | 97 result += AutofillType(type).ToString(); |
97 result += kFieldSeparator; | 98 result += kFieldSeparator; |
98 if (!value.empty()) { | 99 if (!value.empty()) { |
99 base::ReplaceFirstSubstringAfterOffset( | 100 base::ReplaceFirstSubstringAfterOffset( |
100 &value, 0, base::ASCIIToUTF16("\\n"), base::ASCIIToUTF16("\n")); | 101 &value, 0, base::ASCIIToUTF16("\\n"), base::ASCIIToUTF16("\n")); |
101 result += " "; | 102 result += " "; |
102 result += base::UTF16ToUTF8(value); | 103 result += base::UTF16ToUTF8(value); |
103 } | 104 } |
104 result += "\n"; | 105 result += "\n"; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 return string_to_field_type_map_[str]; | 289 return string_to_field_type_map_[str]; |
289 } | 290 } |
290 | 291 |
291 TEST_P(AutofillMergeTest, DataDrivenMergeProfiles) { | 292 TEST_P(AutofillMergeTest, DataDrivenMergeProfiles) { |
292 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName)); | 293 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName)); |
293 } | 294 } |
294 | 295 |
295 INSTANTIATE_TEST_CASE_P(, AutofillMergeTest, testing::ValuesIn(GetTestFiles())); | 296 INSTANTIATE_TEST_CASE_P(, AutofillMergeTest, testing::ValuesIn(GetTestFiles())); |
296 | 297 |
297 } // namespace autofill | 298 } // namespace autofill |
OLD | NEW |