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 <disp_srv.h>
|
---|
30 | #include <errno.h>
|
---|
31 | #include <gfx/context.h>
|
---|
32 | #include <pcut/pcut.h>
|
---|
33 | #include <stdio.h>
|
---|
34 | #include <str.h>
|
---|
35 |
|
---|
36 | #include "../client.h"
|
---|
37 | #include "../display.h"
|
---|
38 | #include "../seat.h"
|
---|
39 | #include "../window.h"
|
---|
40 |
|
---|
41 | PCUT_INIT;
|
---|
42 |
|
---|
43 | PCUT_TEST_SUITE(window);
|
---|
44 |
|
---|
45 | static errno_t dummy_set_color(void *, gfx_color_t *);
|
---|
46 | static errno_t dummy_fill_rect(void *, gfx_rect_t *);
|
---|
47 |
|
---|
48 | static gfx_context_ops_t dummy_ops = {
|
---|
49 | .set_color = dummy_set_color,
|
---|
50 | .fill_rect = dummy_fill_rect
|
---|
51 | };
|
---|
52 |
|
---|
53 | /** Test ds_window_resize(). */
|
---|
54 | PCUT_TEST(window_resize)
|
---|
55 | {
|
---|
56 | ds_display_t *disp;
|
---|
57 | ds_client_t *client;
|
---|
58 | ds_seat_t *seat;
|
---|
59 | ds_window_t *wnd;
|
---|
60 | display_wnd_params_t params;
|
---|
61 | gfx_coord2_t offs;
|
---|
62 | gfx_rect_t nrect;
|
---|
63 | errno_t rc;
|
---|
64 |
|
---|
65 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
66 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
67 |
|
---|
68 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
69 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
70 |
|
---|
71 | rc = ds_seat_create(disp, &seat);
|
---|
72 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
73 |
|
---|
74 | display_wnd_params_init(¶ms);
|
---|
75 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
76 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
77 |
|
---|
78 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
79 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
80 |
|
---|
81 | wnd->dpos.x = 100;
|
---|
82 | wnd->dpos.y = 100;
|
---|
83 |
|
---|
84 | offs.x = -2;
|
---|
85 | offs.y = -3;
|
---|
86 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
87 | params.rect.p1.x = 12;
|
---|
88 | params.rect.p1.y = 13;
|
---|
89 | rc = ds_window_resize(wnd, &offs, &nrect);
|
---|
90 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
91 |
|
---|
92 | PCUT_ASSERT_INT_EQUALS(98, wnd->dpos.x);
|
---|
93 | PCUT_ASSERT_INT_EQUALS(97, wnd->dpos.y);
|
---|
94 |
|
---|
95 | ds_window_destroy(wnd);
|
---|
96 | ds_seat_destroy(seat);
|
---|
97 | ds_client_destroy(client);
|
---|
98 | ds_display_destroy(disp);
|
---|
99 | }
|
---|
100 |
|
---|
101 | /** Test ds_window_get_pos(). */
|
---|
102 | PCUT_TEST(get_pos)
|
---|
103 | {
|
---|
104 | ds_display_t *disp;
|
---|
105 | ds_client_t *client;
|
---|
106 | ds_seat_t *seat;
|
---|
107 | ds_window_t *wnd;
|
---|
108 | display_wnd_params_t params;
|
---|
109 | gfx_coord2_t pos;
|
---|
110 | errno_t rc;
|
---|
111 |
|
---|
112 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
113 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
114 |
|
---|
115 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
116 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
117 |
|
---|
118 | rc = ds_seat_create(disp, &seat);
|
---|
119 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
120 |
|
---|
121 | display_wnd_params_init(¶ms);
|
---|
122 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
123 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
124 |
|
---|
125 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
126 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
127 |
|
---|
128 | wnd->dpos.x = 100;
|
---|
129 | wnd->dpos.y = 100;
|
---|
130 |
|
---|
131 | ds_window_get_pos(wnd, &pos);
|
---|
132 |
|
---|
133 | PCUT_ASSERT_INT_EQUALS(100, pos.x);
|
---|
134 | PCUT_ASSERT_INT_EQUALS(100, pos.y);
|
---|
135 |
|
---|
136 | ds_window_destroy(wnd);
|
---|
137 | ds_seat_destroy(seat);
|
---|
138 | ds_client_destroy(client);
|
---|
139 | ds_display_destroy(disp);
|
---|
140 | }
|
---|
141 |
|
---|
142 | /** Test ds_window_get_max_rect(). */
|
---|
143 | PCUT_TEST(get_max_rect)
|
---|
144 | {
|
---|
145 | ds_display_t *disp;
|
---|
146 | ds_client_t *client;
|
---|
147 | ds_seat_t *seat;
|
---|
148 | ds_window_t *wnd;
|
---|
149 | display_wnd_params_t params;
|
---|
150 | gfx_rect_t rect;
|
---|
151 | errno_t rc;
|
---|
152 |
|
---|
153 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
154 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
155 |
|
---|
156 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
157 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
158 |
|
---|
159 | rc = ds_seat_create(disp, &seat);
|
---|
160 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
161 |
|
---|
162 | display_wnd_params_init(¶ms);
|
---|
163 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
164 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
165 |
|
---|
166 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
167 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
168 |
|
---|
169 | wnd->dpos.x = 100;
|
---|
170 | wnd->dpos.y = 100;
|
---|
171 |
|
---|
172 | ds_window_get_max_rect(wnd, &rect);
|
---|
173 |
|
---|
174 | PCUT_ASSERT_INT_EQUALS(disp->rect.p0.x, rect.p0.x);
|
---|
175 | PCUT_ASSERT_INT_EQUALS(disp->rect.p0.y, rect.p0.y);
|
---|
176 | PCUT_ASSERT_INT_EQUALS(disp->rect.p1.x, rect.p1.x);
|
---|
177 | PCUT_ASSERT_INT_EQUALS(disp->rect.p1.y, rect.p1.y);
|
---|
178 |
|
---|
179 | ds_window_destroy(wnd);
|
---|
180 | ds_seat_destroy(seat);
|
---|
181 | ds_client_destroy(client);
|
---|
182 | ds_display_destroy(disp);
|
---|
183 | }
|
---|
184 |
|
---|
185 | /** Test ds_window_maximize(). */
|
---|
186 | PCUT_TEST(window_maximize)
|
---|
187 | {
|
---|
188 | ds_display_t *disp;
|
---|
189 | ds_client_t *client;
|
---|
190 | ds_seat_t *seat;
|
---|
191 | ds_window_t *wnd;
|
---|
192 | display_wnd_params_t params;
|
---|
193 | errno_t rc;
|
---|
194 |
|
---|
195 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
196 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
197 |
|
---|
198 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
199 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
200 |
|
---|
201 | rc = ds_seat_create(disp, &seat);
|
---|
202 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
203 |
|
---|
204 | display_wnd_params_init(¶ms);
|
---|
205 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
206 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
207 |
|
---|
208 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
209 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
210 |
|
---|
211 | wnd->dpos.x = 100;
|
---|
212 | wnd->dpos.y = 100;
|
---|
213 |
|
---|
214 | rc = ds_window_maximize(wnd);
|
---|
215 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
216 |
|
---|
217 | PCUT_ASSERT_INT_EQUALS(wndf_maximized, wnd->flags & wndf_maximized);
|
---|
218 |
|
---|
219 | ds_window_destroy(wnd);
|
---|
220 | ds_seat_destroy(seat);
|
---|
221 | ds_client_destroy(client);
|
---|
222 | ds_display_destroy(disp);
|
---|
223 | }
|
---|
224 |
|
---|
225 | /** Test ds_window_unmaximize(). */
|
---|
226 | PCUT_TEST(window_unmaximize)
|
---|
227 | {
|
---|
228 | ds_display_t *disp;
|
---|
229 | ds_client_t *client;
|
---|
230 | ds_seat_t *seat;
|
---|
231 | ds_window_t *wnd;
|
---|
232 | display_wnd_params_t params;
|
---|
233 | errno_t rc;
|
---|
234 |
|
---|
235 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
236 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
237 |
|
---|
238 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
239 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
240 |
|
---|
241 | rc = ds_seat_create(disp, &seat);
|
---|
242 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
243 |
|
---|
244 | display_wnd_params_init(¶ms);
|
---|
245 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
246 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
247 |
|
---|
248 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
249 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
250 |
|
---|
251 | wnd->dpos.x = 100;
|
---|
252 | wnd->dpos.y = 100;
|
---|
253 |
|
---|
254 | rc = ds_window_maximize(wnd);
|
---|
255 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
256 |
|
---|
257 | rc = ds_window_unmaximize(wnd);
|
---|
258 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
259 |
|
---|
260 | PCUT_ASSERT_INT_EQUALS(0, wnd->flags & wndf_maximized);
|
---|
261 |
|
---|
262 | ds_window_destroy(wnd);
|
---|
263 | ds_seat_destroy(seat);
|
---|
264 | ds_client_destroy(client);
|
---|
265 | ds_display_destroy(disp);
|
---|
266 | }
|
---|
267 |
|
---|
268 | /** Test ds_window_get_ctx(). */
|
---|
269 | PCUT_TEST(window_get_ctx)
|
---|
270 | {
|
---|
271 | ds_display_t *disp;
|
---|
272 | ds_client_t *client;
|
---|
273 | ds_seat_t *seat;
|
---|
274 | ds_window_t *wnd;
|
---|
275 | display_wnd_params_t params;
|
---|
276 | gfx_context_t *gc;
|
---|
277 | errno_t rc;
|
---|
278 |
|
---|
279 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
280 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
281 |
|
---|
282 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
283 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
284 |
|
---|
285 | rc = ds_seat_create(disp, &seat);
|
---|
286 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
287 |
|
---|
288 | display_wnd_params_init(¶ms);
|
---|
289 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
290 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
291 |
|
---|
292 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
293 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
294 |
|
---|
295 | gc = ds_window_get_ctx(wnd);
|
---|
296 | PCUT_ASSERT_NOT_NULL(gc);
|
---|
297 |
|
---|
298 | ds_window_destroy(wnd);
|
---|
299 | ds_seat_destroy(seat);
|
---|
300 | ds_client_destroy(client);
|
---|
301 | ds_display_destroy(disp);
|
---|
302 | }
|
---|
303 |
|
---|
304 | /** Test ds_window_post_kbd_event() with Alt-F4 sends close event */
|
---|
305 | PCUT_TEST(window_post_kbd_event_alt_f4)
|
---|
306 | {
|
---|
307 | gfx_context_t *gc;
|
---|
308 | ds_display_t *disp;
|
---|
309 | ds_client_t *client;
|
---|
310 | ds_seat_t *seat;
|
---|
311 | ds_window_t *wnd;
|
---|
312 | ds_window_t *rwindow;
|
---|
313 | display_wnd_ev_t revent;
|
---|
314 | display_wnd_params_t params;
|
---|
315 | kbd_event_t event;
|
---|
316 | errno_t rc;
|
---|
317 |
|
---|
318 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
319 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
320 |
|
---|
321 | rc = ds_display_create(gc, df_none, &disp);
|
---|
322 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
323 |
|
---|
324 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
325 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
326 |
|
---|
327 | rc = ds_seat_create(disp, &seat);
|
---|
328 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
329 |
|
---|
330 | display_wnd_params_init(¶ms);
|
---|
331 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
332 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
333 |
|
---|
334 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
335 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
336 |
|
---|
337 | /* New window gets focused event */
|
---|
338 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
339 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
340 |
|
---|
341 | event.type = KEY_PRESS;
|
---|
342 | event.mods = KM_ALT;
|
---|
343 | event.key = KC_F4;
|
---|
344 | rc = ds_window_post_kbd_event(wnd, &event);
|
---|
345 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
346 |
|
---|
347 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
348 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
349 | PCUT_ASSERT_EQUALS(wnd, rwindow);
|
---|
350 | PCUT_ASSERT_EQUALS(wev_close, revent.etype);
|
---|
351 |
|
---|
352 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
353 | PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
|
---|
354 |
|
---|
355 | ds_window_destroy(wnd);
|
---|
356 | ds_seat_destroy(seat);
|
---|
357 | ds_client_destroy(client);
|
---|
358 | ds_display_destroy(disp);
|
---|
359 | }
|
---|
360 |
|
---|
361 | /** Test ds_window_post_pos_event() */
|
---|
362 | PCUT_TEST(window_post_pos_event)
|
---|
363 | {
|
---|
364 | gfx_context_t *gc;
|
---|
365 | ds_display_t *disp;
|
---|
366 | ds_client_t *client;
|
---|
367 | ds_seat_t *seat;
|
---|
368 | ds_window_t *wnd;
|
---|
369 | display_wnd_params_t params;
|
---|
370 | pos_event_t event;
|
---|
371 | errno_t rc;
|
---|
372 |
|
---|
373 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
374 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
375 |
|
---|
376 | rc = ds_display_create(gc, df_none, &disp);
|
---|
377 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
378 |
|
---|
379 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
380 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
381 |
|
---|
382 | rc = ds_seat_create(disp, &seat);
|
---|
383 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
384 |
|
---|
385 | display_wnd_params_init(¶ms);
|
---|
386 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
387 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
388 |
|
---|
389 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
390 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
391 |
|
---|
392 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
393 |
|
---|
394 | wnd->dpos.x = 10;
|
---|
395 | wnd->dpos.y = 10;
|
---|
396 |
|
---|
397 | event.type = POS_PRESS;
|
---|
398 | event.btn_num = 2;
|
---|
399 | event.hpos = 10;
|
---|
400 | event.vpos = 10;
|
---|
401 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
402 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
403 |
|
---|
404 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
405 |
|
---|
406 | event.type = POS_UPDATE;
|
---|
407 | event.hpos = 11;
|
---|
408 | event.vpos = 12;
|
---|
409 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
410 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
411 |
|
---|
412 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
413 | /* Window position does not update until after release */
|
---|
414 | PCUT_ASSERT_INT_EQUALS(10, wnd->dpos.x);
|
---|
415 | PCUT_ASSERT_INT_EQUALS(10, wnd->dpos.y);
|
---|
416 |
|
---|
417 | event.type = POS_RELEASE;
|
---|
418 | event.hpos = 13;
|
---|
419 | event.vpos = 14;
|
---|
420 |
|
---|
421 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
422 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
423 |
|
---|
424 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
425 | PCUT_ASSERT_INT_EQUALS(13, wnd->dpos.x);
|
---|
426 | PCUT_ASSERT_INT_EQUALS(14, wnd->dpos.y);
|
---|
427 |
|
---|
428 | ds_window_destroy(wnd);
|
---|
429 | ds_seat_destroy(seat);
|
---|
430 | ds_client_destroy(client);
|
---|
431 | ds_display_destroy(disp);
|
---|
432 | }
|
---|
433 |
|
---|
434 | /** Test ds_window_move_req() */
|
---|
435 | PCUT_TEST(window_move_req)
|
---|
436 | {
|
---|
437 | gfx_context_t *gc;
|
---|
438 | ds_display_t *disp;
|
---|
439 | ds_client_t *client;
|
---|
440 | ds_seat_t *seat;
|
---|
441 | ds_window_t *wnd;
|
---|
442 | display_wnd_params_t params;
|
---|
443 | gfx_coord2_t pos;
|
---|
444 | errno_t rc;
|
---|
445 |
|
---|
446 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
447 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
448 |
|
---|
449 | rc = ds_display_create(gc, df_none, &disp);
|
---|
450 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
451 |
|
---|
452 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
453 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
454 |
|
---|
455 | rc = ds_seat_create(disp, &seat);
|
---|
456 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
457 |
|
---|
458 | display_wnd_params_init(¶ms);
|
---|
459 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
460 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
461 |
|
---|
462 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
463 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
464 |
|
---|
465 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
466 |
|
---|
467 | pos.x = 42;
|
---|
468 | pos.y = 43;
|
---|
469 | ds_window_move_req(wnd, &pos);
|
---|
470 |
|
---|
471 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
472 | PCUT_ASSERT_INT_EQUALS(pos.x, wnd->orig_pos.x);
|
---|
473 | PCUT_ASSERT_INT_EQUALS(pos.y, wnd->orig_pos.y);
|
---|
474 |
|
---|
475 | ds_window_destroy(wnd);
|
---|
476 | ds_seat_destroy(seat);
|
---|
477 | ds_client_destroy(client);
|
---|
478 | ds_display_destroy(disp);
|
---|
479 | }
|
---|
480 |
|
---|
481 | /** Test ds_window_resize_req() */
|
---|
482 | PCUT_TEST(window_resize_req)
|
---|
483 | {
|
---|
484 | gfx_context_t *gc;
|
---|
485 | ds_display_t *disp;
|
---|
486 | ds_client_t *client;
|
---|
487 | ds_seat_t *seat;
|
---|
488 | ds_window_t *wnd;
|
---|
489 | display_wnd_params_t params;
|
---|
490 | gfx_coord2_t pos;
|
---|
491 | errno_t rc;
|
---|
492 |
|
---|
493 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
494 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
495 |
|
---|
496 | rc = ds_display_create(gc, df_none, &disp);
|
---|
497 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
498 |
|
---|
499 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
500 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
501 |
|
---|
502 | rc = ds_seat_create(disp, &seat);
|
---|
503 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
504 |
|
---|
505 | display_wnd_params_init(¶ms);
|
---|
506 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
507 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
508 |
|
---|
509 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
510 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
511 |
|
---|
512 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
513 |
|
---|
514 | pos.x = 42;
|
---|
515 | pos.y = 43;
|
---|
516 | ds_window_resize_req(wnd, display_wr_top_right, &pos);
|
---|
517 |
|
---|
518 | PCUT_ASSERT_INT_EQUALS(dsw_resizing, wnd->state);
|
---|
519 | PCUT_ASSERT_INT_EQUALS(display_wr_top_right, wnd->rsztype);
|
---|
520 | PCUT_ASSERT_INT_EQUALS(pos.x, wnd->orig_pos.x);
|
---|
521 | PCUT_ASSERT_INT_EQUALS(pos.y, wnd->orig_pos.y);
|
---|
522 |
|
---|
523 | ds_window_destroy(wnd);
|
---|
524 | ds_seat_destroy(seat);
|
---|
525 | ds_client_destroy(client);
|
---|
526 | ds_display_destroy(disp);
|
---|
527 | }
|
---|
528 |
|
---|
529 | PCUT_TEST(window_calc_resize)
|
---|
530 | {
|
---|
531 | ds_display_t *disp;
|
---|
532 | ds_client_t *client;
|
---|
533 | ds_seat_t *seat;
|
---|
534 | ds_window_t *wnd;
|
---|
535 | display_wnd_params_t params;
|
---|
536 | gfx_coord2_t dresize;
|
---|
537 | gfx_coord2_t dresizen;
|
---|
538 | gfx_coord2_t dresizeb;
|
---|
539 | gfx_coord2_t dresizebn;
|
---|
540 | gfx_rect_t nrect;
|
---|
541 | errno_t rc;
|
---|
542 |
|
---|
543 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
544 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
545 |
|
---|
546 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
547 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
548 |
|
---|
549 | rc = ds_seat_create(disp, &seat);
|
---|
550 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
551 |
|
---|
552 | display_wnd_params_init(¶ms);
|
---|
553 | params.rect.p0.x = 10;
|
---|
554 | params.rect.p0.y = 11;
|
---|
555 | params.rect.p1.x = 30;
|
---|
556 | params.rect.p1.y = 31;
|
---|
557 | params.min_size.x = 2;
|
---|
558 | params.min_size.y = 3;
|
---|
559 |
|
---|
560 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
561 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
562 |
|
---|
563 | wnd->state = dsw_resizing;
|
---|
564 |
|
---|
565 | dresize.x = 5;
|
---|
566 | dresize.y = 6;
|
---|
567 |
|
---|
568 | dresizen.x = -5;
|
---|
569 | dresizen.y = -6;
|
---|
570 |
|
---|
571 | dresizeb.x = 50;
|
---|
572 | dresizeb.y = 60;
|
---|
573 |
|
---|
574 | dresizebn.x = -50;
|
---|
575 | dresizebn.y = -60;
|
---|
576 |
|
---|
577 | /* Resize top */
|
---|
578 | wnd->rsztype = display_wr_top;
|
---|
579 |
|
---|
580 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
581 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
582 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
583 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
584 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
585 |
|
---|
586 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
587 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
588 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
589 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
590 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
591 |
|
---|
592 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
593 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
594 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
595 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
596 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
597 |
|
---|
598 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
599 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
600 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
601 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
602 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
603 |
|
---|
604 | /* Resize top left */
|
---|
605 | wnd->rsztype = display_wr_top_left;
|
---|
606 |
|
---|
607 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
608 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
609 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
610 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
611 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
612 |
|
---|
613 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
614 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
615 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
616 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
617 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
618 |
|
---|
619 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
620 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
621 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
622 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
623 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
624 |
|
---|
625 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
626 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
627 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
628 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
629 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
630 |
|
---|
631 | /* Resize left */
|
---|
632 | wnd->rsztype = display_wr_left;
|
---|
633 |
|
---|
634 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
635 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
636 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
637 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
638 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
639 |
|
---|
640 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
641 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
642 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
643 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
644 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
645 |
|
---|
646 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
647 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
648 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
649 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
650 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
651 |
|
---|
652 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
653 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
654 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
655 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
656 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
657 |
|
---|
658 | /* Resize bottom left */
|
---|
659 | wnd->rsztype = display_wr_bottom_left;
|
---|
660 |
|
---|
661 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
662 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
663 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
664 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
665 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
666 |
|
---|
667 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
668 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
669 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
670 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
671 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
672 |
|
---|
673 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
674 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
675 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
676 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
677 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
678 |
|
---|
679 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
680 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
681 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
682 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
683 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
684 |
|
---|
685 | /* Resize bottom */
|
---|
686 | wnd->rsztype = display_wr_bottom;
|
---|
687 |
|
---|
688 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
689 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
690 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
691 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
692 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
693 |
|
---|
694 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
695 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
696 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
697 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
698 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
699 |
|
---|
700 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
701 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
702 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
703 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
704 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
705 |
|
---|
706 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
707 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
708 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
709 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
710 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
711 |
|
---|
712 | /* Resize bottom right */
|
---|
713 | wnd->rsztype = display_wr_bottom_right;
|
---|
714 |
|
---|
715 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
716 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
717 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
718 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
719 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
720 |
|
---|
721 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
722 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
723 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
724 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
725 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
726 |
|
---|
727 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
728 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
729 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
730 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
731 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
732 |
|
---|
733 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
734 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
735 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
736 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
737 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
738 |
|
---|
739 | /* Resize right */
|
---|
740 | wnd->rsztype = display_wr_right;
|
---|
741 |
|
---|
742 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
743 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
744 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
745 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
746 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
747 |
|
---|
748 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
749 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
750 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
751 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
752 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
753 |
|
---|
754 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
755 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
756 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
757 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
758 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
759 |
|
---|
760 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
761 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
762 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
763 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
764 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
765 |
|
---|
766 | /* Resize top right */
|
---|
767 | wnd->rsztype = display_wr_top_right;
|
---|
768 |
|
---|
769 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
770 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
771 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
772 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
773 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
774 |
|
---|
775 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
776 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
777 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
778 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
779 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
780 |
|
---|
781 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
782 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
783 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
784 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
785 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
786 |
|
---|
787 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
788 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
789 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
790 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
791 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
792 |
|
---|
793 | ds_window_destroy(wnd);
|
---|
794 | ds_seat_destroy(seat);
|
---|
795 | ds_client_destroy(client);
|
---|
796 | ds_display_destroy(disp);
|
---|
797 | }
|
---|
798 |
|
---|
799 | /** Test ds_window_set_cursor() */
|
---|
800 | PCUT_TEST(window_set_cursor)
|
---|
801 | {
|
---|
802 | gfx_context_t *gc;
|
---|
803 | ds_display_t *disp;
|
---|
804 | ds_client_t *client;
|
---|
805 | ds_seat_t *seat;
|
---|
806 | ds_window_t *wnd;
|
---|
807 | display_wnd_params_t params;
|
---|
808 | errno_t rc;
|
---|
809 |
|
---|
810 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
811 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
812 |
|
---|
813 | rc = ds_display_create(gc, df_none, &disp);
|
---|
814 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
815 |
|
---|
816 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
817 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
818 |
|
---|
819 | rc = ds_seat_create(disp, &seat);
|
---|
820 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
821 |
|
---|
822 | display_wnd_params_init(¶ms);
|
---|
823 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
824 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
825 |
|
---|
826 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
827 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
828 |
|
---|
829 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
830 |
|
---|
831 | rc = ds_window_set_cursor(wnd, -1);
|
---|
832 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
833 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
834 |
|
---|
835 | rc = ds_window_set_cursor(wnd, dcurs_limit);
|
---|
836 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
837 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
838 |
|
---|
839 | rc = ds_window_set_cursor(wnd, dcurs_limit + 1);
|
---|
840 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
841 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
842 |
|
---|
843 | rc = ds_window_set_cursor(wnd, dcurs_size_lr);
|
---|
844 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
845 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_size_lr], wnd->cursor);
|
---|
846 |
|
---|
847 | ds_window_destroy(wnd);
|
---|
848 | ds_seat_destroy(seat);
|
---|
849 | ds_client_destroy(client);
|
---|
850 | ds_display_destroy(disp);
|
---|
851 | }
|
---|
852 |
|
---|
853 | static errno_t dummy_set_color(void *arg, gfx_color_t *color)
|
---|
854 | {
|
---|
855 | return EOK;
|
---|
856 | }
|
---|
857 |
|
---|
858 | static errno_t dummy_fill_rect(void *arg, gfx_rect_t *rect)
|
---|
859 | {
|
---|
860 | return EOK;
|
---|
861 | }
|
---|
862 |
|
---|
863 | PCUT_EXPORT(window);
|
---|