2 * Copyright © 2013 DENSO CORPORATION
3 * Copyright © 2015 Collabora, Ltd.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 #include "compositor.h"
36 #include "compositor/weston.h"
37 #include "ivi-shell/ivi-layout-export.h"
38 #include "ivi-shell/ivi-layout-private.h"
40 #include "shared/helpers.h"
43 struct weston_compositor *compositor;
44 const struct ivi_layout_interface *layout_interface;
47 struct wl_listener layer_property_changed;
48 struct wl_listener layer_created;
49 struct wl_listener layer_removed;
53 iassert_fail(const char *cond, const char *file, int line,
54 const char *func, struct test_context *ctx)
56 weston_log("Assert failure in %s:%d, %s: '%s'\n",
57 file, line, func, cond);
58 weston_compositor_exit_with_code(ctx->compositor, EXIT_FAILURE);
61 #define iassert(cond) ({ \
64 iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx); \
68 /************************ tests begin ******************************/
71 * These are all internal ivi_layout API tests that do not require
75 test_surface_bad_visibility(struct test_context *ctx)
77 const struct ivi_layout_interface *lyt = ctx->layout_interface;
79 iassert(lyt->surface_set_visibility(NULL, true) == IVI_FAILED);
81 lyt->commit_changes();
85 test_surface_bad_destination_rectangle(struct test_context *ctx)
87 const struct ivi_layout_interface *lyt = ctx->layout_interface;
89 iassert(lyt->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
93 test_surface_bad_source_rectangle(struct test_context *ctx)
95 const struct ivi_layout_interface *lyt = ctx->layout_interface;
97 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
101 test_surface_bad_properties(struct test_context *ctx)
103 const struct ivi_layout_interface *lyt = ctx->layout_interface;
105 iassert(lyt->get_properties_of_surface(NULL) == NULL);
109 test_layer_create(struct test_context *ctx)
111 const struct ivi_layout_interface *lyt = ctx->layout_interface;
114 struct ivi_layout_layer *ivilayer;
115 struct ivi_layout_layer *new_ivilayer;
117 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
118 iassert(ivilayer != NULL);
120 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
122 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
123 iassert(ivilayer == new_ivilayer);
125 id1 = lyt->get_id_of_layer(ivilayer);
126 id2 = lyt->get_id_of_layer(new_ivilayer);
129 lyt->layer_destroy(ivilayer);
130 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
134 test_layer_visibility(struct test_context *ctx)
136 const struct ivi_layout_interface *lyt = ctx->layout_interface;
137 struct ivi_layout_layer *ivilayer;
138 const struct ivi_layout_layer_properties *prop;
140 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
141 iassert(ivilayer != NULL);
143 prop = lyt->get_properties_of_layer(ivilayer);
145 iassert(prop->visibility == false);
147 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
149 iassert(prop->visibility == false);
151 lyt->commit_changes();
153 iassert(prop->visibility == true);
155 lyt->layer_destroy(ivilayer);
159 test_layer_opacity(struct test_context *ctx)
161 const struct ivi_layout_interface *lyt = ctx->layout_interface;
162 struct ivi_layout_layer *ivilayer;
163 const struct ivi_layout_layer_properties *prop;
165 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
166 iassert(ivilayer != NULL);
168 prop = lyt->get_properties_of_layer(ivilayer);
169 iassert(prop->opacity == wl_fixed_from_double(1.0));
171 iassert(lyt->layer_set_opacity(
172 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
174 iassert(prop->opacity == wl_fixed_from_double(1.0));
176 lyt->commit_changes();
178 iassert(prop->opacity == wl_fixed_from_double(0.5));
180 lyt->layer_destroy(ivilayer);
184 test_layer_dimension(struct test_context *ctx)
186 const struct ivi_layout_interface *lyt = ctx->layout_interface;
187 struct ivi_layout_layer *ivilayer;
188 const struct ivi_layout_layer_properties *prop;
190 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
191 iassert(ivilayer != NULL);
193 prop = lyt->get_properties_of_layer(ivilayer);
194 iassert(prop->dest_width == 200);
195 iassert(prop->dest_height == 300);
197 iassert(lyt->layer_set_destination_rectangle(ivilayer, prop->dest_x, prop->dest_y,
198 400, 600) == IVI_SUCCEEDED);
200 iassert(prop->dest_width == 200);
201 iassert(prop->dest_height == 300);
203 lyt->commit_changes();
205 iassert(prop->dest_width == 400);
206 iassert(prop->dest_height == 600);
208 lyt->layer_destroy(ivilayer);
212 test_layer_position(struct test_context *ctx)
214 const struct ivi_layout_interface *lyt = ctx->layout_interface;
215 struct ivi_layout_layer *ivilayer;
216 const struct ivi_layout_layer_properties *prop;
218 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
219 iassert(ivilayer != NULL);
221 prop = lyt->get_properties_of_layer(ivilayer);
222 iassert(prop->dest_x == 0);
223 iassert(prop->dest_y == 0);
225 iassert(lyt->layer_set_destination_rectangle(ivilayer, 20, 30,
226 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
228 iassert(prop->dest_x == 0);
229 iassert(prop->dest_y == 0);
231 lyt->commit_changes();
233 prop = lyt->get_properties_of_layer(ivilayer);
234 iassert(prop->dest_x == 20);
235 iassert(prop->dest_y == 30);
237 lyt->layer_destroy(ivilayer);
241 test_layer_destination_rectangle(struct test_context *ctx)
243 const struct ivi_layout_interface *lyt = ctx->layout_interface;
244 struct ivi_layout_layer *ivilayer;
245 const struct ivi_layout_layer_properties *prop;
247 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
248 iassert(ivilayer != NULL);
250 prop = lyt->get_properties_of_layer(ivilayer);
251 iassert(prop->dest_width == 200);
252 iassert(prop->dest_height == 300);
253 iassert(prop->dest_x == 0);
254 iassert(prop->dest_y == 0);
256 iassert(lyt->layer_set_destination_rectangle(
257 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
259 prop = lyt->get_properties_of_layer(ivilayer);
260 iassert(prop->dest_width == 200);
261 iassert(prop->dest_height == 300);
262 iassert(prop->dest_x == 0);
263 iassert(prop->dest_y == 0);
265 lyt->commit_changes();
267 iassert(prop->dest_width == 400);
268 iassert(prop->dest_height == 600);
269 iassert(prop->dest_x == 20);
270 iassert(prop->dest_y == 30);
272 lyt->layer_destroy(ivilayer);
276 test_layer_source_rectangle(struct test_context *ctx)
278 const struct ivi_layout_interface *lyt = ctx->layout_interface;
279 struct ivi_layout_layer *ivilayer;
280 const struct ivi_layout_layer_properties *prop;
282 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
283 iassert(ivilayer != NULL);
285 prop = lyt->get_properties_of_layer(ivilayer);
286 iassert(prop->source_width == 200);
287 iassert(prop->source_height == 300);
288 iassert(prop->source_x == 0);
289 iassert(prop->source_y == 0);
291 iassert(lyt->layer_set_source_rectangle(
292 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
294 prop = lyt->get_properties_of_layer(ivilayer);
295 iassert(prop->source_width == 200);
296 iassert(prop->source_height == 300);
297 iassert(prop->source_x == 0);
298 iassert(prop->source_y == 0);
300 lyt->commit_changes();
302 prop = lyt->get_properties_of_layer(ivilayer);
303 iassert(prop->source_width == 400);
304 iassert(prop->source_height == 600);
305 iassert(prop->source_x == 20);
306 iassert(prop->source_y == 30);
308 lyt->layer_destroy(ivilayer);
312 test_layer_bad_remove(struct test_context *ctx)
314 const struct ivi_layout_interface *lyt = ctx->layout_interface;
315 lyt->layer_destroy(NULL);
319 test_layer_bad_visibility(struct test_context *ctx)
321 const struct ivi_layout_interface *lyt = ctx->layout_interface;
323 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
325 lyt->commit_changes();
329 test_layer_bad_opacity(struct test_context *ctx)
331 const struct ivi_layout_interface *lyt = ctx->layout_interface;
332 struct ivi_layout_layer *ivilayer;
333 const struct ivi_layout_layer_properties *prop;
335 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
336 iassert(ivilayer != NULL);
338 iassert(lyt->layer_set_opacity(
339 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
341 iassert(lyt->layer_set_opacity(
342 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
344 iassert(lyt->layer_set_opacity(
345 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
347 lyt->commit_changes();
349 prop = lyt->get_properties_of_layer(ivilayer);
350 iassert(prop->opacity == wl_fixed_from_double(0.3));
352 iassert(lyt->layer_set_opacity(
353 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
355 lyt->commit_changes();
357 iassert(prop->opacity == wl_fixed_from_double(0.3));
359 iassert(lyt->layer_set_opacity(
360 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
362 lyt->commit_changes();
364 lyt->layer_destroy(ivilayer);
368 test_layer_bad_destination_rectangle(struct test_context *ctx)
370 const struct ivi_layout_interface *lyt = ctx->layout_interface;
372 iassert(lyt->layer_set_destination_rectangle(
373 NULL, 20, 30, 200, 300) == IVI_FAILED);
377 test_layer_bad_source_rectangle(struct test_context *ctx)
379 const struct ivi_layout_interface *lyt = ctx->layout_interface;
381 iassert(lyt->layer_set_source_rectangle(
382 NULL, 20, 30, 200, 300) == IVI_FAILED);
386 test_layer_bad_properties(struct test_context *ctx)
388 const struct ivi_layout_interface *lyt = ctx->layout_interface;
390 iassert(lyt->get_properties_of_layer(NULL) == NULL);
394 test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
396 const struct ivi_layout_interface *lyt = ctx->layout_interface;
397 struct ivi_layout_layer *ivilayer;
399 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
400 iassert(ivilayer != NULL);
402 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
403 lyt->layer_destroy(ivilayer);
404 lyt->commit_changes();
408 test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
410 const struct ivi_layout_interface *lyt = ctx->layout_interface;
411 struct ivi_layout_layer *ivilayer;
413 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
414 iassert(ivilayer != NULL);
416 iassert(lyt->layer_set_opacity(
417 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
418 lyt->layer_destroy(ivilayer);
419 lyt->commit_changes();
423 test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
425 const struct ivi_layout_interface *lyt = ctx->layout_interface;
426 struct ivi_layout_layer *ivilayer;
428 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
429 iassert(ivilayer != NULL);
431 iassert(lyt->layer_set_source_rectangle(
432 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
433 lyt->layer_destroy(ivilayer);
434 lyt->commit_changes();
438 test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
440 const struct ivi_layout_interface *lyt = ctx->layout_interface;
441 struct ivi_layout_layer *ivilayer;
443 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
444 iassert(ivilayer != NULL);
446 iassert(lyt->layer_set_destination_rectangle(
447 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
448 lyt->layer_destroy(ivilayer);
449 lyt->commit_changes();
453 test_layer_create_duplicate(struct test_context *ctx)
455 const struct ivi_layout_interface *lyt = ctx->layout_interface;
456 struct ivi_layout_layer *ivilayer;
457 struct ivi_layout_layer *duplicatelayer;
459 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
460 iassert(ivilayer != NULL);
462 if (ivilayer != NULL)
463 iassert(ivilayer->ref_count == 1);
465 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
466 iassert(ivilayer == duplicatelayer);
468 if (ivilayer != NULL)
469 iassert(ivilayer->ref_count == 2);
471 lyt->layer_destroy(ivilayer);
473 if (ivilayer != NULL)
474 iassert(ivilayer->ref_count == 1);
476 lyt->layer_destroy(ivilayer);
480 test_get_layer_after_destory_layer(struct test_context *ctx)
482 const struct ivi_layout_interface *lyt = ctx->layout_interface;
483 struct ivi_layout_layer *ivilayer;
485 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
486 iassert(ivilayer != NULL);
488 lyt->layer_destroy(ivilayer);
490 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
491 iassert(ivilayer == NULL);
495 test_screen_render_order(struct test_context *ctx)
497 #define LAYER_NUM (3)
498 const struct ivi_layout_interface *lyt = ctx->layout_interface;
499 struct weston_output *output;
500 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
501 struct ivi_layout_layer **array;
505 if (!iassert(!wl_list_empty(&ctx->compositor->output_list)))
508 output = wl_container_of(ctx->compositor->output_list.next, output, link);
510 for (i = 0; i < LAYER_NUM; i++)
511 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
513 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
515 lyt->commit_changes();
517 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
518 iassert(length == LAYER_NUM);
519 for (i = 0; i < LAYER_NUM; i++)
520 iassert(array[i] == ivilayers[i]);
527 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
529 lyt->commit_changes();
531 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
532 iassert(length == 0 && array == NULL);
534 for (i = 0; i < LAYER_NUM; i++)
535 lyt->layer_destroy(ivilayers[i]);
541 test_screen_bad_render_order(struct test_context *ctx)
543 #define LAYER_NUM (3)
544 const struct ivi_layout_interface *lyt = ctx->layout_interface;
545 struct weston_output *output;
546 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
547 struct ivi_layout_layer **array;
551 if (!iassert(!wl_list_empty(&ctx->compositor->output_list)))
554 output = wl_container_of(ctx->compositor->output_list.next, output, link);
556 for (i = 0; i < LAYER_NUM; i++)
557 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
559 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
561 lyt->commit_changes();
563 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
564 iassert(lyt->get_layers_on_screen(output, NULL, &array) == IVI_FAILED);
565 iassert(lyt->get_layers_on_screen(output, &length, NULL) == IVI_FAILED);
567 for (i = 0; i < LAYER_NUM; i++)
568 lyt->layer_destroy(ivilayers[i]);
574 test_screen_add_layers(struct test_context *ctx)
576 #define LAYER_NUM (3)
577 const struct ivi_layout_interface *lyt = ctx->layout_interface;
578 struct weston_output *output;
579 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
580 struct ivi_layout_layer **array;
584 if (!iassert(!wl_list_empty(&ctx->compositor->output_list)))
587 output = wl_container_of(ctx->compositor->output_list.next, output, link);
589 for (i = 0; i < LAYER_NUM; i++) {
590 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
591 iassert(lyt->screen_add_layer(output, ivilayers[i]) == IVI_SUCCEEDED);
594 lyt->commit_changes();
596 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
597 iassert(length == LAYER_NUM);
598 for (i = 0; i < (uint32_t)length; i++)
599 iassert(array[i] == ivilayers[i]);
606 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
607 for (i = LAYER_NUM; i-- > 0;)
608 iassert(lyt->screen_add_layer(output, ivilayers[i]) == IVI_SUCCEEDED);
610 lyt->commit_changes();
612 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
613 iassert(length == LAYER_NUM);
614 for (i = 0; i < (uint32_t)length; i++)
615 iassert(array[i] == ivilayers[LAYER_NUM - (i + 1)]);
620 for (i = 0; i < LAYER_NUM; i++)
621 lyt->layer_destroy(ivilayers[i]);
627 test_screen_remove_layer(struct test_context *ctx)
629 const struct ivi_layout_interface *lyt = ctx->layout_interface;
630 struct ivi_layout_layer *ivilayer;
631 struct weston_output *output;
632 struct ivi_layout_layer **array;
635 if (wl_list_empty(&ctx->compositor->output_list))
638 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
639 iassert(ivilayer != NULL);
641 output = wl_container_of(ctx->compositor->output_list.next, output, link);
643 iassert(lyt->screen_add_layer(output, ivilayer) == IVI_SUCCEEDED);
644 lyt->commit_changes();
646 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
647 iassert(length == 1);
648 iassert(array[0] == ivilayer);
650 iassert(lyt->screen_remove_layer(output, ivilayer) == IVI_SUCCEEDED);
651 lyt->commit_changes();
658 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
659 iassert(length == 0);
660 iassert(array == NULL);
662 lyt->layer_destroy(ivilayer);
666 test_screen_bad_remove_layer(struct test_context *ctx)
668 const struct ivi_layout_interface *lyt = ctx->layout_interface;
669 struct ivi_layout_layer *ivilayer;
670 struct weston_output *output;
672 if (wl_list_empty(&ctx->compositor->output_list))
675 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
676 iassert(ivilayer != NULL);
678 output = wl_container_of(ctx->compositor->output_list.next, output, link);
680 iassert(lyt->screen_remove_layer(NULL, ivilayer) == IVI_FAILED);
681 lyt->commit_changes();
683 iassert(lyt->screen_remove_layer(output, NULL) == IVI_FAILED);
684 lyt->commit_changes();
686 iassert(lyt->screen_remove_layer(NULL, NULL) == IVI_FAILED);
687 lyt->commit_changes();
689 lyt->layer_destroy(ivilayer);
694 test_commit_changes_after_render_order_set_layer_destroy(
695 struct test_context *ctx)
697 #define LAYER_NUM (3)
698 const struct ivi_layout_interface *lyt = ctx->layout_interface;
699 struct weston_output *output;
700 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
703 if (!iassert(!wl_list_empty(&ctx->compositor->output_list)))
706 output = wl_container_of(ctx->compositor->output_list.next, output, link);
708 for (i = 0; i < LAYER_NUM; i++)
709 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
711 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
713 lyt->layer_destroy(ivilayers[1]);
715 lyt->commit_changes();
717 lyt->layer_destroy(ivilayers[0]);
718 lyt->layer_destroy(ivilayers[2]);
723 test_layer_properties_changed_notification_callback(struct wl_listener *listener, void *data)
725 struct test_context *ctx =
726 container_of(listener, struct test_context,
727 layer_property_changed);
728 const struct ivi_layout_interface *lyt = ctx->layout_interface;
729 struct ivi_layout_layer *ivilayer = data;
730 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
732 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
733 iassert(prop->source_width == 200);
734 iassert(prop->source_height == 300);
736 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
737 prop->source_width == 200 && prop->source_height == 300)
742 test_layer_properties_changed_notification(struct test_context *ctx)
744 const struct ivi_layout_interface *lyt = ctx->layout_interface;
745 struct ivi_layout_layer *ivilayer;
749 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
751 ctx->layer_property_changed.notify = test_layer_properties_changed_notification_callback;
753 iassert(lyt->layer_add_listener(ivilayer, &ctx->layer_property_changed) == IVI_SUCCEEDED);
755 lyt->commit_changes();
757 iassert(ctx->user_flags == 0);
759 iassert(lyt->layer_set_destination_rectangle(
760 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
762 lyt->commit_changes();
764 iassert(ctx->user_flags == 1);
767 iassert(lyt->layer_set_destination_rectangle(
768 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
770 lyt->commit_changes();
772 iassert(ctx->user_flags == 0);
774 // remove layer property changed listener.
775 wl_list_remove(&ctx->layer_property_changed.link);
778 lyt->commit_changes();
780 iassert(ctx->user_flags == 0);
782 lyt->layer_destroy(ivilayer);
786 test_layer_create_notification_callback(struct wl_listener *listener, void *data)
788 struct test_context *ctx =
789 container_of(listener, struct test_context,
791 const struct ivi_layout_interface *lyt = ctx->layout_interface;
792 struct ivi_layout_layer *ivilayer = data;
793 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
795 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
796 iassert(prop->source_width == 200);
797 iassert(prop->source_height == 300);
799 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
800 prop->source_width == 200 && prop->source_height == 300)
805 test_layer_create_notification(struct test_context *ctx)
807 #define LAYER_NUM (2)
808 const struct ivi_layout_interface *lyt = ctx->layout_interface;
809 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
810 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
813 ctx->layer_created.notify = test_layer_create_notification_callback;
815 iassert(lyt->add_listener_create_layer(&ctx->layer_created) == IVI_SUCCEEDED);
816 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
818 iassert(ctx->user_flags == 1);
821 // remove layer created listener.
822 wl_list_remove(&ctx->layer_created.link);
824 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
826 iassert(ctx->user_flags == 0);
828 lyt->layer_destroy(ivilayers[0]);
829 lyt->layer_destroy(ivilayers[1]);
834 test_layer_remove_notification_callback(struct wl_listener *listener, void *data)
836 struct test_context *ctx =
837 container_of(listener, struct test_context,
839 const struct ivi_layout_interface *lyt = ctx->layout_interface;
840 struct ivi_layout_layer *ivilayer = data;
841 const struct ivi_layout_layer_properties *prop =
842 lyt->get_properties_of_layer(ivilayer);
844 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
845 iassert(prop->source_width == 200);
846 iassert(prop->source_height == 300);
848 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
849 prop->source_width == 200 && prop->source_height == 300)
854 test_layer_remove_notification(struct test_context *ctx)
856 #define LAYER_NUM (2)
857 const struct ivi_layout_interface *lyt = ctx->layout_interface;
858 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
859 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
862 ctx->layer_removed.notify = test_layer_remove_notification_callback;
864 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
865 iassert(lyt->add_listener_remove_layer(&ctx->layer_removed) == IVI_SUCCEEDED);
866 lyt->layer_destroy(ivilayers[0]);
868 iassert(ctx->user_flags == 1);
871 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
873 // remove layer property changed listener.
874 wl_list_remove(&ctx->layer_removed.link);
875 lyt->layer_destroy(ivilayers[1]);
877 iassert(ctx->user_flags == 0);
882 test_layer_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
887 test_layer_bad_properties_changed_notification(struct test_context *ctx)
889 const struct ivi_layout_interface *lyt = ctx->layout_interface;
890 struct ivi_layout_layer *ivilayer;
892 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
894 ctx->layer_property_changed.notify = test_layer_bad_properties_changed_notification_callback;
896 iassert(lyt->layer_add_listener(NULL, &ctx->layer_property_changed) == IVI_FAILED);
897 iassert(lyt->layer_add_listener(ivilayer, NULL) == IVI_FAILED);
899 lyt->layer_destroy(ivilayer);
903 test_surface_bad_configure_notification(struct test_context *ctx)
905 const struct ivi_layout_interface *lyt = ctx->layout_interface;
907 iassert(lyt->add_listener_configure_surface(NULL) == IVI_FAILED);
911 test_layer_bad_create_notification(struct test_context *ctx)
913 const struct ivi_layout_interface *lyt = ctx->layout_interface;
915 iassert(lyt->add_listener_create_layer(NULL) == IVI_FAILED);
919 test_surface_bad_create_notification(struct test_context *ctx)
921 const struct ivi_layout_interface *lyt = ctx->layout_interface;
923 iassert(lyt->add_listener_create_surface(NULL) == IVI_FAILED);
927 test_layer_bad_remove_notification(struct test_context *ctx)
929 const struct ivi_layout_interface *lyt = ctx->layout_interface;
931 iassert(lyt->add_listener_remove_layer(NULL) == IVI_FAILED);
935 test_surface_bad_remove_notification(struct test_context *ctx)
937 const struct ivi_layout_interface *lyt = ctx->layout_interface;
939 iassert(lyt->add_listener_remove_surface(NULL) == IVI_FAILED);
942 /************************ tests end ********************************/
945 run_internal_tests(void *data)
947 struct test_context *ctx = data;
949 test_surface_bad_visibility(ctx);
950 test_surface_bad_destination_rectangle(ctx);
951 test_surface_bad_source_rectangle(ctx);
952 test_surface_bad_properties(ctx);
954 test_layer_create(ctx);
955 test_layer_visibility(ctx);
956 test_layer_opacity(ctx);
957 test_layer_dimension(ctx);
958 test_layer_position(ctx);
959 test_layer_destination_rectangle(ctx);
960 test_layer_source_rectangle(ctx);
961 test_layer_bad_remove(ctx);
962 test_layer_bad_visibility(ctx);
963 test_layer_bad_opacity(ctx);
964 test_layer_bad_destination_rectangle(ctx);
965 test_layer_bad_source_rectangle(ctx);
966 test_layer_bad_properties(ctx);
967 test_commit_changes_after_visibility_set_layer_destroy(ctx);
968 test_commit_changes_after_opacity_set_layer_destroy(ctx);
969 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
970 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
971 test_layer_create_duplicate(ctx);
972 test_get_layer_after_destory_layer(ctx);
974 test_screen_render_order(ctx);
975 test_screen_bad_render_order(ctx);
976 test_screen_add_layers(ctx);
977 test_screen_remove_layer(ctx);
978 test_screen_bad_remove_layer(ctx);
979 test_commit_changes_after_render_order_set_layer_destroy(ctx);
981 test_layer_properties_changed_notification(ctx);
982 test_layer_create_notification(ctx);
983 test_layer_remove_notification(ctx);
984 test_layer_bad_properties_changed_notification(ctx);
985 test_surface_bad_configure_notification(ctx);
986 test_layer_bad_create_notification(ctx);
987 test_surface_bad_create_notification(ctx);
988 test_layer_bad_remove_notification(ctx);
989 test_surface_bad_remove_notification(ctx);
991 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
996 wet_module_init(struct weston_compositor *compositor,
997 int *argc, char *argv[])
999 struct wl_event_loop *loop;
1000 struct test_context *ctx;
1001 const struct ivi_layout_interface *iface;
1003 iface = ivi_layout_get_api(compositor);
1006 weston_log("fatal: cannot use ivi_layout_interface.\n");
1010 ctx = zalloc(sizeof(*ctx));
1014 ctx->compositor = compositor;
1015 ctx->layout_interface = iface;
1017 loop = wl_display_get_event_loop(compositor->wl_display);
1018 wl_event_loop_add_idle(loop, run_internal_tests, ctx);