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 "components/autofill/core/browser/contact_info.h" | 5 #include "components/autofill/core/browser/contact_info.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "components/autofill/core/browser/autofill_type.h" | 12 #include "components/autofill/core/browser/autofill_type.h" |
13 #include "components/autofill/core/browser/field_types.h" | 13 #include "components/autofill/core/browser/field_types.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 using base::ASCIIToUTF16; | 16 using base::ASCIIToUTF16; |
| 17 using base::UTF8ToUTF16; |
17 | 18 |
18 namespace autofill { | 19 namespace autofill { |
19 | 20 |
20 struct FullNameTestCase { | 21 struct FullNameTestCase { |
21 std::string full_name_input; | 22 std::string full_name_input; |
22 std::string given_name_output; | 23 std::string given_name_output; |
23 std::string middle_name_output; | 24 std::string middle_name_output; |
24 std::string family_name_output; | 25 std::string family_name_output; |
25 } full_name_test_cases[] = { | 26 } full_name_test_cases[] = { |
26 { "", "", "", "" }, | 27 { "", "", "", "" }, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 {{"Marion", "Mitchell", "Morrison"}, | 210 {{"Marion", "Mitchell", "Morrison"}, |
210 {"Marion Mitchell", "", "MORRISON"}, | 211 {"Marion Mitchell", "", "MORRISON"}, |
211 false}, | 212 false}, |
212 | 213 |
213 // Different names. | 214 // Different names. |
214 {{"Marion", "Mitchell", "Morrison"}, {"Marion", "M.", "Morrison"}, false}, | 215 {{"Marion", "Mitchell", "Morrison"}, {"Marion", "M.", "Morrison"}, false}, |
215 {{"Marion", "Mitchell", "Morrison"}, {"MARION", "M.", "MORRISON"}, false}, | 216 {{"Marion", "Mitchell", "Morrison"}, {"MARION", "M.", "MORRISON"}, false}, |
216 {{"Marion", "Mitchell", "Morrison"}, | 217 {{"Marion", "Mitchell", "Morrison"}, |
217 {"David", "Mitchell", "Morrison"}, | 218 {"David", "Mitchell", "Morrison"}, |
218 false}, | 219 false}, |
| 220 |
| 221 // Non-ASCII characters. |
| 222 {{"M\xc3\xa1rion Mitchell", "", "Morrison"}, |
| 223 {"M\xc3\x81RION MITCHELL", "", "MORRISON"}, |
| 224 true}, |
219 }; | 225 }; |
220 | 226 |
221 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 227 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
222 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); | 228 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); |
223 | 229 |
224 // Construct the starting_profile. | 230 // Construct the starting_profile. |
225 NameInfo starting_profile; | 231 NameInfo starting_profile; |
226 starting_profile.SetRawInfo(NAME_FIRST, | 232 starting_profile.SetRawInfo(NAME_FIRST, |
227 ASCIIToUTF16(test_cases[i].starting_names[0])); | 233 UTF8ToUTF16(test_cases[i].starting_names[0])); |
228 starting_profile.SetRawInfo(NAME_MIDDLE, | 234 starting_profile.SetRawInfo(NAME_MIDDLE, |
229 ASCIIToUTF16(test_cases[i].starting_names[1])); | 235 UTF8ToUTF16(test_cases[i].starting_names[1])); |
230 starting_profile.SetRawInfo(NAME_LAST, | 236 starting_profile.SetRawInfo(NAME_LAST, |
231 ASCIIToUTF16(test_cases[i].starting_names[2])); | 237 UTF8ToUTF16(test_cases[i].starting_names[2])); |
232 | 238 |
233 // Construct the additional_profile. | 239 // Construct the additional_profile. |
234 NameInfo additional_profile; | 240 NameInfo additional_profile; |
235 additional_profile.SetRawInfo( | 241 additional_profile.SetRawInfo( |
236 NAME_FIRST, ASCIIToUTF16(test_cases[i].additional_names[0])); | 242 NAME_FIRST, UTF8ToUTF16(test_cases[i].additional_names[0])); |
237 additional_profile.SetRawInfo( | 243 additional_profile.SetRawInfo( |
238 NAME_MIDDLE, ASCIIToUTF16(test_cases[i].additional_names[1])); | 244 NAME_MIDDLE, UTF8ToUTF16(test_cases[i].additional_names[1])); |
239 additional_profile.SetRawInfo( | 245 additional_profile.SetRawInfo( |
240 NAME_LAST, ASCIIToUTF16(test_cases[i].additional_names[2])); | 246 NAME_LAST, UTF8ToUTF16(test_cases[i].additional_names[2])); |
241 | 247 |
242 // Verify the test expectations. | 248 // Verify the test expectations. |
243 EXPECT_EQ(test_cases[i].expected_result, | 249 EXPECT_EQ(test_cases[i].expected_result, |
244 starting_profile.ParsedNamesAreEqual(additional_profile)); | 250 starting_profile.ParsedNamesAreEqual(additional_profile)); |
245 } | 251 } |
246 } | 252 } |
247 | 253 |
248 } // namespace autofill | 254 } // namespace autofill |
OLD | NEW |