Chromium Code Reviews| 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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 EXPECT_EQ(8, info.compositionEnd); | 855 EXPECT_EQ(8, info.compositionEnd); |
| 856 | 856 |
| 857 webView->confirmComposition(WebWidget::DoNotKeepSelection); | 857 webView->confirmComposition(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->confirmComposition("hello", 0); | |
| 872 webView->confirmComposition("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->confirmComposition("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, ConfirmCompositionForNewCaretPositions) | |
| 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->confirmComposition("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->confirmComposition("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->confirmComposition("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->confirmComposition("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->confirmComposition("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->confirmComposition("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, ConfirmCompositionOrInsertText) | |
| 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 webView->confirmComposition("abc", 0); | |
| 1058 WebTextInputInfo info = webView->textInputInfo(); | |
| 1059 EXPECT_EQ("abc", std::string(info.value.utf8().data())); | |
| 1060 EXPECT_EQ(3, info.selectionStart); | |
| 1061 EXPECT_EQ(3, info.selectionEnd); | |
| 1062 EXPECT_EQ(-1, info.compositionStart); | |
| 1063 EXPECT_EQ(-1, info.compositionEnd); | |
| 1064 | |
| 1065 WebVector<WebCompositionUnderline> emptyUnderlines; | |
| 1066 | |
| 1067 webView->setComposition(WebString::fromUTF8("123"), emptyUnderlines, -3, -3) ; | |
| 1068 info = webView->textInputInfo(); | |
| 1069 EXPECT_EQ("abc123", std::string(info.value.utf8().data())); | |
| 1070 EXPECT_EQ(0, info.selectionStart); | |
| 1071 EXPECT_EQ(0, info.selectionEnd); | |
| 1072 EXPECT_EQ(3, info.compositionStart); | |
| 1073 EXPECT_EQ(6, info.compositionEnd); | |
| 1074 | |
| 1075 // Confirms composing text and moves the caret. | |
| 1076 webView->confirmComposition("", -3); | |
| 1077 info = webView->textInputInfo(); | |
| 1078 EXPECT_EQ("abc123", std::string(info.value.utf8().data())); | |
| 1079 EXPECT_EQ(3, info.selectionStart); | |
| 1080 EXPECT_EQ(3, info.selectionEnd); | |
| 1081 EXPECT_EQ(-1, info.compositionStart); | |
| 1082 EXPECT_EQ(-1, info.compositionEnd); | |
| 1083 | |
| 1084 webView->setComposition(WebString::fromUTF8("ABC"), emptyUnderlines, -3, -3) ; | |
| 1085 info = webView->textInputInfo(); | |
| 1086 EXPECT_EQ("abcABC123", std::string(info.value.utf8().data())); | |
| 1087 EXPECT_EQ(0, info.selectionStart); | |
| 1088 EXPECT_EQ(0, info.selectionEnd); | |
| 1089 EXPECT_EQ(3, info.compositionStart); | |
| 1090 EXPECT_EQ(6, info.compositionEnd); | |
| 1091 | |
| 1092 // Replaces composing text with new text and moves the caret. | |
| 1093 webView->confirmComposition("456", 3); | |
| 1094 info = webView->textInputInfo(); | |
| 1095 EXPECT_EQ("abc456123", std::string(info.value.utf8().data())); | |
| 1096 EXPECT_EQ(9, info.selectionStart); | |
| 1097 EXPECT_EQ(9, info.selectionEnd); | |
| 1098 EXPECT_EQ(-1, info.compositionStart); | |
| 1099 EXPECT_EQ(-1, info.compositionEnd); | |
| 1100 | |
| 1101 // Inserts non-empty text and moves the caret. | |
| 1102 webView->confirmComposition("789", -9); | |
| 1103 info = webView->textInputInfo(); | |
| 1104 EXPECT_EQ("abc456123789", std::string(info.value.utf8().data())); | |
| 1105 EXPECT_EQ(3, info.selectionStart); | |
| 1106 EXPECT_EQ(3, info.selectionEnd); | |
| 1107 EXPECT_EQ(-1, info.compositionStart); | |
| 1108 EXPECT_EQ(-1, info.compositionEnd); | |
| 1109 | |
| 1110 // Inserts empty text and moves the caret. | |
| 1111 webView->confirmComposition("", 3); | |
| 1112 info = webView->textInputInfo(); | |
| 1113 EXPECT_EQ("abc456123789", std::string(info.value.utf8().data())); | |
| 1114 EXPECT_EQ(6, info.selectionStart); | |
| 1115 EXPECT_EQ(6, info.selectionEnd); | |
| 1116 EXPECT_EQ(-1, info.compositionStart); | |
| 1117 EXPECT_EQ(-1, info.compositionEnd); | |
| 1118 | |
| 1119 // Inserts empty text and doesn't move the caret. | |
| 1120 webView->confirmComposition("", 0); | |
| 1121 info = webView->textInputInfo(); | |
| 1122 EXPECT_EQ("abc456123789", std::string(info.value.utf8().data())); | |
| 1123 EXPECT_EQ(6, info.selectionStart); | |
| 1124 EXPECT_EQ(6, info.selectionEnd); | |
| 1125 EXPECT_EQ(-1, info.compositionStart); | |
| 1126 EXPECT_EQ(-1, info.compositionEnd); | |
| 1127 | |
| 1128 webView->setComposition(WebString::fromUTF8("ABC"), emptyUnderlines, 0, 0); | |
| 1129 info = webView->textInputInfo(); | |
| 1130 EXPECT_EQ("abc456ABC123789", std::string(info.value.utf8().data())); | |
| 1131 EXPECT_EQ(6, info.selectionStart); | |
| 1132 EXPECT_EQ(6, info.selectionEnd); | |
| 1133 EXPECT_EQ(6, info.compositionStart); | |
| 1134 EXPECT_EQ(9, info.compositionEnd); | |
| 1135 | |
|
yabinh
2016/08/31 11:23:27
We are able to move caret with composing text.
yabinh
2016/08/31 11:26:21
Typo. Should be "within composing text".
aelias_OOO_until_Jul13
2016/09/01 05:21:58
OK, I think we don't need to worry about that, tke
| |
| 1136 // Confirms composing text and moves the caret within the composing text. | |
| 1137 webView->confirmComposition("", -1); | |
| 1138 info = webView->textInputInfo(); | |
| 1139 EXPECT_EQ("abc456ABC123789", std::string(info.value.utf8().data())); | |
| 1140 EXPECT_EQ(8, info.selectionStart); | |
| 1141 EXPECT_EQ(8, info.selectionEnd); | |
| 1142 EXPECT_EQ(-1, info.compositionStart); | |
| 1143 EXPECT_EQ(-1, info.compositionEnd); | |
| 1144 } | |
| 1145 | |
| 865 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) | 1146 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) |
| 866 { | 1147 { |
| 867 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("form_with_input.html")); | 1148 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"); | 1149 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form_w ith_input.html"); |
| 869 webView->resize(WebSize(800, 600)); | 1150 webView->resize(WebSize(800, 600)); |
| 870 webView->setInitialFocus(false); | 1151 webView->setInitialFocus(false); |
| 871 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1152 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 872 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().height); | 1153 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().height); |
| 873 | 1154 |
| 874 // Set up a composition from existing text that needs to be committed. | 1155 // Set up a composition from existing text that needs to be committed. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 912 EXPECT_EQ(12, info.compositionEnd); | 1193 EXPECT_EQ(12, info.compositionEnd); |
| 913 | 1194 |
| 914 webView->confirmComposition(WebWidget::KeepSelection); | 1195 webView->confirmComposition(WebWidget::KeepSelection); |
| 915 info = webView->textInputInfo(); | 1196 info = webView->textInputInfo(); |
| 916 EXPECT_EQ(4, info.selectionStart); | 1197 EXPECT_EQ(4, info.selectionStart); |
| 917 EXPECT_EQ(4, info.selectionEnd); | 1198 EXPECT_EQ(4, info.selectionEnd); |
| 918 EXPECT_EQ(-1, info.compositionStart); | 1199 EXPECT_EQ(-1, info.compositionStart); |
| 919 EXPECT_EQ(-1, info.compositionEnd); | 1200 EXPECT_EQ(-1, info.compositionEnd); |
| 920 | 1201 |
| 921 std::string compositionText("\n"); | 1202 std::string compositionText("\n"); |
| 922 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 1203 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str()), 0) ; |
| 923 info = webView->textInputInfo(); | 1204 info = webView->textInputInfo(); |
| 924 EXPECT_EQ(5, info.selectionStart); | 1205 EXPECT_EQ(5, info.selectionStart); |
| 925 EXPECT_EQ(5, info.selectionEnd); | 1206 EXPECT_EQ(5, info.selectionEnd); |
| 926 EXPECT_EQ(-1, info.compositionStart); | 1207 EXPECT_EQ(-1, info.compositionStart); |
| 927 EXPECT_EQ(-1, info.compositionEnd); | 1208 EXPECT_EQ(-1, info.compositionEnd); |
| 928 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u tf8().data())); | 1209 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u tf8().data())); |
| 929 } | 1210 } |
| 930 | 1211 |
| 931 TEST_F(WebViewTest, ExtendSelectionAndDelete) | 1212 TEST_F(WebViewTest, ExtendSelectionAndDelete) |
| 932 { | 1213 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 1253 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
| 973 { | 1254 { |
| 974 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("text_area_populated.html")); | 1255 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"); | 1256 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a rea_populated.html"); |
| 976 webView->setInitialFocus(false); | 1257 webView->setInitialFocus(false); |
| 977 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1258 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 978 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1259 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 979 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1260 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 980 frame->setEditableSelectionOffsets(27, 27); | 1261 frame->setEditableSelectionOffsets(27, 27); |
| 981 std::string newLineText("\n"); | 1262 std::string newLineText("\n"); |
| 982 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); | 1263 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str()), 0); |
| 983 WebTextInputInfo info = webView->textInputInfo(); | 1264 WebTextInputInfo info = webView->textInputInfo(); |
| 984 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); | 1265 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); |
| 985 | 1266 |
| 986 frame->setEditableSelectionOffsets(31, 31); | 1267 frame->setEditableSelectionOffsets(31, 31); |
| 987 frame->setCompositionFromExistingText(30, 34, underlines); | 1268 frame->setCompositionFromExistingText(30, 34, underlines); |
| 988 info = webView->textInputInfo(); | 1269 info = webView->textInputInfo(); |
| 989 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); | 1270 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u tf8().data())); |
| 990 EXPECT_EQ(31, info.selectionStart); | 1271 EXPECT_EQ(31, info.selectionStart); |
| 991 EXPECT_EQ(31, info.selectionEnd); | 1272 EXPECT_EQ(31, info.selectionEnd); |
| 992 EXPECT_EQ(30, info.compositionStart); | 1273 EXPECT_EQ(30, info.compositionStart); |
| 993 EXPECT_EQ(34, info.compositionEnd); | 1274 EXPECT_EQ(34, info.compositionEnd); |
| 994 | 1275 |
| 995 std::string compositionText("yolo"); | 1276 std::string compositionText("yolo"); |
| 996 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 1277 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str()), 0) ; |
| 997 info = webView->textInputInfo(); | 1278 info = webView->textInputInfo(); |
| 998 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u tf8().data())); | 1279 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u tf8().data())); |
| 999 EXPECT_EQ(34, info.selectionStart); | 1280 EXPECT_EQ(34, info.selectionStart); |
| 1000 EXPECT_EQ(34, info.selectionEnd); | 1281 EXPECT_EQ(34, info.selectionEnd); |
| 1001 EXPECT_EQ(-1, info.compositionStart); | 1282 EXPECT_EQ(-1, info.compositionStart); |
| 1002 EXPECT_EQ(-1, info.compositionEnd); | 1283 EXPECT_EQ(-1, info.compositionEnd); |
| 1003 } | 1284 } |
| 1004 | 1285 |
| 1005 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) | 1286 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) |
| 1006 { | 1287 { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1020 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) | 1301 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) |
| 1021 { | 1302 { |
| 1022 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); | 1303 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"); | 1304 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_populated.html"); |
| 1024 webView->setInitialFocus(false); | 1305 webView->setInitialFocus(false); |
| 1025 | 1306 |
| 1026 std::string compositionTextFirst("hello "); | 1307 std::string compositionTextFirst("hello "); |
| 1027 std::string compositionTextSecond("world"); | 1308 std::string compositionTextSecond("world"); |
| 1028 WebVector<WebCompositionUnderline> emptyUnderlines; | 1309 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1029 | 1310 |
| 1030 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str() )); | 1311 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str() ), 0); |
| 1031 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, 5); | 1312 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, 5); |
| 1032 | 1313 |
| 1033 WebTextInputInfo info = webView->textInputInfo(); | 1314 WebTextInputInfo info = webView->textInputInfo(); |
| 1034 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1315 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1035 EXPECT_EQ(11, info.selectionStart); | 1316 EXPECT_EQ(11, info.selectionStart); |
| 1036 EXPECT_EQ(11, info.selectionEnd); | 1317 EXPECT_EQ(11, info.selectionEnd); |
| 1037 EXPECT_EQ(6, info.compositionStart); | 1318 EXPECT_EQ(6, info.compositionStart); |
| 1038 EXPECT_EQ(11, info.compositionEnd); | 1319 EXPECT_EQ(11, info.compositionEnd); |
| 1039 | 1320 |
| 1040 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1321 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| (...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3264 | 3545 |
| 3265 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) | 3546 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) |
| 3266 { | 3547 { |
| 3267 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_password.html")); | 3548 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_password.html")); |
| 3268 MockAutofillClient client; | 3549 MockAutofillClient client; |
| 3269 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_password.html", true); | 3550 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_ field_password.html", true); |
| 3270 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3551 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3271 frame->setAutofillClient(&client); | 3552 frame->setAutofillClient(&client); |
| 3272 webView->setInitialFocus(false); | 3553 webView->setInitialFocus(false); |
| 3273 | 3554 |
| 3274 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); | 3555 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()), 0)); |
| 3275 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3556 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3276 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3557 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3277 frame->setAutofillClient(0); | 3558 frame->setAutofillClient(0); |
| 3278 } | 3559 } |
| 3279 | 3560 |
| 3280 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the | 3561 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the |
| 3281 // stack defers its loads. | 3562 // stack defers its loads. |
| 3282 TEST_F(WebViewTest, CreatedDuringLoadDeferral) | 3563 TEST_F(WebViewTest, CreatedDuringLoadDeferral) |
| 3283 { | 3564 { |
| 3284 { | 3565 { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3342 EXPECT_TRUE(webView->page()->defersLoading()); | 3623 EXPECT_TRUE(webView->page()->defersLoading()); |
| 3343 } | 3624 } |
| 3344 | 3625 |
| 3345 EXPECT_TRUE(webView->page()->defersLoading()); | 3626 EXPECT_TRUE(webView->page()->defersLoading()); |
| 3346 } | 3627 } |
| 3347 | 3628 |
| 3348 EXPECT_FALSE(webView->page()->defersLoading()); | 3629 EXPECT_FALSE(webView->page()->defersLoading()); |
| 3349 } | 3630 } |
| 3350 | 3631 |
| 3351 } // namespace blink | 3632 } // namespace blink |
| OLD | NEW |