76aa18c115986039c4f4a98403a4125338e899c1
[platform/core/uifw/e-tizen-testcase.git] / src / e_test_event.h
1 #ifndef __ET_EVENT_LOOP_H__
2 #define __ET_EVENT_LOOP_H__
3
4 #include <gtest/gtest.h>
5 #include <efl_util.h>
6
7 #include "e_test_util.h"
8 #include "e_test_win.h"
9
10 class etRunner
11 {
12 private:
13    etRunner()
14    {
15       worker.timer = NULL;
16       worker.waitTime = 0.0;
17       tzPolicy = NULL;
18       tzSurface = NULL;
19       tzlaunch_effect = NULL;
20       tzlaunch_splash =  NULL;
21       wlOutput = NULL;
22       ev = {0,};
23       logDomain = 0;
24       dbus.conn = NULL;
25       dbus.ds_proxy = NULL;
26       dbus.ds_obj = NULL;
27       dbus.deviced_proxy = NULL;
28       dbus.deviced_obj = NULL;
29       listWinInfo = NULL;
30       output = {0,};
31    };
32
33    ~etRunner() {}
34
35    static etRunner inst;
36
37 public:
38    static etRunner &get() { return inst; }
39
40 private:
41    int          logDomain;
42    struct
43      {
44         Ecore_Timer *timer;
45         double       waitTime;
46      } worker;
47
48    struct
49      {
50         Eldbus_Connection *conn;
51         Eldbus_Proxy      *ds_proxy; // display server proxy
52         Eldbus_Object     *ds_obj;   // display server obj
53         Eldbus_Proxy      *deviced_proxy; // deviced proxy
54         Eldbus_Object     *deviced_obj;   // deviced obj
55      } dbus;
56
57    struct tizen_policy  *tzPolicy;
58    struct tizen_surface *tzSurface;
59    struct tizen_launch_effect *tzlaunch_effect;
60    struct tizen_launch_splash *tzlaunch_splash;
61    struct wl_output *wlOutput;
62
63    Eina_List *listWinInfo;
64
65 public: /* TODO: make it hidden */
66    struct
67      {
68         Evas_Object *elm_win;
69         Ecore_Window native_win;
70
71         Eina_List *sh_list;
72         Eina_List *eh_list;
73         Eina_List *recv_queue;
74
75         E_TC_Event_Item *wait_event_index;
76         E_TC_Event_Item *last_event;
77         E_TC_Event_Item *last_checkpoint;
78
79         struct
80           {
81              Eina_Stringshare *name;
82              Eina_Bool ecore_state;
83              Eina_Bool evas_state;
84              Ecore_Timer *timer;
85           } key;
86         struct
87           {
88              unsigned int state_smcb;
89              unsigned int type;
90           } effect;
91         struct
92           {
93              Ecore_Timer *timer;
94              struct
95                {
96                   int fingers;
97                   int repeats;
98                   int current_repeats;
99                   Eina_Bool pressed;
100                } tap;
101              struct
102                {
103                   int fingers;
104                   efl_util_gesture_edge_e edge;
105                   int touch_count;
106                   Eina_Bool get_event;
107                } edge;
108           } gesture;
109      } ev;
110    struct
111      {
112         int x, y, w, h;
113      } output;
114
115 public:
116    Eina_Bool     init();
117    void          shutdown();
118    void          work();
119    void          work(double time);
120    void          finishWork();
121    void          printWinInfoList();
122    void          setWaitTime(double time) { worker.waitTime = time; };
123    void          delTimer();
124    void          addTimer();
125    void          addTimer(double time);
126    void          waitForDestroy();
127
128    Eina_Bool     registerWin(etWin *tw);
129    Eina_Bool     deregisterWin(etWin *tw);
130    Eina_Bool     resetRegisterWin();
131    Eina_Bool     setWinActivate(etWin *tw);
132    Eina_Bool     setWinIconic(etWin *tw, Eina_Bool set);
133    Eina_Bool     setWinStack(etWin *tw, etWin *sibiling, Eina_Bool above);
134    Eina_Bool     setWinRaise(etWin *tw);
135    Eina_Bool     setWinLower(etWin *tw);
136    Eina_Bool     setWinTransientFor(etWin *tw_child, etWin *tw_parent, Eina_Bool set);
137    Eina_Bool     setWinTransientForBelow(etWin *tw_child, etWin *tw_parent, Eina_Bool set);
138    Eina_Bool     setWinNotiLevel(etWin *tw, efl_util_notification_level_e lv);
139    efl_util_notification_level_e getWinNotiLevel(etWin *tw);
140    Eina_Bool     setFocusSkip(etWin *tw, Eina_Bool set);
141    Eina_Bool     setFocusSkipEcoreWl2(etWin *tw, Eina_Bool set);
142    Eina_Bool     setZoneRotation(int angle);
143    Eina_Bool     setTCStart();
144    Eina_Bool     setTCEnd();
145    Eina_Bool     getWinInfo(etWin *tw);
146    Eina_List    *getWinInfoList();
147    void          freeWinInfoList(Eina_List *list);
148    void          freeLastWinInfoList();
149    Eina_Bool     hasLastWinInfoList() { return !!listWinInfo; };
150    void          setLastWinInfoList(Eina_List *list);
151    Ecore_Window  getWinId(Evas_Object *elm_win);
152    struct wl_surface *getWlSurface(Evas_Object *elm_win);
153    Eina_Bool     setDpms(Eina_Bool on);
154    Eina_Bool     setDevctlDisplayLock(Eina_Bool lock);
155    Eina_Bool     setDevctlDisplayOn(Eina_Bool on);
156    Eina_Bool     feedMouseDown(int x, int y);
157    Eina_Bool     feedMouseMove(int x, int y);
158    Eina_Bool     feedMouseUp(int x, int y);
159    Eina_Bool     feedKeyDown(const char *key);
160    Eina_Bool     feedKeyUp(const char *key);
161    Eina_Bool     generateMouseDown(int x, int y);
162    Eina_Bool     generateMouseMove(int x, int y);
163    Eina_Bool     generateMouseUp(int x, int y);
164    Eina_Bool     generateKeyPress(const char *key);
165    Eina_Bool     generateKeyRelease(const char *key);
166    Eina_Bool     generateKeyEvent(const char *keyname, double delay);
167    Eina_Bool     generateTouchDown(int idx, int x, int y);
168    Eina_Bool     generateTouchMove(int idx, int x, int y);
169    Eina_Bool     generateTouchUp(int idx, int x, int y);
170    Eina_Bool     generateTapGesture();
171    Eina_Bool     generateEdgeSwipeGesture();
172    Eina_Bool     generateEdgeDragGesture();
173    Eina_Bool     setSplashLaunch(const char *path, int type);
174    Eina_Bool     setSplashOwner();
175    Eina_Bool     setWinEffect(etWin *tw);
176    Eina_Bool     freezeEvent();
177    Eina_Bool     thawEvent();
178    Eina_Bool     waitEvent(etWin *win, E_TC_Event_Type ev_type);
179    Eina_Bool     addSupportedAuxHint(const char *hint);
180    Eina_Bool     delSupportedAuxHint(const char *hint);
181    Eina_Bool     requestKillWinByName(const char *name);
182
183    void          flushEventQueue();
184    Eina_Bool     insertEventQueue(Ecore_Window id, E_TC_Event_Type ev_type);
185    Eina_Bool     isEventOccuredAfterCheckpoint(etWin *tw, E_TC_Event_Type ev_type);
186    void          setEventCheckpoint();
187    Eina_Bool     addSignalHandlers();
188    void          delSignalHandlers();
189
190    Eldbus_Proxy  *getDbusProxy()  { return dbus.ds_proxy; }
191    Eldbus_Object *getDbusObject() { return dbus.ds_obj;   }
192    int            getLogDomain()  { return logDomain;  }
193    efl_util_gesture_h getGestureHandler() { return gestureHandler; }
194
195 protected:
196    Eina_Bool initProtocols();
197    efl_util_inputgen_h inputGenerator = NULL;
198    efl_util_gesture_h gestureHandler = NULL;
199 };
200
201 #endif // end of __ET_EVENT_LOOP_H__