OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/autofill_data_util.h" | 5 #include "components/autofill/core/browser/autofill_data_util.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/core/browser/autofill_test_utils.h" | 8 #include "components/autofill/core/browser/autofill_test_utils.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 {"Homer Jay Simpson", "Homer", "Jay", "Simpson"}, | 25 {"Homer Jay Simpson", "Homer", "Jay", "Simpson"}, |
26 // No middle name. | 26 // No middle name. |
27 {"Moe Szyslak", "Moe", "", "Szyslak"}, | 27 {"Moe Szyslak", "Moe", "", "Szyslak"}, |
28 // Common name prefixes removed. | 28 // Common name prefixes removed. |
29 {"Reverend Timothy Lovejoy", "Timothy", "", "Lovejoy"}, | 29 {"Reverend Timothy Lovejoy", "Timothy", "", "Lovejoy"}, |
30 // Common name suffixes removed. | 30 // Common name suffixes removed. |
31 {"John Frink Phd", "John", "", "Frink"}, | 31 {"John Frink Phd", "John", "", "Frink"}, |
32 // Exception to the name suffix removal. | 32 // Exception to the name suffix removal. |
33 {"John Ma", "John", "", "Ma"}, | 33 {"John Ma", "John", "", "Ma"}, |
34 // Common family name prefixes not considered a middle name. | 34 // Common family name prefixes not considered a middle name. |
35 {"Milhouse Van Houten", "Milhouse", "", "Van Houten"}}; | 35 {"Milhouse Van Houten", "Milhouse", "", "Van Houten"}, |
36 | |
37 // CJK names have reverse order (surname goes first, given name goes | |
38 // second). | |
39 {"홍 길동", "길동", "", "홍"}, // Korean name, Hangul | |
40 {"孫 德明", "德明", "", "孫"}, // Chinese name, Unihan | |
41 {"山田 貴洋", "貴洋", "", "山田"}, // Japanese name, Unihan | |
42 | |
43 // CJK names don't usually have a space in the middle, but most of the | |
44 // time, the surname is only one character (in Chinese & Korean). | |
45 {"최성훈", "성훈", "", "최"}, // Korean name, Hangul | |
46 {"강전희", "전희", "", "강"}, // Korean name, Hangul | |
47 {"刘翔", "翔", "", "刘"}, // (Traditional) Chinese name, Unihan | |
48 {"劉翔", "翔", "", "劉"}, // (Simplified) Chinese name, Unihan | |
gogerald1
2016/07/14 18:28:52
nit: I believe this ("劉") is traditional and above
nicolaso
2016/07/14 20:32:17
Fixed.
| |
49 | |
50 // There are a few exceptions. Occasionally, the surname has two | |
51 // characters. | |
52 {"남궁도", "도", "", "남궁"}, // Korean name, Hangul | |
53 {"황보혜정", "혜정", "", "황보"}, // Korean name, Hangul | |
54 {"歐陽靖", "靖", "", "歐陽"}, // (Traditional) Chinese name, Unihan | |
55 | |
56 // Korean full names always have at least 3 characters, so a 2-character | |
Jinsuk Kim
2016/07/13 21:51:09
Please update the comment here.
nicolaso
2016/07/14 18:12:43
Done.
| |
57 // name can only be a given name. Chinese full names, however, might be | |
58 // only 2 characters. | |
59 {"제동", "제동", "", ""}, // Korean name, Hangul | |
60 {"孫文", "文", "", "孫"} // Chinese name, Unihan | |
61 }; | |
36 | 62 |
37 for (TestCase test_case : test_cases) { | 63 for (TestCase test_case : test_cases) { |
38 NameParts name_parts = SplitName(base::UTF8ToUTF16(test_case.full_name)); | 64 NameParts name_parts = SplitName(base::UTF8ToUTF16(test_case.full_name)); |
39 | 65 |
40 EXPECT_EQ(base::UTF8ToUTF16(test_case.given_name), name_parts.given); | 66 EXPECT_EQ(base::UTF8ToUTF16(test_case.given_name), name_parts.given); |
41 EXPECT_EQ(base::UTF8ToUTF16(test_case.middle_name), name_parts.middle); | 67 EXPECT_EQ(base::UTF8ToUTF16(test_case.middle_name), name_parts.middle); |
42 EXPECT_EQ(base::UTF8ToUTF16(test_case.family_name), name_parts.family); | 68 EXPECT_EQ(base::UTF8ToUTF16(test_case.family_name), name_parts.family); |
43 } | 69 } |
44 } | 70 } |
45 | 71 |
(...skipping 13 matching lines...) Expand all Loading... | |
59 | 85 |
60 EXPECT_TRUE( | 86 EXPECT_TRUE( |
61 ProfileMatchesFullName(base::UTF8ToUTF16("First M. Last"), profile)); | 87 ProfileMatchesFullName(base::UTF8ToUTF16("First M. Last"), profile)); |
62 | 88 |
63 EXPECT_FALSE( | 89 EXPECT_FALSE( |
64 ProfileMatchesFullName(base::UTF8ToUTF16("Kirby Puckett"), profile)); | 90 ProfileMatchesFullName(base::UTF8ToUTF16("Kirby Puckett"), profile)); |
65 } | 91 } |
66 | 92 |
67 } // namespace data_util | 93 } // namespace data_util |
68 } // namespace autofill | 94 } // namespace autofill |
OLD | NEW |