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

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: add some comment Created 4 years, 7 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 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 frame->extendSelectionAndDelete(5, 8); 1045 frame->extendSelectionAndDelete(5, 8);
1046 WebTextInputInfo info = webView->textInputInfo(); 1046 WebTextInputInfo info = webView->textInputInfo();
1047 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); 1047 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
1048 EXPECT_EQ(5, info.selectionStart); 1048 EXPECT_EQ(5, info.selectionStart);
1049 EXPECT_EQ(5, info.selectionEnd); 1049 EXPECT_EQ(5, info.selectionEnd);
1050 frame->extendSelectionAndDelete(10, 0); 1050 frame->extendSelectionAndDelete(10, 0);
1051 info = webView->textInputInfo(); 1051 info = webView->textInputInfo();
1052 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data())); 1052 EXPECT_EQ("ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
1053 } 1053 }
1054 1054
1055 TEST_F(WebViewTest, DeleteSurroundingText)
1056 {
1057 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
1058 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
1059 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1060 webView->setInitialFocus(false);
1061
1062 frame->setEditableSelectionOffsets(10, 10);
1063 frame->deleteSurroundingText(5, 8);
1064 WebTextInputInfo info = webView->textInputInfo();
1065 EXPECT_EQ("01234ijklmnopqrstuvwxyz", std::string(info.value.utf8().data()));
1066 EXPECT_EQ(5, info.selectionStart);
1067 EXPECT_EQ(5, info.selectionEnd);
1068
1069 frame->setEditableSelectionOffsets(5, 10);
1070 frame->deleteSurroundingText(3, 5);
1071 info = webView->textInputInfo();
1072 EXPECT_EQ("01ijklmstuvwxyz", std::string(info.value.utf8().data()));
1073 EXPECT_EQ(2, info.selectionStart);
1074 EXPECT_EQ(7, info.selectionEnd);
1075
1076 frame->setEditableSelectionOffsets(5, 5);
1077 frame->deleteSurroundingText(10, 0);
1078 info = webView->textInputInfo();
1079 EXPECT_EQ("lmstuvwxyz", std::string(info.value.utf8().data()));
1080 EXPECT_EQ(0, info.selectionStart);
1081 EXPECT_EQ(0, info.selectionEnd);
1082
1083 frame->deleteSurroundingText(0, 20);
1084 info = webView->textInputInfo();
1085 EXPECT_EQ("", std::string(info.value.utf8().data()));
1086 EXPECT_EQ(0, info.selectionStart);
1087 EXPECT_EQ(0, info.selectionEnd);
1088
1089 frame->deleteSurroundingText(10, 10);
1090 info = webView->textInputInfo();
1091 EXPECT_EQ("", std::string(info.value.utf8().data()));
1092 EXPECT_EQ(0, info.selectionStart);
1093 EXPECT_EQ(0, info.selectionEnd);
1094 }
1095
1055 TEST_F(WebViewTest, SetCompositionFromExistingText) 1096 TEST_F(WebViewTest, SetCompositionFromExistingText)
1056 { 1097 {
1057 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html")); 1098 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("input_field_populated.html"));
1058 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html"); 1099 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "input_fiel d_populated.html");
1059 webView->setInitialFocus(false); 1100 webView->setInitialFocus(false);
1060 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); 1101 WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
1061 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); 1102 underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0);
1062 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 1103 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1063 frame->setEditableSelectionOffsets(4, 10); 1104 frame->setEditableSelectionOffsets(4, 10);
1064 frame->setCompositionFromExistingText(8, 12, underlines); 1105 frame->setCompositionFromExistingText(8, 12, underlines);
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 frame->setAutofillClient(&client); 3094 frame->setAutofillClient(&client);
3054 webView->setInitialFocus(false); 3095 webView->setInitialFocus(false);
3055 3096
3056 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); 3097 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str())));
3057 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3098 EXPECT_EQ(1, client.textChangesFromUserGesture());
3058 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3099 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3059 frame->setAutofillClient(0); 3100 frame->setAutofillClient(0);
3060 } 3101 }
3061 3102
3062 } // namespace blink 3103 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698