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 WebInputEvent::kTimeStampForTesting); | 648 WebTouchEvent event(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers, |
649 WebRect rect = plugin_container_one_element.BoundsInViewport(); | 649 WebInputEvent::kTimeStampForTesting); |
650 event.touches_length = 1; | 650 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
651 event.touches[0].state = WebTouchPoint::kStatePressed; | 651 event.touches_length = 1; |
652 event.touches[0].SetPositionInWidget(rect.x + rect.width / 2, | 652 event.touches[0].state = WebTouchPoint::kStatePressed; |
653 rect.y + rect.height / 2); | 653 event.touches[0].SetPositionInWidget(rect.x + rect.width / 2, |
| 654 rect.y + rect.height / 2); |
654 | 655 |
655 WebCoalescedInputEvent coalesced_event(event); | 656 WebCoalescedInputEvent coalesced_event(event); |
656 | 657 |
657 WebTouchEvent c_event(WebInputEvent::kTouchMove, WebInputEvent::kNoModifiers, | 658 web_view->HandleInputEvent(coalesced_event); |
| 659 RunPendingTasks(); |
| 660 |
| 661 EXPECT_EQ(static_cast<const size_t>(1), |
| 662 test_plugin->GetCoalescedEventCount()); |
| 663 EXPECT_EQ(WebInputEvent::kTouchStart, test_plugin->GetLastInputEventType()); |
| 664 EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X()); |
| 665 EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y()); |
| 666 } |
| 667 |
| 668 { |
| 669 WebTouchEvent event(WebInputEvent::kTouchMove, WebInputEvent::kNoModifiers, |
658 WebInputEvent::kTimeStampForTesting); | 670 WebInputEvent::kTimeStampForTesting); |
659 c_event.touches_length = 1; | 671 WebRect rect = plugin_container_one_element.BoundsInViewport(); |
660 c_event.touches[0].state = WebTouchPoint::kStatePressed; | 672 event.touches_length = 1; |
661 c_event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 1, | 673 event.touches[0].state = WebTouchPoint::kStateMoved; |
| 674 event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 1, |
662 rect.y + rect.height / 2 + 1); | 675 rect.y + rect.height / 2 + 1); |
663 | 676 |
664 coalesced_event.AddCoalescedEvent(c_event); | 677 WebCoalescedInputEvent coalesced_event(event); |
665 c_event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 2, | |
666 rect.y + rect.height / 2 + 2); | |
667 coalesced_event.AddCoalescedEvent(c_event); | |
668 | 678 |
669 web_view->HandleInputEvent(coalesced_event); | 679 WebTouchEvent c_event(WebInputEvent::kTouchMove, |
670 RunPendingTasks(); | 680 WebInputEvent::kNoModifiers, |
| 681 WebInputEvent::kTimeStampForTesting); |
| 682 c_event.touches_length = 1; |
| 683 c_event.touches[0].state = WebTouchPoint::kStateMoved; |
| 684 c_event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 2, |
| 685 rect.y + rect.height / 2 + 2); |
671 | 686 |
672 EXPECT_EQ(static_cast<const size_t>(3), | 687 coalesced_event.AddCoalescedEvent(c_event); |
673 test_plugin->GetCoalescedEventCount()); | 688 c_event.touches[0].SetPositionInWidget(rect.x + rect.width / 2 + 3, |
674 EXPECT_EQ(WebInputEvent::kTouchStart, test_plugin->GetLastInputEventType()); | 689 rect.y + rect.height / 2 + 3); |
675 EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X()); | 690 coalesced_event.AddCoalescedEvent(c_event); |
676 EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y()); | 691 |
| 692 web_view->HandleInputEvent(coalesced_event); |
| 693 RunPendingTasks(); |
| 694 |
| 695 EXPECT_EQ(static_cast<const size_t>(3), |
| 696 test_plugin->GetCoalescedEventCount()); |
| 697 EXPECT_EQ(WebInputEvent::kTouchMove, test_plugin->GetLastInputEventType()); |
| 698 EXPECT_EQ(rect.width / 2 + 1, test_plugin->GetLastEventLocation().X()); |
| 699 EXPECT_EQ(rect.height / 2 + 1, test_plugin->GetLastEventLocation().Y()); |
| 700 } |
677 } | 701 } |
678 | 702 |
679 TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) { | 703 TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) { |
680 RegisterMockedURL("plugin_scroll.html"); | 704 RegisterMockedURL("plugin_scroll.html"); |
681 CustomPluginWebFrameClient<EventTestPlugin> | 705 CustomPluginWebFrameClient<EventTestPlugin> |
682 plugin_web_frame_client; // Must outlive webViewHelper. | 706 plugin_web_frame_client; // Must outlive webViewHelper. |
683 FrameTestHelpers::WebViewHelper web_view_helper; | 707 FrameTestHelpers::WebViewHelper web_view_helper; |
684 WebView* web_view = web_view_helper.InitializeAndLoad( | 708 WebView* web_view = web_view_helper.InitializeAndLoad( |
685 base_url_ + "plugin_scroll.html", true, &plugin_web_frame_client); | 709 base_url_ + "plugin_scroll.html", true, &plugin_web_frame_client); |
686 DCHECK(web_view); | 710 DCHECK(web_view); |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 web_view->MainFrame()->GetDocument().GetElementById( | 1152 web_view->MainFrame()->GetDocument().GetElementById( |
1129 WebString::FromUTF8("translated-plugin")); | 1153 WebString::FromUTF8("translated-plugin")); |
1130 plugin_container_one_element.PluginContainer()->SetWantsWheelEvents(true); | 1154 plugin_container_one_element.PluginContainer()->SetWantsWheelEvents(true); |
1131 | 1155 |
1132 RunPendingTasks(); | 1156 RunPendingTasks(); |
1133 EXPECT_TRUE(web_view->GetPage()->GetEventHandlerRegistry().HasEventHandlers( | 1157 EXPECT_TRUE(web_view->GetPage()->GetEventHandlerRegistry().HasEventHandlers( |
1134 EventHandlerRegistry::kWheelEventBlocking)); | 1158 EventHandlerRegistry::kWheelEventBlocking)); |
1135 } | 1159 } |
1136 | 1160 |
1137 } // namespace blink | 1161 } // namespace blink |
OLD | NEW |