| Index: components/autofill/core/browser/autofill_manager_unittest.cc
|
| diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
|
| index 9945243bcedd5ea18bc0dccf7f5c1f34c8d62df6..e5700109c5a2660b8cbc7572b2ddfc2cb060d09c 100644
|
| --- a/components/autofill/core/browser/autofill_manager_unittest.cc
|
| +++ b/components/autofill/core/browser/autofill_manager_unittest.cc
|
| @@ -3136,4 +3136,66 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestionsForNumberSpitAcrossFields) {
|
| "04/12", kVisaCard, autofill_manager_->GetPackedCreditCardID(4)));
|
| }
|
|
|
| +// Test that when |kEnableSuggestionsWithSubStringMatch| command line switch is
|
| +// on we return only sub-string matching profile suggestions when the selected
|
| +// form field has been partially filled out.
|
| +TEST_F(AutofillManagerTest, GetProfileSuggestionsWithSubStringMatch) {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + autofill::switches::kEnableSuggestionsWithSubStringMatch);
|
| +
|
| + // Set up our form data.
|
| + FormData form;
|
| + test::CreateTestAddressFormData(&form);
|
| + std::vector<FormData> forms(1, form);
|
| + FormsSeen(forms);
|
| +
|
| + FormFieldData field;
|
| + test::CreateTestFormField("Email", "email", "GMAI", "email", &field);
|
| + GetAutofillSuggestions(form, field);
|
| +
|
| + // No suggestions provided, so send an empty vector as the results.
|
| + // This triggers the combined message send.
|
| + AutocompleteSuggestionsReturned(std::vector<base::string16>());
|
| +
|
| + // Test that we receive email address suggestions only with sub-string
|
| + // matching to the input supplied as "GMAI" (case-insensitive) in the email
|
| + // field.
|
| + external_delegate_->CheckSuggestions(
|
| + kDefaultPageID,
|
| + Suggestion("theking@gmail.com", "Elvis Aaron Presley", "", 1),
|
| + Suggestion("buddy@gmail.com", "Charles Hardin Holley", "", 2));
|
| +}
|
| +
|
| +// Test that when |kEnableSuggestionsWithSubStringMatch| command line switch is
|
| +// on we return only sub-string matching autocomplete suggestions when the
|
| +// selected form field has been partially filled out.
|
| +TEST_F(AutofillManagerTest, GetAutocompleteSuggestionsWithSubStringMatch) {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + autofill::switches::kEnableSuggestionsWithSubStringMatch);
|
| +
|
| + // Set up our form data.
|
| + FormData form;
|
| + test::CreateTestAddressFormData(&form);
|
| + std::vector<FormData> forms(1, form);
|
| + FormsSeen(forms);
|
| +
|
| + // Disable Autofill.
|
| + autofill_manager_->set_autofill_enabled(false);
|
| +
|
| + FormFieldData& field = form.fields[0];
|
| + field.value = ASCIIToUTF16("elv");
|
| + GetAutofillSuggestions(form, field);
|
| +
|
| + // Add some Autocomplete suggestions. We should return the autocomplete
|
| + // suggestions as autofill is disabled.
|
| + std::vector<base::string16> suggestions;
|
| + suggestions.push_back(ASCIIToUTF16("Jay.Elvis"));
|
| + suggestions.push_back(ASCIIToUTF16("Jason.Elvis"));
|
| + AutocompleteSuggestionsReturned(suggestions);
|
| +
|
| + external_delegate_->CheckSuggestions(kDefaultPageID,
|
| + Suggestion("Jay.Elvis", "", "", 0),
|
| + Suggestion("Jason.Elvis", "", "", 0));
|
| +}
|
| +
|
| } // namespace autofill
|
|
|