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

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

Issue 2333813002: Introduce WebInputMethodController to blink (Closed)
Patch Set: Explicitly asking for TextInputState updates Created 4 years, 1 month 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
Index: third_party/WebKit/Source/web/tests/WebViewTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
index d7498f94b31474e3f761fd9045bfae3f56f11f4a..497967380b4aaa34870b352546d2e244483665a4 100644
--- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
@@ -85,6 +85,7 @@
#include "public/web/WebFrameContentDumper.h"
#include "public/web/WebHitTestResult.h"
#include "public/web/WebInputEvent.h"
+#include "public/web/WebInputMethodController.h"
#include "public/web/WebScriptSource.h"
#include "public/web/WebSettings.h"
#include "public/web/WebTreeScopeType.h"
@@ -95,6 +96,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "web/DevToolsEmulator.h"
+#include "web/WebInputMethodControllerImpl.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebSettingsImpl.h"
#include "web/WebViewImpl.h"
@@ -890,16 +892,20 @@ TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) {
URLTestHelpers::registerMockedURLFromBaseURL(
WebString::fromUTF8(m_baseURL.c_str()),
WebString::fromUTF8("input_field_populated.html"));
- WebView* webView = m_webViewHelper.initializeAndLoad(
+ WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
m_baseURL + "input_field_populated.html");
webView->setInitialFocus(false);
// Set up a composition that needs to be committed.
std::string compositionText("hello");
+ WebInputMethodController* activeInputMethodController =
+ webView->mainFrameImpl()
+ ->frameWidget()
+ ->getActiveWebInputMethodController();
WebVector<WebCompositionUnderline> emptyUnderlines;
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, 3, 3);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3);
WebTextInputInfo info = webView->textInputInfo();
EXPECT_EQ("hello", std::string(info.value.utf8().data()));
@@ -908,15 +914,16 @@ TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) {
EXPECT_EQ(0, info.compositionStart);
EXPECT_EQ(5, info.compositionEnd);
- webView->finishComposingText(WebWidget::KeepSelection);
+ activeInputMethodController->finishComposingText(
+ WebInputMethodController::KeepSelection);
info = webView->textInputInfo();
EXPECT_EQ(3, info.selectionStart);
EXPECT_EQ(3, info.selectionEnd);
EXPECT_EQ(-1, info.compositionStart);
EXPECT_EQ(-1, info.compositionEnd);
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, 3, 3);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3);
info = webView->textInputInfo();
EXPECT_EQ("helhellolo", std::string(info.value.utf8().data()));
EXPECT_EQ(6, info.selectionStart);
@@ -924,7 +931,8 @@ TEST_F(WebViewTest, FinishComposingTextCursorPositionChange) {
EXPECT_EQ(3, info.compositionStart);
EXPECT_EQ(8, info.compositionEnd);
- webView->finishComposingText(WebWidget::DoNotKeepSelection);
+ activeInputMethodController->finishComposingText(
+ WebInputMethodController::DoNotKeepSelection);
info = webView->textInputInfo();
EXPECT_EQ(8, info.selectionStart);
EXPECT_EQ(8, info.selectionEnd);
@@ -936,12 +944,16 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
URLTestHelpers::registerMockedURLFromBaseURL(
WebString::fromUTF8(m_baseURL.c_str()),
WebString::fromUTF8("input_field_populated.html"));
- WebView* webView = m_webViewHelper.initializeAndLoad(
+ WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
m_baseURL + "input_field_populated.html");
webView->setInitialFocus(false);
+ WebInputMethodController* activeInputMethodController =
+ webView->mainFrameImpl()
+ ->frameWidget()
+ ->getActiveWebInputMethodController();
- webView->commitText("hello", 0);
- webView->commitText("world", -5);
+ activeInputMethodController->commitText("hello", 0);
+ activeInputMethodController->commitText("world", -5);
WebTextInputInfo info = webView->textInputInfo();
EXPECT_EQ("helloworld", std::string(info.value.utf8().data()));
EXPECT_EQ(5, info.selectionStart);
@@ -954,8 +966,8 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
std::string compositionText("ABC");
// Caret is on the left of composing text.
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, 0, 0);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0, 0);
info = webView->textInputInfo();
EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
EXPECT_EQ(5, info.selectionStart);
@@ -964,8 +976,8 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
EXPECT_EQ(8, info.compositionEnd);
// Caret is on the right of composing text.
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, 3, 3);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 3, 3);
info = webView->textInputInfo();
EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
EXPECT_EQ(8, info.selectionStart);
@@ -974,8 +986,8 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
EXPECT_EQ(8, info.compositionEnd);
// Caret is between composing text and left boundary.
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, -2, -2);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -2, -2);
info = webView->textInputInfo();
EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
EXPECT_EQ(3, info.selectionStart);
@@ -984,8 +996,8 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
EXPECT_EQ(8, info.compositionEnd);
// Caret is between composing text and right boundary.
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, 5, 5);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 5, 5);
info = webView->textInputInfo();
EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
EXPECT_EQ(10, info.selectionStart);
@@ -994,8 +1006,8 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
EXPECT_EQ(8, info.compositionEnd);
// Caret is on the left boundary.
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, -5, -5);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -5, -5);
info = webView->textInputInfo();
EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
EXPECT_EQ(0, info.selectionStart);
@@ -1004,8 +1016,8 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
EXPECT_EQ(8, info.compositionEnd);
// Caret is on the right boundary.
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, 8, 8);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 8, 8);
info = webView->textInputInfo();
EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
EXPECT_EQ(13, info.selectionStart);
@@ -1014,8 +1026,9 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
EXPECT_EQ(8, info.compositionEnd);
// Caret exceeds the left boundary.
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, -100, -100);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, -100,
+ -100);
info = webView->textInputInfo();
EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
EXPECT_EQ(0, info.selectionStart);
@@ -1024,8 +1037,8 @@ TEST_F(WebViewTest, SetCompositionForNewCaretPositions) {
EXPECT_EQ(8, info.compositionEnd);
// Caret exceeds the right boundary.
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, 100, 100);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 100, 100);
info = webView->textInputInfo();
EXPECT_EQ("helloABCworld", std::string(info.value.utf8().data()));
EXPECT_EQ(13, info.selectionStart);
@@ -1038,11 +1051,15 @@ TEST_F(WebViewTest, SetCompositionWithEmptyText) {
URLTestHelpers::registerMockedURLFromBaseURL(
WebString::fromUTF8(m_baseURL.c_str()),
WebString::fromUTF8("input_field_populated.html"));
- WebView* webView = m_webViewHelper.initializeAndLoad(
+ WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
m_baseURL + "input_field_populated.html");
webView->setInitialFocus(false);
+ WebInputMethodController* activeInputMethodController =
+ webView->mainFrameImpl()
+ ->frameWidget()
+ ->getActiveWebInputMethodController();
- webView->commitText("hello", 0);
+ activeInputMethodController->commitText("hello", 0);
WebTextInputInfo info = webView->textInputInfo();
EXPECT_EQ("hello", std::string(info.value.utf8().data()));
EXPECT_EQ(5, info.selectionStart);
@@ -1052,7 +1069,8 @@ TEST_F(WebViewTest, SetCompositionWithEmptyText) {
WebVector<WebCompositionUnderline> emptyUnderlines;
- webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, 0, 0);
+ activeInputMethodController->setComposition(WebString::fromUTF8(""),
+ emptyUnderlines, 0, 0);
info = webView->textInputInfo();
EXPECT_EQ("hello", std::string(info.value.utf8().data()));
EXPECT_EQ(5, info.selectionStart);
@@ -1060,7 +1078,8 @@ TEST_F(WebViewTest, SetCompositionWithEmptyText) {
EXPECT_EQ(-1, info.compositionStart);
EXPECT_EQ(-1, info.compositionEnd);
- webView->setComposition(WebString::fromUTF8(""), emptyUnderlines, -2, -2);
+ activeInputMethodController->setComposition(WebString::fromUTF8(""),
+ emptyUnderlines, -2, -2);
info = webView->textInputInfo();
EXPECT_EQ("hello", std::string(info.value.utf8().data()));
EXPECT_EQ(3, info.selectionStart);
@@ -1073,12 +1092,16 @@ TEST_F(WebViewTest, CommitTextForNewCaretPositions) {
URLTestHelpers::registerMockedURLFromBaseURL(
WebString::fromUTF8(m_baseURL.c_str()),
WebString::fromUTF8("input_field_populated.html"));
- WebView* webView = m_webViewHelper.initializeAndLoad(
+ WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
m_baseURL + "input_field_populated.html");
webView->setInitialFocus(false);
+ WebInputMethodController* activeInputMethodController =
+ webView->mainFrameImpl()
+ ->frameWidget()
+ ->getActiveWebInputMethodController();
// Caret is on the left of composing text.
- webView->commitText("ab", -2);
+ activeInputMethodController->commitText("ab", -2);
WebTextInputInfo info = webView->textInputInfo();
EXPECT_EQ("ab", std::string(info.value.utf8().data()));
EXPECT_EQ(0, info.selectionStart);
@@ -1087,7 +1110,7 @@ TEST_F(WebViewTest, CommitTextForNewCaretPositions) {
EXPECT_EQ(-1, info.compositionEnd);
// Caret is on the right of composing text.
- webView->commitText("c", 1);
+ activeInputMethodController->commitText("c", 1);
info = webView->textInputInfo();
EXPECT_EQ("cab", std::string(info.value.utf8().data()));
EXPECT_EQ(2, info.selectionStart);
@@ -1096,7 +1119,7 @@ TEST_F(WebViewTest, CommitTextForNewCaretPositions) {
EXPECT_EQ(-1, info.compositionEnd);
// Caret is on the left boundary.
- webView->commitText("def", -5);
+ activeInputMethodController->commitText("def", -5);
info = webView->textInputInfo();
EXPECT_EQ("cadefb", std::string(info.value.utf8().data()));
EXPECT_EQ(0, info.selectionStart);
@@ -1105,7 +1128,7 @@ TEST_F(WebViewTest, CommitTextForNewCaretPositions) {
EXPECT_EQ(-1, info.compositionEnd);
// Caret is on the right boundary.
- webView->commitText("g", 6);
+ activeInputMethodController->commitText("g", 6);
info = webView->textInputInfo();
EXPECT_EQ("gcadefb", std::string(info.value.utf8().data()));
EXPECT_EQ(7, info.selectionStart);
@@ -1114,7 +1137,7 @@ TEST_F(WebViewTest, CommitTextForNewCaretPositions) {
EXPECT_EQ(-1, info.compositionEnd);
// Caret exceeds the left boundary.
- webView->commitText("hi", -100);
+ activeInputMethodController->commitText("hi", -100);
info = webView->textInputInfo();
EXPECT_EQ("gcadefbhi", std::string(info.value.utf8().data()));
EXPECT_EQ(0, info.selectionStart);
@@ -1123,7 +1146,7 @@ TEST_F(WebViewTest, CommitTextForNewCaretPositions) {
EXPECT_EQ(-1, info.compositionEnd);
// Caret exceeds the right boundary.
- webView->commitText("jk", 100);
+ activeInputMethodController->commitText("jk", 100);
info = webView->textInputInfo();
EXPECT_EQ("jkgcadefbhi", std::string(info.value.utf8().data()));
EXPECT_EQ(11, info.selectionStart);
@@ -1136,12 +1159,17 @@ TEST_F(WebViewTest, CommitTextWhileComposing) {
URLTestHelpers::registerMockedURLFromBaseURL(
WebString::fromUTF8(m_baseURL.c_str()),
WebString::fromUTF8("input_field_populated.html"));
- WebView* webView = m_webViewHelper.initializeAndLoad(
+ WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
m_baseURL + "input_field_populated.html");
webView->setInitialFocus(false);
+ WebInputMethodController* activeInputMethodController =
+ webView->mainFrameImpl()
+ ->frameWidget()
+ ->getActiveWebInputMethodController();
WebVector<WebCompositionUnderline> emptyUnderlines;
- webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0);
+ activeInputMethodController->setComposition(WebString::fromUTF8("abc"),
+ emptyUnderlines, 0, 0);
WebTextInputInfo info = webView->textInputInfo();
EXPECT_EQ("abc", std::string(info.value.utf8().data()));
EXPECT_EQ(0, info.selectionStart);
@@ -1151,7 +1179,7 @@ TEST_F(WebViewTest, CommitTextWhileComposing) {
// Deletes ongoing composition, inserts the specified text and moves the
// caret.
- webView->commitText("hello", -2);
+ activeInputMethodController->commitText("hello", -2);
info = webView->textInputInfo();
EXPECT_EQ("hello", std::string(info.value.utf8().data()));
EXPECT_EQ(3, info.selectionStart);
@@ -1159,7 +1187,8 @@ TEST_F(WebViewTest, CommitTextWhileComposing) {
EXPECT_EQ(-1, info.compositionStart);
EXPECT_EQ(-1, info.compositionEnd);
- webView->setComposition(WebString::fromUTF8("abc"), emptyUnderlines, 0, 0);
+ activeInputMethodController->setComposition(WebString::fromUTF8("abc"),
+ emptyUnderlines, 0, 0);
info = webView->textInputInfo();
EXPECT_EQ("helabclo", std::string(info.value.utf8().data()));
EXPECT_EQ(3, info.selectionStart);
@@ -1168,7 +1197,7 @@ TEST_F(WebViewTest, CommitTextWhileComposing) {
EXPECT_EQ(6, info.compositionEnd);
// Deletes ongoing composition and moves the caret.
- webView->commitText("", 2);
+ activeInputMethodController->commitText("", 2);
info = webView->textInputInfo();
EXPECT_EQ("hello", std::string(info.value.utf8().data()));
EXPECT_EQ(5, info.selectionStart);
@@ -1177,7 +1206,7 @@ TEST_F(WebViewTest, CommitTextWhileComposing) {
EXPECT_EQ(-1, info.compositionEnd);
// Inserts the specified text and moves the caret.
- webView->commitText("world", -5);
+ activeInputMethodController->commitText("world", -5);
info = webView->textInputInfo();
EXPECT_EQ("helloworld", std::string(info.value.utf8().data()));
EXPECT_EQ(5, info.selectionStart);
@@ -1186,7 +1215,7 @@ TEST_F(WebViewTest, CommitTextWhileComposing) {
EXPECT_EQ(-1, info.compositionEnd);
// Only moves the caret.
- webView->commitText("", 5);
+ activeInputMethodController->commitText("", 5);
info = webView->textInputInfo();
EXPECT_EQ("helloworld", std::string(info.value.utf8().data()));
EXPECT_EQ(10, info.selectionStart);
@@ -1224,7 +1253,9 @@ TEST_F(WebViewTest, FinishCompositionDoesNotRevealSelection) {
EXPECT_EQ("hello", std::string(info.value.utf8().data()));
// Verify that the input field is not scrolled back into the viewport.
- webView->finishComposingText(WebWidget::DoNotKeepSelection);
+ frame->frameWidget()
+ ->getActiveWebInputMethodController()
+ ->finishComposingText(WebInputMethodController::DoNotKeepSelection);
EXPECT_EQ(0, webView->mainFrame()->scrollOffset().width);
EXPECT_EQ(offsetHeight, webView->mainFrame()->scrollOffset().height);
}
@@ -1251,7 +1282,10 @@ TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) {
EXPECT_EQ(8, info.compositionStart);
EXPECT_EQ(12, info.compositionEnd);
- webView->finishComposingText(WebWidget::KeepSelection);
+ WebInputMethodController* activeInputMethodController =
+ frame->frameWidget()->getActiveWebInputMethodController();
+ activeInputMethodController->finishComposingText(
+ WebInputMethodController::KeepSelection);
info = webView->textInputInfo();
EXPECT_EQ(4, info.selectionStart);
EXPECT_EQ(4, info.selectionEnd);
@@ -1259,7 +1293,8 @@ TEST_F(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) {
EXPECT_EQ(-1, info.compositionEnd);
std::string compositionText("\n");
- webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0);
+ activeInputMethodController->commitText(
+ WebString::fromUTF8(compositionText.c_str()), 0);
info = webView->textInputInfo();
EXPECT_EQ(5, info.selectionStart);
EXPECT_EQ(5, info.selectionEnd);
@@ -1367,9 +1402,12 @@ TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) {
WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1));
underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0);
WebLocalFrameImpl* frame = webView->mainFrameImpl();
+ WebInputMethodController* activeInputMethodController =
+ frame->frameWidget()->getActiveWebInputMethodController();
frame->setEditableSelectionOffsets(27, 27);
std::string newLineText("\n");
- webView->commitText(WebString::fromUTF8(newLineText.c_str()), 0);
+ activeInputMethodController->commitText(
+ WebString::fromUTF8(newLineText.c_str()), 0);
WebTextInputInfo info = webView->textInputInfo();
EXPECT_EQ("0123456789abcdefghijklmnopq\nrstuvwxyz",
std::string(info.value.utf8().data()));
@@ -1385,7 +1423,8 @@ TEST_F(WebViewTest, SetCompositionFromExistingTextInTextArea) {
EXPECT_EQ(34, info.compositionEnd);
std::string compositionText("yolo");
- webView->commitText(WebString::fromUTF8(compositionText.c_str()), 0);
+ activeInputMethodController->commitText(
+ WebString::fromUTF8(compositionText.c_str()), 0);
info = webView->textInputInfo();
EXPECT_EQ("0123456789abcdefghijklmnopq\nrsyoloxyz",
std::string(info.value.utf8().data()));
@@ -1423,10 +1462,15 @@ TEST_F(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) {
std::string compositionTextFirst("hello ");
std::string compositionTextSecond("world");
WebVector<WebCompositionUnderline> emptyUnderlines;
-
- webView->commitText(WebString::fromUTF8(compositionTextFirst.c_str()), 0);
- webView->setComposition(WebString::fromUTF8(compositionTextSecond.c_str()),
- emptyUnderlines, 5, 5);
+ WebInputMethodController* activeInputMethodController =
+ webView->mainFrameImpl()
+ ->frameWidget()
+ ->getActiveWebInputMethodController();
+ activeInputMethodController->commitText(
+ WebString::fromUTF8(compositionTextFirst.c_str()), 0);
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionTextSecond.c_str()), emptyUnderlines, 5,
+ 5);
WebTextInputInfo info = webView->textInputInfo();
EXPECT_EQ("hello world", std::string(info.value.utf8().data()));
@@ -2664,7 +2708,10 @@ TEST_F(WebViewTest, CompositionNotCancelledByBackspace) {
// Select composition and do sanity check.
WebVector<WebCompositionUnderline> emptyUnderlines;
frame->setEditableSelectionOffsets(6, 6);
- EXPECT_TRUE(webView->setComposition("fghij", emptyUnderlines, 0, 5));
+ WebInputMethodController* activeInputMethodController =
+ frame->frameWidget()->getActiveWebInputMethodController();
+ EXPECT_TRUE(activeInputMethodController->setComposition(
+ "fghij", emptyUnderlines, 0, 5));
frame->setEditableSelectionOffsets(11, 11);
verifySelectionAndComposition(webView, 11, 11, 6, 11, "initial case");
@@ -2677,7 +2724,8 @@ TEST_F(WebViewTest, CompositionNotCancelledByBackspace) {
webView->handleInputEvent(keyEvent);
frame->setEditableSelectionOffsets(6, 6);
- EXPECT_TRUE(webView->setComposition("fghi", emptyUnderlines, 0, 4));
+ EXPECT_TRUE(activeInputMethodController->setComposition(
+ "fghi", emptyUnderlines, 0, 4));
frame->setEditableSelectionOffsets(10, 10);
verifySelectionAndComposition(webView, 10, 10, 6, 10,
"after pressing Backspace");
@@ -2701,13 +2749,15 @@ TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) {
WebLocalFrameImpl* frame = webView->mainFrameImpl();
frame->setAutofillClient(&client);
webView->setInitialFocus(false);
-
+ WebInputMethodController* activeInputMethodController =
+ frame->frameWidget()->getActiveWebInputMethodController();
// Set up a composition that needs to be committed.
std::string compositionText("testingtext");
WebVector<WebCompositionUnderline> emptyUnderlines;
- webView->setComposition(WebString::fromUTF8(compositionText.c_str()),
- emptyUnderlines, 0, compositionText.length());
+ activeInputMethodController->setComposition(
+ WebString::fromUTF8(compositionText.c_str()), emptyUnderlines, 0,
+ compositionText.length());
WebTextInputInfo info = webView->textInputInfo();
EXPECT_EQ(0, info.selectionStart);
@@ -2716,7 +2766,8 @@ TEST_F(WebViewTest, FinishComposingTextTriggersAutofillTextChange) {
EXPECT_EQ((int)compositionText.length(), info.compositionEnd);
client.clearChangeCounts();
- webView->finishComposingText(WebWidget::KeepSelection);
+ activeInputMethodController->finishComposingText(
+ WebInputMethodController::KeepSelection);
EXPECT_EQ(0, client.textChangesWhileIgnored());
EXPECT_EQ(1, client.textChangesWhileNotIgnored());
@@ -3470,6 +3521,8 @@ TEST_F(WebViewTest, NonUserInputTextUpdate) {
WebLocalFrameImpl* frame = webViewImpl->mainFrameImpl();
Document* document = frame->frame()->document();
+ WebInputMethodController* activeInputMethodController =
+ frame->frameWidget()->getActiveWebInputMethodController();
// (A) <input>
// (A.1) Focused and value is changed by script.
@@ -3495,8 +3548,10 @@ TEST_F(WebViewTest, NonUserInputTextUpdate) {
EXPECT_FALSE(client.textIsUpdated());
WebVector<WebCompositionUnderline> emptyUnderlines;
- webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1);
- webViewImpl->finishComposingText(WebWidget::KeepSelection);
+ activeInputMethodController->setComposition(WebString::fromUTF8("2"),
+ emptyUnderlines, 1, 1);
+ activeInputMethodController->finishComposingText(
+ WebInputMethodController::KeepSelection);
EXPECT_FALSE(client.textIsUpdated());
info = webViewImpl->textInputInfo();
EXPECT_EQ("testA2", std::string(info.value.utf8().data()));
@@ -3529,8 +3584,10 @@ TEST_F(WebViewTest, NonUserInputTextUpdate) {
// (B.2) Focused and user input modifies value.
client.reset();
EXPECT_FALSE(client.textIsUpdated());
- webViewImpl->setComposition(WebString::fromUTF8("2"), emptyUnderlines, 1, 1);
- webViewImpl->finishComposingText(WebWidget::KeepSelection);
+ activeInputMethodController->setComposition(WebString::fromUTF8("2"),
+ emptyUnderlines, 1, 1);
+ activeInputMethodController->finishComposingText(
+ WebInputMethodController::KeepSelection);
info = webViewImpl->textInputInfo();
EXPECT_EQ("testB2", std::string(info.value.utf8().data()));
@@ -3631,8 +3688,9 @@ TEST_F(WebViewTest, CompositionIsUserGesture) {
webView->setInitialFocus(false);
EXPECT_TRUE(
- webView->setComposition(WebString::fromUTF8(std::string("hello").c_str()),
- WebVector<WebCompositionUnderline>(), 3, 3));
+ frame->frameWidget()->getActiveWebInputMethodController()->setComposition(
+ WebString::fromUTF8(std::string("hello").c_str()),
+ WebVector<WebCompositionUnderline>(), 3, 3));
EXPECT_EQ(1, client.textChangesFromUserGesture());
EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
EXPECT_TRUE(frame->hasMarkedText());
@@ -4030,8 +4088,9 @@ TEST_F(WebViewTest, PasswordFieldEditingIsUserGesture) {
frame->setAutofillClient(&client);
webView->setInitialFocus(false);
- EXPECT_TRUE(webView->commitText(
- WebString::fromUTF8(std::string("hello").c_str()), 0));
+ EXPECT_TRUE(
+ frame->frameWidget()->getActiveWebInputMethodController()->commitText(
+ WebString::fromUTF8(std::string("hello").c_str()), 0));
EXPECT_EQ(1, client.textChangesFromUserGesture());
EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
frame->setAutofillClient(0);

Powered by Google App Engine
This is Rietveld 408576698