| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 webView->resize(WebSize(300, 300)); | 365 webView->resize(WebSize(300, 300)); |
| 366 webView->updateAllLifecyclePhases(); | 366 webView->updateAllLifecyclePhases(); |
| 367 runPendingTasks(); | 367 runPendingTasks(); |
| 368 | 368 |
| 369 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, | 369 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, |
| 370 WebMouseEvent::Button::Right, | 370 WebMouseEvent::Button::Right, |
| 371 WebPoint(30, 30), 0); | 371 WebPoint(30, 30), 0); |
| 372 event.clickCount = 1; | 372 event.clickCount = 1; |
| 373 | 373 |
| 374 // Make sure the right-click + Copy works in common scenario. | 374 // Make sure the right-click + Copy works in common scenario. |
| 375 webView->handleInputEvent(event); | 375 webView->handleInputEvent(WebCoalescedInputEvent(event)); |
| 376 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->executeCommand("Copy")); | 376 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->executeCommand("Copy")); |
| 377 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText( | 377 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText( |
| 378 WebClipboard::Buffer())); | 378 WebClipboard::Buffer())); |
| 379 | 379 |
| 380 // Clear the clipboard buffer. | 380 // Clear the clipboard buffer. |
| 381 Platform::current()->clipboard()->writePlainText(WebString("")); | 381 Platform::current()->clipboard()->writePlainText(WebString("")); |
| 382 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText( | 382 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText( |
| 383 WebClipboard::Buffer())); | 383 WebClipboard::Buffer())); |
| 384 | 384 |
| 385 // Now, let's try a more complex scenario: | 385 // Now, let's try a more complex scenario: |
| 386 // 1) open the context menu. This will focus the plugin. | 386 // 1) open the context menu. This will focus the plugin. |
| 387 webView->handleInputEvent(event); | 387 webView->handleInputEvent(WebCoalescedInputEvent(event)); |
| 388 // 2) document blurs the plugin, because it can. | 388 // 2) document blurs the plugin, because it can. |
| 389 webView->clearFocusedElement(); | 389 webView->clearFocusedElement(); |
| 390 // 3) Copy should still operate on the context node, even though the focus had | 390 // 3) Copy should still operate on the context node, even though the focus had |
| 391 // shifted. | 391 // shifted. |
| 392 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->executeCommand("Copy")); | 392 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->executeCommand("Copy")); |
| 393 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText( | 393 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText( |
| 394 WebClipboard::Buffer())); | 394 WebClipboard::Buffer())); |
| 395 } | 395 } |
| 396 | 396 |
| 397 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to | 397 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 WebGestureEvent event(WebInputEvent::GestureLongPress, | 501 WebGestureEvent event(WebInputEvent::GestureLongPress, |
| 502 WebInputEvent::NoModifiers, | 502 WebInputEvent::NoModifiers, |
| 503 WebInputEvent::TimeStampForTesting); | 503 WebInputEvent::TimeStampForTesting); |
| 504 event.sourceDevice = WebGestureDeviceTouchscreen; | 504 event.sourceDevice = WebGestureDeviceTouchscreen; |
| 505 | 505 |
| 506 // First, send an event that doesn't hit the plugin to verify that the | 506 // First, send an event that doesn't hit the plugin to verify that the |
| 507 // plugin doesn't receive it. | 507 // plugin doesn't receive it. |
| 508 event.x = 0; | 508 event.x = 0; |
| 509 event.y = 0; | 509 event.y = 0; |
| 510 | 510 |
| 511 webView->handleInputEvent(event); | 511 webView->handleInputEvent(WebCoalescedInputEvent(event)); |
| 512 runPendingTasks(); | 512 runPendingTasks(); |
| 513 | 513 |
| 514 EXPECT_EQ(WebInputEvent::Undefined, testPlugin->getLastInputEventType()); | 514 EXPECT_EQ(WebInputEvent::Undefined, testPlugin->getLastInputEventType()); |
| 515 | 515 |
| 516 // Next, send an event that does hit the plugin, and verify it does receive | 516 // Next, send an event that does hit the plugin, and verify it does receive |
| 517 // it. | 517 // it. |
| 518 WebRect rect = pluginContainerOneElement.boundsInViewport(); | 518 WebRect rect = pluginContainerOneElement.boundsInViewport(); |
| 519 event.x = rect.x + rect.width / 2; | 519 event.x = rect.x + rect.width / 2; |
| 520 event.y = rect.y + rect.height / 2; | 520 event.y = rect.y + rect.height / 2; |
| 521 | 521 |
| 522 webView->handleInputEvent(event); | 522 webView->handleInputEvent(WebCoalescedInputEvent(event)); |
| 523 runPendingTasks(); | 523 runPendingTasks(); |
| 524 | 524 |
| 525 EXPECT_EQ(WebInputEvent::GestureLongPress, | 525 EXPECT_EQ(WebInputEvent::GestureLongPress, |
| 526 testPlugin->getLastInputEventType()); | 526 testPlugin->getLastInputEventType()); |
| 527 } | 527 } |
| 528 | 528 |
| 529 TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) { | 529 TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) { |
| 530 URLTestHelpers::registerMockedURLFromBaseURL( | 530 URLTestHelpers::registerMockedURLFromBaseURL( |
| 531 WebString::fromUTF8(m_baseURL.c_str()), | 531 WebString::fromUTF8(m_baseURL.c_str()), |
| 532 WebString::fromUTF8("plugin_container.html")); | 532 WebString::fromUTF8("plugin_container.html")); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 550 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin); | 550 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin); |
| 551 | 551 |
| 552 WebMouseWheelEvent event(WebInputEvent::MouseWheel, | 552 WebMouseWheelEvent event(WebInputEvent::MouseWheel, |
| 553 WebInputEvent::NoModifiers, | 553 WebInputEvent::NoModifiers, |
| 554 WebInputEvent::TimeStampForTesting); | 554 WebInputEvent::TimeStampForTesting); |
| 555 | 555 |
| 556 WebRect rect = pluginContainerOneElement.boundsInViewport(); | 556 WebRect rect = pluginContainerOneElement.boundsInViewport(); |
| 557 event.x = rect.x + rect.width / 2; | 557 event.x = rect.x + rect.width / 2; |
| 558 event.y = rect.y + rect.height / 2; | 558 event.y = rect.y + rect.height / 2; |
| 559 | 559 |
| 560 webView->handleInputEvent(event); | 560 webView->handleInputEvent(WebCoalescedInputEvent(event)); |
| 561 runPendingTasks(); | 561 runPendingTasks(); |
| 562 | 562 |
| 563 EXPECT_EQ(WebInputEvent::MouseWheel, testPlugin->getLastInputEventType()); | 563 EXPECT_EQ(WebInputEvent::MouseWheel, testPlugin->getLastInputEventType()); |
| 564 EXPECT_EQ(rect.width / 2, testPlugin->getLastMouseEventLocation().x()); | 564 EXPECT_EQ(rect.width / 2, testPlugin->getLastMouseEventLocation().x()); |
| 565 EXPECT_EQ(rect.height / 2, testPlugin->getLastMouseEventLocation().y()); | 565 EXPECT_EQ(rect.height / 2, testPlugin->getLastMouseEventLocation().y()); |
| 566 } | 566 } |
| 567 | 567 |
| 568 // Verify that isRectTopmost returns false when the document is detached. | 568 // Verify that isRectTopmost returns false when the document is detached. |
| 569 TEST_F(WebPluginContainerTest, IsRectTopmostTest) { | 569 TEST_F(WebPluginContainerTest, IsRectTopmostTest) { |
| 570 URLTestHelpers::registerMockedURLFromBaseURL( | 570 URLTestHelpers::registerMockedURLFromBaseURL( |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 WebString::fromUTF8("translated-plugin")); | 815 WebString::fromUTF8("translated-plugin")); |
| 816 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); | 816 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); |
| 817 | 817 |
| 818 runPendingTasks(); | 818 runPendingTasks(); |
| 819 EXPECT_TRUE( | 819 EXPECT_TRUE( |
| 820 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers( | 820 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers( |
| 821 EventHandlerRegistry::WheelEventBlocking)); | 821 EventHandlerRegistry::WheelEventBlocking)); |
| 822 } | 822 } |
| 823 | 823 |
| 824 } // namespace blink | 824 } // namespace blink |
| OLD | NEW |