3cd7f6d2f4dc4522bee8ad8941dd7d59e789de17
[platform/core/uifw/libtdm.git] / utests / stubs / wayland-server-core.h
1 #ifndef WAYLAND_SERVER_CORE_H
2 #define WAYLAND_SERVER_CORE_H
3
4 #include <stdint.h>
5
6 static int WL_EVENT_LOOP_ADD_FD_ERROR;
7 static int WL_EVENT_SOURCE_FD_UPDATE_ERROR;
8 static int WL_EVENT_LOOP_ADD_TIMER_ERROR;
9 static int WL_EVENT_SOURCE_TIMER_UPDATE_ERROR;
10 static int WL_DISPLAY_CREATE_ERROR;
11
12 enum {
13         WL_EVENT_READABLE = 0x01,
14         WL_EVENT_WRITABLE = 0x02,
15         WL_EVENT_HANGUP   = 0x04,
16         WL_EVENT_ERROR    = 0x08
17 };
18
19 struct wl_interface {
20         int a;
21 };
22
23 struct wl_interface wl_tdm_interface;
24
25 struct wl_interface wl_tdm_vblank_interface;
26
27 typedef enum {
28         WL_TDM_ERROR_INVALID_NAME,
29         WL_TDM_ERROR_OPERATION_FAILED
30
31 } wl_error;
32
33 struct wl_display {
34         int a;
35 };
36
37 struct wl_tdm_interface {
38         void (*_tdm_server_cb_wait_vblank)(struct wl_client *client,
39                                                            struct wl_resource *resource,
40                                                            uint32_t id, const char *name, int32_t interval);
41 };
42
43 struct wl_event_loop {
44         int temp;
45 };
46
47 struct wl_event_source {
48         int temp;
49 };
50
51 wl_display ut_wl_display;
52 wl_event_loop ut_wl_event_loop;
53
54 static void wl_display_flush_clients(struct wl_display *display)
55 {
56         (void)display;
57 }
58
59 static struct wl_display *wl_display_create()
60 {
61         if (WL_DISPLAY_CREATE_ERROR)
62                 return NULL;
63         return &ut_wl_display;
64 }
65
66 static struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display)
67 {
68         (void)display;
69
70         return &ut_wl_event_loop;
71 }
72
73 static void wl_display_destroy(struct wl_display *display)
74 {
75         (void)display;
76 }
77
78 static int wl_event_loop_get_fd(struct wl_event_loop *loop)
79 {
80         (void)loop;
81
82         return 0;
83 }
84
85 typedef void (*wl_global_bind_func_t)(struct wl_client *client, void *data,
86                                                                           uint32_t version, uint32_t id);
87
88 static int wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
89 {
90         (void)loop;
91         (void)timeout;
92
93         return 0;
94 }
95
96 typedef int (*wl_event_loop_fd_func_t)(int fd, uint32_t wl_mask, void *data);
97
98 struct wl_event_source event_source;
99
100 static struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
101                                                                                                         int fd, uint32_t mask,
102                                                                                                         wl_event_loop_fd_func_t func,
103                                                                                                         void *data)
104 {
105         (void)loop;
106         (void)fd;
107         (void)mask;
108         (void)func;
109         (void)data;
110
111         if (WL_EVENT_LOOP_ADD_FD_ERROR) {
112                 return NULL;
113         }
114
115         return &event_source;
116 }
117
118 static int wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask)
119 {
120         (void)source;
121         (void)mask;
122
123         if (WL_EVENT_SOURCE_FD_UPDATE_ERROR) {
124                 return -1;
125         }
126
127         return 1;
128 }
129
130 typedef int (*wl_event_loop_timer_func_t) (void *data);
131
132 static struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *loop,
133                                                                                                 wl_event_loop_timer_func_t func,
134                                                                                                 void *data)
135 {
136         (void)loop;
137         (void)func;
138         (void)data;
139
140         if (WL_EVENT_LOOP_ADD_TIMER_ERROR) {
141                 return NULL;
142         }
143
144         return &event_source;
145 }
146
147 static int wl_event_source_timer_update(struct wl_event_source *source, int ms_delay)
148 {
149         (void)source;
150         (void)ms_delay;
151
152         if (WL_EVENT_SOURCE_TIMER_UPDATE_ERROR) {
153                 return -1;
154         }
155
156         return 1;
157 }
158
159 static int wl_event_source_remove(struct wl_event_source *source)
160 {
161         (void)source;
162
163         return 0;
164 }
165
166 typedef void (*wl_resource_destroy_func_t) (struct wl_resource *resource);
167
168 #endif /* WAYLAND_SERVER_CORE_H */