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

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 some comments. Created 4 years, 6 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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 frame->extendSelectionAndDelete(5, 8); 1047 frame->extendSelectionAndDelete(5, 8);
1048 WebTextInputInfo info = webView->textInputInfo(); 1048 WebTextInputInfo info = webView->textInputInfo();
1049 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); 1049 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
1050 EXPECT_EQ(5, info.selectionStart); 1050 EXPECT_EQ(5, info.selectionStart);
1051 EXPECT_EQ(5, info.selectionEnd); 1051 EXPECT_EQ(5, info.selectionEnd);
1052 frame->extendSelectionAndDelete(10, 0); 1052 frame->extendSelectionAndDelete(10, 0);
1053 info = webView->textInputInfo(); 1053 info = webView->textInputInfo();
1054 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); 1054 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
1055 } 1055 }
1056 1056
1057 TEST_F(WebViewTest, DeleteSurroundingText)
1058 {
1059 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
1060 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
1061 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1062 webView->setInitialFocus(false);
1063
1064 frame->setEditableSelectionOffsets(10, 10);
1065 frame->deleteSurroundingText(5, 8);
1066 WebTextInputInfo info = webView->textInputInfo();
1067 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
1068 EXPECT_EQ(5, info.selectionStart);
1069 EXPECT_EQ(5, info.selectionEnd);
1070
1071 frame->setEditableSelectionOffsets(5, 10);
1072 frame->deleteSurroundingText(3, 5);
1073 info = webView->textInputInfo();
1074 EXPECT_EQ("01ijklmstuvwxyz", std::string(info.value.utf8().data()));
1075 EXPECT_EQ(2, info.selectionStart);
1076 EXPECT_EQ(7, info.selectionEnd);
1077
1078 frame->setEditableSelectionOffsets(5, 5);
1079 frame->deleteSurroundingText(10, 0);
1080 info = webView->textInputInfo();
1081 EXPECT_EQ("lmstuvwxyz", std::string(info.value.utf8().data()));
1082 EXPECT_EQ(0, info.selectionStart);
1083 EXPECT_EQ(0, info.selectionEnd);
1084
1085 frame->deleteSurroundingText(0, 20);
1086 info = webView->textInputInfo();
1087 EXPECT_EQ("", std::string(info.value.utf8().data()));
1088 EXPECT_EQ(0, info.selectionStart);
1089 EXPECT_EQ(0, info.selectionEnd);
1090
1091 frame->deleteSurroundingText(10, 10);
1092 info = webView->textInputInfo();
1093 EXPECT_EQ("", std::string(info.value.utf8().data()));
1094 EXPECT_EQ(0, info.selectionStart);
1095 EXPECT_EQ(0, info.selectionEnd);
1096 }
1097
1057 TEST_F(WebViewTest, SetCompositionFromExistingText) 1098 TEST_F(WebViewTest, SetCompositionFromExistingText)
1058 { 1099 {
1059 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 1100 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
1060 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); 1101 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
1061 webView->setInitialFocus(false); 1102 webView->setInitialFocus(false);
1062 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1103 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1063 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1104 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0);
1064 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 1105 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1065 frame->setEditableSelectionOffsets(4, 10); 1106 frame->setEditableSelectionOffsets(4, 10);
1066 frame->setCompositionFromExistingText(8, 12, underlines); 1107 frame->setCompositionFromExistingText(8, 12, underlines);
(...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3179 frame->setAutofillClient(&client); 3220 frame->setAutofillClient(&client);
3180 webView->setInitialFocus(false); 3221 webView->setInitialFocus(false);
3181 3222
3182 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); 3223 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str())));
3183 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3224 EXPECT_EQ(1, client.textChangesFromUserGesture());
3184 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3225 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3185 frame->setAutofillClient(0); 3226 frame->setAutofillClient(0);
3186 } 3227 }
3187 3228
3188 } // namespace blink 3229 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698