Chromium Code Reviews| Index: chrome/renderer/autofill/form_autofill_browsertest.cc |
| diff --git a/chrome/renderer/autofill/form_autofill_browsertest.cc b/chrome/renderer/autofill/form_autofill_browsertest.cc |
| index f76ee97fd465deb7e0fde8bb50a0b54e9c8f70b2..f3287a375ebdcf78a3ef91420a37cc8c242745f0 100644 |
| --- a/chrome/renderer/autofill/form_autofill_browsertest.cc |
| +++ b/chrome/renderer/autofill/form_autofill_browsertest.cc |
| @@ -681,6 +681,127 @@ TEST_F(FormAutofillTest, WebFormControlElementToFormFieldAutocompletetype) { |
| } |
| } |
| +// Both text input and autocomplete should have same direction: test_case#1 |
|
Ilya Sherman
2014/08/07 19:53:01
Rather than just numbering the test cases, please
Sunil Ratnu
2014/08/08 04:56:32
Done.
|
| +TEST_F(FormAutofillTest, |
| + WebFormControlElementToFormFieldAutocompleteDirectionTest1) { |
| + LoadHTML("<STYLE>input{direction:rtl}</STYLE>" |
| + "<FORM autocomplete='on'>" |
|
Ilya Sherman
2014/08/07 19:53:01
nit: You shouldn't need to explicitly specify auto
Sunil Ratnu
2014/08/08 04:56:32
Done.
|
| + " <INPUT type='text' id='element' value='RTL'/>" |
|
Ilya Sherman
2014/08/07 19:53:00
nit: Would this test be equally valid without a va
Sunil Ratnu
2014/08/08 04:56:32
Done.
|
| + "</FORM>"); |
| + |
| + WebFrame* frame = GetMainFrame(); |
| + ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
| + |
| + WebElement web_element = frame->document().getElementById("element"); |
| + WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| + |
| + FormFieldData result; |
| + WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
| + EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
| +} |
| + |
| +// Both text input and autocomplete should have same direction: test_case#2 |
| +TEST_F(FormAutofillTest, |
| + WebFormControlElementToFormFieldAutocompleteDirectionTest2) { |
| + LoadHTML("<STYLE>span{direction:rtl}</STYLE>" |
| + "<FORM autocomplete='on'>" |
| + " <SPAN>" |
| + " <INPUT type='text' id='element' value='RTL'/>" |
| + " </SPAN>" |
| + "</FORM>"); |
| + |
| + WebFrame* frame = GetMainFrame(); |
| + ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
| + |
| + WebElement web_element = frame->document().getElementById("element"); |
| + WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| + |
| + FormFieldData result; |
| + WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
| + EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
| +} |
| + |
| +// Both text input and autocomplete should have same direction: test_case#3 |
| +TEST_F(FormAutofillTest, |
| + WebFormControlElementToFormFieldAutocompleteDirectionTest3) { |
| + LoadHTML("<FORM autocomplete='on'>" |
| + " <SPAN>" |
| + " <INPUT dir='rtl' type='text' id='element' value='RTL'/>" |
| + " </SPAN>" |
| + "</FORM>"); |
| + |
| + WebFrame* frame = GetMainFrame(); |
| + ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
| + |
| + WebElement web_element = frame->document().getElementById("element"); |
| + WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| + |
| + FormFieldData result; |
| + WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
| + EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); |
| +} |
| + |
| +// Both text input and autocomplete should have same direction: test_case#4 |
| +TEST_F(FormAutofillTest, |
| + WebFormControlElementToFormFieldAutocompleteDirectionTest4) { |
| + LoadHTML("<STYLE>input{direction:ltr}</STYLE>" |
| + "<FORM dir='rtl' autocomplete='on'>" |
| + " <INPUT type='text' id='element' value='LTR'/>" |
| + "</FORM>"); |
| + |
| + WebFrame* frame = GetMainFrame(); |
| + ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
| + |
| + WebElement web_element = frame->document().getElementById("element"); |
| + WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| + |
| + FormFieldData result; |
| + WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
| + EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); |
| +} |
| + |
| +// Both text input and autocomplete should have same direction: test_case#5 |
| +TEST_F(FormAutofillTest, |
| + WebFormControlElementToFormFieldAutocompleteDirectionTest5) { |
| + LoadHTML("<STYLE>span{direction:ltr}</STYLE>" |
| + "<FORM autocomplete='on'>" |
| + " <SPAN dir='rtl'>" |
| + " <INPUT type='text' id='element' value='LTR'/>" |
| + " </SPAN>" |
| + "</FORM>"); |
| + |
| + WebFrame* frame = GetMainFrame(); |
| + ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
| + |
| + WebElement web_element = frame->document().getElementById("element"); |
| + WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| + |
| + FormFieldData result; |
| + WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
| + EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); |
| +} |
| + |
| +// Both text input and autocomplete should have same direction: test_case#6 |
| +TEST_F(FormAutofillTest, |
| + WebFormControlElementToFormFieldAutocompleteDirectionTest6) { |
| + LoadHTML("<BODY dir='rtl'>" |
| + "<FORM style='direction:ltr' autocomplete='on'>" |
| + " <SPAN dir='rtl'>" |
| + " <INPUT dir='ltr' type='text' id='element' value='LTR'/>" |
| + " </SPAN>" |
| + "</FORM>"); |
| + |
| + WebFrame* frame = GetMainFrame(); |
| + ASSERT_NE(static_cast<WebFrame*>(NULL), frame); |
| + |
| + WebElement web_element = frame->document().getElementById("element"); |
| + WebFormControlElement element = web_element.to<WebFormControlElement>(); |
| + |
| + FormFieldData result; |
| + WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); |
| + EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); |
| +} |
| + |
| TEST_F(FormAutofillTest, WebFormElementToFormData) { |
| LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| " <LABEL for=\"firstname\">First name:</LABEL>" |