| Code-Review | +1 |
// Find the newly-filled form that contains the input element.
FormData form2 = FindForm(input_element);
EXPECT_EQ(u"TestForm", form2.name());
EXPECT_EQ(GURL("http://abc.com"), form2.action());
const std::vector<FormFieldData>& fields2 = form2.fields();
ASSERT_EQ(6U, fields2.size());
FormFieldData expected;
expected.set_form_control_type(FormControlType::kInputText);
expected.set_max_length(FormFieldData::kDefaultMaxLength);
expected.set_id_attribute(u"firstname");
expected.set_name(expected.id_attribute());
expected.set_value(u"Wyatt");
expected.set_label(u"First Name");
expected.set_placeholder(u"First Name");
expected.set_is_autofilled_according_to_renderer(true);
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]);
// The last name field is not filled, because there is a value in it.
expected.set_id_attribute(u"lastname");
expected.set_name(expected.id_attribute());
expected.set_value(u"Earp");
expected.set_label(u"Last Name");
expected.set_placeholder(u"Last Name");
expected.set_is_autofilled_according_to_renderer(false);
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]);
expected.set_id_attribute(u"phone");
expected.set_name(expected.id_attribute());
expected.set_value(u"888-123-4567");
expected.set_label(u"Phone");
expected.set_placeholder(u"Phone");
expected.set_is_autofilled_according_to_renderer(true);
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]);
expected.set_id_attribute(u"cc");
expected.set_name(expected.id_attribute());
expected.set_value(u"1111-2222-3333-4444");
expected.set_label(u"Credit Card Number");
expected.set_placeholder(u"Credit Card Number");
expected.set_is_autofilled_according_to_renderer(true);
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[3]);
expected.set_id_attribute(u"city");
expected.set_name(expected.id_attribute());
expected.set_value(u"Montreal");
expected.set_label(u"City");
expected.set_placeholder(u"City");
expected.set_is_autofilled_according_to_renderer(true);
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[4]);
expected.set_form_control_type(FormControlType::kSelectOne);
expected.set_id_attribute(u"state");
expected.set_name_attribute(u"state");
expected.set_name(expected.name_attribute());
expected.set_value(u"AA");
expected.set_label(u"State");
expected.set_placeholder(u"State");
expected.set_is_autofilled_according_to_renderer(true);
expected.set_max_length(0);
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[5]);I agree that inlining makes sense, but i think we should follow-up and refactor these tests a bit. There is a lot of repeated logic on these expectations. We could introduce a new util in the test file. Something like:
```
auto verify_field = [](const FormFieldData& actual,
const std::u16string& id,
const std::u16string& val,
const std::u16string& label,
bool is_autofilled) {
...
}
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I agree that inlining makes sense, but i think we should follow-up and refactor these tests a bit. There is a lot of repeated logic on these expectations. We could introduce a new util in the test file. Something like:
```
auto verify_field = [](const FormFieldData& actual,
const std::u16string& id,
const std::u16string& val,
const std::u16string& label,
bool is_autofilled) {
...
}
```
Nvm - i see this is address in a follow-up 😊
Tamino BauknechtHey Norge, this change should be independent of the other changes in this CL chain, so you can also review it last
Mark as resolved
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
10 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
autofill: Inline one-use functions in form_autofill_browsertest.cc
This inlines the following functions because they are only used once
anyway:
* `TestFillFormAndModifyValues`
* `TestFillFormAndModifyInitiatingValue`
* `TestFillFormJSModifiesUserInputValue`
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |