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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 WebElement plugin_container_one_element = | 637 WebElement plugin_container_one_element = |
638 web_view->MainFrame()->GetDocument().GetElementById( | 638 web_view->MainFrame()->GetDocument().GetElementById( |
639 WebString::FromUTF8("scrolled-plugin")); | 639 WebString::FromUTF8("scrolled-plugin")); |
640 plugin_container_one_element.PluginContainer()->RequestTouchEventType( | 640 plugin_container_one_element.PluginContainer()->RequestTouchEventType( |
641 WebPluginContainer::kTouchEventRequestTypeRaw); | 641 WebPluginContainer::kTouchEventRequestTypeRaw); |
642 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( | 642 WebPlugin* plugin = static_cast<WebPluginContainerBase*>( |
643 plugin_container_one_element.PluginContainer()) | 643 plugin_container_one_element.PluginContainer()) |
644 ->Plugin(); | 644 ->Plugin(); |
645 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); | 645 EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin); |
646 | 646 |
647 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, | 647 { |
648 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, | |
mustaq
2017/06/08 20:02:52
Clarification question: why do we need this?
Navid Zolghadr
2017/06/08 21:18:41
Out code never expects to receive a move coalesced
| |
649 WebInputEvent::kTimeStampForTesting); | |
650 WebRect rect = plugin_container_one_element.BoundsInViewport(); | |
651 event.touches_length = 1; | |
652 event.touches[0].state = WebTouchPoint::kStatePressed; | |
653 event.touches[0].SetPositionInWidget(rect.x + rect.width / 2, | |
654 rect.y + rect.height / 2); | |
655 | |
656 WebCoalescedInputEvent coalesced_event(event); | |
657 | |
658 web_view->HandleInputEvent(coalesced_event); | |
659 RunPendingTasks(); | |
660 } | |
661 | |
662 WebTouchEvent event(WebInputEvent::kTouchMove, WebInputEvent::kNoModifiers, | |
648 WebInputEvent::kTimeStampForTesting); | 663 WebInputEvent::kTimeStampForTesting); |
649 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 664 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
650 event.touches_length = 1; | 665 event.touches_length = 1; |
651 event.touches[0].state = WebTouchPoint::kStatePressed; | 666 event.touches[0].state = WebTouchPoint::kStateMoved; |
652 event.touches[0].SetPositionInWidget(rect.x + rect.width / 2, | 667 event.touches[0].SetPositionInWidget(rect.x + rect.width / 2, |
653 rect.y + rect.height / 2); | 668 rect.y + rect.height / 2); |
654 | 669 |
655 WebCoalescedInputEvent coalesced_event(event); | 670 WebCoalescedInputEvent coalesced_event(event); |
656 | 671 |
657 WebTouchEvent c_event(WebInputEvent::kTouchMove, WebInputEvent::kNoModifiers, | 672 WebTouchEvent c_event(WebInputEvent::kTouchMove, WebInputEvent::kNoModifiers, |
658 WebInputEvent::kTimeStampForTesting); | 673 WebInputEvent::kTimeStampForTesting); |
659 c_event.touches_length = 1; | 674 c_event.touches_length = 1; |
660 c_event.touches[0].state = WebTouchPoint::kStatePressed; | 675 c_event.touches[0].state = WebTouchPoint::kStateMoved; |
661 c_event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 1, | 676 c_event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 1, |
662 rect.y + rect.height / 2 + 1); | 677 rect.y + rect.height / 2 + 1); |
663 | 678 |
664 coalesced_event.AddCoalescedEvent(c_event); | 679 coalesced_event.AddCoalescedEvent(c_event); |
665 c_event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 2, | 680 c_event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 2, |
666 rect.y + rect.height / 2 + 2); | 681 rect.y + rect.height / 2 + 2); |
667 coalesced_event.AddCoalescedEvent(c_event); | 682 coalesced_event.AddCoalescedEvent(c_event); |
668 | 683 |
669 web_view->HandleInputEvent(coalesced_event); | 684 web_view->HandleInputEvent(coalesced_event); |
670 RunPendingTasks(); | 685 RunPendingTasks(); |
671 | 686 |
672 EXPECT_EQ(static_cast<const size_t>(3), | 687 EXPECT_EQ(static_cast<const size_t>(2), |
673 test_plugin->GetCoalescedEventCount()); | 688 test_plugin->GetCoalescedEventCount()); |
674 EXPECT_EQ(WebInputEvent::kTouchStart, test_plugin->GetLastInputEventType()); | 689 EXPECT_EQ(WebInputEvent::kTouchMove, test_plugin->GetLastInputEventType()); |
675 EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X()); | 690 EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X()); |
676 EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y()); | 691 EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y()); |
677 } | 692 } |
678 | 693 |
679 TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) { | 694 TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) { |
680 RegisterMockedURL("plugin_scroll.html"); | 695 RegisterMockedURL("plugin_scroll.html"); |
681 CustomPluginWebFrameClient<EventTestPlugin> | 696 CustomPluginWebFrameClient<EventTestPlugin> |
682 plugin_web_frame_client; // Must outlive webViewHelper. | 697 plugin_web_frame_client; // Must outlive webViewHelper. |
683 FrameTestHelpers::WebViewHelper web_view_helper; | 698 FrameTestHelpers::WebViewHelper web_view_helper; |
684 WebView* web_view = web_view_helper.InitializeAndLoad( | 699 WebView* web_view = web_view_helper.InitializeAndLoad( |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1128 web_view->MainFrame()->GetDocument().GetElementById( | 1143 web_view->MainFrame()->GetDocument().GetElementById( |
1129 WebString::FromUTF8("translated-plugin")); | 1144 WebString::FromUTF8("translated-plugin")); |
1130 plugin_container_one_element.PluginContainer()->SetWantsWheelEvents(true); | 1145 plugin_container_one_element.PluginContainer()->SetWantsWheelEvents(true); |
1131 | 1146 |
1132 RunPendingTasks(); | 1147 RunPendingTasks(); |
1133 EXPECT_TRUE(web_view->GetPage()->GetEventHandlerRegistry().HasEventHandlers( | 1148 EXPECT_TRUE(web_view->GetPage()->GetEventHandlerRegistry().HasEventHandlers( |
1134 EventHandlerRegistry::kWheelEventBlocking)); | 1149 EventHandlerRegistry::kWheelEventBlocking)); |
1135 } | 1150 } |
1136 | 1151 |
1137 } // namespace blink | 1152 } // namespace blink |
OLD | NEW |