Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 1889053003: Fix InputConnection.deleteSurroundingText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change for changwan@'s review Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3132 frame->setAutofillClient(&client); 3173 frame->setAutofillClient(&client);
3133 webView->setInitialFocus(false); 3174 webView->setInitialFocus(false);
3134 3175
3135 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); 3176 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str())));
3136 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3177 EXPECT_EQ(1, client.textChangesFromUserGesture());
3137 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3178 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3138 frame->setAutofillClient(0); 3179 frame->setAutofillClient(0);
3139 } 3180 }
3140 3181
3141 } // namespace blink 3182 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698