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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « Source/web/WebPluginContainerImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "public/web/WebPluginContainer.h" 32 #include "public/web/WebPluginContainer.h"
33 33
34 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
35 #include "core/events/KeyboardEvent.h"
35 #include "core/testing/URLTestHelpers.h" 36 #include "core/testing/URLTestHelpers.h"
37 #include "platform/PlatformEvent.h"
38 #include "platform/PlatformKeyboardEvent.h"
36 #include "public/platform/Platform.h" 39 #include "public/platform/Platform.h"
37 #include "public/platform/WebClipboard.h" 40 #include "public/platform/WebClipboard.h"
38 #include "public/platform/WebThread.h" 41 #include "public/platform/WebThread.h"
39 #include "public/platform/WebUnitTestSupport.h" 42 #include "public/platform/WebUnitTestSupport.h"
40 #include "public/web/WebDocument.h" 43 #include "public/web/WebDocument.h"
41 #include "public/web/WebElement.h" 44 #include "public/web/WebElement.h"
42 #include "public/web/WebFrame.h" 45 #include "public/web/WebFrame.h"
43 #include "public/web/WebFrameClient.h" 46 #include "public/web/WebFrameClient.h"
44 #include "public/web/WebPluginParams.h" 47 #include "public/web/WebPluginParams.h"
45 #include "public/web/WebSettings.h" 48 #include "public/web/WebSettings.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 webView->settings()->setPluginsEnabled(true); 172 webView->settings()->setPluginsEnabled(true);
170 webView->resize(WebSize(300, 300)); 173 webView->resize(WebSize(300, 300));
171 webView->layout(); 174 webView->layout();
172 FrameTestHelpers::runPendingTasks(); 175 FrameTestHelpers::runPendingTasks();
173 176
174 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin")); 177 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin"));
175 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOne Element)); 178 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOne Element));
176 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We bClipboard::Buffer())); 179 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We bClipboard::Buffer()));
177 } 180 }
178 181
182 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to
183 // the clipboard.
184 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest)
185 {
186 URLTestHelpers::registerMockedURLFromBaseURL(
187 WebString::fromUTF8(m_baseURL.c_str()),
188 WebString::fromUTF8("plugin_container.html"));
189 FrameTestHelpers::WebViewHelper webViewHelper;
190 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta iner.html", true, new TestPluginWebFrameClient());
191 ASSERT(webView);
192 webView->settings()->setPluginsEnabled(true);
193 webView->resize(WebSize(300, 300));
194 webView->layout();
195 FrameTestHelpers::runPendingTasks();
196
197 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin"));
198 PlatformEvent::Modifiers modifierKey = PlatformEvent::CtrlKey;
199 #if OS(MACOSX)
200 modifierKey = PlatformEvent::MetaKey;
201 #endif
202 PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "", "", "67", 67, 0, false, false, false, modifierKey, 0.0);
203 RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platform KeyboardEventC, 0);
204 ((WebPluginContainerImpl*)(pluginContainerOneElement.pluginContainer()))->ha ndleEvent(keyEventC.get());
205 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We bClipboard::Buffer()));
206
207 // Clearing |Clipboard::Buffer()|.
208 Platform::current()->clipboard()->writePlainText(WebString(""));
209 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web Clipboard::Buffer()));
210
211 PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown, "", "", "45", 45, 0, false, false, false, modifierKey, 0.0);
212 RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(pla tformKeyboardEventInsert, 0);
213 ((WebPluginContainerImpl*)(pluginContainerOneElement.pluginContainer()))->ha ndleEvent(keyEventInsert.get());
214 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We bClipboard::Buffer()));
179 } 215 }
216 }
OLDNEW
« 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