Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3192 form_cache.ExtractNewForms(*web_frame, &forms); | 3192 form_cache.ExtractNewForms(*web_frame, &forms); |
| 3193 ASSERT_EQ(1U, forms.size()); | 3193 ASSERT_EQ(1U, forms.size()); |
| 3194 | 3194 |
| 3195 // Set the auto-filled attribute. | 3195 // Set the auto-filled attribute. |
| 3196 WebInputElement firstname = | 3196 WebInputElement firstname = |
| 3197 web_frame->document().getElementById("firstname").to<WebInputElement>(); | 3197 web_frame->document().getElementById("firstname").to<WebInputElement>(); |
| 3198 firstname.setAutofilled(true); | 3198 firstname.setAutofilled(true); |
| 3199 WebInputElement lastname = | 3199 WebInputElement lastname = |
| 3200 web_frame->document().getElementById("lastname").to<WebInputElement>(); | 3200 web_frame->document().getElementById("lastname").to<WebInputElement>(); |
| 3201 lastname.setAutofilled(true); | 3201 lastname.setAutofilled(true); |
| 3202 WebInputElement state = | |
| 3203 web_frame->document().getElementById("state").to<WebInputElement>(); | |
| 3204 state.setAutofilled(true); | |
| 3205 | 3202 |
| 3206 // Set the value of the select-one. | 3203 // Set the value of the select-one. |
| 3207 WebSelectElement select_element = | 3204 WebSelectElement select_element = |
| 3208 web_frame->document().getElementById("state").to<WebSelectElement>(); | 3205 web_frame->document().getElementById("state").to<WebSelectElement>(); |
| 3209 select_element.setValue(WebString::fromUTF8("AK")); | 3206 select_element.setValue(WebString::fromUTF8("AK")); |
| 3210 | 3207 |
| 3208 // Set the auto-filled attribute of the select-one. | |
| 3209 WebInputElement state = | |
| 3210 web_frame->document().getElementById("state").to<WebInputElement>(); | |
|
Ilya Sherman
2014/09/25 22:31:14
Hmm... how are we even able to cast to WebInputEle
ziran.sun
2014/09/26 09:34:41
Good point! Sorry, I've been careless and didn't s
| |
| 3211 state.setAutofilled(true); | |
|
Ilya Sherman
2014/09/25 22:31:14
I'd suggest combining lines 3203 through 3211 as
ziran.sun
2014/09/26 09:34:41
Done.
| |
| 3212 | |
| 3211 // Clear the form. | 3213 // Clear the form. |
| 3212 EXPECT_TRUE(form_cache.ClearFormWithElement(firstname)); | 3214 EXPECT_TRUE(form_cache.ClearFormWithElement(firstname)); |
| 3213 | 3215 |
| 3214 // Verify that the auto-filled attribute has been turned off. | 3216 // Verify that the auto-filled attribute has been turned off. |
| 3215 EXPECT_FALSE(firstname.isAutofilled()); | 3217 EXPECT_FALSE(firstname.isAutofilled()); |
| 3216 | 3218 |
| 3217 // Verify the form is cleared. | 3219 // Verify the form is cleared. |
| 3218 FormData form2; | 3220 FormData form2; |
| 3219 FormFieldData field2; | 3221 FormFieldData field2; |
| 3220 EXPECT_TRUE(FindFormAndFieldForFormControlElement(firstname, | 3222 EXPECT_TRUE(FindFormAndFieldForFormControlElement(firstname, |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3681 expected.max_length = WebInputElement::defaultMaxLength(); | 3683 expected.max_length = WebInputElement::defaultMaxLength(); |
| 3682 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 3684 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 3683 | 3685 |
| 3684 expected.name = ASCIIToUTF16("country"); | 3686 expected.name = ASCIIToUTF16("country"); |
| 3685 expected.value = ASCIIToUTF16("AL"); | 3687 expected.value = ASCIIToUTF16("AL"); |
| 3686 expected.form_control_type = "select-one"; | 3688 expected.form_control_type = "select-one"; |
| 3687 expected.max_length = 0; | 3689 expected.max_length = 0; |
| 3688 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3690 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 3689 } | 3691 } |
| 3690 } // namespace autofill | 3692 } // namespace autofill |
| OLD | NEW |