OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/basictypes.h" | |
6 #include "base/guid.h" | |
7 #include "base/memory/scoped_ptr.h" | |
8 #include "base/memory/scoped_vector.h" | |
9 #include "base/stl_util.h" | |
10 #include "base/strings/string16.h" | |
11 #include "base/strings/stringprintf.h" | |
12 #include "base/strings/utf_string_conversions.h" | |
13 #include "components/autofill/browser/autofill_common_test.h" | |
14 #include "components/autofill/browser/autofill_profile.h" | |
15 #include "components/autofill/core/common/form_field_data.h" | |
16 #include "grit/component_strings.h" | |
17 #include "testing/gtest/include/gtest/gtest.h" | |
18 | |
19 namespace autofill { | |
20 | |
21 namespace { | |
22 | |
23 bool UpdateProfileLabel(AutofillProfile *profile) { | |
24 std::vector<AutofillProfile*> profiles; | |
25 profiles.push_back(profile); | |
26 return AutofillProfile::AdjustInferredLabels(&profiles); | |
27 } | |
28 | |
29 } // namespace | |
30 | |
31 // Tests different possibilities for summary string generation. | |
32 // Based on existence of first name, last name, and address line 1. | |
33 TEST(AutofillProfileTest, PreviewSummaryString) { | |
34 // Case 0/null: "" | |
35 AutofillProfile profile0(base::GenerateGUID(), "https://www.example.com/"); | |
36 // Empty profile - nothing to update. | |
37 EXPECT_FALSE(UpdateProfileLabel(&profile0)); | |
38 base::string16 summary0 = profile0.Label(); | |
39 EXPECT_EQ(base::string16(), summary0); | |
40 | |
41 // Case 0a/empty name and address, so the first two fields of the rest of the | |
42 // data is used: "Hollywood, CA" | |
43 AutofillProfile profile00(base::GenerateGUID(), "https://www.example.com/"); | |
44 test::SetProfileInfo(&profile00, "", "", "", | |
45 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", | |
46 "16505678910"); | |
47 EXPECT_TRUE(UpdateProfileLabel(&profile00)); | |
48 base::string16 summary00 = profile00.Label(); | |
49 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00); | |
50 | |
51 // Case 1: "<address>" without line 2. | |
52 AutofillProfile profile1(base::GenerateGUID(), "https://www.example.com/"); | |
53 test::SetProfileInfo(&profile1, "", "", "", | |
54 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", "Hollywood", "CA", | |
55 "91601", "US", "16505678910"); | |
56 EXPECT_TRUE(UpdateProfileLabel(&profile1)); | |
57 base::string16 summary1 = profile1.Label(); | |
58 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1); | |
59 | |
60 // Case 1a: "<address>" with line 2. | |
61 AutofillProfile profile1a(base::GenerateGUID(), "https://www.example.com/"); | |
62 test::SetProfileInfo(&profile1a, "", "", "", | |
63 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | |
64 "91601", "US", "16505678910"); | |
65 EXPECT_TRUE(UpdateProfileLabel(&profile1a)); | |
66 base::string16 summary1a = profile1a.Label(); | |
67 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., unit 5"), summary1a); | |
68 | |
69 // Case 2: "<lastname>" | |
70 AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com/"); | |
71 test::SetProfileInfo(&profile2, "", "Mitchell", | |
72 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", | |
73 "91601", "US", "16505678910"); | |
74 EXPECT_TRUE(UpdateProfileLabel(&profile2)); | |
75 base::string16 summary2 = profile2.Label(); | |
76 // Summary includes full name, to the maximal extent available. | |
77 EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, Hollywood"), summary2); | |
78 | |
79 // Case 3: "<lastname>, <address>" | |
80 AutofillProfile profile3(base::GenerateGUID(), "https://www.example.com/"); | |
81 test::SetProfileInfo(&profile3, "", "Mitchell", | |
82 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", | |
83 "Hollywood", "CA", "91601", "US", "16505678910"); | |
84 EXPECT_TRUE(UpdateProfileLabel(&profile3)); | |
85 base::string16 summary3 = profile3.Label(); | |
86 EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, 123 Zoo St."), summary3); | |
87 | |
88 // Case 4: "<firstname>" | |
89 AutofillProfile profile4(base::GenerateGUID(), "https://www.example.com/"); | |
90 test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", | |
91 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", | |
92 "16505678910"); | |
93 EXPECT_TRUE(UpdateProfileLabel(&profile4)); | |
94 base::string16 summary4 = profile4.Label(); | |
95 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4); | |
96 | |
97 // Case 5: "<firstname>, <address>" | |
98 AutofillProfile profile5(base::GenerateGUID(), "https://www.example.com/"); | |
99 test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", | |
100 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | |
101 "91601", "US", "16505678910"); | |
102 EXPECT_TRUE(UpdateProfileLabel(&profile5)); | |
103 base::string16 summary5 = profile5.Label(); | |
104 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, 123 Zoo St."), summary5); | |
105 | |
106 // Case 6: "<firstname> <lastname>" | |
107 AutofillProfile profile6(base::GenerateGUID(), "https://www.example.com/"); | |
108 test::SetProfileInfo(&profile6, "Marion", "Mitchell", | |
109 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", | |
110 "91601", "US", "16505678910"); | |
111 EXPECT_TRUE(UpdateProfileLabel(&profile6)); | |
112 base::string16 summary6 = profile6.Label(); | |
113 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, Hollywood"), | |
114 summary6); | |
115 | |
116 // Case 7: "<firstname> <lastname>, <address>" | |
117 AutofillProfile profile7(base::GenerateGUID(), "https://www.example.com/"); | |
118 test::SetProfileInfo(&profile7, "Marion", "Mitchell", | |
119 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", | |
120 "Hollywood", "CA", "91601", "US", "16505678910"); | |
121 EXPECT_TRUE(UpdateProfileLabel(&profile7)); | |
122 base::string16 summary7 = profile7.Label(); | |
123 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St."), summary7); | |
124 | |
125 // Case 7a: "<firstname> <lastname>, <address>" - same as #7, except for | |
126 // e-mail. | |
127 AutofillProfile profile7a(base::GenerateGUID(), "https://www.example.com/"); | |
128 test::SetProfileInfo(&profile7a, "Marion", "Mitchell", | |
129 "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", | |
130 "Hollywood", "CA", "91601", "US", "16505678910"); | |
131 std::vector<AutofillProfile*> profiles; | |
132 profiles.push_back(&profile7); | |
133 profiles.push_back(&profile7a); | |
134 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles)); | |
135 summary7 = profile7.Label(); | |
136 base::string16 summary7a = profile7a.Label(); | |
137 EXPECT_EQ(ASCIIToUTF16( | |
138 "Marion Mitchell Morrison, 123 Zoo St., johnwayne@me.xyz"), summary7); | |
139 EXPECT_EQ(ASCIIToUTF16( | |
140 "Marion Mitchell Morrison, 123 Zoo St., marion@me.xyz"), summary7a); | |
141 } | |
142 | |
143 TEST(AutofillProfileTest, AdjustInferredLabels) { | |
144 ScopedVector<AutofillProfile> profiles; | |
145 profiles.push_back( | |
146 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
147 test::SetProfileInfo( | |
148 profiles[0], | |
149 "John", | |
150 "", | |
151 "Doe", | |
152 "johndoe@hades.com", | |
153 "Underworld", | |
154 "666 Erebus St.", | |
155 "", | |
156 "Elysium", "CA", | |
157 "91111", | |
158 "US", | |
159 "16502111111"); | |
160 profiles.push_back( | |
161 new AutofillProfile(base::GenerateGUID(), "http://www.example.com/")); | |
162 test::SetProfileInfo( | |
163 profiles[1], | |
164 "Jane", | |
165 "", | |
166 "Doe", | |
167 "janedoe@tertium.com", | |
168 "Pluto Inc.", | |
169 "123 Letha Shore.", | |
170 "", | |
171 "Dis", "CA", | |
172 "91222", | |
173 "US", | |
174 "12345678910"); | |
175 // As labels are empty they are adjusted the first time. | |
176 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles.get())); | |
177 // No need to adjust them anymore. | |
178 EXPECT_FALSE(AutofillProfile::AdjustInferredLabels(&profiles.get())); | |
179 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St."), | |
180 profiles[0]->Label()); | |
181 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), | |
182 profiles[1]->Label()); | |
183 | |
184 profiles.push_back( | |
185 new AutofillProfile(base::GenerateGUID(), "Chrome settings")); | |
186 test::SetProfileInfo( | |
187 profiles[2], | |
188 "John", | |
189 "", | |
190 "Doe", | |
191 "johndoe@tertium.com", | |
192 "Underworld", | |
193 "666 Erebus St.", | |
194 "", | |
195 "Elysium", "CA", | |
196 "91111", | |
197 "US", | |
198 "16502111111"); | |
199 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles.get())); | |
200 | |
201 // Profile 0 and 2 inferred label now includes an e-mail. | |
202 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@hades.com"), | |
203 profiles[0]->Label()); | |
204 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), | |
205 profiles[1]->Label()); | |
206 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., johndoe@tertium.com"), | |
207 profiles[2]->Label()); | |
208 | |
209 profiles.resize(2); | |
210 | |
211 profiles.push_back( | |
212 new AutofillProfile(base::GenerateGUID(), std::string())); | |
213 test::SetProfileInfo( | |
214 profiles[2], | |
215 "John", | |
216 "", | |
217 "Doe", | |
218 "johndoe@hades.com", | |
219 "Underworld", | |
220 "666 Erebus St.", | |
221 "", | |
222 "Elysium", "CO", // State is different | |
223 "91111", | |
224 "US", | |
225 "16502111111"); | |
226 | |
227 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles.get())); | |
228 | |
229 // Profile 0 and 2 inferred label now includes a state. | |
230 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CA"), | |
231 profiles[0]->Label()); | |
232 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), | |
233 profiles[1]->Label()); | |
234 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO"), | |
235 profiles[2]->Label()); | |
236 | |
237 profiles.push_back( | |
238 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
239 test::SetProfileInfo( | |
240 profiles[3], | |
241 "John", | |
242 "", | |
243 "Doe", | |
244 "johndoe@hades.com", | |
245 "Underworld", | |
246 "666 Erebus St.", | |
247 "", | |
248 "Elysium", "CO", // State is different for some. | |
249 "91111", | |
250 "US", | |
251 "16504444444"); // Phone is different for some. | |
252 | |
253 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles.get())); | |
254 | |
255 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CA"), | |
256 profiles[0]->Label()); | |
257 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), | |
258 profiles[1]->Label()); | |
259 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, 16502111111"), | |
260 profiles[2]->Label()); | |
261 // This one differs from other ones by unique phone, so no need for extra | |
262 // information. | |
263 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, 16504444444"), | |
264 profiles[3]->Label()); | |
265 | |
266 profiles.push_back( | |
267 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
268 test::SetProfileInfo( | |
269 profiles[4], | |
270 "John", | |
271 "", | |
272 "Doe", | |
273 "johndoe@styx.com", // E-Mail is different for some. | |
274 "Underworld", | |
275 "666 Erebus St.", | |
276 "", | |
277 "Elysium", "CO", // State is different for some. | |
278 "91111", | |
279 "US", | |
280 "16504444444"); // Phone is different for some. | |
281 | |
282 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles.get())); | |
283 | |
284 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CA"), | |
285 profiles[0]->Label()); | |
286 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), | |
287 profiles[1]->Label()); | |
288 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, johndoe@hades.com," | |
289 " 16502111111"), | |
290 profiles[2]->Label()); | |
291 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, johndoe@hades.com," | |
292 " 16504444444"), | |
293 profiles[3]->Label()); | |
294 // This one differs from other ones by unique e-mail, so no need for extra | |
295 // information. | |
296 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., CO, johndoe@styx.com"), | |
297 profiles[4]->Label()); | |
298 | |
299 EXPECT_FALSE(AutofillProfile::AdjustInferredLabels(&profiles.get())); | |
300 } | |
301 | |
302 TEST(AutofillProfileTest, CreateInferredLabels) { | |
303 ScopedVector<AutofillProfile> profiles; | |
304 profiles.push_back( | |
305 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
306 test::SetProfileInfo(profiles[0], | |
307 "John", | |
308 "", | |
309 "Doe", | |
310 "johndoe@hades.com", | |
311 "Underworld", | |
312 "666 Erebus St.", | |
313 "", | |
314 "Elysium", "CA", | |
315 "91111", | |
316 "US", | |
317 "16502111111"); | |
318 profiles.push_back( | |
319 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
320 test::SetProfileInfo(profiles[1], | |
321 "Jane", | |
322 "", | |
323 "Doe", | |
324 "janedoe@tertium.com", | |
325 "Pluto Inc.", | |
326 "123 Letha Shore.", | |
327 "", | |
328 "Dis", "CA", | |
329 "91222", | |
330 "US", | |
331 "12345678910"); | |
332 std::vector<base::string16> labels; | |
333 // Two fields at least - no filter. | |
334 AutofillProfile::CreateInferredLabels(&profiles.get(), NULL, UNKNOWN_TYPE, 2, | |
335 &labels); | |
336 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St."), labels[0]); | |
337 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]); | |
338 | |
339 // Three fields at least - no filter. | |
340 AutofillProfile::CreateInferredLabels(&profiles.get(), NULL, UNKNOWN_TYPE, 3, | |
341 &labels); | |
342 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., Elysium"), | |
343 labels[0]); | |
344 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore., Dis"), | |
345 labels[1]); | |
346 | |
347 std::vector<AutofillFieldType> suggested_fields; | |
348 suggested_fields.push_back(ADDRESS_HOME_CITY); | |
349 suggested_fields.push_back(ADDRESS_HOME_STATE); | |
350 suggested_fields.push_back(ADDRESS_HOME_ZIP); | |
351 | |
352 // Two fields at least, from suggested fields - no filter. | |
353 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
354 UNKNOWN_TYPE, 2, &labels); | |
355 EXPECT_EQ(ASCIIToUTF16("Elysium, CA"), labels[0]); | |
356 EXPECT_EQ(ASCIIToUTF16("Dis, CA"), labels[1]); | |
357 | |
358 // Three fields at least, from suggested fields - no filter. | |
359 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
360 UNKNOWN_TYPE, 3, &labels); | |
361 EXPECT_EQ(ASCIIToUTF16("Elysium, CA, 91111"), labels[0]); | |
362 EXPECT_EQ(ASCIIToUTF16("Dis, CA, 91222"), labels[1]); | |
363 | |
364 // Three fields at least, from suggested fields - but filter reduces available | |
365 // fields to two. | |
366 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
367 ADDRESS_HOME_STATE, 3, &labels); | |
368 EXPECT_EQ(ASCIIToUTF16("Elysium, 91111"), labels[0]); | |
369 EXPECT_EQ(ASCIIToUTF16("Dis, 91222"), labels[1]); | |
370 | |
371 suggested_fields.clear(); | |
372 // In our implementation we always display NAME_FULL for all NAME* fields... | |
373 suggested_fields.push_back(NAME_MIDDLE); | |
374 // One field at least, from suggested fields - no filter. | |
375 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
376 UNKNOWN_TYPE, 1, &labels); | |
377 EXPECT_EQ(ASCIIToUTF16("John Doe"), labels[0]); | |
378 EXPECT_EQ(ASCIIToUTF16("Jane Doe"), labels[1]); | |
379 | |
380 // One field at least, from suggested fields - filter the same as suggested | |
381 // field. | |
382 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
383 NAME_MIDDLE, 1, &labels); | |
384 EXPECT_EQ(base::string16(), labels[0]); | |
385 EXPECT_EQ(base::string16(), labels[1]); | |
386 | |
387 suggested_fields.clear(); | |
388 // In our implementation we always display NAME_FULL for NAME_MIDDLE_INITIAL | |
389 suggested_fields.push_back(NAME_MIDDLE_INITIAL); | |
390 // One field at least, from suggested fields - no filter. | |
391 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
392 UNKNOWN_TYPE, 1, &labels); | |
393 EXPECT_EQ(ASCIIToUTF16("John Doe"), labels[0]); | |
394 EXPECT_EQ(ASCIIToUTF16("Jane Doe"), labels[1]); | |
395 | |
396 // One field at least, from suggested fields - filter same as the first non- | |
397 // unknown suggested field. | |
398 suggested_fields.clear(); | |
399 suggested_fields.push_back(UNKNOWN_TYPE); | |
400 suggested_fields.push_back(NAME_FULL); | |
401 suggested_fields.push_back(ADDRESS_HOME_LINE1); | |
402 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
403 NAME_FULL, 1, &labels); | |
404 EXPECT_EQ(base::string16(ASCIIToUTF16("666 Erebus St.")), labels[0]); | |
405 EXPECT_EQ(base::string16(ASCIIToUTF16("123 Letha Shore.")), labels[1]); | |
406 } | |
407 | |
408 // Test that we fall back to using the full name if there are no other | |
409 // distinguishing fields, but only if it makes sense given the suggested fields. | |
410 TEST(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) { | |
411 ScopedVector<AutofillProfile> profiles; | |
412 profiles.push_back( | |
413 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
414 test::SetProfileInfo(profiles[0], | |
415 "John", "", "Doe", "doe@example.com", "", | |
416 "88 Nowhere Ave.", "", "", "", "", "", ""); | |
417 profiles.push_back( | |
418 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
419 test::SetProfileInfo(profiles[1], | |
420 "Johnny", "K", "Doe", "doe@example.com", "", | |
421 "88 Nowhere Ave.", "", "", "", "", "", ""); | |
422 | |
423 // If the only name field in the suggested fields is the excluded field, we | |
424 // should not fall back to the full name as a distinguishing field. | |
425 std::vector<AutofillFieldType> suggested_fields; | |
426 suggested_fields.push_back(NAME_LAST); | |
427 suggested_fields.push_back(ADDRESS_HOME_LINE1); | |
428 suggested_fields.push_back(EMAIL_ADDRESS); | |
429 std::vector<base::string16> labels; | |
430 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
431 NAME_LAST, 1, &labels); | |
432 ASSERT_EQ(2U, labels.size()); | |
433 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave."), labels[0]); | |
434 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave."), labels[1]); | |
435 | |
436 // Otherwise, we should. | |
437 suggested_fields.push_back(NAME_FIRST); | |
438 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
439 NAME_LAST, 1, &labels); | |
440 ASSERT_EQ(2U, labels.size()); | |
441 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., John Doe"), labels[0]); | |
442 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., Johnny K Doe"), labels[1]); | |
443 } | |
444 | |
445 // Test that we do not show duplicate fields in the labels. | |
446 TEST(AutofillProfileTest, CreateInferredLabelsNoDuplicatedFields) { | |
447 ScopedVector<AutofillProfile> profiles; | |
448 profiles.push_back( | |
449 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
450 test::SetProfileInfo(profiles[0], | |
451 "John", "", "Doe", "doe@example.com", "", | |
452 "88 Nowhere Ave.", "", "", "", "", "", ""); | |
453 profiles.push_back( | |
454 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
455 test::SetProfileInfo(profiles[1], | |
456 "John", "", "Doe", "dojo@example.com", "", | |
457 "88 Nowhere Ave.", "", "", "", "", "", ""); | |
458 | |
459 // If the only name field in the suggested fields is the excluded field, we | |
460 // should not fall back to the full name as a distinguishing field. | |
461 std::vector<AutofillFieldType> suggested_fields; | |
462 suggested_fields.push_back(ADDRESS_HOME_LINE1); | |
463 suggested_fields.push_back(ADDRESS_BILLING_LINE1); | |
464 suggested_fields.push_back(EMAIL_ADDRESS); | |
465 std::vector<base::string16> labels; | |
466 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, | |
467 UNKNOWN_TYPE, 2, &labels); | |
468 ASSERT_EQ(2U, labels.size()); | |
469 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., doe@example.com"), labels[0]); | |
470 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., dojo@example.com"), labels[1]); | |
471 } | |
472 | |
473 // Make sure that empty fields are not treated as distinguishing fields. | |
474 TEST(AutofillProfileTest, CreateInferredLabelsSkipsEmptyFields) { | |
475 ScopedVector<AutofillProfile> profiles; | |
476 profiles.push_back( | |
477 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
478 test::SetProfileInfo(profiles[0], | |
479 "John", "", "Doe", "doe@example.com", | |
480 "Gogole", "", "", "", "", "", "", ""); | |
481 profiles.push_back( | |
482 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
483 test::SetProfileInfo(profiles[1], | |
484 "John", "", "Doe", "doe@example.com", | |
485 "Ggoole", "", "", "", "", "", "", ""); | |
486 profiles.push_back( | |
487 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
488 test::SetProfileInfo(profiles[2], | |
489 "John", "", "Doe", "john.doe@example.com", | |
490 "Goolge", "", "", "", "", "", "", ""); | |
491 | |
492 std::vector<base::string16> labels; | |
493 AutofillProfile::CreateInferredLabels(&profiles.get(), NULL, UNKNOWN_TYPE, 3, | |
494 &labels); | |
495 ASSERT_EQ(3U, labels.size()); | |
496 EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]); | |
497 EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Ggoole"), labels[1]); | |
498 EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com, Goolge"), labels[2]); | |
499 | |
500 // A field must have a non-empty value for each profile to be considered a | |
501 // distinguishing field. | |
502 profiles[1]->SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("88 Nowhere Ave.")); | |
503 AutofillProfile::CreateInferredLabels(&profiles.get(), NULL, UNKNOWN_TYPE, 1, | |
504 &labels); | |
505 ASSERT_EQ(3U, labels.size()); | |
506 EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]); | |
507 EXPECT_EQ(ASCIIToUTF16("John Doe, 88 Nowhere Ave., doe@example.com, Ggoole"), | |
508 labels[1]) << labels[1]; | |
509 EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com"), labels[2]); | |
510 } | |
511 | |
512 TEST(AutofillProfileTest, IsSubsetOf) { | |
513 scoped_ptr<AutofillProfile> a, b; | |
514 | |
515 // |a| is a subset of |b|. | |
516 a.reset( | |
517 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
518 b.reset( | |
519 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
520 test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", | |
521 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |
522 NULL); | |
523 test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson", | |
524 "declaration_guy@gmail.com", "United States Government", "Monticello", | |
525 NULL, "Charlottesville", "Virginia", "22902", NULL, NULL); | |
526 EXPECT_TRUE(a->IsSubsetOf(*b, "en-US")); | |
527 | |
528 // |b| is not a subset of |a|. | |
529 EXPECT_FALSE(b->IsSubsetOf(*a, "en-US")); | |
530 | |
531 // |a| is a subset of |a|. | |
532 EXPECT_TRUE(a->IsSubsetOf(*a, "en-US")); | |
533 | |
534 // One field in |b| is different. | |
535 a.reset( | |
536 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
537 b.reset( | |
538 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | |
539 test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", | |
540 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |
541 NULL); | |
542 test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams", | |
543 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |
544 NULL); | |
545 EXPECT_FALSE(a->IsSubsetOf(*b, "en-US")); | |
546 } | |
547 | |
548 TEST(AutofillProfileTest, OverwriteWithOrAddTo) { | |
549 AutofillProfile a(base::GenerateGUID(), "https://www.example.com"); | |
550 test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", | |
551 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", | |
552 "Hollywood", "CA", "91601", "US", | |
553 "12345678910"); | |
554 std::vector<base::string16> names; | |
555 a.GetRawMultiInfo(NAME_FULL, &names); | |
556 names.push_back(ASCIIToUTF16("Marion Morrison")); | |
557 a.SetRawMultiInfo(NAME_FULL, names); | |
558 | |
559 // Create an identical profile except that the new profile: | |
560 // (1) Has a different origin, | |
561 // (2) Has a different address line 2, | |
562 // (3) Lacks a company name, and | |
563 // (4) Has a different full name variant. | |
564 AutofillProfile b = a; | |
565 b.set_guid(base::GenerateGUID()); | |
566 b.set_origin("Chrome settings"); | |
567 b.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("area 51")); | |
568 b.SetRawInfo(COMPANY_NAME, base::string16()); | |
569 b.GetRawMultiInfo(NAME_FULL, &names); | |
570 names.push_back(ASCIIToUTF16("Marion M. Morrison")); | |
571 b.SetRawMultiInfo(NAME_FULL, names); | |
572 | |
573 a.OverwriteWithOrAddTo(b, "en-US"); | |
574 EXPECT_EQ("Chrome settings", a.origin()); | |
575 EXPECT_EQ(ASCIIToUTF16("area 51"), a.GetRawInfo(ADDRESS_HOME_LINE2)); | |
576 EXPECT_EQ(ASCIIToUTF16("Fox"), a.GetRawInfo(COMPANY_NAME)); | |
577 a.GetRawMultiInfo(NAME_FULL, &names); | |
578 ASSERT_EQ(3U, names.size()); | |
579 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison"), names[0]); | |
580 EXPECT_EQ(ASCIIToUTF16("Marion Morrison"), names[1]); | |
581 EXPECT_EQ(ASCIIToUTF16("Marion M. Morrison"), names[2]); | |
582 } | |
583 | |
584 TEST(AutofillProfileTest, AssignmentOperator) { | |
585 AutofillProfile a(base::GenerateGUID(), "https://www.example.com/"); | |
586 test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", | |
587 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", | |
588 "Hollywood", "CA", "91601", "US", | |
589 "12345678910"); | |
590 | |
591 // Result of assignment should be logically equal to the original profile. | |
592 AutofillProfile b(base::GenerateGUID(), "http://www.example.com/"); | |
593 b = a; | |
594 EXPECT_TRUE(a == b); | |
595 | |
596 // Assignment to self should not change the profile value. | |
597 a = a; | |
598 EXPECT_TRUE(a == b); | |
599 } | |
600 | |
601 TEST(AutofillProfileTest, Copy) { | |
602 AutofillProfile a(base::GenerateGUID(), "https://www.example.com/"); | |
603 test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", | |
604 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", | |
605 "Hollywood", "CA", "91601", "US", | |
606 "12345678910"); | |
607 | |
608 // Clone should be logically equal to the original. | |
609 AutofillProfile b(a); | |
610 EXPECT_TRUE(a == b); | |
611 } | |
612 | |
613 TEST(AutofillProfileTest, Compare) { | |
614 AutofillProfile a(base::GenerateGUID(), std::string()); | |
615 AutofillProfile b(base::GenerateGUID(), std::string()); | |
616 | |
617 // Empty profiles are the same. | |
618 EXPECT_EQ(0, a.Compare(b)); | |
619 | |
620 // GUIDs don't count. | |
621 a.set_guid(base::GenerateGUID()); | |
622 b.set_guid(base::GenerateGUID()); | |
623 EXPECT_EQ(0, a.Compare(b)); | |
624 | |
625 // Origins don't count. | |
626 a.set_origin("apple"); | |
627 b.set_origin("banana"); | |
628 EXPECT_EQ(0, a.Compare(b)); | |
629 | |
630 // Different values produce non-zero results. | |
631 test::SetProfileInfo(&a, "Jimmy", NULL, NULL, NULL, | |
632 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
633 test::SetProfileInfo(&b, "Ringo", NULL, NULL, NULL, | |
634 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | |
635 EXPECT_GT(0, a.Compare(b)); | |
636 EXPECT_LT(0, b.Compare(a)); | |
637 | |
638 // Phone numbers are compared by the full number, including the area code. | |
639 // This is a regression test for http://crbug.com/163024 | |
640 test::SetProfileInfo(&a, NULL, NULL, NULL, NULL, | |
641 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "650.555.4321"); | |
642 test::SetProfileInfo(&b, NULL, NULL, NULL, NULL, | |
643 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321"); | |
644 EXPECT_GT(0, a.Compare(b)); | |
645 EXPECT_LT(0, b.Compare(a)); | |
646 } | |
647 | |
648 TEST(AutofillProfileTest, MultiValueNames) { | |
649 AutofillProfile p(base::GenerateGUID(), "https://www.example.com/"); | |
650 const base::string16 kJohnDoe(ASCIIToUTF16("John Doe")); | |
651 const base::string16 kJohnPDoe(ASCIIToUTF16("John P. Doe")); | |
652 std::vector<base::string16> set_values; | |
653 set_values.push_back(kJohnDoe); | |
654 set_values.push_back(kJohnPDoe); | |
655 p.SetRawMultiInfo(NAME_FULL, set_values); | |
656 | |
657 // Expect regular |GetInfo| returns the first element. | |
658 EXPECT_EQ(kJohnDoe, p.GetRawInfo(NAME_FULL)); | |
659 | |
660 // Ensure that we get out what we put in. | |
661 std::vector<base::string16> get_values; | |
662 p.GetRawMultiInfo(NAME_FULL, &get_values); | |
663 ASSERT_EQ(2UL, get_values.size()); | |
664 EXPECT_EQ(kJohnDoe, get_values[0]); | |
665 EXPECT_EQ(kJohnPDoe, get_values[1]); | |
666 | |
667 // Update the values. | |
668 AutofillProfile p2 = p; | |
669 EXPECT_EQ(0, p.Compare(p2)); | |
670 const base::string16 kNoOne(ASCIIToUTF16("No One")); | |
671 set_values[1] = kNoOne; | |
672 p.SetRawMultiInfo(NAME_FULL, set_values); | |
673 p.GetRawMultiInfo(NAME_FULL, &get_values); | |
674 ASSERT_EQ(2UL, get_values.size()); | |
675 EXPECT_EQ(kJohnDoe, get_values[0]); | |
676 EXPECT_EQ(kNoOne, get_values[1]); | |
677 EXPECT_NE(0, p.Compare(p2)); | |
678 | |
679 // Delete values. | |
680 set_values.clear(); | |
681 p.SetRawMultiInfo(NAME_FULL, set_values); | |
682 p.GetRawMultiInfo(NAME_FULL, &get_values); | |
683 ASSERT_EQ(1UL, get_values.size()); | |
684 EXPECT_EQ(base::string16(), get_values[0]); | |
685 | |
686 // Expect regular |GetInfo| returns empty value. | |
687 EXPECT_EQ(base::string16(), p.GetRawInfo(NAME_FULL)); | |
688 } | |
689 | |
690 TEST(AutofillProfileTest, MultiValueEmails) { | |
691 AutofillProfile p(base::GenerateGUID(), "https://www.example.com/"); | |
692 const base::string16 kJohnDoe(ASCIIToUTF16("john@doe.com")); | |
693 const base::string16 kJohnPDoe(ASCIIToUTF16("john_p@doe.com")); | |
694 std::vector<base::string16> set_values; | |
695 set_values.push_back(kJohnDoe); | |
696 set_values.push_back(kJohnPDoe); | |
697 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); | |
698 | |
699 // Expect regular |GetInfo| returns the first element. | |
700 EXPECT_EQ(kJohnDoe, p.GetRawInfo(EMAIL_ADDRESS)); | |
701 | |
702 // Ensure that we get out what we put in. | |
703 std::vector<base::string16> get_values; | |
704 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values); | |
705 ASSERT_EQ(2UL, get_values.size()); | |
706 EXPECT_EQ(kJohnDoe, get_values[0]); | |
707 EXPECT_EQ(kJohnPDoe, get_values[1]); | |
708 | |
709 // Update the values. | |
710 AutofillProfile p2 = p; | |
711 EXPECT_EQ(0, p.Compare(p2)); | |
712 const base::string16 kNoOne(ASCIIToUTF16("no@one.com")); | |
713 set_values[1] = kNoOne; | |
714 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); | |
715 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values); | |
716 ASSERT_EQ(2UL, get_values.size()); | |
717 EXPECT_EQ(kJohnDoe, get_values[0]); | |
718 EXPECT_EQ(kNoOne, get_values[1]); | |
719 EXPECT_NE(0, p.Compare(p2)); | |
720 | |
721 // Delete values. | |
722 set_values.clear(); | |
723 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); | |
724 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values); | |
725 ASSERT_EQ(1UL, get_values.size()); | |
726 EXPECT_EQ(base::string16(), get_values[0]); | |
727 | |
728 // Expect regular |GetInfo| returns empty value. | |
729 EXPECT_EQ(base::string16(), p.GetRawInfo(EMAIL_ADDRESS)); | |
730 } | |
731 | |
732 TEST(AutofillProfileTest, MultiValuePhone) { | |
733 AutofillProfile p(base::GenerateGUID(), "https://www.example.com/"); | |
734 const base::string16 kJohnDoe(ASCIIToUTF16("4151112222")); | |
735 const base::string16 kJohnPDoe(ASCIIToUTF16("4151113333")); | |
736 std::vector<base::string16> set_values; | |
737 set_values.push_back(kJohnDoe); | |
738 set_values.push_back(kJohnPDoe); | |
739 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); | |
740 | |
741 // Expect regular |GetInfo| returns the first element. | |
742 EXPECT_EQ(kJohnDoe, p.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); | |
743 | |
744 // Ensure that we get out what we put in. | |
745 std::vector<base::string16> get_values; | |
746 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); | |
747 ASSERT_EQ(2UL, get_values.size()); | |
748 EXPECT_EQ(kJohnDoe, get_values[0]); | |
749 EXPECT_EQ(kJohnPDoe, get_values[1]); | |
750 | |
751 // Update the values. | |
752 AutofillProfile p2 = p; | |
753 EXPECT_EQ(0, p.Compare(p2)); | |
754 const base::string16 kNoOne(ASCIIToUTF16("4152110000")); | |
755 set_values[1] = kNoOne; | |
756 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); | |
757 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); | |
758 ASSERT_EQ(2UL, get_values.size()); | |
759 EXPECT_EQ(kJohnDoe, get_values[0]); | |
760 EXPECT_EQ(kNoOne, get_values[1]); | |
761 EXPECT_NE(0, p.Compare(p2)); | |
762 | |
763 // Delete values. | |
764 set_values.clear(); | |
765 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); | |
766 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); | |
767 ASSERT_EQ(1UL, get_values.size()); | |
768 EXPECT_EQ(base::string16(), get_values[0]); | |
769 | |
770 // Expect regular |GetInfo| returns empty value. | |
771 EXPECT_EQ(base::string16(), p.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); | |
772 } | |
773 | |
774 TEST(AutofillProfileTest, AddressCountryFull) { | |
775 const char* const kCountries[] = { | |
776 "Albania", "Canada" | |
777 }; | |
778 std::vector<base::string16> options(arraysize(kCountries)); | |
779 for (size_t i = 0; i < arraysize(kCountries); ++i) { | |
780 options[i] = ASCIIToUTF16(kCountries[i]); | |
781 } | |
782 | |
783 FormFieldData field; | |
784 field.form_control_type = "select-one"; | |
785 field.option_values = options; | |
786 field.option_contents = options; | |
787 | |
788 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); | |
789 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA")); | |
790 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field); | |
791 EXPECT_EQ(ASCIIToUTF16("Canada"), field.value); | |
792 } | |
793 | |
794 TEST(AutofillProfileTest, AddressCountryAbbrev) { | |
795 const char* const kCountries[] = { | |
796 "AL", "CA" | |
797 }; | |
798 std::vector<base::string16> options(arraysize(kCountries)); | |
799 for (size_t i = 0; i < arraysize(kCountries); ++i) { | |
800 options[i] = ASCIIToUTF16(kCountries[i]); | |
801 } | |
802 | |
803 FormFieldData field; | |
804 field.form_control_type = "select-one"; | |
805 field.option_values = options; | |
806 field.option_contents = options; | |
807 | |
808 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); | |
809 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA")); | |
810 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field); | |
811 EXPECT_EQ(ASCIIToUTF16("CA"), field.value); | |
812 } | |
813 | |
814 TEST(AutofillProfileTest, AddressStateFull) { | |
815 const char* const kStates[] = { | |
816 "Alabama", "California" | |
817 }; | |
818 std::vector<base::string16> options(arraysize(kStates)); | |
819 for (size_t i = 0; i < arraysize(kStates); ++i) { | |
820 options[i] = ASCIIToUTF16(kStates[i]); | |
821 } | |
822 | |
823 FormFieldData field; | |
824 field.form_control_type = "select-one"; | |
825 field.option_values = options; | |
826 field.option_contents = options; | |
827 | |
828 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); | |
829 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); | |
830 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); | |
831 EXPECT_EQ(ASCIIToUTF16("California"), field.value); | |
832 } | |
833 | |
834 TEST(AutofillProfileTest, AddressStateAbbrev) { | |
835 const char* const kStates[] = { | |
836 "AL", "CA" | |
837 }; | |
838 std::vector<base::string16> options(arraysize(kStates)); | |
839 for (size_t i = 0; i < arraysize(kStates); ++i) { | |
840 options[i] = ASCIIToUTF16(kStates[i]); | |
841 } | |
842 | |
843 FormFieldData field; | |
844 field.form_control_type = "select-one"; | |
845 field.option_values = options; | |
846 field.option_contents = options; | |
847 | |
848 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); | |
849 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); | |
850 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); | |
851 EXPECT_EQ(ASCIIToUTF16("CA"), field.value); | |
852 } | |
853 | |
854 TEST(AutofillProfileTest, FillByValue) { | |
855 const char* const kStates[] = { | |
856 "Alabama", "California" | |
857 }; | |
858 std::vector<base::string16> values(arraysize(kStates)); | |
859 std::vector<base::string16> contents(arraysize(kStates)); | |
860 for (unsigned int i = 0; i < arraysize(kStates); ++i) { | |
861 values[i] = ASCIIToUTF16(kStates[i]); | |
862 contents[i] = ASCIIToUTF16(base::StringPrintf("%u", i)); | |
863 } | |
864 | |
865 FormFieldData field; | |
866 field.form_control_type = "select-one"; | |
867 field.option_values = values; | |
868 field.option_contents = contents; | |
869 | |
870 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); | |
871 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); | |
872 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); | |
873 EXPECT_EQ(ASCIIToUTF16("California"), field.value); | |
874 } | |
875 | |
876 TEST(AutofillProfileTest, FillByContents) { | |
877 const char* const kStates[] = { | |
878 "Alabama", "California" | |
879 }; | |
880 std::vector<base::string16> values(arraysize(kStates)); | |
881 std::vector<base::string16> contents(arraysize(kStates)); | |
882 for (unsigned int i = 0; i < arraysize(kStates); ++i) { | |
883 values[i] = ASCIIToUTF16(base::StringPrintf("%u", i + 1)); | |
884 contents[i] = ASCIIToUTF16(kStates[i]); | |
885 } | |
886 | |
887 FormFieldData field; | |
888 field.form_control_type = "select-one"; | |
889 field.option_values = values; | |
890 field.option_contents = contents; | |
891 | |
892 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); | |
893 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); | |
894 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); | |
895 EXPECT_EQ(ASCIIToUTF16("2"), field.value); | |
896 } | |
897 | |
898 } // namespace autofill | |
OLD | NEW |