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

Unified Diff: Source/web/tests/WebPluginContainerTest.cpp

Issue 629823002: Keyboard Shortkey for ctrl+insert is not working. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changes for meta key in mac os. Created 6 years, 2 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
« no previous file with comments | « Source/web/WebPluginContainerImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebPluginContainerTest.cpp
diff --git a/Source/web/tests/WebPluginContainerTest.cpp b/Source/web/tests/WebPluginContainerTest.cpp
index 2f8c616d6b3f4668d92300652d7e73b9a2c9c61e..e8751b9bf43fc5264911c74d0a2abca02f8bd935 100644
--- a/Source/web/tests/WebPluginContainerTest.cpp
+++ b/Source/web/tests/WebPluginContainerTest.cpp
@@ -32,7 +32,10 @@
#include "public/web/WebPluginContainer.h"
#include "core/dom/Element.h"
+#include "core/events/KeyboardEvent.h"
#include "core/testing/URLTestHelpers.h"
+#include "platform/PlatformEvent.h"
+#include "platform/PlatformKeyboardEvent.h"
#include "public/platform/Platform.h"
#include "public/platform/WebClipboard.h"
#include "public/platform/WebThread.h"
@@ -176,4 +179,38 @@ TEST_F(WebPluginContainerTest, Copy)
EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
}
+// Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to
+// the clipboard.
+TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(
+ WebString::fromUTF8(m_baseURL.c_str()),
+ WebString::fromUTF8("plugin_container.html"));
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, new TestPluginWebFrameClient());
+ ASSERT(webView);
+ webView->settings()->setPluginsEnabled(true);
+ webView->resize(WebSize(300, 300));
+ webView->layout();
+ FrameTestHelpers::runPendingTasks();
+
+ WebElement pluginContainerOneElement = webView->mainFrame()->document().getElementById(WebString::fromUTF8("translated-plugin"));
+ PlatformEvent::Modifiers modifierKey = PlatformEvent::CtrlKey;
+#if OS(MACOSX)
+ modifierKey = PlatformEvent::MetaKey;
+#endif
+ PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "", "", "67", 67, 0, false, false, false, modifierKey, 0.0);
+ RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platformKeyboardEventC, 0);
+ ((WebPluginContainerImpl*)(pluginContainerOneElement.pluginContainer()))->handleEvent(keyEventC.get());
+ EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
+
+ // Clearing |Clipboard::Buffer()|.
+ Platform::current()->clipboard()->writePlainText(WebString(""));
+ EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
+
+ PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown, "", "", "45", 45, 0, false, false, false, modifierKey, 0.0);
+ RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(platformKeyboardEventInsert, 0);
+ ((WebPluginContainerImpl*)(pluginContainerOneElement.pluginContainer()))->handleEvent(keyEventInsert.get());
+ EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
+}
}
« no previous file with comments | « Source/web/WebPluginContainerImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698