Chromium Code Reviews| 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 861ca23e6559705ad9676a4c74c21879b417632d..180cf50902b23d66e1343d7f3dc1218f236d1efe 100644 |
| --- a/components/autofill/core/browser/autofill_manager_unittest.cc |
| +++ b/components/autofill/core/browser/autofill_manager_unittest.cc |
| @@ -1475,6 +1475,81 @@ TEST_F(AutofillManagerTest, GetProfileSuggestionsFancyPhone) { |
| expected_labels, expected_icons, expected_unique_ids); |
| } |
| +TEST_F(AutofillManagerTest, GetProfileSuggestionsForPrefixSuffixPhone) { |
|
Ilya Sherman
2014/09/03 00:55:49
nit: "PrefixSuffixPhone" -> "PhonePrefixOrSuffix"
ziran.sun
2014/09/04 13:10:25
Done.
|
| + // Set up our form data. |
| + FormData form; |
| + form.name = ASCIIToUTF16("MyForm"); |
| + form.origin = GURL("http://myform.com/form.html"); |
| + form.action = GURL("http://myform.com/submit.html"); |
| + form.user_submitted = true; |
| + |
| + struct { |
| + const char* label; |
|
Ilya Sherman
2014/09/03 00:55:49
nit: Can this be "const char* const"? Ditto for t
ziran.sun
2014/09/04 13:10:25
Done.
|
| + const char* name; |
| + size_t max_length; |
| + const char* autocomplete_attribute; |
| + } test_fields[] = {{"country code", "country_code", 1, "tel-country-code"}, |
| + {"area code", "area_code", 3, "tel-area-code"}, |
| + {"phone", "phone_prefix", 3, "tel-local-prefix"}, |
| + {"-", "phone_suffix", 4, "tel-local-suffix"}, |
| + {"Phone Extension", "ext", 5, "tel-extension"}}; |
| + |
| + FormFieldData field; |
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_fields); ++i) { |
| + test::CreateTestFormField( |
| + test_fields[i].label, test_fields[i].name, "", "text", &field); |
| + field.max_length = test_fields[i].max_length; |
| + field.autocomplete_attribute = std::string(); |
| + form.fields.push_back(field); |
| + } |
| + |
| + std::vector<FormData> forms(1, form); |
| + FormsSeen(forms); |
| + |
| + AutofillProfile* profile = new AutofillProfile; |
| + profile->set_guid("00000000-0000-0000-0000-000000000104"); |
| + std::vector<base::string16> multi_values(2); |
| + multi_values[0] = ASCIIToUTF16("1800FLOWERS"); |
| + multi_values[1] = ASCIIToUTF16("14158889999"); |
| + |
| + profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, multi_values); |
| + personal_data_.ClearAutofillProfiles(); |
| + autofill_manager_->AddProfile(profile); |
| + |
| + const FormFieldData& phone_prefix = form.fields[2]; |
| + GetAutofillSuggestions(form, phone_prefix); |
| + AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| + // Test that we sent the right prefix values to the external delegate. |
| + base::string16 expected_prefix_values[] = {ASCIIToUTF16("356"), |
| + ASCIIToUTF16("888")}; |
| + base::string16 expected_prefix_labels[] = {ASCIIToUTF16("1"), |
| + ASCIIToUTF16("1")}; |
|
Ilya Sherman
2014/09/03 00:55:49
Why are the labels "1", rather than the values tha
ziran.sun
2014/09/04 13:10:25
From my understanding, distinguishing label does n
Ilya Sherman
2014/09/11 05:32:14
Yes, you're right. Sorry for my confusion.
|
| + base::string16 expected_prefix_icons[] = {base::string16(), base::string16()}; |
| + int expected_unique_ids[] = {1, 2}; |
| + external_delegate_->CheckSuggestions(kDefaultPageID, |
| + arraysize(expected_prefix_values), |
| + expected_prefix_values, |
| + expected_prefix_labels, |
| + expected_prefix_icons, |
| + expected_unique_ids); |
| + |
| + const FormFieldData& phone_suffix = form.fields[3]; |
| + GetAutofillSuggestions(form, phone_suffix); |
| + AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| + // Test that we sent the right suffix values to the external delegate. |
| + base::string16 expected_suffix_values[] = {ASCIIToUTF16("9377"), |
| + ASCIIToUTF16("9999")}; |
| + base::string16 expected_suffix_labels[] = {ASCIIToUTF16("1"), |
| + ASCIIToUTF16("1")}; |
| + base::string16 expected_suffix_icons[] = {base::string16(), base::string16()}; |
| + external_delegate_->CheckSuggestions(kDefaultPageID, |
| + arraysize(expected_suffix_values), |
| + expected_suffix_values, |
| + expected_suffix_labels, |
| + expected_suffix_icons, |
| + expected_unique_ids); |
| +} |
| + |
| // Test that we correctly fill an address form. |
| TEST_F(AutofillManagerTest, FillAddressForm) { |
| // Set up our form data. |