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 cd69fcbc7a8f696682725201f1bafdcfe7c99fea..c62c782cdd64973a1f8667184c122b4c1828b0d9 100644 |
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| @@ -11369,4 +11369,49 @@ 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(WebFrameSwapTest, ShowVirtualKeyboardOnElementFocus) { |
| + WebRemoteFrame* remoteFrame = |
| + WebRemoteFrame::create(WebTreeScopeType::Document, nullptr); |
| + mainFrame()->swap(remoteFrame); |
|
dcheng
2017/02/27 23:13:29
Is it possible to create a WebView directly and se
EhsanK
2017/03/08 23:38:28
Done.
|
| + |
| + FrameTestHelpers::TestWebFrameClient client; |
| + WebLocalFrame* localFrame = WebLocalFrame::createProvisional( |
| + &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None); |
| + ShowVirtualKeyboardObserverWidgetClient webWidgetClient; |
| + WebFrameWidget::create(&webWidgetClient, localFrame); |
| + remoteFrame->swap(localFrame); |
|
dcheng
2017/02/27 23:13:29
Is it possible to use FrameTestHelpers::createLoca
EhsanK
2017/03/08 23:38:28
Done.
|
| + |
| + registerMockedHttpURLLoad("input_field_default.html"); |
| + FrameTestHelpers::loadFrame(localFrame, |
| + m_baseURL + "input_field_default.html"); |
| + |
| + // Simulate an input element focus leading to Element::focus() call with a |
| + // user gesture. |
| + localFrame->setHasReceivedUserGesture(); |
| + localFrame->executeScript( |
| + WebScriptSource("window.focus();" |
| + "document.querySelector('input').focus();")); |
| + |
| + // Verify that the right WebWidgetClient has been notified. |
| + EXPECT_TRUE(webWidgetClient.didShowVirtualKeyboard()); |
| + |
| + reset(); |
| + remoteFrame->close(); |
| +} |
| + |
| } // namespace blink |