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

Side by Side Diff: chrome/renderer/autofill/form_autofill_browsertest.cc

Issue 1245623003: [Autofill] Copy attributes for the select elements as well. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated heuristic tests Created 5 years, 5 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
« no previous file with comments | « no previous file | chrome/test/data/autofill/heuristics/output/04_checkout_lowes.com.out » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result3); 1556 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result3);
1557 1557
1558 ASSERT_EQ(2U, result3.option_values.size()); 1558 ASSERT_EQ(2U, result3.option_values.size());
1559 ASSERT_EQ(2U, result3.option_contents.size()); 1559 ASSERT_EQ(2U, result3.option_contents.size());
1560 EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_values[0]); 1560 EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_values[0]);
1561 EXPECT_EQ(ASCIIToUTF16("California"), result3.option_contents[0]); 1561 EXPECT_EQ(ASCIIToUTF16("California"), result3.option_contents[0]);
1562 EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_values[1]); 1562 EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_values[1]);
1563 EXPECT_EQ(ASCIIToUTF16("Texas"), result3.option_contents[1]); 1563 EXPECT_EQ(ASCIIToUTF16("Texas"), result3.option_contents[1]);
1564 } 1564 }
1565 1565
1566 // We copy extra attributes for the select field.
1567 TEST_F(FormAutofillTest,
1568 WebFormControlElementToFormFieldSelect_ExtraAttributes) {
1569 LoadHTML("<SELECT id='element' autocomplete='off'/>"
1570 " <OPTION value='CA'>California</OPTION>"
1571 " <OPTION value='TX'>Texas</OPTION>"
1572 "</SELECT>");
1573
1574 WebFrame* frame = GetMainFrame();
1575 ASSERT_NE(nullptr, frame);
1576
1577 WebFormControlElement element = GetFormControlElementById("element");
1578 element.setAutofilled(true);
1579
1580 FormFieldData result1;
1581 WebFormControlElementToFormField(element, EXTRACT_VALUE, &result1);
1582
1583 FormFieldData expected;
1584 expected.name = ASCIIToUTF16("element");
1585 expected.max_length = 0;
1586 expected.form_control_type = "select-one";
1587 // We check that the extra attributes have been copied to |result1|.
1588 expected.is_autofilled = true;
1589 expected.autocomplete_attribute = "off";
1590 expected.should_autocomplete = false;
1591 expected.is_focusable = true;
1592 expected.text_direction = base::i18n::LEFT_TO_RIGHT;
1593
1594 expected.value = ASCIIToUTF16("CA");
1595 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result1);
1596 }
1597
1566 // When faced with <select> field with *many* options, we should trim them to a 1598 // When faced with <select> field with *many* options, we should trim them to a
1567 // reasonable number. 1599 // reasonable number.
1568 TEST_F(FormAutofillTest, WebFormControlElementToFormFieldLongSelect) { 1600 TEST_F(FormAutofillTest, WebFormControlElementToFormFieldLongSelect) {
1569 std::string html = "<SELECT id='element'/>"; 1601 std::string html = "<SELECT id='element'/>";
1570 for (size_t i = 0; i < 2 * kMaxListSize; ++i) { 1602 for (size_t i = 0; i < 2 * kMaxListSize; ++i) {
1571 html += base::StringPrintf("<OPTION value='%" PRIuS "'>" 1603 html += base::StringPrintf("<OPTION value='%" PRIuS "'>"
1572 "%" PRIuS "</OPTION>", i, i); 1604 "%" PRIuS "</OPTION>", i, i);
1573 } 1605 }
1574 html += "</SELECT>"; 1606 html += "</SELECT>";
1575 LoadHTML(html.c_str()); 1607 LoadHTML(html.c_str());
(...skipping 2490 matching lines...) Expand 10 before | Expand all | Expand 10 after
4066 ASSERT_TRUE(control_elements.empty()); 4098 ASSERT_TRUE(control_elements.empty());
4067 ASSERT_TRUE(fieldsets.empty()); 4099 ASSERT_TRUE(fieldsets.empty());
4068 4100
4069 FormData form; 4101 FormData form;
4070 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( 4102 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData(
4071 fieldsets, control_elements, nullptr, frame->document(), extract_mask, 4103 fieldsets, control_elements, nullptr, frame->document(), extract_mask,
4072 &form, nullptr)); 4104 &form, nullptr));
4073 } 4105 }
4074 4106
4075 } // namespace autofill 4107 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/autofill/heuristics/output/04_checkout_lowes.com.out » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698