1 | /*
|
---|
2 | * Copyright (c) 2022 Jiri Svoboda
|
---|
3 | * All rights reserved.
|
---|
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 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #include <async.h>
|
---|
30 | #include <errno.h>
|
---|
31 | #include <display.h>
|
---|
32 | #include <disp_srv.h>
|
---|
33 | #include <fibril_synch.h>
|
---|
34 | #include <gfx/color.h>
|
---|
35 | #include <gfx/context.h>
|
---|
36 | #include <gfx/render.h>
|
---|
37 | #include <ipcgfx/server.h>
|
---|
38 | #include <loc.h>
|
---|
39 | #include <pcut/pcut.h>
|
---|
40 | #include "../private/display.h"
|
---|
41 |
|
---|
42 | PCUT_INIT;
|
---|
43 |
|
---|
44 | PCUT_TEST_SUITE(display);
|
---|
45 |
|
---|
46 | static const char *test_display_server = "test-display";
|
---|
47 | static const char *test_display_svc = "test/display";
|
---|
48 |
|
---|
49 | static void test_display_conn(ipc_call_t *, void *);
|
---|
50 |
|
---|
51 | static void test_close_event(void *);
|
---|
52 | static void test_focus_event(void *);
|
---|
53 | static void test_kbd_event(void *, kbd_event_t *);
|
---|
54 | static void test_pos_event(void *, pos_event_t *);
|
---|
55 | static void test_unfocus_event(void *);
|
---|
56 |
|
---|
57 | static errno_t test_window_create(void *, display_wnd_params_t *, sysarg_t *);
|
---|
58 | static errno_t test_window_destroy(void *, sysarg_t);
|
---|
59 | static errno_t test_window_move_req(void *, sysarg_t, gfx_coord2_t *);
|
---|
60 | static errno_t test_window_move(void *, sysarg_t, gfx_coord2_t *);
|
---|
61 | static errno_t test_window_get_pos(void *, sysarg_t, gfx_coord2_t *);
|
---|
62 | static errno_t test_window_get_max_rect(void *, sysarg_t, gfx_rect_t *);
|
---|
63 | static errno_t test_window_resize_req(void *, sysarg_t, display_wnd_rsztype_t,
|
---|
64 | gfx_coord2_t *);
|
---|
65 | static errno_t test_window_resize(void *, sysarg_t, gfx_coord2_t *,
|
---|
66 | gfx_rect_t *);
|
---|
67 | static errno_t test_window_maximize(void *, sysarg_t);
|
---|
68 | static errno_t test_window_unmaximize(void *, sysarg_t);
|
---|
69 | static errno_t test_window_set_cursor(void *, sysarg_t, display_stock_cursor_t);
|
---|
70 | static errno_t test_get_event(void *, sysarg_t *, display_wnd_ev_t *);
|
---|
71 | static errno_t test_get_info(void *, display_info_t *);
|
---|
72 |
|
---|
73 | static errno_t test_gc_set_color(void *, gfx_color_t *);
|
---|
74 |
|
---|
75 | static display_ops_t test_display_srv_ops = {
|
---|
76 | .window_create = test_window_create,
|
---|
77 | .window_destroy = test_window_destroy,
|
---|
78 | .window_move_req = test_window_move_req,
|
---|
79 | .window_move = test_window_move,
|
---|
80 | .window_get_pos = test_window_get_pos,
|
---|
81 | .window_get_max_rect = test_window_get_max_rect,
|
---|
82 | .window_resize_req = test_window_resize_req,
|
---|
83 | .window_resize = test_window_resize,
|
---|
84 | .window_maximize = test_window_maximize,
|
---|
85 | .window_unmaximize = test_window_unmaximize,
|
---|
86 | .window_set_cursor = test_window_set_cursor,
|
---|
87 | .get_event = test_get_event,
|
---|
88 | .get_info = test_get_info
|
---|
89 | };
|
---|
90 |
|
---|
91 | static display_wnd_cb_t test_display_wnd_cb = {
|
---|
92 | .close_event = test_close_event,
|
---|
93 | .focus_event = test_focus_event,
|
---|
94 | .kbd_event = test_kbd_event,
|
---|
95 | .pos_event = test_pos_event,
|
---|
96 | .unfocus_event = test_unfocus_event
|
---|
97 | };
|
---|
98 |
|
---|
99 | static gfx_context_ops_t test_gc_ops = {
|
---|
100 | .set_color = test_gc_set_color
|
---|
101 | };
|
---|
102 |
|
---|
103 | /** Describes to the server how to respond to our request and pass tracking
|
---|
104 | * data back to the client.
|
---|
105 | */
|
---|
106 | typedef struct {
|
---|
107 | errno_t rc;
|
---|
108 | sysarg_t wnd_id;
|
---|
109 | display_wnd_ev_t event;
|
---|
110 | display_wnd_ev_t revent;
|
---|
111 | int event_cnt;
|
---|
112 | bool window_create_called;
|
---|
113 | gfx_rect_t create_rect;
|
---|
114 | gfx_coord2_t create_min_size;
|
---|
115 | bool window_destroy_called;
|
---|
116 | sysarg_t destroy_wnd_id;
|
---|
117 |
|
---|
118 | bool window_move_req_called;
|
---|
119 | sysarg_t move_req_wnd_id;
|
---|
120 | gfx_coord2_t move_req_pos;
|
---|
121 |
|
---|
122 | bool window_move_called;
|
---|
123 | sysarg_t move_wnd_id;
|
---|
124 | gfx_coord2_t move_dpos;
|
---|
125 |
|
---|
126 | bool window_get_pos_called;
|
---|
127 | sysarg_t get_pos_wnd_id;
|
---|
128 | gfx_coord2_t get_pos_rpos;
|
---|
129 |
|
---|
130 | bool window_get_max_rect_called;
|
---|
131 | sysarg_t get_max_rect_wnd_id;
|
---|
132 | gfx_rect_t get_max_rect_rrect;
|
---|
133 |
|
---|
134 | bool window_resize_req_called;
|
---|
135 | sysarg_t resize_req_wnd_id;
|
---|
136 | display_wnd_rsztype_t resize_req_rsztype;
|
---|
137 | gfx_coord2_t resize_req_pos;
|
---|
138 |
|
---|
139 | bool window_resize_called;
|
---|
140 | gfx_coord2_t resize_offs;
|
---|
141 | gfx_rect_t resize_nbound;
|
---|
142 | sysarg_t resize_wnd_id;
|
---|
143 |
|
---|
144 | bool window_maximize_called;
|
---|
145 | bool window_unmaximize_called;
|
---|
146 |
|
---|
147 | bool window_set_cursor_called;
|
---|
148 | sysarg_t set_cursor_wnd_id;
|
---|
149 | display_stock_cursor_t set_cursor_cursor;
|
---|
150 |
|
---|
151 | bool get_event_called;
|
---|
152 |
|
---|
153 | bool get_info_called;
|
---|
154 | gfx_rect_t get_info_rect;
|
---|
155 |
|
---|
156 | bool set_color_called;
|
---|
157 | bool close_event_called;
|
---|
158 | bool focus_event_called;
|
---|
159 | bool kbd_event_called;
|
---|
160 | bool pos_event_called;
|
---|
161 | bool unfocus_event_called;
|
---|
162 | fibril_condvar_t event_cv;
|
---|
163 | fibril_mutex_t event_lock;
|
---|
164 | display_srv_t *srv;
|
---|
165 | } test_response_t;
|
---|
166 |
|
---|
167 | /** display_open(), display_close() work for valid display service */
|
---|
168 | PCUT_TEST(open_close)
|
---|
169 | {
|
---|
170 | errno_t rc;
|
---|
171 | service_id_t sid;
|
---|
172 | display_t *disp = NULL;
|
---|
173 | test_response_t resp;
|
---|
174 |
|
---|
175 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
176 |
|
---|
177 | // FIXME This causes this test to be non-reentrant!
|
---|
178 | rc = loc_server_register(test_display_server);
|
---|
179 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
180 |
|
---|
181 | rc = loc_service_register(test_display_svc, &sid);
|
---|
182 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
183 |
|
---|
184 | rc = display_open(test_display_svc, &disp);
|
---|
185 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
186 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
187 |
|
---|
188 | display_close(disp);
|
---|
189 | rc = loc_service_unregister(sid);
|
---|
190 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
191 | }
|
---|
192 |
|
---|
193 | /** display_window_create() with server returning error response works */
|
---|
194 | PCUT_TEST(window_create_failure)
|
---|
195 | {
|
---|
196 | errno_t rc;
|
---|
197 | service_id_t sid;
|
---|
198 | display_t *disp = NULL;
|
---|
199 | display_wnd_params_t params;
|
---|
200 | display_window_t *wnd;
|
---|
201 | test_response_t resp;
|
---|
202 |
|
---|
203 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
204 |
|
---|
205 | // FIXME This causes this test to be non-reentrant!
|
---|
206 | rc = loc_server_register(test_display_server);
|
---|
207 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
208 |
|
---|
209 | rc = loc_service_register(test_display_svc, &sid);
|
---|
210 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
211 |
|
---|
212 | rc = display_open(test_display_svc, &disp);
|
---|
213 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
214 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
215 |
|
---|
216 | wnd = NULL;
|
---|
217 | resp.rc = ENOMEM;
|
---|
218 | resp.window_create_called = false;
|
---|
219 | display_wnd_params_init(¶ms);
|
---|
220 | params.rect.p0.x = 0;
|
---|
221 | params.rect.p0.y = 0;
|
---|
222 | params.rect.p0.x = 100;
|
---|
223 | params.rect.p0.y = 100;
|
---|
224 | params.min_size.x = 11;
|
---|
225 | params.min_size.y = 12;
|
---|
226 |
|
---|
227 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
228 | (void *) &resp, &wnd);
|
---|
229 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
230 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
231 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
232 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
233 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
234 | PCUT_ASSERT_EQUALS(params.min_size.x, resp.create_min_size.x);
|
---|
235 | PCUT_ASSERT_EQUALS(params.min_size.y, resp.create_min_size.y);
|
---|
236 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
237 | PCUT_ASSERT_NULL(wnd);
|
---|
238 |
|
---|
239 | display_close(disp);
|
---|
240 | rc = loc_service_unregister(sid);
|
---|
241 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
242 | }
|
---|
243 |
|
---|
244 | /** display_window_create() and display_window_destroy() with success
|
---|
245 | *
|
---|
246 | * with server returning success,
|
---|
247 | */
|
---|
248 | PCUT_TEST(window_create_destroy_success)
|
---|
249 | {
|
---|
250 | errno_t rc;
|
---|
251 | service_id_t sid;
|
---|
252 | display_t *disp = NULL;
|
---|
253 | display_wnd_params_t params;
|
---|
254 | display_window_t *wnd;
|
---|
255 | test_response_t resp;
|
---|
256 |
|
---|
257 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
258 |
|
---|
259 | // FIXME This causes this test to be non-reentrant!
|
---|
260 | rc = loc_server_register(test_display_server);
|
---|
261 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
262 |
|
---|
263 | rc = loc_service_register(test_display_svc, &sid);
|
---|
264 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
265 |
|
---|
266 | rc = display_open(test_display_svc, &disp);
|
---|
267 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
268 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
269 |
|
---|
270 | wnd = NULL;
|
---|
271 | resp.rc = EOK;
|
---|
272 | resp.window_create_called = false;
|
---|
273 | display_wnd_params_init(¶ms);
|
---|
274 | params.rect.p0.x = 0;
|
---|
275 | params.rect.p0.y = 0;
|
---|
276 | params.rect.p0.x = 100;
|
---|
277 | params.rect.p0.y = 100;
|
---|
278 |
|
---|
279 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
280 | (void *) &resp, &wnd);
|
---|
281 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
282 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
283 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
284 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
285 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
286 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
287 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
288 |
|
---|
289 | resp.window_destroy_called = false;
|
---|
290 | rc = display_window_destroy(wnd);
|
---|
291 | PCUT_ASSERT_TRUE(resp.window_destroy_called);
|
---|
292 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.destroy_wnd_id);
|
---|
293 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
294 |
|
---|
295 | display_close(disp);
|
---|
296 | rc = loc_service_unregister(sid);
|
---|
297 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
298 | }
|
---|
299 |
|
---|
300 | /** display_window_create() with server returning error response works. */
|
---|
301 | PCUT_TEST(window_destroy_failure)
|
---|
302 | {
|
---|
303 | errno_t rc;
|
---|
304 | service_id_t sid;
|
---|
305 | display_t *disp = NULL;
|
---|
306 | display_wnd_params_t params;
|
---|
307 | display_window_t *wnd;
|
---|
308 | test_response_t resp;
|
---|
309 |
|
---|
310 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
311 |
|
---|
312 | // FIXME This causes this test to be non-reentrant!
|
---|
313 | rc = loc_server_register(test_display_server);
|
---|
314 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
315 |
|
---|
316 | rc = loc_service_register(test_display_svc, &sid);
|
---|
317 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
318 |
|
---|
319 | rc = display_open(test_display_svc, &disp);
|
---|
320 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
321 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
322 |
|
---|
323 | resp.rc = EOK;
|
---|
324 | resp.window_create_called = false;
|
---|
325 | display_wnd_params_init(¶ms);
|
---|
326 | params.rect.p0.x = 0;
|
---|
327 | params.rect.p0.y = 0;
|
---|
328 | params.rect.p0.x = 100;
|
---|
329 | params.rect.p0.y = 100;
|
---|
330 |
|
---|
331 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
332 | (void *) &resp, &wnd);
|
---|
333 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
334 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
335 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
336 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
337 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
338 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
339 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
340 |
|
---|
341 | resp.rc = EIO;
|
---|
342 | resp.window_destroy_called = false;
|
---|
343 | rc = display_window_destroy(wnd);
|
---|
344 | PCUT_ASSERT_TRUE(resp.window_destroy_called);
|
---|
345 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.destroy_wnd_id);
|
---|
346 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
347 |
|
---|
348 | display_close(disp);
|
---|
349 | rc = loc_service_unregister(sid);
|
---|
350 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
351 | }
|
---|
352 |
|
---|
353 | /** display_window_destroy() can handle NULL argument */
|
---|
354 | PCUT_TEST(window_destroy_null)
|
---|
355 | {
|
---|
356 | display_window_destroy(NULL);
|
---|
357 | }
|
---|
358 |
|
---|
359 | /** display_window_move_req() with server returning error response works. */
|
---|
360 | PCUT_TEST(window_move_req_failure)
|
---|
361 | {
|
---|
362 | errno_t rc;
|
---|
363 | service_id_t sid;
|
---|
364 | display_t *disp = NULL;
|
---|
365 | display_wnd_params_t params;
|
---|
366 | display_window_t *wnd;
|
---|
367 | test_response_t resp;
|
---|
368 | gfx_coord2_t pos;
|
---|
369 |
|
---|
370 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
371 |
|
---|
372 | // FIXME This causes this test to be non-reentrant!
|
---|
373 | rc = loc_server_register(test_display_server);
|
---|
374 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
375 |
|
---|
376 | rc = loc_service_register(test_display_svc, &sid);
|
---|
377 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
378 |
|
---|
379 | rc = display_open(test_display_svc, &disp);
|
---|
380 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
381 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
382 |
|
---|
383 | resp.rc = EOK;
|
---|
384 | display_wnd_params_init(¶ms);
|
---|
385 | params.rect.p0.x = 0;
|
---|
386 | params.rect.p0.y = 0;
|
---|
387 | params.rect.p0.x = 100;
|
---|
388 | params.rect.p0.y = 100;
|
---|
389 |
|
---|
390 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
391 | (void *) &resp, &wnd);
|
---|
392 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
393 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
394 |
|
---|
395 | resp.rc = EIO;
|
---|
396 | resp.window_move_req_called = false;
|
---|
397 |
|
---|
398 | pos.x = 42;
|
---|
399 | pos.y = 43;
|
---|
400 |
|
---|
401 | rc = display_window_move_req(wnd, &pos);
|
---|
402 | PCUT_ASSERT_TRUE(resp.window_move_req_called);
|
---|
403 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
404 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_req_wnd_id);
|
---|
405 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.move_req_pos.x);
|
---|
406 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.move_req_pos.y);
|
---|
407 |
|
---|
408 | display_window_destroy(wnd);
|
---|
409 | display_close(disp);
|
---|
410 | rc = loc_service_unregister(sid);
|
---|
411 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
412 | }
|
---|
413 |
|
---|
414 | /** display_window_move_req() with server returning success response works. */
|
---|
415 | PCUT_TEST(window_move_req_success)
|
---|
416 | {
|
---|
417 | errno_t rc;
|
---|
418 | service_id_t sid;
|
---|
419 | display_t *disp = NULL;
|
---|
420 | display_wnd_params_t params;
|
---|
421 | display_window_t *wnd;
|
---|
422 | test_response_t resp;
|
---|
423 | gfx_coord2_t pos;
|
---|
424 |
|
---|
425 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
426 |
|
---|
427 | // FIXME This causes this test to be non-reentrant!
|
---|
428 | rc = loc_server_register(test_display_server);
|
---|
429 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
430 |
|
---|
431 | rc = loc_service_register(test_display_svc, &sid);
|
---|
432 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
433 |
|
---|
434 | rc = display_open(test_display_svc, &disp);
|
---|
435 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
436 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
437 |
|
---|
438 | resp.rc = EOK;
|
---|
439 | display_wnd_params_init(¶ms);
|
---|
440 | params.rect.p0.x = 0;
|
---|
441 | params.rect.p0.y = 0;
|
---|
442 | params.rect.p0.x = 100;
|
---|
443 | params.rect.p0.y = 100;
|
---|
444 |
|
---|
445 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
446 | (void *) &resp, &wnd);
|
---|
447 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
448 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
449 |
|
---|
450 | resp.rc = EOK;
|
---|
451 | resp.window_move_req_called = false;
|
---|
452 |
|
---|
453 | pos.x = 42;
|
---|
454 | pos.y = 43;
|
---|
455 |
|
---|
456 | rc = display_window_move_req(wnd, &pos);
|
---|
457 | PCUT_ASSERT_TRUE(resp.window_move_req_called);
|
---|
458 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
459 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_req_wnd_id);
|
---|
460 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.move_req_pos.x);
|
---|
461 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.move_req_pos.y);
|
---|
462 |
|
---|
463 | display_window_destroy(wnd);
|
---|
464 | display_close(disp);
|
---|
465 | rc = loc_service_unregister(sid);
|
---|
466 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
467 | }
|
---|
468 |
|
---|
469 | /** display_window_move() with server returning error response works. */
|
---|
470 | PCUT_TEST(window_move_failure)
|
---|
471 | {
|
---|
472 | errno_t rc;
|
---|
473 | service_id_t sid;
|
---|
474 | display_t *disp = NULL;
|
---|
475 | display_wnd_params_t params;
|
---|
476 | display_window_t *wnd;
|
---|
477 | gfx_coord2_t dpos;
|
---|
478 | test_response_t resp;
|
---|
479 |
|
---|
480 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
481 |
|
---|
482 | // FIXME This causes this test to be non-reentrant!
|
---|
483 | rc = loc_server_register(test_display_server);
|
---|
484 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
485 |
|
---|
486 | rc = loc_service_register(test_display_svc, &sid);
|
---|
487 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
488 |
|
---|
489 | rc = display_open(test_display_svc, &disp);
|
---|
490 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
491 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
492 |
|
---|
493 | resp.rc = EOK;
|
---|
494 | display_wnd_params_init(¶ms);
|
---|
495 | params.rect.p0.x = 0;
|
---|
496 | params.rect.p0.y = 0;
|
---|
497 | params.rect.p0.x = 100;
|
---|
498 | params.rect.p0.y = 100;
|
---|
499 |
|
---|
500 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
501 | (void *) &resp, &wnd);
|
---|
502 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
503 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
504 |
|
---|
505 | resp.rc = EIO;
|
---|
506 | resp.window_move_called = false;
|
---|
507 | dpos.x = 11;
|
---|
508 | dpos.y = 12;
|
---|
509 |
|
---|
510 | rc = display_window_move(wnd, &dpos);
|
---|
511 | PCUT_ASSERT_TRUE(resp.window_move_called);
|
---|
512 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
513 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_wnd_id);
|
---|
514 | PCUT_ASSERT_INT_EQUALS(dpos.x, resp.move_dpos.x);
|
---|
515 | PCUT_ASSERT_INT_EQUALS(dpos.y, resp.move_dpos.y);
|
---|
516 |
|
---|
517 | display_window_destroy(wnd);
|
---|
518 | display_close(disp);
|
---|
519 | rc = loc_service_unregister(sid);
|
---|
520 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
521 | }
|
---|
522 |
|
---|
523 | /** display_window_move() with server returning success response works. */
|
---|
524 | PCUT_TEST(window_move_success)
|
---|
525 | {
|
---|
526 | errno_t rc;
|
---|
527 | service_id_t sid;
|
---|
528 | display_t *disp = NULL;
|
---|
529 | display_wnd_params_t params;
|
---|
530 | display_window_t *wnd;
|
---|
531 | gfx_coord2_t dpos;
|
---|
532 | test_response_t resp;
|
---|
533 |
|
---|
534 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
535 |
|
---|
536 | // FIXME This causes this test to be non-reentrant!
|
---|
537 | rc = loc_server_register(test_display_server);
|
---|
538 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
539 |
|
---|
540 | rc = loc_service_register(test_display_svc, &sid);
|
---|
541 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
542 |
|
---|
543 | rc = display_open(test_display_svc, &disp);
|
---|
544 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
545 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
546 |
|
---|
547 | resp.rc = EOK;
|
---|
548 | display_wnd_params_init(¶ms);
|
---|
549 | params.rect.p0.x = 0;
|
---|
550 | params.rect.p0.y = 0;
|
---|
551 | params.rect.p0.x = 100;
|
---|
552 | params.rect.p0.y = 100;
|
---|
553 |
|
---|
554 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
555 | (void *) &resp, &wnd);
|
---|
556 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
557 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
558 |
|
---|
559 | resp.rc = EOK;
|
---|
560 | resp.window_move_called = false;
|
---|
561 | dpos.x = 11;
|
---|
562 | dpos.y = 12;
|
---|
563 |
|
---|
564 | rc = display_window_move(wnd, &dpos);
|
---|
565 | PCUT_ASSERT_TRUE(resp.window_move_called);
|
---|
566 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
567 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_wnd_id);
|
---|
568 | PCUT_ASSERT_INT_EQUALS(dpos.x, resp.move_dpos.x);
|
---|
569 | PCUT_ASSERT_INT_EQUALS(dpos.y, resp.move_dpos.y);
|
---|
570 |
|
---|
571 | display_window_destroy(wnd);
|
---|
572 | display_close(disp);
|
---|
573 | rc = loc_service_unregister(sid);
|
---|
574 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
575 | }
|
---|
576 |
|
---|
577 | /** display_window_get_pos() with server returning error response works. */
|
---|
578 | PCUT_TEST(window_get_pos_failure)
|
---|
579 | {
|
---|
580 | errno_t rc;
|
---|
581 | service_id_t sid;
|
---|
582 | display_t *disp = NULL;
|
---|
583 | display_wnd_params_t params;
|
---|
584 | display_window_t *wnd;
|
---|
585 | gfx_coord2_t dpos;
|
---|
586 | test_response_t resp;
|
---|
587 |
|
---|
588 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
589 |
|
---|
590 | // FIXME This causes this test to be non-reentrant!
|
---|
591 | rc = loc_server_register(test_display_server);
|
---|
592 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
593 |
|
---|
594 | rc = loc_service_register(test_display_svc, &sid);
|
---|
595 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
596 |
|
---|
597 | rc = display_open(test_display_svc, &disp);
|
---|
598 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
599 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
600 |
|
---|
601 | resp.rc = EOK;
|
---|
602 | display_wnd_params_init(¶ms);
|
---|
603 | params.rect.p0.x = 0;
|
---|
604 | params.rect.p0.y = 0;
|
---|
605 | params.rect.p0.x = 100;
|
---|
606 | params.rect.p0.y = 100;
|
---|
607 |
|
---|
608 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
609 | (void *) &resp, &wnd);
|
---|
610 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
611 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
612 |
|
---|
613 | resp.rc = EIO;
|
---|
614 | resp.window_get_pos_called = false;
|
---|
615 |
|
---|
616 | dpos.x = 0;
|
---|
617 | dpos.y = 0;
|
---|
618 |
|
---|
619 | rc = display_window_get_pos(wnd, &dpos);
|
---|
620 | PCUT_ASSERT_TRUE(resp.window_get_pos_called);
|
---|
621 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
622 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.get_pos_wnd_id);
|
---|
623 | PCUT_ASSERT_INT_EQUALS(0, dpos.x);
|
---|
624 | PCUT_ASSERT_INT_EQUALS(0, dpos.y);
|
---|
625 |
|
---|
626 | display_window_destroy(wnd);
|
---|
627 | display_close(disp);
|
---|
628 | rc = loc_service_unregister(sid);
|
---|
629 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
630 | }
|
---|
631 |
|
---|
632 | /** display_window_get_pos() with server returning success response works. */
|
---|
633 | PCUT_TEST(window_get_pos_success)
|
---|
634 | {
|
---|
635 | errno_t rc;
|
---|
636 | service_id_t sid;
|
---|
637 | display_t *disp = NULL;
|
---|
638 | display_wnd_params_t params;
|
---|
639 | display_window_t *wnd;
|
---|
640 | gfx_coord2_t dpos;
|
---|
641 | test_response_t resp;
|
---|
642 |
|
---|
643 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
644 |
|
---|
645 | // FIXME This causes this test to be non-reentrant!
|
---|
646 | rc = loc_server_register(test_display_server);
|
---|
647 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
648 |
|
---|
649 | rc = loc_service_register(test_display_svc, &sid);
|
---|
650 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
651 |
|
---|
652 | rc = display_open(test_display_svc, &disp);
|
---|
653 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
654 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
655 |
|
---|
656 | resp.rc = EOK;
|
---|
657 | display_wnd_params_init(¶ms);
|
---|
658 | params.rect.p0.x = 0;
|
---|
659 | params.rect.p0.y = 0;
|
---|
660 | params.rect.p0.x = 100;
|
---|
661 | params.rect.p0.y = 100;
|
---|
662 |
|
---|
663 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
664 | (void *) &resp, &wnd);
|
---|
665 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
666 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
667 |
|
---|
668 | resp.rc = EOK;
|
---|
669 | resp.window_get_pos_called = false;
|
---|
670 | resp.get_pos_rpos.x = 11;
|
---|
671 | resp.get_pos_rpos.y = 12;
|
---|
672 |
|
---|
673 | dpos.x = 0;
|
---|
674 | dpos.y = 0;
|
---|
675 |
|
---|
676 | rc = display_window_get_pos(wnd, &dpos);
|
---|
677 | PCUT_ASSERT_TRUE(resp.window_get_pos_called);
|
---|
678 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
679 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.get_pos_wnd_id);
|
---|
680 | PCUT_ASSERT_INT_EQUALS(resp.get_pos_rpos.x, dpos.x);
|
---|
681 | PCUT_ASSERT_INT_EQUALS(resp.get_pos_rpos.y, dpos.y);
|
---|
682 |
|
---|
683 | display_window_destroy(wnd);
|
---|
684 | display_close(disp);
|
---|
685 | rc = loc_service_unregister(sid);
|
---|
686 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
687 | }
|
---|
688 |
|
---|
689 | /** display_window_get_max_rect() with server returning error response works. */
|
---|
690 | PCUT_TEST(window_get_max_rect_failure)
|
---|
691 | {
|
---|
692 | errno_t rc;
|
---|
693 | service_id_t sid;
|
---|
694 | display_t *disp = NULL;
|
---|
695 | display_wnd_params_t params;
|
---|
696 | display_window_t *wnd;
|
---|
697 | gfx_rect_t rect;
|
---|
698 | test_response_t resp;
|
---|
699 |
|
---|
700 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
701 |
|
---|
702 | // FIXME This causes this test to be non-reentrant!
|
---|
703 | rc = loc_server_register(test_display_server);
|
---|
704 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
705 |
|
---|
706 | rc = loc_service_register(test_display_svc, &sid);
|
---|
707 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
708 |
|
---|
709 | rc = display_open(test_display_svc, &disp);
|
---|
710 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
711 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
712 |
|
---|
713 | resp.rc = EOK;
|
---|
714 | display_wnd_params_init(¶ms);
|
---|
715 | params.rect.p0.x = 0;
|
---|
716 | params.rect.p0.y = 0;
|
---|
717 | params.rect.p0.x = 100;
|
---|
718 | params.rect.p0.y = 100;
|
---|
719 |
|
---|
720 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
721 | (void *) &resp, &wnd);
|
---|
722 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
723 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
724 |
|
---|
725 | resp.rc = EIO;
|
---|
726 | resp.window_get_max_rect_called = false;
|
---|
727 |
|
---|
728 | rect.p0.x = 0;
|
---|
729 | rect.p0.y = 0;
|
---|
730 | rect.p1.x = 0;
|
---|
731 | rect.p1.y = 0;
|
---|
732 |
|
---|
733 | rc = display_window_get_max_rect(wnd, &rect);
|
---|
734 | PCUT_ASSERT_TRUE(resp.window_get_max_rect_called);
|
---|
735 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
736 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.get_max_rect_wnd_id);
|
---|
737 | PCUT_ASSERT_INT_EQUALS(0, rect.p0.x);
|
---|
738 | PCUT_ASSERT_INT_EQUALS(0, rect.p0.y);
|
---|
739 | PCUT_ASSERT_INT_EQUALS(0, rect.p1.x);
|
---|
740 | PCUT_ASSERT_INT_EQUALS(0, rect.p1.y);
|
---|
741 |
|
---|
742 | display_window_destroy(wnd);
|
---|
743 | display_close(disp);
|
---|
744 | rc = loc_service_unregister(sid);
|
---|
745 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
746 | }
|
---|
747 |
|
---|
748 | /** display_window_get_max_rect() with server returning success response works. */
|
---|
749 | PCUT_TEST(window_get_max_rect_success)
|
---|
750 | {
|
---|
751 | errno_t rc;
|
---|
752 | service_id_t sid;
|
---|
753 | display_t *disp = NULL;
|
---|
754 | display_wnd_params_t params;
|
---|
755 | display_window_t *wnd;
|
---|
756 | gfx_rect_t rect;
|
---|
757 | test_response_t resp;
|
---|
758 |
|
---|
759 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
760 |
|
---|
761 | // FIXME This causes this test to be non-reentrant!
|
---|
762 | rc = loc_server_register(test_display_server);
|
---|
763 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
764 |
|
---|
765 | rc = loc_service_register(test_display_svc, &sid);
|
---|
766 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
767 |
|
---|
768 | rc = display_open(test_display_svc, &disp);
|
---|
769 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
770 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
771 |
|
---|
772 | resp.rc = EOK;
|
---|
773 | display_wnd_params_init(¶ms);
|
---|
774 | params.rect.p0.x = 0;
|
---|
775 | params.rect.p0.y = 0;
|
---|
776 | params.rect.p0.x = 100;
|
---|
777 | params.rect.p0.y = 100;
|
---|
778 |
|
---|
779 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
780 | (void *) &resp, &wnd);
|
---|
781 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
782 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
783 |
|
---|
784 | resp.rc = EOK;
|
---|
785 | resp.window_get_max_rect_called = false;
|
---|
786 | resp.get_max_rect_rrect.p0.x = 11;
|
---|
787 | resp.get_max_rect_rrect.p0.y = 12;
|
---|
788 | resp.get_max_rect_rrect.p1.x = 13;
|
---|
789 | resp.get_max_rect_rrect.p1.y = 14;
|
---|
790 |
|
---|
791 | rect.p0.x = 0;
|
---|
792 | rect.p0.y = 0;
|
---|
793 | rect.p1.x = 0;
|
---|
794 | rect.p1.y = 0;
|
---|
795 |
|
---|
796 | rc = display_window_get_max_rect(wnd, &rect);
|
---|
797 | PCUT_ASSERT_TRUE(resp.window_get_max_rect_called);
|
---|
798 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
799 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.get_max_rect_wnd_id);
|
---|
800 | PCUT_ASSERT_INT_EQUALS(resp.get_max_rect_rrect.p0.x, rect.p0.x);
|
---|
801 | PCUT_ASSERT_INT_EQUALS(resp.get_max_rect_rrect.p0.y, rect.p0.y);
|
---|
802 | PCUT_ASSERT_INT_EQUALS(resp.get_max_rect_rrect.p1.x, rect.p1.x);
|
---|
803 | PCUT_ASSERT_INT_EQUALS(resp.get_max_rect_rrect.p1.y, rect.p1.y);
|
---|
804 |
|
---|
805 | display_window_destroy(wnd);
|
---|
806 | display_close(disp);
|
---|
807 | rc = loc_service_unregister(sid);
|
---|
808 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
809 | }
|
---|
810 |
|
---|
811 | /** display_window_resize_req() with server returning error response works. */
|
---|
812 | PCUT_TEST(window_resize_req_failure)
|
---|
813 | {
|
---|
814 | errno_t rc;
|
---|
815 | service_id_t sid;
|
---|
816 | display_t *disp = NULL;
|
---|
817 | display_wnd_params_t params;
|
---|
818 | display_window_t *wnd;
|
---|
819 | test_response_t resp;
|
---|
820 | display_wnd_rsztype_t rsztype;
|
---|
821 | gfx_coord2_t pos;
|
---|
822 |
|
---|
823 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
824 |
|
---|
825 | // FIXME This causes this test to be non-reentrant!
|
---|
826 | rc = loc_server_register(test_display_server);
|
---|
827 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
828 |
|
---|
829 | rc = loc_service_register(test_display_svc, &sid);
|
---|
830 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
831 |
|
---|
832 | rc = display_open(test_display_svc, &disp);
|
---|
833 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
834 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
835 |
|
---|
836 | resp.rc = EOK;
|
---|
837 | display_wnd_params_init(¶ms);
|
---|
838 | params.rect.p0.x = 0;
|
---|
839 | params.rect.p0.y = 0;
|
---|
840 | params.rect.p0.x = 100;
|
---|
841 | params.rect.p0.y = 100;
|
---|
842 |
|
---|
843 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
844 | (void *) &resp, &wnd);
|
---|
845 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
846 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
847 |
|
---|
848 | resp.rc = EIO;
|
---|
849 | resp.window_resize_req_called = false;
|
---|
850 |
|
---|
851 | rsztype = display_wr_top_right;
|
---|
852 | pos.x = 42;
|
---|
853 | pos.y = 43;
|
---|
854 |
|
---|
855 | rc = display_window_resize_req(wnd, rsztype, &pos);
|
---|
856 | PCUT_ASSERT_TRUE(resp.window_resize_req_called);
|
---|
857 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
858 | PCUT_ASSERT_INT_EQUALS(rsztype, resp.resize_req_rsztype);
|
---|
859 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_req_wnd_id);
|
---|
860 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x);
|
---|
861 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y);
|
---|
862 |
|
---|
863 | display_window_destroy(wnd);
|
---|
864 | display_close(disp);
|
---|
865 | rc = loc_service_unregister(sid);
|
---|
866 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
867 | }
|
---|
868 |
|
---|
869 | /** display_window_resize_req() with server returning success response works. */
|
---|
870 | PCUT_TEST(window_resize_req_success)
|
---|
871 | {
|
---|
872 | errno_t rc;
|
---|
873 | service_id_t sid;
|
---|
874 | display_t *disp = NULL;
|
---|
875 | display_wnd_params_t params;
|
---|
876 | display_window_t *wnd;
|
---|
877 | test_response_t resp;
|
---|
878 | display_wnd_rsztype_t rsztype;
|
---|
879 | gfx_coord2_t pos;
|
---|
880 |
|
---|
881 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
882 |
|
---|
883 | // FIXME This causes this test to be non-reentrant!
|
---|
884 | rc = loc_server_register(test_display_server);
|
---|
885 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
886 |
|
---|
887 | rc = loc_service_register(test_display_svc, &sid);
|
---|
888 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
889 |
|
---|
890 | rc = display_open(test_display_svc, &disp);
|
---|
891 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
892 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
893 |
|
---|
894 | resp.rc = EOK;
|
---|
895 | display_wnd_params_init(¶ms);
|
---|
896 | params.rect.p0.x = 0;
|
---|
897 | params.rect.p0.y = 0;
|
---|
898 | params.rect.p0.x = 100;
|
---|
899 | params.rect.p0.y = 100;
|
---|
900 |
|
---|
901 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
902 | (void *) &resp, &wnd);
|
---|
903 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
904 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
905 |
|
---|
906 | resp.rc = EOK;
|
---|
907 | resp.window_resize_req_called = false;
|
---|
908 |
|
---|
909 | rsztype = display_wr_top_right;
|
---|
910 | pos.x = 42;
|
---|
911 | pos.y = 43;
|
---|
912 |
|
---|
913 | rc = display_window_resize_req(wnd, rsztype, &pos);
|
---|
914 | PCUT_ASSERT_TRUE(resp.window_resize_req_called);
|
---|
915 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
916 | PCUT_ASSERT_INT_EQUALS(rsztype, resp.resize_req_rsztype);
|
---|
917 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_req_wnd_id);
|
---|
918 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x);
|
---|
919 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y);
|
---|
920 |
|
---|
921 | display_window_destroy(wnd);
|
---|
922 | display_close(disp);
|
---|
923 | rc = loc_service_unregister(sid);
|
---|
924 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
925 | }
|
---|
926 |
|
---|
927 | /** display_window_resize() with server returning error response works. */
|
---|
928 | PCUT_TEST(window_resize_failure)
|
---|
929 | {
|
---|
930 | errno_t rc;
|
---|
931 | service_id_t sid;
|
---|
932 | display_t *disp = NULL;
|
---|
933 | display_wnd_params_t params;
|
---|
934 | display_window_t *wnd;
|
---|
935 | gfx_coord2_t offs;
|
---|
936 | gfx_rect_t nrect;
|
---|
937 | test_response_t resp;
|
---|
938 |
|
---|
939 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
940 |
|
---|
941 | // FIXME This causes this test to be non-reentrant!
|
---|
942 | rc = loc_server_register(test_display_server);
|
---|
943 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
944 |
|
---|
945 | rc = loc_service_register(test_display_svc, &sid);
|
---|
946 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
947 |
|
---|
948 | rc = display_open(test_display_svc, &disp);
|
---|
949 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
950 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
951 |
|
---|
952 | resp.rc = EOK;
|
---|
953 | display_wnd_params_init(¶ms);
|
---|
954 | params.rect.p0.x = 0;
|
---|
955 | params.rect.p0.y = 0;
|
---|
956 | params.rect.p0.x = 100;
|
---|
957 | params.rect.p0.y = 100;
|
---|
958 |
|
---|
959 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
960 | (void *) &resp, &wnd);
|
---|
961 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
962 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
963 |
|
---|
964 | resp.rc = EIO;
|
---|
965 | resp.window_resize_called = false;
|
---|
966 | offs.x = 11;
|
---|
967 | offs.y = 12;
|
---|
968 | nrect.p0.x = 13;
|
---|
969 | nrect.p0.y = 14;
|
---|
970 | nrect.p1.x = 15;
|
---|
971 | nrect.p1.y = 16;
|
---|
972 |
|
---|
973 | rc = display_window_resize(wnd, &offs, &nrect);
|
---|
974 | PCUT_ASSERT_TRUE(resp.window_resize_called);
|
---|
975 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
976 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_wnd_id);
|
---|
977 | PCUT_ASSERT_INT_EQUALS(offs.x, resp.resize_offs.x);
|
---|
978 | PCUT_ASSERT_INT_EQUALS(offs.y, resp.resize_offs.y);
|
---|
979 | PCUT_ASSERT_INT_EQUALS(nrect.p0.x, resp.resize_nbound.p0.x);
|
---|
980 | PCUT_ASSERT_INT_EQUALS(nrect.p0.y, resp.resize_nbound.p0.y);
|
---|
981 | PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x);
|
---|
982 | PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y);
|
---|
983 |
|
---|
984 | display_window_destroy(wnd);
|
---|
985 | display_close(disp);
|
---|
986 | rc = loc_service_unregister(sid);
|
---|
987 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
988 | }
|
---|
989 |
|
---|
990 | /** display_window_resize() with server returning success response works. */
|
---|
991 | PCUT_TEST(window_resize_success)
|
---|
992 | {
|
---|
993 | errno_t rc;
|
---|
994 | service_id_t sid;
|
---|
995 | display_t *disp = NULL;
|
---|
996 | display_wnd_params_t params;
|
---|
997 | display_window_t *wnd;
|
---|
998 | gfx_coord2_t offs;
|
---|
999 | gfx_rect_t nrect;
|
---|
1000 | test_response_t resp;
|
---|
1001 |
|
---|
1002 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1003 |
|
---|
1004 | // FIXME This causes this test to be non-reentrant!
|
---|
1005 | rc = loc_server_register(test_display_server);
|
---|
1006 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1007 |
|
---|
1008 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1009 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1010 |
|
---|
1011 | rc = display_open(test_display_svc, &disp);
|
---|
1012 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1013 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1014 |
|
---|
1015 | resp.rc = EOK;
|
---|
1016 | display_wnd_params_init(¶ms);
|
---|
1017 | params.rect.p0.x = 0;
|
---|
1018 | params.rect.p0.y = 0;
|
---|
1019 | params.rect.p0.x = 100;
|
---|
1020 | params.rect.p0.y = 100;
|
---|
1021 |
|
---|
1022 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1023 | (void *) &resp, &wnd);
|
---|
1024 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1025 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1026 |
|
---|
1027 | resp.rc = EOK;
|
---|
1028 | resp.window_resize_called = false;
|
---|
1029 | offs.x = 11;
|
---|
1030 | offs.y = 12;
|
---|
1031 | nrect.p0.x = 13;
|
---|
1032 | nrect.p0.y = 14;
|
---|
1033 | nrect.p1.x = 15;
|
---|
1034 | nrect.p1.y = 16;
|
---|
1035 |
|
---|
1036 | rc = display_window_resize(wnd, &offs, &nrect);
|
---|
1037 | PCUT_ASSERT_TRUE(resp.window_resize_called);
|
---|
1038 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
1039 | PCUT_ASSERT_INT_EQUALS(offs.x, resp.resize_offs.x);
|
---|
1040 | PCUT_ASSERT_INT_EQUALS(offs.y, resp.resize_offs.y);
|
---|
1041 | PCUT_ASSERT_INT_EQUALS(nrect.p0.x, resp.resize_nbound.p0.x);
|
---|
1042 | PCUT_ASSERT_INT_EQUALS(nrect.p0.y, resp.resize_nbound.p0.y);
|
---|
1043 | PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x);
|
---|
1044 | PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y);
|
---|
1045 |
|
---|
1046 | display_window_destroy(wnd);
|
---|
1047 | display_close(disp);
|
---|
1048 | rc = loc_service_unregister(sid);
|
---|
1049 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1050 | }
|
---|
1051 |
|
---|
1052 | /** display_window_maximize() with server returning error response works. */
|
---|
1053 | PCUT_TEST(window_maximize_failure)
|
---|
1054 | {
|
---|
1055 | errno_t rc;
|
---|
1056 | service_id_t sid;
|
---|
1057 | display_t *disp = NULL;
|
---|
1058 | display_wnd_params_t params;
|
---|
1059 | display_window_t *wnd;
|
---|
1060 | test_response_t resp;
|
---|
1061 |
|
---|
1062 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1063 |
|
---|
1064 | // FIXME This causes this test to be non-reentrant!
|
---|
1065 | rc = loc_server_register(test_display_server);
|
---|
1066 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1067 |
|
---|
1068 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1069 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1070 |
|
---|
1071 | rc = display_open(test_display_svc, &disp);
|
---|
1072 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1073 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1074 |
|
---|
1075 | resp.rc = EOK;
|
---|
1076 | display_wnd_params_init(¶ms);
|
---|
1077 | params.rect.p0.x = 0;
|
---|
1078 | params.rect.p0.y = 0;
|
---|
1079 | params.rect.p0.x = 100;
|
---|
1080 | params.rect.p0.y = 100;
|
---|
1081 |
|
---|
1082 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1083 | (void *) &resp, &wnd);
|
---|
1084 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1085 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1086 |
|
---|
1087 | resp.rc = EIO;
|
---|
1088 | resp.window_maximize_called = false;
|
---|
1089 |
|
---|
1090 | rc = display_window_maximize(wnd);
|
---|
1091 | PCUT_ASSERT_TRUE(resp.window_maximize_called);
|
---|
1092 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
1093 |
|
---|
1094 | display_window_destroy(wnd);
|
---|
1095 | display_close(disp);
|
---|
1096 | rc = loc_service_unregister(sid);
|
---|
1097 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1098 | }
|
---|
1099 |
|
---|
1100 | /** display_window_maximize() with server returning success response works. */
|
---|
1101 | PCUT_TEST(window_maximize_success)
|
---|
1102 | {
|
---|
1103 | errno_t rc;
|
---|
1104 | service_id_t sid;
|
---|
1105 | display_t *disp = NULL;
|
---|
1106 | display_wnd_params_t params;
|
---|
1107 | display_window_t *wnd;
|
---|
1108 | test_response_t resp;
|
---|
1109 |
|
---|
1110 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1111 |
|
---|
1112 | // FIXME This causes this test to be non-reentrant!
|
---|
1113 | rc = loc_server_register(test_display_server);
|
---|
1114 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1115 |
|
---|
1116 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1117 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1118 |
|
---|
1119 | rc = display_open(test_display_svc, &disp);
|
---|
1120 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1121 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1122 |
|
---|
1123 | resp.rc = EOK;
|
---|
1124 | display_wnd_params_init(¶ms);
|
---|
1125 | params.rect.p0.x = 0;
|
---|
1126 | params.rect.p0.y = 0;
|
---|
1127 | params.rect.p0.x = 100;
|
---|
1128 | params.rect.p0.y = 100;
|
---|
1129 |
|
---|
1130 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1131 | (void *) &resp, &wnd);
|
---|
1132 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1133 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1134 |
|
---|
1135 | resp.rc = EOK;
|
---|
1136 | resp.window_maximize_called = false;
|
---|
1137 |
|
---|
1138 | rc = display_window_maximize(wnd);
|
---|
1139 | PCUT_ASSERT_TRUE(resp.window_maximize_called);
|
---|
1140 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
1141 |
|
---|
1142 | display_window_destroy(wnd);
|
---|
1143 | display_close(disp);
|
---|
1144 | rc = loc_service_unregister(sid);
|
---|
1145 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 | /** display_window_set_cursor() with server returning error response works. */
|
---|
1149 | PCUT_TEST(window_set_cursor_failure)
|
---|
1150 | {
|
---|
1151 | errno_t rc;
|
---|
1152 | service_id_t sid;
|
---|
1153 | display_t *disp = NULL;
|
---|
1154 | display_wnd_params_t params;
|
---|
1155 | display_window_t *wnd;
|
---|
1156 | test_response_t resp;
|
---|
1157 |
|
---|
1158 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1159 |
|
---|
1160 | // FIXME This causes this test to be non-reentrant!
|
---|
1161 | rc = loc_server_register(test_display_server);
|
---|
1162 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1163 |
|
---|
1164 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1165 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1166 |
|
---|
1167 | rc = display_open(test_display_svc, &disp);
|
---|
1168 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1169 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1170 |
|
---|
1171 | resp.rc = EOK;
|
---|
1172 | display_wnd_params_init(¶ms);
|
---|
1173 | params.rect.p0.x = 0;
|
---|
1174 | params.rect.p0.y = 0;
|
---|
1175 | params.rect.p0.x = 100;
|
---|
1176 | params.rect.p0.y = 100;
|
---|
1177 |
|
---|
1178 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1179 | (void *) &resp, &wnd);
|
---|
1180 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1181 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1182 |
|
---|
1183 | resp.rc = EIO;
|
---|
1184 | resp.window_set_cursor_called = false;
|
---|
1185 |
|
---|
1186 | rc = display_window_set_cursor(wnd, dcurs_size_ud);
|
---|
1187 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.set_cursor_wnd_id);
|
---|
1188 | PCUT_ASSERT_TRUE(resp.window_set_cursor_called);
|
---|
1189 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
1190 | PCUT_ASSERT_INT_EQUALS(dcurs_size_ud, resp.set_cursor_cursor);
|
---|
1191 |
|
---|
1192 | display_window_destroy(wnd);
|
---|
1193 | display_close(disp);
|
---|
1194 | rc = loc_service_unregister(sid);
|
---|
1195 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1196 | }
|
---|
1197 |
|
---|
1198 | /** display_window_set_cursor() with server returning success response works. */
|
---|
1199 | PCUT_TEST(window_set_cursor_success)
|
---|
1200 | {
|
---|
1201 | errno_t rc;
|
---|
1202 | service_id_t sid;
|
---|
1203 | display_t *disp = NULL;
|
---|
1204 | display_wnd_params_t params;
|
---|
1205 | display_window_t *wnd;
|
---|
1206 | test_response_t resp;
|
---|
1207 |
|
---|
1208 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1209 |
|
---|
1210 | // FIXME This causes this test to be non-reentrant!
|
---|
1211 | rc = loc_server_register(test_display_server);
|
---|
1212 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1213 |
|
---|
1214 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1215 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1216 |
|
---|
1217 | rc = display_open(test_display_svc, &disp);
|
---|
1218 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1219 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1220 |
|
---|
1221 | resp.rc = EOK;
|
---|
1222 | display_wnd_params_init(¶ms);
|
---|
1223 | params.rect.p0.x = 0;
|
---|
1224 | params.rect.p0.y = 0;
|
---|
1225 | params.rect.p0.x = 100;
|
---|
1226 | params.rect.p0.y = 100;
|
---|
1227 |
|
---|
1228 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1229 | (void *) &resp, &wnd);
|
---|
1230 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1231 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1232 |
|
---|
1233 | resp.rc = EOK;
|
---|
1234 | resp.window_set_cursor_called = false;
|
---|
1235 |
|
---|
1236 | rc = display_window_set_cursor(wnd, dcurs_size_ud);
|
---|
1237 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.set_cursor_wnd_id);
|
---|
1238 | PCUT_ASSERT_TRUE(resp.window_set_cursor_called);
|
---|
1239 | PCUT_ASSERT_ERRNO_VAL(resp.rc, EOK);
|
---|
1240 | PCUT_ASSERT_INT_EQUALS(dcurs_size_ud, resp.set_cursor_cursor);
|
---|
1241 |
|
---|
1242 | display_window_destroy(wnd);
|
---|
1243 | display_close(disp);
|
---|
1244 | rc = loc_service_unregister(sid);
|
---|
1245 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 | /** display_window_get_gc with server returning failure */
|
---|
1249 | PCUT_TEST(window_get_gc_failure)
|
---|
1250 | {
|
---|
1251 | errno_t rc;
|
---|
1252 | service_id_t sid;
|
---|
1253 | display_t *disp = NULL;
|
---|
1254 | display_wnd_params_t params;
|
---|
1255 | display_window_t *wnd;
|
---|
1256 | test_response_t resp;
|
---|
1257 | gfx_context_t *gc;
|
---|
1258 |
|
---|
1259 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1260 |
|
---|
1261 | // FIXME This causes this test to be non-reentrant!
|
---|
1262 | rc = loc_server_register(test_display_server);
|
---|
1263 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1264 |
|
---|
1265 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1266 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1267 |
|
---|
1268 | rc = display_open(test_display_svc, &disp);
|
---|
1269 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1270 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1271 |
|
---|
1272 | wnd = NULL;
|
---|
1273 | resp.rc = EOK;
|
---|
1274 | display_wnd_params_init(¶ms);
|
---|
1275 | params.rect.p0.x = 0;
|
---|
1276 | params.rect.p0.y = 0;
|
---|
1277 | params.rect.p0.x = 100;
|
---|
1278 | params.rect.p0.y = 100;
|
---|
1279 |
|
---|
1280 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1281 | (void *) &resp, &wnd);
|
---|
1282 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1283 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1284 |
|
---|
1285 | gc = NULL;
|
---|
1286 | resp.rc = ENOMEM;
|
---|
1287 | rc = display_window_get_gc(wnd, &gc);
|
---|
1288 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
1289 | PCUT_ASSERT_NULL(gc);
|
---|
1290 |
|
---|
1291 | resp.rc = EOK;
|
---|
1292 | rc = display_window_destroy(wnd);
|
---|
1293 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1294 |
|
---|
1295 | display_close(disp);
|
---|
1296 | rc = loc_service_unregister(sid);
|
---|
1297 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 | /** display_window_get_gc with server returning success */
|
---|
1301 | PCUT_TEST(window_get_gc_success)
|
---|
1302 | {
|
---|
1303 | errno_t rc;
|
---|
1304 | service_id_t sid;
|
---|
1305 | display_t *disp = NULL;
|
---|
1306 | display_wnd_params_t params;
|
---|
1307 | display_window_t *wnd;
|
---|
1308 | test_response_t resp;
|
---|
1309 | gfx_context_t *gc;
|
---|
1310 | gfx_color_t *color;
|
---|
1311 |
|
---|
1312 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1313 |
|
---|
1314 | // FIXME This causes this test to be non-reentrant!
|
---|
1315 | rc = loc_server_register(test_display_server);
|
---|
1316 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1317 |
|
---|
1318 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1319 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1320 |
|
---|
1321 | rc = display_open(test_display_svc, &disp);
|
---|
1322 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1323 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1324 |
|
---|
1325 | wnd = NULL;
|
---|
1326 | resp.rc = EOK;
|
---|
1327 | display_wnd_params_init(¶ms);
|
---|
1328 | params.rect.p0.x = 0;
|
---|
1329 | params.rect.p0.y = 0;
|
---|
1330 | params.rect.p0.x = 100;
|
---|
1331 | params.rect.p0.y = 100;
|
---|
1332 |
|
---|
1333 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1334 | (void *) &resp, &wnd);
|
---|
1335 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1336 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1337 |
|
---|
1338 | gc = NULL;
|
---|
1339 | rc = display_window_get_gc(wnd, &gc);
|
---|
1340 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1341 | PCUT_ASSERT_NOT_NULL(gc);
|
---|
1342 |
|
---|
1343 | rc = gfx_color_new_rgb_i16(0, 0, 0, &color);
|
---|
1344 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1345 |
|
---|
1346 | resp.set_color_called = false;
|
---|
1347 | rc = gfx_set_color(gc, color);
|
---|
1348 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1349 | PCUT_ASSERT_TRUE(resp.set_color_called);
|
---|
1350 |
|
---|
1351 | gfx_color_delete(color);
|
---|
1352 |
|
---|
1353 | rc = display_window_destroy(wnd);
|
---|
1354 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1355 |
|
---|
1356 | display_close(disp);
|
---|
1357 | rc = loc_service_unregister(sid);
|
---|
1358 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1359 | }
|
---|
1360 |
|
---|
1361 | /** Close event can be delivered from server to client callback function */
|
---|
1362 | PCUT_TEST(close_event_deliver)
|
---|
1363 | {
|
---|
1364 | errno_t rc;
|
---|
1365 | service_id_t sid;
|
---|
1366 | display_t *disp = NULL;
|
---|
1367 | display_wnd_params_t params;
|
---|
1368 | display_window_t *wnd;
|
---|
1369 | test_response_t resp;
|
---|
1370 |
|
---|
1371 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1372 |
|
---|
1373 | // FIXME This causes this test to be non-reentrant!
|
---|
1374 | rc = loc_server_register(test_display_server);
|
---|
1375 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1376 |
|
---|
1377 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1378 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1379 |
|
---|
1380 | rc = display_open(test_display_svc, &disp);
|
---|
1381 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1382 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1383 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
1384 |
|
---|
1385 | wnd = NULL;
|
---|
1386 | resp.rc = EOK;
|
---|
1387 | display_wnd_params_init(¶ms);
|
---|
1388 | params.rect.p0.x = 0;
|
---|
1389 | params.rect.p0.y = 0;
|
---|
1390 | params.rect.p0.x = 100;
|
---|
1391 | params.rect.p0.y = 100;
|
---|
1392 |
|
---|
1393 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1394 | (void *) &resp, &wnd);
|
---|
1395 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1396 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1397 |
|
---|
1398 | resp.event_cnt = 1;
|
---|
1399 | resp.event.etype = wev_close;
|
---|
1400 | resp.wnd_id = wnd->id;
|
---|
1401 | resp.close_event_called = false;
|
---|
1402 | fibril_mutex_initialize(&resp.event_lock);
|
---|
1403 | fibril_condvar_initialize(&resp.event_cv);
|
---|
1404 | display_srv_ev_pending(resp.srv);
|
---|
1405 |
|
---|
1406 | /* Wait for the event handler to be called. */
|
---|
1407 | fibril_mutex_lock(&resp.event_lock);
|
---|
1408 | while (!resp.close_event_called) {
|
---|
1409 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
1410 | }
|
---|
1411 | fibril_mutex_unlock(&resp.event_lock);
|
---|
1412 |
|
---|
1413 | /* Verify that the event was delivered correctly */
|
---|
1414 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
---|
1415 | resp.revent.etype);
|
---|
1416 |
|
---|
1417 | rc = display_window_destroy(wnd);
|
---|
1418 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1419 |
|
---|
1420 | display_close(disp);
|
---|
1421 |
|
---|
1422 | rc = loc_service_unregister(sid);
|
---|
1423 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | /** Focus event can be delivered from server to client callback function */
|
---|
1427 | PCUT_TEST(focus_event_deliver)
|
---|
1428 | {
|
---|
1429 | errno_t rc;
|
---|
1430 | service_id_t sid;
|
---|
1431 | display_t *disp = NULL;
|
---|
1432 | display_wnd_params_t params;
|
---|
1433 | display_window_t *wnd;
|
---|
1434 | test_response_t resp;
|
---|
1435 |
|
---|
1436 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1437 |
|
---|
1438 | // FIXME This causes this test to be non-reentrant!
|
---|
1439 | rc = loc_server_register(test_display_server);
|
---|
1440 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1441 |
|
---|
1442 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1443 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1444 |
|
---|
1445 | rc = display_open(test_display_svc, &disp);
|
---|
1446 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1447 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1448 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
1449 |
|
---|
1450 | wnd = NULL;
|
---|
1451 | resp.rc = EOK;
|
---|
1452 | display_wnd_params_init(¶ms);
|
---|
1453 | params.rect.p0.x = 0;
|
---|
1454 | params.rect.p0.y = 0;
|
---|
1455 | params.rect.p0.x = 100;
|
---|
1456 | params.rect.p0.y = 100;
|
---|
1457 |
|
---|
1458 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1459 | (void *) &resp, &wnd);
|
---|
1460 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1461 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1462 |
|
---|
1463 | resp.event_cnt = 1;
|
---|
1464 | resp.event.etype = wev_focus;
|
---|
1465 | resp.wnd_id = wnd->id;
|
---|
1466 | resp.focus_event_called = false;
|
---|
1467 | fibril_mutex_initialize(&resp.event_lock);
|
---|
1468 | fibril_condvar_initialize(&resp.event_cv);
|
---|
1469 | display_srv_ev_pending(resp.srv);
|
---|
1470 |
|
---|
1471 | /* Wait for the event handler to be called. */
|
---|
1472 | fibril_mutex_lock(&resp.event_lock);
|
---|
1473 | while (!resp.focus_event_called) {
|
---|
1474 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
1475 | }
|
---|
1476 | fibril_mutex_unlock(&resp.event_lock);
|
---|
1477 |
|
---|
1478 | /* Verify that the event was delivered correctly */
|
---|
1479 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
---|
1480 | resp.revent.etype);
|
---|
1481 |
|
---|
1482 | rc = display_window_destroy(wnd);
|
---|
1483 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1484 |
|
---|
1485 | display_close(disp);
|
---|
1486 |
|
---|
1487 | rc = loc_service_unregister(sid);
|
---|
1488 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | /** Keyboard event can be delivered from server to client callback function */
|
---|
1492 | PCUT_TEST(kbd_event_deliver)
|
---|
1493 | {
|
---|
1494 | errno_t rc;
|
---|
1495 | service_id_t sid;
|
---|
1496 | display_t *disp = NULL;
|
---|
1497 | display_wnd_params_t params;
|
---|
1498 | display_window_t *wnd;
|
---|
1499 | test_response_t resp;
|
---|
1500 |
|
---|
1501 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1502 |
|
---|
1503 | // FIXME This causes this test to be non-reentrant!
|
---|
1504 | rc = loc_server_register(test_display_server);
|
---|
1505 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1506 |
|
---|
1507 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1508 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1509 |
|
---|
1510 | rc = display_open(test_display_svc, &disp);
|
---|
1511 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1512 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1513 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
1514 |
|
---|
1515 | wnd = NULL;
|
---|
1516 | resp.rc = EOK;
|
---|
1517 | display_wnd_params_init(¶ms);
|
---|
1518 | params.rect.p0.x = 0;
|
---|
1519 | params.rect.p0.y = 0;
|
---|
1520 | params.rect.p0.x = 100;
|
---|
1521 | params.rect.p0.y = 100;
|
---|
1522 |
|
---|
1523 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1524 | (void *) &resp, &wnd);
|
---|
1525 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1526 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1527 |
|
---|
1528 | resp.event_cnt = 1;
|
---|
1529 | resp.event.etype = wev_kbd;
|
---|
1530 | resp.event.ev.kbd.type = KEY_PRESS;
|
---|
1531 | resp.event.ev.kbd.key = KC_ENTER;
|
---|
1532 | resp.event.ev.kbd.mods = 0;
|
---|
1533 | resp.event.ev.kbd.c = L'\0';
|
---|
1534 | resp.wnd_id = wnd->id;
|
---|
1535 | resp.kbd_event_called = false;
|
---|
1536 | fibril_mutex_initialize(&resp.event_lock);
|
---|
1537 | fibril_condvar_initialize(&resp.event_cv);
|
---|
1538 | display_srv_ev_pending(resp.srv);
|
---|
1539 |
|
---|
1540 | /* Wait for the event handler to be called. */
|
---|
1541 | fibril_mutex_lock(&resp.event_lock);
|
---|
1542 | while (!resp.kbd_event_called) {
|
---|
1543 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
1544 | }
|
---|
1545 | fibril_mutex_unlock(&resp.event_lock);
|
---|
1546 |
|
---|
1547 | /* Verify that the event was delivered correctly */
|
---|
1548 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
---|
1549 | resp.revent.etype);
|
---|
1550 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.type,
|
---|
1551 | resp.revent.ev.kbd.type);
|
---|
1552 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.key,
|
---|
1553 | resp.revent.ev.kbd.key);
|
---|
1554 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.mods,
|
---|
1555 | resp.revent.ev.kbd.mods);
|
---|
1556 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.c,
|
---|
1557 | resp.revent.ev.kbd.c);
|
---|
1558 |
|
---|
1559 | rc = display_window_destroy(wnd);
|
---|
1560 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1561 |
|
---|
1562 | display_close(disp);
|
---|
1563 |
|
---|
1564 | rc = loc_service_unregister(sid);
|
---|
1565 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1566 | }
|
---|
1567 |
|
---|
1568 | /** Position event can be delivered from server to client callback function */
|
---|
1569 | PCUT_TEST(pos_event_deliver)
|
---|
1570 | {
|
---|
1571 | errno_t rc;
|
---|
1572 | service_id_t sid;
|
---|
1573 | display_t *disp = NULL;
|
---|
1574 | display_wnd_params_t params;
|
---|
1575 | display_window_t *wnd;
|
---|
1576 | test_response_t resp;
|
---|
1577 |
|
---|
1578 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1579 |
|
---|
1580 | // FIXME This causes this test to be non-reentrant!
|
---|
1581 | rc = loc_server_register(test_display_server);
|
---|
1582 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1583 |
|
---|
1584 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1585 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1586 |
|
---|
1587 | rc = display_open(test_display_svc, &disp);
|
---|
1588 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1589 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1590 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
1591 |
|
---|
1592 | wnd = NULL;
|
---|
1593 | resp.rc = EOK;
|
---|
1594 | display_wnd_params_init(¶ms);
|
---|
1595 | params.rect.p0.x = 0;
|
---|
1596 | params.rect.p0.y = 0;
|
---|
1597 | params.rect.p0.x = 100;
|
---|
1598 | params.rect.p0.y = 100;
|
---|
1599 |
|
---|
1600 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1601 | (void *) &resp, &wnd);
|
---|
1602 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1603 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1604 |
|
---|
1605 | resp.event_cnt = 1;
|
---|
1606 | resp.event.etype = wev_pos;
|
---|
1607 | resp.event.ev.pos.type = POS_PRESS;
|
---|
1608 | resp.event.ev.pos.btn_num = 1;
|
---|
1609 | resp.event.ev.pos.hpos = 2;
|
---|
1610 | resp.event.ev.pos.vpos = 3;
|
---|
1611 | resp.wnd_id = wnd->id;
|
---|
1612 | resp.pos_event_called = false;
|
---|
1613 | fibril_mutex_initialize(&resp.event_lock);
|
---|
1614 | fibril_condvar_initialize(&resp.event_cv);
|
---|
1615 | display_srv_ev_pending(resp.srv);
|
---|
1616 |
|
---|
1617 | /* Wait for the event handler to be called. */
|
---|
1618 | fibril_mutex_lock(&resp.event_lock);
|
---|
1619 | while (!resp.pos_event_called) {
|
---|
1620 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
1621 | }
|
---|
1622 | fibril_mutex_unlock(&resp.event_lock);
|
---|
1623 |
|
---|
1624 | /* Verify that the event was delivered correctly */
|
---|
1625 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
---|
1626 | resp.revent.etype);
|
---|
1627 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.type,
|
---|
1628 | resp.revent.ev.pos.type);
|
---|
1629 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.btn_num,
|
---|
1630 | resp.revent.ev.pos.btn_num);
|
---|
1631 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.hpos,
|
---|
1632 | resp.revent.ev.pos.hpos);
|
---|
1633 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.vpos,
|
---|
1634 | resp.revent.ev.pos.vpos);
|
---|
1635 |
|
---|
1636 | rc = display_window_destroy(wnd);
|
---|
1637 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1638 |
|
---|
1639 | display_close(disp);
|
---|
1640 |
|
---|
1641 | rc = loc_service_unregister(sid);
|
---|
1642 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1643 | }
|
---|
1644 |
|
---|
1645 | /** Unfocus event can be delivered from server to client callback function */
|
---|
1646 | PCUT_TEST(unfocus_event_deliver)
|
---|
1647 | {
|
---|
1648 | errno_t rc;
|
---|
1649 | service_id_t sid;
|
---|
1650 | display_t *disp = NULL;
|
---|
1651 | display_wnd_params_t params;
|
---|
1652 | display_window_t *wnd;
|
---|
1653 | test_response_t resp;
|
---|
1654 |
|
---|
1655 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1656 |
|
---|
1657 | // FIXME This causes this test to be non-reentrant!
|
---|
1658 | rc = loc_server_register(test_display_server);
|
---|
1659 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1660 |
|
---|
1661 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1662 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1663 |
|
---|
1664 | rc = display_open(test_display_svc, &disp);
|
---|
1665 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1666 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1667 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
1668 |
|
---|
1669 | wnd = NULL;
|
---|
1670 | resp.rc = EOK;
|
---|
1671 | display_wnd_params_init(¶ms);
|
---|
1672 | params.rect.p0.x = 0;
|
---|
1673 | params.rect.p0.y = 0;
|
---|
1674 | params.rect.p0.x = 100;
|
---|
1675 | params.rect.p0.y = 100;
|
---|
1676 |
|
---|
1677 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
1678 | (void *) &resp, &wnd);
|
---|
1679 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1680 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
1681 |
|
---|
1682 | resp.event_cnt = 1;
|
---|
1683 | resp.event.etype = wev_unfocus;
|
---|
1684 | resp.wnd_id = wnd->id;
|
---|
1685 | resp.unfocus_event_called = false;
|
---|
1686 | fibril_mutex_initialize(&resp.event_lock);
|
---|
1687 | fibril_condvar_initialize(&resp.event_cv);
|
---|
1688 | display_srv_ev_pending(resp.srv);
|
---|
1689 |
|
---|
1690 | /* Wait for the event handler to be called. */
|
---|
1691 | fibril_mutex_lock(&resp.event_lock);
|
---|
1692 | while (!resp.unfocus_event_called) {
|
---|
1693 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
1694 | }
|
---|
1695 | fibril_mutex_unlock(&resp.event_lock);
|
---|
1696 |
|
---|
1697 | /* Verify that the event was delivered correctly */
|
---|
1698 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
---|
1699 | resp.revent.etype);
|
---|
1700 |
|
---|
1701 | rc = display_window_destroy(wnd);
|
---|
1702 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1703 |
|
---|
1704 | display_close(disp);
|
---|
1705 |
|
---|
1706 | rc = loc_service_unregister(sid);
|
---|
1707 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1708 | }
|
---|
1709 |
|
---|
1710 | /** display_get_info() with server returning failure response works. */
|
---|
1711 | PCUT_TEST(get_info_failure)
|
---|
1712 | {
|
---|
1713 | errno_t rc;
|
---|
1714 | service_id_t sid;
|
---|
1715 | display_t *disp = NULL;
|
---|
1716 | display_info_t info;
|
---|
1717 | test_response_t resp;
|
---|
1718 |
|
---|
1719 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1720 |
|
---|
1721 | // FIXME This causes this test to be non-reentrant!
|
---|
1722 | rc = loc_server_register(test_display_server);
|
---|
1723 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1724 |
|
---|
1725 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1726 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1727 |
|
---|
1728 | rc = display_open(test_display_svc, &disp);
|
---|
1729 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1730 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1731 |
|
---|
1732 | resp.rc = ENOMEM;
|
---|
1733 | resp.get_info_called = false;
|
---|
1734 |
|
---|
1735 | rc = display_get_info(disp, &info);
|
---|
1736 | PCUT_ASSERT_TRUE(resp.get_info_called);
|
---|
1737 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
1738 |
|
---|
1739 | display_close(disp);
|
---|
1740 | rc = loc_service_unregister(sid);
|
---|
1741 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1742 | }
|
---|
1743 |
|
---|
1744 | /** display_get_info() with server returning success response works. */
|
---|
1745 | PCUT_TEST(get_info_success)
|
---|
1746 | {
|
---|
1747 | errno_t rc;
|
---|
1748 | service_id_t sid;
|
---|
1749 | display_t *disp = NULL;
|
---|
1750 | display_info_t info;
|
---|
1751 | test_response_t resp;
|
---|
1752 |
|
---|
1753 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
1754 |
|
---|
1755 | // FIXME This causes this test to be non-reentrant!
|
---|
1756 | rc = loc_server_register(test_display_server);
|
---|
1757 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1758 |
|
---|
1759 | rc = loc_service_register(test_display_svc, &sid);
|
---|
1760 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1761 |
|
---|
1762 | rc = display_open(test_display_svc, &disp);
|
---|
1763 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1764 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
1765 |
|
---|
1766 | resp.rc = EOK;
|
---|
1767 | resp.get_info_called = false;
|
---|
1768 | resp.get_info_rect.p0.x = 10;
|
---|
1769 | resp.get_info_rect.p0.y = 11;
|
---|
1770 | resp.get_info_rect.p1.x = 20;
|
---|
1771 | resp.get_info_rect.p1.y = 21;
|
---|
1772 |
|
---|
1773 | rc = display_get_info(disp, &info);
|
---|
1774 | PCUT_ASSERT_TRUE(resp.get_info_called);
|
---|
1775 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
1776 | PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p0.x, info.rect.p0.x);
|
---|
1777 | PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p0.y, info.rect.p0.y);
|
---|
1778 | PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p1.x, info.rect.p1.x);
|
---|
1779 | PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p1.y, info.rect.p1.y);
|
---|
1780 |
|
---|
1781 | display_close(disp);
|
---|
1782 | rc = loc_service_unregister(sid);
|
---|
1783 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
1784 | }
|
---|
1785 |
|
---|
1786 | /** Test display service connection.
|
---|
1787 | *
|
---|
1788 | * This is very similar to connection handler in the display server.
|
---|
1789 | * XXX This should be folded into display_srv, if possible
|
---|
1790 | */
|
---|
1791 | static void test_display_conn(ipc_call_t *icall, void *arg)
|
---|
1792 | {
|
---|
1793 | test_response_t *resp = (test_response_t *) arg;
|
---|
1794 | display_srv_t srv;
|
---|
1795 | sysarg_t wnd_id;
|
---|
1796 | sysarg_t svc_id;
|
---|
1797 | gfx_context_t *gc;
|
---|
1798 | errno_t rc;
|
---|
1799 |
|
---|
1800 | svc_id = ipc_get_arg2(icall);
|
---|
1801 | wnd_id = ipc_get_arg3(icall);
|
---|
1802 |
|
---|
1803 | if (svc_id != 0) {
|
---|
1804 | /* Set up protocol structure */
|
---|
1805 | display_srv_initialize(&srv);
|
---|
1806 | srv.ops = &test_display_srv_ops;
|
---|
1807 | srv.arg = arg;
|
---|
1808 | resp->srv = &srv;
|
---|
1809 |
|
---|
1810 | /* Handle connection */
|
---|
1811 | display_conn(icall, &srv);
|
---|
1812 |
|
---|
1813 | resp->srv = NULL;
|
---|
1814 | } else {
|
---|
1815 | (void) wnd_id;
|
---|
1816 |
|
---|
1817 | if (resp->rc != EOK) {
|
---|
1818 | async_answer_0(icall, resp->rc);
|
---|
1819 | return;
|
---|
1820 | }
|
---|
1821 |
|
---|
1822 | rc = gfx_context_new(&test_gc_ops, arg, &gc);
|
---|
1823 | if (rc != EOK) {
|
---|
1824 | async_answer_0(icall, ENOMEM);
|
---|
1825 | return;
|
---|
1826 | }
|
---|
1827 |
|
---|
1828 | /* Window GC connection */
|
---|
1829 | gc_conn(icall, gc);
|
---|
1830 | }
|
---|
1831 | }
|
---|
1832 |
|
---|
1833 | static void test_close_event(void *arg)
|
---|
1834 | {
|
---|
1835 | test_response_t *resp = (test_response_t *) arg;
|
---|
1836 |
|
---|
1837 | resp->revent.etype = wev_close;
|
---|
1838 |
|
---|
1839 | fibril_mutex_lock(&resp->event_lock);
|
---|
1840 | resp->close_event_called = true;
|
---|
1841 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
1842 | fibril_mutex_unlock(&resp->event_lock);
|
---|
1843 | }
|
---|
1844 |
|
---|
1845 | static void test_focus_event(void *arg)
|
---|
1846 | {
|
---|
1847 | test_response_t *resp = (test_response_t *) arg;
|
---|
1848 |
|
---|
1849 | resp->revent.etype = wev_focus;
|
---|
1850 |
|
---|
1851 | fibril_mutex_lock(&resp->event_lock);
|
---|
1852 | resp->focus_event_called = true;
|
---|
1853 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
1854 | fibril_mutex_unlock(&resp->event_lock);
|
---|
1855 | }
|
---|
1856 |
|
---|
1857 | static void test_kbd_event(void *arg, kbd_event_t *event)
|
---|
1858 | {
|
---|
1859 | test_response_t *resp = (test_response_t *) arg;
|
---|
1860 |
|
---|
1861 | resp->revent.etype = wev_kbd;
|
---|
1862 | resp->revent.ev.kbd = *event;
|
---|
1863 |
|
---|
1864 | fibril_mutex_lock(&resp->event_lock);
|
---|
1865 | resp->kbd_event_called = true;
|
---|
1866 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
1867 | fibril_mutex_unlock(&resp->event_lock);
|
---|
1868 | }
|
---|
1869 |
|
---|
1870 | static void test_pos_event(void *arg, pos_event_t *event)
|
---|
1871 | {
|
---|
1872 | test_response_t *resp = (test_response_t *) arg;
|
---|
1873 |
|
---|
1874 | resp->revent.etype = wev_pos;
|
---|
1875 | resp->revent.ev.pos = *event;
|
---|
1876 |
|
---|
1877 | fibril_mutex_lock(&resp->event_lock);
|
---|
1878 | resp->pos_event_called = true;
|
---|
1879 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
1880 | fibril_mutex_unlock(&resp->event_lock);
|
---|
1881 | }
|
---|
1882 |
|
---|
1883 | static void test_unfocus_event(void *arg)
|
---|
1884 | {
|
---|
1885 | test_response_t *resp = (test_response_t *) arg;
|
---|
1886 |
|
---|
1887 | resp->revent.etype = wev_unfocus;
|
---|
1888 |
|
---|
1889 | fibril_mutex_lock(&resp->event_lock);
|
---|
1890 | resp->unfocus_event_called = true;
|
---|
1891 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
1892 | fibril_mutex_unlock(&resp->event_lock);
|
---|
1893 | }
|
---|
1894 |
|
---|
1895 | static errno_t test_window_create(void *arg, display_wnd_params_t *params,
|
---|
1896 | sysarg_t *rwnd_id)
|
---|
1897 | {
|
---|
1898 | test_response_t *resp = (test_response_t *) arg;
|
---|
1899 |
|
---|
1900 | resp->window_create_called = true;
|
---|
1901 | resp->create_rect = params->rect;
|
---|
1902 | resp->create_min_size = params->min_size;
|
---|
1903 | if (resp->rc == EOK)
|
---|
1904 | *rwnd_id = resp->wnd_id;
|
---|
1905 |
|
---|
1906 | return resp->rc;
|
---|
1907 | }
|
---|
1908 |
|
---|
1909 | static errno_t test_window_destroy(void *arg, sysarg_t wnd_id)
|
---|
1910 | {
|
---|
1911 | test_response_t *resp = (test_response_t *) arg;
|
---|
1912 |
|
---|
1913 | resp->window_destroy_called = true;
|
---|
1914 | resp->destroy_wnd_id = wnd_id;
|
---|
1915 | return resp->rc;
|
---|
1916 | }
|
---|
1917 |
|
---|
1918 | static errno_t test_window_move_req(void *arg, sysarg_t wnd_id,
|
---|
1919 | gfx_coord2_t *pos)
|
---|
1920 | {
|
---|
1921 | test_response_t *resp = (test_response_t *) arg;
|
---|
1922 |
|
---|
1923 | resp->window_move_req_called = true;
|
---|
1924 | resp->move_req_wnd_id = wnd_id;
|
---|
1925 | resp->move_req_pos = *pos;
|
---|
1926 | return resp->rc;
|
---|
1927 | }
|
---|
1928 |
|
---|
1929 | static errno_t test_window_move(void *arg, sysarg_t wnd_id, gfx_coord2_t *dpos)
|
---|
1930 | {
|
---|
1931 | test_response_t *resp = (test_response_t *) arg;
|
---|
1932 |
|
---|
1933 | resp->window_move_called = true;
|
---|
1934 | resp->move_wnd_id = wnd_id;
|
---|
1935 | resp->move_dpos = *dpos;
|
---|
1936 | return resp->rc;
|
---|
1937 | }
|
---|
1938 |
|
---|
1939 | static errno_t test_window_get_pos(void *arg, sysarg_t wnd_id, gfx_coord2_t *dpos)
|
---|
1940 | {
|
---|
1941 | test_response_t *resp = (test_response_t *) arg;
|
---|
1942 |
|
---|
1943 | resp->window_get_pos_called = true;
|
---|
1944 | resp->get_pos_wnd_id = wnd_id;
|
---|
1945 |
|
---|
1946 | if (resp->rc == EOK)
|
---|
1947 | *dpos = resp->get_pos_rpos;
|
---|
1948 |
|
---|
1949 | return resp->rc;
|
---|
1950 | }
|
---|
1951 |
|
---|
1952 | static errno_t test_window_get_max_rect(void *arg, sysarg_t wnd_id,
|
---|
1953 | gfx_rect_t *rect)
|
---|
1954 | {
|
---|
1955 | test_response_t *resp = (test_response_t *) arg;
|
---|
1956 |
|
---|
1957 | resp->window_get_max_rect_called = true;
|
---|
1958 | resp->get_max_rect_wnd_id = wnd_id;
|
---|
1959 |
|
---|
1960 | if (resp->rc == EOK)
|
---|
1961 | *rect = resp->get_max_rect_rrect;
|
---|
1962 |
|
---|
1963 | return resp->rc;
|
---|
1964 | }
|
---|
1965 |
|
---|
1966 | static errno_t test_window_resize_req(void *arg, sysarg_t wnd_id,
|
---|
1967 | display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
|
---|
1968 | {
|
---|
1969 | test_response_t *resp = (test_response_t *) arg;
|
---|
1970 |
|
---|
1971 | resp->window_resize_req_called = true;
|
---|
1972 | resp->resize_req_rsztype = rsztype;
|
---|
1973 | resp->resize_req_wnd_id = wnd_id;
|
---|
1974 | resp->resize_req_pos = *pos;
|
---|
1975 | return resp->rc;
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 | static errno_t test_window_resize(void *arg, sysarg_t wnd_id,
|
---|
1979 | gfx_coord2_t *offs, gfx_rect_t *nrect)
|
---|
1980 | {
|
---|
1981 | test_response_t *resp = (test_response_t *) arg;
|
---|
1982 |
|
---|
1983 | resp->window_resize_called = true;
|
---|
1984 | resp->resize_wnd_id = wnd_id;
|
---|
1985 | resp->resize_offs = *offs;
|
---|
1986 | resp->resize_nbound = *nrect;
|
---|
1987 | return resp->rc;
|
---|
1988 | }
|
---|
1989 |
|
---|
1990 | static errno_t test_window_maximize(void *arg, sysarg_t wnd_id)
|
---|
1991 | {
|
---|
1992 | test_response_t *resp = (test_response_t *) arg;
|
---|
1993 |
|
---|
1994 | resp->window_maximize_called = true;
|
---|
1995 | resp->resize_wnd_id = wnd_id;
|
---|
1996 | return resp->rc;
|
---|
1997 | }
|
---|
1998 |
|
---|
1999 | static errno_t test_window_unmaximize(void *arg, sysarg_t wnd_id)
|
---|
2000 | {
|
---|
2001 | test_response_t *resp = (test_response_t *) arg;
|
---|
2002 |
|
---|
2003 | resp->window_unmaximize_called = true;
|
---|
2004 | resp->resize_wnd_id = wnd_id;
|
---|
2005 | return resp->rc;
|
---|
2006 | }
|
---|
2007 |
|
---|
2008 | static errno_t test_window_set_cursor(void *arg, sysarg_t wnd_id,
|
---|
2009 | display_stock_cursor_t cursor)
|
---|
2010 | {
|
---|
2011 | test_response_t *resp = (test_response_t *) arg;
|
---|
2012 |
|
---|
2013 | resp->window_set_cursor_called = true;
|
---|
2014 | resp->set_cursor_wnd_id = wnd_id;
|
---|
2015 | resp->set_cursor_cursor = cursor;
|
---|
2016 |
|
---|
2017 | return resp->rc;
|
---|
2018 | }
|
---|
2019 |
|
---|
2020 | static errno_t test_get_event(void *arg, sysarg_t *wnd_id,
|
---|
2021 | display_wnd_ev_t *event)
|
---|
2022 | {
|
---|
2023 | test_response_t *resp = (test_response_t *) arg;
|
---|
2024 |
|
---|
2025 | resp->get_event_called = true;
|
---|
2026 | if (resp->event_cnt > 0) {
|
---|
2027 | --resp->event_cnt;
|
---|
2028 | *wnd_id = resp->wnd_id;
|
---|
2029 | *event = resp->event;
|
---|
2030 | return EOK;
|
---|
2031 | }
|
---|
2032 |
|
---|
2033 | return ENOENT;
|
---|
2034 | }
|
---|
2035 |
|
---|
2036 | static errno_t test_get_info(void *arg, display_info_t *info)
|
---|
2037 | {
|
---|
2038 | test_response_t *resp = (test_response_t *) arg;
|
---|
2039 |
|
---|
2040 | resp->get_info_called = true;
|
---|
2041 | info->rect = resp->get_info_rect;
|
---|
2042 |
|
---|
2043 | return resp->rc;
|
---|
2044 | }
|
---|
2045 |
|
---|
2046 | static errno_t test_gc_set_color(void *arg, gfx_color_t *color)
|
---|
2047 | {
|
---|
2048 | test_response_t *resp = (test_response_t *) arg;
|
---|
2049 |
|
---|
2050 | resp->set_color_called = true;
|
---|
2051 | return resp->rc;
|
---|
2052 | }
|
---|
2053 |
|
---|
2054 | PCUT_EXPORT(display);
|
---|