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