[Release] Webkit2-efl-123997_0.11.86
[framework/web/webkit-efl.git] / Tools / WebKitTestRunner / EventSenderProxy.h
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
27 #ifndef EventSenderProxy_h
28 #define EventSenderProxy_h
29
30 #if PLATFORM(QT)
31 #include <QEvent>
32 #include <QTouchEvent>
33 #elif PLATFORM(GTK)
34 #include <gdk/gdk.h>
35 #include <wtf/Vector.h>
36 #elif PLATFORM(EFL)
37 #include <WebKit2/EWebKit2.h>
38 #include <wtf/Deque.h>
39 #endif
40
41 namespace WTR {
42
43 class TestController;
44
45 #if PLATFORM(GTK)
46 struct WTREventQueueItem;
47 #elif PLATFORM(EFL)
48 struct WTREvent;
49 #endif
50
51 class EventSenderProxy {
52 public:
53     explicit EventSenderProxy(TestController*);
54     ~EventSenderProxy();
55
56     void mouseDown(unsigned button, WKEventModifiers);
57     void mouseUp(unsigned button, WKEventModifiers);
58     void mouseMoveTo(double x, double y);
59     void mouseScrollBy(int x, int y);
60
61     void leapForward(int milliseconds);
62
63     void keyDown(WKStringRef key, WKEventModifiers, unsigned location);
64
65 #if ENABLE(TOUCH_EVENTS)
66     // Touch events.
67     void addTouchPoint(int x, int y);
68     void updateTouchPoint(int index, int x, int y);
69     void setTouchModifier(WKEventModifiers, bool enable);
70     void setTouchPointRadius(int radiusX, int radiusY);
71     void touchStart();
72     void touchMove();
73     void touchEnd();
74     void touchCancel();
75     void clearTouchPoints();
76     void releaseTouchPoint(int index);
77     void cancelTouchPoint(int index);
78 #endif
79
80 private:
81     TestController* m_testController;
82
83     double currentEventTime() { return m_time; }
84     void updateClickCountForButton(int button);
85
86 #if PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
87     void replaySavedEvents();
88 #endif
89
90 #if PLATFORM(QT)
91 #if ENABLE(TOUCH_EVENTS)
92     void sendTouchEvent(QEvent::Type);
93 #endif
94     void sendOrQueueEvent(QEvent*);
95 #elif PLATFORM(GTK)
96     void sendOrQueueEvent(GdkEvent*);
97     GdkEvent* createMouseButtonEvent(GdkEventType, unsigned button, WKEventModifiers);
98 #elif PLATFORM(EFL)
99     void sendOrQueueEvent(const WTREvent&);
100     void dispatchEvent(const WTREvent&);
101 #if ENABLE(TOUCH_EVENTS)
102     void sendTouchEvent(Ewk_Touch_Event_Type);
103 #endif
104 #endif
105
106     double m_time;
107     WKPoint m_position;
108     bool m_leftMouseButtonDown;
109     int m_clickCount;
110     double m_clickTime;
111     WKPoint m_clickPosition;
112     WKEventMouseButton m_clickButton;
113 #if PLATFORM(MAC)
114     int eventNumber;
115 #elif PLATFORM(GTK)
116     Vector<WTREventQueueItem> m_eventQueue;
117     unsigned m_mouseButtonCurrentlyDown;
118 #elif PLATFORM(QT)
119     Qt::MouseButtons m_mouseButtons;
120
121 #if ENABLE(TOUCH_EVENTS)
122     QList<QTouchEvent::TouchPoint> m_touchPoints;
123     Qt::KeyboardModifiers m_touchModifiers;
124     QPoint m_touchPointRadius;
125     bool m_touchActive;
126 #endif
127 #elif PLATFORM(EFL)
128     Deque<WTREvent> m_eventQueue;
129     unsigned m_mouseButton;
130 #if ENABLE(TOUCH_EVENTS)
131     Eina_List* m_touchPoints;
132 #endif
133 #endif
134 };
135
136 } // namespace WTR
137
138 #endif // EventSenderProxy_h