EventSenderProxy.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (C) 2011 Apple Inc. All rights reserved.
  3. * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  15. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  16. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  18. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  19. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  20. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  21. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  22. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  23. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  24. * THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef EventSenderProxy_h
  27. #define EventSenderProxy_h
  28. #if PLATFORM(QT)
  29. #include <QEvent>
  30. #include <QTouchEvent>
  31. #elif PLATFORM(GTK)
  32. #include <gdk/gdk.h>
  33. #include <wtf/Vector.h>
  34. #elif PLATFORM(EFL)
  35. #include <WebKit2/EWebKit2.h>
  36. #include <wtf/Deque.h>
  37. #endif
  38. namespace WTR {
  39. class TestController;
  40. #if PLATFORM(GTK)
  41. struct WTREventQueueItem;
  42. #elif PLATFORM(EFL)
  43. struct WTREvent;
  44. #endif
  45. class EventSenderProxy {
  46. public:
  47. explicit EventSenderProxy(TestController*);
  48. ~EventSenderProxy();
  49. void mouseDown(unsigned button, WKEventModifiers);
  50. void mouseUp(unsigned button, WKEventModifiers);
  51. void mouseMoveTo(double x, double y);
  52. void mouseScrollBy(int x, int y);
  53. void continuousMouseScrollBy(int x, int y, bool paged);
  54. void leapForward(int milliseconds);
  55. void keyDown(WKStringRef key, WKEventModifiers, unsigned location);
  56. #if ENABLE(TOUCH_EVENTS)
  57. // Touch events.
  58. void addTouchPoint(int x, int y);
  59. void updateTouchPoint(int index, int x, int y);
  60. void setTouchModifier(WKEventModifiers, bool enable);
  61. void setTouchPointRadius(int radiusX, int radiusY);
  62. void touchStart();
  63. void touchMove();
  64. void touchEnd();
  65. void touchCancel();
  66. void clearTouchPoints();
  67. void releaseTouchPoint(int index);
  68. void cancelTouchPoint(int index);
  69. #endif
  70. private:
  71. TestController* m_testController;
  72. double currentEventTime() { return m_time; }
  73. void updateClickCountForButton(int button);
  74. #if PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
  75. void replaySavedEvents();
  76. #endif
  77. #if PLATFORM(QT)
  78. #if ENABLE(TOUCH_EVENTS)
  79. void sendTouchEvent(QEvent::Type);
  80. #endif
  81. void sendOrQueueEvent(QEvent*);
  82. #elif PLATFORM(GTK)
  83. void sendOrQueueEvent(GdkEvent*);
  84. GdkEvent* createMouseButtonEvent(GdkEventType, unsigned button, WKEventModifiers);
  85. #elif PLATFORM(EFL)
  86. void sendOrQueueEvent(const WTREvent&);
  87. void dispatchEvent(const WTREvent&);
  88. #if ENABLE(TOUCH_EVENTS)
  89. void sendTouchEvent(Ewk_Touch_Event_Type);
  90. #endif
  91. #endif
  92. double m_time;
  93. WKPoint m_position;
  94. bool m_leftMouseButtonDown;
  95. int m_clickCount;
  96. double m_clickTime;
  97. WKPoint m_clickPosition;
  98. WKEventMouseButton m_clickButton;
  99. #if PLATFORM(MAC)
  100. int eventNumber;
  101. #elif PLATFORM(GTK)
  102. Vector<WTREventQueueItem> m_eventQueue;
  103. unsigned m_mouseButtonCurrentlyDown;
  104. #elif PLATFORM(QT)
  105. Qt::MouseButtons m_mouseButtons;
  106. #if ENABLE(TOUCH_EVENTS)
  107. QList<QTouchEvent::TouchPoint> m_touchPoints;
  108. Qt::KeyboardModifiers m_touchModifiers;
  109. QPoint m_touchPointRadius;
  110. bool m_touchActive;
  111. #endif
  112. #elif PLATFORM(EFL)
  113. Deque<WTREvent> m_eventQueue;
  114. WKEventMouseButton m_mouseButton;
  115. #if ENABLE(TOUCH_EVENTS)
  116. Eina_List* m_touchPoints;
  117. #endif
  118. #endif
  119. };
  120. } // namespace WTR
  121. #endif // EventSenderProxy_h