| 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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 EXPECT_EQ(12, info.compositionEnd); | 883 EXPECT_EQ(12, info.compositionEnd); |
| 884 | 884 |
| 885 webView->confirmComposition(WebWidget::KeepSelection); | 885 webView->confirmComposition(WebWidget::KeepSelection); |
| 886 info = webView->textInputInfo(); | 886 info = webView->textInputInfo(); |
| 887 EXPECT_EQ(4, info.selectionStart); | 887 EXPECT_EQ(4, info.selectionStart); |
| 888 EXPECT_EQ(4, info.selectionEnd); | 888 EXPECT_EQ(4, info.selectionEnd); |
| 889 EXPECT_EQ(-1, info.compositionStart); | 889 EXPECT_EQ(-1, info.compositionStart); |
| 890 EXPECT_EQ(-1, info.compositionEnd); | 890 EXPECT_EQ(-1, info.compositionEnd); |
| 891 | 891 |
| 892 std::string compositionText("\n"); | 892 std::string compositionText("\n"); |
| 893 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 893 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str()), 1)
; |
| 894 info = webView->textInputInfo(); | 894 info = webView->textInputInfo(); |
| 895 EXPECT_EQ(5, info.selectionStart); | 895 EXPECT_EQ(5, info.selectionStart); |
| 896 EXPECT_EQ(5, info.selectionEnd); | 896 EXPECT_EQ(5, info.selectionEnd); |
| 897 EXPECT_EQ(-1, info.compositionStart); | 897 EXPECT_EQ(-1, info.compositionStart); |
| 898 EXPECT_EQ(-1, info.compositionEnd); | 898 EXPECT_EQ(-1, info.compositionEnd); |
| 899 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); | 899 EXPECT_EQ("0123\n456789abcdefghijklmnopqrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 900 } | 900 } |
| 901 | 901 |
| 902 TEST_F(WebViewTest, ExtendSelectionAndDelete) | 902 TEST_F(WebViewTest, ExtendSelectionAndDelete) |
| 903 { | 903 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) | 943 TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) |
| 944 { | 944 { |
| 945 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); | 945 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("text_area_populated.html")); |
| 946 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); | 946 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "text_a
rea_populated.html"); |
| 947 webView->setInitialFocus(false); | 947 webView->setInitialFocus(false); |
| 948 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 948 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
| 949 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 949 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
| 950 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 950 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 951 frame->setEditableSelectionOffsets(27, 27); | 951 frame->setEditableSelectionOffsets(27, 27); |
| 952 std::string newLineText("\n"); | 952 std::string newLineText("\n"); |
| 953 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str())); | 953 webView->confirmComposition(WebString::fromUTF8(newLineText.c_str()), 1); |
| 954 WebTextInputInfo info = webView->textInputInfo(); | 954 WebTextInputInfo info = webView->textInputInfo(); |
| 955 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 955 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 956 | 956 |
| 957 frame->setEditableSelectionOffsets(31, 31); | 957 frame->setEditableSelectionOffsets(31, 31); |
| 958 frame->setCompositionFromExistingText(30, 34, underlines); | 958 frame->setCompositionFromExistingText(30, 34, underlines); |
| 959 info = webView->textInputInfo(); | 959 info = webView->textInputInfo(); |
| 960 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); | 960 EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz", std::string(info.value.u
tf8().data())); |
| 961 EXPECT_EQ(31, info.selectionStart); | 961 EXPECT_EQ(31, info.selectionStart); |
| 962 EXPECT_EQ(31, info.selectionEnd); | 962 EXPECT_EQ(31, info.selectionEnd); |
| 963 EXPECT_EQ(30, info.compositionStart); | 963 EXPECT_EQ(30, info.compositionStart); |
| 964 EXPECT_EQ(34, info.compositionEnd); | 964 EXPECT_EQ(34, info.compositionEnd); |
| 965 | 965 |
| 966 std::string compositionText("yolo"); | 966 std::string compositionText("yolo"); |
| 967 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str())); | 967 webView->confirmComposition(WebString::fromUTF8(compositionText.c_str()), 1)
; |
| 968 info = webView->textInputInfo(); | 968 info = webView->textInputInfo(); |
| 969 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); | 969 EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz", std::string(info.value.u
tf8().data())); |
| 970 EXPECT_EQ(34, info.selectionStart); | 970 EXPECT_EQ(34, info.selectionStart); |
| 971 EXPECT_EQ(34, info.selectionEnd); | 971 EXPECT_EQ(34, info.selectionEnd); |
| 972 EXPECT_EQ(-1, info.compositionStart); | 972 EXPECT_EQ(-1, info.compositionStart); |
| 973 EXPECT_EQ(-1, info.compositionEnd); | 973 EXPECT_EQ(-1, info.compositionEnd); |
| 974 } | 974 } |
| 975 | 975 |
| 976 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) | 976 TEST_F(WebViewTest, SetCompositionFromExistingTextInRichText) |
| 977 { | 977 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 991 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) | 991 TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) |
| 992 { | 992 { |
| 993 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 993 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 994 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); | 994 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_populated.html"); |
| 995 webView->setInitialFocus(false); | 995 webView->setInitialFocus(false); |
| 996 | 996 |
| 997 std::string compositionTextFirst("hello "); | 997 std::string compositionTextFirst("hello "); |
| 998 std::string compositionTextSecond("world"); | 998 std::string compositionTextSecond("world"); |
| 999 WebVector<WebCompositionUnderline> emptyUnderlines; | 999 WebVector<WebCompositionUnderline> emptyUnderlines; |
| 1000 | 1000 |
| 1001 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()
)); | 1001 webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()
), 1); |
| 1002 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); | 1002 webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
emptyUnderlines, 5, 5); |
| 1003 | 1003 |
| 1004 WebTextInputInfo info = webView->textInputInfo(); | 1004 WebTextInputInfo info = webView->textInputInfo(); |
| 1005 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); | 1005 EXPECT_EQ("hello world", std::string(info.value.utf8().data())); |
| 1006 EXPECT_EQ(11, info.selectionStart); | 1006 EXPECT_EQ(11, info.selectionStart); |
| 1007 EXPECT_EQ(11, info.selectionEnd); | 1007 EXPECT_EQ(11, info.selectionEnd); |
| 1008 EXPECT_EQ(6, info.compositionStart); | 1008 EXPECT_EQ(6, info.compositionStart); |
| 1009 EXPECT_EQ(11, info.compositionEnd); | 1009 EXPECT_EQ(11, info.compositionEnd); |
| 1010 | 1010 |
| 1011 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 1011 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| (...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3202 | 3202 |
| 3203 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) | 3203 TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) |
| 3204 { | 3204 { |
| 3205 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); | 3205 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_password.html")); |
| 3206 MockAutofillClient client; | 3206 MockAutofillClient client; |
| 3207 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_password.html", true); | 3207 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_
field_password.html", true); |
| 3208 WebLocalFrameImpl* frame = webView->mainFrameImpl(); | 3208 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 3209 frame->setAutofillClient(&client); | 3209 frame->setAutofillClient(&client); |
| 3210 webView->setInitialFocus(false); | 3210 webView->setInitialFocus(false); |
| 3211 | 3211 |
| 3212 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); | 3212 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()), 1)); |
| 3213 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3213 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3214 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3214 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3215 frame->setAutofillClient(0); | 3215 frame->setAutofillClient(0); |
| 3216 } | 3216 } |
| 3217 | 3217 |
| 3218 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the | 3218 // Verify that a WebView created with a ScopedPageLoadDeferrer already on the |
| 3219 // stack defers its loads. | 3219 // stack defers its loads. |
| 3220 TEST_F(WebViewTest, CreatedDuringLoadDeferral) | 3220 TEST_F(WebViewTest, CreatedDuringLoadDeferral) |
| 3221 { | 3221 { |
| 3222 { | 3222 { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3280 EXPECT_TRUE(webView->page()->defersLoading()); | 3280 EXPECT_TRUE(webView->page()->defersLoading()); |
| 3281 } | 3281 } |
| 3282 | 3282 |
| 3283 EXPECT_TRUE(webView->page()->defersLoading()); | 3283 EXPECT_TRUE(webView->page()->defersLoading()); |
| 3284 } | 3284 } |
| 3285 | 3285 |
| 3286 EXPECT_FALSE(webView->page()->defersLoading()); | 3286 EXPECT_FALSE(webView->page()->defersLoading()); |
| 3287 } | 3287 } |
| 3288 | 3288 |
| 3289 } // namespace blink | 3289 } // namespace blink |
| OLD | NEW |