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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 if (test_cases[i].form_control_type == "text") | 674 if (test_cases[i].form_control_type == "text") |
675 expected.max_length = WebInputElement::defaultMaxLength(); | 675 expected.max_length = WebInputElement::defaultMaxLength(); |
676 else | 676 else |
677 expected.max_length = 0; | 677 expected.max_length = 0; |
678 | 678 |
679 SCOPED_TRACE(test_cases[i].element_id); | 679 SCOPED_TRACE(test_cases[i].element_id); |
680 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); | 680 EXPECT_FORM_FIELD_DATA_EQUALS(expected, result); |
681 } | 681 } |
682 } | 682 } |
683 | 683 |
684 // 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.
| |
685 TEST_F(FormAutofillTest, | |
686 WebFormControlElementToFormFieldAutocompleteDirectionTest1) { | |
687 LoadHTML("<STYLE>input{direction:rtl}</STYLE>" | |
688 "<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.
| |
689 " <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.
| |
690 "</FORM>"); | |
691 | |
692 WebFrame* frame = GetMainFrame(); | |
693 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); | |
694 | |
695 WebElement web_element = frame->document().getElementById("element"); | |
696 WebFormControlElement element = web_element.to<WebFormControlElement>(); | |
697 | |
698 FormFieldData result; | |
699 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); | |
700 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); | |
701 } | |
702 | |
703 // Both text input and autocomplete should have same direction: test_case#2 | |
704 TEST_F(FormAutofillTest, | |
705 WebFormControlElementToFormFieldAutocompleteDirectionTest2) { | |
706 LoadHTML("<STYLE>span{direction:rtl}</STYLE>" | |
707 "<FORM autocomplete='on'>" | |
708 " <SPAN>" | |
709 " <INPUT type='text' id='element' value='RTL'/>" | |
710 " </SPAN>" | |
711 "</FORM>"); | |
712 | |
713 WebFrame* frame = GetMainFrame(); | |
714 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); | |
715 | |
716 WebElement web_element = frame->document().getElementById("element"); | |
717 WebFormControlElement element = web_element.to<WebFormControlElement>(); | |
718 | |
719 FormFieldData result; | |
720 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); | |
721 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); | |
722 } | |
723 | |
724 // Both text input and autocomplete should have same direction: test_case#3 | |
725 TEST_F(FormAutofillTest, | |
726 WebFormControlElementToFormFieldAutocompleteDirectionTest3) { | |
727 LoadHTML("<FORM autocomplete='on'>" | |
728 " <SPAN>" | |
729 " <INPUT dir='rtl' type='text' id='element' value='RTL'/>" | |
730 " </SPAN>" | |
731 "</FORM>"); | |
732 | |
733 WebFrame* frame = GetMainFrame(); | |
734 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); | |
735 | |
736 WebElement web_element = frame->document().getElementById("element"); | |
737 WebFormControlElement element = web_element.to<WebFormControlElement>(); | |
738 | |
739 FormFieldData result; | |
740 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); | |
741 EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, result.text_direction); | |
742 } | |
743 | |
744 // Both text input and autocomplete should have same direction: test_case#4 | |
745 TEST_F(FormAutofillTest, | |
746 WebFormControlElementToFormFieldAutocompleteDirectionTest4) { | |
747 LoadHTML("<STYLE>input{direction:ltr}</STYLE>" | |
748 "<FORM dir='rtl' autocomplete='on'>" | |
749 " <INPUT type='text' id='element' value='LTR'/>" | |
750 "</FORM>"); | |
751 | |
752 WebFrame* frame = GetMainFrame(); | |
753 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); | |
754 | |
755 WebElement web_element = frame->document().getElementById("element"); | |
756 WebFormControlElement element = web_element.to<WebFormControlElement>(); | |
757 | |
758 FormFieldData result; | |
759 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); | |
760 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); | |
761 } | |
762 | |
763 // Both text input and autocomplete should have same direction: test_case#5 | |
764 TEST_F(FormAutofillTest, | |
765 WebFormControlElementToFormFieldAutocompleteDirectionTest5) { | |
766 LoadHTML("<STYLE>span{direction:ltr}</STYLE>" | |
767 "<FORM autocomplete='on'>" | |
768 " <SPAN dir='rtl'>" | |
769 " <INPUT type='text' id='element' value='LTR'/>" | |
770 " </SPAN>" | |
771 "</FORM>"); | |
772 | |
773 WebFrame* frame = GetMainFrame(); | |
774 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); | |
775 | |
776 WebElement web_element = frame->document().getElementById("element"); | |
777 WebFormControlElement element = web_element.to<WebFormControlElement>(); | |
778 | |
779 FormFieldData result; | |
780 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); | |
781 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); | |
782 } | |
783 | |
784 // Both text input and autocomplete should have same direction: test_case#6 | |
785 TEST_F(FormAutofillTest, | |
786 WebFormControlElementToFormFieldAutocompleteDirectionTest6) { | |
787 LoadHTML("<BODY dir='rtl'>" | |
788 "<FORM style='direction:ltr' autocomplete='on'>" | |
789 " <SPAN dir='rtl'>" | |
790 " <INPUT dir='ltr' type='text' id='element' value='LTR'/>" | |
791 " </SPAN>" | |
792 "</FORM>"); | |
793 | |
794 WebFrame* frame = GetMainFrame(); | |
795 ASSERT_NE(static_cast<WebFrame*>(NULL), frame); | |
796 | |
797 WebElement web_element = frame->document().getElementById("element"); | |
798 WebFormControlElement element = web_element.to<WebFormControlElement>(); | |
799 | |
800 FormFieldData result; | |
801 WebFormControlElementToFormField(element, autofill::EXTRACT_VALUE, &result); | |
802 EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, result.text_direction); | |
803 } | |
804 | |
684 TEST_F(FormAutofillTest, WebFormElementToFormData) { | 805 TEST_F(FormAutofillTest, WebFormElementToFormData) { |
685 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" | 806 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
686 " <LABEL for=\"firstname\">First name:</LABEL>" | 807 " <LABEL for=\"firstname\">First name:</LABEL>" |
687 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" | 808 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |
688 " <LABEL for=\"lastname\">Last name:</LABEL>" | 809 " <LABEL for=\"lastname\">Last name:</LABEL>" |
689 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" | 810 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" |
690 " <LABEL for=\"street-address\">Address:</LABEL>" | 811 " <LABEL for=\"street-address\">Address:</LABEL>" |
691 " <TEXTAREA id=\"street-address\">" | 812 " <TEXTAREA id=\"street-address\">" |
692 "123 Fantasy Ln. " | 813 "123 Fantasy Ln. " |
693 "Apt. 42" | 814 "Apt. 42" |
(...skipping 2868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3562 expected.max_length = WebInputElement::defaultMaxLength(); | 3683 expected.max_length = WebInputElement::defaultMaxLength(); |
3563 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 3684 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
3564 | 3685 |
3565 expected.name = ASCIIToUTF16("country"); | 3686 expected.name = ASCIIToUTF16("country"); |
3566 expected.value = ASCIIToUTF16("AL"); | 3687 expected.value = ASCIIToUTF16("AL"); |
3567 expected.form_control_type = "select-one"; | 3688 expected.form_control_type = "select-one"; |
3568 expected.max_length = 0; | 3689 expected.max_length = 0; |
3569 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3690 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
3570 } | 3691 } |
3571 } // namespace autofill | 3692 } // namespace autofill |
OLD | NEW |