| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 float velocity_x, | 397 float velocity_x, |
| 398 float velocity_y, | 398 float velocity_y, |
| 399 gin::Arguments* args); | 399 gin::Arguments* args); |
| 400 void GestureScrollFirstPoint(int x, int y); | 400 void GestureScrollFirstPoint(int x, int y); |
| 401 void TouchStart(); | 401 void TouchStart(); |
| 402 void TouchMove(); | 402 void TouchMove(); |
| 403 void TouchMoveCausingScrollIfUncanceled(); | 403 void TouchMoveCausingScrollIfUncanceled(); |
| 404 void TouchCancel(); | 404 void TouchCancel(); |
| 405 void TouchEnd(); | 405 void TouchEnd(); |
| 406 void LeapForward(int milliseconds); | 406 void LeapForward(int milliseconds); |
| 407 double LastEventTimestamp(); |
| 407 void BeginDragWithFiles(const std::vector<std::string>& files); | 408 void BeginDragWithFiles(const std::vector<std::string>& files); |
| 408 void AddTouchPoint(double x, double y, gin::Arguments* args); | 409 void AddTouchPoint(double x, double y, gin::Arguments* args); |
| 409 void MouseDragBegin(); | 410 void MouseDragBegin(); |
| 410 void MouseDragEnd(); | 411 void MouseDragEnd(); |
| 411 void GestureScrollBegin(gin::Arguments* args); | 412 void GestureScrollBegin(gin::Arguments* args); |
| 412 void GestureScrollEnd(gin::Arguments* args); | 413 void GestureScrollEnd(gin::Arguments* args); |
| 413 void GestureScrollUpdate(gin::Arguments* args); | 414 void GestureScrollUpdate(gin::Arguments* args); |
| 414 void GesturePinchBegin(gin::Arguments* args); | 415 void GesturePinchBegin(gin::Arguments* args); |
| 415 void GesturePinchEnd(gin::Arguments* args); | 416 void GesturePinchEnd(gin::Arguments* args); |
| 416 void GesturePinchUpdate(gin::Arguments* args); | 417 void GesturePinchUpdate(gin::Arguments* args); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) | 525 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) |
| 525 .SetMethod("gestureScrollFirstPoint", | 526 .SetMethod("gestureScrollFirstPoint", |
| 526 &EventSenderBindings::GestureScrollFirstPoint) | 527 &EventSenderBindings::GestureScrollFirstPoint) |
| 527 .SetMethod("touchStart", &EventSenderBindings::TouchStart) | 528 .SetMethod("touchStart", &EventSenderBindings::TouchStart) |
| 528 .SetMethod("touchMove", &EventSenderBindings::TouchMove) | 529 .SetMethod("touchMove", &EventSenderBindings::TouchMove) |
| 529 .SetMethod("touchMoveCausingScrollIfUncanceled", | 530 .SetMethod("touchMoveCausingScrollIfUncanceled", |
| 530 &EventSenderBindings::TouchMoveCausingScrollIfUncanceled) | 531 &EventSenderBindings::TouchMoveCausingScrollIfUncanceled) |
| 531 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) | 532 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) |
| 532 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) | 533 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) |
| 533 .SetMethod("leapForward", &EventSenderBindings::LeapForward) | 534 .SetMethod("leapForward", &EventSenderBindings::LeapForward) |
| 535 .SetMethod("lastEventTimestamp", &EventSenderBindings::LastEventTimestamp) |
| 534 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) | 536 .SetMethod("beginDragWithFiles", &EventSenderBindings::BeginDragWithFiles) |
| 535 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) | 537 .SetMethod("addTouchPoint", &EventSenderBindings::AddTouchPoint) |
| 536 .SetMethod("mouseDragBegin", &EventSenderBindings::MouseDragBegin) | 538 .SetMethod("mouseDragBegin", &EventSenderBindings::MouseDragBegin) |
| 537 .SetMethod("mouseDragEnd", &EventSenderBindings::MouseDragEnd) | 539 .SetMethod("mouseDragEnd", &EventSenderBindings::MouseDragEnd) |
| 538 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) | 540 .SetMethod("gestureScrollBegin", &EventSenderBindings::GestureScrollBegin) |
| 539 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) | 541 .SetMethod("gestureScrollEnd", &EventSenderBindings::GestureScrollEnd) |
| 540 .SetMethod("gestureScrollUpdate", | 542 .SetMethod("gestureScrollUpdate", |
| 541 &EventSenderBindings::GestureScrollUpdate) | 543 &EventSenderBindings::GestureScrollUpdate) |
| 542 .SetMethod("gesturePinchBegin", &EventSenderBindings::GesturePinchBegin) | 544 .SetMethod("gesturePinchBegin", &EventSenderBindings::GesturePinchBegin) |
| 543 .SetMethod("gesturePinchEnd", &EventSenderBindings::GesturePinchEnd) | 545 .SetMethod("gesturePinchEnd", &EventSenderBindings::GesturePinchEnd) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 void EventSenderBindings::TouchEnd() { | 724 void EventSenderBindings::TouchEnd() { |
| 723 if (sender_) | 725 if (sender_) |
| 724 sender_->TouchEnd(); | 726 sender_->TouchEnd(); |
| 725 } | 727 } |
| 726 | 728 |
| 727 void EventSenderBindings::LeapForward(int milliseconds) { | 729 void EventSenderBindings::LeapForward(int milliseconds) { |
| 728 if (sender_) | 730 if (sender_) |
| 729 sender_->LeapForward(milliseconds); | 731 sender_->LeapForward(milliseconds); |
| 730 } | 732 } |
| 731 | 733 |
| 734 double EventSenderBindings::LastEventTimestamp() { |
| 735 if (sender_) |
| 736 return sender_->last_event_timestamp(); |
| 737 return 0; |
| 738 } |
| 739 |
| 732 void EventSenderBindings::BeginDragWithFiles( | 740 void EventSenderBindings::BeginDragWithFiles( |
| 733 const std::vector<std::string>& files) { | 741 const std::vector<std::string>& files) { |
| 734 if (sender_) | 742 if (sender_) |
| 735 sender_->BeginDragWithFiles(files); | 743 sender_->BeginDragWithFiles(files); |
| 736 } | 744 } |
| 737 | 745 |
| 738 void EventSenderBindings::AddTouchPoint(double x, | 746 void EventSenderBindings::AddTouchPoint(double x, |
| 739 double y, | 747 double y, |
| 740 gin::Arguments* args) { | 748 gin::Arguments* args) { |
| 741 if (sender_) | 749 if (sender_) |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 view_->layout(); | 1889 view_->layout(); |
| 1882 | 1890 |
| 1883 WebMouseEvent event; | 1891 WebMouseEvent event; |
| 1884 InitMouseEvent(WebInputEvent::MouseLeave, | 1892 InitMouseEvent(WebInputEvent::MouseLeave, |
| 1885 WebMouseEvent::ButtonNone, | 1893 WebMouseEvent::ButtonNone, |
| 1886 last_mouse_pos_, | 1894 last_mouse_pos_, |
| 1887 GetCurrentEventTimeSec(), | 1895 GetCurrentEventTimeSec(), |
| 1888 click_count_, | 1896 click_count_, |
| 1889 0, | 1897 0, |
| 1890 &event); | 1898 &event); |
| 1891 view_->handleInputEvent(event); | 1899 HandleInputEventOnViewOrPopup(event); |
| 1892 } | 1900 } |
| 1893 | 1901 |
| 1894 | 1902 |
| 1895 void EventSender::TrackpadScrollBegin() { | 1903 void EventSender::TrackpadScrollBegin() { |
| 1896 WebMouseWheelEvent event; | 1904 WebMouseWheelEvent event; |
| 1897 InitMouseEvent(WebInputEvent::MouseWheel, | 1905 InitMouseEvent(WebInputEvent::MouseWheel, |
| 1898 WebMouseEvent::ButtonNone, | 1906 WebMouseEvent::ButtonNone, |
| 1899 last_mouse_pos_, | 1907 last_mouse_pos_, |
| 1900 GetCurrentEventTimeSec(), | 1908 GetCurrentEventTimeSec(), |
| 1901 click_count_, | 1909 click_count_, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); | 1947 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); |
| 1940 } | 1948 } |
| 1941 | 1949 |
| 1942 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, | 1950 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, |
| 1943 int modifiers, | 1951 int modifiers, |
| 1944 KeyLocationCode location) { | 1952 KeyLocationCode location) { |
| 1945 delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location)); | 1953 delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location)); |
| 1946 } | 1954 } |
| 1947 | 1955 |
| 1948 double EventSender::GetCurrentEventTimeSec() { | 1956 double EventSender::GetCurrentEventTimeSec() { |
| 1949 return (delegate_->GetCurrentTimeInMillisecond() + time_offset_ms_) / 1000.0; | 1957 return (base::TimeTicks::Now() - base::TimeTicks()).InSeconds() + |
| 1958 time_offset_ms_ / 1000.0; |
| 1950 } | 1959 } |
| 1951 | 1960 |
| 1952 void EventSender::DoLeapForward(int milliseconds) { | 1961 void EventSender::DoLeapForward(int milliseconds) { |
| 1953 time_offset_ms_ += milliseconds; | 1962 time_offset_ms_ += milliseconds; |
| 1954 } | 1963 } |
| 1955 | 1964 |
| 1956 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, | 1965 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, |
| 1957 bool causesScrollingIfUncanceled) { | 1966 bool causesScrollingIfUncanceled) { |
| 1958 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), | 1967 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), |
| 1959 touch_points_.size()); | 1968 touch_points_.size()); |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2480 } | 2489 } |
| 2481 default: | 2490 default: |
| 2482 NOTREACHED(); | 2491 NOTREACHED(); |
| 2483 } | 2492 } |
| 2484 } | 2493 } |
| 2485 | 2494 |
| 2486 replaying_saved_events_ = false; | 2495 replaying_saved_events_ = false; |
| 2487 } | 2496 } |
| 2488 | 2497 |
| 2489 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { | 2498 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { |
| 2499 last_event_timestamp_ = event.timeStampSeconds; |
| 2500 |
| 2490 if (WebPagePopup* popup = view_->pagePopup()) { | 2501 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2491 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2502 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2492 return popup->handleInputEvent(event); | 2503 return popup->handleInputEvent(event); |
| 2493 } | 2504 } |
| 2494 return view_->handleInputEvent(event); | 2505 return view_->handleInputEvent(event); |
| 2495 } | 2506 } |
| 2496 | 2507 |
| 2497 } // namespace test_runner | 2508 } // namespace test_runner |
| OLD | NEW |