| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 frame->setEditableSelectionOffsets(8, 19); | 813 frame->setEditableSelectionOffsets(8, 19); |
| 814 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); | 814 EXPECT_EQ("89abcdefghi", frame->selectionAsText()); |
| 815 info = webView->textInputInfo(); | 815 info = webView->textInputInfo(); |
| 816 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); | 816 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", info.value); |
| 817 EXPECT_EQ(8, info.selectionStart); | 817 EXPECT_EQ(8, info.selectionStart); |
| 818 EXPECT_EQ(19, info.selectionEnd); | 818 EXPECT_EQ(19, info.selectionEnd); |
| 819 EXPECT_EQ(-1, info.compositionStart); | 819 EXPECT_EQ(-1, info.compositionStart); |
| 820 EXPECT_EQ(-1, info.compositionEnd); | 820 EXPECT_EQ(-1, info.compositionEnd); |
| 821 } | 821 } |
| 822 | 822 |
| 823 TEST_F(WebViewTest, ConfirmCompositionCursorPositionChange) | 823 TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) |
| 824 { | 824 { |
| 825 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 825 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 826 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 826 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 827 webView->setInitialFocus(false); | 827 webView->setInitialFocus(false); |
| 828 | 828 |
| 829 // Set up a composition that needs to be committed. | 829 // Set up a composition that needs to be committed. |
| 830 std::string compositionText("hello"); | 830 std::string compositionText("hello"); |
| 831 | 831 |
| 832 WebVector<WebCompositionUnderline> emptyUnderlines; | 832 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 833 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 3, 3); | 833 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 3, 3); |
| 834 | 834 |
| 835 WebTextInputInfo info = webView->textInputInfo(); | 835 WebTextInputInfo info = webView->textInputInfo(); |
| 836 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 836 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 837 EXPECT_EQ(3, info.selectionStart); | 837 EXPECT_EQ(3, info.selectionStart); |
| 838 EXPECT_EQ(3, info.selectionEnd); | 838 EXPECT_EQ(3, info.selectionEnd); |
| 839 EXPECT_EQ(0, info.compositionStart); | 839 EXPECT_EQ(0, info.compositionStart); |
| 840 EXPECT_EQ(5, info.compositionEnd); | 840 EXPECT_EQ(5, info.compositionEnd); |
| 841 | 841 |
| 842 webView->confirmComposition(WebWidget::KeepSelection); | 842 webView->finishComposingText(WebWidget::KeepSelection); |
| 843 info = webView->textInputInfo(); | 843 info = webView->textInputInfo(); |
| 844 EXPECT_EQ(3, info.selectionStart); | 844 EXPECT_EQ(3, info.selectionStart); |
| 845 EXPECT_EQ(3, info.selectionEnd); | 845 EXPECT_EQ(3, info.selectionEnd); |
| 846 EXPECT_EQ(-1, info.compositionStart); | 846 EXPECT_EQ(-1, info.compositionStart); |
| 847 EXPECT_EQ(-1, info.compositionEnd); | 847 EXPECT_EQ(-1, info.compositionEnd); |
| 848 | 848 |
| 849 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 3, 3); | 849 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 3, 3); |
| 850 info = webView->textInputInfo(); | 850 info = webView->textInputInfo(); |
| 851 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); | 851 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); |
| 852 EXPECT_EQ(6, info.selectionStart); | 852 EXPECT_EQ(6, info.selectionStart); |
| 853 EXPECT_EQ(6, info.selectionEnd); | 853 EXPECT_EQ(6, info.selectionEnd); |
| 854 EXPECT_EQ(3, info.compositionStart); | 854 EXPECT_EQ(3, info.compositionStart); |
| 855 EXPECT_EQ(8, info.compositionEnd); | 855 EXPECT_EQ(8, info.compositionEnd); |
| 856 | 856 |
| 857 webView->confirmComposition(WebWidget::DoNotKeepSelection); | 857 webView->finishComposingText(WebWidget::DoNotKeepSelection); |
| 858 info = webView->textInputInfo(); | 858 info = webView->textInputInfo(); |
| 859 EXPECT_EQ(8, info.selectionStart); | 859 EXPECT_EQ(8, info.selectionStart); |
| 860 EXPECT_EQ(8, info.selectionEnd); | 860 EXPECT_EQ(8, info.selectionEnd); |
| 861 EXPECT_EQ(-1, info.compositionStart); | 861 EXPECT_EQ(-1, info.compositionStart); |
| 862 EXPECT_EQ(-1, info.compositionEnd); | 862 EXPECT_EQ(-1, info.compositionEnd); |
| 863 } | 863 } |
| 864 | 864 |
| 865 TEST_F(WebViewTest, SetCompositionForNewCaretPositions) |
| 866 { |
| 867 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 868 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 869 webView->setInitialFocus(false); |
| 870 |
| 871 webView->commitText("hello", 0); |
| 872 webView->commitText("world", -5); |
| 873 WebTextInputInfo info = webView->textInputInfo(); |
| 874 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 875 EXPECT_EQ(5, info.selectionStart); |
| 876 EXPECT_EQ(5, info.selectionEnd); |
| 877 EXPECT_EQ(-1, info.compositionStart); |
| 878 EXPECT_EQ(-1, info.compositionEnd); |
| 879 |
| 880 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 881 // Set up a composition that needs to be committed. |
| 882 std::string compositionText("ABC"); |
| 883 |
| 884 // Caret is on the left of composing text. |
| 885 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 0, 0); |
| 886 info = webView->textInputInfo(); |
| 887 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 888 EXPECT_EQ(5, info.selectionStart); |
| 889 EXPECT_EQ(5, info.selectionEnd); |
| 890 EXPECT_EQ(5, info.compositionStart); |
| 891 EXPECT_EQ(8, info.compositionEnd); |
| 892 |
| 893 // Caret is on the right of composing text. |
| 894 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 3, 3); |
| 895 info = webView->textInputInfo(); |
| 896 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 897 EXPECT_EQ(8, info.selectionStart); |
| 898 EXPECT_EQ(8, info.selectionEnd); |
| 899 EXPECT_EQ(5, info.compositionStart); |
| 900 EXPECT_EQ(8, info.compositionEnd); |
| 901 |
| 902 // Caret is between composing text and left boundary. |
| 903 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, -2, -2); |
| 904 info = webView->textInputInfo(); |
| 905 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 906 EXPECT_EQ(3, info.selectionStart); |
| 907 EXPECT_EQ(3, info.selectionEnd); |
| 908 EXPECT_EQ(5, info.compositionStart); |
| 909 EXPECT_EQ(8, info.compositionEnd); |
| 910 |
| 911 // Caret is between composing text and right boundary. |
| 912 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 5, 5); |
| 913 info = webView->textInputInfo(); |
| 914 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 915 EXPECT_EQ(10, info.selectionStart); |
| 916 EXPECT_EQ(10, info.selectionEnd); |
| 917 EXPECT_EQ(5, info.compositionStart); |
| 918 EXPECT_EQ(8, info.compositionEnd); |
| 919 |
| 920 // Caret is on the left boundary. |
| 921 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, -5, -5); |
| 922 info = webView->textInputInfo(); |
| 923 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 924 EXPECT_EQ(0, info.selectionStart); |
| 925 EXPECT_EQ(0, info.selectionEnd); |
| 926 EXPECT_EQ(5, info.compositionStart); |
| 927 EXPECT_EQ(8, info.compositionEnd); |
| 928 |
| 929 // Caret is on the right boundary. |
| 930 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 8, 8); |
| 931 info = webView->textInputInfo(); |
| 932 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 933 EXPECT_EQ(13, info.selectionStart); |
| 934 EXPECT_EQ(13, info.selectionEnd); |
| 935 EXPECT_EQ(5, info.compositionStart); |
| 936 EXPECT_EQ(8, info.compositionEnd); |
| 937 |
| 938 // Caret exceeds the left boundary. |
| 939 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, -100, -100); |
| 940 info = webView->textInputInfo(); |
| 941 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 942 EXPECT_EQ(0, info.selectionStart); |
| 943 EXPECT_EQ(0, info.selectionEnd); |
| 944 EXPECT_EQ(5, info.compositionStart); |
| 945 EXPECT_EQ(8, info.compositionEnd); |
| 946 |
| 947 // Caret exceeds the right boundary. |
| 948 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 100, 100); |
| 949 info = webView->textInputInfo(); |
| 950 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 951 EXPECT_EQ(13, info.selectionStart); |
| 952 EXPECT_EQ(13, info.selectionEnd); |
| 953 EXPECT_EQ(5, info.compositionStart); |
| 954 EXPECT_EQ(8, info.compositionEnd); |
| 955 } |
| 956 |
| 957 TEST_F(WebViewTest, SetCompositionWithEmptyText) |
| 958 { |
| 959 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 960 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 961 webView->setInitialFocus(false); |
| 962 |
| 963 webView->commitText("hello", 0); |
| 964 WebTextInputInfo info = webView->textInputInfo(); |
| 965 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 966 EXPECT_EQ(5, info.selectionStart); |
| 967 EXPECT_EQ(5, info.selectionEnd); |
| 968 EXPECT_EQ(-1, info.compositionStart); |
| 969 EXPECT_EQ(-1, info.compositionEnd); |
| 970 |
| 971 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 972 |
| 973 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, 0, 0); |
| 974 info = webView->textInputInfo(); |
| 975 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 976 EXPECT_EQ(5, info.selectionStart); |
| 977 EXPECT_EQ(5, info.selectionEnd); |
| 978 EXPECT_EQ(-1, info.compositionStart); |
| 979 EXPECT_EQ(-1, info.compositionEnd); |
| 980 |
| 981 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, -2, -2); |
| 982 info = webView->textInputInfo(); |
| 983 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 984 EXPECT_EQ(3, info.selectionStart); |
| 985 EXPECT_EQ(3, info.selectionEnd); |
| 986 EXPECT_EQ(-1, info.compositionStart); |
| 987 EXPECT_EQ(-1, info.compositionEnd); |
| 988 } |
| 989 |
| 990 TEST_F(WebViewTest, CommitTextForNewCaretPositions) |
| 991 { |
| 992 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 993 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 994 webView->setInitialFocus(false); |
| 995 |
| 996 // Caret is on the left of composing text. |
| 997 webView->commitText("ab", -2); |
| 998 WebTextInputInfo info = webView->textInputInfo(); |
| 999 EXPECT_EQ("ab", std::string(info.value.utf8().data())); |
| 1000 EXPECT_EQ(0, info.selectionStart); |
| 1001 EXPECT_EQ(0, info.selectionEnd); |
| 1002 EXPECT_EQ(-1, info.compositionStart); |
| 1003 EXPECT_EQ(-1, info.compositionEnd); |
| 1004 |
| 1005 // Caret is on the right of composing text. |
| 1006 webView->commitText("c", 1); |
| 1007 info = webView->textInputInfo(); |
| 1008 EXPECT_EQ("cab", std::string(info.value.utf8().data())); |
| 1009 EXPECT_EQ(2, info.selectionStart); |
| 1010 EXPECT_EQ(2, info.selectionEnd); |
| 1011 EXPECT_EQ(-1, info.compositionStart); |
| 1012 EXPECT_EQ(-1, info.compositionEnd); |
| 1013 |
| 1014 // Caret is on the left boundary. |
| 1015 webView->commitText("def", -5); |
| 1016 info = webView->textInputInfo(); |
| 1017 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); |
| 1018 EXPECT_EQ(0, info.selectionStart); |
| 1019 EXPECT_EQ(0, info.selectionEnd); |
| 1020 EXPECT_EQ(-1, info.compositionStart); |
| 1021 EXPECT_EQ(-1, info.compositionEnd); |
| 1022 |
| 1023 // Caret is on the right boundary. |
| 1024 webView->commitText("g", 6); |
| 1025 info = webView->textInputInfo(); |
| 1026 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); |
| 1027 EXPECT_EQ(7, info.selectionStart); |
| 1028 EXPECT_EQ(7, info.selectionEnd); |
| 1029 EXPECT_EQ(-1, info.compositionStart); |
| 1030 EXPECT_EQ(-1, info.compositionEnd); |
| 1031 |
| 1032 // Caret exceeds the left boundary. |
| 1033 webView->commitText("hi", -100); |
| 1034 info = webView->textInputInfo(); |
| 1035 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); |
| 1036 EXPECT_EQ(0, info.selectionStart); |
| 1037 EXPECT_EQ(0, info.selectionEnd); |
| 1038 EXPECT_EQ(-1, info.compositionStart); |
| 1039 EXPECT_EQ(-1, info.compositionEnd); |
| 1040 |
| 1041 // Caret exceeds the right boundary. |
| 1042 webView->commitText("jk", 100); |
| 1043 info = webView->textInputInfo(); |
| 1044 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); |
| 1045 EXPECT_EQ(11, info.selectionStart); |
| 1046 EXPECT_EQ(11, info.selectionEnd); |
| 1047 EXPECT_EQ(-1, info.compositionStart); |
| 1048 EXPECT_EQ(-1, info.compositionEnd); |
| 1049 } |
| 1050 |
| 1051 TEST_F(WebViewTest, CommitTextWhileComposing) |
| 1052 { |
| 1053 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 1054 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 1055 webView->setInitialFocus(false); |
| 1056 |
| 1057 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1058 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); |
| 1059 WebTextInputInfo info = webView->textInputInfo(); |
| 1060 EXPECT_EQ("abc", std::string(info.value.utf8().data())); |
| 1061 EXPECT_EQ(0, info.selectionStart); |
| 1062 EXPECT_EQ(0, info.selectionEnd); |
| 1063 EXPECT_EQ(0, info.compositionStart); |
| 1064 EXPECT_EQ(3, info.compositionEnd); |
| 1065 |
| 1066 // Deletes ongoing composition, inserts the specified text and moves the |
| 1067 // caret. |
| 1068 webView->commitText("hello", -2); |
| 1069 info = webView->textInputInfo(); |
| 1070 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1071 EXPECT_EQ(3, info.selectionStart); |
| 1072 EXPECT_EQ(3, info.selectionEnd); |
| 1073 EXPECT_EQ(-1, info.compositionStart); |
| 1074 EXPECT_EQ(-1, info.compositionEnd); |
| 1075 |
| 1076 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); |
| 1077 info = webView->textInputInfo(); |
| 1078 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); |
| 1079 EXPECT_EQ(3, info.selectionStart); |
| 1080 EXPECT_EQ(3, info.selectionEnd); |
| 1081 EXPECT_EQ(3, info.compositionStart); |
| 1082 EXPECT_EQ(6, info.compositionEnd); |
| 1083 |
| 1084 // Deletes ongoing composition and moves the caret. |
| 1085 webView->commitText("", 2); |
| 1086 info = webView->textInputInfo(); |
| 1087 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1088 EXPECT_EQ(5, info.selectionStart); |
| 1089 EXPECT_EQ(5, info.selectionEnd); |
| 1090 EXPECT_EQ(-1, info.compositionStart); |
| 1091 EXPECT_EQ(-1, info.compositionEnd); |
| 1092 |
| 1093 // Inserts the specified text and moves the caret. |
| 1094 webView->commitText("world", -5); |
| 1095 info = webView->textInputInfo(); |
| 1096 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 1097 EXPECT_EQ(5, info.selectionStart); |
| 1098 EXPECT_EQ(5, info.selectionEnd); |
| 1099 EXPECT_EQ(-1, info.compositionStart); |
| 1100 EXPECT_EQ(-1, info.compositionEnd); |
| 1101 |
| 1102 // Only moves the caret. |
| 1103 webView->commitText("", 5); |
| 1104 info = webView->textInputInfo(); |
| 1105 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 1106 EXPECT_EQ(10, info.selectionStart); |
| 1107 EXPECT_EQ(10, info.selectionEnd); |
| 1108 EXPECT_EQ(-1, info.compositionStart); |
| 1109 EXPECT_EQ(-1, info.compositionEnd); |
| 1110 } |
| 1111 |
| 865 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) | 1112 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) |
| 866 { | 1113 { |
| 867 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form_with_input.html")); | 1114 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("form_with_input.html")); |
| 868 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form_w
ith_input.html"); | 1115 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form_w
ith_input.html"); |
| 869 webView->resize(WebSize(800, 600)); | 1116 webView->resize(WebSize(800, 600)); |
| 870 webView->setInitialFocus(false); | 1117 webView->setInitialFocus(false); |
| 871 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1118 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 872 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().height); | 1119 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().height); |
| 873 | 1120 |
| 874 // Set up a composition from existing text that needs to be committed. | 1121 // Set up a composition from existing text that needs to be committed. |
| 875 Vector<CompositionUnderline> emptyUnderlines; | 1122 Vector<CompositionUnderline> emptyUnderlines; |
| 876 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1123 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 877 frame->frame()->inputMethodController().setCompositionFromExistingText(empty
Underlines, 3, 3); | 1124 frame->frame()->inputMethodController().setCompositionFromExistingText(empty
Underlines, 3, 3); |
| 878 | 1125 |
| 879 // Scroll the input field out of the viewport. | 1126 // Scroll the input field out of the viewport. |
| 880 Element* element = static_cast<Element*>(webView->mainFrame()->document().ge
tElementById("btn")); | 1127 Element* element = static_cast<Element*>(webView->mainFrame()->document().ge
tElementById("btn")); |
| 881 element->scrollIntoView(); | 1128 element->scrollIntoView(); |
| 882 float offsetHeight = webView->mainFrame()->scrollOffset().height; | 1129 float offsetHeight = webView->mainFrame()->scrollOffset().height; |
| 883 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1130 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 884 EXPECT_LT(0, offsetHeight); | 1131 EXPECT_LT(0, offsetHeight); |
| 885 | 1132 |
| 886 WebTextInputInfo info = webView->textInputInfo(); | 1133 WebTextInputInfo info = webView->textInputInfo(); |
| 887 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1134 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 888 | 1135 |
| 889 // Verify that the input field is not scrolled back into the viewport. | 1136 // Verify that the input field is not scrolled back into the viewport. |
| 890 webView->confirmComposition(WebWidget::DoNotKeepSelection); | 1137 webView->finishComposingText(WebWidget::DoNotKeepSelection); |
| 891 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1138 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 892 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); | 1139 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); |
| 893 } | 1140 } |
| 894 | 1141 |
| 895 TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition) | 1142 TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) |
| 896 { | 1143 { |
| 897 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 1144 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 898 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); | 1145 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); |
| 899 webView->setInitialFocus(false); | 1146 webView->setInitialFocus(false); |
| 900 | 1147 |
| 901 WebVector<WebCompositionUnderline> emptyUnderlines; | 1148 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 902 | 1149 |
| 903 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1150 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 904 frame->setEditableSelectionOffsets(4, 4); | 1151 frame->setEditableSelectionOffsets(4, 4); |
| 905 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1152 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 906 | 1153 |
| 907 WebTextInputInfo info = webView->textInputInfo(); | 1154 WebTextInputInfo info = webView->textInputInfo(); |
| 908 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); | 1155 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); |
| 909 EXPECT_EQ(4, info.selectionStart); | 1156 EXPECT_EQ(4, info.selectionStart); |
| 910 EXPECT_EQ(4, info.selectionEnd); | 1157 EXPECT_EQ(4, info.selectionEnd); |
| 911 EXPECT_EQ(8, info.compositionStart); | 1158 EXPECT_EQ(8, info.compositionStart); |
| 912 EXPECT_EQ(12, info.compositionEnd); | 1159 EXPECT_EQ(12, info.compositionEnd); |
| 913 | 1160 |
| 914 webView->confirmComposition(WebWidget::KeepSelection); | 1161 webView->finishComposingText(WebWidget::KeepSelection); |
| 915 info = webView->textInputInfo(); | 1162 info = webView->textInputInfo(); |
| 916 EXPECT_EQ(4, info.selectionStart); | 1163 EXPECT_EQ(4, info.selectionStart); |
| 917 EXPECT_EQ(4, info.selectionEnd); | 1164 EXPECT_EQ(4, info.selectionEnd); |
| 918 EXPECT_EQ(-1, info.compositionStart); | 1165 EXPECT_EQ(-1, info.compositionStart); |
| 919 EXPECT_EQ(-1, info.compositionEnd); | 1166 EXPECT_EQ(-1, info.compositionEnd); |
| 920 | 1167 |
| 921 std::string compositionText("\n"); | 1168 std::string compositionText("\n"); |
| 922 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 1169 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); |
| 923 info = webView->textInputInfo(); | 1170 info = webView->textInputInfo(); |
| 924 EXPECT_EQ(5, info.selectionStart); | 1171 EXPECT_EQ(5, info.selectionStart); |
| 925 EXPECT_EQ(5, info.selectionEnd); | 1172 EXPECT_EQ(5, info.selectionEnd); |
| 926 EXPECT_EQ(-1, info.compositionStart); | 1173 EXPECT_EQ(-1, info.compositionStart); |
| 927 EXPECT_EQ(-1, info.compositionEnd); | 1174 EXPECT_EQ(-1, info.compositionEnd); |
| 928 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); | 1175 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 929 } | 1176 } |
| 930 | 1177 |
| 931 TEST_F(WebViewTest, ExtendSelectionAndDelete) | 1178 TEST_F(WebViewTest, ExtendSelectionAndDelete) |
| 932 { | 1179 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 1219 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
| 973 { | 1220 { |
| 974 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 1221 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 975 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); | 1222 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); |
| 976 webView->setInitialFocus(false); | 1223 webView->setInitialFocus(false); |
| 977 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1224 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 978 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1225 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 979 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1226 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 980 frame->setEditableSelectionOffsets(27, 27); | 1227 frame->setEditableSelectionOffsets(27, 27); |
| 981 std::string newLineText("\n"); | 1228 std::string newLineText("\n"); |
| 982 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); | 1229 webView->commitText(WebString::fromUTF8(newLineText.c_str()), 0); |
| 983 WebTextInputInfo info = webView->textInputInfo(); | 1230 WebTextInputInfo info = webView->textInputInfo(); |
| 984 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 1231 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 985 | 1232 |
| 986 frame->setEditableSelectionOffsets(31, 31); | 1233 frame->setEditableSelectionOffsets(31, 31); |
| 987 frame->setCompositionFromExistingText(30, 34, underlines); | 1234 frame->setCompositionFromExistingText(30, 34, underlines); |
| 988 info = webView->textInputInfo(); | 1235 info = webView->textInputInfo(); |
| 989 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 1236 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 990 EXPECT_EQ(31, info.selectionStart); | 1237 EXPECT_EQ(31, info.selectionStart); |
| 991 EXPECT_EQ(31, info.selectionEnd); | 1238 EXPECT_EQ(31, info.selectionEnd); |
| 992 EXPECT_EQ(30, info.compositionStart); | 1239 EXPECT_EQ(30, info.compositionStart); |
| 993 EXPECT_EQ(34, info.compositionEnd); | 1240 EXPECT_EQ(34, info.compositionEnd); |
| 994 | 1241 |
| 995 std::string compositionText("yolo"); | 1242 std::string compositionText("yolo"); |
| 996 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 1243 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); |
| 997 info = webView->textInputInfo(); | 1244 info = webView->textInputInfo(); |
| 998 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); | 1245 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); |
| 999 EXPECT_EQ(34, info.selectionStart); | 1246 EXPECT_EQ(34, info.selectionStart); |
| 1000 EXPECT_EQ(34, info.selectionEnd); | 1247 EXPECT_EQ(34, info.selectionEnd); |
| 1001 EXPECT_EQ(-1, info.compositionStart); | 1248 EXPECT_EQ(-1, info.compositionStart); |
| 1002 EXPECT_EQ(-1, info.compositionEnd); | 1249 EXPECT_EQ(-1, info.compositionEnd); |
| 1003 } | 1250 } |
| 1004 | 1251 |
| 1005 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) | 1252 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) |
| 1006 { | 1253 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1020 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) | 1267 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) |
| 1021 { | 1268 { |
| 1022 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1269 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 1023 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); | 1270 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 1024 webView->setInitialFocus(false); | 1271 webView->setInitialFocus(false); |
| 1025 | 1272 |
| 1026 std::string compositionTextFirst("hello "); | 1273 std::string compositionTextFirst("hello "); |
| 1027 std::string compositionTextSecond("world"); | 1274 std::string compositionTextSecond("world"); |
| 1028 WebVector<WebCompositionUnderline> emptyUnderlines; | 1275 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1029 | 1276 |
| 1030 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()
)); | 1277 webView->commitText(WebString::fromUTF8(compositionTextFirst.c_str()), 0); |
| 1031 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); | 1278 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); |
| 1032 | 1279 |
| 1033 WebTextInputInfo info = webView->textInputInfo(); | 1280 WebTextInputInfo info = webView->textInputInfo(); |
| 1034 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1281 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1035 EXPECT_EQ(11, info.selectionStart); | 1282 EXPECT_EQ(11, info.selectionStart); |
| 1036 EXPECT_EQ(11, info.selectionEnd); | 1283 EXPECT_EQ(11, info.selectionEnd); |
| 1037 EXPECT_EQ(6, info.compositionStart); | 1284 EXPECT_EQ(6, info.compositionStart); |
| 1038 EXPECT_EQ(11, info.compositionEnd); | 1285 EXPECT_EQ(11, info.compositionEnd); |
| 1039 | 1286 |
| 1040 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1287 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 | 2336 |
| 2090 keyEvent.type = WebInputEvent::KeyUp; | 2337 keyEvent.type = WebInputEvent::KeyUp; |
| 2091 webView->handleInputEvent(keyEvent); | 2338 webView->handleInputEvent(keyEvent); |
| 2092 | 2339 |
| 2093 webView->advanceFocus(false); | 2340 webView->advanceFocus(false); |
| 2094 } | 2341 } |
| 2095 | 2342 |
| 2096 frame->setAutofillClient(0); | 2343 frame->setAutofillClient(0); |
| 2097 } | 2344 } |
| 2098 | 2345 |
| 2099 TEST_F(WebViewTest, ConfirmCompositionTriggersAutofillTextChange) | 2346 TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) |
| 2100 { | 2347 { |
| 2101 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 2348 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 2102 MockAutofillClient client; | 2349 MockAutofillClient client; |
| 2103 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); | 2350 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 2104 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2351 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2105 frame->setAutofillClient(&client); | 2352 frame->setAutofillClient(&client); |
| 2106 webView->setInitialFocus(false); | 2353 webView->setInitialFocus(false); |
| 2107 | 2354 |
| 2108 // Set up a composition that needs to be committed. | 2355 // Set up a composition that needs to be committed. |
| 2109 std::string compositionText("testingtext"); | 2356 std::string compositionText("testingtext"); |
| 2110 | 2357 |
| 2111 WebVector<WebCompositionUnderline> emptyUnderlines; | 2358 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2112 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 0, compositionText.length()); | 2359 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 0, compositionText.length()); |
| 2113 | 2360 |
| 2114 WebTextInputInfo info = webView->textInputInfo(); | 2361 WebTextInputInfo info = webView->textInputInfo(); |
| 2115 EXPECT_EQ(0, info.selectionStart); | 2362 EXPECT_EQ(0, info.selectionStart); |
| 2116 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); | 2363 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); |
| 2117 EXPECT_EQ(0, info.compositionStart); | 2364 EXPECT_EQ(0, info.compositionStart); |
| 2118 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); | 2365 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); |
| 2119 | 2366 |
| 2120 client.clearChangeCounts(); | 2367 client.clearChangeCounts(); |
| 2121 webView->confirmComposition(); | 2368 webView->finishComposingText(WebWidget::KeepSelection); |
| 2122 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 2369 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
| 2123 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); | 2370 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); |
| 2124 | 2371 |
| 2125 frame->setAutofillClient(0); | 2372 frame->setAutofillClient(0); |
| 2126 } | 2373 } |
| 2127 | 2374 |
| 2128 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) | 2375 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) |
| 2129 { | 2376 { |
| 2130 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 2377 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 2131 MockAutofillClient client; | 2378 MockAutofillClient client; |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2814 EXPECT_TRUE(client.textIsUpdated()); | 3061 EXPECT_TRUE(client.textIsUpdated()); |
| 2815 WebTextInputInfo info = webViewImpl->textInputInfo(); | 3062 WebTextInputInfo info = webViewImpl->textInputInfo(); |
| 2816 EXPECT_EQ("testA", std::string(info.value.utf8().data())); | 3063 EXPECT_EQ("testA", std::string(info.value.utf8().data())); |
| 2817 | 3064 |
| 2818 // (A.2) Focused and user input modifies value. | 3065 // (A.2) Focused and user input modifies value. |
| 2819 client.reset(); | 3066 client.reset(); |
| 2820 EXPECT_FALSE(client.textIsUpdated()); | 3067 EXPECT_FALSE(client.textIsUpdated()); |
| 2821 | 3068 |
| 2822 WebVector<WebCompositionUnderline> emptyUnderlines; | 3069 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2823 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; | 3070 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; |
| 2824 webViewImpl->confirmComposition(WebWidget::KeepSelection); | 3071 webViewImpl->finishComposingText(WebWidget::KeepSelection); |
| 2825 EXPECT_FALSE(client.textIsUpdated()); | 3072 EXPECT_FALSE(client.textIsUpdated()); |
| 2826 info = webViewImpl->textInputInfo(); | 3073 info = webViewImpl->textInputInfo(); |
| 2827 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); | 3074 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); |
| 2828 | 3075 |
| 2829 // (A.3) Unfocused and value is changed by script. | 3076 // (A.3) Unfocused and value is changed by script. |
| 2830 client.reset(); | 3077 client.reset(); |
| 2831 EXPECT_FALSE(client.textIsUpdated()); | 3078 EXPECT_FALSE(client.textIsUpdated()); |
| 2832 document->clearFocusedElement(); | 3079 document->clearFocusedElement(); |
| 2833 webViewImpl->setFocus(false); | 3080 webViewImpl->setFocus(false); |
| 2834 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); | 3081 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2845 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement)
); | 3092 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement)
); |
| 2846 textAreaElement->setValue("testB"); | 3093 textAreaElement->setValue("testB"); |
| 2847 EXPECT_TRUE(client.textIsUpdated()); | 3094 EXPECT_TRUE(client.textIsUpdated()); |
| 2848 info = webViewImpl->textInputInfo(); | 3095 info = webViewImpl->textInputInfo(); |
| 2849 EXPECT_EQ("testB", std::string(info.value.utf8().data())); | 3096 EXPECT_EQ("testB", std::string(info.value.utf8().data())); |
| 2850 | 3097 |
| 2851 // (B.2) Focused and user input modifies value. | 3098 // (B.2) Focused and user input modifies value. |
| 2852 client.reset(); | 3099 client.reset(); |
| 2853 EXPECT_FALSE(client.textIsUpdated()); | 3100 EXPECT_FALSE(client.textIsUpdated()); |
| 2854 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; | 3101 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; |
| 2855 webViewImpl->confirmComposition(WebWidget::KeepSelection); | 3102 webViewImpl->finishComposingText(WebWidget::KeepSelection); |
| 2856 info = webViewImpl->textInputInfo(); | 3103 info = webViewImpl->textInputInfo(); |
| 2857 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); | 3104 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); |
| 2858 | 3105 |
| 2859 // (B.3) Unfocused and value is changed by script. | 3106 // (B.3) Unfocused and value is changed by script. |
| 2860 client.reset(); | 3107 client.reset(); |
| 2861 EXPECT_FALSE(client.textIsUpdated()); | 3108 EXPECT_FALSE(client.textIsUpdated()); |
| 2862 document->clearFocusedElement(); | 3109 document->clearFocusedElement(); |
| 2863 webViewImpl->setFocus(false); | 3110 webViewImpl->setFocus(false); |
| 2864 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement)
); | 3111 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement)
); |
| 2865 inputElement->setValue("testB3"); | 3112 inputElement->setValue("testB3"); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3286 | 3533 |
| 3287 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) | 3534 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) |
| 3288 { | 3535 { |
| 3289 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); | 3536 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); |
| 3290 MockAutofillClient client; | 3537 MockAutofillClient client; |
| 3291 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_password.html", true); | 3538 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_password.html", true); |
| 3292 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3539 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3293 frame->setAutofillClient(&client); | 3540 frame->setAutofillClient(&client); |
| 3294 webView->setInitialFocus(false); | 3541 webView->setInitialFocus(false); |
| 3295 | 3542 |
| 3296 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); | 3543 EXPECT_TRUE(webView->commitText(WebString::fromUTF8(std::string("hello").c_s
tr()), 0)); |
| 3297 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3544 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3298 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3545 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3299 frame->setAutofillClient(0); | 3546 frame->setAutofillClient(0); |
| 3300 } | 3547 } |
| 3301 | 3548 |
| 3302 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the | 3549 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the |
| 3303 // stack defers its loads. | 3550 // stack defers its loads. |
| 3304 TEST_F(WebViewTest, CreatedDuringLoadDeferral) | 3551 TEST_F(WebViewTest, CreatedDuringLoadDeferral) |
| 3305 { | 3552 { |
| 3306 { | 3553 { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 EXPECT_TRUE(webView->page()->defersLoading()); | 3611 EXPECT_TRUE(webView->page()->defersLoading()); |
| 3365 } | 3612 } |
| 3366 | 3613 |
| 3367 EXPECT_TRUE(webView->page()->defersLoading()); | 3614 EXPECT_TRUE(webView->page()->defersLoading()); |
| 3368 } | 3615 } |
| 3369 | 3616 |
| 3370 EXPECT_FALSE(webView->page()->defersLoading()); | 3617 EXPECT_FALSE(webView->page()->defersLoading()); |
| 3371 } | 3618 } |
| 3372 | 3619 |
| 3373 } // namespace blink | 3620 } // namespace blink |
| OLD | NEW |