Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 void CheckSuggestions(int expected_page_id, | 694 void CheckSuggestions(int expected_page_id, |
| 695 const Suggestion& suggestion0, | 695 const Suggestion& suggestion0, |
| 696 const Suggestion& suggestion1, | 696 const Suggestion& suggestion1, |
| 697 const Suggestion& suggestion2) { | 697 const Suggestion& suggestion2) { |
| 698 std::vector<Suggestion> suggestion_vector; | 698 std::vector<Suggestion> suggestion_vector; |
| 699 suggestion_vector.push_back(suggestion0); | 699 suggestion_vector.push_back(suggestion0); |
| 700 suggestion_vector.push_back(suggestion1); | 700 suggestion_vector.push_back(suggestion1); |
| 701 suggestion_vector.push_back(suggestion2); | 701 suggestion_vector.push_back(suggestion2); |
| 702 CheckSuggestions(expected_page_id, 3, &suggestion_vector[0]); | 702 CheckSuggestions(expected_page_id, 3, &suggestion_vector[0]); |
| 703 } | 703 } |
| 704 // Check that the autofill suggestions were sent, and that they match a page | |
| 705 // but contain no results. | |
| 704 void CheckNoSuggestions(int expected_page_id) { | 706 void CheckNoSuggestions(int expected_page_id) { |
| 705 EXPECT_TRUE(on_suggestions_returned_seen()); | |
| 706 CheckSuggestions(expected_page_id, 0, nullptr); | 707 CheckSuggestions(expected_page_id, 0, nullptr); |
| 707 } | 708 } |
| 709 // Check that the autofill suggestions were sent, and that they match a page | |
| 710 // and contain a specific number of suggestions. | |
| 711 void CheckSuggestionCount(int expected_page_id, | |
| 712 size_t expected_num_suggestions) { | |
| 713 // Ensure that these results are from the most recent query. | |
| 714 EXPECT_TRUE(on_suggestions_returned_seen_); | |
| 715 | |
| 716 EXPECT_EQ(expected_page_id, query_id_); | |
| 717 ASSERT_EQ(expected_num_suggestions, suggestions_.size()); | |
| 718 } | |
| 708 | 719 |
| 709 bool on_query_seen() const { | 720 bool on_query_seen() const { |
| 710 return on_query_seen_; | 721 return on_query_seen_; |
| 711 } | 722 } |
| 712 | 723 |
| 713 bool on_suggestions_returned_seen() const { | 724 bool on_suggestions_returned_seen() const { |
| 714 return on_suggestions_returned_seen_; | 725 return on_suggestions_returned_seen_; |
| 715 } | 726 } |
| 716 | 727 |
| 717 private: | 728 private: |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 "2017"); | 965 "2017"); |
| 955 card->SetTypeForMaskedCard(kVisaCard); | 966 card->SetTypeForMaskedCard(kVisaCard); |
| 956 | 967 |
| 957 EXPECT_CALL(*autofill_driver_, SendFormDataToRenderer(_, _, _)) | 968 EXPECT_CALL(*autofill_driver_, SendFormDataToRenderer(_, _, _)) |
| 958 .Times(AtLeast(1)); | 969 .Times(AtLeast(1)); |
| 959 autofill_manager_->FillOrPreviewCreditCardForm( | 970 autofill_manager_->FillOrPreviewCreditCardForm( |
| 960 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form, | 971 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form, |
| 961 form->fields[0], *card); | 972 form->fields[0], *card); |
| 962 } | 973 } |
| 963 | 974 |
| 975 // Convenience method for using and retrieving a mock autocomplete history | |
| 976 // manager. | |
| 977 MockAutocompleteHistoryManager* UseMockAutocompleteHistoryManager() { | |
| 978 autofill_manager_->autocomplete_history_manager_.reset( | |
|
Mathieu
2016/08/04 20:57:19
to avoid the cast, you can:
MockAutocompleteHisto
asredzki
2016/08/04 21:10:10
Done.
| |
| 979 new MockAutocompleteHistoryManager(autofill_driver_.get(), | |
| 980 autofill_manager_->client())); | |
| 981 return static_cast<MockAutocompleteHistoryManager*>( | |
| 982 autofill_manager_->autocomplete_history_manager_.get()); | |
|
Mathieu
2016/08/04 20:57:19
indent is off here?
asredzki
2016/08/04 21:10:10
Done.
| |
| 983 } | |
| 984 | |
| 964 // Convenience method to cast the FullCardRequest into a CardUnmaskDelegate. | 985 // Convenience method to cast the FullCardRequest into a CardUnmaskDelegate. |
| 965 CardUnmaskDelegate* full_card_unmask_delegate() { | 986 CardUnmaskDelegate* full_card_unmask_delegate() { |
| 966 DCHECK(autofill_manager_->full_card_request_); | 987 DCHECK(autofill_manager_->full_card_request_); |
| 967 return static_cast<CardUnmaskDelegate*>( | 988 return static_cast<CardUnmaskDelegate*>( |
| 968 autofill_manager_->full_card_request_.get()); | 989 autofill_manager_->full_card_request_.get()); |
| 969 } | 990 } |
| 970 | 991 |
| 971 protected: | 992 protected: |
| 972 base::MessageLoop message_loop_; | 993 base::MessageLoop message_loop_; |
| 973 MockAutofillClient autofill_client_; | 994 MockAutofillClient autofill_client_; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1055 form2.fields.push_back(field); | 1076 form2.fields.push_back(field); |
| 1056 | 1077 |
| 1057 forms.clear(); | 1078 forms.clear(); |
| 1058 forms.push_back(form2); | 1079 forms.push_back(form2); |
| 1059 FormsSeen(forms); | 1080 FormsSeen(forms); |
| 1060 histogram_tester.ExpectUniqueSample("Autofill.UserHappiness", | 1081 histogram_tester.ExpectUniqueSample("Autofill.UserHappiness", |
| 1061 0 /* FORMS_LOADED */, 2); | 1082 0 /* FORMS_LOADED */, 2); |
| 1062 download_manager_->VerifyLastQueriedForms(forms); | 1083 download_manager_->VerifyLastQueriedForms(forms); |
| 1063 } | 1084 } |
| 1064 | 1085 |
| 1065 // Test that no suggestions are returned for a field with an unrecognized | 1086 // Test that no autofill suggestions are returned for a field with an |
| 1066 // autocomplete attribute. | 1087 // unrecognized autocomplete attribute. |
| 1067 TEST_F(AutofillManagerTest, GetProfileSuggestions_UnrecognizedAttribute) { | 1088 TEST_F(AutofillManagerTest, GetProfileSuggestions_UnrecognizedAttribute) { |
| 1089 // Set up our form data. | |
| 1068 FormData form; | 1090 FormData form; |
| 1069 form.name = ASCIIToUTF16("MyForm"); | 1091 form.name = ASCIIToUTF16("MyForm"); |
| 1070 form.origin = GURL("https://myform.com/form.html"); | 1092 form.origin = GURL("https://myform.com/form.html"); |
| 1071 form.action = GURL("https://myform.com/submit.html"); | 1093 form.action = GURL("https://myform.com/submit.html"); |
| 1072 FormFieldData field; | 1094 FormFieldData field; |
| 1073 // Set a valid autocomplete attribute for the first name. | 1095 // Set a valid autocomplete attribute for the first name. |
| 1074 test::CreateTestFormField("First name", "firstname", "", "text", &field); | 1096 test::CreateTestFormField("First name", "firstname", "", "text", &field); |
| 1075 field.autocomplete_attribute = "given-name"; | 1097 field.autocomplete_attribute = "given-name"; |
| 1076 form.fields.push_back(field); | 1098 form.fields.push_back(field); |
| 1077 // Set no autocomplete attribute for the middle name. | 1099 // Set no autocomplete attribute for the middle name. |
| 1078 test::CreateTestFormField("Middle name", "middle", "", "text", &field); | 1100 test::CreateTestFormField("Middle name", "middle", "", "text", &field); |
| 1079 field.autocomplete_attribute = ""; | 1101 field.autocomplete_attribute = ""; |
| 1080 form.fields.push_back(field); | 1102 form.fields.push_back(field); |
| 1081 // Set an unrecognized autocomplete attribute for the last name. | 1103 // Set an unrecognized autocomplete attribute for the last name. |
| 1082 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); | 1104 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); |
| 1083 field.autocomplete_attribute = "unrecognized"; | 1105 field.autocomplete_attribute = "unrecognized"; |
| 1084 form.fields.push_back(field); | 1106 form.fields.push_back(field); |
| 1085 std::vector<FormData> forms(1, form); | 1107 std::vector<FormData> forms(1, form); |
| 1086 FormsSeen(forms); | 1108 FormsSeen(forms); |
| 1087 | 1109 |
| 1088 // Suggestions should be returned for the first two fields | 1110 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
|
Mathieu
2016/08/04 20:57:18
I don't like "Use", perhaps "Recreate"?
asredzki
2016/08/04 21:10:10
Done.
| |
| 1111 | |
| 1112 // Ensure that autocomplete manager is not called for suggestions either. | |
| 1113 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); | |
| 1114 | |
| 1115 // Suggestions should be returned for the first two fields. | |
| 1089 GetAutofillSuggestions(form, form.fields[0]); | 1116 GetAutofillSuggestions(form, form.fields[0]); |
| 1090 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 1117 external_delegate_->CheckSuggestionCount(kDefaultPageID, 2); |
| 1091 GetAutofillSuggestions(form, form.fields[1]); | 1118 GetAutofillSuggestions(form, form.fields[1]); |
| 1092 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 1119 external_delegate_->CheckSuggestionCount(kDefaultPageID, 2); |
| 1093 | 1120 |
| 1094 // Suggestions should not be returned for the third field because of its | 1121 // No suggestions should not be provided for the third field because of its |
| 1095 // unrecognized autocomplete attribute. | 1122 // unrecognized autocomplete attribute. |
| 1096 GetAutofillSuggestions(form, form.fields[2]); | 1123 GetAutofillSuggestions(form, form.fields[2]); |
| 1097 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); | 1124 external_delegate_->CheckNoSuggestions(kDefaultPageID); |
| 1098 } | 1125 } |
| 1099 | 1126 |
| 1100 // Test that no suggestions are returned when there are less than three fields | 1127 // Test that no suggestions are returned when there are less than three fields |
| 1101 // and none of them have an autocomplete attribute. | 1128 // and none of them have an autocomplete attribute. |
| 1102 TEST_F(AutofillManagerTest, GetProfileSuggestions_SmallFormNoAutocomplete) { | 1129 TEST_F(AutofillManagerTest, GetProfileSuggestions_SmallFormNoAutocomplete) { |
| 1130 // Set up our form data. | |
| 1103 FormData form; | 1131 FormData form; |
| 1104 form.name = ASCIIToUTF16("MyForm"); | 1132 form.name = ASCIIToUTF16("MyForm"); |
| 1105 form.origin = GURL("https://myform.com/form.html"); | 1133 form.origin = GURL("https://myform.com/form.html"); |
| 1106 form.action = GURL("https://myform.com/submit.html"); | 1134 form.action = GURL("https://myform.com/submit.html"); |
| 1107 FormFieldData field; | 1135 FormFieldData field; |
| 1108 test::CreateTestFormField("First Name", "firstname", "", "text", &field); | 1136 test::CreateTestFormField("First Name", "firstname", "", "text", &field); |
| 1109 form.fields.push_back(field); | 1137 form.fields.push_back(field); |
| 1110 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); | 1138 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); |
| 1111 form.fields.push_back(field); | 1139 form.fields.push_back(field); |
| 1112 | 1140 |
| 1113 std::vector<FormData> forms(1, form); | 1141 std::vector<FormData> forms(1, form); |
| 1114 FormsSeen(forms); | 1142 FormsSeen(forms); |
| 1115 | 1143 |
| 1144 // Ensure that autocomplete manager is called for both fields. | |
| 1145 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); | |
| 1146 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(2); | |
| 1147 | |
| 1116 GetAutofillSuggestions(form, form.fields[0]); | 1148 GetAutofillSuggestions(form, form.fields[0]); |
| 1117 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); | 1149 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); |
| 1118 | 1150 |
| 1119 GetAutofillSuggestions(form, form.fields[1]); | 1151 GetAutofillSuggestions(form, form.fields[1]); |
| 1120 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); | 1152 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); |
| 1121 } | 1153 } |
| 1122 | 1154 |
| 1123 // Test that for form with two fields with one that has an autocomplete | 1155 // Test that for form with two fields with one that has an autocomplete |
| 1124 // attribute, suggestions are only made for the one that has the attribute. | 1156 // attribute, suggestions are only made for the one that has the attribute. |
| 1125 TEST_F(AutofillManagerTest, | 1157 TEST_F(AutofillManagerTest, |
| 1126 GetProfileSuggestions_SmallFormWithOneAutocomplete) { | 1158 GetProfileSuggestions_SmallFormWithOneAutocomplete) { |
| 1159 // Set up our form data. | |
| 1127 FormData form; | 1160 FormData form; |
| 1128 form.name = ASCIIToUTF16("MyForm"); | 1161 form.name = ASCIIToUTF16("MyForm"); |
| 1129 form.origin = GURL("https://myform.com/form.html"); | 1162 form.origin = GURL("https://myform.com/form.html"); |
| 1130 form.action = GURL("https://myform.com/submit.html"); | 1163 form.action = GURL("https://myform.com/submit.html"); |
| 1131 FormFieldData field; | 1164 FormFieldData field; |
| 1132 test::CreateTestFormField("First Name", "firstname", "", "text", &field); | 1165 test::CreateTestFormField("First Name", "firstname", "", "text", &field); |
| 1133 field.autocomplete_attribute = "given-name"; | 1166 field.autocomplete_attribute = "given-name"; |
| 1134 form.fields.push_back(field); | 1167 form.fields.push_back(field); |
| 1135 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); | 1168 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); |
| 1136 field.autocomplete_attribute = ""; | 1169 field.autocomplete_attribute = ""; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1149 // Check that there are no suggestions for the field without the autocomplete | 1182 // Check that there are no suggestions for the field without the autocomplete |
| 1150 // attribute. | 1183 // attribute. |
| 1151 GetAutofillSuggestions(form, form.fields[1]); | 1184 GetAutofillSuggestions(form, form.fields[1]); |
| 1152 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); | 1185 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); |
| 1153 } | 1186 } |
| 1154 | 1187 |
| 1155 // Test that for a form with two fields with autocomplete attributes, | 1188 // Test that for a form with two fields with autocomplete attributes, |
| 1156 // suggestions are made for both fields. | 1189 // suggestions are made for both fields. |
| 1157 TEST_F(AutofillManagerTest, | 1190 TEST_F(AutofillManagerTest, |
| 1158 GetProfileSuggestions_SmallFormWithTwoAutocomplete) { | 1191 GetProfileSuggestions_SmallFormWithTwoAutocomplete) { |
| 1192 // Set up our form data. | |
| 1159 FormData form; | 1193 FormData form; |
| 1160 form.name = ASCIIToUTF16("MyForm"); | 1194 form.name = ASCIIToUTF16("MyForm"); |
| 1161 form.origin = GURL("https://myform.com/form.html"); | 1195 form.origin = GURL("https://myform.com/form.html"); |
| 1162 form.action = GURL("https://myform.com/submit.html"); | 1196 form.action = GURL("https://myform.com/submit.html"); |
| 1163 FormFieldData field; | 1197 FormFieldData field; |
| 1164 test::CreateTestFormField("First Name", "firstname", "", "text", &field); | 1198 test::CreateTestFormField("First Name", "firstname", "", "text", &field); |
| 1165 field.autocomplete_attribute = "given-name"; | 1199 field.autocomplete_attribute = "given-name"; |
| 1166 form.fields.push_back(field); | 1200 form.fields.push_back(field); |
| 1167 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); | 1201 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); |
| 1168 field.autocomplete_attribute = "family-name"; | 1202 field.autocomplete_attribute = "family-name"; |
| 1169 form.fields.push_back(field); | 1203 form.fields.push_back(field); |
| 1170 | 1204 |
| 1171 std::vector<FormData> forms(1, form); | 1205 std::vector<FormData> forms(1, form); |
| 1172 FormsSeen(forms); | 1206 FormsSeen(forms); |
| 1173 | 1207 |
| 1174 GetAutofillSuggestions(form, form.fields[0]); | 1208 GetAutofillSuggestions(form, form.fields[0]); |
| 1175 external_delegate_->CheckSuggestions( | 1209 external_delegate_->CheckSuggestions( |
| 1176 kDefaultPageID, Suggestion("Charles", "Charles Hardin Holley", "", 1), | 1210 kDefaultPageID, Suggestion("Charles", "Charles Hardin Holley", "", 1), |
| 1177 Suggestion("Elvis", "Elvis Aaron Presley", "", 2)); | 1211 Suggestion("Elvis", "Elvis Aaron Presley", "", 2)); |
| 1178 | 1212 |
| 1179 GetAutofillSuggestions(form, form.fields[1]); | 1213 GetAutofillSuggestions(form, form.fields[1]); |
| 1180 external_delegate_->CheckSuggestions( | 1214 external_delegate_->CheckSuggestions( |
| 1181 kDefaultPageID, Suggestion("Holley", "Charles Hardin Holley", "", 1), | 1215 kDefaultPageID, Suggestion("Holley", "Charles Hardin Holley", "", 1), |
| 1182 Suggestion("Presley", "Elvis Aaron Presley", "", 2)); | 1216 Suggestion("Presley", "Elvis Aaron Presley", "", 2)); |
| 1183 } | 1217 } |
| 1184 | 1218 |
| 1185 // Test that we return all address profile suggestions when all form fields are | 1219 // Test that we return all address profile suggestions when all form fields are |
| 1186 // empty. | 1220 // empty. |
| 1187 TEST_F(AutofillManagerTest, GetProfileSuggestionsEmptyValue) { | 1221 TEST_F(AutofillManagerTest, GetProfileSuggestions_EmptyValue) { |
| 1188 // Set up our form data. | 1222 // Set up our form data. |
| 1189 FormData form; | 1223 FormData form; |
| 1190 test::CreateTestAddressFormData(&form); | 1224 test::CreateTestAddressFormData(&form); |
| 1191 std::vector<FormData> forms(1, form); | 1225 std::vector<FormData> forms(1, form); |
| 1192 FormsSeen(forms); | 1226 FormsSeen(forms); |
| 1193 | 1227 |
| 1194 const FormFieldData& field = form.fields[0]; | 1228 const FormFieldData& field = form.fields[0]; |
| 1195 GetAutofillSuggestions(form, field); | 1229 GetAutofillSuggestions(form, field); |
| 1196 | 1230 |
| 1197 // Test that we sent the right values to the external delegate. Inferred | 1231 // Test that we sent the right values to the external delegate. Inferred |
| 1198 // labels include full first relevant field, which in this case is the | 1232 // labels include full first relevant field, which in this case is the |
| 1199 // address line 1. | 1233 // address line 1. |
| 1200 external_delegate_->CheckSuggestions( | 1234 external_delegate_->CheckSuggestions( |
| 1201 kDefaultPageID, Suggestion("Charles", "123 Apple St.", "", 1), | 1235 kDefaultPageID, Suggestion("Charles", "123 Apple St.", "", 1), |
| 1202 Suggestion("Elvis", "3734 Elvis Presley Blvd.", "", 2)); | 1236 Suggestion("Elvis", "3734 Elvis Presley Blvd.", "", 2)); |
| 1203 } | 1237 } |
| 1204 | 1238 |
| 1205 // Test that we return only matching address profile suggestions when the | 1239 // Test that we return only matching address profile suggestions when the |
| 1206 // selected form field has been partially filled out. | 1240 // selected form field has been partially filled out. |
| 1207 TEST_F(AutofillManagerTest, GetProfileSuggestionsMatchCharacter) { | 1241 TEST_F(AutofillManagerTest, GetProfileSuggestions_MatchCharacter) { |
| 1208 // Set up our form data. | 1242 // Set up our form data. |
| 1209 FormData form; | 1243 FormData form; |
| 1210 test::CreateTestAddressFormData(&form); | 1244 test::CreateTestAddressFormData(&form); |
| 1211 std::vector<FormData> forms(1, form); | 1245 std::vector<FormData> forms(1, form); |
| 1212 FormsSeen(forms); | 1246 FormsSeen(forms); |
| 1213 | 1247 |
| 1214 FormFieldData field; | 1248 FormFieldData field; |
| 1215 test::CreateTestFormField("First Name", "firstname", "E", "text", &field); | 1249 test::CreateTestFormField("First Name", "firstname", "E", "text", &field); |
| 1216 GetAutofillSuggestions(form, field); | 1250 GetAutofillSuggestions(form, field); |
| 1217 | 1251 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1289 test::CreateTestFormField("First Name", "firstname", "E", "text", &field); | 1323 test::CreateTestFormField("First Name", "firstname", "E", "text", &field); |
| 1290 GetAutofillSuggestions(form, field); | 1324 GetAutofillSuggestions(form, field); |
| 1291 | 1325 |
| 1292 // Test that we sent the right values to the external delegate. No labels. | 1326 // Test that we sent the right values to the external delegate. No labels. |
| 1293 external_delegate_->CheckSuggestions( | 1327 external_delegate_->CheckSuggestions( |
| 1294 kDefaultPageID, | 1328 kDefaultPageID, |
| 1295 Suggestion("Elvis", "" /* no label */, "", 1)); | 1329 Suggestion("Elvis", "" /* no label */, "", 1)); |
| 1296 } | 1330 } |
| 1297 | 1331 |
| 1298 // Test that we return no suggestions when the form has no relevant fields. | 1332 // Test that we return no suggestions when the form has no relevant fields. |
| 1299 TEST_F(AutofillManagerTest, GetProfileSuggestionsUnknownFields) { | 1333 TEST_F(AutofillManagerTest, GetProfileSuggestions_UnknownFields) { |
| 1300 // Set up our form data. | 1334 // Set up our form data. |
| 1301 FormData form; | 1335 FormData form; |
| 1302 form.name = ASCIIToUTF16("MyForm"); | 1336 form.name = ASCIIToUTF16("MyForm"); |
| 1303 form.origin = GURL("http://myform.com/form.html"); | 1337 form.origin = GURL("http://myform.com/form.html"); |
| 1304 form.action = GURL("http://myform.com/submit.html"); | 1338 form.action = GURL("http://myform.com/submit.html"); |
| 1305 | 1339 |
| 1306 FormFieldData field; | 1340 FormFieldData field; |
| 1307 test::CreateTestFormField("Username", "username", "", "text", &field); | 1341 test::CreateTestFormField("Username", "username", "", "text", &field); |
| 1308 form.fields.push_back(field); | 1342 form.fields.push_back(field); |
| 1309 test::CreateTestFormField("Password", "password", "", "password", &field); | 1343 test::CreateTestFormField("Password", "password", "", "password", &field); |
| 1310 form.fields.push_back(field); | 1344 form.fields.push_back(field); |
| 1311 test::CreateTestFormField("Quest", "quest", "", "quest", &field); | 1345 test::CreateTestFormField("Quest", "quest", "", "quest", &field); |
| 1312 form.fields.push_back(field); | 1346 form.fields.push_back(field); |
| 1313 test::CreateTestFormField("Color", "color", "", "text", &field); | 1347 test::CreateTestFormField("Color", "color", "", "text", &field); |
| 1314 form.fields.push_back(field); | 1348 form.fields.push_back(field); |
| 1315 | 1349 |
| 1316 std::vector<FormData> forms(1, form); | 1350 std::vector<FormData> forms(1, form); |
| 1317 FormsSeen(forms); | 1351 FormsSeen(forms); |
| 1318 | 1352 |
| 1319 GetAutofillSuggestions(form, field); | 1353 GetAutofillSuggestions(form, field); |
| 1320 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); | 1354 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); |
| 1321 } | 1355 } |
| 1322 | 1356 |
| 1323 // Test that we cull duplicate profile suggestions. | 1357 // Test that we cull duplicate profile suggestions. |
| 1324 TEST_F(AutofillManagerTest, GetProfileSuggestionsWithDuplicates) { | 1358 TEST_F(AutofillManagerTest, GetProfileSuggestions_WithDuplicates) { |
| 1325 // Set up our form data. | 1359 // Set up our form data. |
| 1326 FormData form; | 1360 FormData form; |
| 1327 test::CreateTestAddressFormData(&form); | 1361 test::CreateTestAddressFormData(&form); |
| 1328 std::vector<FormData> forms(1, form); | 1362 std::vector<FormData> forms(1, form); |
| 1329 FormsSeen(forms); | 1363 FormsSeen(forms); |
| 1330 | 1364 |
| 1331 // Add a duplicate profile. | 1365 // Add a duplicate profile. |
| 1332 AutofillProfile* duplicate_profile = | 1366 AutofillProfile* duplicate_profile = |
| 1333 new AutofillProfile( | 1367 new AutofillProfile( |
| 1334 *(autofill_manager_->GetProfileWithGUID( | 1368 *(autofill_manager_->GetProfileWithGUID( |
| 1335 "00000000-0000-0000-0000-000000000001"))); | 1369 "00000000-0000-0000-0000-000000000001"))); |
| 1336 autofill_manager_->AddProfile(duplicate_profile); | 1370 autofill_manager_->AddProfile(duplicate_profile); |
| 1337 | 1371 |
| 1338 const FormFieldData& field = form.fields[0]; | 1372 const FormFieldData& field = form.fields[0]; |
| 1339 GetAutofillSuggestions(form, field); | 1373 GetAutofillSuggestions(form, field); |
| 1340 | 1374 |
| 1341 // Test that we sent the right values to the external delegate. | 1375 // Test that we sent the right values to the external delegate. |
| 1342 external_delegate_->CheckSuggestions( | 1376 external_delegate_->CheckSuggestions( |
| 1343 kDefaultPageID, Suggestion("Charles", "123 Apple St.", "", 1), | 1377 kDefaultPageID, Suggestion("Charles", "123 Apple St.", "", 1), |
| 1344 Suggestion("Elvis", "3734 Elvis Presley Blvd.", "", 2)); | 1378 Suggestion("Elvis", "3734 Elvis Presley Blvd.", "", 2)); |
| 1345 } | 1379 } |
| 1346 | 1380 |
| 1347 // Test that we return no suggestions when autofill is disabled. | 1381 // Test that we return no suggestions when autofill is disabled. |
| 1348 TEST_F(AutofillManagerTest, GetProfileSuggestionsAutofillDisabledByUser) { | 1382 TEST_F(AutofillManagerTest, GetProfileSuggestions_AutofillDisabledByUser) { |
| 1349 // Set up our form data. | 1383 // Set up our form data. |
| 1350 FormData form; | 1384 FormData form; |
| 1351 test::CreateTestAddressFormData(&form); | 1385 test::CreateTestAddressFormData(&form); |
| 1352 std::vector<FormData> forms(1, form); | 1386 std::vector<FormData> forms(1, form); |
| 1353 FormsSeen(forms); | 1387 FormsSeen(forms); |
| 1354 | 1388 |
| 1355 // Disable Autofill. | 1389 // Disable Autofill. |
| 1356 autofill_manager_->set_autofill_enabled(false); | 1390 autofill_manager_->set_autofill_enabled(false); |
| 1357 | 1391 |
| 1358 const FormFieldData& field = form.fields[0]; | 1392 const FormFieldData& field = form.fields[0]; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1459 // Test that we sent the right value to the external delegate. | 1493 // Test that we sent the right value to the external delegate. |
| 1460 external_delegate_->CheckSuggestions( | 1494 external_delegate_->CheckSuggestions( |
| 1461 kDefaultPageID, Suggestion("MasterCard\xC2\xA0\xE2\x8B\xAF" | 1495 kDefaultPageID, Suggestion("MasterCard\xC2\xA0\xE2\x8B\xAF" |
| 1462 "3123", | 1496 "3123", |
| 1463 "08/17", kMasterCard, | 1497 "08/17", kMasterCard, |
| 1464 autofill_manager_->GetPackedCreditCardID(7))); | 1498 autofill_manager_->GetPackedCreditCardID(7))); |
| 1465 } | 1499 } |
| 1466 | 1500 |
| 1467 // Test that we return only matching credit card profile suggestions when the | 1501 // Test that we return only matching credit card profile suggestions when the |
| 1468 // selected form field has been partially filled out. | 1502 // selected form field has been partially filled out. |
| 1469 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsMatchCharacter) { | 1503 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_MatchCharacter) { |
| 1470 // Set up our form data. | 1504 // Set up our form data. |
| 1471 FormData form; | 1505 FormData form; |
| 1472 CreateTestCreditCardFormData(&form, true, false); | 1506 CreateTestCreditCardFormData(&form, true, false); |
| 1473 std::vector<FormData> forms(1, form); | 1507 std::vector<FormData> forms(1, form); |
| 1474 FormsSeen(forms); | 1508 FormsSeen(forms); |
| 1475 | 1509 |
| 1476 FormFieldData field; | 1510 FormFieldData field; |
| 1477 test::CreateTestFormField("Card Number", "cardnumber", "78", "text", &field); | 1511 test::CreateTestFormField("Card Number", "cardnumber", "78", "text", &field); |
| 1478 GetAutofillSuggestions(form, field); | 1512 GetAutofillSuggestions(form, field); |
| 1479 | 1513 |
| 1480 // Test that we sent the right values to the external delegate. | 1514 // Test that we sent the right values to the external delegate. |
| 1481 external_delegate_->CheckSuggestions( | 1515 external_delegate_->CheckSuggestions( |
| 1482 kDefaultPageID, Suggestion("Visa\xC2\xA0\xE2\x8B\xAF" | 1516 kDefaultPageID, Suggestion("Visa\xC2\xA0\xE2\x8B\xAF" |
| 1483 "3456", | 1517 "3456", |
| 1484 "04/99", kVisaCard, | 1518 "04/99", kVisaCard, |
| 1485 autofill_manager_->GetPackedCreditCardID(4))); | 1519 autofill_manager_->GetPackedCreditCardID(4))); |
| 1486 } | 1520 } |
| 1487 | 1521 |
| 1488 // Test that we return credit card profile suggestions when the selected form | 1522 // Test that we return credit card profile suggestions when the selected form |
| 1489 // field is not the credit card number field. | 1523 // field is not the credit card number field. |
| 1490 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonCCNumber) { | 1524 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_NonCCNumber) { |
| 1491 // Set up our form data. | 1525 // Set up our form data. |
| 1492 FormData form; | 1526 FormData form; |
| 1493 CreateTestCreditCardFormData(&form, true, false); | 1527 CreateTestCreditCardFormData(&form, true, false); |
| 1494 std::vector<FormData> forms(1, form); | 1528 std::vector<FormData> forms(1, form); |
| 1495 FormsSeen(forms); | 1529 FormsSeen(forms); |
| 1496 | 1530 |
| 1497 const FormFieldData& field = form.fields[0]; | 1531 const FormFieldData& field = form.fields[0]; |
| 1498 GetAutofillSuggestions(form, field); | 1532 GetAutofillSuggestions(form, field); |
| 1499 | 1533 |
| 1500 #if defined(OS_ANDROID) | 1534 #if defined(OS_ANDROID) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1513 external_delegate_->CheckSuggestions( | 1547 external_delegate_->CheckSuggestions( |
| 1514 kDefaultPageID, | 1548 kDefaultPageID, |
| 1515 Suggestion("Elvis Presley", kVisaSuggestion, kVisaCard, | 1549 Suggestion("Elvis Presley", kVisaSuggestion, kVisaCard, |
| 1516 autofill_manager_->GetPackedCreditCardID(4)), | 1550 autofill_manager_->GetPackedCreditCardID(4)), |
| 1517 Suggestion("Buddy Holly", kMcSuggestion, kMasterCard, | 1551 Suggestion("Buddy Holly", kMcSuggestion, kMasterCard, |
| 1518 autofill_manager_->GetPackedCreditCardID(5))); | 1552 autofill_manager_->GetPackedCreditCardID(5))); |
| 1519 } | 1553 } |
| 1520 | 1554 |
| 1521 // Test that we return a warning explaining that credit card profile suggestions | 1555 // Test that we return a warning explaining that credit card profile suggestions |
| 1522 // are unavailable when the form is not secure. | 1556 // are unavailable when the form is not secure. |
| 1523 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonHTTPS) { | 1557 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_NonHTTPS) { |
| 1524 // Set up our form data. | 1558 // Set up our form data. |
| 1525 FormData form; | 1559 FormData form; |
| 1526 CreateTestCreditCardFormData(&form, false, false); | 1560 CreateTestCreditCardFormData(&form, false, false); |
| 1527 std::vector<FormData> forms(1, form); | 1561 std::vector<FormData> forms(1, form); |
| 1528 FormsSeen(forms); | 1562 FormsSeen(forms); |
| 1529 | 1563 |
| 1530 const FormFieldData& field = form.fields[0]; | 1564 const FormFieldData& field = form.fields[0]; |
| 1531 GetAutofillSuggestions(form, field); | 1565 GetAutofillSuggestions(form, field); |
| 1532 | 1566 |
| 1533 // Test that we sent the right values to the external delegate. | 1567 // Test that we sent the right values to the external delegate. |
| 1534 external_delegate_->CheckSuggestions( | 1568 external_delegate_->CheckSuggestions( |
| 1535 kDefaultPageID, | 1569 kDefaultPageID, |
| 1536 Suggestion( | 1570 Suggestion( |
| 1537 l10n_util::GetStringUTF8(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION), | 1571 l10n_util::GetStringUTF8(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION), |
| 1538 "", "", -1)); | 1572 "", "", -1)); |
| 1539 | 1573 |
| 1540 // Clear the test credit cards and try again -- we shouldn't return a warning. | 1574 // Clear the test credit cards and try again -- we shouldn't return a warning. |
| 1541 personal_data_.ClearCreditCards(); | 1575 personal_data_.ClearCreditCards(); |
| 1542 GetAutofillSuggestions(form, field); | 1576 GetAutofillSuggestions(form, field); |
| 1543 // Autocomplete suggestions are queried, but not Autofill. | 1577 // Autocomplete suggestions are queried, but not Autofill. |
| 1544 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); | 1578 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); |
| 1545 } | 1579 } |
| 1546 | 1580 |
| 1547 // Test that we return all credit card suggestions in the case that two cards | 1581 // Test that we return all credit card suggestions in the case that two cards |
| 1548 // have the same obfuscated number. | 1582 // have the same obfuscated number. |
| 1549 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsRepeatedObfuscatedNumber) { | 1583 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_RepeatedObfuscatedNumber) { |
| 1550 // Add a credit card with the same obfuscated number as Elvis's. | 1584 // Add a credit card with the same obfuscated number as Elvis's. |
| 1551 // |credit_card| will be owned by the mock PersonalDataManager. | 1585 // |credit_card| will be owned by the mock PersonalDataManager. |
| 1552 CreditCard* credit_card = new CreditCard; | 1586 CreditCard* credit_card = new CreditCard; |
| 1553 test::SetCreditCardInfo(credit_card, "Elvis Presley", | 1587 test::SetCreditCardInfo(credit_card, "Elvis Presley", |
| 1554 "5231567890123456", // Mastercard | 1588 "5231567890123456", // Mastercard |
| 1555 "05", "2999"); | 1589 "05", "2999"); |
| 1556 credit_card->set_guid("00000000-0000-0000-0000-000000000007"); | 1590 credit_card->set_guid("00000000-0000-0000-0000-000000000007"); |
| 1557 credit_card->set_use_date(base::Time::Now() - base::TimeDelta::FromDays(15)); | 1591 credit_card->set_use_date(base::Time::Now() - base::TimeDelta::FromDays(15)); |
| 1558 autofill_manager_->AddCreditCard(credit_card); | 1592 autofill_manager_->AddCreditCard(credit_card); |
| 1559 | 1593 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1720 field.is_autofilled = true; | 1754 field.is_autofilled = true; |
| 1721 field.value = ASCIIToUTF16("Elvis"); | 1755 field.value = ASCIIToUTF16("Elvis"); |
| 1722 GetAutofillSuggestions(form, field); | 1756 GetAutofillSuggestions(form, field); |
| 1723 | 1757 |
| 1724 // Test that we sent the right values to the external delegate. | 1758 // Test that we sent the right values to the external delegate. |
| 1725 external_delegate_->CheckSuggestions( | 1759 external_delegate_->CheckSuggestions( |
| 1726 kDefaultPageID, | 1760 kDefaultPageID, |
| 1727 Suggestion("Elvis", "", "", 1)); | 1761 Suggestion("Elvis", "", "", 1)); |
| 1728 } | 1762 } |
| 1729 | 1763 |
| 1730 TEST_F(AutofillManagerTest, GetProfileSuggestionsFancyPhone) { | 1764 TEST_F(AutofillManagerTest, GetProfileSuggestions_FancyPhone) { |
| 1731 // Set up our form data. | 1765 // Set up our form data. |
| 1732 FormData form; | 1766 FormData form; |
| 1733 test::CreateTestAddressFormData(&form); | 1767 test::CreateTestAddressFormData(&form); |
| 1734 std::vector<FormData> forms(1, form); | 1768 std::vector<FormData> forms(1, form); |
| 1735 FormsSeen(forms); | 1769 FormsSeen(forms); |
| 1736 | 1770 |
| 1737 AutofillProfile* profile = new AutofillProfile; | 1771 AutofillProfile* profile = new AutofillProfile; |
| 1738 profile->set_guid("00000000-0000-0000-0000-000000000103"); | 1772 profile->set_guid("00000000-0000-0000-0000-000000000103"); |
| 1739 profile->SetInfo(AutofillType(NAME_FULL), ASCIIToUTF16("Natty Bumppo"), | 1773 profile->SetInfo(AutofillType(NAME_FULL), ASCIIToUTF16("Natty Bumppo"), |
| 1740 "en-US"); | 1774 "en-US"); |
| 1741 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, | 1775 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, |
| 1742 ASCIIToUTF16("1800PRAIRIE")); | 1776 ASCIIToUTF16("1800PRAIRIE")); |
| 1743 autofill_manager_->AddProfile(profile); | 1777 autofill_manager_->AddProfile(profile); |
| 1744 | 1778 |
| 1745 const FormFieldData& field = form.fields[9]; | 1779 const FormFieldData& field = form.fields[9]; |
| 1746 GetAutofillSuggestions(form, field); | 1780 GetAutofillSuggestions(form, field); |
| 1747 | 1781 |
| 1748 // Test that we sent the right values to the external delegate. Inferred | 1782 // Test that we sent the right values to the external delegate. Inferred |
| 1749 // labels include the most private field of those that would be filled. | 1783 // labels include the most private field of those that would be filled. |
| 1750 external_delegate_->CheckSuggestions( | 1784 external_delegate_->CheckSuggestions( |
| 1751 kDefaultPageID, | 1785 kDefaultPageID, |
| 1752 Suggestion("18007724743", "Natty Bumppo", "", 1), // 1800PRAIRIE | 1786 Suggestion("18007724743", "Natty Bumppo", "", 1), // 1800PRAIRIE |
| 1753 Suggestion("23456789012", "123 Apple St.", "", 2), | 1787 Suggestion("23456789012", "123 Apple St.", "", 2), |
| 1754 Suggestion("12345678901", "3734 Elvis Presley Blvd.", "", 3)); | 1788 Suggestion("12345678901", "3734 Elvis Presley Blvd.", "", 3)); |
| 1755 } | 1789 } |
| 1756 | 1790 |
| 1757 TEST_F(AutofillManagerTest, GetProfileSuggestionsForPhonePrefixOrSuffix) { | 1791 TEST_F(AutofillManagerTest, GetProfileSuggestions_ForPhonePrefixOrSuffix) { |
| 1758 // Set up our form data. | 1792 // Set up our form data. |
| 1759 FormData form; | 1793 FormData form; |
| 1760 form.name = ASCIIToUTF16("MyForm"); | 1794 form.name = ASCIIToUTF16("MyForm"); |
| 1761 form.origin = GURL("http://myform.com/form.html"); | 1795 form.origin = GURL("http://myform.com/form.html"); |
| 1762 form.action = GURL("http://myform.com/submit.html"); | 1796 form.action = GURL("http://myform.com/submit.html"); |
| 1763 | 1797 |
| 1764 struct { | 1798 struct { |
| 1765 const char* const label; | 1799 const char* const label; |
| 1766 const char* const name; | 1800 const char* const name; |
| 1767 size_t max_length; | 1801 size_t max_length; |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2959 EXPECT_EQ(0, personal_data_.num_times_save_imported_profile_called()); | 2993 EXPECT_EQ(0, personal_data_.num_times_save_imported_profile_called()); |
| 2960 } | 2994 } |
| 2961 | 2995 |
| 2962 // Test that when Autocomplete is enabled and Autofill is disabled, form | 2996 // Test that when Autocomplete is enabled and Autofill is disabled, form |
| 2963 // submissions are still received by AutocompleteHistoryManager. | 2997 // submissions are still received by AutocompleteHistoryManager. |
| 2964 TEST_F(AutofillManagerTest, FormSubmittedAutocompleteEnabled) { | 2998 TEST_F(AutofillManagerTest, FormSubmittedAutocompleteEnabled) { |
| 2965 TestAutofillClient client; | 2999 TestAutofillClient client; |
| 2966 autofill_manager_.reset( | 3000 autofill_manager_.reset( |
| 2967 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); | 3001 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); |
| 2968 autofill_manager_->set_autofill_enabled(false); | 3002 autofill_manager_->set_autofill_enabled(false); |
| 2969 autofill_manager_->autocomplete_history_manager_.reset( | |
| 2970 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | |
| 2971 | 3003 |
| 2972 // Set up our form data. | 3004 // Set up our form data. |
| 2973 FormData form; | 3005 FormData form; |
| 2974 test::CreateTestAddressFormData(&form); | 3006 test::CreateTestAddressFormData(&form); |
| 2975 MockAutocompleteHistoryManager* m = static_cast< | 3007 |
| 2976 MockAutocompleteHistoryManager*>( | 3008 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 2977 autofill_manager_->autocomplete_history_manager_.get()); | |
| 2978 EXPECT_CALL(*m, OnWillSubmitForm(_)); | 3009 EXPECT_CALL(*m, OnWillSubmitForm(_)); |
| 2979 FormSubmitted(form); | 3010 FormSubmitted(form); |
| 2980 } | 3011 } |
| 2981 | 3012 |
| 2982 // Test that when Autofill is disabled, Autocomplete suggestions are still | 3013 // Test that when Autofill is disabled, Autocomplete suggestions are still |
| 2983 // queried. | 3014 // queried. |
| 2984 TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillDisabled) { | 3015 TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillDisabled) { |
| 2985 TestAutofillClient client; | 3016 TestAutofillClient client; |
| 2986 autofill_manager_.reset( | 3017 autofill_manager_.reset( |
| 2987 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); | 3018 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); |
| 2988 autofill_manager_->set_autofill_enabled(false); | 3019 autofill_manager_->set_autofill_enabled(false); |
| 2989 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 3020 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
| 2990 | 3021 |
| 2991 // Set up our form data. | 3022 // Set up our form data. |
| 2992 FormData form; | 3023 FormData form; |
| 2993 test::CreateTestAddressFormData(&form); | 3024 test::CreateTestAddressFormData(&form); |
| 2994 std::vector<FormData> forms(1, form); | 3025 std::vector<FormData> forms(1, form); |
| 2995 FormsSeen(forms); | 3026 FormsSeen(forms); |
| 2996 const FormFieldData& field = form.fields[0]; | 3027 const FormFieldData& field = form.fields[0]; |
| 2997 | 3028 |
| 2998 // Expect Autocomplete manager to be called for suggestions. | 3029 // Expect Autocomplete manager to be called for suggestions. |
| 2999 autofill_manager_->autocomplete_history_manager_.reset( | 3030 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 3000 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | 3031 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)); |
| 3001 MockAutocompleteHistoryManager* m = static_cast< | |
| 3002 MockAutocompleteHistoryManager*>( | |
| 3003 autofill_manager_->autocomplete_history_manager_.get()); | |
| 3004 EXPECT_CALL(*m, | |
| 3005 OnGetAutocompleteSuggestions(_, _, _, _)); | |
| 3006 | 3032 |
| 3007 GetAutofillSuggestions(form, field); | 3033 GetAutofillSuggestions(form, field); |
| 3008 } | 3034 } |
| 3009 | 3035 |
| 3010 // Test that when Autofill is disabled and the field should not autocomplete, | 3036 // Test that when Autofill is disabled and the field should not autocomplete, |
| 3011 // autocomplete is not queried for suggestions. | 3037 // autocomplete is not queried for suggestions. |
| 3012 TEST_F(AutofillManagerTest, | 3038 TEST_F(AutofillManagerTest, |
| 3013 AutocompleteSuggestions_AutofillDisabledAndFieldShouldNotAutocomplete) { | 3039 AutocompleteSuggestions_AutofillDisabledAndFieldShouldNotAutocomplete) { |
| 3014 TestAutofillClient client; | 3040 TestAutofillClient client; |
| 3015 autofill_manager_.reset( | 3041 autofill_manager_.reset( |
| 3016 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); | 3042 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); |
| 3017 autofill_manager_->set_autofill_enabled(false); | 3043 autofill_manager_->set_autofill_enabled(false); |
| 3018 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 3044 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
| 3019 | 3045 |
| 3020 // Set up our form data. | 3046 // Set up our form data. |
| 3021 FormData form; | 3047 FormData form; |
| 3022 test::CreateTestAddressFormData(&form); | 3048 test::CreateTestAddressFormData(&form); |
| 3023 std::vector<FormData> forms(1, form); | 3049 std::vector<FormData> forms(1, form); |
| 3024 FormsSeen(forms); | 3050 FormsSeen(forms); |
| 3025 FormFieldData field = form.fields[0]; | 3051 FormFieldData field = form.fields[0]; |
| 3026 field.should_autocomplete = false; | 3052 field.should_autocomplete = false; |
| 3027 | 3053 |
| 3028 // Autocomplete manager is not called for suggestions. | 3054 // Autocomplete manager is not called for suggestions. |
| 3029 autofill_manager_->autocomplete_history_manager_.reset( | 3055 |
| 3030 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | 3056 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 3031 MockAutocompleteHistoryManager* m = static_cast< | 3057 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); |
| 3032 MockAutocompleteHistoryManager*>( | |
| 3033 autofill_manager_->autocomplete_history_manager_.get()); | |
| 3034 EXPECT_CALL(*m, | |
| 3035 OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); | |
| 3036 | 3058 |
| 3037 GetAutofillSuggestions(form, field); | 3059 GetAutofillSuggestions(form, field); |
| 3038 } | 3060 } |
| 3039 | 3061 |
| 3040 // Test that we do not query for Autocomplete suggestions when there are | 3062 // Test that we do not query for Autocomplete suggestions when there are |
| 3041 // Autofill suggestions available. | 3063 // Autofill suggestions available. |
| 3042 TEST_F(AutofillManagerTest, AutocompleteSuggestions_NoneWhenAutofillPresent) { | 3064 TEST_F(AutofillManagerTest, AutocompleteSuggestions_NoneWhenAutofillPresent) { |
| 3043 // Set up our form data. | 3065 // Set up our form data. |
| 3044 FormData form; | 3066 FormData form; |
| 3045 test::CreateTestAddressFormData(&form); | 3067 test::CreateTestAddressFormData(&form); |
| 3046 std::vector<FormData> forms(1, form); | 3068 std::vector<FormData> forms(1, form); |
| 3047 FormsSeen(forms); | 3069 FormsSeen(forms); |
| 3048 | 3070 |
| 3049 const FormFieldData& field = form.fields[0]; | 3071 const FormFieldData& field = form.fields[0]; |
| 3050 | 3072 |
| 3051 // Autocomplete manager is not called for suggestions. | 3073 // Autocomplete manager is not called for suggestions. |
| 3052 autofill_manager_->autocomplete_history_manager_.reset( | 3074 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 3053 new MockAutocompleteHistoryManager(autofill_driver_.get(), | 3075 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); |
| 3054 autofill_manager_->client())); | |
| 3055 MockAutocompleteHistoryManager* m = static_cast< | |
| 3056 MockAutocompleteHistoryManager*>( | |
| 3057 autofill_manager_->autocomplete_history_manager_.get()); | |
| 3058 EXPECT_CALL(*m, | |
| 3059 OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); | |
| 3060 | 3076 |
| 3061 GetAutofillSuggestions(form, field); | 3077 GetAutofillSuggestions(form, field); |
| 3062 | 3078 |
| 3063 // Test that we sent the right values to the external delegate. Inferred | 3079 // Test that we sent the right values to the external delegate. Inferred |
| 3064 // labels include full first relevant field, which in this case is the | 3080 // labels include full first relevant field, which in this case is the |
| 3065 // address line 1. | 3081 // address line 1. |
| 3066 external_delegate_->CheckSuggestions( | 3082 external_delegate_->CheckSuggestions( |
| 3067 kDefaultPageID, Suggestion("Charles", "123 Apple St.", "", 1), | 3083 kDefaultPageID, Suggestion("Charles", "123 Apple St.", "", 1), |
| 3068 Suggestion("Elvis", "3734 Elvis Presley Blvd.", "", 2)); | 3084 Suggestion("Elvis", "3734 Elvis Presley Blvd.", "", 2)); |
| 3069 } | 3085 } |
| 3070 | 3086 |
| 3071 // Test that we query for Autocomplete suggestions when there are no Autofill | 3087 // Test that we query for Autocomplete suggestions when there are no Autofill |
| 3072 // suggestions available. | 3088 // suggestions available. |
| 3073 TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillEmpty) { | 3089 TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillEmpty) { |
| 3074 // Set up our form data. | 3090 // Set up our form data. |
| 3075 FormData form; | 3091 FormData form; |
| 3076 test::CreateTestAddressFormData(&form); | 3092 test::CreateTestAddressFormData(&form); |
| 3077 std::vector<FormData> forms(1, form); | 3093 std::vector<FormData> forms(1, form); |
| 3078 FormsSeen(forms); | 3094 FormsSeen(forms); |
| 3079 | 3095 |
| 3080 // No suggestions matching "donkey". | 3096 // No suggestions matching "donkey". |
| 3081 FormFieldData field; | 3097 FormFieldData field; |
| 3082 test::CreateTestFormField("Email", "email", "donkey", "email", &field); | 3098 test::CreateTestFormField("Email", "email", "donkey", "email", &field); |
| 3083 | 3099 |
| 3084 // Autocomplete manager is called for suggestions because Autofill is empty. | 3100 // Autocomplete manager is called for suggestions because Autofill is empty. |
| 3085 autofill_manager_->autocomplete_history_manager_.reset( | 3101 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 3086 new MockAutocompleteHistoryManager(autofill_driver_.get(), | 3102 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)); |
| 3087 autofill_manager_->client())); | |
| 3088 MockAutocompleteHistoryManager* m = static_cast< | |
| 3089 MockAutocompleteHistoryManager*>( | |
| 3090 autofill_manager_->autocomplete_history_manager_.get()); | |
| 3091 EXPECT_CALL(*m, | |
| 3092 OnGetAutocompleteSuggestions(_, _, _, _)); | |
| 3093 | 3103 |
| 3094 GetAutofillSuggestions(form, field); | 3104 GetAutofillSuggestions(form, field); |
| 3095 } | 3105 } |
| 3096 | 3106 |
| 3097 // Test that when Autofill is disabled and the field is a credit card name | 3107 // Test that when Autofill is disabled and the field is a credit card name |
| 3098 // field, | 3108 // field, |
| 3099 // autocomplete is queried for suggestions. | 3109 // autocomplete is queried for suggestions. |
| 3100 TEST_F(AutofillManagerTest, | 3110 TEST_F(AutofillManagerTest, |
| 3101 AutocompleteSuggestions_CreditCardNameFieldShouldAutocomplete) { | 3111 AutocompleteSuggestions_CreditCardNameFieldShouldAutocomplete) { |
| 3102 TestAutofillClient client; | 3112 TestAutofillClient client; |
| 3103 autofill_manager_.reset( | 3113 autofill_manager_.reset( |
| 3104 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); | 3114 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); |
| 3105 autofill_manager_->set_autofill_enabled(false); | 3115 autofill_manager_->set_autofill_enabled(false); |
| 3106 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 3116 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
| 3107 | 3117 |
| 3108 // Set up our form data. | 3118 // Set up our form data. |
| 3109 FormData form; | 3119 FormData form; |
| 3110 CreateTestCreditCardFormData(&form, false, false); | 3120 CreateTestCreditCardFormData(&form, false, false); |
| 3111 std::vector<FormData> forms(1, form); | 3121 std::vector<FormData> forms(1, form); |
| 3112 FormsSeen(forms); | 3122 FormsSeen(forms); |
| 3113 // The first field is "Name on card", which should autocomplete. | 3123 // The first field is "Name on card", which should autocomplete. |
| 3114 FormFieldData field = form.fields[0]; | 3124 FormFieldData field = form.fields[0]; |
| 3115 field.should_autocomplete = true; | 3125 field.should_autocomplete = true; |
| 3116 | 3126 |
| 3117 // Autocomplete manager is not called for suggestions. | 3127 // Autocomplete manager is not called for suggestions. |
| 3118 autofill_manager_->autocomplete_history_manager_.reset( | 3128 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 3119 new MockAutocompleteHistoryManager(autofill_driver_.get(), | |
| 3120 autofill_manager_->client())); | |
| 3121 MockAutocompleteHistoryManager* m = | |
| 3122 static_cast<MockAutocompleteHistoryManager*>( | |
| 3123 autofill_manager_->autocomplete_history_manager_.get()); | |
| 3124 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)); | 3129 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)); |
| 3125 | 3130 |
| 3126 GetAutofillSuggestions(form, field); | 3131 GetAutofillSuggestions(form, field); |
| 3127 } | 3132 } |
| 3128 | 3133 |
| 3129 // Test that when Autofill is disabled and the field is a credit card number | 3134 // Test that when Autofill is disabled and the field is a credit card number |
| 3130 // field, autocomplete is not queried for suggestions. | 3135 // field, autocomplete is not queried for suggestions. |
| 3131 TEST_F(AutofillManagerTest, | 3136 TEST_F(AutofillManagerTest, |
| 3132 AutocompleteSuggestions_CreditCardNumberShouldNotAutocomplete) { | 3137 AutocompleteSuggestions_CreditCardNumberShouldNotAutocomplete) { |
| 3133 TestAutofillClient client; | 3138 TestAutofillClient client; |
| 3134 autofill_manager_.reset( | 3139 autofill_manager_.reset( |
| 3135 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); | 3140 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); |
| 3136 autofill_manager_->set_autofill_enabled(false); | 3141 autofill_manager_->set_autofill_enabled(false); |
| 3137 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 3142 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
| 3138 | 3143 |
| 3139 // Set up our form data. | 3144 // Set up our form data. |
| 3140 FormData form; | 3145 FormData form; |
| 3141 CreateTestCreditCardFormData(&form, false, false); | 3146 CreateTestCreditCardFormData(&form, false, false); |
| 3142 std::vector<FormData> forms(1, form); | 3147 std::vector<FormData> forms(1, form); |
| 3143 FormsSeen(forms); | 3148 FormsSeen(forms); |
| 3144 // The second field is "Card Number", which should not autocomplete. | 3149 // The second field is "Card Number", which should not autocomplete. |
| 3145 FormFieldData field = form.fields[1]; | 3150 FormFieldData field = form.fields[1]; |
| 3146 field.should_autocomplete = true; | 3151 field.should_autocomplete = true; |
| 3147 | 3152 |
| 3148 // Autocomplete manager is not called for suggestions. | 3153 // Autocomplete manager is not called for suggestions. |
| 3149 autofill_manager_->autocomplete_history_manager_.reset( | 3154 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 3150 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | |
| 3151 MockAutocompleteHistoryManager* m = | |
| 3152 static_cast<MockAutocompleteHistoryManager*>( | |
| 3153 autofill_manager_->autocomplete_history_manager_.get()); | |
| 3154 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); | 3155 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); |
| 3155 | 3156 |
| 3156 GetAutofillSuggestions(form, field); | 3157 GetAutofillSuggestions(form, field); |
| 3157 } | 3158 } |
| 3158 | 3159 |
| 3159 // Test that we do not query for Autocomplete suggestions when there are no | 3160 // Test that we do not query for Autocomplete suggestions when there are no |
| 3160 // Autofill suggestions available, and that the field should not autocomplete. | 3161 // Autofill suggestions available, and that the field should not autocomplete. |
| 3161 TEST_F( | 3162 TEST_F( |
| 3162 AutofillManagerTest, | 3163 AutofillManagerTest, |
| 3163 AutocompleteSuggestions_NoneWhenAutofillEmptyFieldShouldNotAutocomplete) { | 3164 AutocompleteSuggestions_NoneWhenAutofillEmptyFieldShouldNotAutocomplete) { |
| 3164 // Set up our form data. | 3165 // Set up our form data. |
| 3165 FormData form; | 3166 FormData form; |
| 3166 test::CreateTestAddressFormData(&form); | 3167 test::CreateTestAddressFormData(&form); |
| 3167 std::vector<FormData> forms(1, form); | 3168 std::vector<FormData> forms(1, form); |
| 3168 FormsSeen(forms); | 3169 FormsSeen(forms); |
| 3169 | 3170 |
| 3170 // No suggestions matching "donkey". | 3171 // No suggestions matching "donkey". |
| 3171 FormFieldData field; | 3172 FormFieldData field; |
| 3172 field.should_autocomplete = false; | 3173 field.should_autocomplete = false; |
| 3173 test::CreateTestFormField("Email", "email", "donkey", "email", &field); | 3174 test::CreateTestFormField("Email", "email", "donkey", "email", &field); |
| 3174 | 3175 |
| 3175 // Autocomplete manager is not called for suggestions. | 3176 // Autocomplete manager is not called for suggestions. |
| 3176 autofill_manager_->autocomplete_history_manager_.reset( | 3177 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 3177 new MockAutocompleteHistoryManager(autofill_driver_.get(), | 3178 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); |
| 3178 autofill_manager_->client())); | |
| 3179 MockAutocompleteHistoryManager* m = static_cast< | |
| 3180 MockAutocompleteHistoryManager*>( | |
| 3181 autofill_manager_->autocomplete_history_manager_.get()); | |
| 3182 EXPECT_CALL(*m, | |
| 3183 OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); | |
| 3184 | 3179 |
| 3185 GetAutofillSuggestions(form, field); | 3180 GetAutofillSuggestions(form, field); |
| 3186 } | 3181 } |
| 3187 | 3182 |
| 3188 TEST_F(AutofillManagerTest, AutocompleteOffRespectedForAutocomplete) { | 3183 TEST_F(AutofillManagerTest, AutocompleteOffRespectedForAutocomplete) { |
| 3189 TestAutofillClient client; | 3184 TestAutofillClient client; |
| 3190 autofill_manager_.reset( | 3185 autofill_manager_.reset( |
| 3191 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); | 3186 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); |
| 3192 autofill_manager_->set_autofill_enabled(false); | 3187 autofill_manager_->set_autofill_enabled(false); |
| 3193 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 3188 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
| 3194 | 3189 |
| 3195 autofill_manager_->autocomplete_history_manager_.reset( | 3190 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 3196 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); | 3191 EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); |
| 3197 MockAutocompleteHistoryManager* m = static_cast< | |
| 3198 MockAutocompleteHistoryManager*>( | |
| 3199 autofill_manager_->autocomplete_history_manager_.get()); | |
| 3200 EXPECT_CALL(*m, | |
| 3201 OnGetAutocompleteSuggestions(_, _, _, _)).Times(0); | |
| 3202 | 3192 |
| 3203 // Set up our form data. | 3193 // Set up our form data. |
| 3204 FormData form; | 3194 FormData form; |
| 3205 test::CreateTestAddressFormData(&form); | 3195 test::CreateTestAddressFormData(&form); |
| 3206 std::vector<FormData> forms(1, form); | 3196 std::vector<FormData> forms(1, form); |
| 3207 FormsSeen(forms); | 3197 FormsSeen(forms); |
| 3208 FormFieldData* field = &form.fields[0]; | 3198 FormFieldData* field = &form.fields[0]; |
| 3209 field->should_autocomplete = false; | 3199 field->should_autocomplete = false; |
| 3210 GetAutofillSuggestions(form, *field); | 3200 GetAutofillSuggestions(form, *field); |
| 3211 } | 3201 } |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4118 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4108 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 4119 | 4109 |
| 4120 // Suggestions should still be returned for the third field because it is a | 4110 // Suggestions should still be returned for the third field because it is a |
| 4121 // credit card field. | 4111 // credit card field. |
| 4122 GetAutofillSuggestions(form, form.fields[2]); | 4112 GetAutofillSuggestions(form, form.fields[2]); |
| 4123 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4113 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 4124 } | 4114 } |
| 4125 | 4115 |
| 4126 // Test to verify suggestions appears for forms having credit card number split | 4116 // Test to verify suggestions appears for forms having credit card number split |
| 4127 // across fields. | 4117 // across fields. |
| 4128 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsForNumberSpitAcrossFields) { | 4118 TEST_F(AutofillManagerTest, |
| 4119 GetCreditCardSuggestions_ForNumberSpitAcrossFields) { | |
| 4129 // Set up our form data with credit card number split across fields. | 4120 // Set up our form data with credit card number split across fields. |
| 4130 FormData form; | 4121 FormData form; |
| 4131 form.name = ASCIIToUTF16("MyForm"); | 4122 form.name = ASCIIToUTF16("MyForm"); |
| 4132 form.origin = GURL("https://myform.com/form.html"); | 4123 form.origin = GURL("https://myform.com/form.html"); |
| 4133 form.action = GURL("https://myform.com/submit.html"); | 4124 form.action = GURL("https://myform.com/submit.html"); |
| 4134 | 4125 |
| 4135 FormFieldData name_field; | 4126 FormFieldData name_field; |
| 4136 test::CreateTestFormField("Name on Card", "nameoncard", "", "text", | 4127 test::CreateTestFormField("Name on Card", "nameoncard", "", "text", |
| 4137 &name_field); | 4128 &name_field); |
| 4138 form.fields.push_back(name_field); | 4129 form.fields.push_back(name_field); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4175 external_delegate_->CheckSuggestions( | 4166 external_delegate_->CheckSuggestions( |
| 4176 kDefaultPageID, Suggestion("Visa\xC2\xA0\xE2\x8B\xAF" | 4167 kDefaultPageID, Suggestion("Visa\xC2\xA0\xE2\x8B\xAF" |
| 4177 "3456", | 4168 "3456", |
| 4178 "04/99", kVisaCard, | 4169 "04/99", kVisaCard, |
| 4179 autofill_manager_->GetPackedCreditCardID(4))); | 4170 autofill_manager_->GetPackedCreditCardID(4))); |
| 4180 } | 4171 } |
| 4181 | 4172 |
| 4182 // Test that inputs detected to be CVC inputs are forced to | 4173 // Test that inputs detected to be CVC inputs are forced to |
| 4183 // !should_autocomplete for AutocompleteHistoryManager::OnWillSubmitForm. | 4174 // !should_autocomplete for AutocompleteHistoryManager::OnWillSubmitForm. |
| 4184 TEST_F(AutofillManagerTest, DontSaveCvcInAutocompleteHistory) { | 4175 TEST_F(AutofillManagerTest, DontSaveCvcInAutocompleteHistory) { |
| 4185 autofill_manager_->autocomplete_history_manager_.reset( | |
| 4186 new MockAutocompleteHistoryManager(autofill_driver_.get(), | |
| 4187 &autofill_client_)); | |
| 4188 FormData form_seen_by_ahm; | 4176 FormData form_seen_by_ahm; |
| 4189 MockAutocompleteHistoryManager* mock_ahm = | 4177 MockAutocompleteHistoryManager* m = UseMockAutocompleteHistoryManager(); |
| 4190 static_cast<MockAutocompleteHistoryManager*>( | 4178 EXPECT_CALL(*m, OnWillSubmitForm(_)).WillOnce(SaveArg<0>(&form_seen_by_ahm)); |
| 4191 autofill_manager_->autocomplete_history_manager_.get()); | |
| 4192 EXPECT_CALL(*mock_ahm, OnWillSubmitForm(_)) | |
| 4193 .WillOnce(SaveArg<0>(&form_seen_by_ahm)); | |
| 4194 | 4179 |
| 4195 FormData form; | 4180 FormData form; |
| 4196 form.name = ASCIIToUTF16("MyForm"); | 4181 form.name = ASCIIToUTF16("MyForm"); |
| 4197 form.origin = GURL("http://myform.com/form.html"); | 4182 form.origin = GURL("http://myform.com/form.html"); |
| 4198 form.action = GURL("http://myform.com/submit.html"); | 4183 form.action = GURL("http://myform.com/submit.html"); |
| 4199 | 4184 |
| 4200 struct { | 4185 struct { |
| 4201 const char* label; | 4186 const char* label; |
| 4202 const char* name; | 4187 const char* name; |
| 4203 const char* value; | 4188 const char* value; |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5228 FormsSeen(mixed_forms); | 5213 FormsSeen(mixed_forms); |
| 5229 | 5214 |
| 5230 // Suggestions should always be displayed. | 5215 // Suggestions should always be displayed. |
| 5231 for (const FormFieldData& field : mixed_form.fields) { | 5216 for (const FormFieldData& field : mixed_form.fields) { |
| 5232 GetAutofillSuggestions(mixed_form, field); | 5217 GetAutofillSuggestions(mixed_form, field); |
| 5233 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 5218 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 5234 } | 5219 } |
| 5235 } | 5220 } |
| 5236 | 5221 |
| 5237 } // namespace autofill | 5222 } // namespace autofill |
| OLD | NEW |