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

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

Issue 2709813007: Remove WebViewClient::showVirtualKeyboardOnElementFocus() (Closed)
Patch Set: Addressing dcheng@'s comments Created 3 years, 9 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 a2fd5bc6e1f81b9c860c8f5171e9396187ed86b3..64fbcc02897a329f11a7b7d62002615f6eb1eae1 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -11415,4 +11415,50 @@ 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::WebViewHelper webViewHelper;
+ WebViewImpl* webView = webViewHelper.initialize(true);
+ WebRemoteFrameImpl* remoteFrame = static_cast<WebRemoteFrameImpl*>(
+ WebRemoteFrame::create(WebTreeScopeType::Document, nullptr));
+ webView->setMainFrame(remoteFrame);
+ RefPtr<SecurityOrigin> uniqueOrigin = SecurityOrigin::createUnique();
+ remoteFrame->frame()->securityContext()->setSecurityOrigin(uniqueOrigin);
+
+ ShowVirtualKeyboardObserverWidgetClient webWidgetClient;
+ WebLocalFrameImpl* localFrame = FrameTestHelpers::createLocalChild(
+ remoteFrame, "child", nullptr, &webWidgetClient);
+
+ 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());
+
+ remoteFrame->close();
+ webViewHelper.reset();
+}
+
} // 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