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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2709813007: Remove WebViewClient::showVirtualKeyboardOnElementFocus() (Closed)
Patch Set: Made the test better 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11351 matching lines...) Expand 10 before | Expand all | Expand 10 after
11362 FrameTestHelpers::TestWebViewClient openerWebViewClient; 11362 FrameTestHelpers::TestWebViewClient openerWebViewClient;
11363 FrameTestHelpers::WebViewHelper openerHelper; 11363 FrameTestHelpers::WebViewHelper openerHelper;
11364 openerHelper.initialize(false, nullptr, &openerWebViewClient); 11364 openerHelper.initialize(false, nullptr, &openerWebViewClient);
11365 FrameTestHelpers::WebViewHelper helper; 11365 FrameTestHelpers::WebViewHelper helper;
11366 helper.initializeWithOpener(openerHelper.webView()->mainFrame()); 11366 helper.initializeWithOpener(openerHelper.webView()->mainFrame());
11367 11367
11368 openerHelper.reset(); 11368 openerHelper.reset();
11369 EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener()); 11369 EXPECT_EQ(nullptr, helper.webView()->mainFrameImpl()->opener());
11370 } 11370 }
11371 11371
11372 class ShowVirtualKeyboardObserverWidgetClient
11373 : public FrameTestHelpers::TestWebWidgetClient {
11374 public:
11375 ShowVirtualKeyboardObserverWidgetClient() : m_didShowVirtualKeyboard(false) {}
11376
11377 void showVirtualKeyboardOnElementFocus() override {
11378 m_didShowVirtualKeyboard = true;
11379 }
11380
11381 bool didShowVirtualKeyboard() const { return m_didShowVirtualKeyboard; }
11382
11383 private:
11384 bool m_didShowVirtualKeyboard;
11385 };
11386
11387 TEST_F(WebFrameSwapTest, ShowVirtualKeyboardOnElementFocus) {
11388 WebRemoteFrame* remoteFrame =
11389 WebRemoteFrame::create(WebTreeScopeType::Document, nullptr);
11390 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.
11391
11392 FrameTestHelpers::TestWebFrameClient client;
11393 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(
11394 &client, nullptr, nullptr, remoteFrame, WebSandboxFlags::None);
11395 ShowVirtualKeyboardObserverWidgetClient webWidgetClient;
11396 WebFrameWidget::create(&webWidgetClient, localFrame);
11397 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.
11398
11399 registerMockedHttpURLLoad("input_field_default.html");
11400 FrameTestHelpers::loadFrame(localFrame,
11401 m_baseURL + "input_field_default.html");
11402
11403 // Simulate an input element focus leading to Element::focus() call with a
11404 // user gesture.
11405 localFrame->setHasReceivedUserGesture();
11406 localFrame->executeScript(
11407 WebScriptSource("window.focus();"
11408 "document.querySelector('input').focus();"));
11409
11410 // Verify that the right WebWidgetClient has been notified.
11411 EXPECT_TRUE(webWidgetClient.didShowVirtualKeyboard());
11412
11413 reset();
11414 remoteFrame->close();
11415 }
11416
11372 } // namespace blink 11417 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698