| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 237 |
| 236 void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResi
ze, | 238 void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResi
ze, |
| 237 const std::string& pageWidth, const std::string& pageHei
ght, | 239 const std::string& pageWidth, const std::string& pageHei
ght, |
| 238 int expectedWidth, int expectedHeight, | 240 int expectedWidth, int expectedHeight, |
| 239 HorizontalScrollbarState expectedHorizontalState, Vertic
alScrollbarState expectedVerticalState); | 241 HorizontalScrollbarState expectedHorizontalState, Vertic
alScrollbarState expectedVerticalState); |
| 240 | 242 |
| 241 void testTextInputType(WebTextInputType expectedType, const std::string& htm
lFile); | 243 void testTextInputType(WebTextInputType expectedType, const std::string& htm
lFile); |
| 242 void testInputMode(const WebString& expectedInputMode, const std::string& ht
mlFile); | 244 void testInputMode(const WebString& expectedInputMode, const std::string& ht
mlFile); |
| 243 bool tapElement(WebInputEvent::Type, Element*); | 245 bool tapElement(WebInputEvent::Type, Element*); |
| 244 bool tapElementById(WebInputEvent::Type, const WebString& id); | 246 bool tapElementById(WebInputEvent::Type, const WebString& id); |
| 247 // The WebInputMethodCotnroller corresponding to focused frame (could be nul
lptr). |
| 248 WebInputMethodController* activeInputMethodController() const; |
| 245 | 249 |
| 246 std::string m_baseURL; | 250 std::string m_baseURL; |
| 247 FrameTestHelpers::WebViewHelper m_webViewHelper; | 251 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 248 }; | 252 }; |
| 249 | 253 |
| 250 static bool hitTestIsContentEditable(WebView* view, int x, int y) | 254 static bool hitTestIsContentEditable(WebView* view, int x, int y) |
| 251 { | 255 { |
| 252 WebPoint hitPoint(x, y); | 256 WebPoint hitPoint(x, y); |
| 253 WebHitTestResult hitTestResult = view->hitTestResultAt(hitPoint); | 257 WebHitTestResult hitTestResult = view->hitTestResultAt(hitPoint); |
| 254 return hitTestResult.isContentEditable(); | 258 return hitTestResult.isContentEditable(); |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) | 832 TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) |
| 829 { | 833 { |
| 830 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 834 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 831 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 835 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 832 webView->setInitialFocus(false); | 836 webView->setInitialFocus(false); |
| 833 | 837 |
| 834 // Set up a composition that needs to be committed. | 838 // Set up a composition that needs to be committed. |
| 835 std::string compositionText("hello"); | 839 std::string compositionText("hello"); |
| 836 | 840 |
| 837 WebVector<WebCompositionUnderline> emptyUnderlines; | 841 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 838 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 3, 3); | 842 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, 3, 3); |
| 839 | 843 |
| 840 WebTextInputInfo info = webView->textInputInfo(); | 844 WebTextInputInfo info = webView->textInputInfo(); |
| 841 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 845 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 842 EXPECT_EQ(3, info.selectionStart); | 846 EXPECT_EQ(3, info.selectionStart); |
| 843 EXPECT_EQ(3, info.selectionEnd); | 847 EXPECT_EQ(3, info.selectionEnd); |
| 844 EXPECT_EQ(0, info.compositionStart); | 848 EXPECT_EQ(0, info.compositionStart); |
| 845 EXPECT_EQ(5, info.compositionEnd); | 849 EXPECT_EQ(5, info.compositionEnd); |
| 846 | 850 |
| 847 webView->finishComposingText(WebWidget::KeepSelection); | 851 activeInputMethodController()->finishComposingText(WebInputMethodController:
:KeepSelection); |
| 848 info = webView->textInputInfo(); | 852 info = webView->textInputInfo(); |
| 849 EXPECT_EQ(3, info.selectionStart); | 853 EXPECT_EQ(3, info.selectionStart); |
| 850 EXPECT_EQ(3, info.selectionEnd); | 854 EXPECT_EQ(3, info.selectionEnd); |
| 851 EXPECT_EQ(-1, info.compositionStart); | 855 EXPECT_EQ(-1, info.compositionStart); |
| 852 EXPECT_EQ(-1, info.compositionEnd); | 856 EXPECT_EQ(-1, info.compositionEnd); |
| 853 | 857 |
| 854 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 3, 3); | 858 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, 3, 3); |
| 855 info = webView->textInputInfo(); | 859 info = webView->textInputInfo(); |
| 856 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); | 860 EXPECT_EQ("helhellolo", std::string(info.value.utf8().data())); |
| 857 EXPECT_EQ(6, info.selectionStart); | 861 EXPECT_EQ(6, info.selectionStart); |
| 858 EXPECT_EQ(6, info.selectionEnd); | 862 EXPECT_EQ(6, info.selectionEnd); |
| 859 EXPECT_EQ(3, info.compositionStart); | 863 EXPECT_EQ(3, info.compositionStart); |
| 860 EXPECT_EQ(8, info.compositionEnd); | 864 EXPECT_EQ(8, info.compositionEnd); |
| 861 | 865 |
| 862 webView->finishComposingText(WebWidget::DoNotKeepSelection); | 866 activeInputMethodController()->finishComposingText(WebInputMethodController:
:DoNotKeepSelection); |
| 863 info = webView->textInputInfo(); | 867 info = webView->textInputInfo(); |
| 864 EXPECT_EQ(8, info.selectionStart); | 868 EXPECT_EQ(8, info.selectionStart); |
| 865 EXPECT_EQ(8, info.selectionEnd); | 869 EXPECT_EQ(8, info.selectionEnd); |
| 866 EXPECT_EQ(-1, info.compositionStart); | 870 EXPECT_EQ(-1, info.compositionStart); |
| 867 EXPECT_EQ(-1, info.compositionEnd); | 871 EXPECT_EQ(-1, info.compositionEnd); |
| 868 } | 872 } |
| 869 | 873 |
| 870 TEST_F(WebViewTest, SetCompositionForNewCaretPositions) | 874 TEST_F(WebViewTest, SetCompositionForNewCaretPositions) |
| 871 { | 875 { |
| 872 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 876 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 873 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 877 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 874 webView->setInitialFocus(false); | 878 webView->setInitialFocus(false); |
| 875 | 879 |
| 876 webView->commitText("hello", 0); | 880 activeInputMethodController()->commitText("hello", 0); |
| 877 webView->commitText("world", -5); | 881 activeInputMethodController()->commitText("world", -5); |
| 878 WebTextInputInfo info = webView->textInputInfo(); | 882 WebTextInputInfo info = webView->textInputInfo(); |
| 879 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 883 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 880 EXPECT_EQ(5, info.selectionStart); | 884 EXPECT_EQ(5, info.selectionStart); |
| 881 EXPECT_EQ(5, info.selectionEnd); | 885 EXPECT_EQ(5, info.selectionEnd); |
| 882 EXPECT_EQ(-1, info.compositionStart); | 886 EXPECT_EQ(-1, info.compositionStart); |
| 883 EXPECT_EQ(-1, info.compositionEnd); | 887 EXPECT_EQ(-1, info.compositionEnd); |
| 884 | 888 |
| 885 WebVector<WebCompositionUnderline> emptyUnderlines; | 889 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 886 // Set up a composition that needs to be committed. | 890 // Set up a composition that needs to be committed. |
| 887 std::string compositionText("ABC"); | 891 std::string compositionText("ABC"); |
| 888 | 892 |
| 889 // Caret is on the left of composing text. | 893 // Caret is on the left of composing text. |
| 890 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 0, 0); | 894 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, 0, 0); |
| 891 info = webView->textInputInfo(); | 895 info = webView->textInputInfo(); |
| 892 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 896 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 893 EXPECT_EQ(5, info.selectionStart); | 897 EXPECT_EQ(5, info.selectionStart); |
| 894 EXPECT_EQ(5, info.selectionEnd); | 898 EXPECT_EQ(5, info.selectionEnd); |
| 895 EXPECT_EQ(5, info.compositionStart); | 899 EXPECT_EQ(5, info.compositionStart); |
| 896 EXPECT_EQ(8, info.compositionEnd); | 900 EXPECT_EQ(8, info.compositionEnd); |
| 897 | 901 |
| 898 // Caret is on the right of composing text. | 902 // Caret is on the right of composing text. |
| 899 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 3, 3); | 903 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, 3, 3); |
| 900 info = webView->textInputInfo(); | 904 info = webView->textInputInfo(); |
| 901 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 905 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 902 EXPECT_EQ(8, info.selectionStart); | 906 EXPECT_EQ(8, info.selectionStart); |
| 903 EXPECT_EQ(8, info.selectionEnd); | 907 EXPECT_EQ(8, info.selectionEnd); |
| 904 EXPECT_EQ(5, info.compositionStart); | 908 EXPECT_EQ(5, info.compositionStart); |
| 905 EXPECT_EQ(8, info.compositionEnd); | 909 EXPECT_EQ(8, info.compositionEnd); |
| 906 | 910 |
| 907 // Caret is between composing text and left boundary. | 911 // Caret is between composing text and left boundary. |
| 908 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, -2, -2); | 912 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, -2, -2); |
| 909 info = webView->textInputInfo(); | 913 info = webView->textInputInfo(); |
| 910 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 914 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 911 EXPECT_EQ(3, info.selectionStart); | 915 EXPECT_EQ(3, info.selectionStart); |
| 912 EXPECT_EQ(3, info.selectionEnd); | 916 EXPECT_EQ(3, info.selectionEnd); |
| 913 EXPECT_EQ(5, info.compositionStart); | 917 EXPECT_EQ(5, info.compositionStart); |
| 914 EXPECT_EQ(8, info.compositionEnd); | 918 EXPECT_EQ(8, info.compositionEnd); |
| 915 | 919 |
| 916 // Caret is between composing text and right boundary. | 920 // Caret is between composing text and right boundary. |
| 917 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 5, 5); | 921 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, 5, 5); |
| 918 info = webView->textInputInfo(); | 922 info = webView->textInputInfo(); |
| 919 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 923 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 920 EXPECT_EQ(10, info.selectionStart); | 924 EXPECT_EQ(10, info.selectionStart); |
| 921 EXPECT_EQ(10, info.selectionEnd); | 925 EXPECT_EQ(10, info.selectionEnd); |
| 922 EXPECT_EQ(5, info.compositionStart); | 926 EXPECT_EQ(5, info.compositionStart); |
| 923 EXPECT_EQ(8, info.compositionEnd); | 927 EXPECT_EQ(8, info.compositionEnd); |
| 924 | 928 |
| 925 // Caret is on the left boundary. | 929 // Caret is on the left boundary. |
| 926 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, -5, -5); | 930 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, -5, -5); |
| 927 info = webView->textInputInfo(); | 931 info = webView->textInputInfo(); |
| 928 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 932 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 929 EXPECT_EQ(0, info.selectionStart); | 933 EXPECT_EQ(0, info.selectionStart); |
| 930 EXPECT_EQ(0, info.selectionEnd); | 934 EXPECT_EQ(0, info.selectionEnd); |
| 931 EXPECT_EQ(5, info.compositionStart); | 935 EXPECT_EQ(5, info.compositionStart); |
| 932 EXPECT_EQ(8, info.compositionEnd); | 936 EXPECT_EQ(8, info.compositionEnd); |
| 933 | 937 |
| 934 // Caret is on the right boundary. | 938 // Caret is on the right boundary. |
| 935 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 8, 8); | 939 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, 8, 8); |
| 936 info = webView->textInputInfo(); | 940 info = webView->textInputInfo(); |
| 937 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 941 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 938 EXPECT_EQ(13, info.selectionStart); | 942 EXPECT_EQ(13, info.selectionStart); |
| 939 EXPECT_EQ(13, info.selectionEnd); | 943 EXPECT_EQ(13, info.selectionEnd); |
| 940 EXPECT_EQ(5, info.compositionStart); | 944 EXPECT_EQ(5, info.compositionStart); |
| 941 EXPECT_EQ(8, info.compositionEnd); | 945 EXPECT_EQ(8, info.compositionEnd); |
| 942 | 946 |
| 943 // Caret exceeds the left boundary. | 947 // Caret exceeds the left boundary. |
| 944 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, -100, -100); | 948 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, -100, -100); |
| 945 info = webView->textInputInfo(); | 949 info = webView->textInputInfo(); |
| 946 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 950 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 947 EXPECT_EQ(0, info.selectionStart); | 951 EXPECT_EQ(0, info.selectionStart); |
| 948 EXPECT_EQ(0, info.selectionEnd); | 952 EXPECT_EQ(0, info.selectionEnd); |
| 949 EXPECT_EQ(5, info.compositionStart); | 953 EXPECT_EQ(5, info.compositionStart); |
| 950 EXPECT_EQ(8, info.compositionEnd); | 954 EXPECT_EQ(8, info.compositionEnd); |
| 951 | 955 |
| 952 // Caret exceeds the right boundary. | 956 // Caret exceeds the right boundary. |
| 953 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 100, 100); | 957 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, 100, 100); |
| 954 info = webView->textInputInfo(); | 958 info = webView->textInputInfo(); |
| 955 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); | 959 EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data())); |
| 956 EXPECT_EQ(13, info.selectionStart); | 960 EXPECT_EQ(13, info.selectionStart); |
| 957 EXPECT_EQ(13, info.selectionEnd); | 961 EXPECT_EQ(13, info.selectionEnd); |
| 958 EXPECT_EQ(5, info.compositionStart); | 962 EXPECT_EQ(5, info.compositionStart); |
| 959 EXPECT_EQ(8, info.compositionEnd); | 963 EXPECT_EQ(8, info.compositionEnd); |
| 960 } | 964 } |
| 961 | 965 |
| 962 TEST_F(WebViewTest, SetCompositionWithEmptyText) | 966 TEST_F(WebViewTest, SetCompositionWithEmptyText) |
| 963 { | 967 { |
| 964 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 968 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 965 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 969 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 966 webView->setInitialFocus(false); | 970 webView->setInitialFocus(false); |
| 967 | 971 |
| 968 webView->commitText("hello", 0); | 972 activeInputMethodController()->commitText("hello", 0); |
| 969 WebTextInputInfo info = webView->textInputInfo(); | 973 WebTextInputInfo info = webView->textInputInfo(); |
| 970 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 974 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 971 EXPECT_EQ(5, info.selectionStart); | 975 EXPECT_EQ(5, info.selectionStart); |
| 972 EXPECT_EQ(5, info.selectionEnd); | 976 EXPECT_EQ(5, info.selectionEnd); |
| 973 EXPECT_EQ(-1, info.compositionStart); | 977 EXPECT_EQ(-1, info.compositionStart); |
| 974 EXPECT_EQ(-1, info.compositionEnd); | 978 EXPECT_EQ(-1, info.compositionEnd); |
| 975 | 979 |
| 976 WebVector<WebCompositionUnderline> emptyUnderlines; | 980 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 977 | 981 |
| 978 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, 0, 0); | 982 activeInputMethodController()->setComposition(WebString::fromUTF8(""), empty
Underlines, 0, 0); |
| 979 info = webView->textInputInfo(); | 983 info = webView->textInputInfo(); |
| 980 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 984 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 981 EXPECT_EQ(5, info.selectionStart); | 985 EXPECT_EQ(5, info.selectionStart); |
| 982 EXPECT_EQ(5, info.selectionEnd); | 986 EXPECT_EQ(5, info.selectionEnd); |
| 983 EXPECT_EQ(-1, info.compositionStart); | 987 EXPECT_EQ(-1, info.compositionStart); |
| 984 EXPECT_EQ(-1, info.compositionEnd); | 988 EXPECT_EQ(-1, info.compositionEnd); |
| 985 | 989 |
| 986 webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, -2, -2); | 990 activeInputMethodController()->setComposition(WebString::fromUTF8(""), empty
Underlines, -2, -2); |
| 987 info = webView->textInputInfo(); | 991 info = webView->textInputInfo(); |
| 988 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 992 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 989 EXPECT_EQ(3, info.selectionStart); | 993 EXPECT_EQ(3, info.selectionStart); |
| 990 EXPECT_EQ(3, info.selectionEnd); | 994 EXPECT_EQ(3, info.selectionEnd); |
| 991 EXPECT_EQ(-1, info.compositionStart); | 995 EXPECT_EQ(-1, info.compositionStart); |
| 992 EXPECT_EQ(-1, info.compositionEnd); | 996 EXPECT_EQ(-1, info.compositionEnd); |
| 993 } | 997 } |
| 994 | 998 |
| 995 TEST_F(WebViewTest, CommitTextForNewCaretPositions) | 999 TEST_F(WebViewTest, CommitTextForNewCaretPositions) |
| 996 { | 1000 { |
| 997 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1001 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 998 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 1002 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 999 webView->setInitialFocus(false); | 1003 webView->setInitialFocus(false); |
| 1000 | 1004 |
| 1001 // Caret is on the left of composing text. | 1005 // Caret is on the left of composing text. |
| 1002 webView->commitText("ab", -2); | 1006 activeInputMethodController()->commitText("ab", -2); |
| 1003 WebTextInputInfo info = webView->textInputInfo(); | 1007 WebTextInputInfo info = webView->textInputInfo(); |
| 1004 EXPECT_EQ("ab", std::string(info.value.utf8().data())); | 1008 EXPECT_EQ("ab", std::string(info.value.utf8().data())); |
| 1005 EXPECT_EQ(0, info.selectionStart); | 1009 EXPECT_EQ(0, info.selectionStart); |
| 1006 EXPECT_EQ(0, info.selectionEnd); | 1010 EXPECT_EQ(0, info.selectionEnd); |
| 1007 EXPECT_EQ(-1, info.compositionStart); | 1011 EXPECT_EQ(-1, info.compositionStart); |
| 1008 EXPECT_EQ(-1, info.compositionEnd); | 1012 EXPECT_EQ(-1, info.compositionEnd); |
| 1009 | 1013 |
| 1010 // Caret is on the right of composing text. | 1014 // Caret is on the right of composing text. |
| 1011 webView->commitText("c", 1); | 1015 activeInputMethodController()->commitText("c", 1); |
| 1012 info = webView->textInputInfo(); | 1016 info = webView->textInputInfo(); |
| 1013 EXPECT_EQ("cab", std::string(info.value.utf8().data())); | 1017 EXPECT_EQ("cab", std::string(info.value.utf8().data())); |
| 1014 EXPECT_EQ(2, info.selectionStart); | 1018 EXPECT_EQ(2, info.selectionStart); |
| 1015 EXPECT_EQ(2, info.selectionEnd); | 1019 EXPECT_EQ(2, info.selectionEnd); |
| 1016 EXPECT_EQ(-1, info.compositionStart); | 1020 EXPECT_EQ(-1, info.compositionStart); |
| 1017 EXPECT_EQ(-1, info.compositionEnd); | 1021 EXPECT_EQ(-1, info.compositionEnd); |
| 1018 | 1022 |
| 1019 // Caret is on the left boundary. | 1023 // Caret is on the left boundary. |
| 1020 webView->commitText("def", -5); | 1024 activeInputMethodController()->commitText("def", -5); |
| 1021 info = webView->textInputInfo(); | 1025 info = webView->textInputInfo(); |
| 1022 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); | 1026 EXPECT_EQ("cadefb", std::string(info.value.utf8().data())); |
| 1023 EXPECT_EQ(0, info.selectionStart); | 1027 EXPECT_EQ(0, info.selectionStart); |
| 1024 EXPECT_EQ(0, info.selectionEnd); | 1028 EXPECT_EQ(0, info.selectionEnd); |
| 1025 EXPECT_EQ(-1, info.compositionStart); | 1029 EXPECT_EQ(-1, info.compositionStart); |
| 1026 EXPECT_EQ(-1, info.compositionEnd); | 1030 EXPECT_EQ(-1, info.compositionEnd); |
| 1027 | 1031 |
| 1028 // Caret is on the right boundary. | 1032 // Caret is on the right boundary. |
| 1029 webView->commitText("g", 6); | 1033 activeInputMethodController()->commitText("g", 6); |
| 1030 info = webView->textInputInfo(); | 1034 info = webView->textInputInfo(); |
| 1031 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); | 1035 EXPECT_EQ("gcadefb", std::string(info.value.utf8().data())); |
| 1032 EXPECT_EQ(7, info.selectionStart); | 1036 EXPECT_EQ(7, info.selectionStart); |
| 1033 EXPECT_EQ(7, info.selectionEnd); | 1037 EXPECT_EQ(7, info.selectionEnd); |
| 1034 EXPECT_EQ(-1, info.compositionStart); | 1038 EXPECT_EQ(-1, info.compositionStart); |
| 1035 EXPECT_EQ(-1, info.compositionEnd); | 1039 EXPECT_EQ(-1, info.compositionEnd); |
| 1036 | 1040 |
| 1037 // Caret exceeds the left boundary. | 1041 // Caret exceeds the left boundary. |
| 1038 webView->commitText("hi", -100); | 1042 activeInputMethodController()->commitText("hi", -100); |
| 1039 info = webView->textInputInfo(); | 1043 info = webView->textInputInfo(); |
| 1040 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); | 1044 EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data())); |
| 1041 EXPECT_EQ(0, info.selectionStart); | 1045 EXPECT_EQ(0, info.selectionStart); |
| 1042 EXPECT_EQ(0, info.selectionEnd); | 1046 EXPECT_EQ(0, info.selectionEnd); |
| 1043 EXPECT_EQ(-1, info.compositionStart); | 1047 EXPECT_EQ(-1, info.compositionStart); |
| 1044 EXPECT_EQ(-1, info.compositionEnd); | 1048 EXPECT_EQ(-1, info.compositionEnd); |
| 1045 | 1049 |
| 1046 // Caret exceeds the right boundary. | 1050 // Caret exceeds the right boundary. |
| 1047 webView->commitText("jk", 100); | 1051 activeInputMethodController()->commitText("jk", 100); |
| 1048 info = webView->textInputInfo(); | 1052 info = webView->textInputInfo(); |
| 1049 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); | 1053 EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data())); |
| 1050 EXPECT_EQ(11, info.selectionStart); | 1054 EXPECT_EQ(11, info.selectionStart); |
| 1051 EXPECT_EQ(11, info.selectionEnd); | 1055 EXPECT_EQ(11, info.selectionEnd); |
| 1052 EXPECT_EQ(-1, info.compositionStart); | 1056 EXPECT_EQ(-1, info.compositionStart); |
| 1053 EXPECT_EQ(-1, info.compositionEnd); | 1057 EXPECT_EQ(-1, info.compositionEnd); |
| 1054 } | 1058 } |
| 1055 | 1059 |
| 1056 TEST_F(WebViewTest, CommitTextWhileComposing) | 1060 TEST_F(WebViewTest, CommitTextWhileComposing) |
| 1057 { | 1061 { |
| 1058 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1062 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 1059 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 1063 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 1060 webView->setInitialFocus(false); | 1064 webView->setInitialFocus(false); |
| 1061 | 1065 |
| 1062 WebVector<WebCompositionUnderline> emptyUnderlines; | 1066 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1063 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); | 1067 activeInputMethodController()->setComposition(WebString::fromUTF8("abc"), em
ptyUnderlines, 0, 0); |
| 1064 WebTextInputInfo info = webView->textInputInfo(); | 1068 WebTextInputInfo info = webView->textInputInfo(); |
| 1065 EXPECT_EQ("abc", std::string(info.value.utf8().data())); | 1069 EXPECT_EQ("abc", std::string(info.value.utf8().data())); |
| 1066 EXPECT_EQ(0, info.selectionStart); | 1070 EXPECT_EQ(0, info.selectionStart); |
| 1067 EXPECT_EQ(0, info.selectionEnd); | 1071 EXPECT_EQ(0, info.selectionEnd); |
| 1068 EXPECT_EQ(0, info.compositionStart); | 1072 EXPECT_EQ(0, info.compositionStart); |
| 1069 EXPECT_EQ(3, info.compositionEnd); | 1073 EXPECT_EQ(3, info.compositionEnd); |
| 1070 | 1074 |
| 1071 // Deletes ongoing composition, inserts the specified text and moves the | 1075 // Deletes ongoing composition, inserts the specified text and moves the |
| 1072 // caret. | 1076 // caret. |
| 1073 webView->commitText("hello", -2); | 1077 activeInputMethodController()->commitText("hello", -2); |
| 1074 info = webView->textInputInfo(); | 1078 info = webView->textInputInfo(); |
| 1075 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1079 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1076 EXPECT_EQ(3, info.selectionStart); | 1080 EXPECT_EQ(3, info.selectionStart); |
| 1077 EXPECT_EQ(3, info.selectionEnd); | 1081 EXPECT_EQ(3, info.selectionEnd); |
| 1078 EXPECT_EQ(-1, info.compositionStart); | 1082 EXPECT_EQ(-1, info.compositionStart); |
| 1079 EXPECT_EQ(-1, info.compositionEnd); | 1083 EXPECT_EQ(-1, info.compositionEnd); |
| 1080 | 1084 |
| 1081 webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0); | 1085 activeInputMethodController()->setComposition(WebString::fromUTF8("abc"), em
ptyUnderlines, 0, 0); |
| 1082 info = webView->textInputInfo(); | 1086 info = webView->textInputInfo(); |
| 1083 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); | 1087 EXPECT_EQ("helabclo", std::string(info.value.utf8().data())); |
| 1084 EXPECT_EQ(3, info.selectionStart); | 1088 EXPECT_EQ(3, info.selectionStart); |
| 1085 EXPECT_EQ(3, info.selectionEnd); | 1089 EXPECT_EQ(3, info.selectionEnd); |
| 1086 EXPECT_EQ(3, info.compositionStart); | 1090 EXPECT_EQ(3, info.compositionStart); |
| 1087 EXPECT_EQ(6, info.compositionEnd); | 1091 EXPECT_EQ(6, info.compositionEnd); |
| 1088 | 1092 |
| 1089 // Deletes ongoing composition and moves the caret. | 1093 // Deletes ongoing composition and moves the caret. |
| 1090 webView->commitText("", 2); | 1094 activeInputMethodController()->commitText("", 2); |
| 1091 info = webView->textInputInfo(); | 1095 info = webView->textInputInfo(); |
| 1092 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1096 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1093 EXPECT_EQ(5, info.selectionStart); | 1097 EXPECT_EQ(5, info.selectionStart); |
| 1094 EXPECT_EQ(5, info.selectionEnd); | 1098 EXPECT_EQ(5, info.selectionEnd); |
| 1095 EXPECT_EQ(-1, info.compositionStart); | 1099 EXPECT_EQ(-1, info.compositionStart); |
| 1096 EXPECT_EQ(-1, info.compositionEnd); | 1100 EXPECT_EQ(-1, info.compositionEnd); |
| 1097 | 1101 |
| 1098 // Inserts the specified text and moves the caret. | 1102 // Inserts the specified text and moves the caret. |
| 1099 webView->commitText("world", -5); | 1103 activeInputMethodController()->commitText("world", -5); |
| 1100 info = webView->textInputInfo(); | 1104 info = webView->textInputInfo(); |
| 1101 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1105 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 1102 EXPECT_EQ(5, info.selectionStart); | 1106 EXPECT_EQ(5, info.selectionStart); |
| 1103 EXPECT_EQ(5, info.selectionEnd); | 1107 EXPECT_EQ(5, info.selectionEnd); |
| 1104 EXPECT_EQ(-1, info.compositionStart); | 1108 EXPECT_EQ(-1, info.compositionStart); |
| 1105 EXPECT_EQ(-1, info.compositionEnd); | 1109 EXPECT_EQ(-1, info.compositionEnd); |
| 1106 | 1110 |
| 1107 // Only moves the caret. | 1111 // Only moves the caret. |
| 1108 webView->commitText("", 5); | 1112 activeInputMethodController()->commitText("", 5); |
| 1109 info = webView->textInputInfo(); | 1113 info = webView->textInputInfo(); |
| 1110 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); | 1114 EXPECT_EQ("helloworld", std::string(info.value.utf8().data())); |
| 1111 EXPECT_EQ(10, info.selectionStart); | 1115 EXPECT_EQ(10, info.selectionStart); |
| 1112 EXPECT_EQ(10, info.selectionEnd); | 1116 EXPECT_EQ(10, info.selectionEnd); |
| 1113 EXPECT_EQ(-1, info.compositionStart); | 1117 EXPECT_EQ(-1, info.compositionStart); |
| 1114 EXPECT_EQ(-1, info.compositionEnd); | 1118 EXPECT_EQ(-1, info.compositionEnd); |
| 1115 } | 1119 } |
| 1116 | 1120 |
| 1117 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) | 1121 TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) |
| 1118 { | 1122 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1132 Element* element = static_cast<Element*>(webView->mainFrame()->document().ge
tElementById("btn")); | 1136 Element* element = static_cast<Element*>(webView->mainFrame()->document().ge
tElementById("btn")); |
| 1133 element->scrollIntoView(); | 1137 element->scrollIntoView(); |
| 1134 float offsetHeight = webView->mainFrame()->scrollOffset().height; | 1138 float offsetHeight = webView->mainFrame()->scrollOffset().height; |
| 1135 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1139 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 1136 EXPECT_LT(0, offsetHeight); | 1140 EXPECT_LT(0, offsetHeight); |
| 1137 | 1141 |
| 1138 WebTextInputInfo info = webView->textInputInfo(); | 1142 WebTextInputInfo info = webView->textInputInfo(); |
| 1139 EXPECT_EQ("hello", std::string(info.value.utf8().data())); | 1143 EXPECT_EQ("hello", std::string(info.value.utf8().data())); |
| 1140 | 1144 |
| 1141 // Verify that the input field is not scrolled back into the viewport. | 1145 // Verify that the input field is not scrolled back into the viewport. |
| 1142 webView->finishComposingText(WebWidget::DoNotKeepSelection); | 1146 activeInputMethodController()->finishComposingText(WebInputMethodController:
:DoNotKeepSelection); |
| 1143 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); | 1147 EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width); |
| 1144 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); | 1148 EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height); |
| 1145 } | 1149 } |
| 1146 | 1150 |
| 1147 TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) | 1151 TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) |
| 1148 { | 1152 { |
| 1149 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 1153 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 1150 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); | 1154 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); |
| 1151 webView->setInitialFocus(false); | 1155 webView->setInitialFocus(false); |
| 1152 | 1156 |
| 1153 WebVector<WebCompositionUnderline> emptyUnderlines; | 1157 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1154 | 1158 |
| 1155 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1159 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1156 frame->setEditableSelectionOffsets(4, 4); | 1160 frame->setEditableSelectionOffsets(4, 4); |
| 1157 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); | 1161 frame->setCompositionFromExistingText(8, 12, emptyUnderlines); |
| 1158 | 1162 |
| 1159 WebTextInputInfo info = webView->textInputInfo(); | 1163 WebTextInputInfo info = webView->textInputInfo(); |
| 1160 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); | 1164 EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.utf
8().data())); |
| 1161 EXPECT_EQ(4, info.selectionStart); | 1165 EXPECT_EQ(4, info.selectionStart); |
| 1162 EXPECT_EQ(4, info.selectionEnd); | 1166 EXPECT_EQ(4, info.selectionEnd); |
| 1163 EXPECT_EQ(8, info.compositionStart); | 1167 EXPECT_EQ(8, info.compositionStart); |
| 1164 EXPECT_EQ(12, info.compositionEnd); | 1168 EXPECT_EQ(12, info.compositionEnd); |
| 1165 | 1169 |
| 1166 webView->finishComposingText(WebWidget::KeepSelection); | 1170 activeInputMethodController()->finishComposingText(WebInputMethodController:
:KeepSelection); |
| 1167 info = webView->textInputInfo(); | 1171 info = webView->textInputInfo(); |
| 1168 EXPECT_EQ(4, info.selectionStart); | 1172 EXPECT_EQ(4, info.selectionStart); |
| 1169 EXPECT_EQ(4, info.selectionEnd); | 1173 EXPECT_EQ(4, info.selectionEnd); |
| 1170 EXPECT_EQ(-1, info.compositionStart); | 1174 EXPECT_EQ(-1, info.compositionStart); |
| 1171 EXPECT_EQ(-1, info.compositionEnd); | 1175 EXPECT_EQ(-1, info.compositionEnd); |
| 1172 | 1176 |
| 1173 std::string compositionText("\n"); | 1177 std::string compositionText("\n"); |
| 1174 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); | 1178 activeInputMethodController()->commitText(WebString::fromUTF8(compositionTex
t.c_str()), 0); |
| 1175 info = webView->textInputInfo(); | 1179 info = webView->textInputInfo(); |
| 1176 EXPECT_EQ(5, info.selectionStart); | 1180 EXPECT_EQ(5, info.selectionStart); |
| 1177 EXPECT_EQ(5, info.selectionEnd); | 1181 EXPECT_EQ(5, info.selectionEnd); |
| 1178 EXPECT_EQ(-1, info.compositionStart); | 1182 EXPECT_EQ(-1, info.compositionStart); |
| 1179 EXPECT_EQ(-1, info.compositionEnd); | 1183 EXPECT_EQ(-1, info.compositionEnd); |
| 1180 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); | 1184 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 1181 } | 1185 } |
| 1182 | 1186 |
| 1183 TEST_F(WebViewTest, ExtendSelectionAndDelete) | 1187 TEST_F(WebViewTest, ExtendSelectionAndDelete) |
| 1184 { | 1188 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 1228 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
| 1225 { | 1229 { |
| 1226 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 1230 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 1227 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); | 1231 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); |
| 1228 webView->setInitialFocus(false); | 1232 webView->setInitialFocus(false); |
| 1229 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1233 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 1230 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1234 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 1231 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1235 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1232 frame->setEditableSelectionOffsets(27, 27); | 1236 frame->setEditableSelectionOffsets(27, 27); |
| 1233 std::string newLineText("\n"); | 1237 std::string newLineText("\n"); |
| 1234 webView->commitText(WebString::fromUTF8(newLineText.c_str()), 0); | 1238 activeInputMethodController()->commitText(WebString::fromUTF8(newLineText.c_
str()), 0); |
| 1235 WebTextInputInfo info = webView->textInputInfo(); | 1239 WebTextInputInfo info = webView->textInputInfo(); |
| 1236 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 1240 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 1237 | 1241 |
| 1238 frame->setEditableSelectionOffsets(31, 31); | 1242 frame->setEditableSelectionOffsets(31, 31); |
| 1239 frame->setCompositionFromExistingText(30, 34, underlines); | 1243 frame->setCompositionFromExistingText(30, 34, underlines); |
| 1240 info = webView->textInputInfo(); | 1244 info = webView->textInputInfo(); |
| 1241 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 1245 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 1242 EXPECT_EQ(31, info.selectionStart); | 1246 EXPECT_EQ(31, info.selectionStart); |
| 1243 EXPECT_EQ(31, info.selectionEnd); | 1247 EXPECT_EQ(31, info.selectionEnd); |
| 1244 EXPECT_EQ(30, info.compositionStart); | 1248 EXPECT_EQ(30, info.compositionStart); |
| 1245 EXPECT_EQ(34, info.compositionEnd); | 1249 EXPECT_EQ(34, info.compositionEnd); |
| 1246 | 1250 |
| 1247 std::string compositionText("yolo"); | 1251 std::string compositionText("yolo"); |
| 1248 webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0); | 1252 activeInputMethodController()->commitText(WebString::fromUTF8(compositionTex
t.c_str()), 0); |
| 1249 info = webView->textInputInfo(); | 1253 info = webView->textInputInfo(); |
| 1250 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); | 1254 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); |
| 1251 EXPECT_EQ(34, info.selectionStart); | 1255 EXPECT_EQ(34, info.selectionStart); |
| 1252 EXPECT_EQ(34, info.selectionEnd); | 1256 EXPECT_EQ(34, info.selectionEnd); |
| 1253 EXPECT_EQ(-1, info.compositionStart); | 1257 EXPECT_EQ(-1, info.compositionStart); |
| 1254 EXPECT_EQ(-1, info.compositionEnd); | 1258 EXPECT_EQ(-1, info.compositionEnd); |
| 1255 } | 1259 } |
| 1256 | 1260 |
| 1257 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) | 1261 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) |
| 1258 { | 1262 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1272 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) | 1276 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) |
| 1273 { | 1277 { |
| 1274 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 1278 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 1275 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); | 1279 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 1276 webView->setInitialFocus(false); | 1280 webView->setInitialFocus(false); |
| 1277 | 1281 |
| 1278 std::string compositionTextFirst("hello "); | 1282 std::string compositionTextFirst("hello "); |
| 1279 std::string compositionTextSecond("world"); | 1283 std::string compositionTextSecond("world"); |
| 1280 WebVector<WebCompositionUnderline> emptyUnderlines; | 1284 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1281 | 1285 |
| 1282 webView->commitText(WebString::fromUTF8(compositionTextFirst.c_str()), 0); | 1286 activeInputMethodController()->commitText(WebString::fromUTF8(compositionTex
tFirst.c_str()), 0); |
| 1283 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); | 1287 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nTextSecond.c_str()), emptyUnderlines, 5, 5); |
| 1284 | 1288 |
| 1285 WebTextInputInfo info = webView->textInputInfo(); | 1289 WebTextInputInfo info = webView->textInputInfo(); |
| 1286 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1290 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1287 EXPECT_EQ(11, info.selectionStart); | 1291 EXPECT_EQ(11, info.selectionStart); |
| 1288 EXPECT_EQ(11, info.selectionEnd); | 1292 EXPECT_EQ(11, info.selectionEnd); |
| 1289 EXPECT_EQ(6, info.compositionStart); | 1293 EXPECT_EQ(6, info.compositionStart); |
| 1290 EXPECT_EQ(11, info.compositionEnd); | 1294 EXPECT_EQ(11, info.compositionEnd); |
| 1291 | 1295 |
| 1292 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1296 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 1293 frame->setEditableSelectionOffsets(6, 6); | 1297 frame->setEditableSelectionOffsets(6, 6); |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 return true; | 1719 return true; |
| 1716 } | 1720 } |
| 1717 | 1721 |
| 1718 bool WebViewTest::tapElementById(WebInputEvent::Type type, const WebString& id) | 1722 bool WebViewTest::tapElementById(WebInputEvent::Type type, const WebString& id) |
| 1719 { | 1723 { |
| 1720 DCHECK(m_webViewHelper.webView()); | 1724 DCHECK(m_webViewHelper.webView()); |
| 1721 Element* element = static_cast<Element*>(m_webViewHelper.webView()->mainFram
e()->document().getElementById(id)); | 1725 Element* element = static_cast<Element*>(m_webViewHelper.webView()->mainFram
e()->document().getElementById(id)); |
| 1722 return tapElement(type, element); | 1726 return tapElement(type, element); |
| 1723 } | 1727 } |
| 1724 | 1728 |
| 1729 WebInputMethodController* WebViewTest::activeInputMethodController() const |
| 1730 { |
| 1731 return m_webViewHelper.webView()->mainFrameImpl()->frameWidget()->getActiveW
ebInputMethodController(); |
| 1732 } |
| 1733 |
| 1725 TEST_F(WebViewTest, DetectContentAroundPosition) | 1734 TEST_F(WebViewTest, DetectContentAroundPosition) |
| 1726 { | 1735 { |
| 1727 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_listeners.html")); | 1736 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_listeners.html")); |
| 1728 | 1737 |
| 1729 ContentDetectorClient client; | 1738 ContentDetectorClient client; |
| 1730 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li
steners.html", true, 0, &client); | 1739 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li
steners.html", true, 0, &client); |
| 1731 webView->resize(WebSize(500, 300)); | 1740 webView->resize(WebSize(500, 300)); |
| 1732 webView->updateAllLifecyclePhases(); | 1741 webView->updateAllLifecyclePhases(); |
| 1733 runPendingTasks(); | 1742 runPendingTasks(); |
| 1734 | 1743 |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "compos
ition_not_cancelled_by_backspace.html"); | 2324 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "compos
ition_not_cancelled_by_backspace.html"); |
| 2316 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2325 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2317 frame->setAutofillClient(&client); | 2326 frame->setAutofillClient(&client); |
| 2318 webView->setInitialFocus(false); | 2327 webView->setInitialFocus(false); |
| 2319 | 2328 |
| 2320 // Test both input elements. | 2329 // Test both input elements. |
| 2321 for (int i = 0; i < 2; ++i) { | 2330 for (int i = 0; i < 2; ++i) { |
| 2322 // Select composition and do sanity check. | 2331 // Select composition and do sanity check. |
| 2323 WebVector<WebCompositionUnderline> emptyUnderlines; | 2332 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2324 frame->setEditableSelectionOffsets(6, 6); | 2333 frame->setEditableSelectionOffsets(6, 6); |
| 2325 EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5)); | 2334 EXPECT_TRUE(activeInputMethodController()->setComposition("fghij", empty
Underlines, 0, 5)); |
| 2326 frame->setEditableSelectionOffsets(11, 11); | 2335 frame->setEditableSelectionOffsets(11, 11); |
| 2327 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); | 2336 verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case"); |
| 2328 | 2337 |
| 2329 // Press Backspace and verify composition didn't get cancelled. This is
to verify the fix | 2338 // Press Backspace and verify composition didn't get cancelled. This is
to verify the fix |
| 2330 // for crbug.com/429916. | 2339 // for crbug.com/429916. |
| 2331 WebKeyboardEvent keyEvent; | 2340 WebKeyboardEvent keyEvent; |
| 2332 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); | 2341 keyEvent.domKey = Platform::current()->domKeyEnumFromString("\b"); |
| 2333 keyEvent.windowsKeyCode = VKEY_BACK; | 2342 keyEvent.windowsKeyCode = VKEY_BACK; |
| 2334 keyEvent.type = WebInputEvent::RawKeyDown; | 2343 keyEvent.type = WebInputEvent::RawKeyDown; |
| 2335 webView->handleInputEvent(keyEvent); | 2344 webView->handleInputEvent(keyEvent); |
| 2336 | 2345 |
| 2337 frame->setEditableSelectionOffsets(6, 6); | 2346 frame->setEditableSelectionOffsets(6, 6); |
| 2338 EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4)); | 2347 EXPECT_TRUE(activeInputMethodController()->setComposition("fghi", emptyU
nderlines, 0, 4)); |
| 2339 frame->setEditableSelectionOffsets(10, 10); | 2348 frame->setEditableSelectionOffsets(10, 10); |
| 2340 verifySelectionAndComposition(webView, 10, 10, 6, 10, "after pressing Ba
ckspace"); | 2349 verifySelectionAndComposition(webView, 10, 10, 6, 10, "after pressing Ba
ckspace"); |
| 2341 | 2350 |
| 2342 keyEvent.type = WebInputEvent::KeyUp; | 2351 keyEvent.type = WebInputEvent::KeyUp; |
| 2343 webView->handleInputEvent(keyEvent); | 2352 webView->handleInputEvent(keyEvent); |
| 2344 | 2353 |
| 2345 webView->advanceFocus(false); | 2354 webView->advanceFocus(false); |
| 2346 } | 2355 } |
| 2347 | 2356 |
| 2348 frame->setAutofillClient(0); | 2357 frame->setAutofillClient(0); |
| 2349 } | 2358 } |
| 2350 | 2359 |
| 2351 TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) | 2360 TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) |
| 2352 { | 2361 { |
| 2353 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 2362 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 2354 MockAutofillClient client; | 2363 MockAutofillClient client; |
| 2355 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); | 2364 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 2356 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 2365 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 2357 frame->setAutofillClient(&client); | 2366 frame->setAutofillClient(&client); |
| 2358 webView->setInitialFocus(false); | 2367 webView->setInitialFocus(false); |
| 2359 | 2368 |
| 2360 // Set up a composition that needs to be committed. | 2369 // Set up a composition that needs to be committed. |
| 2361 std::string compositionText("testingtext"); | 2370 std::string compositionText("testingtext"); |
| 2362 | 2371 |
| 2363 WebVector<WebCompositionUnderline> emptyUnderlines; | 2372 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 2364 webView->setComposition(WebString::fromUTF8(compositionText.c_str()), emptyU
nderlines, 0, compositionText.length()); | 2373 activeInputMethodController()->setComposition(WebString::fromUTF8(compositio
nText.c_str()), emptyUnderlines, 0, compositionText.length()); |
| 2365 | 2374 |
| 2366 WebTextInputInfo info = webView->textInputInfo(); | 2375 WebTextInputInfo info = webView->textInputInfo(); |
| 2367 EXPECT_EQ(0, info.selectionStart); | 2376 EXPECT_EQ(0, info.selectionStart); |
| 2368 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); | 2377 EXPECT_EQ((int) compositionText.length(), info.selectionEnd); |
| 2369 EXPECT_EQ(0, info.compositionStart); | 2378 EXPECT_EQ(0, info.compositionStart); |
| 2370 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); | 2379 EXPECT_EQ((int) compositionText.length(), info.compositionEnd); |
| 2371 | 2380 |
| 2372 client.clearChangeCounts(); | 2381 client.clearChangeCounts(); |
| 2373 webView->finishComposingText(WebWidget::KeepSelection); | 2382 activeInputMethodController()->finishComposingText(WebInputMethodController:
:KeepSelection); |
| 2374 EXPECT_EQ(0, client.textChangesWhileIgnored()); | 2383 EXPECT_EQ(0, client.textChangesWhileIgnored()); |
| 2375 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); | 2384 EXPECT_EQ(1, client.textChangesWhileNotIgnored()); |
| 2376 | 2385 |
| 2377 frame->setAutofillClient(0); | 2386 frame->setAutofillClient(0); |
| 2378 } | 2387 } |
| 2379 | 2388 |
| 2380 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) | 2389 TEST_F(WebViewTest, SetCompositionFromExistingTextTriggersAutofillTextChange) |
| 2381 { | 2390 { |
| 2382 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 2391 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 2383 MockAutofillClient client; | 2392 MockAutofillClient client; |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3065 inputElement->setValue("testA"); | 3074 inputElement->setValue("testA"); |
| 3066 EXPECT_TRUE(client.textIsUpdated()); | 3075 EXPECT_TRUE(client.textIsUpdated()); |
| 3067 WebTextInputInfo info = webViewImpl->textInputInfo(); | 3076 WebTextInputInfo info = webViewImpl->textInputInfo(); |
| 3068 EXPECT_EQ("testA", std::string(info.value.utf8().data())); | 3077 EXPECT_EQ("testA", std::string(info.value.utf8().data())); |
| 3069 | 3078 |
| 3070 // (A.2) Focused and user input modifies value. | 3079 // (A.2) Focused and user input modifies value. |
| 3071 client.reset(); | 3080 client.reset(); |
| 3072 EXPECT_FALSE(client.textIsUpdated()); | 3081 EXPECT_FALSE(client.textIsUpdated()); |
| 3073 | 3082 |
| 3074 WebVector<WebCompositionUnderline> emptyUnderlines; | 3083 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 3075 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; | 3084 activeInputMethodController()->setComposition(WebString::fromUTF8("2"), empt
yUnderlines, 1, 1); |
| 3076 webViewImpl->finishComposingText(WebWidget::KeepSelection); | 3085 activeInputMethodController()->finishComposingText(WebInputMethodController:
:KeepSelection); |
| 3077 EXPECT_FALSE(client.textIsUpdated()); | 3086 EXPECT_FALSE(client.textIsUpdated()); |
| 3078 info = webViewImpl->textInputInfo(); | 3087 info = webViewImpl->textInputInfo(); |
| 3079 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); | 3088 EXPECT_EQ("testA2", std::string(info.value.utf8().data())); |
| 3080 | 3089 |
| 3081 // (A.3) Unfocused and value is changed by script. | 3090 // (A.3) Unfocused and value is changed by script. |
| 3082 client.reset(); | 3091 client.reset(); |
| 3083 EXPECT_FALSE(client.textIsUpdated()); | 3092 EXPECT_FALSE(client.textIsUpdated()); |
| 3084 document->clearFocusedElement(); | 3093 document->clearFocusedElement(); |
| 3085 webViewImpl->setFocus(false); | 3094 webViewImpl->setFocus(false); |
| 3086 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); | 3095 EXPECT_NE(document->focusedElement(), static_cast<Element*>(inputElement)); |
| 3087 inputElement->setValue("testA3"); | 3096 inputElement->setValue("testA3"); |
| 3088 EXPECT_FALSE(client.textIsUpdated()); | 3097 EXPECT_FALSE(client.textIsUpdated()); |
| 3089 | 3098 |
| 3090 // (B) <textarea> | 3099 // (B) <textarea> |
| 3091 // (B.1) Focused and value is changed by script. | 3100 // (B.1) Focused and value is changed by script. |
| 3092 client.reset(); | 3101 client.reset(); |
| 3093 EXPECT_FALSE(client.textIsUpdated()); | 3102 EXPECT_FALSE(client.textIsUpdated()); |
| 3094 HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(document->getEl
ementById("textarea")); | 3103 HTMLTextAreaElement* textAreaElement = toHTMLTextAreaElement(document->getEl
ementById("textarea")); |
| 3095 document->setFocusedElement(textAreaElement, FocusParams(SelectionBehaviorOn
Focus::None, WebFocusTypeNone, nullptr)); | 3104 document->setFocusedElement(textAreaElement, FocusParams(SelectionBehaviorOn
Focus::None, WebFocusTypeNone, nullptr)); |
| 3096 webViewImpl->setFocus(true); | 3105 webViewImpl->setFocus(true); |
| 3097 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement)
); | 3106 EXPECT_EQ(document->focusedElement(), static_cast<Element*>(textAreaElement)
); |
| 3098 textAreaElement->setValue("testB"); | 3107 textAreaElement->setValue("testB"); |
| 3099 EXPECT_TRUE(client.textIsUpdated()); | 3108 EXPECT_TRUE(client.textIsUpdated()); |
| 3100 info = webViewImpl->textInputInfo(); | 3109 info = webViewImpl->textInputInfo(); |
| 3101 EXPECT_EQ("testB", std::string(info.value.utf8().data())); | 3110 EXPECT_EQ("testB", std::string(info.value.utf8().data())); |
| 3102 | 3111 |
| 3103 // (B.2) Focused and user input modifies value. | 3112 // (B.2) Focused and user input modifies value. |
| 3104 client.reset(); | 3113 client.reset(); |
| 3105 EXPECT_FALSE(client.textIsUpdated()); | 3114 EXPECT_FALSE(client.textIsUpdated()); |
| 3106 webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1)
; | 3115 activeInputMethodController()->setComposition(WebString::fromUTF8("2"), empt
yUnderlines, 1, 1); |
| 3107 webViewImpl->finishComposingText(WebWidget::KeepSelection); | 3116 activeInputMethodController()->finishComposingText(WebInputMethodController:
:KeepSelection); |
| 3108 info = webViewImpl->textInputInfo(); | 3117 info = webViewImpl->textInputInfo(); |
| 3109 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); | 3118 EXPECT_EQ("testB2", std::string(info.value.utf8().data())); |
| 3110 | 3119 |
| 3111 // (B.3) Unfocused and value is changed by script. | 3120 // (B.3) Unfocused and value is changed by script. |
| 3112 client.reset(); | 3121 client.reset(); |
| 3113 EXPECT_FALSE(client.textIsUpdated()); | 3122 EXPECT_FALSE(client.textIsUpdated()); |
| 3114 document->clearFocusedElement(); | 3123 document->clearFocusedElement(); |
| 3115 webViewImpl->setFocus(false); | 3124 webViewImpl->setFocus(false); |
| 3116 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement)
); | 3125 EXPECT_NE(document->focusedElement(), static_cast<Element*>(textAreaElement)
); |
| 3117 inputElement->setValue("testB3"); | 3126 inputElement->setValue("testB3"); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3190 | 3199 |
| 3191 TEST_F(WebViewTest, CompositionIsUserGesture) | 3200 TEST_F(WebViewTest, CompositionIsUserGesture) |
| 3192 { | 3201 { |
| 3193 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 3202 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 3194 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); | 3203 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 3195 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3204 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3196 MockAutofillClient client; | 3205 MockAutofillClient client; |
| 3197 frame->setAutofillClient(&client); | 3206 frame->setAutofillClient(&client); |
| 3198 webView->setInitialFocus(false); | 3207 webView->setInitialFocus(false); |
| 3199 | 3208 |
| 3200 EXPECT_TRUE(webView->setComposition(WebString::fromUTF8(std::string("hello")
.c_str()), WebVector<WebCompositionUnderline>(), 3, 3)); | 3209 EXPECT_TRUE(activeInputMethodController()->setComposition(WebString::fromUTF
8(std::string("hello").c_str()), WebVector<WebCompositionUnderline>(), 3, 3)); |
| 3201 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3210 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3202 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3211 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3203 EXPECT_TRUE(frame->hasMarkedText()); | 3212 EXPECT_TRUE(frame->hasMarkedText()); |
| 3204 | 3213 |
| 3205 frame->setAutofillClient(0); | 3214 frame->setAutofillClient(0); |
| 3206 } | 3215 } |
| 3207 | 3216 |
| 3208 TEST_F(WebViewTest, CompareSelectAllToContentAsText) | 3217 TEST_F(WebViewTest, CompareSelectAllToContentAsText) |
| 3209 { | 3218 { |
| 3210 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_selection.html")); | 3219 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("longpress_selection.html")); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3538 | 3547 |
| 3539 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) | 3548 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) |
| 3540 { | 3549 { |
| 3541 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); | 3550 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); |
| 3542 MockAutofillClient client; | 3551 MockAutofillClient client; |
| 3543 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_password.html", true); | 3552 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_password.html", true); |
| 3544 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3553 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3545 frame->setAutofillClient(&client); | 3554 frame->setAutofillClient(&client); |
| 3546 webView->setInitialFocus(false); | 3555 webView->setInitialFocus(false); |
| 3547 | 3556 |
| 3548 EXPECT_TRUE(webView->commitText(WebString::fromUTF8(std::string("hello").c_s
tr()), 0)); | 3557 EXPECT_TRUE(activeInputMethodController()->commitText(WebString::fromUTF8(st
d::string("hello").c_str()), 0)); |
| 3549 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3558 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3550 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3559 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3551 frame->setAutofillClient(0); | 3560 frame->setAutofillClient(0); |
| 3552 } | 3561 } |
| 3553 | 3562 |
| 3554 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the | 3563 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the |
| 3555 // stack defers its loads. | 3564 // stack defers its loads. |
| 3556 TEST_F(WebViewTest, CreatedDuringLoadDeferral) | 3565 TEST_F(WebViewTest, CreatedDuringLoadDeferral) |
| 3557 { | 3566 { |
| 3558 { | 3567 { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3716 | 3725 |
| 3717 // Transform adapts to page scale changes. | 3726 // Transform adapts to page scale changes. |
| 3718 webViewImpl->setPageScaleFactor(2.f); | 3727 webViewImpl->setPageScaleFactor(2.f); |
| 3719 expectedMatrix.makeIdentity().scale(2.f).translate(-50, -55).translate(50, 5
5).scale(1. / 2.f); | 3728 expectedMatrix.makeIdentity().scale(2.f).translate(-50, -55).translate(50, 5
5).scale(1. / 2.f); |
| 3720 EXPECT_EQ(expectedMatrix, webViewImpl->getRootLayerTransformForTesting()); | 3729 EXPECT_EQ(expectedMatrix, webViewImpl->getRootLayerTransformForTesting()); |
| 3721 // visibleContentRect doesn't change. | 3730 // visibleContentRect doesn't change. |
| 3722 EXPECT_EQ(IntRect(50, 55, 50, 75), *devToolsEmulator->visibleContentRectForP
ainting()); | 3731 EXPECT_EQ(IntRect(50, 55, 50, 75), *devToolsEmulator->visibleContentRectForP
ainting()); |
| 3723 } | 3732 } |
| 3724 | 3733 |
| 3725 } // namespace blink | 3734 } // namespace blink |
| OLD | NEW |