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

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

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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) 2012 The Chromium Authors. All rights reserved. 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 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/guid.h" 6 #include "base/guid.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 15 matching lines...) Expand all
26 26
27 } // namespace 27 } // namespace
28 28
29 // Tests different possibilities for summary string generation. 29 // Tests different possibilities for summary string generation.
30 // Based on existence of first name, last name, and address line 1. 30 // Based on existence of first name, last name, and address line 1.
31 TEST(AutofillProfileTest, PreviewSummaryString) { 31 TEST(AutofillProfileTest, PreviewSummaryString) {
32 // Case 0/null: "" 32 // Case 0/null: ""
33 AutofillProfile profile0; 33 AutofillProfile profile0;
34 // Empty profile - nothing to update. 34 // Empty profile - nothing to update.
35 EXPECT_FALSE(UpdateProfileLabel(&profile0)); 35 EXPECT_FALSE(UpdateProfileLabel(&profile0));
36 string16 summary0 = profile0.Label(); 36 base::string16 summary0 = profile0.Label();
37 EXPECT_EQ(string16(), summary0); 37 EXPECT_EQ(base::string16(), summary0);
38 38
39 // Case 0a/empty name and address, so the first two fields of the rest of the 39 // Case 0a/empty name and address, so the first two fields of the rest of the
40 // data is used: "Hollywood, CA" 40 // data is used: "Hollywood, CA"
41 AutofillProfile profile00; 41 AutofillProfile profile00;
42 autofill_test::SetProfileInfo(&profile00, "", "", "", 42 autofill_test::SetProfileInfo(&profile00, "", "", "",
43 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", 43 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US",
44 "16505678910"); 44 "16505678910");
45 EXPECT_TRUE(UpdateProfileLabel(&profile00)); 45 EXPECT_TRUE(UpdateProfileLabel(&profile00));
46 string16 summary00 = profile00.Label(); 46 base::string16 summary00 = profile00.Label();
47 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00); 47 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00);
48 48
49 // Case 1: "<address>" without line 2. 49 // Case 1: "<address>" without line 2.
50 AutofillProfile profile1; 50 AutofillProfile profile1;
51 autofill_test::SetProfileInfo(&profile1, "", "", "", 51 autofill_test::SetProfileInfo(&profile1, "", "", "",
52 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", "Hollywood", "CA", 52 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", "Hollywood", "CA",
53 "91601", "US", "16505678910"); 53 "91601", "US", "16505678910");
54 EXPECT_TRUE(UpdateProfileLabel(&profile1)); 54 EXPECT_TRUE(UpdateProfileLabel(&profile1));
55 string16 summary1 = profile1.Label(); 55 base::string16 summary1 = profile1.Label();
56 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1); 56 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1);
57 57
58 // Case 1a: "<address>" with line 2. 58 // Case 1a: "<address>" with line 2.
59 AutofillProfile profile1a; 59 AutofillProfile profile1a;
60 autofill_test::SetProfileInfo(&profile1a, "", "", "", 60 autofill_test::SetProfileInfo(&profile1a, "", "", "",
61 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 61 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
62 "91601", "US", "16505678910"); 62 "91601", "US", "16505678910");
63 EXPECT_TRUE(UpdateProfileLabel(&profile1a)); 63 EXPECT_TRUE(UpdateProfileLabel(&profile1a));
64 string16 summary1a = profile1a.Label(); 64 base::string16 summary1a = profile1a.Label();
65 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., unit 5"), summary1a); 65 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., unit 5"), summary1a);
66 66
67 // Case 2: "<lastname>" 67 // Case 2: "<lastname>"
68 AutofillProfile profile2; 68 AutofillProfile profile2;
69 autofill_test::SetProfileInfo(&profile2, "", "Mitchell", 69 autofill_test::SetProfileInfo(&profile2, "", "Mitchell",
70 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", 70 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA",
71 "91601", "US", "16505678910"); 71 "91601", "US", "16505678910");
72 EXPECT_TRUE(UpdateProfileLabel(&profile2)); 72 EXPECT_TRUE(UpdateProfileLabel(&profile2));
73 string16 summary2 = profile2.Label(); 73 base::string16 summary2 = profile2.Label();
74 // Summary includes full name, to the maximal extent available. 74 // Summary includes full name, to the maximal extent available.
75 EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, Hollywood"), summary2); 75 EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, Hollywood"), summary2);
76 76
77 // Case 3: "<lastname>, <address>" 77 // Case 3: "<lastname>, <address>"
78 AutofillProfile profile3; 78 AutofillProfile profile3;
79 autofill_test::SetProfileInfo(&profile3, "", "Mitchell", 79 autofill_test::SetProfileInfo(&profile3, "", "Mitchell",
80 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", 80 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "",
81 "Hollywood", "CA", "91601", "US", "16505678910"); 81 "Hollywood", "CA", "91601", "US", "16505678910");
82 EXPECT_TRUE(UpdateProfileLabel(&profile3)); 82 EXPECT_TRUE(UpdateProfileLabel(&profile3));
83 string16 summary3 = profile3.Label(); 83 base::string16 summary3 = profile3.Label();
84 EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, 123 Zoo St."), summary3); 84 EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, 123 Zoo St."), summary3);
85 85
86 // Case 4: "<firstname>" 86 // Case 4: "<firstname>"
87 AutofillProfile profile4; 87 AutofillProfile profile4;
88 autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", 88 autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "",
89 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", 89 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US",
90 "16505678910"); 90 "16505678910");
91 EXPECT_TRUE(UpdateProfileLabel(&profile4)); 91 EXPECT_TRUE(UpdateProfileLabel(&profile4));
92 string16 summary4 = profile4.Label(); 92 base::string16 summary4 = profile4.Label();
93 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4); 93 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4);
94 94
95 // Case 5: "<firstname>, <address>" 95 // Case 5: "<firstname>, <address>"
96 AutofillProfile profile5; 96 AutofillProfile profile5;
97 autofill_test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", 97 autofill_test::SetProfileInfo(&profile5, "Marion", "Mitchell", "",
98 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 98 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
99 "91601", "US", "16505678910"); 99 "91601", "US", "16505678910");
100 EXPECT_TRUE(UpdateProfileLabel(&profile5)); 100 EXPECT_TRUE(UpdateProfileLabel(&profile5));
101 string16 summary5 = profile5.Label(); 101 base::string16 summary5 = profile5.Label();
102 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, 123 Zoo St."), summary5); 102 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, 123 Zoo St."), summary5);
103 103
104 // Case 6: "<firstname> <lastname>" 104 // Case 6: "<firstname> <lastname>"
105 AutofillProfile profile6; 105 AutofillProfile profile6;
106 autofill_test::SetProfileInfo(&profile6, "Marion", "Mitchell", 106 autofill_test::SetProfileInfo(&profile6, "Marion", "Mitchell",
107 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", 107 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA",
108 "91601", "US", "16505678910"); 108 "91601", "US", "16505678910");
109 EXPECT_TRUE(UpdateProfileLabel(&profile6)); 109 EXPECT_TRUE(UpdateProfileLabel(&profile6));
110 string16 summary6 = profile6.Label(); 110 base::string16 summary6 = profile6.Label();
111 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, Hollywood"), 111 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, Hollywood"),
112 summary6); 112 summary6);
113 113
114 // Case 7: "<firstname> <lastname>, <address>" 114 // Case 7: "<firstname> <lastname>, <address>"
115 AutofillProfile profile7; 115 AutofillProfile profile7;
116 autofill_test::SetProfileInfo(&profile7, "Marion", "Mitchell", 116 autofill_test::SetProfileInfo(&profile7, "Marion", "Mitchell",
117 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", 117 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5",
118 "Hollywood", "CA", "91601", "US", "16505678910"); 118 "Hollywood", "CA", "91601", "US", "16505678910");
119 EXPECT_TRUE(UpdateProfileLabel(&profile7)); 119 EXPECT_TRUE(UpdateProfileLabel(&profile7));
120 string16 summary7 = profile7.Label(); 120 base::string16 summary7 = profile7.Label();
121 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St."), 121 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St."),
122 summary7); 122 summary7);
123 123
124 // Case 7a: "<firstname> <lastname>, <address>" - same as #7, except for 124 // Case 7a: "<firstname> <lastname>, <address>" - same as #7, except for
125 // e-mail. 125 // e-mail.
126 AutofillProfile profile7a; 126 AutofillProfile profile7a;
127 autofill_test::SetProfileInfo(&profile7a, "Marion", "Mitchell", 127 autofill_test::SetProfileInfo(&profile7a, "Marion", "Mitchell",
128 "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", 128 "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
129 "Hollywood", "CA", "91601", "US", "16505678910"); 129 "Hollywood", "CA", "91601", "US", "16505678910");
130 std::vector<AutofillProfile*> profiles; 130 std::vector<AutofillProfile*> profiles;
131 profiles.push_back(&profile7); 131 profiles.push_back(&profile7);
132 profiles.push_back(&profile7a); 132 profiles.push_back(&profile7a);
133 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles)); 133 EXPECT_TRUE(AutofillProfile::AdjustInferredLabels(&profiles));
134 summary7 = profile7.Label(); 134 summary7 = profile7.Label();
135 string16 summary7a = profile7a.Label(); 135 base::string16 summary7a = profile7a.Label();
136 EXPECT_EQ(ASCIIToUTF16( 136 EXPECT_EQ(ASCIIToUTF16(
137 "Marion Mitchell Morrison, 123 Zoo St., johnwayne@me.xyz"), summary7); 137 "Marion Mitchell Morrison, 123 Zoo St., johnwayne@me.xyz"), summary7);
138 EXPECT_EQ(ASCIIToUTF16( 138 EXPECT_EQ(ASCIIToUTF16(
139 "Marion Mitchell Morrison, 123 Zoo St., marion@me.xyz"), summary7a); 139 "Marion Mitchell Morrison, 123 Zoo St., marion@me.xyz"), summary7a);
140 } 140 }
141 141
142 TEST(AutofillProfileTest, AdjustInferredLabels) { 142 TEST(AutofillProfileTest, AdjustInferredLabels) {
143 std::vector<AutofillProfile*> profiles; 143 std::vector<AutofillProfile*> profiles;
144 profiles.push_back(new AutofillProfile); 144 profiles.push_back(new AutofillProfile);
145 autofill_test::SetProfileInfo( 145 autofill_test::SetProfileInfo(
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 "", 317 "",
318 "Doe", 318 "Doe",
319 "janedoe@tertium.com", 319 "janedoe@tertium.com",
320 "Pluto Inc.", 320 "Pluto Inc.",
321 "123 Letha Shore.", 321 "123 Letha Shore.",
322 "", 322 "",
323 "Dis", "CA", 323 "Dis", "CA",
324 "91222", 324 "91222",
325 "US", 325 "US",
326 "12345678910"); 326 "12345678910");
327 std::vector<string16> labels; 327 std::vector<base::string16> labels;
328 // Two fields at least - no filter. 328 // Two fields at least - no filter.
329 AutofillProfile::CreateInferredLabels(&profiles, NULL, UNKNOWN_TYPE, 2, 329 AutofillProfile::CreateInferredLabels(&profiles, NULL, UNKNOWN_TYPE, 2,
330 &labels); 330 &labels);
331 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St."), labels[0]); 331 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St."), labels[0]);
332 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]); 332 EXPECT_EQ(ASCIIToUTF16("Jane Doe, 123 Letha Shore."), labels[1]);
333 333
334 // Three fields at least - no filter. 334 // Three fields at least - no filter.
335 AutofillProfile::CreateInferredLabels(&profiles, NULL, UNKNOWN_TYPE, 3, 335 AutofillProfile::CreateInferredLabels(&profiles, NULL, UNKNOWN_TYPE, 3,
336 &labels); 336 &labels);
337 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., Elysium"), 337 EXPECT_EQ(ASCIIToUTF16("John Doe, 666 Erebus St., Elysium"),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // One field at least, from suggested fields - no filter. 369 // One field at least, from suggested fields - no filter.
370 AutofillProfile::CreateInferredLabels(&profiles, &suggested_fields, 370 AutofillProfile::CreateInferredLabels(&profiles, &suggested_fields,
371 UNKNOWN_TYPE, 1, &labels); 371 UNKNOWN_TYPE, 1, &labels);
372 EXPECT_EQ(ASCIIToUTF16("John Doe"), labels[0]); 372 EXPECT_EQ(ASCIIToUTF16("John Doe"), labels[0]);
373 EXPECT_EQ(ASCIIToUTF16("Jane Doe"), labels[1]); 373 EXPECT_EQ(ASCIIToUTF16("Jane Doe"), labels[1]);
374 374
375 // One field at least, from suggested fields - filter the same as suggested 375 // One field at least, from suggested fields - filter the same as suggested
376 // field. 376 // field.
377 AutofillProfile::CreateInferredLabels(&profiles, &suggested_fields, 377 AutofillProfile::CreateInferredLabels(&profiles, &suggested_fields,
378 NAME_MIDDLE, 1, &labels); 378 NAME_MIDDLE, 1, &labels);
379 EXPECT_EQ(string16(), labels[0]); 379 EXPECT_EQ(base::string16(), labels[0]);
380 EXPECT_EQ(string16(), labels[1]); 380 EXPECT_EQ(base::string16(), labels[1]);
381 381
382 suggested_fields.clear(); 382 suggested_fields.clear();
383 // In our implementation we always display NAME_FULL for NAME_MIDDLE_INITIAL 383 // In our implementation we always display NAME_FULL for NAME_MIDDLE_INITIAL
384 suggested_fields.push_back(NAME_MIDDLE_INITIAL); 384 suggested_fields.push_back(NAME_MIDDLE_INITIAL);
385 // One field at least, from suggested fields - no filter. 385 // One field at least, from suggested fields - no filter.
386 AutofillProfile::CreateInferredLabels(&profiles, &suggested_fields, 386 AutofillProfile::CreateInferredLabels(&profiles, &suggested_fields,
387 UNKNOWN_TYPE, 1, &labels); 387 UNKNOWN_TYPE, 1, &labels);
388 EXPECT_EQ(ASCIIToUTF16("John Doe"), labels[0]); 388 EXPECT_EQ(ASCIIToUTF16("John Doe"), labels[0]);
389 EXPECT_EQ(ASCIIToUTF16("Jane Doe"), labels[1]); 389 EXPECT_EQ(ASCIIToUTF16("Jane Doe"), labels[1]);
390 390
391 // One field at least, from suggested fields - filter same as the first non- 391 // One field at least, from suggested fields - filter same as the first non-
392 // unknown suggested field. 392 // unknown suggested field.
393 suggested_fields.clear(); 393 suggested_fields.clear();
394 suggested_fields.push_back(UNKNOWN_TYPE); 394 suggested_fields.push_back(UNKNOWN_TYPE);
395 suggested_fields.push_back(NAME_FULL); 395 suggested_fields.push_back(NAME_FULL);
396 suggested_fields.push_back(ADDRESS_HOME_LINE1); 396 suggested_fields.push_back(ADDRESS_HOME_LINE1);
397 AutofillProfile::CreateInferredLabels(&profiles, &suggested_fields, NAME_FULL, 397 AutofillProfile::CreateInferredLabels(&profiles, &suggested_fields, NAME_FULL,
398 1, &labels); 398 1, &labels);
399 EXPECT_EQ(string16(ASCIIToUTF16("666 Erebus St.")), labels[0]); 399 EXPECT_EQ(base::string16(ASCIIToUTF16("666 Erebus St.")), labels[0]);
400 EXPECT_EQ(string16(ASCIIToUTF16("123 Letha Shore.")), labels[1]); 400 EXPECT_EQ(base::string16(ASCIIToUTF16("123 Letha Shore.")), labels[1]);
401 401
402 // Clean up. 402 // Clean up.
403 STLDeleteContainerPointers(profiles.begin(), profiles.end()); 403 STLDeleteContainerPointers(profiles.begin(), profiles.end());
404 } 404 }
405 405
406 // Test that we fall back to using the full name if there are no other 406 // Test that we fall back to using the full name if there are no other
407 // distinguishing fields, but only if it makes sense given the suggested fields. 407 // distinguishing fields, but only if it makes sense given the suggested fields.
408 TEST(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) { 408 TEST(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) {
409 ScopedVector<AutofillProfile> profiles; 409 ScopedVector<AutofillProfile> profiles;
410 profiles.push_back(new AutofillProfile); 410 profiles.push_back(new AutofillProfile);
411 autofill_test::SetProfileInfo(profiles[0], 411 autofill_test::SetProfileInfo(profiles[0],
412 "John", "", "Doe", "doe@example.com", "", 412 "John", "", "Doe", "doe@example.com", "",
413 "88 Nowhere Ave.", "", "", "", "", "", ""); 413 "88 Nowhere Ave.", "", "", "", "", "", "");
414 profiles.push_back(new AutofillProfile); 414 profiles.push_back(new AutofillProfile);
415 autofill_test::SetProfileInfo(profiles[1], 415 autofill_test::SetProfileInfo(profiles[1],
416 "Johnny", "K", "Doe", "doe@example.com", "", 416 "Johnny", "K", "Doe", "doe@example.com", "",
417 "88 Nowhere Ave.", "", "", "", "", "", ""); 417 "88 Nowhere Ave.", "", "", "", "", "", "");
418 418
419 // If the only name field in the suggested fields is the excluded field, we 419 // If the only name field in the suggested fields is the excluded field, we
420 // should not fall back to the full name as a distinguishing field. 420 // should not fall back to the full name as a distinguishing field.
421 std::vector<AutofillFieldType> suggested_fields; 421 std::vector<AutofillFieldType> suggested_fields;
422 suggested_fields.push_back(NAME_LAST); 422 suggested_fields.push_back(NAME_LAST);
423 suggested_fields.push_back(ADDRESS_HOME_LINE1); 423 suggested_fields.push_back(ADDRESS_HOME_LINE1);
424 suggested_fields.push_back(EMAIL_ADDRESS); 424 suggested_fields.push_back(EMAIL_ADDRESS);
425 std::vector<string16> labels; 425 std::vector<base::string16> labels;
426 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, 426 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields,
427 NAME_LAST, 1, &labels); 427 NAME_LAST, 1, &labels);
428 ASSERT_EQ(2U, labels.size()); 428 ASSERT_EQ(2U, labels.size());
429 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave."), labels[0]); 429 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave."), labels[0]);
430 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave."), labels[1]); 430 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave."), labels[1]);
431 431
432 // Otherwise, we should. 432 // Otherwise, we should.
433 suggested_fields.push_back(NAME_FIRST); 433 suggested_fields.push_back(NAME_FIRST);
434 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, 434 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields,
435 NAME_LAST, 1, &labels); 435 NAME_LAST, 1, &labels);
(...skipping 13 matching lines...) Expand all
449 autofill_test::SetProfileInfo(profiles[1], 449 autofill_test::SetProfileInfo(profiles[1],
450 "John", "", "Doe", "dojo@example.com", "", 450 "John", "", "Doe", "dojo@example.com", "",
451 "88 Nowhere Ave.", "", "", "", "", "", ""); 451 "88 Nowhere Ave.", "", "", "", "", "", "");
452 452
453 // If the only name field in the suggested fields is the excluded field, we 453 // If the only name field in the suggested fields is the excluded field, we
454 // should not fall back to the full name as a distinguishing field. 454 // should not fall back to the full name as a distinguishing field.
455 std::vector<AutofillFieldType> suggested_fields; 455 std::vector<AutofillFieldType> suggested_fields;
456 suggested_fields.push_back(ADDRESS_HOME_LINE1); 456 suggested_fields.push_back(ADDRESS_HOME_LINE1);
457 suggested_fields.push_back(ADDRESS_BILLING_LINE1); 457 suggested_fields.push_back(ADDRESS_BILLING_LINE1);
458 suggested_fields.push_back(EMAIL_ADDRESS); 458 suggested_fields.push_back(EMAIL_ADDRESS);
459 std::vector<string16> labels; 459 std::vector<base::string16> labels;
460 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields, 460 AutofillProfile::CreateInferredLabels(&profiles.get(), &suggested_fields,
461 UNKNOWN_TYPE, 2, &labels); 461 UNKNOWN_TYPE, 2, &labels);
462 ASSERT_EQ(2U, labels.size()); 462 ASSERT_EQ(2U, labels.size());
463 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., doe@example.com"), labels[0]); 463 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., doe@example.com"), labels[0]);
464 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., dojo@example.com"), labels[1]); 464 EXPECT_EQ(ASCIIToUTF16("88 Nowhere Ave., dojo@example.com"), labels[1]);
465 } 465 }
466 466
467 // Make sure that empty fields are not treated as distinguishing fields. 467 // Make sure that empty fields are not treated as distinguishing fields.
468 TEST(AutofillProfileTest, CreateInferredLabelsSkipsEmptyFields) { 468 TEST(AutofillProfileTest, CreateInferredLabelsSkipsEmptyFields) {
469 ScopedVector<AutofillProfile> profiles; 469 ScopedVector<AutofillProfile> profiles;
470 profiles.push_back(new AutofillProfile); 470 profiles.push_back(new AutofillProfile);
471 autofill_test::SetProfileInfo(profiles[0], 471 autofill_test::SetProfileInfo(profiles[0],
472 "John", "", "Doe", "doe@example.com", 472 "John", "", "Doe", "doe@example.com",
473 "Gogole", "", "", "", "", "", "", ""); 473 "Gogole", "", "", "", "", "", "", "");
474 profiles.push_back(new AutofillProfile); 474 profiles.push_back(new AutofillProfile);
475 autofill_test::SetProfileInfo(profiles[1], 475 autofill_test::SetProfileInfo(profiles[1],
476 "John", "", "Doe", "doe@example.com", 476 "John", "", "Doe", "doe@example.com",
477 "Ggoole", "", "", "", "", "", "", ""); 477 "Ggoole", "", "", "", "", "", "", "");
478 profiles.push_back(new AutofillProfile); 478 profiles.push_back(new AutofillProfile);
479 autofill_test::SetProfileInfo(profiles[2], 479 autofill_test::SetProfileInfo(profiles[2],
480 "John", "", "Doe", "john.doe@example.com", 480 "John", "", "Doe", "john.doe@example.com",
481 "Goolge", "", "", "", "", "", "", ""); 481 "Goolge", "", "", "", "", "", "", "");
482 482
483 std::vector<string16> labels; 483 std::vector<base::string16> labels;
484 AutofillProfile::CreateInferredLabels(&profiles.get(), NULL, UNKNOWN_TYPE, 3, 484 AutofillProfile::CreateInferredLabels(&profiles.get(), NULL, UNKNOWN_TYPE, 3,
485 &labels); 485 &labels);
486 ASSERT_EQ(3U, labels.size()); 486 ASSERT_EQ(3U, labels.size());
487 EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]); 487 EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]);
488 EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Ggoole"), labels[1]); 488 EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Ggoole"), labels[1]);
489 EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com, Goolge"), labels[2]); 489 EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com, Goolge"), labels[2]);
490 490
491 // A field must have a non-empty value for each profile to be considered a 491 // A field must have a non-empty value for each profile to be considered a
492 // distinguishing field. 492 // distinguishing field.
493 profiles[1]->SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("88 Nowhere Ave.")); 493 profiles[1]->SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("88 Nowhere Ave."));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 autofill_test::SetProfileInfo(&a, NULL, NULL, NULL, NULL, 584 autofill_test::SetProfileInfo(&a, NULL, NULL, NULL, NULL,
585 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "650.555.4321"); 585 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "650.555.4321");
586 autofill_test::SetProfileInfo(&b, NULL, NULL, NULL, NULL, 586 autofill_test::SetProfileInfo(&b, NULL, NULL, NULL, NULL,
587 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321"); 587 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321");
588 EXPECT_GT(0, a.Compare(b)); 588 EXPECT_GT(0, a.Compare(b));
589 EXPECT_LT(0, b.Compare(a)); 589 EXPECT_LT(0, b.Compare(a));
590 } 590 }
591 591
592 TEST(AutofillProfileTest, MultiValueNames) { 592 TEST(AutofillProfileTest, MultiValueNames) {
593 AutofillProfile p; 593 AutofillProfile p;
594 const string16 kJohnDoe(ASCIIToUTF16("John Doe")); 594 const base::string16 kJohnDoe(ASCIIToUTF16("John Doe"));
595 const string16 kJohnPDoe(ASCIIToUTF16("John P. Doe")); 595 const base::string16 kJohnPDoe(ASCIIToUTF16("John P. Doe"));
596 std::vector<string16> set_values; 596 std::vector<base::string16> set_values;
597 set_values.push_back(kJohnDoe); 597 set_values.push_back(kJohnDoe);
598 set_values.push_back(kJohnPDoe); 598 set_values.push_back(kJohnPDoe);
599 p.SetRawMultiInfo(NAME_FULL, set_values); 599 p.SetRawMultiInfo(NAME_FULL, set_values);
600 600
601 // Expect regular |GetInfo| returns the first element. 601 // Expect regular |GetInfo| returns the first element.
602 EXPECT_EQ(kJohnDoe, p.GetRawInfo(NAME_FULL)); 602 EXPECT_EQ(kJohnDoe, p.GetRawInfo(NAME_FULL));
603 603
604 // Ensure that we get out what we put in. 604 // Ensure that we get out what we put in.
605 std::vector<string16> get_values; 605 std::vector<base::string16> get_values;
606 p.GetRawMultiInfo(NAME_FULL, &get_values); 606 p.GetRawMultiInfo(NAME_FULL, &get_values);
607 ASSERT_EQ(2UL, get_values.size()); 607 ASSERT_EQ(2UL, get_values.size());
608 EXPECT_EQ(kJohnDoe, get_values[0]); 608 EXPECT_EQ(kJohnDoe, get_values[0]);
609 EXPECT_EQ(kJohnPDoe, get_values[1]); 609 EXPECT_EQ(kJohnPDoe, get_values[1]);
610 610
611 // Update the values. 611 // Update the values.
612 AutofillProfile p2 = p; 612 AutofillProfile p2 = p;
613 EXPECT_EQ(0, p.Compare(p2)); 613 EXPECT_EQ(0, p.Compare(p2));
614 const string16 kNoOne(ASCIIToUTF16("No One")); 614 const base::string16 kNoOne(ASCIIToUTF16("No One"));
615 set_values[1] = kNoOne; 615 set_values[1] = kNoOne;
616 p.SetRawMultiInfo(NAME_FULL, set_values); 616 p.SetRawMultiInfo(NAME_FULL, set_values);
617 p.GetRawMultiInfo(NAME_FULL, &get_values); 617 p.GetRawMultiInfo(NAME_FULL, &get_values);
618 ASSERT_EQ(2UL, get_values.size()); 618 ASSERT_EQ(2UL, get_values.size());
619 EXPECT_EQ(kJohnDoe, get_values[0]); 619 EXPECT_EQ(kJohnDoe, get_values[0]);
620 EXPECT_EQ(kNoOne, get_values[1]); 620 EXPECT_EQ(kNoOne, get_values[1]);
621 EXPECT_NE(0, p.Compare(p2)); 621 EXPECT_NE(0, p.Compare(p2));
622 622
623 // Delete values. 623 // Delete values.
624 set_values.clear(); 624 set_values.clear();
625 p.SetRawMultiInfo(NAME_FULL, set_values); 625 p.SetRawMultiInfo(NAME_FULL, set_values);
626 p.GetRawMultiInfo(NAME_FULL, &get_values); 626 p.GetRawMultiInfo(NAME_FULL, &get_values);
627 ASSERT_EQ(1UL, get_values.size()); 627 ASSERT_EQ(1UL, get_values.size());
628 EXPECT_EQ(string16(), get_values[0]); 628 EXPECT_EQ(base::string16(), get_values[0]);
629 629
630 // Expect regular |GetInfo| returns empty value. 630 // Expect regular |GetInfo| returns empty value.
631 EXPECT_EQ(string16(), p.GetRawInfo(NAME_FULL)); 631 EXPECT_EQ(base::string16(), p.GetRawInfo(NAME_FULL));
632 } 632 }
633 633
634 TEST(AutofillProfileTest, MultiValueEmails) { 634 TEST(AutofillProfileTest, MultiValueEmails) {
635 AutofillProfile p; 635 AutofillProfile p;
636 const string16 kJohnDoe(ASCIIToUTF16("john@doe.com")); 636 const base::string16 kJohnDoe(ASCIIToUTF16("john@doe.com"));
637 const string16 kJohnPDoe(ASCIIToUTF16("john_p@doe.com")); 637 const base::string16 kJohnPDoe(ASCIIToUTF16("john_p@doe.com"));
638 std::vector<string16> set_values; 638 std::vector<base::string16> set_values;
639 set_values.push_back(kJohnDoe); 639 set_values.push_back(kJohnDoe);
640 set_values.push_back(kJohnPDoe); 640 set_values.push_back(kJohnPDoe);
641 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); 641 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values);
642 642
643 // Expect regular |GetInfo| returns the first element. 643 // Expect regular |GetInfo| returns the first element.
644 EXPECT_EQ(kJohnDoe, p.GetRawInfo(EMAIL_ADDRESS)); 644 EXPECT_EQ(kJohnDoe, p.GetRawInfo(EMAIL_ADDRESS));
645 645
646 // Ensure that we get out what we put in. 646 // Ensure that we get out what we put in.
647 std::vector<string16> get_values; 647 std::vector<base::string16> get_values;
648 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values); 648 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values);
649 ASSERT_EQ(2UL, get_values.size()); 649 ASSERT_EQ(2UL, get_values.size());
650 EXPECT_EQ(kJohnDoe, get_values[0]); 650 EXPECT_EQ(kJohnDoe, get_values[0]);
651 EXPECT_EQ(kJohnPDoe, get_values[1]); 651 EXPECT_EQ(kJohnPDoe, get_values[1]);
652 652
653 // Update the values. 653 // Update the values.
654 AutofillProfile p2 = p; 654 AutofillProfile p2 = p;
655 EXPECT_EQ(0, p.Compare(p2)); 655 EXPECT_EQ(0, p.Compare(p2));
656 const string16 kNoOne(ASCIIToUTF16("no@one.com")); 656 const base::string16 kNoOne(ASCIIToUTF16("no@one.com"));
657 set_values[1] = kNoOne; 657 set_values[1] = kNoOne;
658 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); 658 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values);
659 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values); 659 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values);
660 ASSERT_EQ(2UL, get_values.size()); 660 ASSERT_EQ(2UL, get_values.size());
661 EXPECT_EQ(kJohnDoe, get_values[0]); 661 EXPECT_EQ(kJohnDoe, get_values[0]);
662 EXPECT_EQ(kNoOne, get_values[1]); 662 EXPECT_EQ(kNoOne, get_values[1]);
663 EXPECT_NE(0, p.Compare(p2)); 663 EXPECT_NE(0, p.Compare(p2));
664 664
665 // Delete values. 665 // Delete values.
666 set_values.clear(); 666 set_values.clear();
667 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); 667 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values);
668 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values); 668 p.GetRawMultiInfo(EMAIL_ADDRESS, &get_values);
669 ASSERT_EQ(1UL, get_values.size()); 669 ASSERT_EQ(1UL, get_values.size());
670 EXPECT_EQ(string16(), get_values[0]); 670 EXPECT_EQ(base::string16(), get_values[0]);
671 671
672 // Expect regular |GetInfo| returns empty value. 672 // Expect regular |GetInfo| returns empty value.
673 EXPECT_EQ(string16(), p.GetRawInfo(EMAIL_ADDRESS)); 673 EXPECT_EQ(base::string16(), p.GetRawInfo(EMAIL_ADDRESS));
674 } 674 }
675 675
676 TEST(AutofillProfileTest, MultiValuePhone) { 676 TEST(AutofillProfileTest, MultiValuePhone) {
677 AutofillProfile p; 677 AutofillProfile p;
678 const string16 kJohnDoe(ASCIIToUTF16("4151112222")); 678 const base::string16 kJohnDoe(ASCIIToUTF16("4151112222"));
679 const string16 kJohnPDoe(ASCIIToUTF16("4151113333")); 679 const base::string16 kJohnPDoe(ASCIIToUTF16("4151113333"));
680 std::vector<string16> set_values; 680 std::vector<base::string16> set_values;
681 set_values.push_back(kJohnDoe); 681 set_values.push_back(kJohnDoe);
682 set_values.push_back(kJohnPDoe); 682 set_values.push_back(kJohnPDoe);
683 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 683 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
684 684
685 // Expect regular |GetInfo| returns the first element. 685 // Expect regular |GetInfo| returns the first element.
686 EXPECT_EQ(kJohnDoe, p.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 686 EXPECT_EQ(kJohnDoe, p.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
687 687
688 // Ensure that we get out what we put in. 688 // Ensure that we get out what we put in.
689 std::vector<string16> get_values; 689 std::vector<base::string16> get_values;
690 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); 690 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values);
691 ASSERT_EQ(2UL, get_values.size()); 691 ASSERT_EQ(2UL, get_values.size());
692 EXPECT_EQ(kJohnDoe, get_values[0]); 692 EXPECT_EQ(kJohnDoe, get_values[0]);
693 EXPECT_EQ(kJohnPDoe, get_values[1]); 693 EXPECT_EQ(kJohnPDoe, get_values[1]);
694 694
695 // Update the values. 695 // Update the values.
696 AutofillProfile p2 = p; 696 AutofillProfile p2 = p;
697 EXPECT_EQ(0, p.Compare(p2)); 697 EXPECT_EQ(0, p.Compare(p2));
698 const string16 kNoOne(ASCIIToUTF16("4152110000")); 698 const base::string16 kNoOne(ASCIIToUTF16("4152110000"));
699 set_values[1] = kNoOne; 699 set_values[1] = kNoOne;
700 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 700 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
701 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); 701 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values);
702 ASSERT_EQ(2UL, get_values.size()); 702 ASSERT_EQ(2UL, get_values.size());
703 EXPECT_EQ(kJohnDoe, get_values[0]); 703 EXPECT_EQ(kJohnDoe, get_values[0]);
704 EXPECT_EQ(kNoOne, get_values[1]); 704 EXPECT_EQ(kNoOne, get_values[1]);
705 EXPECT_NE(0, p.Compare(p2)); 705 EXPECT_NE(0, p.Compare(p2));
706 706
707 // Delete values. 707 // Delete values.
708 set_values.clear(); 708 set_values.clear();
709 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 709 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
710 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); 710 p.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values);
711 ASSERT_EQ(1UL, get_values.size()); 711 ASSERT_EQ(1UL, get_values.size());
712 EXPECT_EQ(string16(), get_values[0]); 712 EXPECT_EQ(base::string16(), get_values[0]);
713 713
714 // Expect regular |GetInfo| returns empty value. 714 // Expect regular |GetInfo| returns empty value.
715 EXPECT_EQ(string16(), p.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 715 EXPECT_EQ(base::string16(), p.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
716 } 716 }
717 717
718 TEST(AutofillProfileTest, AddressCountryFull) { 718 TEST(AutofillProfileTest, AddressCountryFull) {
719 const char* const kCountries[] = { 719 const char* const kCountries[] = {
720 "Albania", "Canada" 720 "Albania", "Canada"
721 }; 721 };
722 std::vector<string16> options(arraysize(kCountries)); 722 std::vector<base::string16> options(arraysize(kCountries));
723 for (size_t i = 0; i < arraysize(kCountries); ++i) { 723 for (size_t i = 0; i < arraysize(kCountries); ++i) {
724 options[i] = ASCIIToUTF16(kCountries[i]); 724 options[i] = ASCIIToUTF16(kCountries[i]);
725 } 725 }
726 726
727 FormFieldData field; 727 FormFieldData field;
728 field.form_control_type = "select-one"; 728 field.form_control_type = "select-one";
729 field.option_values = options; 729 field.option_values = options;
730 field.option_contents = options; 730 field.option_contents = options;
731 731
732 AutofillProfile profile; 732 AutofillProfile profile;
733 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA")); 733 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
734 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field); 734 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field);
735 EXPECT_EQ(ASCIIToUTF16("Canada"), field.value); 735 EXPECT_EQ(ASCIIToUTF16("Canada"), field.value);
736 } 736 }
737 737
738 TEST(AutofillProfileTest, AddressCountryAbbrev) { 738 TEST(AutofillProfileTest, AddressCountryAbbrev) {
739 const char* const kCountries[] = { 739 const char* const kCountries[] = {
740 "AL", "CA" 740 "AL", "CA"
741 }; 741 };
742 std::vector<string16> options(arraysize(kCountries)); 742 std::vector<base::string16> options(arraysize(kCountries));
743 for (size_t i = 0; i < arraysize(kCountries); ++i) { 743 for (size_t i = 0; i < arraysize(kCountries); ++i) {
744 options[i] = ASCIIToUTF16(kCountries[i]); 744 options[i] = ASCIIToUTF16(kCountries[i]);
745 } 745 }
746 746
747 FormFieldData field; 747 FormFieldData field;
748 field.form_control_type = "select-one"; 748 field.form_control_type = "select-one";
749 field.option_values = options; 749 field.option_values = options;
750 field.option_contents = options; 750 field.option_contents = options;
751 751
752 AutofillProfile profile; 752 AutofillProfile profile;
753 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA")); 753 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
754 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field); 754 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, "en-US", &field);
755 EXPECT_EQ(ASCIIToUTF16("CA"), field.value); 755 EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
756 } 756 }
757 757
758 TEST(AutofillProfileTest, AddressStateFull) { 758 TEST(AutofillProfileTest, AddressStateFull) {
759 const char* const kStates[] = { 759 const char* const kStates[] = {
760 "Alabama", "California" 760 "Alabama", "California"
761 }; 761 };
762 std::vector<string16> options(arraysize(kStates)); 762 std::vector<base::string16> options(arraysize(kStates));
763 for (size_t i = 0; i < arraysize(kStates); ++i) { 763 for (size_t i = 0; i < arraysize(kStates); ++i) {
764 options[i] = ASCIIToUTF16(kStates[i]); 764 options[i] = ASCIIToUTF16(kStates[i]);
765 } 765 }
766 766
767 FormFieldData field; 767 FormFieldData field;
768 field.form_control_type = "select-one"; 768 field.form_control_type = "select-one";
769 field.option_values = options; 769 field.option_values = options;
770 field.option_contents = options; 770 field.option_contents = options;
771 771
772 AutofillProfile profile; 772 AutofillProfile profile;
773 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); 773 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
774 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); 774 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
775 EXPECT_EQ(ASCIIToUTF16("California"), field.value); 775 EXPECT_EQ(ASCIIToUTF16("California"), field.value);
776 } 776 }
777 777
778 TEST(AutofillProfileTest, AddressStateAbbrev) { 778 TEST(AutofillProfileTest, AddressStateAbbrev) {
779 const char* const kStates[] = { 779 const char* const kStates[] = {
780 "AL", "CA" 780 "AL", "CA"
781 }; 781 };
782 std::vector<string16> options(arraysize(kStates)); 782 std::vector<base::string16> options(arraysize(kStates));
783 for (size_t i = 0; i < arraysize(kStates); ++i) { 783 for (size_t i = 0; i < arraysize(kStates); ++i) {
784 options[i] = ASCIIToUTF16(kStates[i]); 784 options[i] = ASCIIToUTF16(kStates[i]);
785 } 785 }
786 786
787 FormFieldData field; 787 FormFieldData field;
788 field.form_control_type = "select-one"; 788 field.form_control_type = "select-one";
789 field.option_values = options; 789 field.option_values = options;
790 field.option_contents = options; 790 field.option_contents = options;
791 791
792 AutofillProfile profile; 792 AutofillProfile profile;
793 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); 793 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
794 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); 794 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
795 EXPECT_EQ(ASCIIToUTF16("CA"), field.value); 795 EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
796 } 796 }
797 797
798 TEST(AutofillProfileTest, FillByValue) { 798 TEST(AutofillProfileTest, FillByValue) {
799 const char* const kStates[] = { 799 const char* const kStates[] = {
800 "Alabama", "California" 800 "Alabama", "California"
801 }; 801 };
802 std::vector<string16> values(arraysize(kStates)); 802 std::vector<base::string16> values(arraysize(kStates));
803 std::vector<string16> contents(arraysize(kStates)); 803 std::vector<base::string16> contents(arraysize(kStates));
804 for (unsigned int i = 0; i < arraysize(kStates); ++i) { 804 for (unsigned int i = 0; i < arraysize(kStates); ++i) {
805 values[i] = ASCIIToUTF16(kStates[i]); 805 values[i] = ASCIIToUTF16(kStates[i]);
806 contents[i] = ASCIIToUTF16(base::StringPrintf("%u", i)); 806 contents[i] = ASCIIToUTF16(base::StringPrintf("%u", i));
807 } 807 }
808 808
809 FormFieldData field; 809 FormFieldData field;
810 field.form_control_type = "select-one"; 810 field.form_control_type = "select-one";
811 field.option_values = values; 811 field.option_values = values;
812 field.option_contents = contents; 812 field.option_contents = contents;
813 813
814 AutofillProfile profile; 814 AutofillProfile profile;
815 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); 815 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
816 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); 816 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
817 EXPECT_EQ(ASCIIToUTF16("California"), field.value); 817 EXPECT_EQ(ASCIIToUTF16("California"), field.value);
818 } 818 }
819 819
820 TEST(AutofillProfileTest, FillByContents) { 820 TEST(AutofillProfileTest, FillByContents) {
821 const char* const kStates[] = { 821 const char* const kStates[] = {
822 "Alabama", "California" 822 "Alabama", "California"
823 }; 823 };
824 std::vector<string16> values(arraysize(kStates)); 824 std::vector<base::string16> values(arraysize(kStates));
825 std::vector<string16> contents(arraysize(kStates)); 825 std::vector<base::string16> contents(arraysize(kStates));
826 for (unsigned int i = 0; i < arraysize(kStates); ++i) { 826 for (unsigned int i = 0; i < arraysize(kStates); ++i) {
827 values[i] = ASCIIToUTF16(base::StringPrintf("%u", i + 1)); 827 values[i] = ASCIIToUTF16(base::StringPrintf("%u", i + 1));
828 contents[i] = ASCIIToUTF16(kStates[i]); 828 contents[i] = ASCIIToUTF16(kStates[i]);
829 } 829 }
830 830
831 FormFieldData field; 831 FormFieldData field;
832 field.form_control_type = "select-one"; 832 field.form_control_type = "select-one";
833 field.option_values = values; 833 field.option_values = values;
834 field.option_contents = contents; 834 field.option_contents = contents;
835 835
836 AutofillProfile profile; 836 AutofillProfile profile;
837 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); 837 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
838 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); 838 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field);
839 EXPECT_EQ(ASCIIToUTF16("2"), field.value); 839 EXPECT_EQ(ASCIIToUTF16("2"), field.value);
840 } 840 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698