OLD | NEW |
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 class CustomPluginWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 100 class CustomPluginWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
101 public: | 101 public: |
102 WebPlugin* createPlugin(WebLocalFrame* frame, | 102 WebPlugin* createPlugin(WebLocalFrame* frame, |
103 const WebPluginParams& params) override { | 103 const WebPluginParams& params) override { |
104 return new T(frame, params); | 104 return new T(frame, params); |
105 } | 105 } |
106 }; | 106 }; |
107 | 107 |
108 class TestPluginWebFrameClient; | 108 class TestPluginWebFrameClient; |
109 | 109 |
110 // Subclass of FakeWebPlugin that has a selection of 'x' as plain text and 'y' a
s markup text. | 110 // Subclass of FakeWebPlugin that has a selection of 'x' as plain text and 'y' |
| 111 // as markup text. |
111 class TestPlugin : public FakeWebPlugin { | 112 class TestPlugin : public FakeWebPlugin { |
112 public: | 113 public: |
113 TestPlugin(WebFrame* frame, | 114 TestPlugin(WebFrame* frame, |
114 const WebPluginParams& params, | 115 const WebPluginParams& params, |
115 TestPluginWebFrameClient* testClient) | 116 TestPluginWebFrameClient* testClient) |
116 : FakeWebPlugin(frame, params) { | 117 : FakeWebPlugin(frame, params) { |
117 m_testClient = testClient; | 118 m_testClient = testClient; |
118 } | 119 } |
119 | 120 |
120 bool hasSelection() const override { return true; } | 121 bool hasSelection() const override { return true; } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // Clear the clipboard buffer. | 379 // Clear the clipboard buffer. |
379 Platform::current()->clipboard()->writePlainText(WebString("")); | 380 Platform::current()->clipboard()->writePlainText(WebString("")); |
380 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText( | 381 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText( |
381 WebClipboard::Buffer())); | 382 WebClipboard::Buffer())); |
382 | 383 |
383 // Now, let's try a more complex scenario: | 384 // Now, let's try a more complex scenario: |
384 // 1) open the context menu. This will focus the plugin. | 385 // 1) open the context menu. This will focus the plugin. |
385 webView->handleInputEvent(event); | 386 webView->handleInputEvent(event); |
386 // 2) document blurs the plugin, because it can. | 387 // 2) document blurs the plugin, because it can. |
387 webView->clearFocusedElement(); | 388 webView->clearFocusedElement(); |
388 // 3) Copy should still operate on the context node, even though the focus had
shifted. | 389 // 3) Copy should still operate on the context node, even though the focus had |
| 390 // shifted. |
389 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->executeCommand("Copy")); | 391 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->executeCommand("Copy")); |
390 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText( | 392 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText( |
391 WebClipboard::Buffer())); | 393 WebClipboard::Buffer())); |
392 } | 394 } |
393 | 395 |
394 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to | 396 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to |
395 // the clipboard. | 397 // the clipboard. |
396 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) { | 398 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) { |
397 URLTestHelpers::registerMockedURLFromBaseURL( | 399 URLTestHelpers::registerMockedURLFromBaseURL( |
398 WebString::fromUTF8(m_baseURL.c_str()), | 400 WebString::fromUTF8(m_baseURL.c_str()), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 // First, send an event that doesn't hit the plugin to verify that the | 495 // First, send an event that doesn't hit the plugin to verify that the |
494 // plugin doesn't receive it. | 496 // plugin doesn't receive it. |
495 event.x = 0; | 497 event.x = 0; |
496 event.y = 0; | 498 event.y = 0; |
497 | 499 |
498 webView->handleInputEvent(event); | 500 webView->handleInputEvent(event); |
499 runPendingTasks(); | 501 runPendingTasks(); |
500 | 502 |
501 EXPECT_EQ(WebInputEvent::Undefined, testPlugin->getLastInputEventType()); | 503 EXPECT_EQ(WebInputEvent::Undefined, testPlugin->getLastInputEventType()); |
502 | 504 |
503 // Next, send an event that does hit the plugin, and verify it does receive it
. | 505 // Next, send an event that does hit the plugin, and verify it does receive |
| 506 // it. |
504 WebRect rect = pluginContainerOneElement.boundsInViewport(); | 507 WebRect rect = pluginContainerOneElement.boundsInViewport(); |
505 event.x = rect.x + rect.width / 2; | 508 event.x = rect.x + rect.width / 2; |
506 event.y = rect.y + rect.height / 2; | 509 event.y = rect.y + rect.height / 2; |
507 | 510 |
508 webView->handleInputEvent(event); | 511 webView->handleInputEvent(event); |
509 runPendingTasks(); | 512 runPendingTasks(); |
510 | 513 |
511 EXPECT_EQ(WebInputEvent::GestureLongPress, | 514 EXPECT_EQ(WebInputEvent::GestureLongPress, |
512 testPlugin->getLastInputEventType()); | 515 testPlugin->getLastInputEventType()); |
513 } | 516 } |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 WebString::fromUTF8("translated-plugin")); | 769 WebString::fromUTF8("translated-plugin")); |
767 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); | 770 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); |
768 | 771 |
769 runPendingTasks(); | 772 runPendingTasks(); |
770 EXPECT_TRUE( | 773 EXPECT_TRUE( |
771 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers( | 774 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers( |
772 EventHandlerRegistry::WheelEventBlocking)); | 775 EventHandlerRegistry::WheelEventBlocking)); |
773 } | 776 } |
774 | 777 |
775 } // namespace blink | 778 } // namespace blink |
OLD | NEW |