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 {"刘翔", "翔", "", "刘"}, // (Simplified) Chinese name, Unihan |
| 47 {"劉翔", "翔", "", "劉"}, // (Traditional) Chinese name, Unihan |
| 48 |
| 49 // There are a few exceptions. Occasionally, the surname has two |
| 50 // characters. |
| 51 {"남궁도", "도", "", "남궁"}, // Korean name, Hangul |
| 52 {"황보혜정", "혜정", "", "황보"}, // Korean name, Hangul |
| 53 {"歐陽靖", "靖", "", "歐陽"}, // (Traditional) Chinese name, Unihan |
| 54 |
| 55 // In Korean, some 2-character surnames are rare/ambiguous, like "강전": |
| 56 // "강" is a common surname, and "전" can be part of a given name. In |
| 57 // those cases, we assume it's 1/2 for 3-character names, or 2/2 for |
| 58 // 4-character names. |
| 59 {"강전희", "전희", "", "강"}, // Korean name, Hangul |
| 60 {"황목치승", "치승", "", "황목"}, // Korean name, Hangul |
| 61 |
| 62 // It occasionally happens that a full name is 2 characters, 1/1. |
| 63 {"이도", "도", "", "이"}, // Korean name, Hangul |
| 64 {"孫文", "文", "", "孫"} // Chinese name, Unihan |
| 65 }; |
36 | 66 |
37 for (TestCase test_case : test_cases) { | 67 for (TestCase test_case : test_cases) { |
38 NameParts name_parts = SplitName(base::UTF8ToUTF16(test_case.full_name)); | 68 NameParts name_parts = SplitName(base::UTF8ToUTF16(test_case.full_name)); |
39 | 69 |
40 EXPECT_EQ(base::UTF8ToUTF16(test_case.given_name), name_parts.given); | 70 EXPECT_EQ(base::UTF8ToUTF16(test_case.given_name), name_parts.given); |
41 EXPECT_EQ(base::UTF8ToUTF16(test_case.middle_name), name_parts.middle); | 71 EXPECT_EQ(base::UTF8ToUTF16(test_case.middle_name), name_parts.middle); |
42 EXPECT_EQ(base::UTF8ToUTF16(test_case.family_name), name_parts.family); | 72 EXPECT_EQ(base::UTF8ToUTF16(test_case.family_name), name_parts.family); |
43 } | 73 } |
44 } | 74 } |
45 | 75 |
(...skipping 13 matching lines...) Expand all Loading... |
59 | 89 |
60 EXPECT_TRUE( | 90 EXPECT_TRUE( |
61 ProfileMatchesFullName(base::UTF8ToUTF16("First M. Last"), profile)); | 91 ProfileMatchesFullName(base::UTF8ToUTF16("First M. Last"), profile)); |
62 | 92 |
63 EXPECT_FALSE( | 93 EXPECT_FALSE( |
64 ProfileMatchesFullName(base::UTF8ToUTF16("Kirby Puckett"), profile)); | 94 ProfileMatchesFullName(base::UTF8ToUTF16("Kirby Puckett"), profile)); |
65 } | 95 } |
66 | 96 |
67 } // namespace data_util | 97 } // namespace data_util |
68 } // namespace autofill | 98 } // namespace autofill |
OLD | NEW |