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 "content/shell/renderer/test_runner/event_sender.h" | 5 #include "content/shell/renderer/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/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "content/shell/renderer/test_runner/MockSpellCheck.h" | 10 #include "content/shell/renderer/test_runner/MockSpellCheck.h" |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 void TextZoomIn(); | 334 void TextZoomIn(); |
335 void TextZoomOut(); | 335 void TextZoomOut(); |
336 void ZoomPageIn(); | 336 void ZoomPageIn(); |
337 void ZoomPageOut(); | 337 void ZoomPageOut(); |
338 void SetPageScaleFactor(gin::Arguments* args); | 338 void SetPageScaleFactor(gin::Arguments* args); |
339 void ClearTouchPoints(); | 339 void ClearTouchPoints(); |
340 void ReleaseTouchPoint(unsigned index); | 340 void ReleaseTouchPoint(unsigned index); |
341 void UpdateTouchPoint(unsigned index, double x, double y); | 341 void UpdateTouchPoint(unsigned index, double x, double y); |
342 void CancelTouchPoint(unsigned index); | 342 void CancelTouchPoint(unsigned index); |
343 void SetTouchModifier(const std::string& key_name, bool set_mask); | 343 void SetTouchModifier(const std::string& key_name, bool set_mask); |
| 344 void SetTouchCancelable(bool cancelable); |
344 void DumpFilenameBeingDragged(); | 345 void DumpFilenameBeingDragged(); |
345 void GestureFlingCancel(); | 346 void GestureFlingCancel(); |
346 void GestureFlingStart(float x, float y, float velocity_x, float velocity_y); | 347 void GestureFlingStart(float x, float y, float velocity_x, float velocity_y); |
347 void GestureScrollFirstPoint(int x, int y); | 348 void GestureScrollFirstPoint(int x, int y); |
348 void TouchStart(); | 349 void TouchStart(); |
349 void TouchMove(); | 350 void TouchMove(); |
350 void TouchCancel(); | 351 void TouchCancel(); |
351 void TouchEnd(); | 352 void TouchEnd(); |
352 void LeapForward(int milliseconds); | 353 void LeapForward(int milliseconds); |
353 void BeginDragWithFiles(const std::vector<std::string>& files); | 354 void BeginDragWithFiles(const std::vector<std::string>& files); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 .SetMethod("textZoomIn", &EventSenderBindings::TextZoomIn) | 452 .SetMethod("textZoomIn", &EventSenderBindings::TextZoomIn) |
452 .SetMethod("textZoomOut", &EventSenderBindings::TextZoomOut) | 453 .SetMethod("textZoomOut", &EventSenderBindings::TextZoomOut) |
453 .SetMethod("zoomPageIn", &EventSenderBindings::ZoomPageIn) | 454 .SetMethod("zoomPageIn", &EventSenderBindings::ZoomPageIn) |
454 .SetMethod("zoomPageOut", &EventSenderBindings::ZoomPageOut) | 455 .SetMethod("zoomPageOut", &EventSenderBindings::ZoomPageOut) |
455 .SetMethod("setPageScaleFactor", &EventSenderBindings::SetPageScaleFactor) | 456 .SetMethod("setPageScaleFactor", &EventSenderBindings::SetPageScaleFactor) |
456 .SetMethod("clearTouchPoints", &EventSenderBindings::ClearTouchPoints) | 457 .SetMethod("clearTouchPoints", &EventSenderBindings::ClearTouchPoints) |
457 .SetMethod("releaseTouchPoint", &EventSenderBindings::ReleaseTouchPoint) | 458 .SetMethod("releaseTouchPoint", &EventSenderBindings::ReleaseTouchPoint) |
458 .SetMethod("updateTouchPoint", &EventSenderBindings::UpdateTouchPoint) | 459 .SetMethod("updateTouchPoint", &EventSenderBindings::UpdateTouchPoint) |
459 .SetMethod("cancelTouchPoint", &EventSenderBindings::CancelTouchPoint) | 460 .SetMethod("cancelTouchPoint", &EventSenderBindings::CancelTouchPoint) |
460 .SetMethod("setTouchModifier", &EventSenderBindings::SetTouchModifier) | 461 .SetMethod("setTouchModifier", &EventSenderBindings::SetTouchModifier) |
| 462 .SetMethod("setTouchCancelable", &EventSenderBindings::SetTouchCancelable) |
461 .SetMethod("dumpFilenameBeingDragged", | 463 .SetMethod("dumpFilenameBeingDragged", |
462 &EventSenderBindings::DumpFilenameBeingDragged) | 464 &EventSenderBindings::DumpFilenameBeingDragged) |
463 .SetMethod("gestureFlingCancel", &EventSenderBindings::GestureFlingCancel) | 465 .SetMethod("gestureFlingCancel", &EventSenderBindings::GestureFlingCancel) |
464 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) | 466 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) |
465 .SetMethod("gestureScrollFirstPoint", | 467 .SetMethod("gestureScrollFirstPoint", |
466 &EventSenderBindings::GestureScrollFirstPoint) | 468 &EventSenderBindings::GestureScrollFirstPoint) |
467 .SetMethod("touchStart", &EventSenderBindings::TouchStart) | 469 .SetMethod("touchStart", &EventSenderBindings::TouchStart) |
468 .SetMethod("touchMove", &EventSenderBindings::TouchMove) | 470 .SetMethod("touchMove", &EventSenderBindings::TouchMove) |
469 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) | 471 .SetMethod("touchCancel", &EventSenderBindings::TouchCancel) |
470 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) | 472 .SetMethod("touchEnd", &EventSenderBindings::TouchEnd) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 if (sender_) | 619 if (sender_) |
618 sender_->CancelTouchPoint(index); | 620 sender_->CancelTouchPoint(index); |
619 } | 621 } |
620 | 622 |
621 void EventSenderBindings::SetTouchModifier(const std::string& key_name, | 623 void EventSenderBindings::SetTouchModifier(const std::string& key_name, |
622 bool set_mask) { | 624 bool set_mask) { |
623 if (sender_) | 625 if (sender_) |
624 sender_->SetTouchModifier(key_name, set_mask); | 626 sender_->SetTouchModifier(key_name, set_mask); |
625 } | 627 } |
626 | 628 |
| 629 void EventSenderBindings::SetTouchCancelable(bool cancelable) { |
| 630 if (sender_) |
| 631 sender_->SetTouchCancelable(cancelable); |
| 632 } |
| 633 |
627 void EventSenderBindings::DumpFilenameBeingDragged() { | 634 void EventSenderBindings::DumpFilenameBeingDragged() { |
628 if (sender_) | 635 if (sender_) |
629 sender_->DumpFilenameBeingDragged(); | 636 sender_->DumpFilenameBeingDragged(); |
630 } | 637 } |
631 | 638 |
632 void EventSenderBindings::GestureFlingCancel() { | 639 void EventSenderBindings::GestureFlingCancel() { |
633 if (sender_) | 640 if (sender_) |
634 sender_->GestureFlingCancel(); | 641 sender_->GestureFlingCancel(); |
635 } | 642 } |
636 | 643 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 milliseconds(0), | 992 milliseconds(0), |
986 modifiers(0) {} | 993 modifiers(0) {} |
987 | 994 |
988 EventSender::EventSender(WebTestRunner::TestInterfaces* interfaces) | 995 EventSender::EventSender(WebTestRunner::TestInterfaces* interfaces) |
989 : interfaces_(interfaces), | 996 : interfaces_(interfaces), |
990 delegate_(NULL), | 997 delegate_(NULL), |
991 view_(NULL), | 998 view_(NULL), |
992 force_layout_on_events_(false), | 999 force_layout_on_events_(false), |
993 is_drag_mode_(true), | 1000 is_drag_mode_(true), |
994 touch_modifiers_(0), | 1001 touch_modifiers_(0), |
| 1002 touch_cancelable_(true), |
995 replaying_saved_events_(false), | 1003 replaying_saved_events_(false), |
996 current_drag_effects_allowed_(blink::WebDragOperationNone), | 1004 current_drag_effects_allowed_(blink::WebDragOperationNone), |
997 last_click_time_sec_(0), | 1005 last_click_time_sec_(0), |
998 current_drag_effect_(blink::WebDragOperationNone), | 1006 current_drag_effect_(blink::WebDragOperationNone), |
999 time_offset_ms_(0), | 1007 time_offset_ms_(0), |
1000 click_count_(0), | 1008 click_count_(0), |
1001 #if defined(OS_WIN) | 1009 #if defined(OS_WIN) |
1002 wm_key_down_(0), | 1010 wm_key_down_(0), |
1003 wm_key_up_(0), | 1011 wm_key_up_(0), |
1004 wm_char_(0), | 1012 wm_char_(0), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 last_click_pos_ = WebPoint(0, 0); | 1047 last_click_pos_ = WebPoint(0, 0); |
1040 last_button_type_ = WebMouseEvent::ButtonNone; | 1048 last_button_type_ = WebMouseEvent::ButtonNone; |
1041 touch_points_.clear(); | 1049 touch_points_.clear(); |
1042 last_context_menu_data_.reset(); | 1050 last_context_menu_data_.reset(); |
1043 task_list_.revokeAll(); | 1051 task_list_.revokeAll(); |
1044 current_gesture_location_ = WebPoint(0, 0); | 1052 current_gesture_location_ = WebPoint(0, 0); |
1045 mouse_event_queue_.clear(); | 1053 mouse_event_queue_.clear(); |
1046 | 1054 |
1047 time_offset_ms_ = 0; | 1055 time_offset_ms_ = 0; |
1048 click_count_ = 0; | 1056 click_count_ = 0; |
| 1057 |
| 1058 touch_modifiers_ = 0; |
| 1059 touch_cancelable_ = true; |
| 1060 touch_points_.clear(); |
1049 } | 1061 } |
1050 | 1062 |
1051 void EventSender::Install(WebFrame* frame) { | 1063 void EventSender::Install(WebFrame* frame) { |
1052 EventSenderBindings::Install(weak_factory_.GetWeakPtr(), frame); | 1064 EventSenderBindings::Install(weak_factory_.GetWeakPtr(), frame); |
1053 } | 1065 } |
1054 | 1066 |
1055 void EventSender::SetDelegate(WebTestRunner::WebTestDelegate* delegate) { | 1067 void EventSender::SetDelegate(WebTestRunner::WebTestDelegate* delegate) { |
1056 delegate_ = delegate; | 1068 delegate_ = delegate; |
1057 } | 1069 } |
1058 | 1070 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 mask = WebInputEvent::ControlKey; | 1440 mask = WebInputEvent::ControlKey; |
1429 else if (key_name == "meta") | 1441 else if (key_name == "meta") |
1430 mask = WebInputEvent::MetaKey; | 1442 mask = WebInputEvent::MetaKey; |
1431 | 1443 |
1432 if (set_mask) | 1444 if (set_mask) |
1433 touch_modifiers_ |= mask; | 1445 touch_modifiers_ |= mask; |
1434 else | 1446 else |
1435 touch_modifiers_ &= ~mask; | 1447 touch_modifiers_ &= ~mask; |
1436 } | 1448 } |
1437 | 1449 |
| 1450 void EventSender::SetTouchCancelable(bool cancelable) { |
| 1451 touch_cancelable_ = cancelable; |
| 1452 } |
| 1453 |
1438 void EventSender::DumpFilenameBeingDragged() { | 1454 void EventSender::DumpFilenameBeingDragged() { |
1439 WebString filename; | 1455 WebString filename; |
1440 WebVector<WebDragData::Item> items = current_drag_data_.items(); | 1456 WebVector<WebDragData::Item> items = current_drag_data_.items(); |
1441 for (size_t i = 0; i < items.size(); ++i) { | 1457 for (size_t i = 0; i < items.size(); ++i) { |
1442 if (items[i].storageType == WebDragData::Item::StorageTypeBinaryData) { | 1458 if (items[i].storageType == WebDragData::Item::StorageTypeBinaryData) { |
1443 filename = items[i].title; | 1459 filename = items[i].title; |
1444 break; | 1460 break; |
1445 } | 1461 } |
1446 } | 1462 } |
1447 delegate_->printMessage(std::string("Filename being dragged: ") + | 1463 delegate_->printMessage(std::string("Filename being dragged: ") + |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 | 1772 |
1757 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type) { | 1773 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type) { |
1758 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), | 1774 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), |
1759 touch_points_.size()); | 1775 touch_points_.size()); |
1760 if (force_layout_on_events_) | 1776 if (force_layout_on_events_) |
1761 view_->layout(); | 1777 view_->layout(); |
1762 | 1778 |
1763 WebTouchEvent touch_event; | 1779 WebTouchEvent touch_event; |
1764 touch_event.type = type; | 1780 touch_event.type = type; |
1765 touch_event.modifiers = touch_modifiers_; | 1781 touch_event.modifiers = touch_modifiers_; |
| 1782 touch_event.cancelable = touch_cancelable_; |
1766 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); | 1783 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); |
1767 touch_event.touchesLength = touch_points_.size(); | 1784 touch_event.touchesLength = touch_points_.size(); |
1768 for (size_t i = 0; i < touch_points_.size(); ++i) | 1785 for (size_t i = 0; i < touch_points_.size(); ++i) |
1769 touch_event.touches[i] = touch_points_[i]; | 1786 touch_event.touches[i] = touch_points_[i]; |
1770 view_->handleInputEvent(touch_event); | 1787 view_->handleInputEvent(touch_event); |
1771 | 1788 |
1772 for (size_t i = 0; i < touch_points_.size(); ++i) { | 1789 for (size_t i = 0; i < touch_points_.size(); ++i) { |
1773 WebTouchPoint* touch_point = &touch_points_[i]; | 1790 WebTouchPoint* touch_point = &touch_points_[i]; |
1774 if (touch_point->state == WebTouchPoint::StateReleased) { | 1791 if (touch_point->state == WebTouchPoint::StateReleased) { |
1775 touch_points_.erase(touch_points_.begin() + i); | 1792 touch_points_.erase(touch_points_.begin() + i); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2130 } | 2147 } |
2131 default: | 2148 default: |
2132 NOTREACHED(); | 2149 NOTREACHED(); |
2133 } | 2150 } |
2134 } | 2151 } |
2135 | 2152 |
2136 replaying_saved_events_ = false; | 2153 replaying_saved_events_ = false; |
2137 } | 2154 } |
2138 | 2155 |
2139 } // namespace content | 2156 } // namespace content |
OLD | NEW |