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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 content::NotificationRegistrar registrar_; | 104 content::NotificationRegistrar registrar_; |
105 content::MockNotificationObserver observer_; | 105 content::MockNotificationObserver observer_; |
106 PersonalDataLoadedObserverMock personal_data_observer_; | 106 PersonalDataLoadedObserverMock personal_data_observer_; |
107 }; | 107 }; |
108 | 108 |
109 TEST_F(PersonalDataManagerTest, AddProfile) { | 109 TEST_F(PersonalDataManagerTest, AddProfile) { |
110 AutofillProfile profile0; | 110 AutofillProfile profile0; |
111 autofill_test::SetProfileInfo(&profile0, | 111 autofill_test::SetProfileInfo(&profile0, |
112 "John", "Mitchell", "Smith", | 112 "John", "Mitchell", "Smith", |
113 "j@s.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA", | 113 "j@s.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA", |
114 "94102", "USA", "4158889999"); | 114 "94102", "US", "4158889999"); |
115 | 115 |
116 // Add profile0 to the database. | 116 // Add profile0 to the database. |
117 personal_data_->AddProfile(profile0); | 117 personal_data_->AddProfile(profile0); |
118 | 118 |
119 // Reload the database. | 119 // Reload the database. |
120 ResetPersonalDataManager(); | 120 ResetPersonalDataManager(); |
121 | 121 |
122 // Verify the addition. | 122 // Verify the addition. |
123 const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); | 123 const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); |
124 ASSERT_EQ(1U, results1.size()); | 124 ASSERT_EQ(1U, results1.size()); |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 974 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
975 MessageLoop::current()->Run(); | 975 MessageLoop::current()->Run(); |
976 | 976 |
977 const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); | 977 const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); |
978 | 978 |
979 // Add multi-valued phone number to expectation. Also, country gets added. | 979 // Add multi-valued phone number to expectation. Also, country gets added. |
980 std::vector<string16> values; | 980 std::vector<string16> values; |
981 expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); | 981 expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); |
982 values.push_back(ASCIIToUTF16("(650) 223-1234")); | 982 values.push_back(ASCIIToUTF16("(650) 223-1234")); |
983 expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); | 983 expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); |
984 expected.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States")); | 984 expected.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); |
985 ASSERT_EQ(1U, results2.size()); | 985 ASSERT_EQ(1U, results2.size()); |
986 EXPECT_EQ(0, expected.Compare(*results2[0])); | 986 EXPECT_EQ(0, expected.Compare(*results2[0])); |
987 } | 987 } |
988 | 988 |
989 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { | 989 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { |
990 FormData form1; | 990 FormData form1; |
991 FormFieldData field; | 991 FormFieldData field; |
992 autofill_test::CreateTestFormField( | 992 autofill_test::CreateTestFormField( |
993 "First name:", "first_name", "George", "text", &field); | 993 "First name:", "first_name", "George", "text", &field); |
994 form1.fields.push_back(field); | 994 form1.fields.push_back(field); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 ASSERT_EQ(0U, credit_cards.size()); | 1201 ASSERT_EQ(0U, credit_cards.size()); |
1202 } | 1202 } |
1203 | 1203 |
1204 TEST_F(PersonalDataManagerTest, AggregateExistingAuxiliaryProfile) { | 1204 TEST_F(PersonalDataManagerTest, AggregateExistingAuxiliaryProfile) { |
1205 // Simulate having access to an auxiliary profile. | 1205 // Simulate having access to an auxiliary profile. |
1206 // |auxiliary_profile| will be owned by |personal_data_|. | 1206 // |auxiliary_profile| will be owned by |personal_data_|. |
1207 AutofillProfile* auxiliary_profile = new AutofillProfile; | 1207 AutofillProfile* auxiliary_profile = new AutofillProfile; |
1208 autofill_test::SetProfileInfo(auxiliary_profile, | 1208 autofill_test::SetProfileInfo(auxiliary_profile, |
1209 "Tester", "Frederick", "McAddressBookTesterson", | 1209 "Tester", "Frederick", "McAddressBookTesterson", |
1210 "tester@example.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", | 1210 "tester@example.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", |
1211 "CA", "94102", "USA", "1.415.888.9999"); | 1211 "CA", "94102", "US", "1.415.888.9999"); |
1212 ScopedVector<AutofillProfile>& auxiliary_profiles = | 1212 ScopedVector<AutofillProfile>& auxiliary_profiles = |
1213 personal_data_->auxiliary_profiles_; | 1213 personal_data_->auxiliary_profiles_; |
1214 auxiliary_profiles.push_back(auxiliary_profile); | 1214 auxiliary_profiles.push_back(auxiliary_profile); |
1215 | 1215 |
1216 // Simulate a form submission with a subset of the info. | 1216 // Simulate a form submission with a subset of the info. |
1217 // Note that the phone number format is different from the saved format. | 1217 // Note that the phone number format is different from the saved format. |
1218 FormData form; | 1218 FormData form; |
1219 FormFieldData field; | 1219 FormFieldData field; |
1220 autofill_test::CreateTestFormField( | 1220 autofill_test::CreateTestFormField( |
1221 "First name:", "first_name", "Tester", "text", &field); | 1221 "First name:", "first_name", "Tester", "text", &field); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |