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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 frame->extendSelectionAndDelete(5, 8); | 910 frame->extendSelectionAndDelete(5, 8); |
911 WebTextInputInfo info = webView->textInputInfo(); | 911 WebTextInputInfo info = webView->textInputInfo(); |
912 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 912 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
913 EXPECT_EQ(5, info.selectionStart); | 913 EXPECT_EQ(5, info.selectionStart); |
914 EXPECT_EQ(5, info.selectionEnd); | 914 EXPECT_EQ(5, info.selectionEnd); |
915 frame->extendSelectionAndDelete(10, 0); | 915 frame->extendSelectionAndDelete(10, 0); |
916 info = webView->textInputInfo(); | 916 info = webView->textInputInfo(); |
917 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); | 917 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
918 } | 918 } |
919 | 919 |
| 920 TEST_F(WebViewTest, DeleteSurroundingText) |
| 921 { |
| 922 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
| 923 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
| 924 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
| 925 webView->setInitialFocus(false); |
| 926 |
| 927 frame->setEditableSelectionOffsets(10, 10); |
| 928 frame->deleteSurroundingText(5, 8); |
| 929 WebTextInputInfo info = webView->textInputInfo(); |
| 930 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); |
| 931 EXPECT_EQ(5, info.selectionStart); |
| 932 EXPECT_EQ(5, info.selectionEnd); |
| 933 |
| 934 frame->setEditableSelectionOffsets(5, 10); |
| 935 frame->deleteSurroundingText(3, 5); |
| 936 info = webView->textInputInfo(); |
| 937 EXPECT_EQ("01ijklmstuvwxyz", std::string(info.value.utf8().data())); |
| 938 EXPECT_EQ(2, info.selectionStart); |
| 939 EXPECT_EQ(7, info.selectionEnd); |
| 940 |
| 941 frame->setEditableSelectionOffsets(5, 5); |
| 942 frame->deleteSurroundingText(10, 0); |
| 943 info = webView->textInputInfo(); |
| 944 EXPECT_EQ("lmstuvwxyz", std::string(info.value.utf8().data())); |
| 945 EXPECT_EQ(0, info.selectionStart); |
| 946 EXPECT_EQ(0, info.selectionEnd); |
| 947 |
| 948 frame->deleteSurroundingText(0, 20); |
| 949 info = webView->textInputInfo(); |
| 950 EXPECT_EQ("", std::string(info.value.utf8().data())); |
| 951 EXPECT_EQ(0, info.selectionStart); |
| 952 EXPECT_EQ(0, info.selectionEnd); |
| 953 |
| 954 frame->deleteSurroundingText(10, 10); |
| 955 info = webView->textInputInfo(); |
| 956 EXPECT_EQ("", std::string(info.value.utf8().data())); |
| 957 EXPECT_EQ(0, info.selectionStart); |
| 958 EXPECT_EQ(0, info.selectionEnd); |
| 959 } |
| 960 |
920 TEST_F(WebViewTest, SetCompositionFromExistingText) | 961 TEST_F(WebViewTest, SetCompositionFromExistingText) |
921 { | 962 { |
922 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); | 963 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("input_field_populated.html")); |
923 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); | 964 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel
d_populated.html"); |
924 webView->setInitialFocus(false); | 965 webView->setInitialFocus(false); |
925 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 966 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); |
926 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 967 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); |
927 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); | 968 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); |
928 frame->setEditableSelectionOffsets(4, 10); | 969 frame->setEditableSelectionOffsets(4, 10); |
929 frame->setCompositionFromExistingText(8, 12, underlines); | 970 frame->setCompositionFromExistingText(8, 12, underlines); |
(...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3210 frame->setAutofillClient(&client); | 3251 frame->setAutofillClient(&client); |
3211 webView->setInitialFocus(false); | 3252 webView->setInitialFocus(false); |
3212 | 3253 |
3213 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); | 3254 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); |
3214 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3255 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
3215 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3256 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
3216 frame->setAutofillClient(0); | 3257 frame->setAutofillClient(0); |
3217 } | 3258 } |
3218 | 3259 |
3219 } // namespace blink | 3260 } // namespace blink |
OLD | NEW |