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

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

Issue 11000016: Move forms/ out of webkit/. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Response to review Created 8 years, 2 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 (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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/autofill/autofill_common_test.h" 12 #include "chrome/browser/autofill/autofill_common_test.h"
13 #include "chrome/browser/autofill/autofill_profile.h" 13 #include "chrome/browser/autofill/autofill_profile.h"
14 #include "chrome/browser/autofill/form_structure.h" 14 #include "chrome/browser/autofill/form_structure.h"
15 #include "chrome/browser/autofill/personal_data_manager.h" 15 #include "chrome/browser/autofill/personal_data_manager.h"
16 #include "chrome/browser/autofill/personal_data_manager_observer.h" 16 #include "chrome/browser/autofill/personal_data_manager_observer.h"
17 #include "chrome/browser/password_manager/encryptor.h" 17 #include "chrome/browser/password_manager/encryptor.h"
18 #include "chrome/browser/webdata/web_data_service.h" 18 #include "chrome/browser/webdata/web_data_service.h"
19 #include "chrome/browser/webdata/web_data_service_factory.h" 19 #include "chrome/browser/webdata/web_data_service_factory.h"
20 #include "chrome/common/form_data.h"
20 #include "chrome/test/base/testing_browser_process.h" 21 #include "chrome/test/base/testing_browser_process.h"
21 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
22 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.h"
24 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
25 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
26 #include "content/public/test/mock_notification_observer.h" 27 #include "content/public/test/mock_notification_observer.h"
27 #include "content/public/test/test_browser_thread.h" 28 #include "content/public/test/test_browser_thread.h"
28 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 #include "webkit/forms/form_data.h"
31 31
32 using content::BrowserThread; 32 using content::BrowserThread;
33 using webkit::forms::FormData;
34 33
35 ACTION(QuitUIMessageLoop) { 34 ACTION(QuitUIMessageLoop) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37 MessageLoop::current()->Quit(); 36 MessageLoop::current()->Quit();
38 } 37 }
39 38
40 class PersonalDataLoadedObserverMock : public PersonalDataManagerObserver { 39 class PersonalDataLoadedObserverMock : public PersonalDataManagerObserver {
41 public: 40 public:
42 PersonalDataLoadedObserverMock() {} 41 PersonalDataLoadedObserverMock() {}
43 virtual ~PersonalDataLoadedObserverMock() {} 42 virtual ~PersonalDataLoadedObserverMock() {}
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 475 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
477 MessageLoop::current()->Run(); 476 MessageLoop::current()->Run();
478 477
479 const std::vector<AutofillProfile*>& results3 = personal_data_->profiles(); 478 const std::vector<AutofillProfile*>& results3 = personal_data_->profiles();
480 ASSERT_EQ(1U, results3.size()); 479 ASSERT_EQ(1U, results3.size());
481 EXPECT_EQ(profile0, *results2[0]); 480 EXPECT_EQ(profile0, *results2[0]);
482 } 481 }
483 482
484 TEST_F(PersonalDataManagerTest, ImportFormData) { 483 TEST_F(PersonalDataManagerTest, ImportFormData) {
485 FormData form; 484 FormData form;
486 webkit::forms::FormField field; 485 FormFieldData field;
487 autofill_test::CreateTestFormField( 486 autofill_test::CreateTestFormField(
488 "First name:", "first_name", "George", "text", &field); 487 "First name:", "first_name", "George", "text", &field);
489 form.fields.push_back(field); 488 form.fields.push_back(field);
490 autofill_test::CreateTestFormField( 489 autofill_test::CreateTestFormField(
491 "Last name:", "last_name", "Washington", "text", &field); 490 "Last name:", "last_name", "Washington", "text", &field);
492 form.fields.push_back(field); 491 form.fields.push_back(field);
493 autofill_test::CreateTestFormField( 492 autofill_test::CreateTestFormField(
494 "Email:", "email", "theprez@gmail.com", "text", &field); 493 "Email:", "email", "theprez@gmail.com", "text", &field);
495 form.fields.push_back(field); 494 form.fields.push_back(field);
496 autofill_test::CreateTestFormField( 495 autofill_test::CreateTestFormField(
(...skipping 24 matching lines...) Expand all
521 autofill_test::SetProfileInfo(&expected, "George", NULL, 520 autofill_test::SetProfileInfo(&expected, "George", NULL,
522 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, 521 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL,
523 "San Francisco", "California", "94102", NULL, NULL); 522 "San Francisco", "California", "94102", NULL, NULL);
524 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); 523 const std::vector<AutofillProfile*>& results = personal_data_->profiles();
525 ASSERT_EQ(1U, results.size()); 524 ASSERT_EQ(1U, results.size());
526 EXPECT_EQ(0, expected.Compare(*results[0])); 525 EXPECT_EQ(0, expected.Compare(*results[0]));
527 } 526 }
528 527
529 TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) { 528 TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) {
530 FormData form; 529 FormData form;
531 webkit::forms::FormField field; 530 FormFieldData field;
532 autofill_test::CreateTestFormField( 531 autofill_test::CreateTestFormField(
533 "First name:", "first_name", "George", "text", &field); 532 "First name:", "first_name", "George", "text", &field);
534 form.fields.push_back(field); 533 form.fields.push_back(field);
535 autofill_test::CreateTestFormField( 534 autofill_test::CreateTestFormField(
536 "Last name:", "last_name", "Washington", "text", &field); 535 "Last name:", "last_name", "Washington", "text", &field);
537 form.fields.push_back(field); 536 form.fields.push_back(field);
538 autofill_test::CreateTestFormField( 537 autofill_test::CreateTestFormField(
539 "Email:", "email", "bogus", "text", &field); 538 "Email:", "email", "bogus", "text", &field);
540 form.fields.push_back(field); 539 form.fields.push_back(field);
541 autofill_test::CreateTestFormField( 540 autofill_test::CreateTestFormField(
(...skipping 14 matching lines...) Expand all
556 EXPECT_FALSE(personal_data_->ImportFormData(form_structure, 555 EXPECT_FALSE(personal_data_->ImportFormData(form_structure,
557 &imported_credit_card)); 556 &imported_credit_card));
558 ASSERT_EQ(static_cast<CreditCard*>(NULL), imported_credit_card); 557 ASSERT_EQ(static_cast<CreditCard*>(NULL), imported_credit_card);
559 558
560 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); 559 const std::vector<AutofillProfile*>& results = personal_data_->profiles();
561 ASSERT_EQ(0U, results.size()); 560 ASSERT_EQ(0U, results.size());
562 } 561 }
563 562
564 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { 563 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) {
565 FormData form; 564 FormData form;
566 webkit::forms::FormField field; 565 FormFieldData field;
567 autofill_test::CreateTestFormField( 566 autofill_test::CreateTestFormField(
568 "First name:", "first_name", "George", "text", &field); 567 "First name:", "first_name", "George", "text", &field);
569 form.fields.push_back(field); 568 form.fields.push_back(field);
570 autofill_test::CreateTestFormField( 569 autofill_test::CreateTestFormField(
571 "Last name:", "last_name", "Washington", "text", &field); 570 "Last name:", "last_name", "Washington", "text", &field);
572 form.fields.push_back(field); 571 form.fields.push_back(field);
573 autofill_test::CreateTestFormField( 572 autofill_test::CreateTestFormField(
574 "Card number:", "card_number", "4111 1111 1111 1111", "text", &field); 573 "Card number:", "card_number", "4111 1111 1111 1111", "text", &field);
575 form.fields.push_back(field); 574 form.fields.push_back(field);
576 FormStructure form_structure(form); 575 FormStructure form_structure(form);
577 form_structure.DetermineHeuristicTypes(); 576 form_structure.DetermineHeuristicTypes();
578 const CreditCard* imported_credit_card; 577 const CreditCard* imported_credit_card;
579 EXPECT_FALSE(personal_data_->ImportFormData(form_structure, 578 EXPECT_FALSE(personal_data_->ImportFormData(form_structure,
580 &imported_credit_card)); 579 &imported_credit_card));
581 ASSERT_FALSE(imported_credit_card); 580 ASSERT_FALSE(imported_credit_card);
582 581
583 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); 582 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles();
584 ASSERT_EQ(0U, profiles.size()); 583 ASSERT_EQ(0U, profiles.size());
585 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); 584 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards();
586 ASSERT_EQ(0U, credit_cards.size()); 585 ASSERT_EQ(0U, credit_cards.size());
587 } 586 }
588 587
589 TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) { 588 TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) {
590 FormData form; 589 FormData form;
591 webkit::forms::FormField field; 590 FormFieldData field;
592 autofill_test::CreateTestFormField( 591 autofill_test::CreateTestFormField(
593 "First name:", "first_name", "George", "text", &field); 592 "First name:", "first_name", "George", "text", &field);
594 form.fields.push_back(field); 593 form.fields.push_back(field);
595 autofill_test::CreateTestFormField( 594 autofill_test::CreateTestFormField(
596 "Last name:", "last_name", "Washington", "text", &field); 595 "Last name:", "last_name", "Washington", "text", &field);
597 form.fields.push_back(field); 596 form.fields.push_back(field);
598 autofill_test::CreateTestFormField( 597 autofill_test::CreateTestFormField(
599 "Phone #:", "home_phone_area_code", "650", "text", &field); 598 "Phone #:", "home_phone_area_code", "650", "text", &field);
600 field.max_length = 3; 599 field.max_length = 3;
601 form.fields.push_back(field); 600 form.fields.push_back(field);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 EXPECT_EQ(credit_card0.guid(), results[0]->guid()); 671 EXPECT_EQ(credit_card0.guid(), results[0]->guid());
673 EXPECT_EQ(credit_card1.guid(), results[1]->guid()); 672 EXPECT_EQ(credit_card1.guid(), results[1]->guid());
674 EXPECT_EQ(credit_card2.guid(), results[2]->guid()); 673 EXPECT_EQ(credit_card2.guid(), results[2]->guid());
675 EXPECT_EQ(credit_card3.guid(), results[3]->guid()); 674 EXPECT_EQ(credit_card3.guid(), results[3]->guid());
676 EXPECT_EQ(credit_card4.guid(), results[4]->guid()); 675 EXPECT_EQ(credit_card4.guid(), results[4]->guid());
677 EXPECT_EQ(credit_card5.guid(), results[5]->guid()); 676 EXPECT_EQ(credit_card5.guid(), results[5]->guid());
678 } 677 }
679 678
680 TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { 679 TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) {
681 FormData form1; 680 FormData form1;
682 webkit::forms::FormField field; 681 FormFieldData field;
683 autofill_test::CreateTestFormField( 682 autofill_test::CreateTestFormField(
684 "First name:", "first_name", "George", "text", &field); 683 "First name:", "first_name", "George", "text", &field);
685 form1.fields.push_back(field); 684 form1.fields.push_back(field);
686 autofill_test::CreateTestFormField( 685 autofill_test::CreateTestFormField(
687 "Last name:", "last_name", "Washington", "text", &field); 686 "Last name:", "last_name", "Washington", "text", &field);
688 form1.fields.push_back(field); 687 form1.fields.push_back(field);
689 autofill_test::CreateTestFormField( 688 autofill_test::CreateTestFormField(
690 "Email:", "email", "theprez@gmail.com", "text", &field); 689 "Email:", "email", "theprez@gmail.com", "text", &field);
691 form1.fields.push_back(field); 690 form1.fields.push_back(field);
692 autofill_test::CreateTestFormField( 691 autofill_test::CreateTestFormField(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 autofill_test::SetProfileInfo(&expected2, "John", NULL, 762 autofill_test::SetProfileInfo(&expected2, "John", NULL,
764 "Adams", "second@gmail.com", NULL, "22 Laussat St", NULL, 763 "Adams", "second@gmail.com", NULL, "22 Laussat St", NULL,
765 "San Francisco", "California", "94102", NULL, NULL); 764 "San Francisco", "California", "94102", NULL, NULL);
766 ASSERT_EQ(2U, results2.size()); 765 ASSERT_EQ(2U, results2.size());
767 EXPECT_EQ(0, expected.Compare(*results2[0])); 766 EXPECT_EQ(0, expected.Compare(*results2[0]));
768 EXPECT_EQ(0, expected2.Compare(*results2[1])); 767 EXPECT_EQ(0, expected2.Compare(*results2[1]));
769 } 768 }
770 769
771 TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) { 770 TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) {
772 FormData form1; 771 FormData form1;
773 webkit::forms::FormField field; 772 FormFieldData field;
774 autofill_test::CreateTestFormField( 773 autofill_test::CreateTestFormField(
775 "First name:", "first_name", "George", "text", &field); 774 "First name:", "first_name", "George", "text", &field);
776 form1.fields.push_back(field); 775 form1.fields.push_back(field);
777 autofill_test::CreateTestFormField( 776 autofill_test::CreateTestFormField(
778 "Last name:", "last_name", "Washington", "text", &field); 777 "Last name:", "last_name", "Washington", "text", &field);
779 form1.fields.push_back(field); 778 form1.fields.push_back(field);
780 autofill_test::CreateTestFormField( 779 autofill_test::CreateTestFormField(
781 "Email:", "email", "theprez@gmail.com", "text", &field); 780 "Email:", "email", "theprez@gmail.com", "text", &field);
782 form1.fields.push_back(field); 781 form1.fields.push_back(field);
783 autofill_test::CreateTestFormField( 782 autofill_test::CreateTestFormField(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 expected.GetMultiInfo(EMAIL_ADDRESS, &values); 857 expected.GetMultiInfo(EMAIL_ADDRESS, &values);
859 values.push_back(ASCIIToUTF16("second@gmail.com")); 858 values.push_back(ASCIIToUTF16("second@gmail.com"));
860 expected.SetMultiInfo(EMAIL_ADDRESS, values); 859 expected.SetMultiInfo(EMAIL_ADDRESS, values);
861 860
862 ASSERT_EQ(1U, results2.size()); 861 ASSERT_EQ(1U, results2.size());
863 EXPECT_EQ(0, expected.Compare(*results2[0])); 862 EXPECT_EQ(0, expected.Compare(*results2[0]));
864 } 863 }
865 864
866 TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { 865 TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
867 FormData form1; 866 FormData form1;
868 webkit::forms::FormField field; 867 FormFieldData field;
869 autofill_test::CreateTestFormField( 868 autofill_test::CreateTestFormField(
870 "First name:", "first_name", "George", "text", &field); 869 "First name:", "first_name", "George", "text", &field);
871 form1.fields.push_back(field); 870 form1.fields.push_back(field);
872 autofill_test::CreateTestFormField( 871 autofill_test::CreateTestFormField(
873 "Last name:", "last_name", "Washington", "text", &field); 872 "Last name:", "last_name", "Washington", "text", &field);
874 form1.fields.push_back(field); 873 form1.fields.push_back(field);
875 autofill_test::CreateTestFormField( 874 autofill_test::CreateTestFormField(
876 "Address:", "address", "1600 Pennsylvania Avenue", "text", &field); 875 "Address:", "address", "1600 Pennsylvania Avenue", "text", &field);
877 form1.fields.push_back(field); 876 form1.fields.push_back(field);
878 autofill_test::CreateTestFormField( 877 autofill_test::CreateTestFormField(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); 967 expected.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
969 values.push_back(ASCIIToUTF16("6502231234")); 968 values.push_back(ASCIIToUTF16("6502231234"));
970 expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); 969 expected.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values);
971 expected.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States")); 970 expected.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States"));
972 ASSERT_EQ(1U, results2.size()); 971 ASSERT_EQ(1U, results2.size());
973 EXPECT_EQ(0, expected.Compare(*results2[0])); 972 EXPECT_EQ(0, expected.Compare(*results2[0]));
974 } 973 }
975 974
976 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { 975 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) {
977 FormData form1; 976 FormData form1;
978 webkit::forms::FormField field; 977 FormFieldData field;
979 autofill_test::CreateTestFormField( 978 autofill_test::CreateTestFormField(
980 "First name:", "first_name", "George", "text", &field); 979 "First name:", "first_name", "George", "text", &field);
981 form1.fields.push_back(field); 980 form1.fields.push_back(field);
982 autofill_test::CreateTestFormField( 981 autofill_test::CreateTestFormField(
983 "Last name:", "last_name", "Washington", "text", &field); 982 "Last name:", "last_name", "Washington", "text", &field);
984 form1.fields.push_back(field); 983 form1.fields.push_back(field);
985 autofill_test::CreateTestFormField( 984 autofill_test::CreateTestFormField(
986 "Address Line 1:", "address", "190 High Street", "text", &field); 985 "Address Line 1:", "address", "190 High Street", "text", &field);
987 form1.fields.push_back(field); 986 form1.fields.push_back(field);
988 autofill_test::CreateTestFormField( 987 autofill_test::CreateTestFormField(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 AutofillProfile expected2; 1054 AutofillProfile expected2;
1056 autofill_test::SetProfileInfo(&expected2, "George", NULL, 1055 autofill_test::SetProfileInfo(&expected2, "George", NULL,
1057 "Washington", "theprez@gmail.com", NULL, "190 High Street", NULL, 1056 "Washington", "theprez@gmail.com", NULL, "190 High Street", NULL,
1058 "Philadelphia", "Pennsylvania", "19106", NULL, NULL); 1057 "Philadelphia", "Pennsylvania", "19106", NULL, NULL);
1059 ASSERT_EQ(1U, results2.size()); 1058 ASSERT_EQ(1U, results2.size());
1060 EXPECT_EQ(0, expected2.Compare(*results2[0])); 1059 EXPECT_EQ(0, expected2.Compare(*results2[0]));
1061 } 1060 }
1062 1061
1063 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) { 1062 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) {
1064 FormData form1; 1063 FormData form1;
1065 webkit::forms::FormField field; 1064 FormFieldData field;
1066 autofill_test::CreateTestFormField( 1065 autofill_test::CreateTestFormField(
1067 "First name:", "first_name", "George", "text", &field); 1066 "First name:", "first_name", "George", "text", &field);
1068 form1.fields.push_back(field); 1067 form1.fields.push_back(field);
1069 autofill_test::CreateTestFormField( 1068 autofill_test::CreateTestFormField(
1070 "Last name:", "last_name", "Washington", "text", &field); 1069 "Last name:", "last_name", "Washington", "text", &field);
1071 form1.fields.push_back(field); 1070 form1.fields.push_back(field);
1072 autofill_test::CreateTestFormField( 1071 autofill_test::CreateTestFormField(
1073 "Company:", "company", "Government", "text", &field); 1072 "Company:", "company", "Government", "text", &field);
1074 form1.fields.push_back(field); 1073 form1.fields.push_back(field);
1075 autofill_test::CreateTestFormField( 1074 autofill_test::CreateTestFormField(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 1145
1147 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); 1146 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles();
1148 1147
1149 // Expect no change. 1148 // Expect no change.
1150 ASSERT_EQ(1U, results2.size()); 1149 ASSERT_EQ(1U, results2.size());
1151 EXPECT_EQ(0, expected.Compare(*results2[0])); 1150 EXPECT_EQ(0, expected.Compare(*results2[0]));
1152 } 1151 }
1153 1152
1154 TEST_F(PersonalDataManagerTest, AggregateProfileWithInsufficientAddress) { 1153 TEST_F(PersonalDataManagerTest, AggregateProfileWithInsufficientAddress) {
1155 FormData form1; 1154 FormData form1;
1156 webkit::forms::FormField field; 1155 FormFieldData field;
1157 autofill_test::CreateTestFormField( 1156 autofill_test::CreateTestFormField(
1158 "First name:", "first_name", "George", "text", &field); 1157 "First name:", "first_name", "George", "text", &field);
1159 form1.fields.push_back(field); 1158 form1.fields.push_back(field);
1160 autofill_test::CreateTestFormField( 1159 autofill_test::CreateTestFormField(
1161 "Last name:", "last_name", "Washington", "text", &field); 1160 "Last name:", "last_name", "Washington", "text", &field);
1162 form1.fields.push_back(field); 1161 form1.fields.push_back(field);
1163 autofill_test::CreateTestFormField( 1162 autofill_test::CreateTestFormField(
1164 "Company:", "company", "Government", "text", &field); 1163 "Company:", "company", "Government", "text", &field);
1165 form1.fields.push_back(field); 1164 form1.fields.push_back(field);
1166 autofill_test::CreateTestFormField( 1165 autofill_test::CreateTestFormField(
(...skipping 29 matching lines...) Expand all
1196 "Tester", "Frederick", "McAddressBookTesterson", 1195 "Tester", "Frederick", "McAddressBookTesterson",
1197 "tester@example.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", 1196 "tester@example.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco",
1198 "CA", "94102", "USA", "1.415.888.9999"); 1197 "CA", "94102", "USA", "1.415.888.9999");
1199 ScopedVector<AutofillProfile>& auxiliary_profiles = 1198 ScopedVector<AutofillProfile>& auxiliary_profiles =
1200 personal_data_->auxiliary_profiles_; 1199 personal_data_->auxiliary_profiles_;
1201 auxiliary_profiles.push_back(auxiliary_profile); 1200 auxiliary_profiles.push_back(auxiliary_profile);
1202 1201
1203 // Simulate a form submission with a subset of the info. 1202 // Simulate a form submission with a subset of the info.
1204 // Note that the phone number format is different from the saved format. 1203 // Note that the phone number format is different from the saved format.
1205 FormData form; 1204 FormData form;
1206 webkit::forms::FormField field; 1205 FormFieldData field;
1207 autofill_test::CreateTestFormField( 1206 autofill_test::CreateTestFormField(
1208 "First name:", "first_name", "Tester", "text", &field); 1207 "First name:", "first_name", "Tester", "text", &field);
1209 form.fields.push_back(field); 1208 form.fields.push_back(field);
1210 autofill_test::CreateTestFormField( 1209 autofill_test::CreateTestFormField(
1211 "Last name:", "last_name", "McAddressBookTesterson", "text", &field); 1210 "Last name:", "last_name", "McAddressBookTesterson", "text", &field);
1212 form.fields.push_back(field); 1211 form.fields.push_back(field);
1213 autofill_test::CreateTestFormField( 1212 autofill_test::CreateTestFormField(
1214 "Email:", "email", "tester@example.com", "text", &field); 1213 "Email:", "email", "tester@example.com", "text", &field);
1215 form.fields.push_back(field); 1214 form.fields.push_back(field);
1216 autofill_test::CreateTestFormField( 1215 autofill_test::CreateTestFormField(
(...skipping 26 matching lines...) Expand all
1243 personal_data_->web_profiles(); 1242 personal_data_->web_profiles();
1244 EXPECT_EQ(0U, web_profiles.size()); 1243 EXPECT_EQ(0U, web_profiles.size());
1245 ASSERT_EQ(1U, auxiliary_profiles.size()); 1244 ASSERT_EQ(1U, auxiliary_profiles.size());
1246 EXPECT_EQ(0, auxiliary_profile->Compare(*auxiliary_profiles[0])); 1245 EXPECT_EQ(0, auxiliary_profile->Compare(*auxiliary_profiles[0]));
1247 } 1246 }
1248 1247
1249 TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) { 1248 TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) {
1250 FormData form1; 1249 FormData form1;
1251 1250
1252 // Start with a single valid credit card form. 1251 // Start with a single valid credit card form.
1253 webkit::forms::FormField field; 1252 FormFieldData field;
1254 autofill_test::CreateTestFormField( 1253 autofill_test::CreateTestFormField(
1255 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); 1254 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field);
1256 form1.fields.push_back(field); 1255 form1.fields.push_back(field);
1257 autofill_test::CreateTestFormField( 1256 autofill_test::CreateTestFormField(
1258 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); 1257 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field);
1259 form1.fields.push_back(field); 1258 form1.fields.push_back(field);
1260 autofill_test::CreateTestFormField( 1259 autofill_test::CreateTestFormField(
1261 "Exp Month:", "exp_month", "01", "text", &field); 1260 "Exp Month:", "exp_month", "01", "text", &field);
1262 form1.fields.push_back(field); 1261 form1.fields.push_back(field);
1263 autofill_test::CreateTestFormField( 1262 autofill_test::CreateTestFormField(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); 1318 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards();
1320 ASSERT_EQ(2U, results2.size()); 1319 ASSERT_EQ(2U, results2.size());
1321 EXPECT_EQ(0, expected.Compare(*results2[0])); 1320 EXPECT_EQ(0, expected.Compare(*results2[0]));
1322 EXPECT_EQ(0, expected2.Compare(*results2[1])); 1321 EXPECT_EQ(0, expected2.Compare(*results2[1]));
1323 } 1322 }
1324 1323
1325 TEST_F(PersonalDataManagerTest, AggregateInvalidCreditCard) { 1324 TEST_F(PersonalDataManagerTest, AggregateInvalidCreditCard) {
1326 FormData form1; 1325 FormData form1;
1327 1326
1328 // Start with a single valid credit card form. 1327 // Start with a single valid credit card form.
1329 webkit::forms::FormField field; 1328 FormFieldData field;
1330 autofill_test::CreateTestFormField( 1329 autofill_test::CreateTestFormField(
1331 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); 1330 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field);
1332 form1.fields.push_back(field); 1331 form1.fields.push_back(field);
1333 autofill_test::CreateTestFormField( 1332 autofill_test::CreateTestFormField(
1334 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); 1333 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field);
1335 form1.fields.push_back(field); 1334 form1.fields.push_back(field);
1336 autofill_test::CreateTestFormField( 1335 autofill_test::CreateTestFormField(
1337 "Exp Month:", "exp_month", "01", "text", &field); 1336 "Exp Month:", "exp_month", "01", "text", &field);
1338 form1.fields.push_back(field); 1337 form1.fields.push_back(field);
1339 autofill_test::CreateTestFormField( 1338 autofill_test::CreateTestFormField(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1385
1387 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); 1386 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards();
1388 ASSERT_EQ(1U, results2.size()); 1387 ASSERT_EQ(1U, results2.size());
1389 EXPECT_EQ(0, expected.Compare(*results2[0])); 1388 EXPECT_EQ(0, expected.Compare(*results2[0]));
1390 } 1389 }
1391 1390
1392 TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) { 1391 TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) {
1393 FormData form1; 1392 FormData form1;
1394 1393
1395 // Start with a single valid credit card form. 1394 // Start with a single valid credit card form.
1396 webkit::forms::FormField field; 1395 FormFieldData field;
1397 autofill_test::CreateTestFormField( 1396 autofill_test::CreateTestFormField(
1398 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); 1397 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field);
1399 form1.fields.push_back(field); 1398 form1.fields.push_back(field);
1400 autofill_test::CreateTestFormField( 1399 autofill_test::CreateTestFormField(
1401 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); 1400 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field);
1402 form1.fields.push_back(field); 1401 form1.fields.push_back(field);
1403 autofill_test::CreateTestFormField( 1402 autofill_test::CreateTestFormField(
1404 "Exp Month:", "exp_month", "01", "text", &field); 1403 "Exp Month:", "exp_month", "01", "text", &field);
1405 form1.fields.push_back(field); 1404 form1.fields.push_back(field);
1406 autofill_test::CreateTestFormField( 1405 autofill_test::CreateTestFormField(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 "Biggie Smalls", "4111111111111111", "01", "2012"); 1461 "Biggie Smalls", "4111111111111111", "01", "2012");
1463 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); 1462 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards();
1464 ASSERT_EQ(1U, results2.size()); 1463 ASSERT_EQ(1U, results2.size());
1465 EXPECT_EQ(0, expected2.Compare(*results2[0])); 1464 EXPECT_EQ(0, expected2.Compare(*results2[0]));
1466 } 1465 }
1467 1466
1468 TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) { 1467 TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) {
1469 FormData form1; 1468 FormData form1;
1470 1469
1471 // Start with a single valid credit card form. 1470 // Start with a single valid credit card form.
1472 webkit::forms::FormField field; 1471 FormFieldData field;
1473 autofill_test::CreateTestFormField( 1472 autofill_test::CreateTestFormField(
1474 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); 1473 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field);
1475 form1.fields.push_back(field); 1474 form1.fields.push_back(field);
1476 autofill_test::CreateTestFormField( 1475 autofill_test::CreateTestFormField(
1477 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); 1476 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field);
1478 form1.fields.push_back(field); 1477 form1.fields.push_back(field);
1479 autofill_test::CreateTestFormField( 1478 autofill_test::CreateTestFormField(
1480 "Exp Month:", "exp_month", "01", "text", &field); 1479 "Exp Month:", "exp_month", "01", "text", &field);
1481 form1.fields.push_back(field); 1480 form1.fields.push_back(field);
1482 autofill_test::CreateTestFormField( 1481 autofill_test::CreateTestFormField(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 "Biggie Smalls", "4111111111111111", "01", "2011"); 1529 "Biggie Smalls", "4111111111111111", "01", "2011");
1531 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); 1530 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards();
1532 ASSERT_EQ(1U, results2.size()); 1531 ASSERT_EQ(1U, results2.size());
1533 EXPECT_EQ(0, expected2.Compare(*results2[0])); 1532 EXPECT_EQ(0, expected2.Compare(*results2[0]));
1534 } 1533 }
1535 1534
1536 TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { 1535 TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) {
1537 FormData form1; 1536 FormData form1;
1538 1537
1539 // Start with a single valid credit card form. 1538 // Start with a single valid credit card form.
1540 webkit::forms::FormField field; 1539 FormFieldData field;
1541 autofill_test::CreateTestFormField( 1540 autofill_test::CreateTestFormField(
1542 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); 1541 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field);
1543 form1.fields.push_back(field); 1542 form1.fields.push_back(field);
1544 autofill_test::CreateTestFormField( 1543 autofill_test::CreateTestFormField(
1545 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); 1544 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field);
1546 form1.fields.push_back(field); 1545 form1.fields.push_back(field);
1547 autofill_test::CreateTestFormField( 1546 autofill_test::CreateTestFormField(
1548 "Exp Month:", "exp_month", "01", "text", &field); 1547 "Exp Month:", "exp_month", "01", "text", &field);
1549 form1.fields.push_back(field); 1548 form1.fields.push_back(field);
1550 autofill_test::CreateTestFormField( 1549 autofill_test::CreateTestFormField(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 MessageLoop::current()->Run(); 1645 MessageLoop::current()->Run();
1647 1646
1648 const std::vector<CreditCard*>& results1 = personal_data_->credit_cards(); 1647 const std::vector<CreditCard*>& results1 = personal_data_->credit_cards();
1649 ASSERT_EQ(1U, results1.size()); 1648 ASSERT_EQ(1U, results1.size());
1650 EXPECT_EQ(saved_credit_card, *results1[0]); 1649 EXPECT_EQ(saved_credit_card, *results1[0]);
1651 1650
1652 1651
1653 // Add a second different valid credit card where the year is different but 1652 // Add a second different valid credit card where the year is different but
1654 // the credit card number matches. 1653 // the credit card number matches.
1655 FormData form; 1654 FormData form;
1656 webkit::forms::FormField field; 1655 FormFieldData field;
1657 autofill_test::CreateTestFormField( 1656 autofill_test::CreateTestFormField(
1658 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); 1657 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field);
1659 form.fields.push_back(field); 1658 form.fields.push_back(field);
1660 autofill_test::CreateTestFormField( 1659 autofill_test::CreateTestFormField(
1661 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); 1660 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field);
1662 form.fields.push_back(field); 1661 form.fields.push_back(field);
1663 autofill_test::CreateTestFormField( 1662 autofill_test::CreateTestFormField(
1664 "Exp Month:", "exp_month", "01", "text", &field); 1663 "Exp Month:", "exp_month", "01", "text", &field);
1665 form.fields.push_back(field); 1664 form.fields.push_back(field);
1666 autofill_test::CreateTestFormField( 1665 autofill_test::CreateTestFormField(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 EXPECT_CALL(personal_data_observer_, 1702 EXPECT_CALL(personal_data_observer_,
1704 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 1703 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
1705 MessageLoop::current()->Run(); 1704 MessageLoop::current()->Run();
1706 1705
1707 const std::vector<CreditCard*>& results1 = personal_data_->credit_cards(); 1706 const std::vector<CreditCard*>& results1 = personal_data_->credit_cards();
1708 ASSERT_EQ(1U, results1.size()); 1707 ASSERT_EQ(1U, results1.size());
1709 EXPECT_EQ(0, saved_credit_card.Compare(*results1[0])); 1708 EXPECT_EQ(0, saved_credit_card.Compare(*results1[0]));
1710 1709
1711 // Import the same card info, but with different separators in the number. 1710 // Import the same card info, but with different separators in the number.
1712 FormData form; 1711 FormData form;
1713 webkit::forms::FormField field; 1712 FormFieldData field;
1714 autofill_test::CreateTestFormField( 1713 autofill_test::CreateTestFormField(
1715 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); 1714 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field);
1716 form.fields.push_back(field); 1715 form.fields.push_back(field);
1717 autofill_test::CreateTestFormField( 1716 autofill_test::CreateTestFormField(
1718 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); 1717 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field);
1719 form.fields.push_back(field); 1718 form.fields.push_back(field);
1720 autofill_test::CreateTestFormField( 1719 autofill_test::CreateTestFormField(
1721 "Exp Month:", "exp_month", "01", "text", &field); 1720 "Exp Month:", "exp_month", "01", "text", &field);
1722 form.fields.push_back(field); 1721 form.fields.push_back(field);
1723 autofill_test::CreateTestFormField( 1722 autofill_test::CreateTestFormField(
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); 1856 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER));
1858 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); 1857 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH));
1859 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); 1858 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR));
1860 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); 1859 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR));
1861 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); 1860 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR));
1862 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); 1861 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR));
1863 } 1862 }
1864 1863
1865 TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { 1864 TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) {
1866 FormData form1; 1865 FormData form1;
1867 webkit::forms::FormField field; 1866 FormFieldData field;
1868 autofill_test::CreateTestFormField( 1867 autofill_test::CreateTestFormField(
1869 "First name:", "first_name", "George", "text", &field); 1868 "First name:", "first_name", "George", "text", &field);
1870 form1.fields.push_back(field); 1869 form1.fields.push_back(field);
1871 autofill_test::CreateTestFormField( 1870 autofill_test::CreateTestFormField(
1872 "Last name:", "last_name", "Washington", "text", &field); 1871 "Last name:", "last_name", "Washington", "text", &field);
1873 form1.fields.push_back(field); 1872 form1.fields.push_back(field);
1874 autofill_test::CreateTestFormField( 1873 autofill_test::CreateTestFormField(
1875 "Email:", "email", "theprez@gmail.com", "text", &field); 1874 "Email:", "email", "theprez@gmail.com", "text", &field);
1876 form1.fields.push_back(field); 1875 form1.fields.push_back(field);
1877 autofill_test::CreateTestFormField( 1876 autofill_test::CreateTestFormField(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 1951
1953 // Modify expected to include multi-valued fields. 1952 // Modify expected to include multi-valued fields.
1954 std::vector<string16> values; 1953 std::vector<string16> values;
1955 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); 1954 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values);
1956 values.push_back(ASCIIToUTF16("214-555-1234")); 1955 values.push_back(ASCIIToUTF16("214-555-1234"));
1957 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); 1956 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values);
1958 1957
1959 ASSERT_EQ(1U, results2.size()); 1958 ASSERT_EQ(1U, results2.size());
1960 EXPECT_EQ(0, expected.Compare(*results2[0])); 1959 EXPECT_EQ(0, expected.Compare(*results2[0]));
1961 } 1960 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/password_autofill_manager_unittest.cc ('k') | chrome/browser/autofill/phone_field_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698