Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: components/autofill/core/browser/autofill_manager_unittest.cc

Issue 1842693003: [Autofill] Fill fields where the value equals the placeholder attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/form_autofill_util.cc ('k') | components/autofill/core/common/form_field_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698