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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 3118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3129 AutocompleteSuggestionsReturned(std::vector<base::string16>()); | 3129 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
3130 | 3130 |
3131 external_delegate_->CheckSuggestions( | 3131 external_delegate_->CheckSuggestions( |
3132 kDefaultPageID, | 3132 kDefaultPageID, |
3133 Suggestion( | 3133 Suggestion( |
3134 "Visa \xE2\x8B\xAF" | 3134 "Visa \xE2\x8B\xAF" |
3135 "3456", | 3135 "3456", |
3136 "04/12", kVisaCard, autofill_manager_->GetPackedCreditCardID(4))); | 3136 "04/12", kVisaCard, autofill_manager_->GetPackedCreditCardID(4))); |
3137 } | 3137 } |
3138 | 3138 |
| 3139 // Test that when |kEnableSuggestionsWithSubstringMatch| command line switch is |
| 3140 // on we return only substring matching profile suggestions when the selected |
| 3141 // form field has been partially filled out. |
| 3142 TEST_F(AutofillManagerTest, GetProfileSuggestionsWithSubStringMatch) { |
| 3143 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 3144 autofill::switches::kEnableSuggestionsWithSubstringMatch); |
| 3145 |
| 3146 // Set up our form data. |
| 3147 FormData form; |
| 3148 test::CreateTestAddressFormData(&form); |
| 3149 std::vector<FormData> forms(1, form); |
| 3150 FormsSeen(forms); |
| 3151 |
| 3152 FormFieldData field; |
| 3153 test::CreateTestFormField("Email", "email", "GMAI", "email", &field); |
| 3154 GetAutofillSuggestions(form, field); |
| 3155 |
| 3156 // No suggestions provided, so send an empty vector as the results. |
| 3157 // This triggers the combined message send. |
| 3158 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 3159 |
| 3160 // Test that we receive email address suggestions only with substring |
| 3161 // matching to the input supplied as "GMAI" (case-insensitive) in the email |
| 3162 // field. |
| 3163 external_delegate_->CheckSuggestions( |
| 3164 kDefaultPageID, |
| 3165 Suggestion("theking@gmail.com", "Elvis Aaron Presley", "", 1), |
| 3166 Suggestion("buddy@gmail.com", "Charles Hardin Holley", "", 2)); |
| 3167 } |
| 3168 |
| 3169 // Test that when |kEnableSuggestionsWithSubstringMatch| command line switch is |
| 3170 // on we return only substring matching autocomplete suggestions when the |
| 3171 // selected form field has been partially filled out. |
| 3172 TEST_F(AutofillManagerTest, GetAutocompleteSuggestionsWithSubStringMatch) { |
| 3173 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 3174 autofill::switches::kEnableSuggestionsWithSubstringMatch); |
| 3175 |
| 3176 // Set up our form data. |
| 3177 FormData form; |
| 3178 test::CreateTestAddressFormData(&form); |
| 3179 std::vector<FormData> forms(1, form); |
| 3180 FormsSeen(forms); |
| 3181 |
| 3182 // Disable Autofill. |
| 3183 autofill_manager_->set_autofill_enabled(false); |
| 3184 |
| 3185 FormFieldData& field = form.fields[0]; |
| 3186 field.value = ASCIIToUTF16("elv"); |
| 3187 GetAutofillSuggestions(form, field); |
| 3188 |
| 3189 // Add some Autocomplete suggestions. We should return the autocomplete |
| 3190 // suggestions as autofill is disabled. |
| 3191 std::vector<base::string16> suggestions; |
| 3192 suggestions.push_back(ASCIIToUTF16("Jay.Elvis")); |
| 3193 suggestions.push_back(ASCIIToUTF16("Jason.Elvis")); |
| 3194 AutocompleteSuggestionsReturned(suggestions); |
| 3195 |
| 3196 external_delegate_->CheckSuggestions(kDefaultPageID, |
| 3197 Suggestion("Jay.Elvis", "", "", 0), |
| 3198 Suggestion("Jason.Elvis", "", "", 0)); |
| 3199 } |
| 3200 |
3139 } // namespace autofill | 3201 } // namespace autofill |
OLD | NEW |