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/autofill_profile.h" | 5 #include "components/autofill/core/browser/autofill_profile.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 21 matching lines...) Expand all Loading... |
32 namespace { | 32 namespace { |
33 | 33 |
34 base::string16 GetLabel(AutofillProfile* profile) { | 34 base::string16 GetLabel(AutofillProfile* profile) { |
35 std::vector<AutofillProfile*> profiles; | 35 std::vector<AutofillProfile*> profiles; |
36 profiles.push_back(profile); | 36 profiles.push_back(profile); |
37 std::vector<base::string16> labels; | 37 std::vector<base::string16> labels; |
38 AutofillProfile::CreateDifferentiatingLabels(profiles, "en-US", &labels); | 38 AutofillProfile::CreateDifferentiatingLabels(profiles, "en-US", &labels); |
39 return labels[0]; | 39 return labels[0]; |
40 } | 40 } |
41 | 41 |
42 // Holds the autofill profile |first|, |middle| and |last| names. | |
43 struct NameParts { | |
44 NameParts(const std::string& first, | |
45 const std::string& middle, | |
46 const std::string& last) | |
47 : first(first), middle(middle), last(last) {} | |
48 | |
49 std::string first; | |
50 std::string middle; | |
51 std::string last; | |
52 }; | |
53 | |
54 // Test case to be executed to validate OverwriteOrAppendNames. | |
55 struct TestCase { | |
56 TestCase(const NameParts& starting_name, | |
57 const NameParts& additional_name, | |
58 const NameParts& expected_result) | |
59 : starting_names(std::vector<NameParts>(1, starting_name)), | |
60 additional_names(std::vector<NameParts>(1, additional_name)), | |
61 expected_result(std::vector<NameParts>(1, expected_result)) {} | |
62 | |
63 TestCase(const std::vector<NameParts>& starting_names, | |
64 const std::vector<NameParts>& additional_names, | |
65 const std::vector<NameParts>& expected_result) | |
66 : starting_names(starting_names), | |
67 additional_names(additional_names), | |
68 expected_result(expected_result) {} | |
69 | |
70 std::vector<NameParts> starting_names; | |
71 std::vector<NameParts> additional_names; | |
72 std::vector<NameParts> expected_result; | |
73 }; | |
74 | |
75 void SetupTestProfile(AutofillProfile& profile) { | 42 void SetupTestProfile(AutofillProfile& profile) { |
76 profile.set_guid(base::GenerateGUID()); | 43 profile.set_guid(base::GenerateGUID()); |
77 profile.set_origin(kSettingsOrigin); | 44 profile.set_origin(kSettingsOrigin); |
78 test::SetProfileInfo(&profile, "Marion", "Mitchell", "Morrison", | 45 test::SetProfileInfo(&profile, "Marion", "Mitchell", "Morrison", |
79 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", | 46 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", |
80 "Hollywood", "CA", "91601", "US", "12345678910"); | 47 "Hollywood", "CA", "91601", "US", "12345678910"); |
81 } | 48 } |
82 | 49 |
83 std::vector<AutofillProfile*> ToRawPointerVector( | 50 std::vector<AutofillProfile*> ToRawPointerVector( |
84 const std::vector<std::unique_ptr<AutofillProfile>>& list) { | 51 const std::vector<std::unique_ptr<AutofillProfile>>& list) { |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 // The first, middle and last names should be kept and name full should be | 1094 // The first, middle and last names should be kept and name full should be |
1128 // added. | 1095 // added. |
1129 EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST)); | 1096 EXPECT_EQ(base::ASCIIToUTF16("Marion"), a.GetRawInfo(NAME_FIRST)); |
1130 EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE)); | 1097 EXPECT_EQ(base::ASCIIToUTF16("Mitchell"), a.GetRawInfo(NAME_MIDDLE)); |
1131 EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST)); | 1098 EXPECT_EQ(base::ASCIIToUTF16("Morrison"), a.GetRawInfo(NAME_LAST)); |
1132 EXPECT_EQ(base::ASCIIToUTF16("Marion Mitchell Morrison"), | 1099 EXPECT_EQ(base::ASCIIToUTF16("Marion Mitchell Morrison"), |
1133 a.GetRawInfo(NAME_FULL)); | 1100 a.GetRawInfo(NAME_FULL)); |
1134 } | 1101 } |
1135 | 1102 |
1136 } // namespace autofill | 1103 } // namespace autofill |
OLD | NEW |