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")); |