Chromium Code Reviews| 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 |