| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2145 // The address line 1 should not be filled on desktop. | 2145 // The address line 1 should not be filled on desktop. |
| 2146 if (IsDesktopPlatform()) { | 2146 if (IsDesktopPlatform()) { |
| 2147 ExpectFilledField("Address Line 1", "addr1", "", "text", | 2147 ExpectFilledField("Address Line 1", "addr1", "", "text", |
| 2148 response_data.fields[3]); | 2148 response_data.fields[3]); |
| 2149 } else { | 2149 } else { |
| 2150 ExpectFilledField("Address Line 1", "addr1", "3734 Elvis Presley Blvd.", | 2150 ExpectFilledField("Address Line 1", "addr1", "3734 Elvis Presley Blvd.", |
| 2151 "text", response_data.fields[3]); | 2151 "text", response_data.fields[3]); |
| 2152 } | 2152 } |
| 2153 } | 2153 } |
| 2154 | 2154 |
| 2155 // Test that a field with a value equal to it's placeholder attribute is filled. |
| 2156 TEST_F(AutofillManagerTest, FillAddressForm_PlaceholderEqualsValue) { |
| 2157 FormData address_form; |
| 2158 address_form.name = ASCIIToUTF16("MyForm"); |
| 2159 address_form.origin = GURL("https://myform.com/form.html"); |
| 2160 address_form.action = GURL("https://myform.com/submit.html"); |
| 2161 FormFieldData field; |
| 2162 // Set the same placeholder and value for each field. |
| 2163 test::CreateTestFormField("First name", "firstname", "", "text", &field); |
| 2164 field.placeholder = ASCIIToUTF16("First Name"); |
| 2165 field.value = ASCIIToUTF16("First Name"); |
| 2166 address_form.fields.push_back(field); |
| 2167 test::CreateTestFormField("Middle name", "middle", "", "text", &field); |
| 2168 field.placeholder = ASCIIToUTF16("Middle Name"); |
| 2169 field.value = ASCIIToUTF16("Middle Name"); |
| 2170 address_form.fields.push_back(field); |
| 2171 test::CreateTestFormField("Last name", "lastname", "", "text", &field); |
| 2172 field.placeholder = ASCIIToUTF16("Last Name"); |
| 2173 field.value = ASCIIToUTF16("Last Name"); |
| 2174 address_form.fields.push_back(field); |
| 2175 std::vector<FormData> address_forms(1, address_form); |
| 2176 FormsSeen(address_forms); |
| 2177 |
| 2178 // Fill the address form. |
| 2179 const char guid[] = "00000000-0000-0000-0000-000000000001"; |
| 2180 int response_page_id = 0; |
| 2181 FormData response_data; |
| 2182 FillAutofillFormDataAndSaveResults( |
| 2183 kDefaultPageID, address_form, address_form.fields[0], |
| 2184 MakeFrontendID(std::string(), guid), &response_page_id, &response_data); |
| 2185 |
| 2186 // All the fields should be filled. |
| 2187 ExpectFilledField("First name", "firstname", "Elvis", "text", |
| 2188 response_data.fields[0]); |
| 2189 ExpectFilledField("Middle name", "middle", "Aaron", "text", |
| 2190 response_data.fields[1]); |
| 2191 ExpectFilledField("Last name", "lastname", "Presley", "text", |
| 2192 response_data.fields[2]); |
| 2193 } |
| 2194 |
| 2155 // Test that a credit card field with an unrecognized autocomplete attribute | 2195 // Test that a credit card field with an unrecognized autocomplete attribute |
| 2156 // gets filled. | 2196 // gets filled. |
| 2157 TEST_F(AutofillManagerTest, FillCreditCardForm_UnrecognizedAttribute) { | 2197 TEST_F(AutofillManagerTest, FillCreditCardForm_UnrecognizedAttribute) { |
| 2158 // Set up the form data. | 2198 // Set up the form data. |
| 2159 FormData form; | 2199 FormData form; |
| 2160 form.name = ASCIIToUTF16("MyForm"); | 2200 form.name = ASCIIToUTF16("MyForm"); |
| 2161 form.origin = GURL("https://myform.com/form.html"); | 2201 form.origin = GURL("https://myform.com/form.html"); |
| 2162 form.action = GURL("https://myform.com/submit.html"); | 2202 form.action = GURL("https://myform.com/submit.html"); |
| 2163 | 2203 |
| 2164 FormFieldData field; | 2204 FormFieldData field; |
| (...skipping 2626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4791 FormsSeen(mixed_forms); | 4831 FormsSeen(mixed_forms); |
| 4792 | 4832 |
| 4793 // Suggestions should always be displayed. | 4833 // Suggestions should always be displayed. |
| 4794 for (const FormFieldData& field : mixed_form.fields) { | 4834 for (const FormFieldData& field : mixed_form.fields) { |
| 4795 GetAutofillSuggestions(mixed_form, field); | 4835 GetAutofillSuggestions(mixed_form, field); |
| 4796 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4836 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 4797 } | 4837 } |
| 4798 } | 4838 } |
| 4799 | 4839 |
| 4800 } // namespace autofill | 4840 } // namespace autofill |
| OLD | NEW |