| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/test_runner/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "components/test_runner/mock_spell_check.h" | 16 #include "components/test_runner/mock_spell_check.h" |
| 17 #include "components/test_runner/test_interfaces.h" | 17 #include "components/test_runner/test_interfaces.h" |
| 18 #include "components/test_runner/web_test_delegate.h" | 18 #include "components/test_runner/web_test_delegate.h" |
| 19 #include "components/test_runner/web_test_proxy.h" | 19 #include "components/test_runner/web_test_proxy.h" |
| 20 #include "gin/handle.h" | 20 #include "gin/handle.h" |
| 21 #include "gin/object_template_builder.h" | 21 #include "gin/object_template_builder.h" |
| 22 #include "gin/wrappable.h" | 22 #include "gin/wrappable.h" |
| 23 #include "third_party/WebKit/public/platform/WebPointerProperties.h" |
| 23 #include "third_party/WebKit/public/platform/WebString.h" | 24 #include "third_party/WebKit/public/platform/WebString.h" |
| 24 #include "third_party/WebKit/public/platform/WebVector.h" | 25 #include "third_party/WebKit/public/platform/WebVector.h" |
| 25 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 26 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
| 26 #include "third_party/WebKit/public/web/WebFrame.h" | 27 #include "third_party/WebKit/public/web/WebFrame.h" |
| 27 #include "third_party/WebKit/public/web/WebKit.h" | 28 #include "third_party/WebKit/public/web/WebKit.h" |
| 28 #include "third_party/WebKit/public/web/WebPagePopup.h" | 29 #include "third_party/WebKit/public/web/WebPagePopup.h" |
| 29 #include "third_party/WebKit/public/web/WebView.h" | 30 #include "third_party/WebKit/public/web/WebView.h" |
| 30 #include "ui/events/keycodes/dom/keycode_converter.h" | 31 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 31 #include "ui/events/keycodes/keyboard_codes.h" | 32 #include "ui/events/keycodes/keyboard_codes.h" |
| 32 #include "v8/include/v8.h" | 33 #include "v8/include/v8.h" |
| 33 | 34 |
| 34 using blink::WebContextMenuData; | 35 using blink::WebContextMenuData; |
| 35 using blink::WebDragData; | 36 using blink::WebDragData; |
| 36 using blink::WebDragOperationsMask; | 37 using blink::WebDragOperationsMask; |
| 37 using blink::WebFloatPoint; | 38 using blink::WebFloatPoint; |
| 38 using blink::WebFrame; | 39 using blink::WebFrame; |
| 39 using blink::WebGestureEvent; | 40 using blink::WebGestureEvent; |
| 40 using blink::WebInputEvent; | 41 using blink::WebInputEvent; |
| 41 using blink::WebInputEventResult; | 42 using blink::WebInputEventResult; |
| 42 using blink::WebKeyboardEvent; | 43 using blink::WebKeyboardEvent; |
| 43 using blink::WebMenuItemInfo; | 44 using blink::WebMenuItemInfo; |
| 44 using blink::WebMouseEvent; | 45 using blink::WebMouseEvent; |
| 45 using blink::WebMouseWheelEvent; | 46 using blink::WebMouseWheelEvent; |
| 46 using blink::WebPagePopup; | 47 using blink::WebPagePopup; |
| 47 using blink::WebPoint; | 48 using blink::WebPoint; |
| 49 using blink::WebPointerProperties; |
| 48 using blink::WebString; | 50 using blink::WebString; |
| 49 using blink::WebTouchEvent; | 51 using blink::WebTouchEvent; |
| 50 using blink::WebTouchPoint; | 52 using blink::WebTouchPoint; |
| 51 using blink::WebVector; | 53 using blink::WebVector; |
| 52 using blink::WebView; | 54 using blink::WebView; |
| 53 | 55 |
| 54 namespace test_runner { | 56 namespace test_runner { |
| 55 | 57 |
| 56 namespace { | 58 namespace { |
| 57 | 59 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 float velocity_x, | 489 float velocity_x, |
| 488 float velocity_y, | 490 float velocity_y, |
| 489 gin::Arguments* args); | 491 gin::Arguments* args); |
| 490 bool IsFlinging() const; | 492 bool IsFlinging() const; |
| 491 void GestureScrollFirstPoint(int x, int y); | 493 void GestureScrollFirstPoint(int x, int y); |
| 492 void TouchStart(); | 494 void TouchStart(); |
| 493 void TouchMove(); | 495 void TouchMove(); |
| 494 void TouchMoveCausingScrollIfUncanceled(); | 496 void TouchMoveCausingScrollIfUncanceled(); |
| 495 void TouchCancel(); | 497 void TouchCancel(); |
| 496 void TouchEnd(); | 498 void TouchEnd(); |
| 499 void NotifyStartOfImplScroll(); |
| 500 void NotifyEndOfImplScroll(); |
| 497 void LeapForward(int milliseconds); | 501 void LeapForward(int milliseconds); |
| 498 double LastEventTimestamp(); | 502 double LastEventTimestamp(); |
| 499 void BeginDragWithFiles(const std::vector<std::string>& files); | 503 void BeginDragWithFiles(const std::vector<std::string>& files); |
| 500 void AddTouchPoint(double x, double y, gin::Arguments* args); | 504 void AddTouchPoint(double x, double y, gin::Arguments* args); |
| 501 void MouseDragBegin(); | 505 void MouseDragBegin(); |
| 502 void MouseDragEnd(); | 506 void MouseDragEnd(); |
| 503 void GestureScrollBegin(gin::Arguments* args); | 507 void GestureScrollBegin(gin::Arguments* args); |
| 504 void GestureScrollEnd(gin::Arguments* args); | 508 void GestureScrollEnd(gin::Arguments* args); |
| 505 void GestureScrollUpdate(gin::Arguments* args); | 509 void GestureScrollUpdate(gin::Arguments* args); |
| 506 void GesturePinchBegin(gin::Arguments* args); | 510 void GesturePinchBegin(gin::Arguments* args); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 .SetMethod("setTouchCancelable", &EventSenderBindings::SetTouchCancelable) | 617 .SetMethod("setTouchCancelable", &EventSenderBindings::SetTouchCancelable) |
| 614 .SetMethod("dumpFilenameBeingDragged", | 618 .SetMethod("dumpFilenameBeingDragged", |
| 615 &EventSenderBindings::DumpFilenameBeingDragged) | 619 &EventSenderBindings::DumpFilenameBeingDragged) |
| 616 .SetMethod("gestureFlingCancel", &EventSenderBindings::GestureFlingCancel) | 620 .SetMethod("gestureFlingCancel", &EventSenderBindings::GestureFlingCancel) |
| 617 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) | 621 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) |
| 618 .SetMethod("isFlinging", &EventSenderBindings::IsFlinging) | 622 .SetMethod("isFlinging", &EventSenderBindings::IsFlinging) |
| 619 .SetMethod("gestureScrollFirstPoint", | 623 .SetMethod("gestureScrollFirstPoint", |
| 620 &EventSenderBindings::GestureScrollFirstPoint) | 624 &EventSenderBindings::GestureScrollFirstPoint) |
| 621 .SetMethod("touchStart", &EventSenderBindings::TouchStart) | 625 .SetMethod("touchStart", &EventSenderBindings::TouchStart) |
| 622 .SetMethod("touchMove", &EventSenderBindings::TouchMove) | 626 .SetMethod("touchMove", &EventSenderBindings::TouchMove) |
| 623 .SetMethod("touchMoveCausingScrollIfUncanceled", | |
| 624 &EventSenderBindings::TouchMoveCausingScrollIfUncanceled) | |
| 625 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) | 627 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) |
| 626 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) | 628 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) |
| 629 .SetMethod("notifyStartOfImplScroll", |
| 630 &EventSenderBindings::NotifyStartOfImplScroll) |
| 631 .SetMethod("notifyEndOfImplScroll", |
| 632 &EventSenderBindings::NotifyEndOfImplScroll) |
| 627 .SetMethod("leapForward", &EventSenderBindings::LeapForward) | 633 .SetMethod("leapForward", &EventSenderBindings::LeapForward) |
| 628 .SetMethod("lastEventTimestamp", &EventSenderBindings::LastEventTimestamp) | 634 .SetMethod("lastEventTimestamp", &EventSenderBindings::LastEventTimestamp) |
| 629 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) | 635 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) |
| 630 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) | 636 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) |
| 631 .SetMethod("mouseDragBegin", &EventSenderBindings::MouseDragBegin) | 637 .SetMethod("mouseDragBegin", &EventSenderBindings::MouseDragBegin) |
| 632 .SetMethod("mouseDragEnd", &EventSenderBindings::MouseDragEnd) | 638 .SetMethod("mouseDragEnd", &EventSenderBindings::MouseDragEnd) |
| 633 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) | 639 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) |
| 634 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) | 640 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) |
| 635 .SetMethod("gestureScrollUpdate", | 641 .SetMethod("gestureScrollUpdate", |
| 636 &EventSenderBindings::GestureScrollUpdate) | 642 &EventSenderBindings::GestureScrollUpdate) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 void EventSenderBindings::TouchStart() { | 809 void EventSenderBindings::TouchStart() { |
| 804 if (sender_) | 810 if (sender_) |
| 805 sender_->TouchStart(); | 811 sender_->TouchStart(); |
| 806 } | 812 } |
| 807 | 813 |
| 808 void EventSenderBindings::TouchMove() { | 814 void EventSenderBindings::TouchMove() { |
| 809 if (sender_) | 815 if (sender_) |
| 810 sender_->TouchMove(); | 816 sender_->TouchMove(); |
| 811 } | 817 } |
| 812 | 818 |
| 813 void EventSenderBindings::TouchMoveCausingScrollIfUncanceled() { | |
| 814 if (sender_) | |
| 815 sender_->TouchMoveCausingScrollIfUncanceled(); | |
| 816 } | |
| 817 | |
| 818 void EventSenderBindings::TouchCancel() { | 819 void EventSenderBindings::TouchCancel() { |
| 819 if (sender_) | 820 if (sender_) |
| 820 sender_->TouchCancel(); | 821 sender_->TouchCancel(); |
| 821 } | 822 } |
| 822 | 823 |
| 823 void EventSenderBindings::TouchEnd() { | 824 void EventSenderBindings::TouchEnd() { |
| 824 if (sender_) | 825 if (sender_) |
| 825 sender_->TouchEnd(); | 826 sender_->TouchEnd(); |
| 826 } | 827 } |
| 827 | 828 |
| 829 void EventSenderBindings::NotifyStartOfImplScroll() { |
| 830 if (sender_) |
| 831 sender_->NotifyStartOfImplScroll(); |
| 832 } |
| 833 |
| 834 void EventSenderBindings::NotifyEndOfImplScroll() { |
| 835 if (sender_) |
| 836 sender_->NotifyEndOfImplScroll(); |
| 837 } |
| 838 |
| 828 void EventSenderBindings::LeapForward(int milliseconds) { | 839 void EventSenderBindings::LeapForward(int milliseconds) { |
| 829 if (sender_) | 840 if (sender_) |
| 830 sender_->LeapForward(milliseconds); | 841 sender_->LeapForward(milliseconds); |
| 831 } | 842 } |
| 832 | 843 |
| 833 double EventSenderBindings::LastEventTimestamp() { | 844 double EventSenderBindings::LastEventTimestamp() { |
| 834 if (sender_) | 845 if (sender_) |
| 835 return sender_->last_event_timestamp(); | 846 return sender_->last_event_timestamp(); |
| 836 return 0; | 847 return 0; |
| 837 } | 848 } |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 } | 1836 } |
| 1826 | 1837 |
| 1827 void EventSender::TouchStart() { | 1838 void EventSender::TouchStart() { |
| 1828 SendCurrentTouchEvent(WebInputEvent::TouchStart, false); | 1839 SendCurrentTouchEvent(WebInputEvent::TouchStart, false); |
| 1829 } | 1840 } |
| 1830 | 1841 |
| 1831 void EventSender::TouchMove() { | 1842 void EventSender::TouchMove() { |
| 1832 SendCurrentTouchEvent(WebInputEvent::TouchMove, false); | 1843 SendCurrentTouchEvent(WebInputEvent::TouchMove, false); |
| 1833 } | 1844 } |
| 1834 | 1845 |
| 1835 void EventSender::TouchMoveCausingScrollIfUncanceled() { | |
| 1836 SendCurrentTouchEvent(WebInputEvent::TouchMove, true); | |
| 1837 } | |
| 1838 | |
| 1839 void EventSender::TouchCancel() { | 1846 void EventSender::TouchCancel() { |
| 1840 SendCurrentTouchEvent(WebInputEvent::TouchCancel, false); | 1847 SendCurrentTouchEvent(WebInputEvent::TouchCancel, false); |
| 1841 } | 1848 } |
| 1842 | 1849 |
| 1843 void EventSender::TouchEnd() { | 1850 void EventSender::TouchEnd() { |
| 1844 SendCurrentTouchEvent(WebInputEvent::TouchEnd, false); | 1851 SendCurrentTouchEvent(WebInputEvent::TouchEnd, false); |
| 1845 } | 1852 } |
| 1846 | 1853 |
| 1854 void EventSender::NotifyStartOfImplScroll() { |
| 1855 WebGestureEvent gesture_event; |
| 1856 gesture_event.type = WebInputEvent::GestureScrollBegin; |
| 1857 HandleInputEventOnViewOrPopup(gesture_event, |
| 1858 WebInputEventDispatchType::NonBlocking); |
| 1859 } |
| 1860 |
| 1861 void EventSender::NotifyEndOfImplScroll() { |
| 1862 WebGestureEvent gesture_event; |
| 1863 gesture_event.type = WebInputEvent::GestureScrollEnd; |
| 1864 HandleInputEventOnViewOrPopup(gesture_event, |
| 1865 WebInputEventDispatchType::NonBlocking); |
| 1866 } |
| 1867 |
| 1847 void EventSender::LeapForward(int milliseconds) { | 1868 void EventSender::LeapForward(int milliseconds) { |
| 1848 if (is_drag_mode_ && pressed_button_ == WebMouseEvent::ButtonLeft && | 1869 if (is_drag_mode_ && pressed_button_ == WebMouseEvent::ButtonLeft && |
| 1849 !replaying_saved_events_) { | 1870 !replaying_saved_events_) { |
| 1850 SavedEvent saved_event; | 1871 SavedEvent saved_event; |
| 1851 saved_event.type = SavedEvent::TYPE_LEAP_FORWARD; | 1872 saved_event.type = SavedEvent::TYPE_LEAP_FORWARD; |
| 1852 saved_event.milliseconds = milliseconds; | 1873 saved_event.milliseconds = milliseconds; |
| 1853 mouse_event_queue_.push_back(saved_event); | 1874 mouse_event_queue_.push_back(saved_event); |
| 1854 } else { | 1875 } else { |
| 1855 DoLeapForward(milliseconds); | 1876 DoLeapForward(milliseconds); |
| 1856 } | 1877 } |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2675 last_event_timestamp_ = event.timeStampSeconds; | 2696 last_event_timestamp_ = event.timeStampSeconds; |
| 2676 | 2697 |
| 2677 if (WebPagePopup* popup = view_->pagePopup()) { | 2698 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2678 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2699 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2679 return popup->handleInputEvent(event); | 2700 return popup->handleInputEvent(event); |
| 2680 } | 2701 } |
| 2681 return view_->handleInputEvent(event); | 2702 return view_->handleInputEvent(event); |
| 2682 } | 2703 } |
| 2683 | 2704 |
| 2684 } // namespace test_runner | 2705 } // namespace test_runner |
| OLD | NEW |