Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/autofill/autofill_profile_unittest.cc

Issue 6877130: These changes *are* for review :) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 21 matching lines...) Expand all
32 // Empty profile - nothing to update. 32 // Empty profile - nothing to update.
33 EXPECT_FALSE(UpdateProfileLabel(&profile0)); 33 EXPECT_FALSE(UpdateProfileLabel(&profile0));
34 string16 summary0 = profile0.Label(); 34 string16 summary0 = profile0.Label();
35 EXPECT_EQ(string16(), summary0); 35 EXPECT_EQ(string16(), summary0);
36 36
37 // Case 0a/empty name and address, so the first two fields of the rest of the 37 // Case 0a/empty name and address, so the first two fields of the rest of the
38 // data is used: "Hollywood, CA" 38 // data is used: "Hollywood, CA"
39 AutofillProfile profile00; 39 AutofillProfile profile00;
40 autofill_test::SetProfileInfo(&profile00, "", "Mitchell", "", 40 autofill_test::SetProfileInfo(&profile00, "", "Mitchell", "",
41 "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US", 41 "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US",
42 "12345678910", "01987654321"); 42 "16505678910", "78127654321");
43 EXPECT_TRUE(UpdateProfileLabel(&profile00)); 43 EXPECT_TRUE(UpdateProfileLabel(&profile00));
44 string16 summary00 = profile00.Label(); 44 string16 summary00 = profile00.Label();
45 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00); 45 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00);
46 46
47 // Case 1: "<address>" 47 // Case 1: "<address>"
48 AutofillProfile profile1; 48 AutofillProfile profile1;
49 autofill_test::SetProfileInfo(&profile1, "", "Mitchell", "", 49 autofill_test::SetProfileInfo(&profile1, "", "Mitchell", "",
50 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 50 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
51 "91601", "US", "12345678910", "01987654321"); 51 "91601", "US", "16505678910", "78127654321");
52 EXPECT_TRUE(UpdateProfileLabel(&profile1)); 52 EXPECT_TRUE(UpdateProfileLabel(&profile1));
53 string16 summary1 = profile1.Label(); 53 string16 summary1 = profile1.Label();
54 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1); 54 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1);
55 55
56 // Case 2: "<lastname>" 56 // Case 2: "<lastname>"
57 AutofillProfile profile2; 57 AutofillProfile profile2;
58 autofill_test::SetProfileInfo(&profile2, "", "Mitchell", 58 autofill_test::SetProfileInfo(&profile2, "", "Mitchell",
59 "Morrison", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", 59 "Morrison", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA",
60 "91601", "US", "12345678910", "01987654321"); 60 "91601", "US", "16505678910", "78127654321");
61 EXPECT_TRUE(UpdateProfileLabel(&profile2)); 61 EXPECT_TRUE(UpdateProfileLabel(&profile2));
62 string16 summary2 = profile2.Label(); 62 string16 summary2 = profile2.Label();
63 // Summary does include full name which is empty if the first name is empty. 63 // Summary does include full name which is empty if the first name is empty.
64 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary2); 64 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary2);
65 65
66 // Case 3: "<lastname>, <address>" 66 // Case 3: "<lastname>, <address>"
67 AutofillProfile profile3; 67 AutofillProfile profile3;
68 autofill_test::SetProfileInfo(&profile3, "", "Mitchell", 68 autofill_test::SetProfileInfo(&profile3, "", "Mitchell",
69 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", 69 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5",
70 "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); 70 "Hollywood", "CA", "91601", "US", "16505678910", "78127654321");
71 EXPECT_TRUE(UpdateProfileLabel(&profile3)); 71 EXPECT_TRUE(UpdateProfileLabel(&profile3));
72 string16 summary3 = profile3.Label(); 72 string16 summary3 = profile3.Label();
73 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary3); 73 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary3);
74 74
75 // Case 4: "<firstname>" 75 // Case 4: "<firstname>"
76 AutofillProfile profile4; 76 AutofillProfile profile4;
77 autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", 77 autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "",
78 "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US", 78 "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US",
79 "12345678910", "01987654321"); 79 "16505678910", "01987654321");
80 EXPECT_TRUE(UpdateProfileLabel(&profile4)); 80 EXPECT_TRUE(UpdateProfileLabel(&profile4));
81 string16 summary4 = profile4.Label(); 81 string16 summary4 = profile4.Label();
82 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4); 82 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4);
83 83
84 // Case 5: "<firstname>, <address>" 84 // Case 5: "<firstname>, <address>"
85 AutofillProfile profile5; 85 AutofillProfile profile5;
86 autofill_test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", 86 autofill_test::SetProfileInfo(&profile5, "Marion", "Mitchell", "",
87 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 87 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
88 "91601", "US", "12345678910", "01987654321"); 88 "91601", "US", "16505678910", "78127654321");
89 EXPECT_TRUE(UpdateProfileLabel(&profile5)); 89 EXPECT_TRUE(UpdateProfileLabel(&profile5));
90 string16 summary5 = profile5.Label(); 90 string16 summary5 = profile5.Label();
91 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, 123 Zoo St."), summary5); 91 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, 123 Zoo St."), summary5);
92 92
93 // Case 6: "<firstname> <lastname>" 93 // Case 6: "<firstname> <lastname>"
94 AutofillProfile profile6; 94 AutofillProfile profile6;
95 autofill_test::SetProfileInfo(&profile6, "Marion", "Mitchell", 95 autofill_test::SetProfileInfo(&profile6, "Marion", "Mitchell",
96 "Morrison", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", 96 "Morrison", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA",
97 "91601", "US", "12345678910", "01987654321"); 97 "91601", "US", "16505678910", "78127654321");
98 EXPECT_TRUE(UpdateProfileLabel(&profile6)); 98 EXPECT_TRUE(UpdateProfileLabel(&profile6));
99 string16 summary6 = profile6.Label(); 99 string16 summary6 = profile6.Label();
100 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, Hollywood"), 100 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, Hollywood"),
101 summary6); 101 summary6);
102 102
103 // Case 7: "<firstname> <lastname>, <address>" 103 // Case 7: "<firstname> <lastname>, <address>"
104 AutofillProfile profile7; 104 AutofillProfile profile7;
105 autofill_test::SetProfileInfo(&profile7, "Marion", "Mitchell", 105 autofill_test::SetProfileInfo(&profile7, "Marion", "Mitchell",
106 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", 106 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5",
107 "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); 107 "Hollywood", "CA", "91601", "US", "16505678910", "78127654321");
108 EXPECT_TRUE(UpdateProfileLabel(&profile7)); 108 EXPECT_TRUE(UpdateProfileLabel(&profile7));
109 string16 summary7 = profile7.Label(); 109 string16 summary7 = profile7.Label();
110 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St."), 110 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St."),
111 summary7); 111 summary7);
112 112
113 // Case 7a: "<firstname> <lastname>, <address>" - same as #7, except for 113 // Case 7a: "<firstname> <lastname>, <address>" - same as #7, except for
114 // e-mail. 114 // e-mail.
115 AutofillProfile profile7a; 115 AutofillProfile profile7a;
116 autofill_test::SetProfileInfo(&profile7a, "Marion", "Mitchell", 116 autofill_test::SetProfileInfo(&profile7a, "Marion", "Mitchell",
117 "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", 117 "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
118 "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); 118 "Hollywood", "CA", "91601", "US", "16505678910", "78127654321");
119 std::vector<AutofillProfile*> profiles; 119 std::vector<AutofillProfile*> profiles;
120 profiles.push_back(&profile7); 120 profiles.push_back(&profile7);
121 profiles.push_back(&profile7a); 121 profiles.push_back(&profile7a);
122 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles)); 122 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles));
123 summary7 = profile7.Label(); 123 summary7 = profile7.Label();
124 string16 summary7a = profile7a.Label(); 124 string16 summary7a = profile7a.Label();
125 EXPECT_EQ(ASCIIToUTF16( 125 EXPECT_EQ(ASCIIToUTF16(
126 "Marion Mitchell Morrison, 123 Zoo St., johnwayne@me.xyz"), summary7); 126 "Marion Mitchell Morrison, 123 Zoo St., johnwayne@me.xyz"), summary7);
127 EXPECT_EQ(ASCIIToUTF16( 127 EXPECT_EQ(ASCIIToUTF16(
128 "Marion Mitchell Morrison, 123 Zoo St., marion@me.xyz"), summary7a); 128 "Marion Mitchell Morrison, 123 Zoo St., marion@me.xyz"), summary7a);
129 } 129 }
130 130
131 TEST(AutofillProfileTest, AdjustInferredLabels) { 131 TEST(AutofillProfileTest, AdjustInferredLabels) {
132 std::vector<AutofillProfile*> profiles; 132 std::vector<AutofillProfile*> profiles;
133 profiles.push_back(new AutofillProfile); 133 profiles.push_back(new AutofillProfile);
134 autofill_test::SetProfileInfo( 134 autofill_test::SetProfileInfo(
135 profiles[0], 135 profiles[0],
136 "John", 136 "John",
137 "", 137 "",
138 "Doe", 138 "Doe",
139 "johndoe@hades.com", 139 "johndoe@hades.com",
140 "Underworld", 140 "Underworld",
141 "666 Erebus St.", 141 "666 Erebus St.",
142 "", 142 "",
143 "Elysium", "CA", 143 "Elysium", "CA",
144 "91111", 144 "91111",
145 "US", 145 "US",
146 "11111111111", 146 "16502111111",
147 "22222222222"); 147 "16502222222");
148 profiles.push_back(new AutofillProfile); 148 profiles.push_back(new AutofillProfile);
149 autofill_test::SetProfileInfo( 149 autofill_test::SetProfileInfo(
150 profiles[1], 150 profiles[1],
151 "Jane", 151 "Jane",
152 "", 152 "",
153 "Doe", 153 "Doe",
154 "janedoe@tertium.com", 154 "janedoe@tertium.com",
155 "Pluto Inc.", 155 "Pluto Inc.",
156 "123 Letha Shore.", 156 "123 Letha Shore.",
157 "", 157 "",
(...skipping 17 matching lines...) Expand all
175 "John", 175 "John",
176 "", 176 "",
177 "Doe", 177 "Doe",
178 "johndoe@tertium.com", 178 "johndoe@tertium.com",
179 "Underworld", 179 "Underworld",
180 "666 Erebus St.", 180 "666 Erebus St.",
181 "", 181 "",
182 "Elysium", "CA", 182 "Elysium", "CA",
183 "91111", 183 "91111",
184 "US", 184 "US",
185 "11111111111", 185 "16502111111",
186 "22222222222"); 186 "16502222222");
187 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles)); 187 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles));
188 188
189 // Profile 0 and 2 inferred label now includes an e-mail. 189 // Profile 0 and 2 inferred label now includes an e-mail.
190 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com"), 190 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com"),
191 profiles[0]->Label()); 191 profiles[0]->Label());
192 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), 192 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."),
193 profiles[1]->Label()); 193 profiles[1]->Label());
194 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@tertium.com"), 194 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@tertium.com"),
195 profiles[2]->Label()); 195 profiles[2]->Label());
196 196
197 delete profiles[2]; 197 delete profiles[2];
198 profiles.pop_back(); 198 profiles.pop_back();
199 199
200 profiles.push_back(new AutofillProfile); 200 profiles.push_back(new AutofillProfile);
201 autofill_test::SetProfileInfo( 201 autofill_test::SetProfileInfo(
202 profiles[2], 202 profiles[2],
203 "John", 203 "John",
204 "", 204 "",
205 "Doe", 205 "Doe",
206 "johndoe@hades.com", 206 "johndoe@hades.com",
207 "Underworld", 207 "Underworld",
208 "666 Erebus St.", 208 "666 Erebus St.",
209 "", 209 "",
210 "Elysium", "CA", 210 "Elysium", "CA",
211 "91111", 211 "91111",
212 "US", 212 "US",
213 "11111111111", 213 "16502111111",
214 "33333333333"); // Fax is different 214 "16503333333"); // Fax is different
215 215
216 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles)); 216 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles));
217 217
218 // Profile 0 and 2 inferred label now includes a fax number. 218 // Profile 0 and 2 inferred label now includes a fax number.
219 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., fax:#22222222222"), 219 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., fax:#16502222222"),
220 profiles[0]->Label()); 220 profiles[0]->Label());
221 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), 221 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."),
222 profiles[1]->Label()); 222 profiles[1]->Label());
223 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., fax:#33333333333"), 223 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., fax:#16503333333"),
224 profiles[2]->Label()); 224 profiles[2]->Label());
225 225
226 profiles.push_back(new AutofillProfile); 226 profiles.push_back(new AutofillProfile);
227 autofill_test::SetProfileInfo( 227 autofill_test::SetProfileInfo(
228 profiles[3], 228 profiles[3],
229 "John", 229 "John",
230 "", 230 "",
231 "Doe", 231 "Doe",
232 "johndoe@hades.com", 232 "johndoe@hades.com",
233 "Underworld", 233 "Underworld",
234 "666 Erebus St.", 234 "666 Erebus St.",
235 "", 235 "",
236 "Elysium", "CA", 236 "Elysium", "CA",
237 "91111", 237 "91111",
238 "US", 238 "US",
239 "44444444444", // Phone is different for some. 239 "16504444444", // Phone is different for some.
240 "33333333333"); // Fax is different for some. 240 "16503333333"); // Fax is different for some.
241 241
242 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles)); 242 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles));
243 243
244 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., 11111111111," 244 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., 16502111111,"
245 " fax:#22222222222"), 245 " fax:#16502222222"),
246 profiles[0]->Label()); 246 profiles[0]->Label());
247 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), 247 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."),
248 profiles[1]->Label()); 248 profiles[1]->Label());
249 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., 11111111111," 249 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., 16502111111,"
250 " fax:#33333333333"), 250 " fax:#16503333333"),
251 profiles[2]->Label()); 251 profiles[2]->Label());
252 // This one differs from other ones by unique phone, so no need for extra 252 // This one differs from other ones by unique phone, so no need for extra
253 // information. 253 // information.
254 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., 44444444444"), 254 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., 16504444444"),
255 profiles[3]->Label()); 255 profiles[3]->Label());
256 256
257 profiles.push_back(new AutofillProfile); 257 profiles.push_back(new AutofillProfile);
258 autofill_test::SetProfileInfo( 258 autofill_test::SetProfileInfo(
259 profiles[4], 259 profiles[4],
260 "John", 260 "John",
261 "", 261 "",
262 "Doe", 262 "Doe",
263 "johndoe@styx.com", // E-Mail is different for some. 263 "johndoe@styx.com", // E-Mail is different for some.
264 "Underworld", 264 "Underworld",
265 "666 Erebus St.", 265 "666 Erebus St.",
266 "", 266 "",
267 "Elysium", "CA", 267 "Elysium", "CA",
268 "91111", 268 "91111",
269 "US", 269 "US",
270 "44444444444", // Phone is different for some. 270 "16504444444", // Phone is different for some.
271 "33333333333"); // Fax is different for some. 271 "16503333333"); // Fax is different for some.
272 272
273 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles)); 273 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles));
274 274
275 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com," 275 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com,"
276 " 11111111111, fax:#22222222222"), 276 " 16502111111, fax:#16502222222"),
277 profiles[0]->Label()); 277 profiles[0]->Label());
278 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), 278 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."),
279 profiles[1]->Label()); 279 profiles[1]->Label());
280 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com," 280 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com,"
281 " 11111111111, fax:#33333333333"), 281 " 16502111111, fax:#16503333333"),
282 profiles[2]->Label()); 282 profiles[2]->Label());
283 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com," 283 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com,"
284 " 44444444444, fax:#33333333333"), 284 " 16504444444, fax:#16503333333"),
285 profiles[3]->Label()); 285 profiles[3]->Label());
286 // This one differs from other ones by unique e-mail, so no need for extra 286 // This one differs from other ones by unique e-mail, so no need for extra
287 // information. 287 // information.
288 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@styx.com"), 288 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@styx.com"),
289 profiles[4]->Label()); 289 profiles[4]->Label());
290 290
291 EXPECT_FALSE(AutofillProfile::AdjustInferredLabels(&profiles)); 291 EXPECT_FALSE(AutofillProfile::AdjustInferredLabels(&profiles));
292 292
293 // Clean up. 293 // Clean up.
294 STLDeleteContainerPointers(profiles.begin(), profiles.end()); 294 STLDeleteContainerPointers(profiles.begin(), profiles.end());
295 } 295 }
296 296
297 TEST(AutofillProfileTest, CreateInferredLabels) { 297 TEST(AutofillProfileTest, CreateInferredLabels) {
298 std::vector<AutofillProfile*> profiles; 298 std::vector<AutofillProfile*> profiles;
299 profiles.push_back(new AutofillProfile); 299 profiles.push_back(new AutofillProfile);
300 autofill_test::SetProfileInfo(profiles[0], 300 autofill_test::SetProfileInfo(profiles[0],
301 "John", 301 "John",
302 "", 302 "",
303 "Doe", 303 "Doe",
304 "johndoe@hades.com", 304 "johndoe@hades.com",
305 "Underworld", 305 "Underworld",
306 "666 Erebus St.", 306 "666 Erebus St.",
307 "", 307 "",
308 "Elysium", "CA", 308 "Elysium", "CA",
309 "91111", 309 "91111",
310 "US", 310 "US",
311 "11111111111", 311 "16502111111",
312 "22222222222"); 312 "16502222222");
313 profiles.push_back(new AutofillProfile); 313 profiles.push_back(new AutofillProfile);
314 autofill_test::SetProfileInfo(profiles[1], 314 autofill_test::SetProfileInfo(profiles[1],
315 "Jane", 315 "Jane",
316 "", 316 "",
317 "Doe", 317 "Doe",
318 "janedoe@tertium.com", 318 "janedoe@tertium.com",
319 "Pluto Inc.", 319 "Pluto Inc.",
320 "123 Letha Shore.", 320 "123 Letha Shore.",
321 "", 321 "",
322 "Dis", "CA", 322 "Dis", "CA",
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 std::vector<string16> get_values; 747 std::vector<string16> get_values;
748 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); 748 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values);
749 ASSERT_EQ(2UL, get_values.size()); 749 ASSERT_EQ(2UL, get_values.size());
750 EXPECT_EQ(kJohnDoe, get_values[0]); 750 EXPECT_EQ(kJohnDoe, get_values[0]);
751 EXPECT_EQ(kJohnPDoe, get_values[1]); 751 EXPECT_EQ(kJohnPDoe, get_values[1]);
752 752
753 // Update the values. 753 // Update the values.
754 AutofillProfile p2 = p; 754 AutofillProfile p2 = p;
755 EXPECT_EQ(0, p.Compare(p2)); 755 EXPECT_EQ(0, p.Compare(p2));
756 EXPECT_EQ(0, p.CompareMulti(p2)); 756 EXPECT_EQ(0, p.CompareMulti(p2));
757 const string16 kNoOne(ASCIIToUTF16("4151110000")); 757 const string16 kNoOne(ASCIIToUTF16("4152110000"));
758 set_values[1] = kNoOne; 758 set_values[1] = kNoOne;
759 p.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 759 p.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
760 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); 760 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values);
761 ASSERT_EQ(2UL, get_values.size()); 761 ASSERT_EQ(2UL, get_values.size());
762 EXPECT_EQ(kJohnDoe, get_values[0]); 762 EXPECT_EQ(kJohnDoe, get_values[0]);
763 EXPECT_EQ(kNoOne, get_values[1]); 763 EXPECT_EQ(kNoOne, get_values[1]);
764 EXPECT_EQ(0, p.Compare(p2)); 764 EXPECT_EQ(0, p.Compare(p2));
765 EXPECT_NE(0, p.CompareMulti(p2)); 765 EXPECT_NE(0, p.CompareMulti(p2));
766 766
767 // Delete values. 767 // Delete values.
768 set_values.clear(); 768 set_values.clear();
769 p.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 769 p.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
770 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); 770 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values);
771 ASSERT_EQ(1UL, get_values.size()); 771 ASSERT_EQ(1UL, get_values.size());
772 EXPECT_EQ(string16(), get_values[0]); 772 EXPECT_EQ(string16(), get_values[0]);
773 773
774 // Expect regular |GetInfo| returns empty value. 774 // Expect regular |GetInfo| returns empty value.
775 EXPECT_EQ(string16(), p.GetInfo(PHONE_HOME_WHOLE_NUMBER)); 775 EXPECT_EQ(string16(), p.GetInfo(PHONE_HOME_WHOLE_NUMBER));
776 } 776 }
777 777
778 TEST(AutofillProfileTest, MultiValueFax) { 778 TEST(AutofillProfileTest, MultiValueFax) {
779 AutofillProfile p; 779 AutofillProfile p;
780 const string16 kJohnDoe(ASCIIToUTF16("4151112222")); 780 const string16 kJohnDoe(ASCIIToUTF16("4152112222"));
781 const string16 kJohnPDoe(ASCIIToUTF16("4151113333")); 781 const string16 kJohnPDoe(ASCIIToUTF16("4153113333"));
782 std::vector<string16> set_values; 782 std::vector<string16> set_values;
783 set_values.push_back(kJohnDoe); 783 set_values.push_back(kJohnDoe);
784 set_values.push_back(kJohnPDoe); 784 set_values.push_back(kJohnPDoe);
785 p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values); 785 p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values);
786 786
787 // Expect regular |GetInfo| returns the first element. 787 // Expect regular |GetInfo| returns the first element.
788 EXPECT_EQ(kJohnDoe, p.GetInfo(PHONE_FAX_WHOLE_NUMBER)); 788 EXPECT_EQ(kJohnDoe, p.GetInfo(PHONE_FAX_WHOLE_NUMBER));
789 789
790 // Ensure that we get out what we put in. 790 // Ensure that we get out what we put in.
791 std::vector<string16> get_values; 791 std::vector<string16> get_values;
(...skipping 19 matching lines...) Expand all
811 // Delete values. 811 // Delete values.
812 set_values.clear(); 812 set_values.clear();
813 p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values); 813 p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values);
814 p.GetMultiInfo(PHONE_FAX_WHOLE_NUMBER, &get_values); 814 p.GetMultiInfo(PHONE_FAX_WHOLE_NUMBER, &get_values);
815 ASSERT_EQ(1UL, get_values.size()); 815 ASSERT_EQ(1UL, get_values.size());
816 EXPECT_EQ(string16(), get_values[0]); 816 EXPECT_EQ(string16(), get_values[0]);
817 817
818 // Expect regular |GetInfo| returns empty value. 818 // Expect regular |GetInfo| returns empty value.
819 EXPECT_EQ(string16(), p.GetInfo(PHONE_FAX_WHOLE_NUMBER)); 819 EXPECT_EQ(string16(), p.GetInfo(PHONE_FAX_WHOLE_NUMBER));
820 } 820 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698