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 (size_t j = 0; j < arraysize(kProfileFieldTypes); ++j) { | 94 for (const ServerFieldType& type : kProfileFieldTypes) { |
95 ServerFieldType type = kProfileFieldTypes[j]; | |
96 base::string16 value = profiles[i]->GetRawInfo(type); | 95 base::string16 value = profiles[i]->GetRawInfo(type); |
97 result += AutofillType(type).ToString(); | 96 result += AutofillType(type).ToString(); |
98 result += kFieldSeparator; | 97 result += kFieldSeparator; |
99 if (!value.empty()) { | 98 if (!value.empty()) { |
100 base::ReplaceFirstSubstringAfterOffset( | 99 base::ReplaceFirstSubstringAfterOffset( |
101 &value, 0, base::ASCIIToUTF16("\\n"), base::ASCIIToUTF16("\n")); | 100 &value, 0, base::ASCIIToUTF16("\\n"), base::ASCIIToUTF16("\n")); |
102 result += " "; | 101 result += " "; |
103 result += base::UTF16ToUTF8(value); | 102 result += base::UTF16ToUTF8(value); |
104 } | 103 } |
105 result += "\n"; | 104 result += "\n"; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 return string_to_field_type_map_[str]; | 288 return string_to_field_type_map_[str]; |
290 } | 289 } |
291 | 290 |
292 TEST_P(AutofillMergeTest, DataDrivenMergeProfiles) { | 291 TEST_P(AutofillMergeTest, DataDrivenMergeProfiles) { |
293 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName)); | 292 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName)); |
294 } | 293 } |
295 | 294 |
296 INSTANTIATE_TEST_CASE_P(, AutofillMergeTest, testing::ValuesIn(GetTestFiles())); | 295 INSTANTIATE_TEST_CASE_P(, AutofillMergeTest, testing::ValuesIn(GetTestFiles())); |
297 | 296 |
298 } // namespace autofill | 297 } // namespace autofill |
OLD | NEW |