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

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

Issue 2586133003: Remove PlatformWheelEvent and use WebMouseWheelEvent instead (Closed)
Patch Set: Adjust function name Created 3 years, 11 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) 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 30 matching lines...) Expand all
41 #include "platform/graphics/paint/CullRect.h" 41 #include "platform/graphics/paint/CullRect.h"
42 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" 42 #include "platform/graphics/paint/ForeignLayerDisplayItem.h"
43 #include "platform/graphics/paint/PaintController.h" 43 #include "platform/graphics/paint/PaintController.h"
44 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 44 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
45 #include "platform/testing/URLTestHelpers.h" 45 #include "platform/testing/URLTestHelpers.h"
46 #include "platform/testing/UnitTestHelpers.h" 46 #include "platform/testing/UnitTestHelpers.h"
47 #include "public/platform/Platform.h" 47 #include "public/platform/Platform.h"
48 #include "public/platform/WebClipboard.h" 48 #include "public/platform/WebClipboard.h"
49 #include "public/platform/WebCompositorSupport.h" 49 #include "public/platform/WebCompositorSupport.h"
50 #include "public/platform/WebLayer.h" 50 #include "public/platform/WebLayer.h"
51 #include "public/platform/WebMouseWheelEvent.h"
51 #include "public/platform/WebThread.h" 52 #include "public/platform/WebThread.h"
52 #include "public/platform/WebURLLoaderMockFactory.h" 53 #include "public/platform/WebURLLoaderMockFactory.h"
53 #include "public/web/WebCache.h" 54 #include "public/web/WebCache.h"
54 #include "public/web/WebDocument.h" 55 #include "public/web/WebDocument.h"
55 #include "public/web/WebElement.h" 56 #include "public/web/WebElement.h"
56 #include "public/web/WebFrame.h" 57 #include "public/web/WebFrame.h"
57 #include "public/web/WebFrameClient.h" 58 #include "public/web/WebFrameClient.h"
58 #include "public/web/WebPluginParams.h" 59 #include "public/web/WebPluginParams.h"
59 #include "public/web/WebPrintParams.h" 60 #include "public/web/WebPrintParams.h"
60 #include "public/web/WebSettings.h" 61 #include "public/web/WebSettings.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // A class to facilitate testing that events are correctly received by plugins. 450 // A class to facilitate testing that events are correctly received by plugins.
450 class EventTestPlugin : public FakeWebPlugin { 451 class EventTestPlugin : public FakeWebPlugin {
451 public: 452 public:
452 EventTestPlugin(WebFrame* frame, const WebPluginParams& params) 453 EventTestPlugin(WebFrame* frame, const WebPluginParams& params)
453 : FakeWebPlugin(frame, params), 454 : FakeWebPlugin(frame, params),
454 m_lastEventType(WebInputEvent::Undefined) {} 455 m_lastEventType(WebInputEvent::Undefined) {}
455 456
456 WebInputEventResult handleInputEvent(const WebInputEvent& event, 457 WebInputEventResult handleInputEvent(const WebInputEvent& event,
457 WebCursorInfo&) override { 458 WebCursorInfo&) override {
458 m_lastEventType = event.type; 459 m_lastEventType = event.type;
460 if (WebInputEvent::isMouseEventType(event.type) ||
461 event.type == WebInputEvent::MouseWheel) {
462 const WebMouseEvent& mouseEvent =
463 static_cast<const WebMouseEvent&>(event);
464 m_lastMouseEventLocation = IntPoint(mouseEvent.x, mouseEvent.y);
465 }
466
459 return WebInputEventResult::HandledSystem; 467 return WebInputEventResult::HandledSystem;
460 } 468 }
461 WebInputEvent::Type getLastInputEventType() { return m_lastEventType; } 469 WebInputEvent::Type getLastInputEventType() { return m_lastEventType; }
462 470
471 IntPoint getLastMouseEventLocation() { return m_lastMouseEventLocation; }
472
463 private: 473 private:
464 WebInputEvent::Type m_lastEventType; 474 WebInputEvent::Type m_lastEventType;
475 IntPoint m_lastMouseEventLocation;
465 }; 476 };
466 477
467 TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) { 478 TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {
468 URLTestHelpers::registerMockedURLFromBaseURL( 479 URLTestHelpers::registerMockedURLFromBaseURL(
469 WebString::fromUTF8(m_baseURL.c_str()), 480 WebString::fromUTF8(m_baseURL.c_str()),
470 WebString::fromUTF8("plugin_container.html")); 481 WebString::fromUTF8("plugin_container.html"));
471 CustomPluginWebFrameClient<EventTestPlugin> 482 CustomPluginWebFrameClient<EventTestPlugin>
472 pluginWebFrameClient; // Must outlive webViewHelper. 483 pluginWebFrameClient; // Must outlive webViewHelper.
473 FrameTestHelpers::WebViewHelper webViewHelper; 484 FrameTestHelpers::WebViewHelper webViewHelper;
474 WebView* webView = webViewHelper.initializeAndLoad( 485 WebView* webView = webViewHelper.initializeAndLoad(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 event.x = rect.x + rect.width / 2; 519 event.x = rect.x + rect.width / 2;
509 event.y = rect.y + rect.height / 2; 520 event.y = rect.y + rect.height / 2;
510 521
511 webView->handleInputEvent(event); 522 webView->handleInputEvent(event);
512 runPendingTasks(); 523 runPendingTasks();
513 524
514 EXPECT_EQ(WebInputEvent::GestureLongPress, 525 EXPECT_EQ(WebInputEvent::GestureLongPress,
515 testPlugin->getLastInputEventType()); 526 testPlugin->getLastInputEventType());
516 } 527 }
517 528
529 TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) {
530 URLTestHelpers::registerMockedURLFromBaseURL(
531 WebString::fromUTF8(m_baseURL.c_str()),
532 WebString::fromUTF8("plugin_container.html"));
533 CustomPluginWebFrameClient<EventTestPlugin>
534 pluginWebFrameClient; // Must outlive webViewHelper.
535 FrameTestHelpers::WebViewHelper webViewHelper;
536 WebView* webView = webViewHelper.initializeAndLoad(
537 m_baseURL + "plugin_container.html", true, &pluginWebFrameClient);
538 DCHECK(webView);
539 webView->settings()->setPluginsEnabled(true);
540 webView->resize(WebSize(300, 300));
541 webView->updateAllLifecyclePhases();
542 runPendingTasks();
543
544 WebElement pluginContainerOneElement =
545 webView->mainFrame()->document().getElementById(
546 WebString::fromUTF8("translated-plugin"));
547 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(
548 pluginContainerOneElement.pluginContainer())
549 ->plugin();
550 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin);
551
552 WebMouseWheelEvent event(WebInputEvent::MouseWheel,
553 WebInputEvent::NoModifiers,
554 WebInputEvent::TimeStampForTesting);
555
556 WebRect rect = pluginContainerOneElement.boundsInViewport();
557 event.x = rect.x + rect.width / 2;
558 event.y = rect.y + rect.height / 2;
559
560 webView->handleInputEvent(event);
561 runPendingTasks();
562
563 EXPECT_EQ(WebInputEvent::MouseWheel, testPlugin->getLastInputEventType());
564 EXPECT_EQ(rect.width / 2, testPlugin->getLastMouseEventLocation().x());
565 EXPECT_EQ(rect.height / 2, testPlugin->getLastMouseEventLocation().y());
566 }
567
518 // Verify that isRectTopmost returns false when the document is detached. 568 // Verify that isRectTopmost returns false when the document is detached.
519 TEST_F(WebPluginContainerTest, IsRectTopmostTest) { 569 TEST_F(WebPluginContainerTest, IsRectTopmostTest) {
520 URLTestHelpers::registerMockedURLFromBaseURL( 570 URLTestHelpers::registerMockedURLFromBaseURL(
521 WebString::fromUTF8(m_baseURL.c_str()), 571 WebString::fromUTF8(m_baseURL.c_str()),
522 WebString::fromUTF8("plugin_container.html")); 572 WebString::fromUTF8("plugin_container.html"));
523 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper. 573 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
524 FrameTestHelpers::WebViewHelper webViewHelper; 574 FrameTestHelpers::WebViewHelper webViewHelper;
525 WebView* webView = webViewHelper.initializeAndLoad( 575 WebView* webView = webViewHelper.initializeAndLoad(
526 m_baseURL + "plugin_container.html", true, &pluginWebFrameClient); 576 m_baseURL + "plugin_container.html", true, &pluginWebFrameClient);
527 DCHECK(webView); 577 DCHECK(webView);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 WebString::fromUTF8("translated-plugin")); 815 WebString::fromUTF8("translated-plugin"));
766 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); 816 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true);
767 817
768 runPendingTasks(); 818 runPendingTasks();
769 EXPECT_TRUE( 819 EXPECT_TRUE(
770 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers( 820 webView->page()->frameHost().eventHandlerRegistry().hasEventHandlers(
771 EventHandlerRegistry::WheelEventBlocking)); 821 EventHandlerRegistry::WheelEventBlocking));
772 } 822 }
773 823
774 } // namespace blink 824 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698