OLD | NEW |
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" |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 form.fields.push_back(field); | 511 form.fields.push_back(field); |
512 autofill_test::CreateTestFormField( | 512 autofill_test::CreateTestFormField( |
513 "City:", "city", "San Francisco", "text", &field); | 513 "City:", "city", "San Francisco", "text", &field); |
514 form.fields.push_back(field); | 514 form.fields.push_back(field); |
515 autofill_test::CreateTestFormField( | 515 autofill_test::CreateTestFormField( |
516 "State:", "state", "California", "text", &field); | 516 "State:", "state", "California", "text", &field); |
517 form.fields.push_back(field); | 517 form.fields.push_back(field); |
518 autofill_test::CreateTestFormField( | 518 autofill_test::CreateTestFormField( |
519 "Zip:", "zip", "94102", "text", &field); | 519 "Zip:", "zip", "94102", "text", &field); |
520 form.fields.push_back(field); | 520 form.fields.push_back(field); |
521 FormStructure form_structure(form); | 521 FormStructure form_structure(form, std::string()); |
522 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); | 522 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); |
523 const CreditCard* imported_credit_card; | 523 const CreditCard* imported_credit_card; |
524 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, | 524 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, |
525 &imported_credit_card)); | 525 &imported_credit_card)); |
526 ASSERT_FALSE(imported_credit_card); | 526 ASSERT_FALSE(imported_credit_card); |
527 | 527 |
528 // Verify that the web database has been updated and the notification sent. | 528 // Verify that the web database has been updated and the notification sent. |
529 EXPECT_CALL(personal_data_observer_, | 529 EXPECT_CALL(personal_data_observer_, |
530 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 530 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
531 MessageLoop::current()->Run(); | 531 MessageLoop::current()->Run(); |
(...skipping 24 matching lines...) Expand all Loading... |
556 form.fields.push_back(field); | 556 form.fields.push_back(field); |
557 autofill_test::CreateTestFormField( | 557 autofill_test::CreateTestFormField( |
558 "City:", "city", "San Francisco", "text", &field); | 558 "City:", "city", "San Francisco", "text", &field); |
559 form.fields.push_back(field); | 559 form.fields.push_back(field); |
560 autofill_test::CreateTestFormField( | 560 autofill_test::CreateTestFormField( |
561 "State:", "state", "California", "text", &field); | 561 "State:", "state", "California", "text", &field); |
562 form.fields.push_back(field); | 562 form.fields.push_back(field); |
563 autofill_test::CreateTestFormField( | 563 autofill_test::CreateTestFormField( |
564 "Zip:", "zip", "94102", "text", &field); | 564 "Zip:", "zip", "94102", "text", &field); |
565 form.fields.push_back(field); | 565 form.fields.push_back(field); |
566 FormStructure form_structure(form); | 566 FormStructure form_structure(form, std::string()); |
567 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); | 567 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); |
568 const CreditCard* imported_credit_card; | 568 const CreditCard* imported_credit_card; |
569 EXPECT_FALSE(personal_data_->ImportFormData(form_structure, | 569 EXPECT_FALSE(personal_data_->ImportFormData(form_structure, |
570 &imported_credit_card)); | 570 &imported_credit_card)); |
571 ASSERT_EQ(static_cast<CreditCard*>(NULL), imported_credit_card); | 571 ASSERT_EQ(static_cast<CreditCard*>(NULL), imported_credit_card); |
572 | 572 |
573 const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); | 573 const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); |
574 ASSERT_EQ(0U, results.size()); | 574 ASSERT_EQ(0U, results.size()); |
575 } | 575 } |
576 | 576 |
577 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { | 577 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { |
578 FormData form; | 578 FormData form; |
579 FormFieldData field; | 579 FormFieldData field; |
580 autofill_test::CreateTestFormField( | 580 autofill_test::CreateTestFormField( |
581 "First name:", "first_name", "George", "text", &field); | 581 "First name:", "first_name", "George", "text", &field); |
582 form.fields.push_back(field); | 582 form.fields.push_back(field); |
583 autofill_test::CreateTestFormField( | 583 autofill_test::CreateTestFormField( |
584 "Last name:", "last_name", "Washington", "text", &field); | 584 "Last name:", "last_name", "Washington", "text", &field); |
585 form.fields.push_back(field); | 585 form.fields.push_back(field); |
586 autofill_test::CreateTestFormField( | 586 autofill_test::CreateTestFormField( |
587 "Card number:", "card_number", "4111 1111 1111 1111", "text", &field); | 587 "Card number:", "card_number", "4111 1111 1111 1111", "text", &field); |
588 form.fields.push_back(field); | 588 form.fields.push_back(field); |
589 FormStructure form_structure(form); | 589 FormStructure form_structure(form, std::string()); |
590 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); | 590 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); |
591 const CreditCard* imported_credit_card; | 591 const CreditCard* imported_credit_card; |
592 EXPECT_FALSE(personal_data_->ImportFormData(form_structure, | 592 EXPECT_FALSE(personal_data_->ImportFormData(form_structure, |
593 &imported_credit_card)); | 593 &imported_credit_card)); |
594 ASSERT_FALSE(imported_credit_card); | 594 ASSERT_FALSE(imported_credit_card); |
595 | 595 |
596 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); | 596 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); |
597 ASSERT_EQ(0U, profiles.size()); | 597 ASSERT_EQ(0U, profiles.size()); |
598 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); | 598 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); |
599 ASSERT_EQ(0U, credit_cards.size()); | 599 ASSERT_EQ(0U, credit_cards.size()); |
(...skipping 25 matching lines...) Expand all Loading... |
625 form.fields.push_back(field); | 625 form.fields.push_back(field); |
626 autofill_test::CreateTestFormField( | 626 autofill_test::CreateTestFormField( |
627 "City:", "city", "San Francisco", "text", &field); | 627 "City:", "city", "San Francisco", "text", &field); |
628 form.fields.push_back(field); | 628 form.fields.push_back(field); |
629 autofill_test::CreateTestFormField( | 629 autofill_test::CreateTestFormField( |
630 "State:", "state", "California", "text", &field); | 630 "State:", "state", "California", "text", &field); |
631 form.fields.push_back(field); | 631 form.fields.push_back(field); |
632 autofill_test::CreateTestFormField( | 632 autofill_test::CreateTestFormField( |
633 "Zip:", "zip", "94102", "text", &field); | 633 "Zip:", "zip", "94102", "text", &field); |
634 form.fields.push_back(field); | 634 form.fields.push_back(field); |
635 FormStructure form_structure(form); | 635 FormStructure form_structure(form, std::string()); |
636 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); | 636 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); |
637 const CreditCard* imported_credit_card; | 637 const CreditCard* imported_credit_card; |
638 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, | 638 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, |
639 &imported_credit_card)); | 639 &imported_credit_card)); |
640 ASSERT_FALSE(imported_credit_card); | 640 ASSERT_FALSE(imported_credit_card); |
641 | 641 |
642 // Verify that the web database has been updated and the notification sent. | 642 // Verify that the web database has been updated and the notification sent. |
643 EXPECT_CALL(personal_data_observer_, | 643 EXPECT_CALL(personal_data_observer_, |
644 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 644 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
645 MessageLoop::current()->Run(); | 645 MessageLoop::current()->Run(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 autofill_test::CreateTestFormField( | 708 autofill_test::CreateTestFormField( |
709 "City:", "city", "San Francisco", "text", &field); | 709 "City:", "city", "San Francisco", "text", &field); |
710 form1.fields.push_back(field); | 710 form1.fields.push_back(field); |
711 autofill_test::CreateTestFormField( | 711 autofill_test::CreateTestFormField( |
712 "State:", "state", "California", "text", &field); | 712 "State:", "state", "California", "text", &field); |
713 form1.fields.push_back(field); | 713 form1.fields.push_back(field); |
714 autofill_test::CreateTestFormField( | 714 autofill_test::CreateTestFormField( |
715 "Zip:", "zip", "94102", "text", &field); | 715 "Zip:", "zip", "94102", "text", &field); |
716 form1.fields.push_back(field); | 716 form1.fields.push_back(field); |
717 | 717 |
718 FormStructure form_structure1(form1); | 718 FormStructure form_structure1(form1, std::string()); |
719 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 719 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
720 const CreditCard* imported_credit_card; | 720 const CreditCard* imported_credit_card; |
721 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 721 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
722 &imported_credit_card)); | 722 &imported_credit_card)); |
723 ASSERT_FALSE(imported_credit_card); | 723 ASSERT_FALSE(imported_credit_card); |
724 | 724 |
725 // Verify that the web database has been updated and the notification sent. | 725 // Verify that the web database has been updated and the notification sent. |
726 EXPECT_CALL(personal_data_observer_, | 726 EXPECT_CALL(personal_data_observer_, |
727 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 727 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
728 MessageLoop::current()->Run(); | 728 MessageLoop::current()->Run(); |
(...skipping 23 matching lines...) Expand all Loading... |
752 autofill_test::CreateTestFormField( | 752 autofill_test::CreateTestFormField( |
753 "City:", "city", "San Francisco", "text", &field); | 753 "City:", "city", "San Francisco", "text", &field); |
754 form2.fields.push_back(field); | 754 form2.fields.push_back(field); |
755 autofill_test::CreateTestFormField( | 755 autofill_test::CreateTestFormField( |
756 "State:", "state", "California", "text", &field); | 756 "State:", "state", "California", "text", &field); |
757 form2.fields.push_back(field); | 757 form2.fields.push_back(field); |
758 autofill_test::CreateTestFormField( | 758 autofill_test::CreateTestFormField( |
759 "Zip:", "zip", "94102", "text", &field); | 759 "Zip:", "zip", "94102", "text", &field); |
760 form2.fields.push_back(field); | 760 form2.fields.push_back(field); |
761 | 761 |
762 FormStructure form_structure2(form2); | 762 FormStructure form_structure2(form2, std::string()); |
763 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 763 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
764 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 764 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
765 &imported_credit_card)); | 765 &imported_credit_card)); |
766 ASSERT_FALSE(imported_credit_card); | 766 ASSERT_FALSE(imported_credit_card); |
767 | 767 |
768 // Verify that the web database has been updated and the notification sent. | 768 // Verify that the web database has been updated and the notification sent. |
769 EXPECT_CALL(personal_data_observer_, | 769 EXPECT_CALL(personal_data_observer_, |
770 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 770 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
771 MessageLoop::current()->Run(); | 771 MessageLoop::current()->Run(); |
772 | 772 |
(...skipping 26 matching lines...) Expand all Loading... |
799 autofill_test::CreateTestFormField( | 799 autofill_test::CreateTestFormField( |
800 "City:", "city", "San Francisco", "text", &field); | 800 "City:", "city", "San Francisco", "text", &field); |
801 form1.fields.push_back(field); | 801 form1.fields.push_back(field); |
802 autofill_test::CreateTestFormField( | 802 autofill_test::CreateTestFormField( |
803 "State:", "state", "California", "text", &field); | 803 "State:", "state", "California", "text", &field); |
804 form1.fields.push_back(field); | 804 form1.fields.push_back(field); |
805 autofill_test::CreateTestFormField( | 805 autofill_test::CreateTestFormField( |
806 "Zip:", "zip", "94102", "text", &field); | 806 "Zip:", "zip", "94102", "text", &field); |
807 form1.fields.push_back(field); | 807 form1.fields.push_back(field); |
808 | 808 |
809 FormStructure form_structure1(form1); | 809 FormStructure form_structure1(form1, std::string()); |
810 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 810 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
811 const CreditCard* imported_credit_card; | 811 const CreditCard* imported_credit_card; |
812 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 812 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
813 &imported_credit_card)); | 813 &imported_credit_card)); |
814 ASSERT_FALSE(imported_credit_card); | 814 ASSERT_FALSE(imported_credit_card); |
815 | 815 |
816 // Verify that the web database has been updated and the notification sent. | 816 // Verify that the web database has been updated and the notification sent. |
817 EXPECT_CALL(personal_data_observer_, | 817 EXPECT_CALL(personal_data_observer_, |
818 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 818 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
819 MessageLoop::current()->Run(); | 819 MessageLoop::current()->Run(); |
(...skipping 23 matching lines...) Expand all Loading... |
843 autofill_test::CreateTestFormField( | 843 autofill_test::CreateTestFormField( |
844 "City:", "city", "San Francisco", "text", &field); | 844 "City:", "city", "San Francisco", "text", &field); |
845 form2.fields.push_back(field); | 845 form2.fields.push_back(field); |
846 autofill_test::CreateTestFormField( | 846 autofill_test::CreateTestFormField( |
847 "State:", "state", "California", "text", &field); | 847 "State:", "state", "California", "text", &field); |
848 form2.fields.push_back(field); | 848 form2.fields.push_back(field); |
849 autofill_test::CreateTestFormField( | 849 autofill_test::CreateTestFormField( |
850 "Zip:", "zip", "94102", "text", &field); | 850 "Zip:", "zip", "94102", "text", &field); |
851 form2.fields.push_back(field); | 851 form2.fields.push_back(field); |
852 | 852 |
853 FormStructure form_structure2(form2); | 853 FormStructure form_structure2(form2, std::string()); |
854 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 854 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
855 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 855 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
856 &imported_credit_card)); | 856 &imported_credit_card)); |
857 ASSERT_FALSE(imported_credit_card); | 857 ASSERT_FALSE(imported_credit_card); |
858 | 858 |
859 // Verify that the web database has been updated and the notification sent. | 859 // Verify that the web database has been updated and the notification sent. |
860 EXPECT_CALL(personal_data_observer_, | 860 EXPECT_CALL(personal_data_observer_, |
861 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 861 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
862 MessageLoop::current()->Run(); | 862 MessageLoop::current()->Run(); |
863 | 863 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 autofill_test::CreateTestFormField( | 900 autofill_test::CreateTestFormField( |
901 "Zip:", "zip", "94102", "text", &field); | 901 "Zip:", "zip", "94102", "text", &field); |
902 form1.fields.push_back(field); | 902 form1.fields.push_back(field); |
903 autofill_test::CreateTestFormField( | 903 autofill_test::CreateTestFormField( |
904 "Email:", "email", "theprez@gmail.com", "text", &field); | 904 "Email:", "email", "theprez@gmail.com", "text", &field); |
905 form1.fields.push_back(field); | 905 form1.fields.push_back(field); |
906 autofill_test::CreateTestFormField( | 906 autofill_test::CreateTestFormField( |
907 "Phone:", "phone", "6505556666", "text", &field); | 907 "Phone:", "phone", "6505556666", "text", &field); |
908 form1.fields.push_back(field); | 908 form1.fields.push_back(field); |
909 | 909 |
910 FormStructure form_structure1(form1); | 910 FormStructure form_structure1(form1, std::string()); |
911 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 911 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
912 const CreditCard* imported_credit_card; | 912 const CreditCard* imported_credit_card; |
913 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 913 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
914 &imported_credit_card)); | 914 &imported_credit_card)); |
915 ASSERT_FALSE(imported_credit_card); | 915 ASSERT_FALSE(imported_credit_card); |
916 | 916 |
917 // Verify that the web database has been updated and the notification sent. | 917 // Verify that the web database has been updated and the notification sent. |
918 EXPECT_CALL(personal_data_observer_, | 918 EXPECT_CALL(personal_data_observer_, |
919 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 919 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
920 MessageLoop::current()->Run(); | 920 MessageLoop::current()->Run(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 form2.fields.push_back(field); | 956 form2.fields.push_back(field); |
957 // Country gets added. | 957 // Country gets added. |
958 autofill_test::CreateTestFormField( | 958 autofill_test::CreateTestFormField( |
959 "Country:", "country", "USA", "text", &field); | 959 "Country:", "country", "USA", "text", &field); |
960 form2.fields.push_back(field); | 960 form2.fields.push_back(field); |
961 // Phone gets updated. | 961 // Phone gets updated. |
962 autofill_test::CreateTestFormField( | 962 autofill_test::CreateTestFormField( |
963 "Phone:", "phone", "6502231234", "text", &field); | 963 "Phone:", "phone", "6502231234", "text", &field); |
964 form2.fields.push_back(field); | 964 form2.fields.push_back(field); |
965 | 965 |
966 FormStructure form_structure2(form2); | 966 FormStructure form_structure2(form2, std::string()); |
967 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 967 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
968 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 968 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
969 &imported_credit_card)); | 969 &imported_credit_card)); |
970 ASSERT_FALSE(imported_credit_card); | 970 ASSERT_FALSE(imported_credit_card); |
971 | 971 |
972 // Verify that the web database has been updated and the notification sent. | 972 // Verify that the web database has been updated and the notification sent. |
973 EXPECT_CALL(personal_data_observer_, | 973 EXPECT_CALL(personal_data_observer_, |
974 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 974 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
975 MessageLoop::current()->Run(); | 975 MessageLoop::current()->Run(); |
976 | 976 |
(...skipping 24 matching lines...) Expand all Loading... |
1001 autofill_test::CreateTestFormField( | 1001 autofill_test::CreateTestFormField( |
1002 "City:", "city", "Philadelphia", "text", &field); | 1002 "City:", "city", "Philadelphia", "text", &field); |
1003 form1.fields.push_back(field); | 1003 form1.fields.push_back(field); |
1004 autofill_test::CreateTestFormField( | 1004 autofill_test::CreateTestFormField( |
1005 "State:", "state", "Pennsylvania", "text", &field); | 1005 "State:", "state", "Pennsylvania", "text", &field); |
1006 form1.fields.push_back(field); | 1006 form1.fields.push_back(field); |
1007 autofill_test::CreateTestFormField( | 1007 autofill_test::CreateTestFormField( |
1008 "Zip:", "zipcode", "19106", "text", &field); | 1008 "Zip:", "zipcode", "19106", "text", &field); |
1009 form1.fields.push_back(field); | 1009 form1.fields.push_back(field); |
1010 | 1010 |
1011 FormStructure form_structure1(form1); | 1011 FormStructure form_structure1(form1, std::string()); |
1012 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1012 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1013 const CreditCard* imported_credit_card; | 1013 const CreditCard* imported_credit_card; |
1014 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1014 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
1015 &imported_credit_card)); | 1015 &imported_credit_card)); |
1016 EXPECT_FALSE(imported_credit_card); | 1016 EXPECT_FALSE(imported_credit_card); |
1017 | 1017 |
1018 // Verify that the web database has been updated and the notification sent. | 1018 // Verify that the web database has been updated and the notification sent. |
1019 EXPECT_CALL(personal_data_observer_, | 1019 EXPECT_CALL(personal_data_observer_, |
1020 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1020 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1021 MessageLoop::current()->Run(); | 1021 MessageLoop::current()->Run(); |
(...skipping 23 matching lines...) Expand all Loading... |
1045 autofill_test::CreateTestFormField( | 1045 autofill_test::CreateTestFormField( |
1046 "City:", "city", "Philadelphia", "text", &field); | 1046 "City:", "city", "Philadelphia", "text", &field); |
1047 form2.fields.push_back(field); | 1047 form2.fields.push_back(field); |
1048 autofill_test::CreateTestFormField( | 1048 autofill_test::CreateTestFormField( |
1049 "State:", "state", "Pennsylvania", "text", &field); | 1049 "State:", "state", "Pennsylvania", "text", &field); |
1050 form2.fields.push_back(field); | 1050 form2.fields.push_back(field); |
1051 autofill_test::CreateTestFormField( | 1051 autofill_test::CreateTestFormField( |
1052 "Zip:", "zipcode", "19106", "text", &field); | 1052 "Zip:", "zipcode", "19106", "text", &field); |
1053 form2.fields.push_back(field); | 1053 form2.fields.push_back(field); |
1054 | 1054 |
1055 FormStructure form_structure2(form2); | 1055 FormStructure form_structure2(form2, std::string()); |
1056 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 1056 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
1057 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 1057 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
1058 &imported_credit_card)); | 1058 &imported_credit_card)); |
1059 ASSERT_FALSE(imported_credit_card); | 1059 ASSERT_FALSE(imported_credit_card); |
1060 | 1060 |
1061 // Verify that the web database has been updated and the notification sent. | 1061 // Verify that the web database has been updated and the notification sent. |
1062 EXPECT_CALL(personal_data_observer_, | 1062 EXPECT_CALL(personal_data_observer_, |
1063 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1063 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1064 MessageLoop::current()->Run(); | 1064 MessageLoop::current()->Run(); |
1065 | 1065 |
(...skipping 28 matching lines...) Expand all Loading... |
1094 autofill_test::CreateTestFormField( | 1094 autofill_test::CreateTestFormField( |
1095 "City:", "city", "Philadelphia", "text", &field); | 1095 "City:", "city", "Philadelphia", "text", &field); |
1096 form1.fields.push_back(field); | 1096 form1.fields.push_back(field); |
1097 autofill_test::CreateTestFormField( | 1097 autofill_test::CreateTestFormField( |
1098 "State:", "state", "Pennsylvania", "text", &field); | 1098 "State:", "state", "Pennsylvania", "text", &field); |
1099 form1.fields.push_back(field); | 1099 form1.fields.push_back(field); |
1100 autofill_test::CreateTestFormField( | 1100 autofill_test::CreateTestFormField( |
1101 "Zip:", "zipcode", "19106", "text", &field); | 1101 "Zip:", "zipcode", "19106", "text", &field); |
1102 form1.fields.push_back(field); | 1102 form1.fields.push_back(field); |
1103 | 1103 |
1104 FormStructure form_structure1(form1); | 1104 FormStructure form_structure1(form1, std::string()); |
1105 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1105 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1106 const CreditCard* imported_credit_card; | 1106 const CreditCard* imported_credit_card; |
1107 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1107 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
1108 &imported_credit_card)); | 1108 &imported_credit_card)); |
1109 ASSERT_FALSE(imported_credit_card); | 1109 ASSERT_FALSE(imported_credit_card); |
1110 | 1110 |
1111 // Verify that the web database has been updated and the notification sent. | 1111 // Verify that the web database has been updated and the notification sent. |
1112 EXPECT_CALL(personal_data_observer_, | 1112 EXPECT_CALL(personal_data_observer_, |
1113 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1113 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1114 MessageLoop::current()->Run(); | 1114 MessageLoop::current()->Run(); |
(...skipping 24 matching lines...) Expand all Loading... |
1139 autofill_test::CreateTestFormField( | 1139 autofill_test::CreateTestFormField( |
1140 "City:", "city", "Philadelphia", "text", &field); | 1140 "City:", "city", "Philadelphia", "text", &field); |
1141 form2.fields.push_back(field); | 1141 form2.fields.push_back(field); |
1142 autofill_test::CreateTestFormField( | 1142 autofill_test::CreateTestFormField( |
1143 "State:", "state", "Pennsylvania", "text", &field); | 1143 "State:", "state", "Pennsylvania", "text", &field); |
1144 form2.fields.push_back(field); | 1144 form2.fields.push_back(field); |
1145 autofill_test::CreateTestFormField( | 1145 autofill_test::CreateTestFormField( |
1146 "Zip:", "zipcode", "19106", "text", &field); | 1146 "Zip:", "zipcode", "19106", "text", &field); |
1147 form2.fields.push_back(field); | 1147 form2.fields.push_back(field); |
1148 | 1148 |
1149 FormStructure form_structure2(form2); | 1149 FormStructure form_structure2(form2, std::string()); |
1150 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 1150 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
1151 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 1151 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
1152 &imported_credit_card)); | 1152 &imported_credit_card)); |
1153 ASSERT_FALSE(imported_credit_card); | 1153 ASSERT_FALSE(imported_credit_card); |
1154 | 1154 |
1155 // Verify that the web database has been updated and the notification sent. | 1155 // Verify that the web database has been updated and the notification sent. |
1156 EXPECT_CALL(personal_data_observer_, | 1156 EXPECT_CALL(personal_data_observer_, |
1157 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1157 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1158 MessageLoop::current()->Run(); | 1158 MessageLoop::current()->Run(); |
1159 | 1159 |
(...skipping 19 matching lines...) Expand all Loading... |
1179 autofill_test::CreateTestFormField( | 1179 autofill_test::CreateTestFormField( |
1180 "Email:", "email", "theprez@gmail.com", "text", &field); | 1180 "Email:", "email", "theprez@gmail.com", "text", &field); |
1181 form1.fields.push_back(field); | 1181 form1.fields.push_back(field); |
1182 autofill_test::CreateTestFormField( | 1182 autofill_test::CreateTestFormField( |
1183 "Address Line 1:", "address", "190 High Street", "text", &field); | 1183 "Address Line 1:", "address", "190 High Street", "text", &field); |
1184 form1.fields.push_back(field); | 1184 form1.fields.push_back(field); |
1185 autofill_test::CreateTestFormField( | 1185 autofill_test::CreateTestFormField( |
1186 "City:", "city", "Philadelphia", "text", &field); | 1186 "City:", "city", "Philadelphia", "text", &field); |
1187 form1.fields.push_back(field); | 1187 form1.fields.push_back(field); |
1188 | 1188 |
1189 FormStructure form_structure1(form1); | 1189 FormStructure form_structure1(form1, std::string()); |
1190 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1190 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1191 const CreditCard* imported_credit_card; | 1191 const CreditCard* imported_credit_card; |
1192 EXPECT_FALSE(personal_data_->ImportFormData(form_structure1, | 1192 EXPECT_FALSE(personal_data_->ImportFormData(form_structure1, |
1193 &imported_credit_card)); | 1193 &imported_credit_card)); |
1194 ASSERT_FALSE(imported_credit_card); | 1194 ASSERT_FALSE(imported_credit_card); |
1195 | 1195 |
1196 // Note: no refresh here. | 1196 // Note: no refresh here. |
1197 | 1197 |
1198 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); | 1198 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); |
1199 ASSERT_EQ(0U, profiles.size()); | 1199 ASSERT_EQ(0U, profiles.size()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 autofill_test::CreateTestFormField( | 1235 autofill_test::CreateTestFormField( |
1236 "State:", "state", "CA", "text", &field); | 1236 "State:", "state", "CA", "text", &field); |
1237 form.fields.push_back(field); | 1237 form.fields.push_back(field); |
1238 autofill_test::CreateTestFormField( | 1238 autofill_test::CreateTestFormField( |
1239 "Zip:", "zip", "94102", "text", &field); | 1239 "Zip:", "zip", "94102", "text", &field); |
1240 form.fields.push_back(field); | 1240 form.fields.push_back(field); |
1241 autofill_test::CreateTestFormField( | 1241 autofill_test::CreateTestFormField( |
1242 "Phone:", "phone", "4158889999", "text", &field); | 1242 "Phone:", "phone", "4158889999", "text", &field); |
1243 form.fields.push_back(field); | 1243 form.fields.push_back(field); |
1244 | 1244 |
1245 FormStructure form_structure(form); | 1245 FormStructure form_structure(form, std::string()); |
1246 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); | 1246 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); |
1247 const CreditCard* imported_credit_card; | 1247 const CreditCard* imported_credit_card; |
1248 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, | 1248 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, |
1249 &imported_credit_card)); | 1249 &imported_credit_card)); |
1250 EXPECT_FALSE(imported_credit_card); | 1250 EXPECT_FALSE(imported_credit_card); |
1251 | 1251 |
1252 // Note: No refresh. | 1252 // Note: No refresh. |
1253 | 1253 |
1254 // Expect no change. | 1254 // Expect no change. |
1255 const std::vector<AutofillProfile*>& web_profiles = | 1255 const std::vector<AutofillProfile*>& web_profiles = |
(...skipping 14 matching lines...) Expand all Loading... |
1270 autofill_test::CreateTestFormField( | 1270 autofill_test::CreateTestFormField( |
1271 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); | 1271 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); |
1272 form1.fields.push_back(field); | 1272 form1.fields.push_back(field); |
1273 autofill_test::CreateTestFormField( | 1273 autofill_test::CreateTestFormField( |
1274 "Exp Month:", "exp_month", "01", "text", &field); | 1274 "Exp Month:", "exp_month", "01", "text", &field); |
1275 form1.fields.push_back(field); | 1275 form1.fields.push_back(field); |
1276 autofill_test::CreateTestFormField( | 1276 autofill_test::CreateTestFormField( |
1277 "Exp Year:", "exp_year", "2011", "text", &field); | 1277 "Exp Year:", "exp_year", "2011", "text", &field); |
1278 form1.fields.push_back(field); | 1278 form1.fields.push_back(field); |
1279 | 1279 |
1280 FormStructure form_structure1(form1); | 1280 FormStructure form_structure1(form1, std::string()); |
1281 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1281 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1282 const CreditCard* imported_credit_card; | 1282 const CreditCard* imported_credit_card; |
1283 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1283 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
1284 &imported_credit_card)); | 1284 &imported_credit_card)); |
1285 ASSERT_TRUE(imported_credit_card); | 1285 ASSERT_TRUE(imported_credit_card); |
1286 personal_data_->SaveImportedCreditCard(*imported_credit_card); | 1286 personal_data_->SaveImportedCreditCard(*imported_credit_card); |
1287 delete imported_credit_card; | 1287 delete imported_credit_card; |
1288 | 1288 |
1289 // Verify that the web database has been updated and the notification sent. | 1289 // Verify that the web database has been updated and the notification sent. |
1290 EXPECT_CALL(personal_data_observer_, | 1290 EXPECT_CALL(personal_data_observer_, |
(...skipping 15 matching lines...) Expand all Loading... |
1306 autofill_test::CreateTestFormField( | 1306 autofill_test::CreateTestFormField( |
1307 "Card Number:", "card_number", "5500 0000 0000 0004", "text", &field); | 1307 "Card Number:", "card_number", "5500 0000 0000 0004", "text", &field); |
1308 form2.fields.push_back(field); | 1308 form2.fields.push_back(field); |
1309 autofill_test::CreateTestFormField( | 1309 autofill_test::CreateTestFormField( |
1310 "Exp Month:", "exp_month", "02", "text", &field); | 1310 "Exp Month:", "exp_month", "02", "text", &field); |
1311 form2.fields.push_back(field); | 1311 form2.fields.push_back(field); |
1312 autofill_test::CreateTestFormField( | 1312 autofill_test::CreateTestFormField( |
1313 "Exp Year:", "exp_year", "2012", "text", &field); | 1313 "Exp Year:", "exp_year", "2012", "text", &field); |
1314 form2.fields.push_back(field); | 1314 form2.fields.push_back(field); |
1315 | 1315 |
1316 FormStructure form_structure2(form2); | 1316 FormStructure form_structure2(form2, std::string()); |
1317 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 1317 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
1318 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 1318 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
1319 &imported_credit_card)); | 1319 &imported_credit_card)); |
1320 ASSERT_TRUE(imported_credit_card); | 1320 ASSERT_TRUE(imported_credit_card); |
1321 personal_data_->SaveImportedCreditCard(*imported_credit_card); | 1321 personal_data_->SaveImportedCreditCard(*imported_credit_card); |
1322 delete imported_credit_card; | 1322 delete imported_credit_card; |
1323 | 1323 |
1324 // Verify that the web database has been updated and the notification sent. | 1324 // Verify that the web database has been updated and the notification sent. |
1325 EXPECT_CALL(personal_data_observer_, | 1325 EXPECT_CALL(personal_data_observer_, |
1326 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1326 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
(...skipping 19 matching lines...) Expand all Loading... |
1346 autofill_test::CreateTestFormField( | 1346 autofill_test::CreateTestFormField( |
1347 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); | 1347 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); |
1348 form1.fields.push_back(field); | 1348 form1.fields.push_back(field); |
1349 autofill_test::CreateTestFormField( | 1349 autofill_test::CreateTestFormField( |
1350 "Exp Month:", "exp_month", "01", "text", &field); | 1350 "Exp Month:", "exp_month", "01", "text", &field); |
1351 form1.fields.push_back(field); | 1351 form1.fields.push_back(field); |
1352 autofill_test::CreateTestFormField( | 1352 autofill_test::CreateTestFormField( |
1353 "Exp Year:", "exp_year", "2011", "text", &field); | 1353 "Exp Year:", "exp_year", "2011", "text", &field); |
1354 form1.fields.push_back(field); | 1354 form1.fields.push_back(field); |
1355 | 1355 |
1356 FormStructure form_structure1(form1); | 1356 FormStructure form_structure1(form1, std::string()); |
1357 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1357 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1358 const CreditCard* imported_credit_card; | 1358 const CreditCard* imported_credit_card; |
1359 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1359 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
1360 &imported_credit_card)); | 1360 &imported_credit_card)); |
1361 ASSERT_TRUE(imported_credit_card); | 1361 ASSERT_TRUE(imported_credit_card); |
1362 personal_data_->SaveImportedCreditCard(*imported_credit_card); | 1362 personal_data_->SaveImportedCreditCard(*imported_credit_card); |
1363 delete imported_credit_card; | 1363 delete imported_credit_card; |
1364 | 1364 |
1365 // Verify that the web database has been updated and the notification sent. | 1365 // Verify that the web database has been updated and the notification sent. |
1366 EXPECT_CALL(personal_data_observer_, | 1366 EXPECT_CALL(personal_data_observer_, |
(...skipping 15 matching lines...) Expand all Loading... |
1382 autofill_test::CreateTestFormField( | 1382 autofill_test::CreateTestFormField( |
1383 "Card Number:", "card_number", "1000000000000000", "text", &field); | 1383 "Card Number:", "card_number", "1000000000000000", "text", &field); |
1384 form2.fields.push_back(field); | 1384 form2.fields.push_back(field); |
1385 autofill_test::CreateTestFormField( | 1385 autofill_test::CreateTestFormField( |
1386 "Exp Month:", "exp_month", "02", "text", &field); | 1386 "Exp Month:", "exp_month", "02", "text", &field); |
1387 form2.fields.push_back(field); | 1387 form2.fields.push_back(field); |
1388 autofill_test::CreateTestFormField( | 1388 autofill_test::CreateTestFormField( |
1389 "Exp Year:", "exp_year", "2012", "text", &field); | 1389 "Exp Year:", "exp_year", "2012", "text", &field); |
1390 form2.fields.push_back(field); | 1390 form2.fields.push_back(field); |
1391 | 1391 |
1392 FormStructure form_structure2(form2); | 1392 FormStructure form_structure2(form2, std::string()); |
1393 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 1393 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
1394 EXPECT_FALSE(personal_data_->ImportFormData(form_structure2, | 1394 EXPECT_FALSE(personal_data_->ImportFormData(form_structure2, |
1395 &imported_credit_card)); | 1395 &imported_credit_card)); |
1396 ASSERT_FALSE(imported_credit_card); | 1396 ASSERT_FALSE(imported_credit_card); |
1397 | 1397 |
1398 // Note: no refresh here. | 1398 // Note: no refresh here. |
1399 | 1399 |
1400 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); | 1400 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); |
1401 ASSERT_EQ(1U, results2.size()); | 1401 ASSERT_EQ(1U, results2.size()); |
1402 EXPECT_EQ(0, expected.Compare(*results2[0])); | 1402 EXPECT_EQ(0, expected.Compare(*results2[0])); |
(...skipping 10 matching lines...) Expand all Loading... |
1413 autofill_test::CreateTestFormField( | 1413 autofill_test::CreateTestFormField( |
1414 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); | 1414 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); |
1415 form1.fields.push_back(field); | 1415 form1.fields.push_back(field); |
1416 autofill_test::CreateTestFormField( | 1416 autofill_test::CreateTestFormField( |
1417 "Exp Month:", "exp_month", "01", "text", &field); | 1417 "Exp Month:", "exp_month", "01", "text", &field); |
1418 form1.fields.push_back(field); | 1418 form1.fields.push_back(field); |
1419 autofill_test::CreateTestFormField( | 1419 autofill_test::CreateTestFormField( |
1420 "Exp Year:", "exp_year", "2011", "text", &field); | 1420 "Exp Year:", "exp_year", "2011", "text", &field); |
1421 form1.fields.push_back(field); | 1421 form1.fields.push_back(field); |
1422 | 1422 |
1423 FormStructure form_structure1(form1); | 1423 FormStructure form_structure1(form1, std::string()); |
1424 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1424 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1425 const CreditCard* imported_credit_card; | 1425 const CreditCard* imported_credit_card; |
1426 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1426 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
1427 &imported_credit_card)); | 1427 &imported_credit_card)); |
1428 ASSERT_TRUE(imported_credit_card); | 1428 ASSERT_TRUE(imported_credit_card); |
1429 personal_data_->SaveImportedCreditCard(*imported_credit_card); | 1429 personal_data_->SaveImportedCreditCard(*imported_credit_card); |
1430 delete imported_credit_card; | 1430 delete imported_credit_card; |
1431 | 1431 |
1432 // Verify that the web database has been updated and the notification sent. | 1432 // Verify that the web database has been updated and the notification sent. |
1433 EXPECT_CALL(personal_data_observer_, | 1433 EXPECT_CALL(personal_data_observer_, |
(...skipping 16 matching lines...) Expand all Loading... |
1450 autofill_test::CreateTestFormField( | 1450 autofill_test::CreateTestFormField( |
1451 "Card Number:", "card_number", "4111 1111 1111 1111", "text", &field); | 1451 "Card Number:", "card_number", "4111 1111 1111 1111", "text", &field); |
1452 form2.fields.push_back(field); | 1452 form2.fields.push_back(field); |
1453 autofill_test::CreateTestFormField( | 1453 autofill_test::CreateTestFormField( |
1454 "Exp Month:", "exp_month", "01", "text", &field); | 1454 "Exp Month:", "exp_month", "01", "text", &field); |
1455 form2.fields.push_back(field); | 1455 form2.fields.push_back(field); |
1456 autofill_test::CreateTestFormField( | 1456 autofill_test::CreateTestFormField( |
1457 "Exp Year:", "exp_year", "2012", "text", &field); | 1457 "Exp Year:", "exp_year", "2012", "text", &field); |
1458 form2.fields.push_back(field); | 1458 form2.fields.push_back(field); |
1459 | 1459 |
1460 FormStructure form_structure2(form2); | 1460 FormStructure form_structure2(form2, std::string()); |
1461 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 1461 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
1462 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 1462 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
1463 &imported_credit_card)); | 1463 &imported_credit_card)); |
1464 EXPECT_FALSE(imported_credit_card); | 1464 EXPECT_FALSE(imported_credit_card); |
1465 | 1465 |
1466 // Verify that the web database has been updated and the notification sent. | 1466 // Verify that the web database has been updated and the notification sent. |
1467 EXPECT_CALL(personal_data_observer_, | 1467 EXPECT_CALL(personal_data_observer_, |
1468 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1468 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1469 MessageLoop::current()->Run(); | 1469 MessageLoop::current()->Run(); |
1470 | 1470 |
(...skipping 18 matching lines...) Expand all Loading... |
1489 autofill_test::CreateTestFormField( | 1489 autofill_test::CreateTestFormField( |
1490 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); | 1490 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); |
1491 form1.fields.push_back(field); | 1491 form1.fields.push_back(field); |
1492 autofill_test::CreateTestFormField( | 1492 autofill_test::CreateTestFormField( |
1493 "Exp Month:", "exp_month", "01", "text", &field); | 1493 "Exp Month:", "exp_month", "01", "text", &field); |
1494 form1.fields.push_back(field); | 1494 form1.fields.push_back(field); |
1495 autofill_test::CreateTestFormField( | 1495 autofill_test::CreateTestFormField( |
1496 "Exp Year:", "exp_year", "2011", "text", &field); | 1496 "Exp Year:", "exp_year", "2011", "text", &field); |
1497 form1.fields.push_back(field); | 1497 form1.fields.push_back(field); |
1498 | 1498 |
1499 FormStructure form_structure1(form1); | 1499 FormStructure form_structure1(form1, std::string()); |
1500 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1500 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1501 const CreditCard* imported_credit_card; | 1501 const CreditCard* imported_credit_card; |
1502 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1502 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
1503 &imported_credit_card)); | 1503 &imported_credit_card)); |
1504 ASSERT_TRUE(imported_credit_card); | 1504 ASSERT_TRUE(imported_credit_card); |
1505 personal_data_->SaveImportedCreditCard(*imported_credit_card); | 1505 personal_data_->SaveImportedCreditCard(*imported_credit_card); |
1506 delete imported_credit_card; | 1506 delete imported_credit_card; |
1507 | 1507 |
1508 // Verify that the web database has been updated and the notification sent. | 1508 // Verify that the web database has been updated and the notification sent. |
1509 EXPECT_CALL(personal_data_observer_, | 1509 EXPECT_CALL(personal_data_observer_, |
(...skipping 12 matching lines...) Expand all Loading... |
1522 autofill_test::CreateTestFormField( | 1522 autofill_test::CreateTestFormField( |
1523 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); | 1523 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); |
1524 form2.fields.push_back(field); | 1524 form2.fields.push_back(field); |
1525 autofill_test::CreateTestFormField( | 1525 autofill_test::CreateTestFormField( |
1526 "Exp Month:", "exp_month", "01", "text", &field); | 1526 "Exp Month:", "exp_month", "01", "text", &field); |
1527 form2.fields.push_back(field); | 1527 form2.fields.push_back(field); |
1528 autofill_test::CreateTestFormField( | 1528 autofill_test::CreateTestFormField( |
1529 "Exp Year:", "exp_year", "2012", "text", &field); | 1529 "Exp Year:", "exp_year", "2012", "text", &field); |
1530 form2.fields.push_back(field); | 1530 form2.fields.push_back(field); |
1531 | 1531 |
1532 FormStructure form_structure2(form2); | 1532 FormStructure form_structure2(form2, std::string()); |
1533 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 1533 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
1534 EXPECT_FALSE(personal_data_->ImportFormData(form_structure2, | 1534 EXPECT_FALSE(personal_data_->ImportFormData(form_structure2, |
1535 &imported_credit_card)); | 1535 &imported_credit_card)); |
1536 EXPECT_FALSE(imported_credit_card); | 1536 EXPECT_FALSE(imported_credit_card); |
1537 | 1537 |
1538 // Note: no refresh here. | 1538 // Note: no refresh here. |
1539 | 1539 |
1540 // No change is expected. | 1540 // No change is expected. |
1541 CreditCard expected2; | 1541 CreditCard expected2; |
1542 autofill_test::SetCreditCardInfo(&expected2, | 1542 autofill_test::SetCreditCardInfo(&expected2, |
(...skipping 14 matching lines...) Expand all Loading... |
1557 autofill_test::CreateTestFormField( | 1557 autofill_test::CreateTestFormField( |
1558 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); | 1558 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); |
1559 form1.fields.push_back(field); | 1559 form1.fields.push_back(field); |
1560 autofill_test::CreateTestFormField( | 1560 autofill_test::CreateTestFormField( |
1561 "Exp Month:", "exp_month", "01", "text", &field); | 1561 "Exp Month:", "exp_month", "01", "text", &field); |
1562 form1.fields.push_back(field); | 1562 form1.fields.push_back(field); |
1563 autofill_test::CreateTestFormField( | 1563 autofill_test::CreateTestFormField( |
1564 "Exp Year:", "exp_year", "2011", "text", &field); | 1564 "Exp Year:", "exp_year", "2011", "text", &field); |
1565 form1.fields.push_back(field); | 1565 form1.fields.push_back(field); |
1566 | 1566 |
1567 FormStructure form_structure1(form1); | 1567 FormStructure form_structure1(form1, std::string()); |
1568 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1568 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1569 const CreditCard* imported_credit_card; | 1569 const CreditCard* imported_credit_card; |
1570 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1570 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
1571 &imported_credit_card)); | 1571 &imported_credit_card)); |
1572 ASSERT_TRUE(imported_credit_card); | 1572 ASSERT_TRUE(imported_credit_card); |
1573 personal_data_->SaveImportedCreditCard(*imported_credit_card); | 1573 personal_data_->SaveImportedCreditCard(*imported_credit_card); |
1574 delete imported_credit_card; | 1574 delete imported_credit_card; |
1575 | 1575 |
1576 // Verify that the web database has been updated and the notification sent. | 1576 // Verify that the web database has been updated and the notification sent. |
1577 EXPECT_CALL(personal_data_observer_, | 1577 EXPECT_CALL(personal_data_observer_, |
(...skipping 14 matching lines...) Expand all Loading... |
1592 autofill_test::CreateTestFormField( | 1592 autofill_test::CreateTestFormField( |
1593 "Card Number:", "card_number", "4111111111111111", "text", &field); | 1593 "Card Number:", "card_number", "4111111111111111", "text", &field); |
1594 form2.fields.push_back(field); | 1594 form2.fields.push_back(field); |
1595 autofill_test::CreateTestFormField( | 1595 autofill_test::CreateTestFormField( |
1596 "Exp Month:", "exp_month", "01", "text", &field); | 1596 "Exp Month:", "exp_month", "01", "text", &field); |
1597 form2.fields.push_back(field); | 1597 form2.fields.push_back(field); |
1598 autofill_test::CreateTestFormField( | 1598 autofill_test::CreateTestFormField( |
1599 "Exp Year:", "exp_year", "2011", "text", &field); | 1599 "Exp Year:", "exp_year", "2011", "text", &field); |
1600 form2.fields.push_back(field); | 1600 form2.fields.push_back(field); |
1601 | 1601 |
1602 FormStructure form_structure2(form2); | 1602 FormStructure form_structure2(form2, std::string()); |
1603 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 1603 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
1604 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 1604 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
1605 &imported_credit_card)); | 1605 &imported_credit_card)); |
1606 EXPECT_FALSE(imported_credit_card); | 1606 EXPECT_FALSE(imported_credit_card); |
1607 | 1607 |
1608 // Wait for the refresh, which in this case is a no-op. | 1608 // Wait for the refresh, which in this case is a no-op. |
1609 EXPECT_CALL(personal_data_observer_, | 1609 EXPECT_CALL(personal_data_observer_, |
1610 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1610 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1611 MessageLoop::current()->Run(); | 1611 MessageLoop::current()->Run(); |
1612 | 1612 |
1613 // No change is expected. | 1613 // No change is expected. |
1614 CreditCard expected2; | 1614 CreditCard expected2; |
1615 autofill_test::SetCreditCardInfo(&expected2, | 1615 autofill_test::SetCreditCardInfo(&expected2, |
1616 "Biggie Smalls", "4111111111111111", "01", "2011"); | 1616 "Biggie Smalls", "4111111111111111", "01", "2011"); |
1617 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); | 1617 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); |
1618 ASSERT_EQ(1U, results2.size()); | 1618 ASSERT_EQ(1U, results2.size()); |
1619 EXPECT_EQ(0, expected2.Compare(*results2[0])); | 1619 EXPECT_EQ(0, expected2.Compare(*results2[0])); |
1620 | 1620 |
1621 // Add a third credit card where the expiration date is missing. | 1621 // Add a third credit card where the expiration date is missing. |
1622 FormData form3; | 1622 FormData form3; |
1623 autofill_test::CreateTestFormField( | 1623 autofill_test::CreateTestFormField( |
1624 "Name on card:", "name_on_card", "Johnny McEnroe", "text", &field); | 1624 "Name on card:", "name_on_card", "Johnny McEnroe", "text", &field); |
1625 form3.fields.push_back(field); | 1625 form3.fields.push_back(field); |
1626 autofill_test::CreateTestFormField( | 1626 autofill_test::CreateTestFormField( |
1627 "Card Number:", "card_number", "5555555555554444", "text", &field); | 1627 "Card Number:", "card_number", "5555555555554444", "text", &field); |
1628 form3.fields.push_back(field); | 1628 form3.fields.push_back(field); |
1629 // Note missing expiration month and year.. | 1629 // Note missing expiration month and year.. |
1630 | 1630 |
1631 FormStructure form_structure3(form3); | 1631 FormStructure form_structure3(form3, std::string()); |
1632 form_structure3.DetermineHeuristicTypes(TestAutofillMetrics()); | 1632 form_structure3.DetermineHeuristicTypes(TestAutofillMetrics()); |
1633 EXPECT_FALSE(personal_data_->ImportFormData(form_structure3, | 1633 EXPECT_FALSE(personal_data_->ImportFormData(form_structure3, |
1634 &imported_credit_card)); | 1634 &imported_credit_card)); |
1635 ASSERT_FALSE(imported_credit_card); | 1635 ASSERT_FALSE(imported_credit_card); |
1636 | 1636 |
1637 // Note: no refresh here. | 1637 // Note: no refresh here. |
1638 | 1638 |
1639 // No change is expected. | 1639 // No change is expected. |
1640 CreditCard expected3; | 1640 CreditCard expected3; |
1641 autofill_test::SetCreditCardInfo(&expected3, | 1641 autofill_test::SetCreditCardInfo(&expected3, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 autofill_test::CreateTestFormField( | 1673 autofill_test::CreateTestFormField( |
1674 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); | 1674 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); |
1675 form.fields.push_back(field); | 1675 form.fields.push_back(field); |
1676 autofill_test::CreateTestFormField( | 1676 autofill_test::CreateTestFormField( |
1677 "Exp Month:", "exp_month", "01", "text", &field); | 1677 "Exp Month:", "exp_month", "01", "text", &field); |
1678 form.fields.push_back(field); | 1678 form.fields.push_back(field); |
1679 autofill_test::CreateTestFormField( | 1679 autofill_test::CreateTestFormField( |
1680 "Exp Year:", "exp_year", "2012", "text", &field); | 1680 "Exp Year:", "exp_year", "2012", "text", &field); |
1681 form.fields.push_back(field); | 1681 form.fields.push_back(field); |
1682 | 1682 |
1683 FormStructure form_structure(form); | 1683 FormStructure form_structure(form, std::string()); |
1684 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); | 1684 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); |
1685 const CreditCard* imported_credit_card; | 1685 const CreditCard* imported_credit_card; |
1686 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, | 1686 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, |
1687 &imported_credit_card)); | 1687 &imported_credit_card)); |
1688 EXPECT_FALSE(imported_credit_card); | 1688 EXPECT_FALSE(imported_credit_card); |
1689 | 1689 |
1690 // Verify that the web database has been updated and the notification sent. | 1690 // Verify that the web database has been updated and the notification sent. |
1691 EXPECT_CALL(personal_data_observer_, | 1691 EXPECT_CALL(personal_data_observer_, |
1692 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1692 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1693 MessageLoop::current()->Run(); | 1693 MessageLoop::current()->Run(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 autofill_test::CreateTestFormField( | 1730 autofill_test::CreateTestFormField( |
1731 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); | 1731 "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); |
1732 form.fields.push_back(field); | 1732 form.fields.push_back(field); |
1733 autofill_test::CreateTestFormField( | 1733 autofill_test::CreateTestFormField( |
1734 "Exp Month:", "exp_month", "01", "text", &field); | 1734 "Exp Month:", "exp_month", "01", "text", &field); |
1735 form.fields.push_back(field); | 1735 form.fields.push_back(field); |
1736 autofill_test::CreateTestFormField( | 1736 autofill_test::CreateTestFormField( |
1737 "Exp Year:", "exp_year", "2011", "text", &field); | 1737 "Exp Year:", "exp_year", "2011", "text", &field); |
1738 form.fields.push_back(field); | 1738 form.fields.push_back(field); |
1739 | 1739 |
1740 FormStructure form_structure(form); | 1740 FormStructure form_structure(form, std::string()); |
1741 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); | 1741 form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); |
1742 const CreditCard* imported_credit_card; | 1742 const CreditCard* imported_credit_card; |
1743 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, | 1743 EXPECT_TRUE(personal_data_->ImportFormData(form_structure, |
1744 &imported_credit_card)); | 1744 &imported_credit_card)); |
1745 EXPECT_FALSE(imported_credit_card); | 1745 EXPECT_FALSE(imported_credit_card); |
1746 | 1746 |
1747 // Wait for the refresh, which in this case is a no-op. | 1747 // Wait for the refresh, which in this case is a no-op. |
1748 EXPECT_CALL(personal_data_observer_, | 1748 EXPECT_CALL(personal_data_observer_, |
1749 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1749 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1750 MessageLoop::current()->Run(); | 1750 MessageLoop::current()->Run(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 autofill_test::CreateTestFormField( | 1896 autofill_test::CreateTestFormField( |
1897 "State:", "state", "California", "text", &field); | 1897 "State:", "state", "California", "text", &field); |
1898 form1.fields.push_back(field); | 1898 form1.fields.push_back(field); |
1899 autofill_test::CreateTestFormField( | 1899 autofill_test::CreateTestFormField( |
1900 "Zip:", "zip", "94102", "text", &field); | 1900 "Zip:", "zip", "94102", "text", &field); |
1901 form1.fields.push_back(field); | 1901 form1.fields.push_back(field); |
1902 autofill_test::CreateTestFormField( | 1902 autofill_test::CreateTestFormField( |
1903 "Phone number:", "phone_number", "817-555-6789", "text", &field); | 1903 "Phone number:", "phone_number", "817-555-6789", "text", &field); |
1904 form1.fields.push_back(field); | 1904 form1.fields.push_back(field); |
1905 | 1905 |
1906 FormStructure form_structure1(form1); | 1906 FormStructure form_structure1(form1, std::string()); |
1907 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); | 1907 form_structure1.DetermineHeuristicTypes(TestAutofillMetrics()); |
1908 const CreditCard* imported_credit_card; | 1908 const CreditCard* imported_credit_card; |
1909 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, | 1909 EXPECT_TRUE(personal_data_->ImportFormData(form_structure1, |
1910 &imported_credit_card)); | 1910 &imported_credit_card)); |
1911 ASSERT_FALSE(imported_credit_card); | 1911 ASSERT_FALSE(imported_credit_card); |
1912 | 1912 |
1913 // Verify that the web database has been updated and the notification sent. | 1913 // Verify that the web database has been updated and the notification sent. |
1914 EXPECT_CALL(personal_data_observer_, | 1914 EXPECT_CALL(personal_data_observer_, |
1915 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1915 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1916 MessageLoop::current()->Run(); | 1916 MessageLoop::current()->Run(); |
(...skipping 26 matching lines...) Expand all Loading... |
1943 autofill_test::CreateTestFormField( | 1943 autofill_test::CreateTestFormField( |
1944 "State:", "state", "California", "text", &field); | 1944 "State:", "state", "California", "text", &field); |
1945 form2.fields.push_back(field); | 1945 form2.fields.push_back(field); |
1946 autofill_test::CreateTestFormField( | 1946 autofill_test::CreateTestFormField( |
1947 "Zip:", "zip", "94102", "text", &field); | 1947 "Zip:", "zip", "94102", "text", &field); |
1948 form2.fields.push_back(field); | 1948 form2.fields.push_back(field); |
1949 autofill_test::CreateTestFormField( | 1949 autofill_test::CreateTestFormField( |
1950 "Phone number:", "phone_number", "214-555-1234", "text", &field); | 1950 "Phone number:", "phone_number", "214-555-1234", "text", &field); |
1951 form2.fields.push_back(field); | 1951 form2.fields.push_back(field); |
1952 | 1952 |
1953 FormStructure form_structure2(form2); | 1953 FormStructure form_structure2(form2, std::string()); |
1954 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); | 1954 form_structure2.DetermineHeuristicTypes(TestAutofillMetrics()); |
1955 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, | 1955 EXPECT_TRUE(personal_data_->ImportFormData(form_structure2, |
1956 &imported_credit_card)); | 1956 &imported_credit_card)); |
1957 ASSERT_FALSE(imported_credit_card); | 1957 ASSERT_FALSE(imported_credit_card); |
1958 | 1958 |
1959 // Verify that the web database has been updated and the notification sent. | 1959 // Verify that the web database has been updated and the notification sent. |
1960 EXPECT_CALL(personal_data_observer_, | 1960 EXPECT_CALL(personal_data_observer_, |
1961 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1961 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
1962 MessageLoop::current()->Run(); | 1962 MessageLoop::current()->Run(); |
1963 | 1963 |
1964 const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); | 1964 const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); |
1965 | 1965 |
1966 // Modify expected to include multi-valued fields. | 1966 // Modify expected to include multi-valued fields. |
1967 std::vector<string16> values; | 1967 std::vector<string16> values; |
1968 expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); | 1968 expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); |
1969 values.push_back(ASCIIToUTF16("(214) 555-1234")); | 1969 values.push_back(ASCIIToUTF16("(214) 555-1234")); |
1970 expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); | 1970 expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); |
1971 | 1971 |
1972 ASSERT_EQ(1U, results2.size()); | 1972 ASSERT_EQ(1U, results2.size()); |
1973 EXPECT_EQ(0, expected.Compare(*results2[0])); | 1973 EXPECT_EQ(0, expected.Compare(*results2[0])); |
1974 } | 1974 } |
OLD | NEW |