Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: components/test_runner/event_sender.cc

Issue 1553623002: Remove random lonely semicolons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix formatting Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 .SetMethod("mouseUp", &EventSenderBindings::MouseUp) 629 .SetMethod("mouseUp", &EventSenderBindings::MouseUp)
630 .SetMethod("setMouseButtonState", 630 .SetMethod("setMouseButtonState",
631 &EventSenderBindings::SetMouseButtonState) 631 &EventSenderBindings::SetMouseButtonState)
632 .SetMethod("scheduleAsynchronousClick", 632 .SetMethod("scheduleAsynchronousClick",
633 &EventSenderBindings::ScheduleAsynchronousClick) 633 &EventSenderBindings::ScheduleAsynchronousClick)
634 .SetMethod("scheduleAsynchronousKeyDown", 634 .SetMethod("scheduleAsynchronousKeyDown",
635 &EventSenderBindings::ScheduleAsynchronousKeyDown) 635 &EventSenderBindings::ScheduleAsynchronousKeyDown)
636 .SetProperty("forceLayoutOnEvents", 636 .SetProperty("forceLayoutOnEvents",
637 &EventSenderBindings::ForceLayoutOnEvents, 637 &EventSenderBindings::ForceLayoutOnEvents,
638 &EventSenderBindings::SetForceLayoutOnEvents) 638 &EventSenderBindings::SetForceLayoutOnEvents)
639 .SetProperty("dragMode", &EventSenderBindings::IsDragMode,
640 &EventSenderBindings::SetIsDragMode)
641 #if defined(OS_WIN) 639 #if defined(OS_WIN)
642 .SetProperty("WM_KEYDOWN", &EventSenderBindings::WmKeyDown, 640 .SetProperty("WM_KEYDOWN", &EventSenderBindings::WmKeyDown,
643 &EventSenderBindings::SetWmKeyDown) 641 &EventSenderBindings::SetWmKeyDown)
644 .SetProperty("WM_KEYUP", &EventSenderBindings::WmKeyUp, 642 .SetProperty("WM_KEYUP", &EventSenderBindings::WmKeyUp,
645 &EventSenderBindings::SetWmKeyUp) 643 &EventSenderBindings::SetWmKeyUp)
646 .SetProperty("WM_CHAR", &EventSenderBindings::WmChar, 644 .SetProperty("WM_CHAR", &EventSenderBindings::WmChar,
647 &EventSenderBindings::SetWmChar) 645 &EventSenderBindings::SetWmChar)
648 .SetProperty("WM_DEADCHAR", &EventSenderBindings::WmDeadChar, 646 .SetProperty("WM_DEADCHAR", &EventSenderBindings::WmDeadChar,
649 &EventSenderBindings::SetWmDeadChar) 647 &EventSenderBindings::SetWmDeadChar)
650 .SetProperty("WM_SYSKEYDOWN", &EventSenderBindings::WmSysKeyDown, 648 .SetProperty("WM_SYSKEYDOWN", &EventSenderBindings::WmSysKeyDown,
651 &EventSenderBindings::SetWmSysKeyDown) 649 &EventSenderBindings::SetWmSysKeyDown)
652 .SetProperty("WM_SYSKEYUP", &EventSenderBindings::WmSysKeyUp, 650 .SetProperty("WM_SYSKEYUP", &EventSenderBindings::WmSysKeyUp,
653 &EventSenderBindings::SetWmSysKeyUp) 651 &EventSenderBindings::SetWmSysKeyUp)
654 .SetProperty("WM_SYSCHAR", &EventSenderBindings::WmSysChar, 652 .SetProperty("WM_SYSCHAR", &EventSenderBindings::WmSysChar,
655 &EventSenderBindings::SetWmSysChar) 653 &EventSenderBindings::SetWmSysChar)
656 .SetProperty("WM_SYSDEADCHAR", &EventSenderBindings::WmSysDeadChar, 654 .SetProperty("WM_SYSDEADCHAR", &EventSenderBindings::WmSysDeadChar,
657 &EventSenderBindings::SetWmSysDeadChar); 655 &EventSenderBindings::SetWmSysDeadChar)
658 #else
659 ;
660 #endif 656 #endif
657 .SetProperty("dragMode", &EventSenderBindings::IsDragMode,
658 &EventSenderBindings::SetIsDragMode);
661 } 659 }
662 660
663 void EventSenderBindings::EnableDOMUIEventLogging() { 661 void EventSenderBindings::EnableDOMUIEventLogging() {
664 if (sender_) 662 if (sender_)
665 sender_->EnableDOMUIEventLogging(); 663 sender_->EnableDOMUIEventLogging();
666 } 664 }
667 665
668 void EventSenderBindings::FireKeyboardEventsToElement() { 666 void EventSenderBindings::FireKeyboardEventsToElement() {
669 if (sender_) 667 if (sender_)
670 sender_->FireKeyboardEventsToElement(); 668 sender_->FireKeyboardEventsToElement();
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 void EventSenderBindings::SetMouseButtonState(gin::Arguments* args) { 987 void EventSenderBindings::SetMouseButtonState(gin::Arguments* args) {
990 if (!sender_) 988 if (!sender_)
991 return; 989 return;
992 990
993 int button_number; 991 int button_number;
994 if (!args->GetNext(&button_number)) { 992 if (!args->GetNext(&button_number)) {
995 args->ThrowError(); 993 args->ThrowError();
996 return; 994 return;
997 } 995 }
998 996
999 int modifiers = -1; // Default to the modifier implied by button_number 997 int modifiers = -1; // Default to the modifier implied by button_number
1000 if (!args->PeekNext().IsEmpty()) { 998 if (!args->PeekNext().IsEmpty()) {
1001 modifiers = GetKeyModifiersFromV8(args->isolate(), args->PeekNext()); 999 modifiers = GetKeyModifiersFromV8(args->isolate(), args->PeekNext());
1002 } 1000 }
1003 1001
1004 sender_->SetMouseButtonState(button_number, modifiers); 1002 sender_->SetMouseButtonState(button_number, modifiers);
1005 } 1003 }
1006 1004
1007 void EventSenderBindings::KeyDown(gin::Arguments* args) { 1005 void EventSenderBindings::KeyDown(gin::Arguments* args) {
1008 if (!sender_) 1006 if (!sender_)
1009 return; 1007 return;
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 1484
1487 event_down.setKeyIdentifierFromWindowsKeyCode(); 1485 event_down.setKeyIdentifierFromWindowsKeyCode();
1488 1486
1489 if (event_down.modifiers != 0) 1487 if (event_down.modifiers != 0)
1490 event_down.isSystemKey = IsSystemKeyEvent(event_down); 1488 event_down.isSystemKey = IsSystemKeyEvent(event_down);
1491 1489
1492 if (needs_shift_key_modifier) 1490 if (needs_shift_key_modifier)
1493 event_down.modifiers |= WebInputEvent::ShiftKey; 1491 event_down.modifiers |= WebInputEvent::ShiftKey;
1494 1492
1495 // See if KeyLocation argument is given. 1493 // See if KeyLocation argument is given.
1496 switch(location) { 1494 switch (location) {
1497 case DOMKeyLocationStandard: 1495 case DOMKeyLocationStandard:
1498 break; 1496 break;
1499 case DOMKeyLocationLeft: 1497 case DOMKeyLocationLeft:
1500 event_down.modifiers |= WebInputEvent::IsLeft; 1498 event_down.modifiers |= WebInputEvent::IsLeft;
1501 break; 1499 break;
1502 case DOMKeyLocationRight: 1500 case DOMKeyLocationRight:
1503 event_down.modifiers |= WebInputEvent::IsRight; 1501 event_down.modifiers |= WebInputEvent::IsRight;
1504 break; 1502 break;
1505 case DOMKeyLocationNumpad: 1503 case DOMKeyLocationNumpad:
1506 event_down.modifiers |= WebInputEvent::IsKeyPad; 1504 event_down.modifiers |= WebInputEvent::IsKeyPad;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 last_mouse_pos_, 1587 last_mouse_pos_,
1590 GetCurrentEventTimeSec(), 1588 GetCurrentEventTimeSec(),
1591 click_count_, 1589 click_count_,
1592 0, 1590 0,
1593 &event); 1591 &event);
1594 HandleInputEventOnViewOrPopup(event); 1592 HandleInputEventOnViewOrPopup(event);
1595 1593
1596 #if defined(OS_WIN) 1594 #if defined(OS_WIN)
1597 current_buttons_ &= 1595 current_buttons_ &=
1598 ~GetWebMouseEventModifierForButton(WebMouseEvent::ButtonRight); 1596 ~GetWebMouseEventModifierForButton(WebMouseEvent::ButtonRight);
1599 pressed_button_= WebMouseEvent::ButtonNone; 1597 pressed_button_ = WebMouseEvent::ButtonNone;
1600 1598
1601 InitMouseEvent(WebInputEvent::MouseUp, 1599 InitMouseEvent(WebInputEvent::MouseUp,
1602 WebMouseEvent::ButtonRight, 1600 WebMouseEvent::ButtonRight,
1603 current_buttons_, 1601 current_buttons_,
1604 last_mouse_pos_, 1602 last_mouse_pos_,
1605 GetCurrentEventTimeSec(), 1603 GetCurrentEventTimeSec(),
1606 click_count_, 1604 click_count_,
1607 0, 1605 0,
1608 &event); 1606 &event);
1609 HandleInputEventOnViewOrPopup(event); 1607 HandleInputEventOnViewOrPopup(event);
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 1995
1998 WebMouseEvent event; 1996 WebMouseEvent event;
1999 InitMouseEvent(WebInputEvent::MouseLeave, 1997 InitMouseEvent(WebInputEvent::MouseLeave,
2000 WebMouseEvent::ButtonNone, 1998 WebMouseEvent::ButtonNone,
2001 0, 1999 0,
2002 last_mouse_pos_, 2000 last_mouse_pos_,
2003 GetCurrentEventTimeSec(), 2001 GetCurrentEventTimeSec(),
2004 click_count_, 2002 click_count_,
2005 0, 2003 0,
2006 &event); 2004 &event);
2007 HandleInputEventOnViewOrPopup(event); 2005 HandleInputEventOnViewOrPopup(event);
2008 } 2006 }
2009 2007
2010 2008
2011 void EventSender::TrackpadScrollBegin() { 2009 void EventSender::TrackpadScrollBegin() {
2012 WebMouseWheelEvent event; 2010 WebMouseWheelEvent event;
2013 InitMouseEvent(WebInputEvent::MouseWheel, 2011 InitMouseEvent(WebInputEvent::MouseWheel,
2014 WebMouseEvent::ButtonNone, 2012 WebMouseEvent::ButtonNone,
2015 0, 2013 0,
2016 last_mouse_pos_, 2014 last_mouse_pos_,
2017 GetCurrentEventTimeSec(), 2015 GetCurrentEventTimeSec(),
(...skipping 22 matching lines...) Expand all
2040 GetCurrentEventTimeSec(), 2038 GetCurrentEventTimeSec(),
2041 click_count_, 2039 click_count_,
2042 0, 2040 0,
2043 &event); 2041 &event);
2044 event.phase = WebMouseWheelEvent::PhaseEnded; 2042 event.phase = WebMouseWheelEvent::PhaseEnded;
2045 event.hasPreciseScrollingDeltas = true; 2043 event.hasPreciseScrollingDeltas = true;
2046 HandleInputEventOnViewOrPopup(event); 2044 HandleInputEventOnViewOrPopup(event);
2047 } 2045 }
2048 2046
2049 void EventSender::MouseScrollBy(gin::Arguments* args) { 2047 void EventSender::MouseScrollBy(gin::Arguments* args) {
2050 WebMouseWheelEvent event; 2048 WebMouseWheelEvent event;
2051 InitMouseWheelEvent(args, false, &event); 2049 InitMouseWheelEvent(args, false, &event);
2052 HandleInputEventOnViewOrPopup(event); 2050 HandleInputEventOnViewOrPopup(event);
2053 } 2051 }
2054 2052
2055 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { 2053 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) {
2056 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); 2054 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers));
2057 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); 2055 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers));
2058 } 2056 }
2059 2057
2060 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, 2058 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str,
(...skipping 28 matching lines...) Expand all
2089 for (size_t i = 0; i < touch_points_.size(); ++i) 2087 for (size_t i = 0; i < touch_points_.size(); ++i)
2090 touch_event.touches[i] = touch_points_[i]; 2088 touch_event.touches[i] = touch_points_[i];
2091 HandleInputEventOnViewOrPopup(touch_event); 2089 HandleInputEventOnViewOrPopup(touch_event);
2092 2090
2093 for (size_t i = 0; i < touch_points_.size(); ++i) { 2091 for (size_t i = 0; i < touch_points_.size(); ++i) {
2094 WebTouchPoint* touch_point = &touch_points_[i]; 2092 WebTouchPoint* touch_point = &touch_points_[i];
2095 if (touch_point->state == WebTouchPoint::StateReleased 2093 if (touch_point->state == WebTouchPoint::StateReleased
2096 || touch_point->state == WebTouchPoint::StateCancelled) { 2094 || touch_point->state == WebTouchPoint::StateCancelled) {
2097 touch_points_.erase(touch_points_.begin() + i); 2095 touch_points_.erase(touch_points_.begin() + i);
2098 --i; 2096 --i;
2099 } else 2097 } else {
2100 touch_point->state = WebTouchPoint::StateStationary; 2098 touch_point->state = WebTouchPoint::StateStationary;
2099 }
2101 } 2100 }
2102 } 2101 }
2103 2102
2104 void EventSender::GestureEvent(WebInputEvent::Type type, 2103 void EventSender::GestureEvent(WebInputEvent::Type type,
2105 gin::Arguments* args) { 2104 gin::Arguments* args) {
2106 WebGestureEvent event; 2105 WebGestureEvent event;
2107 event.type = type; 2106 event.type = type;
2108 2107
2109 // If the first argument is a string, it is to specify the device, otherwise 2108 // If the first argument is a string, it is to specify the device, otherwise
2110 // the device is assumed to be a touchscreen (since most tests were written 2109 // the device is assumed to be a touchscreen (since most tests were written
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 last_event_timestamp_ = event.timeStampSeconds; 2615 last_event_timestamp_ = event.timeStampSeconds;
2617 2616
2618 if (WebPagePopup* popup = view_->pagePopup()) { 2617 if (WebPagePopup* popup = view_->pagePopup()) {
2619 if (!WebInputEvent::isKeyboardEventType(event.type)) 2618 if (!WebInputEvent::isKeyboardEventType(event.type))
2620 return popup->handleInputEvent(event); 2619 return popup->handleInputEvent(event);
2621 } 2620 }
2622 return view_->handleInputEvent(event); 2621 return view_->handleInputEvent(event);
2623 } 2622 }
2624 2623
2625 } // namespace test_runner 2624 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698