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

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

Issue 5364007: Autofill should not allow overwrite of field data when merging profile data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autofill/autofill_profile.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/ref_counted.h" 7 #include "base/ref_counted.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autofill/autofill_common_test.h" 10 #include "chrome/browser/autofill/autofill_common_test.h"
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 autofill_test::CreateTestFormField( 743 autofill_test::CreateTestFormField(
744 "First name:", "first_name", "George", "text", &field); 744 "First name:", "first_name", "George", "text", &field);
745 form1.fields.push_back(field); 745 form1.fields.push_back(field);
746 autofill_test::CreateTestFormField( 746 autofill_test::CreateTestFormField(
747 "Last name:", "last_name", "Washington", "text", &field); 747 "Last name:", "last_name", "Washington", "text", &field);
748 form1.fields.push_back(field); 748 form1.fields.push_back(field);
749 autofill_test::CreateTestFormField( 749 autofill_test::CreateTestFormField(
750 "Address:", "address", "1600 Pennsylvania Avenue", "text", &field); 750 "Address:", "address", "1600 Pennsylvania Avenue", "text", &field);
751 form1.fields.push_back(field); 751 form1.fields.push_back(field);
752 autofill_test::CreateTestFormField( 752 autofill_test::CreateTestFormField(
753 "Address Line 2:", "address2", "Suite A", "text", &field);
754 form1.fields.push_back(field);
755 autofill_test::CreateTestFormField(
753 "Email:", "email", "theprez@gmail.com", "text", &field); 756 "Email:", "email", "theprez@gmail.com", "text", &field);
754 form1.fields.push_back(field); 757 form1.fields.push_back(field);
758 // Phone gets updated.
759 autofill_test::CreateTestFormField(
760 "Phone:", "phone", "4445556666", "text", &field);
761 form1.fields.push_back(field);
755 762
756 FormStructure form_structure1(form1); 763 FormStructure form_structure1(form1);
757 std::vector<FormStructure*> forms; 764 std::vector<FormStructure*> forms;
758 forms.push_back(&form_structure1); 765 forms.push_back(&form_structure1);
759 EXPECT_TRUE(personal_data_->ImportFormData(forms)); 766 EXPECT_TRUE(personal_data_->ImportFormData(forms));
760 767
761 // Wait for the refresh. 768 // Wait for the refresh.
762 EXPECT_CALL(personal_data_observer_, 769 EXPECT_CALL(personal_data_observer_,
763 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); 770 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
764 771
765 MessageLoop::current()->Run(); 772 MessageLoop::current()->Run();
766 773
767 AutoFillProfile expected; 774 AutoFillProfile expected;
768 autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, 775 autofill_test::SetProfileInfo(&expected, NULL, "George", NULL,
769 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", NULL, 776 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue",
Ilya Sherman 2010/11/30 01:18:50 nit: There's a space at the end of this line (than
dhollowa 2010/11/30 01:31:27 Done. In this case the GTM Plugin failed me... so
770 NULL, NULL, NULL, NULL, NULL, NULL); 777 "Suite A", NULL, NULL, NULL, NULL, "4445556666", NULL);
771 const std::vector<AutoFillProfile*>& results1 = personal_data_->profiles(); 778 const std::vector<AutoFillProfile*>& results1 = personal_data_->profiles();
772 ASSERT_EQ(1U, results1.size()); 779 ASSERT_EQ(1U, results1.size());
773 EXPECT_EQ(0, expected.Compare(*results1[0])); 780 EXPECT_EQ(0, expected.Compare(*results1[0]));
774 781
775 // Now create an updated profile. 782 // Now create an updated profile.
776 FormData form2; 783 FormData form2;
777 autofill_test::CreateTestFormField( 784 autofill_test::CreateTestFormField(
778 "First name:", "first_name", "George", "text", &field); 785 "First name:", "first_name", "George", "text", &field);
779 form2.fields.push_back(field); 786 form2.fields.push_back(field);
780 autofill_test::CreateTestFormField( 787 autofill_test::CreateTestFormField(
781 "Last name:", "last_name", "Washington", "text", &field); 788 "Last name:", "last_name", "Washington", "text", &field);
782 form2.fields.push_back(field); 789 form2.fields.push_back(field);
783 autofill_test::CreateTestFormField( 790 autofill_test::CreateTestFormField(
784 "Address:", "address", "1600 Pennsylvania Avenue", "text", &field); 791 "Address:", "address", "1600 Pennsylvania Avenue", "text", &field);
785 form2.fields.push_back(field); 792 form2.fields.push_back(field);
793 autofill_test::CreateTestFormField(
794 "Address Line 2:", "address2", "Suite A", "text", &field);
795 form2.fields.push_back(field);
796 autofill_test::CreateTestFormField(
797 "Email:", "email", "theprez@gmail.com", "text", &field);
798 form2.fields.push_back(field);
786 // Country gets added. 799 // Country gets added.
787 autofill_test::CreateTestFormField( 800 autofill_test::CreateTestFormField(
788 "Country:", "country", "USA", "text", &field); 801 "Country:", "country", "USA", "text", &field);
789 form2.fields.push_back(field); 802 form2.fields.push_back(field);
790 // Email gets updated. 803 // Phone gets updated.
791 autofill_test::CreateTestFormField( 804 autofill_test::CreateTestFormField(
792 "Email:", "email", "new_email@gmail.com", "text", &field); 805 "Phone:", "phone", "1231231234", "text", &field);
793 form2.fields.push_back(field); 806 form2.fields.push_back(field);
794 807
795 FormStructure form_structure2(form2); 808 FormStructure form_structure2(form2);
796 forms.clear(); 809 forms.clear();
797 forms.push_back(&form_structure2); 810 forms.push_back(&form_structure2);
798 EXPECT_TRUE(personal_data_->ImportFormData(forms)); 811 EXPECT_TRUE(personal_data_->ImportFormData(forms));
799 812
800 // Wait for the refresh. 813 // Wait for the refresh.
801 EXPECT_CALL(personal_data_observer_, 814 EXPECT_CALL(personal_data_observer_,
802 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); 815 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
803 816
804 MessageLoop::current()->Run(); 817 MessageLoop::current()->Run();
805 818
806 const std::vector<AutoFillProfile*>& results2 = personal_data_->profiles(); 819 const std::vector<AutoFillProfile*>& results2 = personal_data_->profiles();
807 820
808 AutoFillProfile expected2; 821 AutoFillProfile expected2;
809 autofill_test::SetProfileInfo(&expected2, NULL, "George", NULL, 822 autofill_test::SetProfileInfo(&expected2, NULL, "George", NULL,
810 "Washington", "new_email@gmail.com", NULL, "1600 Pennsylvania Avenue", 823 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue",
811 NULL, NULL, NULL, NULL, "USA", NULL, NULL); 824 "Suite A", NULL, NULL, NULL, "USA", "1231231234", NULL);
812 ASSERT_EQ(1U, results2.size()); 825 ASSERT_EQ(1U, results2.size());
813 EXPECT_EQ(0, expected2.Compare(*results2[0])); 826 EXPECT_EQ(0, expected2.Compare(*results2[0]));
814 } 827 }
815 828
816 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { 829 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) {
817 FormData form1; 830 FormData form1;
818 webkit_glue::FormField field; 831 webkit_glue::FormField field;
819 autofill_test::CreateTestFormField( 832 autofill_test::CreateTestFormField(
820 "First name:", "first_name", "George", "text", &field); 833 "First name:", "first_name", "George", "text", &field);
821 form1.fields.push_back(field); 834 form1.fields.push_back(field);
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 // Expect that the newer information is saved. In this case the year is 1379 // Expect that the newer information is saved. In this case the year is
1367 // added to the existing credit card. 1380 // added to the existing credit card.
1368 CreditCard expected2; 1381 CreditCard expected2;
1369 autofill_test::SetCreditCardInfo(&expected2, 1382 autofill_test::SetCreditCardInfo(&expected2,
1370 "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); 1383 "L1", "Biggie Smalls", "4111111111111111", "01", "2011");
1371 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); 1384 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards();
1372 ASSERT_EQ(1U, results2.size()); 1385 ASSERT_EQ(1U, results2.size());
1373 EXPECT_EQ(0, expected2.Compare(*results2[0])); 1386 EXPECT_EQ(0, expected2.Compare(*results2[0]));
1374 } 1387 }
1375 1388
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_profile.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698