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

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

Issue 490373002: Add back organization field for autofill settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Git migration. Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/format_macros.h" 6 #include "base/format_macros.h"
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 "8002", 358 "8002",
359 "CH", 359 "CH",
360 "+41 44-668-1800"); 360 "+41 44-668-1800");
361 profiles.back()->set_language_code("de_CH"); 361 profiles.back()->set_language_code("de_CH");
362 static const char* kExpectedLabels[] = { 362 static const char* kExpectedLabels[] = {
363 "", 363 "",
364 "H. R. Giger", 364 "H. R. Giger",
365 "H. R. Giger, Brandschenkestrasse 110", 365 "H. R. Giger, Brandschenkestrasse 110",
366 "H. R. Giger, Brandschenkestrasse 110, Zurich", 366 "H. R. Giger, Brandschenkestrasse 110, Zurich",
367 "H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich", 367 "H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich",
368 "H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, Switzerland", 368 "Beispiel Inc, H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich",
369 "H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, Switzerland, " 369 "Beispiel Inc, H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, "
370 "hrgiger@beispiel.com", 370 "Switzerland",
371 "H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, Switzerland, " 371 "Beispiel Inc, H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, "
372 "hrgiger@beispiel.com, +41446681800", 372 "Switzerland, hrgiger@beispiel.com",
373 "H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, Switzerland, " 373 "Beispiel Inc, H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, "
374 "hrgiger@beispiel.com, +41446681800, Beispiel Inc", 374 "Switzerland, hrgiger@beispiel.com, +41446681800",
375 }; 375 };
376 376
377 std::vector<base::string16> labels; 377 std::vector<base::string16> labels;
378 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) { 378 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
379 AutofillProfile::CreateInferredLabels( 379 AutofillProfile::CreateInferredLabels(
380 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels); 380 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels);
381 ASSERT_FALSE(labels.empty()); 381 ASSERT_FALSE(labels.empty());
382 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back()); 382 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back());
383 } 383 }
384 } 384 }
(...skipping 18 matching lines...) Expand all
403 profiles.back()->set_language_code("fr_FR"); 403 profiles.back()->set_language_code("fr_FR");
404 profiles.back()->SetInfo( 404 profiles.back()->SetInfo(
405 AutofillType(ADDRESS_HOME_SORTING_CODE), UTF8ToUTF16("CEDEX"), "en-US"); 405 AutofillType(ADDRESS_HOME_SORTING_CODE), UTF8ToUTF16("CEDEX"), "en-US");
406 static const char* kExpectedLabels[] = { 406 static const char* kExpectedLabels[] = {
407 "", 407 "",
408 "Antoine de Saint-Exupéry", 408 "Antoine de Saint-Exupéry",
409 "Antoine de Saint-Exupéry, 8 Rue de Londres", 409 "Antoine de Saint-Exupéry, 8 Rue de Londres",
410 "Antoine de Saint-Exupéry, 8 Rue de Londres, Paris", 410 "Antoine de Saint-Exupéry, 8 Rue de Londres, Paris",
411 "Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris", 411 "Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris",
412 "Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX", 412 "Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX",
413 "Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX, France", 413 "Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
414 "Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX, France, " 414 "CEDEX",
415 "antoine@exemple.com", 415 "Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
416 "Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX, France, " 416 "CEDEX, France",
417 "antoine@exemple.com, +33142685300", 417 "Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
418 "Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX, France, " 418 "CEDEX, France, antoine@exemple.com",
419 "antoine@exemple.com, +33142685300, Exemple Inc", 419 "Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
420 "CEDEX, France, antoine@exemple.com, +33142685300",
421 "Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
422 "CEDEX, France, antoine@exemple.com, +33142685300",
420 }; 423 };
421 424
422 std::vector<base::string16> labels; 425 std::vector<base::string16> labels;
423 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) { 426 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
424 AutofillProfile::CreateInferredLabels( 427 AutofillProfile::CreateInferredLabels(
425 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels); 428 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels);
426 ASSERT_FALSE(labels.empty()); 429 ASSERT_FALSE(labels.empty());
427 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back()); 430 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back());
428 } 431 }
429 } 432 }
(...skipping 23 matching lines...) Expand all
453 "Park Jae-sang", 456 "Park Jae-sang",
454 "Park Jae-sang, Gangnam Finance Center", 457 "Park Jae-sang, Gangnam Finance Center",
455 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro", 458 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro",
456 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong", 459 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong",
457 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, " 460 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, "
458 "Gangnam-Gu", 461 "Gangnam-Gu",
459 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, " 462 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, "
460 "Gangnam-Gu, Seoul", 463 "Gangnam-Gu, Seoul",
461 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, " 464 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, "
462 "Gangnam-Gu, Seoul, 135-984", 465 "Gangnam-Gu, Seoul, 135-984",
463 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, " 466 "Park Jae-sang, Yeleul Inc, Gangnam Finance Center, 152 Teheran-ro, "
464 "Gangnam-Gu, Seoul, 135-984, South Korea", 467 "Yeoksam-Dong, Gangnam-Gu, Seoul, 135-984",
465 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, " 468 "Park Jae-sang, Yeleul Inc, Gangnam Finance Center, 152 Teheran-ro, "
466 "Gangnam-Gu, Seoul, 135-984, South Korea, park@yeleul.com", 469 "Yeoksam-Dong, Gangnam-Gu, Seoul, 135-984, South Korea",
467 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, " 470 "Park Jae-sang, Yeleul Inc, Gangnam Finance Center, 152 Teheran-ro, "
468 "Gangnam-Gu, Seoul, 135-984, South Korea, park@yeleul.com, " 471 "Yeoksam-Dong, Gangnam-Gu, Seoul, 135-984, South Korea, "
469 "+8225319000", 472 "park@yeleul.com",
470 "Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, " 473 "Park Jae-sang, Yeleul Inc, Gangnam Finance Center, 152 Teheran-ro, "
471 "Gangnam-Gu, Seoul, 135-984, South Korea, park@yeleul.com, " 474 "Yeoksam-Dong, Gangnam-Gu, Seoul, 135-984, South Korea, "
472 "+8225319000, Yeleul Inc", 475 "park@yeleul.com, +8225319000",
473 }; 476 };
474 477
475 std::vector<base::string16> labels; 478 std::vector<base::string16> labels;
476 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) { 479 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
477 AutofillProfile::CreateInferredLabels( 480 AutofillProfile::CreateInferredLabels(
478 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels); 481 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels);
479 ASSERT_FALSE(labels.empty()); 482 ASSERT_FALSE(labels.empty());
480 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back()); 483 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back());
481 } 484 }
482 } 485 }
(...skipping 18 matching lines...) Expand all
501 static const char* kExpectedLabels[] = { 504 static const char* kExpectedLabels[] = {
502 "", 505 "",
503 "Miku Hatsune", 506 "Miku Hatsune",
504 "Miku Hatsune, Roppongi Hills Mori Tower", 507 "Miku Hatsune, Roppongi Hills Mori Tower",
505 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi", 508 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi",
506 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku", 509 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku",
507 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, " 510 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, "
508 "Tokyo", 511 "Tokyo",
509 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, " 512 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, "
510 "Tokyo, 106-6126", 513 "Tokyo, 106-6126",
511 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, " 514 "Miku Hatsune, Rei Inc, Roppongi Hills Mori Tower, 6-10-1 Roppongi, "
512 "Tokyo, 106-6126, Japan", 515 "Minato-ku, Tokyo, 106-6126",
513 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, " 516 "Miku Hatsune, Rei Inc, Roppongi Hills Mori Tower, 6-10-1 Roppongi, "
514 "Tokyo, 106-6126, Japan, miku@rei.com", 517 "Minato-ku, Tokyo, 106-6126, Japan",
515 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, " 518 "Miku Hatsune, Rei Inc, Roppongi Hills Mori Tower, 6-10-1 Roppongi, "
516 "Tokyo, 106-6126, Japan, miku@rei.com, +81363849000", 519 "Minato-ku, Tokyo, 106-6126, Japan, miku@rei.com",
517 "Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, " 520 "Miku Hatsune, Rei Inc, Roppongi Hills Mori Tower, 6-10-1 Roppongi, "
518 "Tokyo, 106-6126, Japan, miku@rei.com, +81363849000, Rei Inc", 521 "Minato-ku, Tokyo, 106-6126, Japan, miku@rei.com, +81363849000",
519 }; 522 };
520 523
521 std::vector<base::string16> labels; 524 std::vector<base::string16> labels;
522 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) { 525 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
523 AutofillProfile::CreateInferredLabels( 526 AutofillProfile::CreateInferredLabels(
524 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels); 527 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels);
525 ASSERT_FALSE(labels.empty()); 528 ASSERT_FALSE(labels.empty());
526 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back()); 529 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back());
527 } 530 }
528 } 531 }
(...skipping 16 matching lines...) Expand all
545 "03-6384-9000"); 548 "03-6384-9000");
546 profiles.back()->set_language_code("ja_JP"); 549 profiles.back()->set_language_code("ja_JP");
547 static const char* kExpectedLabels[] = { 550 static const char* kExpectedLabels[] = {
548 "", 551 "",
549 "ミク 初音", 552 "ミク 初音",
550 "六本木ヒルズ森タワーミク 初音", 553 "六本木ヒルズ森タワーミク 初音",
551 "六本木ヒルズ森タワー六本木 6-10-1ミク 初音", 554 "六本木ヒルズ森タワー六本木 6-10-1ミク 初音",
552 "港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音", 555 "港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音",
553 "東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音", 556 "東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音",
554 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音", 557 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音",
555 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音, Japan", 558 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1例ミク 初音",
556 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音, Japan, " 559 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1例ミク 初音, Japan",
560 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1例ミク 初音, Japan, "
557 "miku@rei.com", 561 "miku@rei.com",
558 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音, Japan, " 562 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1例ミク 初音, Japan, "
559 "miku@rei.com, 0363849000", 563 "miku@rei.com, 0363849000",
560 "〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音, Japan, "
561 "miku@rei.com, 0363849000, 例",
562 }; 564 };
563 565
564 std::vector<base::string16> labels; 566 std::vector<base::string16> labels;
565 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) { 567 for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
566 AutofillProfile::CreateInferredLabels( 568 AutofillProfile::CreateInferredLabels(
567 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels); 569 profiles.get(), NULL, UNKNOWN_TYPE, i, "en-US", &labels);
568 ASSERT_FALSE(labels.empty()); 570 ASSERT_FALSE(labels.empty());
569 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back()); 571 EXPECT_EQ(UTF8ToUTF16(kExpectedLabels[i]), labels.back());
570 } 572 }
571 } 573 }
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 TEST(AutofillProfileTest, FullAddress) { 1188 TEST(AutofillProfileTest, FullAddress) {
1187 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); 1189 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
1188 test::SetProfileInfo(&profile, "Marion", "Mitchell", "Morrison", 1190 test::SetProfileInfo(&profile, "Marion", "Mitchell", "Morrison",
1189 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", 1191 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
1190 "Hollywood", "CA", "91601", "US", 1192 "Hollywood", "CA", "91601", "US",
1191 "12345678910"); 1193 "12345678910");
1192 1194
1193 AutofillType full_address(HTML_TYPE_FULL_ADDRESS, HTML_MODE_NONE); 1195 AutofillType full_address(HTML_TYPE_FULL_ADDRESS, HTML_MODE_NONE);
1194 base::string16 formatted_address(ASCIIToUTF16( 1196 base::string16 formatted_address(ASCIIToUTF16(
1195 "Marion Mitchell Morrison\n" 1197 "Marion Mitchell Morrison\n"
1198 "Fox\n"
1196 "123 Zoo St.\n" 1199 "123 Zoo St.\n"
1197 "unit 5\n" 1200 "unit 5\n"
1198 "Hollywood, CA 91601")); 1201 "Hollywood, CA 91601"));
1199 EXPECT_EQ(formatted_address, profile.GetInfo(full_address, "en-US")); 1202 EXPECT_EQ(formatted_address, profile.GetInfo(full_address, "en-US"));
1200 // This should fail and leave the profile unchanged. 1203 // This should fail and leave the profile unchanged.
1201 EXPECT_FALSE(profile.SetInfo(full_address, ASCIIToUTF16("foobar"), "en-US")); 1204 EXPECT_FALSE(profile.SetInfo(full_address, ASCIIToUTF16("foobar"), "en-US"));
1202 EXPECT_EQ(formatted_address, profile.GetInfo(full_address, "en-US")); 1205 EXPECT_EQ(formatted_address, profile.GetInfo(full_address, "en-US"));
1203 1206
1204 // Some things can be missing... 1207 // Some things can be missing...
1205 profile.SetInfo(AutofillType(ADDRESS_HOME_LINE2), 1208 profile.SetInfo(AutofillType(ADDRESS_HOME_LINE2),
1206 base::string16(), 1209 base::string16(),
1207 "en-US"); 1210 "en-US");
1208 profile.SetInfo(AutofillType(EMAIL_ADDRESS), 1211 profile.SetInfo(AutofillType(EMAIL_ADDRESS),
1209 base::string16(), 1212 base::string16(),
1210 "en-US"); 1213 "en-US");
1211 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison\n" 1214 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison\n"
1215 "Fox\n"
1212 "123 Zoo St.\n" 1216 "123 Zoo St.\n"
1213 "Hollywood, CA 91601"), 1217 "Hollywood, CA 91601"),
1214 profile.GetInfo(full_address, "en-US")); 1218 profile.GetInfo(full_address, "en-US"));
1215 1219
1216 // ...but nothing comes out if a required field is missing. 1220 // ...but nothing comes out if a required field is missing.
1217 profile.SetInfo(AutofillType(ADDRESS_HOME_STATE), base::string16(), "en-US"); 1221 profile.SetInfo(AutofillType(ADDRESS_HOME_STATE), base::string16(), "en-US");
1218 EXPECT_TRUE(profile.GetInfo(full_address, "en-US").empty()); 1222 EXPECT_TRUE(profile.GetInfo(full_address, "en-US").empty());
1219 1223
1220 // Restore the state but remove country. This should also fail. 1224 // Restore the state but remove country. This should also fail.
1221 profile.SetInfo(AutofillType(ADDRESS_HOME_STATE), 1225 profile.SetInfo(AutofillType(ADDRESS_HOME_STATE),
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 1375
1372 for (size_t i = 0; i < current_case.expected_result.size(); ++i) { 1376 for (size_t i = 0; i < current_case.expected_result.size(); ++i) {
1373 EXPECT_EQ(first_names[i], merged_first_names[i]); 1377 EXPECT_EQ(first_names[i], merged_first_names[i]);
1374 EXPECT_EQ(middle_names[i], merged_middle_names[i]); 1378 EXPECT_EQ(middle_names[i], merged_middle_names[i]);
1375 EXPECT_EQ(last_names[i], merged_last_names[i]); 1379 EXPECT_EQ(last_names[i], merged_last_names[i]);
1376 } 1380 }
1377 } 1381 }
1378 } 1382 }
1379 1383
1380 } // namespace autofill 1384 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/address_i18n_unittest.cc ('k') | third_party/libaddressinput/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698