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

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

Issue 103863007: Let WebViewImpl::textInputInfo() query the focused element when selection is empty (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added unit test Created 7 years 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/web/WebViewImpl.cpp ('k') | Source/web/tests/data/input_field_focused.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebViewTest.cpp
diff --git a/Source/web/tests/WebViewTest.cpp b/Source/web/tests/WebViewTest.cpp
index edef35660abc1a0331298e823cd605bc98c2c566..572b76f1a1a3aca9c838637061b049bf102a5df3 100644
--- a/Source/web/tests/WebViewTest.cpp
+++ b/Source/web/tests/WebViewTest.cpp
@@ -234,6 +234,17 @@ protected:
FrameTestHelpers::WebViewHelper m_webViewHelper;
};
+class FocusedNodeChangedObserverWebViewClient : public WebViewClient {
+public:
+ void setWebView(WebView* webView) { m_webView = webView; }
+ WebTextInputInfo textInputInfoOnFocusedNodeChanged() const { return m_textInputInfoOnFocusedNodeChanged; }
+private:
+ void focusedNodeChanged(const WebNode&) OVERRIDE { m_textInputInfoOnFocusedNodeChanged = m_webView->textInputInfo(); }
+
+ WebView* m_webView;
+ WebTextInputInfo m_textInputInfoOnFocusedNodeChanged;
+};
+
TEST_F(WebViewTest, SetBaseBackgroundColor)
{
const WebColor kWhite = 0xFFFFFFFF;
@@ -554,6 +565,21 @@ TEST_F(WebViewTest, ConfirmCompositionCursorPositionChange)
EXPECT_EQ(-1, info.compositionEnd);
}
+TEST_F(WebViewTest, TextInputInfoOnInputFocused)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("input_field_focused.html"));
+ FocusedNodeChangedObserverWebViewClient client;
+ WebView* webView = m_webViewHelper.initialize(true, 0, &client);
+ client.setWebView(webView);
+
+ WebCore::KURL url = toKURL(m_baseURL + "input_field_focused.html");
+ webView->mainFrame()->loadRequest(WebURLRequest(WebURL(url)));
+ Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+
+ WebTextInputInfo info = client.textInputInfoOnFocusedNodeChanged();
+ EXPECT_EQ(WebTextInputTypeText, info.type);
+}
+
TEST_F(WebViewTest, InsertNewLinePlacementAfterConfirmComposition)
{
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("text_area_populated.html"));
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/input_field_focused.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698