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

Unified Diff: Source/web/tests/WebViewTest.cpp

Issue 23526038: Merge 157345 "Fixing the bounds check in cancelCompositionIfSele..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1599/
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/InputMethodController.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebViewTest.cpp
===================================================================
--- Source/web/tests/WebViewTest.cpp (revision 157550)
+++ Source/web/tests/WebViewTest.cpp (working copy)
@@ -683,6 +683,68 @@
webView->close();
}
+TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html"));
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "input_field_populated.html");
+ webView->setInitialFocus(false);
+
+ std::string compositionTextFirst("hello ");
+ std::string compositionTextSecond("world");
+ WebVector<WebCompositionUnderline> emptyUnderlines;
+
+ webView->confirmComposition(WebString::fromUTF8(compositionTextFirst.c_str()));
+ webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5, 5);
+
+ WebTextInputInfo info = webView->textInputInfo();
+ EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
+ EXPECT_EQ(11, info.selectionStart);
+ EXPECT_EQ(11, info.selectionEnd);
+ EXPECT_EQ(6, info.compositionStart);
+ EXPECT_EQ(11, info.compositionEnd);
+
+ webView->setEditableSelectionOffsets(6, 6);
+ info = webView->textInputInfo();
+ EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
+ EXPECT_EQ(6, info.selectionStart);
+ EXPECT_EQ(6, info.selectionEnd);
+ EXPECT_EQ(6, info.compositionStart);
+ EXPECT_EQ(11, info.compositionEnd);
+
+ webView->setEditableSelectionOffsets(8, 8);
+ info = webView->textInputInfo();
+ EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
+ EXPECT_EQ(8, info.selectionStart);
+ EXPECT_EQ(8, info.selectionEnd);
+ EXPECT_EQ(6, info.compositionStart);
+ EXPECT_EQ(11, info.compositionEnd);
+
+ webView->setEditableSelectionOffsets(11, 11);
+ info = webView->textInputInfo();
+ EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
+ EXPECT_EQ(11, info.selectionStart);
+ EXPECT_EQ(11, info.selectionEnd);
+ EXPECT_EQ(6, info.compositionStart);
+ EXPECT_EQ(11, info.compositionEnd);
+
+ webView->setEditableSelectionOffsets(6, 11);
+ info = webView->textInputInfo();
+ EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
+ EXPECT_EQ(6, info.selectionStart);
+ EXPECT_EQ(11, info.selectionEnd);
+ EXPECT_EQ(6, info.compositionStart);
+ EXPECT_EQ(11, info.compositionEnd);
+
+ webView->setEditableSelectionOffsets(2, 2);
+ info = webView->textInputInfo();
+ EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
+ EXPECT_EQ(2, info.selectionStart);
+ EXPECT_EQ(2, info.selectionEnd);
+ EXPECT_EQ(-1, info.compositionStart);
+ EXPECT_EQ(-1, info.compositionEnd);
+ webView->close();
+}
+
TEST_F(WebViewTest, IsSelectionAnchorFirst)
{
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_populated.html"));
« no previous file with comments | « Source/core/editing/InputMethodController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698