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

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

Issue 2709813007: Remove WebViewClient::showVirtualKeyboardOnElementFocus() (Closed)
Patch Set: Rebased Created 3 years, 10 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
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index c2d05760f89da2d2a59c6ff65d6c3f7cecc93e44..a5dea41b5e54565e0192829fd60d7947243d4441 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -11412,4 +11412,43 @@ TEST_F(WebFrameTest, ClearClosedOpener) {
EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener());
}
+class ShowVirtualKeyboardObserverWidgetClient
+ : public FrameTestHelpers::TestWebWidgetClient {
+ public:
+ ShowVirtualKeyboardObserverWidgetClient() : m_didShowVirtualKeyboard(false) {}
+
+ void showVirtualKeyboardOnElementFocus() override {
+ m_didShowVirtualKeyboard = true;
+ }
+
+ bool didShowVirtualKeyboard() const { return m_didShowVirtualKeyboard; }
+
+ private:
+ bool m_didShowVirtualKeyboard;
+};
+
+TEST_F(WebFrameTest, ShowVirtualKeyboardOnElementFocus) {
+ FrameTestHelpers::TestWebViewClient viewClient;
+ WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible);
+
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
+ view->setMainFrame(remoteClient.frame());
+
+ ShowVirtualKeyboardObserverWidgetClient childWidgetClient;
+ WebLocalFrameImpl* childFrame = FrameTestHelpers::createLocalChild(
+ view->mainFrame()->toWebRemoteFrame(), WebString(), nullptr,
+ &childWidgetClient);
+ EXPECT_EQ(childFrame, view->focusedFrame());
+
+ // Simulate an input element focus leading to Element::focus() call with a
+ // user gesture.
+ static_cast<WebViewImpl*>(view)
+ ->chromeClient()
+ .showVirtualKeyboardOnElementFocus(childFrame->frame());
+
+ // Verify that the right WebWidgetClient has been notified.
+ EXPECT_TRUE(childWidgetClient.didShowVirtualKeyboard());
+ view->close();
dcheng 2017/02/23 19:28:48 FWIW, I don't think this unit test adds much and w
EhsanK 2017/02/23 21:06:09 I agree with not having the test. I intended to lo
dcheng 2017/02/23 21:10:21 One option is to use the helpers from FrameTestHel
EhsanK 2017/02/27 16:59:56 Thanks! I also had to make it a proper WebFrameSwa
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/web/tests/ImeOnFocusTest.cpp ('k') | third_party/WebKit/public/web/WebViewClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698