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

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

Powered by Google App Engine
This is Rietveld 408576698