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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 #include "public/web/WebCache.h" | 79 #include "public/web/WebCache.h" |
80 #include "public/web/WebDateTimeChooserCompletion.h" | 80 #include "public/web/WebDateTimeChooserCompletion.h" |
81 #include "public/web/WebDeviceEmulationParams.h" | 81 #include "public/web/WebDeviceEmulationParams.h" |
82 #include "public/web/WebDocument.h" | 82 #include "public/web/WebDocument.h" |
83 #include "public/web/WebElement.h" | 83 #include "public/web/WebElement.h" |
84 #include "public/web/WebFrame.h" | 84 #include "public/web/WebFrame.h" |
85 #include "public/web/WebFrameClient.h" | 85 #include "public/web/WebFrameClient.h" |
86 #include "public/web/WebFrameContentDumper.h" | 86 #include "public/web/WebFrameContentDumper.h" |
87 #include "public/web/WebHitTestResult.h" | 87 #include "public/web/WebHitTestResult.h" |
88 #include "public/web/WebInputEvent.h" | 88 #include "public/web/WebInputEvent.h" |
| 89 #include "public/web/WebInputMethodController.h" |
89 #include "public/web/WebScriptSource.h" | 90 #include "public/web/WebScriptSource.h" |
90 #include "public/web/WebSettings.h" | 91 #include "public/web/WebSettings.h" |
91 #include "public/web/WebTreeScopeType.h" | 92 #include "public/web/WebTreeScopeType.h" |
92 #include "public/web/WebViewClient.h" | 93 #include "public/web/WebViewClient.h" |
93 #include "public/web/WebWidget.h" | 94 #include "public/web/WebWidget.h" |
94 #include "public/web/WebWidgetClient.h" | 95 #include "public/web/WebWidgetClient.h" |
95 #include "testing/gtest/include/gtest/gtest.h" | 96 #include "testing/gtest/include/gtest/gtest.h" |
96 #include "third_party/skia/include/core/SkBitmap.h" | 97 #include "third_party/skia/include/core/SkBitmap.h" |
97 #include "third_party/skia/include/core/SkCanvas.h" | 98 #include "third_party/skia/include/core/SkCanvas.h" |
98 #include "web/DevToolsEmulator.h" | 99 #include "web/DevToolsEmulator.h" |
| 100 #include "web/WebInputMethodControllerImpl.h" |
99 #include "web/WebLocalFrameImpl.h" | 101 #include "web/WebLocalFrameImpl.h" |
100 #include "web/WebSettingsImpl.h" | 102 #include "web/WebSettingsImpl.h" |
101 #include "web/WebViewImpl.h" | 103 #include "web/WebViewImpl.h" |
102 #include "web/tests/FrameTestHelpers.h" | 104 #include "web/tests/FrameTestHelpers.h" |
103 #include "wtf/PtrUtil.h" | 105 #include "wtf/PtrUtil.h" |
104 #include <memory> | 106 #include <memory> |
105 | 107 |
106 #if OS(MACOSX) | 108 #if OS(MACOSX) |
107 #include "public/web/mac/WebSubstringUtil.h" | 109 #include "public/web/mac/WebSubstringUtil.h" |
108 #endif | 110 #endif |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 EXPECT_EQ(8, info.selectionStart); | 894 EXPECT_EQ(8, info.selectionStart); |
893 EXPECT_EQ(19, info.selectionEnd); | 895 EXPECT_EQ(19, info.selectionEnd); |
894 EXPECT_EQ(-1, info.compositionStart); | 896 EXPECT_EQ(-1, info.compositionStart); |
895 EXPECT_EQ(-1, info.compositionEnd); | 897 EXPECT_EQ(-1, info.compositionEnd); |
896 } | 898 } |
897 | 899 |
898 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { | 900 TEST_P(WebViewTest, FinishComposingTextCursorPositionChange) { |
899 URLTestHelpers::registerMockedURLFromBaseURL( | 901 URLTestHelpers::registerMockedURLFromBaseURL( |
900 WebString::fromUTF8(m_baseURL.c_str()), | 902 WebString::fromUTF8(m_baseURL.c_str()), |
901 WebString::fromUTF8("input_field_populated.html")); | 903 WebString::fromUTF8("input_field_populated.html")); |
902 WebView* webView = m_webViewHelper.initializeAndLoad( | 904 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
903 m_baseURL + "input_field_populated.html"); | 905 m_baseURL + "input_field_populated.html"); |
904 webView->setInitialFocus(false); | 906 webView->setInitialFocus(false); |
905 | 907 |
906 // Set up a composition that needs to be committed. | 908 // Set up a composition that needs to be committed. |
907 std::string compositionText("hello"); | 909 std::string compositionText("hello"); |
908 | 910 |
| 911 WebInputMethodController* activeInputMethodController = |
| 912 webView->mainFrameImpl() |
| 913 ->frameWidget() |
| 914 ->getActiveWebInputMethodController(); |
909 WebVector<WebCompositionUnderline> emptyUnderlines; | 915 WebVector<WebCompositionUnderline> emptyUnderlines; |
910 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 916 activeInputMethodController->setComposition( |
911 emptyUnderlines, 3, 3); | 917 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
912 | 918 |
913 WebTextInputInfo info = webView->textInputInfo(); | 919 WebTextInputInfo info = webView->textInputInfo(); |
914 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 920 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
915 EXPECT_EQ(3, info.selectionStart); | 921 EXPECT_EQ(3, info.selectionStart); |
916 EXPECT_EQ(3, info.selectionEnd); | 922 EXPECT_EQ(3, info.selectionEnd); |
917 EXPECT_EQ(0, info.compositionStart); | 923 EXPECT_EQ(0, info.compositionStart); |
918 EXPECT_EQ(5, info.compositionEnd); | 924 EXPECT_EQ(5, info.compositionEnd); |
919 | 925 |
920 webView->finishComposingText(WebWidget::KeepSelection); | 926 activeInputMethodController->finishComposingText( |
| 927 WebInputMethodController::KeepSelection); |
921 info = webView->textInputInfo(); | 928 info = webView->textInputInfo(); |
922 EXPECT_EQ(3, info.selectionStart); | 929 EXPECT_EQ(3, info.selectionStart); |
923 EXPECT_EQ(3, info.selectionEnd); | 930 EXPECT_EQ(3, info.selectionEnd); |
924 EXPECT_EQ(-1, info.compositionStart); | 931 EXPECT_EQ(-1, info.compositionStart); |
925 EXPECT_EQ(-1, info.compositionEnd); | 932 EXPECT_EQ(-1, info.compositionEnd); |
926 | 933 |
927 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 934 activeInputMethodController->setComposition( |
928 emptyUnderlines, 3, 3); | 935 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
929 info = webView->textInputInfo(); | 936 info = webView->textInputInfo(); |
930 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); | 937 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); |
931 EXPECT_EQ(6, info.selectionStart); | 938 EXPECT_EQ(6, info.selectionStart); |
932 EXPECT_EQ(6, info.selectionEnd); | 939 EXPECT_EQ(6, info.selectionEnd); |
933 EXPECT_EQ(3, info.compositionStart); | 940 EXPECT_EQ(3, info.compositionStart); |
934 EXPECT_EQ(8, info.compositionEnd); | 941 EXPECT_EQ(8, info.compositionEnd); |
935 | 942 |
936 webView->finishComposingText(WebWidget::DoNotKeepSelection); | 943 activeInputMethodController->finishComposingText( |
| 944 WebInputMethodController::DoNotKeepSelection); |
937 info = webView->textInputInfo(); | 945 info = webView->textInputInfo(); |
938 EXPECT_EQ(8, info.selectionStart); | 946 EXPECT_EQ(8, info.selectionStart); |
939 EXPECT_EQ(8, info.selectionEnd); | 947 EXPECT_EQ(8, info.selectionEnd); |
940 EXPECT_EQ(-1, info.compositionStart); | 948 EXPECT_EQ(-1, info.compositionStart); |
941 EXPECT_EQ(-1, info.compositionEnd); | 949 EXPECT_EQ(-1, info.compositionEnd); |
942 } | 950 } |
943 | 951 |
944 TEST_P(WebViewTest, SetCompositionForNewCaretPositions) { | 952 TEST_P(WebViewTest, SetCompositionForNewCaretPositions) { |
945 URLTestHelpers::registerMockedURLFromBaseURL( | 953 URLTestHelpers::registerMockedURLFromBaseURL( |
946 WebString::fromUTF8(m_baseURL.c_str()), | 954 WebString::fromUTF8(m_baseURL.c_str()), |
947 WebString::fromUTF8("input_field_populated.html")); | 955 WebString::fromUTF8("input_field_populated.html")); |
948 WebView* webView = m_webViewHelper.initializeAndLoad( | 956 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
949 m_baseURL + "input_field_populated.html"); | 957 m_baseURL + "input_field_populated.html"); |
950 webView->setInitialFocus(false); | 958 webView->setInitialFocus(false); |
| 959 WebInputMethodController* activeInputMethodController = |
| 960 webView->mainFrameImpl() |
| 961 ->frameWidget() |
| 962 ->getActiveWebInputMethodController(); |
951 | 963 |
952 webView->commitText("hello", 0); | 964 activeInputMethodController->commitText("hello", 0); |
953 webView->commitText("world", -5); | 965 activeInputMethodController->commitText("world", -5); |
954 WebTextInputInfo info = webView->textInputInfo(); | 966 WebTextInputInfo info = webView->textInputInfo(); |
955 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 967 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
956 EXPECT_EQ(5, info.selectionStart); | 968 EXPECT_EQ(5, info.selectionStart); |
957 EXPECT_EQ(5, info.selectionEnd); | 969 EXPECT_EQ(5, info.selectionEnd); |
958 EXPECT_EQ(-1, info.compositionStart); | 970 EXPECT_EQ(-1, info.compositionStart); |
959 EXPECT_EQ(-1, info.compositionEnd); | 971 EXPECT_EQ(-1, info.compositionEnd); |
960 | 972 |
961 WebVector<WebCompositionUnderline> emptyUnderlines; | 973 WebVector<WebCompositionUnderline> emptyUnderlines; |
962 // Set up a composition that needs to be committed. | 974 // Set up a composition that needs to be committed. |
963 std::string compositionText("ABC"); | 975 std::string compositionText("ABC"); |
964 | 976 |
965 // Caret is on the left of composing text. | 977 // Caret is on the left of composing text. |
966 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 978 activeInputMethodController->setComposition( |
967 emptyUnderlines, 0, 0); | 979 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0); |
968 info = webView->textInputInfo(); | 980 info = webView->textInputInfo(); |
969 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 981 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
970 EXPECT_EQ(5, info.selectionStart); | 982 EXPECT_EQ(5, info.selectionStart); |
971 EXPECT_EQ(5, info.selectionEnd); | 983 EXPECT_EQ(5, info.selectionEnd); |
972 EXPECT_EQ(5, info.compositionStart); | 984 EXPECT_EQ(5, info.compositionStart); |
973 EXPECT_EQ(8, info.compositionEnd); | 985 EXPECT_EQ(8, info.compositionEnd); |
974 | 986 |
975 // Caret is on the right of composing text. | 987 // Caret is on the right of composing text. |
976 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 988 activeInputMethodController->setComposition( |
977 emptyUnderlines, 3, 3); | 989 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3); |
978 info = webView->textInputInfo(); | 990 info = webView->textInputInfo(); |
979 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 991 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
980 EXPECT_EQ(8, info.selectionStart); | 992 EXPECT_EQ(8, info.selectionStart); |
981 EXPECT_EQ(8, info.selectionEnd); | 993 EXPECT_EQ(8, info.selectionEnd); |
982 EXPECT_EQ(5, info.compositionStart); | 994 EXPECT_EQ(5, info.compositionStart); |
983 EXPECT_EQ(8, info.compositionEnd); | 995 EXPECT_EQ(8, info.compositionEnd); |
984 | 996 |
985 // Caret is between composing text and left boundary. | 997 // Caret is between composing text and left boundary. |
986 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 998 activeInputMethodController->setComposition( |
987 emptyUnderlines, -2, -2); | 999 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -2, -2); |
988 info = webView->textInputInfo(); | 1000 info = webView->textInputInfo(); |
989 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1001 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
990 EXPECT_EQ(3, info.selectionStart); | 1002 EXPECT_EQ(3, info.selectionStart); |
991 EXPECT_EQ(3, info.selectionEnd); | 1003 EXPECT_EQ(3, info.selectionEnd); |
992 EXPECT_EQ(5, info.compositionStart); | 1004 EXPECT_EQ(5, info.compositionStart); |
993 EXPECT_EQ(8, info.compositionEnd); | 1005 EXPECT_EQ(8, info.compositionEnd); |
994 | 1006 |
995 // Caret is between composing text and right boundary. | 1007 // Caret is between composing text and right boundary. |
996 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1008 activeInputMethodController->setComposition( |
997 emptyUnderlines, 5, 5); | 1009 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5); |
998 info = webView->textInputInfo(); | 1010 info = webView->textInputInfo(); |
999 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1011 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1000 EXPECT_EQ(10, info.selectionStart); | 1012 EXPECT_EQ(10, info.selectionStart); |
1001 EXPECT_EQ(10, info.selectionEnd); | 1013 EXPECT_EQ(10, info.selectionEnd); |
1002 EXPECT_EQ(5, info.compositionStart); | 1014 EXPECT_EQ(5, info.compositionStart); |
1003 EXPECT_EQ(8, info.compositionEnd); | 1015 EXPECT_EQ(8, info.compositionEnd); |
1004 | 1016 |
1005 // Caret is on the left boundary. | 1017 // Caret is on the left boundary. |
1006 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1018 activeInputMethodController->setComposition( |
1007 emptyUnderlines, -5, -5); | 1019 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -5, -5); |
1008 info = webView->textInputInfo(); | 1020 info = webView->textInputInfo(); |
1009 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1021 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1010 EXPECT_EQ(0, info.selectionStart); | 1022 EXPECT_EQ(0, info.selectionStart); |
1011 EXPECT_EQ(0, info.selectionEnd); | 1023 EXPECT_EQ(0, info.selectionEnd); |
1012 EXPECT_EQ(5, info.compositionStart); | 1024 EXPECT_EQ(5, info.compositionStart); |
1013 EXPECT_EQ(8, info.compositionEnd); | 1025 EXPECT_EQ(8, info.compositionEnd); |
1014 | 1026 |
1015 // Caret is on the right boundary. | 1027 // Caret is on the right boundary. |
1016 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1028 activeInputMethodController->setComposition( |
1017 emptyUnderlines, 8, 8); | 1029 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 8, 8); |
1018 info = webView->textInputInfo(); | 1030 info = webView->textInputInfo(); |
1019 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1031 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1020 EXPECT_EQ(13, info.selectionStart); | 1032 EXPECT_EQ(13, info.selectionStart); |
1021 EXPECT_EQ(13, info.selectionEnd); | 1033 EXPECT_EQ(13, info.selectionEnd); |
1022 EXPECT_EQ(5, info.compositionStart); | 1034 EXPECT_EQ(5, info.compositionStart); |
1023 EXPECT_EQ(8, info.compositionEnd); | 1035 EXPECT_EQ(8, info.compositionEnd); |
1024 | 1036 |
1025 // Caret exceeds the left boundary. | 1037 // Caret exceeds the left boundary. |
1026 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1038 activeInputMethodController->setComposition( |
1027 emptyUnderlines, -100, -100); | 1039 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -100, |
| 1040 -100); |
1028 info = webView->textInputInfo(); | 1041 info = webView->textInputInfo(); |
1029 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1042 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1030 EXPECT_EQ(0, info.selectionStart); | 1043 EXPECT_EQ(0, info.selectionStart); |
1031 EXPECT_EQ(0, info.selectionEnd); | 1044 EXPECT_EQ(0, info.selectionEnd); |
1032 EXPECT_EQ(5, info.compositionStart); | 1045 EXPECT_EQ(5, info.compositionStart); |
1033 EXPECT_EQ(8, info.compositionEnd); | 1046 EXPECT_EQ(8, info.compositionEnd); |
1034 | 1047 |
1035 // Caret exceeds the right boundary. | 1048 // Caret exceeds the right boundary. |
1036 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 1049 activeInputMethodController->setComposition( |
1037 emptyUnderlines, 100, 100); | 1050 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 100, 100); |
1038 info = webView->textInputInfo(); | 1051 info = webView->textInputInfo(); |
1039 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 1052 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
1040 EXPECT_EQ(13, info.selectionStart); | 1053 EXPECT_EQ(13, info.selectionStart); |
1041 EXPECT_EQ(13, info.selectionEnd); | 1054 EXPECT_EQ(13, info.selectionEnd); |
1042 EXPECT_EQ(5, info.compositionStart); | 1055 EXPECT_EQ(5, info.compositionStart); |
1043 EXPECT_EQ(8, info.compositionEnd); | 1056 EXPECT_EQ(8, info.compositionEnd); |
1044 } | 1057 } |
1045 | 1058 |
1046 TEST_P(WebViewTest, SetCompositionWithEmptyText) { | 1059 TEST_P(WebViewTest, SetCompositionWithEmptyText) { |
1047 URLTestHelpers::registerMockedURLFromBaseURL( | 1060 URLTestHelpers::registerMockedURLFromBaseURL( |
1048 WebString::fromUTF8(m_baseURL.c_str()), | 1061 WebString::fromUTF8(m_baseURL.c_str()), |
1049 WebString::fromUTF8("input_field_populated.html")); | 1062 WebString::fromUTF8("input_field_populated.html")); |
1050 WebView* webView = m_webViewHelper.initializeAndLoad( | 1063 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1051 m_baseURL + "input_field_populated.html"); | 1064 m_baseURL + "input_field_populated.html"); |
1052 webView->setInitialFocus(false); | 1065 webView->setInitialFocus(false); |
| 1066 WebInputMethodController* activeInputMethodController = |
| 1067 webView->mainFrameImpl() |
| 1068 ->frameWidget() |
| 1069 ->getActiveWebInputMethodController(); |
1053 | 1070 |
1054 webView->commitText("hello", 0); | 1071 activeInputMethodController->commitText("hello", 0); |
1055 WebTextInputInfo info = webView->textInputInfo(); | 1072 WebTextInputInfo info = webView->textInputInfo(); |
1056 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1073 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1057 EXPECT_EQ(5, info.selectionStart); | 1074 EXPECT_EQ(5, info.selectionStart); |
1058 EXPECT_EQ(5, info.selectionEnd); | 1075 EXPECT_EQ(5, info.selectionEnd); |
1059 EXPECT_EQ(-1, info.compositionStart); | 1076 EXPECT_EQ(-1, info.compositionStart); |
1060 EXPECT_EQ(-1, info.compositionEnd); | 1077 EXPECT_EQ(-1, info.compositionEnd); |
1061 | 1078 |
1062 WebVector<WebCompositionUnderline> emptyUnderlines; | 1079 WebVector<WebCompositionUnderline> emptyUnderlines; |
1063 | 1080 |
1064 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, 0, 0); | 1081 activeInputMethodController->setComposition(WebString::fromUTF8(""), |
| 1082 emptyUnderlines, 0, 0); |
1065 info = webView->textInputInfo(); | 1083 info = webView->textInputInfo(); |
1066 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1084 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1067 EXPECT_EQ(5, info.selectionStart); | 1085 EXPECT_EQ(5, info.selectionStart); |
1068 EXPECT_EQ(5, info.selectionEnd); | 1086 EXPECT_EQ(5, info.selectionEnd); |
1069 EXPECT_EQ(-1, info.compositionStart); | 1087 EXPECT_EQ(-1, info.compositionStart); |
1070 EXPECT_EQ(-1, info.compositionEnd); | 1088 EXPECT_EQ(-1, info.compositionEnd); |
1071 | 1089 |
1072 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, -2, -2); | 1090 activeInputMethodController->setComposition(WebString::fromUTF8(""), |
| 1091 emptyUnderlines, -2, -2); |
1073 info = webView->textInputInfo(); | 1092 info = webView->textInputInfo(); |
1074 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1093 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1075 EXPECT_EQ(3, info.selectionStart); | 1094 EXPECT_EQ(3, info.selectionStart); |
1076 EXPECT_EQ(3, info.selectionEnd); | 1095 EXPECT_EQ(3, info.selectionEnd); |
1077 EXPECT_EQ(-1, info.compositionStart); | 1096 EXPECT_EQ(-1, info.compositionStart); |
1078 EXPECT_EQ(-1, info.compositionEnd); | 1097 EXPECT_EQ(-1, info.compositionEnd); |
1079 } | 1098 } |
1080 | 1099 |
1081 TEST_P(WebViewTest, CommitTextForNewCaretPositions) { | 1100 TEST_P(WebViewTest, CommitTextForNewCaretPositions) { |
1082 URLTestHelpers::registerMockedURLFromBaseURL( | 1101 URLTestHelpers::registerMockedURLFromBaseURL( |
1083 WebString::fromUTF8(m_baseURL.c_str()), | 1102 WebString::fromUTF8(m_baseURL.c_str()), |
1084 WebString::fromUTF8("input_field_populated.html")); | 1103 WebString::fromUTF8("input_field_populated.html")); |
1085 WebView* webView = m_webViewHelper.initializeAndLoad( | 1104 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1086 m_baseURL + "input_field_populated.html"); | 1105 m_baseURL + "input_field_populated.html"); |
1087 webView->setInitialFocus(false); | 1106 webView->setInitialFocus(false); |
| 1107 WebInputMethodController* activeInputMethodController = |
| 1108 webView->mainFrameImpl() |
| 1109 ->frameWidget() |
| 1110 ->getActiveWebInputMethodController(); |
1088 | 1111 |
1089 // Caret is on the left of composing text. | 1112 // Caret is on the left of composing text. |
1090 webView->commitText("ab", -2); | 1113 activeInputMethodController->commitText("ab", -2); |
1091 WebTextInputInfo info = webView->textInputInfo(); | 1114 WebTextInputInfo info = webView->textInputInfo(); |
1092 EXPECT_EQ("ab", std::string(info.value.utf8().data())); | 1115 EXPECT_EQ("ab", std::string(info.value.utf8().data())); |
1093 EXPECT_EQ(0, info.selectionStart); | 1116 EXPECT_EQ(0, info.selectionStart); |
1094 EXPECT_EQ(0, info.selectionEnd); | 1117 EXPECT_EQ(0, info.selectionEnd); |
1095 EXPECT_EQ(-1, info.compositionStart); | 1118 EXPECT_EQ(-1, info.compositionStart); |
1096 EXPECT_EQ(-1, info.compositionEnd); | 1119 EXPECT_EQ(-1, info.compositionEnd); |
1097 | 1120 |
1098 // Caret is on the right of composing text. | 1121 // Caret is on the right of composing text. |
1099 webView->commitText("c", 1); | 1122 activeInputMethodController->commitText("c", 1); |
1100 info = webView->textInputInfo(); | 1123 info = webView->textInputInfo(); |
1101 EXPECT_EQ("cab", std::string(info.value.utf8().data())); | 1124 EXPECT_EQ("cab", std::string(info.value.utf8().data())); |
1102 EXPECT_EQ(2, info.selectionStart); | 1125 EXPECT_EQ(2, info.selectionStart); |
1103 EXPECT_EQ(2, info.selectionEnd); | 1126 EXPECT_EQ(2, info.selectionEnd); |
1104 EXPECT_EQ(-1, info.compositionStart); | 1127 EXPECT_EQ(-1, info.compositionStart); |
1105 EXPECT_EQ(-1, info.compositionEnd); | 1128 EXPECT_EQ(-1, info.compositionEnd); |
1106 | 1129 |
1107 // Caret is on the left boundary. | 1130 // Caret is on the left boundary. |
1108 webView->commitText("def", -5); | 1131 activeInputMethodController->commitText("def", -5); |
1109 info = webView->textInputInfo(); | 1132 info = webView->textInputInfo(); |
1110 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); | 1133 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); |
1111 EXPECT_EQ(0, info.selectionStart); | 1134 EXPECT_EQ(0, info.selectionStart); |
1112 EXPECT_EQ(0, info.selectionEnd); | 1135 EXPECT_EQ(0, info.selectionEnd); |
1113 EXPECT_EQ(-1, info.compositionStart); | 1136 EXPECT_EQ(-1, info.compositionStart); |
1114 EXPECT_EQ(-1, info.compositionEnd); | 1137 EXPECT_EQ(-1, info.compositionEnd); |
1115 | 1138 |
1116 // Caret is on the right boundary. | 1139 // Caret is on the right boundary. |
1117 webView->commitText("g", 6); | 1140 activeInputMethodController->commitText("g", 6); |
1118 info = webView->textInputInfo(); | 1141 info = webView->textInputInfo(); |
1119 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); | 1142 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); |
1120 EXPECT_EQ(7, info.selectionStart); | 1143 EXPECT_EQ(7, info.selectionStart); |
1121 EXPECT_EQ(7, info.selectionEnd); | 1144 EXPECT_EQ(7, info.selectionEnd); |
1122 EXPECT_EQ(-1, info.compositionStart); | 1145 EXPECT_EQ(-1, info.compositionStart); |
1123 EXPECT_EQ(-1, info.compositionEnd); | 1146 EXPECT_EQ(-1, info.compositionEnd); |
1124 | 1147 |
1125 // Caret exceeds the left boundary. | 1148 // Caret exceeds the left boundary. |
1126 webView->commitText("hi", -100); | 1149 activeInputMethodController->commitText("hi", -100); |
1127 info = webView->textInputInfo(); | 1150 info = webView->textInputInfo(); |
1128 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); | 1151 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); |
1129 EXPECT_EQ(0, info.selectionStart); | 1152 EXPECT_EQ(0, info.selectionStart); |
1130 EXPECT_EQ(0, info.selectionEnd); | 1153 EXPECT_EQ(0, info.selectionEnd); |
1131 EXPECT_EQ(-1, info.compositionStart); | 1154 EXPECT_EQ(-1, info.compositionStart); |
1132 EXPECT_EQ(-1, info.compositionEnd); | 1155 EXPECT_EQ(-1, info.compositionEnd); |
1133 | 1156 |
1134 // Caret exceeds the right boundary. | 1157 // Caret exceeds the right boundary. |
1135 webView->commitText("jk", 100); | 1158 activeInputMethodController->commitText("jk", 100); |
1136 info = webView->textInputInfo(); | 1159 info = webView->textInputInfo(); |
1137 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); | 1160 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); |
1138 EXPECT_EQ(11, info.selectionStart); | 1161 EXPECT_EQ(11, info.selectionStart); |
1139 EXPECT_EQ(11, info.selectionEnd); | 1162 EXPECT_EQ(11, info.selectionEnd); |
1140 EXPECT_EQ(-1, info.compositionStart); | 1163 EXPECT_EQ(-1, info.compositionStart); |
1141 EXPECT_EQ(-1, info.compositionEnd); | 1164 EXPECT_EQ(-1, info.compositionEnd); |
1142 } | 1165 } |
1143 | 1166 |
1144 TEST_P(WebViewTest, CommitTextWhileComposing) { | 1167 TEST_P(WebViewTest, CommitTextWhileComposing) { |
1145 URLTestHelpers::registerMockedURLFromBaseURL( | 1168 URLTestHelpers::registerMockedURLFromBaseURL( |
1146 WebString::fromUTF8(m_baseURL.c_str()), | 1169 WebString::fromUTF8(m_baseURL.c_str()), |
1147 WebString::fromUTF8("input_field_populated.html")); | 1170 WebString::fromUTF8("input_field_populated.html")); |
1148 WebView* webView = m_webViewHelper.initializeAndLoad( | 1171 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1149 m_baseURL + "input_field_populated.html"); | 1172 m_baseURL + "input_field_populated.html"); |
1150 webView->setInitialFocus(false); | 1173 webView->setInitialFocus(false); |
| 1174 WebInputMethodController* activeInputMethodController = |
| 1175 webView->mainFrameImpl() |
| 1176 ->frameWidget() |
| 1177 ->getActiveWebInputMethodController(); |
1151 | 1178 |
1152 WebVector<WebCompositionUnderline> emptyUnderlines; | 1179 WebVector<WebCompositionUnderline> emptyUnderlines; |
1153 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); | 1180 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), |
| 1181 emptyUnderlines, 0, 0); |
1154 WebTextInputInfo info = webView->textInputInfo(); | 1182 WebTextInputInfo info = webView->textInputInfo(); |
1155 EXPECT_EQ("abc", std::string(info.value.utf8().data())); | 1183 EXPECT_EQ("abc", std::string(info.value.utf8().data())); |
1156 EXPECT_EQ(0, info.selectionStart); | 1184 EXPECT_EQ(0, info.selectionStart); |
1157 EXPECT_EQ(0, info.selectionEnd); | 1185 EXPECT_EQ(0, info.selectionEnd); |
1158 EXPECT_EQ(0, info.compositionStart); | 1186 EXPECT_EQ(0, info.compositionStart); |
1159 EXPECT_EQ(3, info.compositionEnd); | 1187 EXPECT_EQ(3, info.compositionEnd); |
1160 | 1188 |
1161 // Deletes ongoing composition, inserts the specified text and moves the | 1189 // Deletes ongoing composition, inserts the specified text and moves the |
1162 // caret. | 1190 // caret. |
1163 webView->commitText("hello", -2); | 1191 activeInputMethodController->commitText("hello", -2); |
1164 info = webView->textInputInfo(); | 1192 info = webView->textInputInfo(); |
1165 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1193 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1166 EXPECT_EQ(3, info.selectionStart); | 1194 EXPECT_EQ(3, info.selectionStart); |
1167 EXPECT_EQ(3, info.selectionEnd); | 1195 EXPECT_EQ(3, info.selectionEnd); |
1168 EXPECT_EQ(-1, info.compositionStart); | 1196 EXPECT_EQ(-1, info.compositionStart); |
1169 EXPECT_EQ(-1, info.compositionEnd); | 1197 EXPECT_EQ(-1, info.compositionEnd); |
1170 | 1198 |
1171 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); | 1199 activeInputMethodController->setComposition(WebString::fromUTF8("abc"), |
| 1200 emptyUnderlines, 0, 0); |
1172 info = webView->textInputInfo(); | 1201 info = webView->textInputInfo(); |
1173 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); | 1202 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); |
1174 EXPECT_EQ(3, info.selectionStart); | 1203 EXPECT_EQ(3, info.selectionStart); |
1175 EXPECT_EQ(3, info.selectionEnd); | 1204 EXPECT_EQ(3, info.selectionEnd); |
1176 EXPECT_EQ(3, info.compositionStart); | 1205 EXPECT_EQ(3, info.compositionStart); |
1177 EXPECT_EQ(6, info.compositionEnd); | 1206 EXPECT_EQ(6, info.compositionEnd); |
1178 | 1207 |
1179 // Deletes ongoing composition and moves the caret. | 1208 // Deletes ongoing composition and moves the caret. |
1180 webView->commitText("", 2); | 1209 activeInputMethodController->commitText("", 2); |
1181 info = webView->textInputInfo(); | 1210 info = webView->textInputInfo(); |
1182 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1211 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1183 EXPECT_EQ(5, info.selectionStart); | 1212 EXPECT_EQ(5, info.selectionStart); |
1184 EXPECT_EQ(5, info.selectionEnd); | 1213 EXPECT_EQ(5, info.selectionEnd); |
1185 EXPECT_EQ(-1, info.compositionStart); | 1214 EXPECT_EQ(-1, info.compositionStart); |
1186 EXPECT_EQ(-1, info.compositionEnd); | 1215 EXPECT_EQ(-1, info.compositionEnd); |
1187 | 1216 |
1188 // Inserts the specified text and moves the caret. | 1217 // Inserts the specified text and moves the caret. |
1189 webView->commitText("world", -5); | 1218 activeInputMethodController->commitText("world", -5); |
1190 info = webView->textInputInfo(); | 1219 info = webView->textInputInfo(); |
1191 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1220 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1192 EXPECT_EQ(5, info.selectionStart); | 1221 EXPECT_EQ(5, info.selectionStart); |
1193 EXPECT_EQ(5, info.selectionEnd); | 1222 EXPECT_EQ(5, info.selectionEnd); |
1194 EXPECT_EQ(-1, info.compositionStart); | 1223 EXPECT_EQ(-1, info.compositionStart); |
1195 EXPECT_EQ(-1, info.compositionEnd); | 1224 EXPECT_EQ(-1, info.compositionEnd); |
1196 | 1225 |
1197 // Only moves the caret. | 1226 // Only moves the caret. |
1198 webView->commitText("", 5); | 1227 activeInputMethodController->commitText("", 5); |
1199 info = webView->textInputInfo(); | 1228 info = webView->textInputInfo(); |
1200 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1229 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
1201 EXPECT_EQ(10, info.selectionStart); | 1230 EXPECT_EQ(10, info.selectionStart); |
1202 EXPECT_EQ(10, info.selectionEnd); | 1231 EXPECT_EQ(10, info.selectionEnd); |
1203 EXPECT_EQ(-1, info.compositionStart); | 1232 EXPECT_EQ(-1, info.compositionStart); |
1204 EXPECT_EQ(-1, info.compositionEnd); | 1233 EXPECT_EQ(-1, info.compositionEnd); |
1205 } | 1234 } |
1206 | 1235 |
1207 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { | 1236 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { |
1208 URLTestHelpers::registerMockedURLFromBaseURL( | 1237 URLTestHelpers::registerMockedURLFromBaseURL( |
(...skipping 17 matching lines...) Expand all Loading... |
1226 webView->mainFrame()->document().getElementById("btn")); | 1255 webView->mainFrame()->document().getElementById("btn")); |
1227 element->scrollIntoView(); | 1256 element->scrollIntoView(); |
1228 float offsetHeight = webView->mainFrame()->scrollOffset().height; | 1257 float offsetHeight = webView->mainFrame()->scrollOffset().height; |
1229 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1258 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
1230 EXPECT_LT(0, offsetHeight); | 1259 EXPECT_LT(0, offsetHeight); |
1231 | 1260 |
1232 WebTextInputInfo info = webView->textInputInfo(); | 1261 WebTextInputInfo info = webView->textInputInfo(); |
1233 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1262 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
1234 | 1263 |
1235 // Verify that the input field is not scrolled back into the viewport. | 1264 // Verify that the input field is not scrolled back into the viewport. |
1236 webView->finishComposingText(WebWidget::DoNotKeepSelection); | 1265 frame->frameWidget() |
| 1266 ->getActiveWebInputMethodController() |
| 1267 ->finishComposingText(WebInputMethodController::DoNotKeepSelection); |
1237 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1268 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
1238 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); | 1269 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); |
1239 } | 1270 } |
1240 | 1271 |
1241 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { | 1272 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { |
1242 URLTestHelpers::registerMockedURLFromBaseURL( | 1273 URLTestHelpers::registerMockedURLFromBaseURL( |
1243 WebString::fromUTF8(m_baseURL.c_str()), | 1274 WebString::fromUTF8(m_baseURL.c_str()), |
1244 WebString::fromUTF8("text_area_populated.html")); | 1275 WebString::fromUTF8("text_area_populated.html")); |
1245 WebViewImpl* webView = | 1276 WebViewImpl* webView = |
1246 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); | 1277 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); |
1247 webView->setInitialFocus(false); | 1278 webView->setInitialFocus(false); |
1248 | 1279 |
1249 WebVector<WebCompositionUnderline> emptyUnderlines; | 1280 WebVector<WebCompositionUnderline> emptyUnderlines; |
1250 | 1281 |
1251 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1282 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
1252 frame->setEditableSelectionOffsets(4, 4); | 1283 frame->setEditableSelectionOffsets(4, 4); |
1253 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1284 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
1254 | 1285 |
1255 WebTextInputInfo info = webView->textInputInfo(); | 1286 WebTextInputInfo info = webView->textInputInfo(); |
1256 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", | 1287 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", |
1257 std::string(info.value.utf8().data())); | 1288 std::string(info.value.utf8().data())); |
1258 EXPECT_EQ(4, info.selectionStart); | 1289 EXPECT_EQ(4, info.selectionStart); |
1259 EXPECT_EQ(4, info.selectionEnd); | 1290 EXPECT_EQ(4, info.selectionEnd); |
1260 EXPECT_EQ(8, info.compositionStart); | 1291 EXPECT_EQ(8, info.compositionStart); |
1261 EXPECT_EQ(12, info.compositionEnd); | 1292 EXPECT_EQ(12, info.compositionEnd); |
1262 | 1293 |
1263 webView->finishComposingText(WebWidget::KeepSelection); | 1294 WebInputMethodController* activeInputMethodController = |
| 1295 frame->frameWidget()->getActiveWebInputMethodController(); |
| 1296 activeInputMethodController->finishComposingText( |
| 1297 WebInputMethodController::KeepSelection); |
1264 info = webView->textInputInfo(); | 1298 info = webView->textInputInfo(); |
1265 EXPECT_EQ(4, info.selectionStart); | 1299 EXPECT_EQ(4, info.selectionStart); |
1266 EXPECT_EQ(4, info.selectionEnd); | 1300 EXPECT_EQ(4, info.selectionEnd); |
1267 EXPECT_EQ(-1, info.compositionStart); | 1301 EXPECT_EQ(-1, info.compositionStart); |
1268 EXPECT_EQ(-1, info.compositionEnd); | 1302 EXPECT_EQ(-1, info.compositionEnd); |
1269 | 1303 |
1270 std::string compositionText("\n"); | 1304 std::string compositionText("\n"); |
1271 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); | 1305 activeInputMethodController->commitText( |
| 1306 WebString::fromUTF8(compositionText.c_str()), 0); |
1272 info = webView->textInputInfo(); | 1307 info = webView->textInputInfo(); |
1273 EXPECT_EQ(5, info.selectionStart); | 1308 EXPECT_EQ(5, info.selectionStart); |
1274 EXPECT_EQ(5, info.selectionEnd); | 1309 EXPECT_EQ(5, info.selectionEnd); |
1275 EXPECT_EQ(-1, info.compositionStart); | 1310 EXPECT_EQ(-1, info.compositionStart); |
1276 EXPECT_EQ(-1, info.compositionEnd); | 1311 EXPECT_EQ(-1, info.compositionEnd); |
1277 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", | 1312 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", |
1278 std::string(info.value.utf8().data())); | 1313 std::string(info.value.utf8().data())); |
1279 } | 1314 } |
1280 | 1315 |
1281 TEST_P(WebViewTest, ExtendSelectionAndDelete) { | 1316 TEST_P(WebViewTest, ExtendSelectionAndDelete) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) { | 1404 TEST_P(WebViewTest, SetCompositionFromExistingTextInTextArea) { |
1370 URLTestHelpers::registerMockedURLFromBaseURL( | 1405 URLTestHelpers::registerMockedURLFromBaseURL( |
1371 WebString::fromUTF8(m_baseURL.c_str()), | 1406 WebString::fromUTF8(m_baseURL.c_str()), |
1372 WebString::fromUTF8("text_area_populated.html")); | 1407 WebString::fromUTF8("text_area_populated.html")); |
1373 WebViewImpl* webView = | 1408 WebViewImpl* webView = |
1374 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); | 1409 m_webViewHelper.initializeAndLoad(m_baseURL + "text_area_populated.html"); |
1375 webView->setInitialFocus(false); | 1410 webView->setInitialFocus(false); |
1376 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1411 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
1377 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1412 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
1378 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1413 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1414 WebInputMethodController* activeInputMethodController = |
| 1415 frame->frameWidget()->getActiveWebInputMethodController(); |
1379 frame->setEditableSelectionOffsets(27, 27); | 1416 frame->setEditableSelectionOffsets(27, 27); |
1380 std::string newLineText("\n"); | 1417 std::string newLineText("\n"); |
1381 webView->commitText(WebString::fromUTF8(newLineText.c_str()), 0); | 1418 activeInputMethodController->commitText( |
| 1419 WebString::fromUTF8(newLineText.c_str()), 0); |
1382 WebTextInputInfo info = webView->textInputInfo(); | 1420 WebTextInputInfo info = webView->textInputInfo(); |
1383 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", | 1421 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", |
1384 std::string(info.value.utf8().data())); | 1422 std::string(info.value.utf8().data())); |
1385 | 1423 |
1386 frame->setEditableSelectionOffsets(31, 31); | 1424 frame->setEditableSelectionOffsets(31, 31); |
1387 frame->setCompositionFromExistingText(30, 34, underlines); | 1425 frame->setCompositionFromExistingText(30, 34, underlines); |
1388 info = webView->textInputInfo(); | 1426 info = webView->textInputInfo(); |
1389 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", | 1427 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", |
1390 std::string(info.value.utf8().data())); | 1428 std::string(info.value.utf8().data())); |
1391 EXPECT_EQ(31, info.selectionStart); | 1429 EXPECT_EQ(31, info.selectionStart); |
1392 EXPECT_EQ(31, info.selectionEnd); | 1430 EXPECT_EQ(31, info.selectionEnd); |
1393 EXPECT_EQ(30, info.compositionStart); | 1431 EXPECT_EQ(30, info.compositionStart); |
1394 EXPECT_EQ(34, info.compositionEnd); | 1432 EXPECT_EQ(34, info.compositionEnd); |
1395 | 1433 |
1396 std::string compositionText("yolo"); | 1434 std::string compositionText("yolo"); |
1397 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); | 1435 activeInputMethodController->commitText( |
| 1436 WebString::fromUTF8(compositionText.c_str()), 0); |
1398 info = webView->textInputInfo(); | 1437 info = webView->textInputInfo(); |
1399 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", | 1438 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", |
1400 std::string(info.value.utf8().data())); | 1439 std::string(info.value.utf8().data())); |
1401 EXPECT_EQ(34, info.selectionStart); | 1440 EXPECT_EQ(34, info.selectionStart); |
1402 EXPECT_EQ(34, info.selectionEnd); | 1441 EXPECT_EQ(34, info.selectionEnd); |
1403 EXPECT_EQ(-1, info.compositionStart); | 1442 EXPECT_EQ(-1, info.compositionStart); |
1404 EXPECT_EQ(-1, info.compositionEnd); | 1443 EXPECT_EQ(-1, info.compositionEnd); |
1405 } | 1444 } |
1406 | 1445 |
1407 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { | 1446 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { |
(...skipping 17 matching lines...) Expand all Loading... |
1425 URLTestHelpers::registerMockedURLFromBaseURL( | 1464 URLTestHelpers::registerMockedURLFromBaseURL( |
1426 WebString::fromUTF8(m_baseURL.c_str()), | 1465 WebString::fromUTF8(m_baseURL.c_str()), |
1427 WebString::fromUTF8("input_field_populated.html")); | 1466 WebString::fromUTF8("input_field_populated.html")); |
1428 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 1467 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
1429 m_baseURL + "input_field_populated.html"); | 1468 m_baseURL + "input_field_populated.html"); |
1430 webView->setInitialFocus(false); | 1469 webView->setInitialFocus(false); |
1431 | 1470 |
1432 std::string compositionTextFirst("hello "); | 1471 std::string compositionTextFirst("hello "); |
1433 std::string compositionTextSecond("world"); | 1472 std::string compositionTextSecond("world"); |
1434 WebVector<WebCompositionUnderline> emptyUnderlines; | 1473 WebVector<WebCompositionUnderline> emptyUnderlines; |
1435 | 1474 WebInputMethodController* activeInputMethodController = |
1436 webView->commitText(WebString::fromUTF8(compositionTextFirst.c_str()), 0); | 1475 webView->mainFrameImpl() |
1437 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), | 1476 ->frameWidget() |
1438 emptyUnderlines, 5, 5); | 1477 ->getActiveWebInputMethodController(); |
| 1478 activeInputMethodController->commitText( |
| 1479 WebString::fromUTF8(compositionTextFirst.c_str()), 0); |
| 1480 activeInputMethodController->setComposition( |
| 1481 WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, |
| 1482 5); |
1439 | 1483 |
1440 WebTextInputInfo info = webView->textInputInfo(); | 1484 WebTextInputInfo info = webView->textInputInfo(); |
1441 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1485 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
1442 EXPECT_EQ(11, info.selectionStart); | 1486 EXPECT_EQ(11, info.selectionStart); |
1443 EXPECT_EQ(11, info.selectionEnd); | 1487 EXPECT_EQ(11, info.selectionEnd); |
1444 EXPECT_EQ(6, info.compositionStart); | 1488 EXPECT_EQ(6, info.compositionStart); |
1445 EXPECT_EQ(11, info.compositionEnd); | 1489 EXPECT_EQ(11, info.compositionEnd); |
1446 | 1490 |
1447 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1491 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
1448 frame->setEditableSelectionOffsets(6, 6); | 1492 frame->setEditableSelectionOffsets(6, 6); |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2666 m_baseURL + "composition_not_cancelled_by_backspace.html"); | 2710 m_baseURL + "composition_not_cancelled_by_backspace.html"); |
2667 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2711 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
2668 frame->setAutofillClient(&client); | 2712 frame->setAutofillClient(&client); |
2669 webView->setInitialFocus(false); | 2713 webView->setInitialFocus(false); |
2670 | 2714 |
2671 // Test both input elements. | 2715 // Test both input elements. |
2672 for (int i = 0; i < 2; ++i) { | 2716 for (int i = 0; i < 2; ++i) { |
2673 // Select composition and do sanity check. | 2717 // Select composition and do sanity check. |
2674 WebVector<WebCompositionUnderline> emptyUnderlines; | 2718 WebVector<WebCompositionUnderline> emptyUnderlines; |
2675 frame->setEditableSelectionOffsets(6, 6); | 2719 frame->setEditableSelectionOffsets(6, 6); |
2676 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); | 2720 WebInputMethodController* activeInputMethodController = |
| 2721 frame->frameWidget()->getActiveWebInputMethodController(); |
| 2722 EXPECT_TRUE(activeInputMethodController->setComposition( |
| 2723 "fghij", emptyUnderlines, 0, 5)); |
2677 frame->setEditableSelectionOffsets(11, 11); | 2724 frame->setEditableSelectionOffsets(11, 11); |
2678 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); | 2725 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); |
2679 | 2726 |
2680 // Press Backspace and verify composition didn't get cancelled. This is to | 2727 // Press Backspace and verify composition didn't get cancelled. This is to |
2681 // verify the fix for crbug.com/429916. | 2728 // verify the fix for crbug.com/429916. |
2682 WebKeyboardEvent keyEvent; | 2729 WebKeyboardEvent keyEvent; |
2683 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); | 2730 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); |
2684 keyEvent.windowsKeyCode = VKEY_BACK; | 2731 keyEvent.windowsKeyCode = VKEY_BACK; |
2685 keyEvent.type = WebInputEvent::RawKeyDown; | 2732 keyEvent.type = WebInputEvent::RawKeyDown; |
2686 webView->handleInputEvent(keyEvent); | 2733 webView->handleInputEvent(keyEvent); |
2687 | 2734 |
2688 frame->setEditableSelectionOffsets(6, 6); | 2735 frame->setEditableSelectionOffsets(6, 6); |
2689 EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4)); | 2736 EXPECT_TRUE(activeInputMethodController->setComposition( |
| 2737 "fghi", emptyUnderlines, 0, 4)); |
2690 frame->setEditableSelectionOffsets(10, 10); | 2738 frame->setEditableSelectionOffsets(10, 10); |
2691 verifySelectionAndComposition(webView, 10, 10, 6, 10, | 2739 verifySelectionAndComposition(webView, 10, 10, 6, 10, |
2692 "after pressing Backspace"); | 2740 "after pressing Backspace"); |
2693 | 2741 |
2694 keyEvent.type = WebInputEvent::KeyUp; | 2742 keyEvent.type = WebInputEvent::KeyUp; |
2695 webView->handleInputEvent(keyEvent); | 2743 webView->handleInputEvent(keyEvent); |
2696 | 2744 |
2697 webView->advanceFocus(false); | 2745 webView->advanceFocus(false); |
2698 } | 2746 } |
2699 | 2747 |
2700 frame->setAutofillClient(0); | 2748 frame->setAutofillClient(0); |
2701 } | 2749 } |
2702 | 2750 |
2703 TEST_P(WebViewTest, FinishComposingTextTriggersAutofillTextChange) { | 2751 TEST_P(WebViewTest, FinishComposingTextTriggersAutofillTextChange) { |
2704 URLTestHelpers::registerMockedURLFromBaseURL( | 2752 URLTestHelpers::registerMockedURLFromBaseURL( |
2705 WebString::fromUTF8(m_baseURL.c_str()), | 2753 WebString::fromUTF8(m_baseURL.c_str()), |
2706 WebString::fromUTF8("input_field_populated.html")); | 2754 WebString::fromUTF8("input_field_populated.html")); |
2707 MockAutofillClient client; | 2755 MockAutofillClient client; |
2708 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 2756 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
2709 m_baseURL + "input_field_populated.html"); | 2757 m_baseURL + "input_field_populated.html"); |
2710 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2758 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
2711 frame->setAutofillClient(&client); | 2759 frame->setAutofillClient(&client); |
2712 webView->setInitialFocus(false); | 2760 webView->setInitialFocus(false); |
2713 | 2761 WebInputMethodController* activeInputMethodController = |
| 2762 frame->frameWidget()->getActiveWebInputMethodController(); |
2714 // Set up a composition that needs to be committed. | 2763 // Set up a composition that needs to be committed. |
2715 std::string compositionText("testingtext"); | 2764 std::string compositionText("testingtext"); |
2716 | 2765 |
2717 WebVector<WebCompositionUnderline> emptyUnderlines; | 2766 WebVector<WebCompositionUnderline> emptyUnderlines; |
2718 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), | 2767 activeInputMethodController->setComposition( |
2719 emptyUnderlines, 0, compositionText.length()); | 2768 WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, |
| 2769 compositionText.length()); |
2720 | 2770 |
2721 WebTextInputInfo info = webView->textInputInfo(); | 2771 WebTextInputInfo info = webView->textInputInfo(); |
2722 EXPECT_EQ(0, info.selectionStart); | 2772 EXPECT_EQ(0, info.selectionStart); |
2723 EXPECT_EQ((int)compositionText.length(), info.selectionEnd); | 2773 EXPECT_EQ((int)compositionText.length(), info.selectionEnd); |
2724 EXPECT_EQ(0, info.compositionStart); | 2774 EXPECT_EQ(0, info.compositionStart); |
2725 EXPECT_EQ((int)compositionText.length(), info.compositionEnd); | 2775 EXPECT_EQ((int)compositionText.length(), info.compositionEnd); |
2726 | 2776 |
2727 client.clearChangeCounts(); | 2777 client.clearChangeCounts(); |
2728 webView->finishComposingText(WebWidget::KeepSelection); | 2778 activeInputMethodController->finishComposingText( |
| 2779 WebInputMethodController::KeepSelection); |
2729 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 2780 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
2730 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); | 2781 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); |
2731 | 2782 |
2732 frame->setAutofillClient(0); | 2783 frame->setAutofillClient(0); |
2733 } | 2784 } |
2734 | 2785 |
2735 TEST_P(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) { | 2786 TEST_P(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) { |
2736 URLTestHelpers::registerMockedURLFromBaseURL( | 2787 URLTestHelpers::registerMockedURLFromBaseURL( |
2737 WebString::fromUTF8(m_baseURL.c_str()), | 2788 WebString::fromUTF8(m_baseURL.c_str()), |
2738 WebString::fromUTF8("input_field_populated.html")); | 2789 WebString::fromUTF8("input_field_populated.html")); |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3470 NonUserInputTextUpdateWebWidgetClient client; | 3521 NonUserInputTextUpdateWebWidgetClient client; |
3471 std::string url = m_baseURL + "non_user_input_text_update.html"; | 3522 std::string url = m_baseURL + "non_user_input_text_update.html"; |
3472 URLTestHelpers::registerMockedURLLoad(toKURL(url), | 3523 URLTestHelpers::registerMockedURLLoad(toKURL(url), |
3473 "non_user_input_text_update.html"); | 3524 "non_user_input_text_update.html"); |
3474 WebViewImpl* webViewImpl = | 3525 WebViewImpl* webViewImpl = |
3475 m_webViewHelper.initializeAndLoad(url, true, nullptr, nullptr, &client); | 3526 m_webViewHelper.initializeAndLoad(url, true, nullptr, nullptr, &client); |
3476 webViewImpl->setInitialFocus(false); | 3527 webViewImpl->setInitialFocus(false); |
3477 | 3528 |
3478 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); | 3529 WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl(); |
3479 Document* document = frame->frame()->document(); | 3530 Document* document = frame->frame()->document(); |
| 3531 WebInputMethodController* activeInputMethodController = |
| 3532 frame->frameWidget()->getActiveWebInputMethodController(); |
3480 | 3533 |
3481 // (A) <input> | 3534 // (A) <input> |
3482 // (A.1) Focused and value is changed by script. | 3535 // (A.1) Focused and value is changed by script. |
3483 client.reset(); | 3536 client.reset(); |
3484 EXPECT_FALSE(client.textIsUpdated()); | 3537 EXPECT_FALSE(client.textIsUpdated()); |
3485 | 3538 |
3486 HTMLInputElement* inputElement = | 3539 HTMLInputElement* inputElement = |
3487 toHTMLInputElement(document->getElementById("input")); | 3540 toHTMLInputElement(document->getElementById("input")); |
3488 document->setFocusedElement( | 3541 document->setFocusedElement( |
3489 inputElement, | 3542 inputElement, |
3490 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); | 3543 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
3491 webViewImpl->setFocus(true); | 3544 webViewImpl->setFocus(true); |
3492 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(inputElement)); | 3545 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(inputElement)); |
3493 | 3546 |
3494 // Emulate value change from script. | 3547 // Emulate value change from script. |
3495 inputElement->setValue("testA"); | 3548 inputElement->setValue("testA"); |
3496 EXPECT_TRUE(client.textIsUpdated()); | 3549 EXPECT_TRUE(client.textIsUpdated()); |
3497 WebTextInputInfo info = webViewImpl->textInputInfo(); | 3550 WebTextInputInfo info = webViewImpl->textInputInfo(); |
3498 EXPECT_EQ("testA", std::string(info.value.utf8().data())); | 3551 EXPECT_EQ("testA", std::string(info.value.utf8().data())); |
3499 | 3552 |
3500 // (A.2) Focused and user input modifies value. | 3553 // (A.2) Focused and user input modifies value. |
3501 client.reset(); | 3554 client.reset(); |
3502 EXPECT_FALSE(client.textIsUpdated()); | 3555 EXPECT_FALSE(client.textIsUpdated()); |
3503 | 3556 |
3504 WebVector<WebCompositionUnderline> emptyUnderlines; | 3557 WebVector<WebCompositionUnderline> emptyUnderlines; |
3505 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1); | 3558 activeInputMethodController->setComposition(WebString::fromUTF8("2"), |
3506 webViewImpl->finishComposingText(WebWidget::KeepSelection); | 3559 emptyUnderlines, 1, 1); |
| 3560 activeInputMethodController->finishComposingText( |
| 3561 WebInputMethodController::KeepSelection); |
3507 EXPECT_FALSE(client.textIsUpdated()); | 3562 EXPECT_FALSE(client.textIsUpdated()); |
3508 info = webViewImpl->textInputInfo(); | 3563 info = webViewImpl->textInputInfo(); |
3509 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); | 3564 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); |
3510 | 3565 |
3511 // (A.3) Unfocused and value is changed by script. | 3566 // (A.3) Unfocused and value is changed by script. |
3512 client.reset(); | 3567 client.reset(); |
3513 EXPECT_FALSE(client.textIsUpdated()); | 3568 EXPECT_FALSE(client.textIsUpdated()); |
3514 document->clearFocusedElement(); | 3569 document->clearFocusedElement(); |
3515 webViewImpl->setFocus(false); | 3570 webViewImpl->setFocus(false); |
3516 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); | 3571 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); |
(...skipping 12 matching lines...) Expand all Loading... |
3529 webViewImpl->setFocus(true); | 3584 webViewImpl->setFocus(true); |
3530 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement)); | 3585 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement)); |
3531 textAreaElement->setValue("testB"); | 3586 textAreaElement->setValue("testB"); |
3532 EXPECT_TRUE(client.textIsUpdated()); | 3587 EXPECT_TRUE(client.textIsUpdated()); |
3533 info = webViewImpl->textInputInfo(); | 3588 info = webViewImpl->textInputInfo(); |
3534 EXPECT_EQ("testB", std::string(info.value.utf8().data())); | 3589 EXPECT_EQ("testB", std::string(info.value.utf8().data())); |
3535 | 3590 |
3536 // (B.2) Focused and user input modifies value. | 3591 // (B.2) Focused and user input modifies value. |
3537 client.reset(); | 3592 client.reset(); |
3538 EXPECT_FALSE(client.textIsUpdated()); | 3593 EXPECT_FALSE(client.textIsUpdated()); |
3539 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1); | 3594 activeInputMethodController->setComposition(WebString::fromUTF8("2"), |
3540 webViewImpl->finishComposingText(WebWidget::KeepSelection); | 3595 emptyUnderlines, 1, 1); |
| 3596 activeInputMethodController->finishComposingText( |
| 3597 WebInputMethodController::KeepSelection); |
3541 info = webViewImpl->textInputInfo(); | 3598 info = webViewImpl->textInputInfo(); |
3542 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); | 3599 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); |
3543 | 3600 |
3544 // (B.3) Unfocused and value is changed by script. | 3601 // (B.3) Unfocused and value is changed by script. |
3545 client.reset(); | 3602 client.reset(); |
3546 EXPECT_FALSE(client.textIsUpdated()); | 3603 EXPECT_FALSE(client.textIsUpdated()); |
3547 document->clearFocusedElement(); | 3604 document->clearFocusedElement(); |
3548 webViewImpl->setFocus(false); | 3605 webViewImpl->setFocus(false); |
3549 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement)); | 3606 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement)); |
3550 inputElement->setValue("testB3"); | 3607 inputElement->setValue("testB3"); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 WebString::fromUTF8(m_baseURL.c_str()), | 3688 WebString::fromUTF8(m_baseURL.c_str()), |
3632 WebString::fromUTF8("input_field_populated.html")); | 3689 WebString::fromUTF8("input_field_populated.html")); |
3633 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 3690 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
3634 m_baseURL + "input_field_populated.html"); | 3691 m_baseURL + "input_field_populated.html"); |
3635 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3692 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
3636 MockAutofillClient client; | 3693 MockAutofillClient client; |
3637 frame->setAutofillClient(&client); | 3694 frame->setAutofillClient(&client); |
3638 webView->setInitialFocus(false); | 3695 webView->setInitialFocus(false); |
3639 | 3696 |
3640 EXPECT_TRUE( | 3697 EXPECT_TRUE( |
3641 webView->setComposition(WebString::fromUTF8(std::string("hello").c_str()), | 3698 frame->frameWidget()->getActiveWebInputMethodController()->setComposition( |
3642 WebVector<WebCompositionUnderline>(), 3, 3)); | 3699 WebString::fromUTF8(std::string("hello").c_str()), |
| 3700 WebVector<WebCompositionUnderline>(), 3, 3)); |
3643 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3701 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
3644 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3702 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
3645 EXPECT_TRUE(frame->hasMarkedText()); | 3703 EXPECT_TRUE(frame->hasMarkedText()); |
3646 | 3704 |
3647 frame->setAutofillClient(0); | 3705 frame->setAutofillClient(0); |
3648 } | 3706 } |
3649 | 3707 |
3650 TEST_P(WebViewTest, CompareSelectAllToContentAsText) { | 3708 TEST_P(WebViewTest, CompareSelectAllToContentAsText) { |
3651 URLTestHelpers::registerMockedURLFromBaseURL( | 3709 URLTestHelpers::registerMockedURLFromBaseURL( |
3652 WebString::fromUTF8(m_baseURL.c_str()), | 3710 WebString::fromUTF8(m_baseURL.c_str()), |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4030 URLTestHelpers::registerMockedURLFromBaseURL( | 4088 URLTestHelpers::registerMockedURLFromBaseURL( |
4031 WebString::fromUTF8(m_baseURL.c_str()), | 4089 WebString::fromUTF8(m_baseURL.c_str()), |
4032 WebString::fromUTF8("input_field_password.html")); | 4090 WebString::fromUTF8("input_field_password.html")); |
4033 MockAutofillClient client; | 4091 MockAutofillClient client; |
4034 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( | 4092 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
4035 m_baseURL + "input_field_password.html", true); | 4093 m_baseURL + "input_field_password.html", true); |
4036 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 4094 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
4037 frame->setAutofillClient(&client); | 4095 frame->setAutofillClient(&client); |
4038 webView->setInitialFocus(false); | 4096 webView->setInitialFocus(false); |
4039 | 4097 |
4040 EXPECT_TRUE(webView->commitText( | 4098 EXPECT_TRUE( |
4041 WebString::fromUTF8(std::string("hello").c_str()), 0)); | 4099 frame->frameWidget()->getActiveWebInputMethodController()->commitText( |
| 4100 WebString::fromUTF8(std::string("hello").c_str()), 0)); |
4042 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 4101 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
4043 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 4102 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
4044 frame->setAutofillClient(0); | 4103 frame->setAutofillClient(0); |
4045 } | 4104 } |
4046 | 4105 |
4047 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the | 4106 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the |
4048 // stack defers its loads. | 4107 // stack defers its loads. |
4049 TEST_P(WebViewTest, CreatedDuringLoadDeferral) { | 4108 TEST_P(WebViewTest, CreatedDuringLoadDeferral) { |
4050 { | 4109 { |
4051 WebViewImpl* webView = m_webViewHelper.initialize(); | 4110 WebViewImpl* webView = m_webViewHelper.initialize(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 .translate(50, 55) | 4316 .translate(50, 55) |
4258 .scale(1. / 2.f); | 4317 .scale(1. / 2.f); |
4259 EXPECT_EQ(expectedMatrix, | 4318 EXPECT_EQ(expectedMatrix, |
4260 webViewImpl->getDeviceEmulationTransformForTesting()); | 4319 webViewImpl->getDeviceEmulationTransformForTesting()); |
4261 // visibleContentRect doesn't change. | 4320 // visibleContentRect doesn't change. |
4262 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4321 EXPECT_EQ(IntRect(50, 55, 50, 75), |
4263 *devToolsEmulator->visibleContentRectForPainting()); | 4322 *devToolsEmulator->visibleContentRectForPainting()); |
4264 } | 4323 } |
4265 | 4324 |
4266 } // namespace blink | 4325 } // namespace blink |
OLD | NEW |