| 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 5cf3d886c2f2063ea69db0be24a73080cc397bad..0cfe1b12a8aae8aa25efe1af701d8e0e5deb2446 100644
|
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
|
| @@ -11401,4 +11401,43 @@ TEST_F(WebFrameTest, NoLoadingCompletionCallbacksInDetach) {
|
| webViewHelper.reset();
|
| }
|
|
|
| +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();
|
| +}
|
| +
|
| } // namespace blink
|
|
|