blob: f7f7c8056b043985af19322245bb9b7f43ef1a03 [file] [log] [blame]
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001/*
2 * Copyright © 2013 DENSO CORPORATION
3 * Copyright © 2015 Collabora, Ltd.
4 *
Bryce Harrington2cc92972015-06-11 15:39:40 -07005 * 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:
Pekka Paalanen46804ca2015-03-27 11:55:21 +020012 *
Bryce Harrington2cc92972015-06-11 15:39:40 -070013 * 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.
16 *
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
24 * SOFTWARE.
Pekka Paalanen46804ca2015-03-27 11:55:21 +020025 */
26
27#include "config.h"
28
29#include <unistd.h>
30#include <signal.h>
31#include <string.h>
32#include <stdbool.h>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030033#include <stdint.h>
Pekka Paalanen46804ca2015-03-27 11:55:21 +020034
Pekka Paalanenb5e3ea22016-06-03 17:12:10 +030035#include "compositor.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070036#include "ivi-shell/ivi-layout-export.h"
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +090037#include "ivi-shell/ivi-layout-private.h"
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +090038#include "ivi-test.h"
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +000039#include "shared/helpers.h"
Pekka Paalanen46804ca2015-03-27 11:55:21 +020040
41struct test_context {
42 struct weston_compositor *compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000043 const struct ivi_layout_interface *layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +090044 uint32_t user_flags;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +000045
46 struct wl_listener layer_property_changed;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +000047 struct wl_listener layer_created;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +000048 struct wl_listener layer_removed;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020049};
50
51static void
52iassert_fail(const char *cond, const char *file, int line,
53 const char *func, struct test_context *ctx)
54{
55 weston_log("Assert failure in %s:%d, %s: '%s'\n",
56 file, line, func, cond);
57 weston_compositor_exit_with_code(ctx->compositor, EXIT_FAILURE);
58}
59
60#define iassert(cond) ({ \
61 bool b_ = (cond); \
62 if (!b_) \
63 iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx); \
64 b_; \
65})
66
67/************************ tests begin ******************************/
68
69/*
70 * These are all internal ivi_layout API tests that do not require
71 * any client objects.
72 */
Pekka Paalanen46804ca2015-03-27 11:55:21 +020073static void
74test_surface_bad_visibility(struct test_context *ctx)
75{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000076 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020077
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000078 iassert(lyt->surface_set_visibility(NULL, true) == IVI_FAILED);
Pekka Paalanen46804ca2015-03-27 11:55:21 +020079
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000080 lyt->commit_changes();
Pekka Paalanen46804ca2015-03-27 11:55:21 +020081}
82
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090083static void
84test_surface_bad_destination_rectangle(struct test_context *ctx)
85{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000086 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090087
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000088 iassert(lyt->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090089}
90
91static void
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090092test_surface_bad_source_rectangle(struct test_context *ctx)
93{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000094 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090095
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000096 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090097}
98
99static void
100test_surface_bad_properties(struct test_context *ctx)
101{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000102 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900103
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000104 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900105}
106
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900107static void
108test_layer_create(struct test_context *ctx)
109{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000110 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900111 uint32_t id1;
112 uint32_t id2;
113 struct ivi_layout_layer *ivilayer;
114 struct ivi_layout_layer *new_ivilayer;
115
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000116 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900117 iassert(ivilayer != NULL);
118
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000119 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900120
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000121 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900122 iassert(ivilayer == new_ivilayer);
123
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000124 id1 = lyt->get_id_of_layer(ivilayer);
125 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900126 iassert(id1 == id2);
127
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000128 lyt->layer_destroy(ivilayer);
129 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900130}
131
132static void
133test_layer_visibility(struct test_context *ctx)
134{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000135 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900136 struct ivi_layout_layer *ivilayer;
137 const struct ivi_layout_layer_properties *prop;
138
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000139 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900140 iassert(ivilayer != NULL);
141
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000142 prop = lyt->get_properties_of_layer(ivilayer);
143
144 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900145
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000146 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900147
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000148 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900149
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000150 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900151
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900152 iassert(prop->visibility == true);
153
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000154 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900155}
156
157static void
158test_layer_opacity(struct test_context *ctx)
159{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000160 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900161 struct ivi_layout_layer *ivilayer;
162 const struct ivi_layout_layer_properties *prop;
163
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000164 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900165 iassert(ivilayer != NULL);
166
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000167 prop = lyt->get_properties_of_layer(ivilayer);
168 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900169
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000170 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900171 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
172
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000173 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900174
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000175 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900176
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900177 iassert(prop->opacity == wl_fixed_from_double(0.5));
178
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000179 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900180}
181
182static void
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183test_layer_dimension(struct test_context *ctx)
184{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000185 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900186 struct ivi_layout_layer *ivilayer;
187 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900188
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000189 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900190 iassert(ivilayer != NULL);
191
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000192 prop = lyt->get_properties_of_layer(ivilayer);
193 iassert(prop->dest_width == 200);
194 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900195
Ucan, Emre \(ADITG/SW1\)16d1fa12016-03-04 12:50:52 +0000196 iassert(lyt->layer_set_destination_rectangle(ivilayer, prop->dest_x, prop->dest_y,
197 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000199 iassert(prop->dest_width == 200);
200 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900201
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000202 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900203
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900204 iassert(prop->dest_width == 400);
205 iassert(prop->dest_height == 600);
206
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000207 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208}
209
210static void
211test_layer_position(struct test_context *ctx)
212{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000213 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900214 struct ivi_layout_layer *ivilayer;
215 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900216
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000217 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900218 iassert(ivilayer != NULL);
219
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000220 prop = lyt->get_properties_of_layer(ivilayer);
221 iassert(prop->dest_x == 0);
222 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900223
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +0000224 iassert(lyt->layer_set_destination_rectangle(ivilayer, 20, 30,
225 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900226
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000227 iassert(prop->dest_x == 0);
228 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900229
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000230 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000232 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900233 iassert(prop->dest_x == 20);
234 iassert(prop->dest_y == 30);
235
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000236 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900237}
238
239static void
240test_layer_destination_rectangle(struct test_context *ctx)
241{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000242 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900243 struct ivi_layout_layer *ivilayer;
244 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900245
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000246 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900247 iassert(ivilayer != NULL);
248
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000249 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900250 iassert(prop->dest_width == 200);
251 iassert(prop->dest_height == 300);
252 iassert(prop->dest_x == 0);
253 iassert(prop->dest_y == 0);
254
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000255 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900256 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
257
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000258 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900259 iassert(prop->dest_width == 200);
260 iassert(prop->dest_height == 300);
261 iassert(prop->dest_x == 0);
262 iassert(prop->dest_y == 0);
263
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000264 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900265
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900266 iassert(prop->dest_width == 400);
267 iassert(prop->dest_height == 600);
268 iassert(prop->dest_x == 20);
269 iassert(prop->dest_y == 30);
270
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000271 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900272}
273
274static void
275test_layer_source_rectangle(struct test_context *ctx)
276{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000277 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900278 struct ivi_layout_layer *ivilayer;
279 const struct ivi_layout_layer_properties *prop;
280
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000281 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900282 iassert(ivilayer != NULL);
283
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000284 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900285 iassert(prop->source_width == 200);
286 iassert(prop->source_height == 300);
287 iassert(prop->source_x == 0);
288 iassert(prop->source_y == 0);
289
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000290 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
292
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000293 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900294 iassert(prop->source_width == 200);
295 iassert(prop->source_height == 300);
296 iassert(prop->source_x == 0);
297 iassert(prop->source_y == 0);
298
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000299 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900300
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000301 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900302 iassert(prop->source_width == 400);
303 iassert(prop->source_height == 600);
304 iassert(prop->source_x == 20);
305 iassert(prop->source_y == 30);
306
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000307 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900308}
309
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900310static void
311test_layer_bad_remove(struct test_context *ctx)
312{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000313 const struct ivi_layout_interface *lyt = ctx->layout_interface;
314 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900315}
316
317static void
318test_layer_bad_visibility(struct test_context *ctx)
319{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000320 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900321
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000322 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900323
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000324 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900325}
326
327static void
328test_layer_bad_opacity(struct test_context *ctx)
329{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000330 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900331 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000332 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900333
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000334 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900335 iassert(ivilayer != NULL);
336
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000337 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900338 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
339
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000340 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900341 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
342
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000343 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900344 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
345
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900347
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000348 prop = lyt->get_properties_of_layer(ivilayer);
349 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900350
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000351 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900352 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
353
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000354 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900355
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000356 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900357
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000358 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900359 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
360
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000361 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900362
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000363 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900364}
365
366static void
367test_layer_bad_destination_rectangle(struct test_context *ctx)
368{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900370
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000371 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900372 NULL, 20, 30, 200, 300) == IVI_FAILED);
373}
374
375static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900376test_layer_bad_source_rectangle(struct test_context *ctx)
377{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000378 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900379
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000380 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900381 NULL, 20, 30, 200, 300) == IVI_FAILED);
382}
383
384static void
385test_layer_bad_properties(struct test_context *ctx)
386{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000387 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900388
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000389 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900390}
391
392static void
393test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
394{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000395 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900396 struct ivi_layout_layer *ivilayer;
397
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000398 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900399 iassert(ivilayer != NULL);
400
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000401 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
402 lyt->layer_destroy(ivilayer);
403 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900404}
405
406static void
407test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
408{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000409 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900410 struct ivi_layout_layer *ivilayer;
411
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000412 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900413 iassert(ivilayer != NULL);
414
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000415 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900416 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000417 lyt->layer_destroy(ivilayer);
418 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900419}
420
421static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900422test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
423{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000424 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900425 struct ivi_layout_layer *ivilayer;
426
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000427 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900428 iassert(ivilayer != NULL);
429
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000430 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900431 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000432 lyt->layer_destroy(ivilayer);
433 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900434}
435
436static void
437test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
438{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000439 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900440 struct ivi_layout_layer *ivilayer;
441
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000442 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900443 iassert(ivilayer != NULL);
444
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000445 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900446 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000447 lyt->layer_destroy(ivilayer);
448 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900449}
450
451static void
452test_layer_create_duplicate(struct test_context *ctx)
453{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000454 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900455 struct ivi_layout_layer *ivilayer;
456 struct ivi_layout_layer *duplicatelayer;
457
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000458 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900459 iassert(ivilayer != NULL);
460
461 if (ivilayer != NULL)
462 iassert(ivilayer->ref_count == 1);
463
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000464 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900465 iassert(ivilayer == duplicatelayer);
466
467 if (ivilayer != NULL)
468 iassert(ivilayer->ref_count == 2);
469
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000470 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900471
472 if (ivilayer != NULL)
473 iassert(ivilayer->ref_count == 1);
474
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900476}
477
478static void
479test_get_layer_after_destory_layer(struct test_context *ctx)
480{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000481 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900482 struct ivi_layout_layer *ivilayer;
483
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000484 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900485 iassert(ivilayer != NULL);
486
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000487 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900488
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000489 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900490 iassert(ivilayer == NULL);
491}
492
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900493static void
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900494test_screen_render_order(struct test_context *ctx)
495{
496#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000497 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000498 struct weston_output *output;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900499 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
500 struct ivi_layout_layer **array;
501 int32_t length = 0;
502 uint32_t i;
503
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000504 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900505 return;
506
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000507 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900508
509 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000510 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900511
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000512 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900513
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000514 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900515
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000516 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900517 iassert(length == LAYER_NUM);
518 for (i = 0; i < LAYER_NUM; i++)
519 iassert(array[i] == ivilayers[i]);
520
521 if (length > 0)
522 free(array);
523
524 array = NULL;
525
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000526 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900527
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000528 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900529
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000530 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900531 iassert(length == 0 && array == NULL);
532
533 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000534 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900535
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900536#undef LAYER_NUM
537}
538
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900539static void
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900540test_screen_bad_render_order(struct test_context *ctx)
541{
542#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000543 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000544 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900545 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
546 struct ivi_layout_layer **array;
547 int32_t length = 0;
548 uint32_t i;
549
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000550 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900551 return;
552
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000553 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900554
555 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000556 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900557
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000558 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900559
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000560 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900561
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000562 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000563 iassert(lyt->get_layers_on_screen(output, NULL, &array) == IVI_FAILED);
564 iassert(lyt->get_layers_on_screen(output, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900565
566 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000567 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900568
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900569#undef LAYER_NUM
570}
571
572static void
Ucan, Emre (ADITG/SW1)fbce2f52017-01-18 15:25:36 +0000573test_screen_add_layers(struct test_context *ctx)
574{
575#define LAYER_NUM (3)
576 const struct ivi_layout_interface *lyt = ctx->layout_interface;
577 struct weston_output *output;
578 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
579 struct ivi_layout_layer **array;
580 int32_t length = 0;
581 uint32_t i;
582
583 if (wl_list_empty(&ctx->compositor->output_list))
584 return;
585
586 output = wl_container_of(ctx->compositor->output_list.next, output, link);
587
588 for (i = 0; i < LAYER_NUM; i++) {
589 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
590 iassert(lyt->screen_add_layer(output, ivilayers[i]) == IVI_SUCCEEDED);
591 }
592
593 lyt->commit_changes();
594
595 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
596 iassert(length == LAYER_NUM);
597 for (i = 0; i < (uint32_t)length; i++)
598 iassert(array[i] == ivilayers[i]);
599
600 if (length > 0)
601 free(array);
602
603 array = NULL;
604
605 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
606 for (i = LAYER_NUM; i-- > 0;)
607 iassert(lyt->screen_add_layer(output, ivilayers[i]) == IVI_SUCCEEDED);
608
609 lyt->commit_changes();
610
611 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
612 iassert(length == LAYER_NUM);
613 for (i = 0; i < (uint32_t)length; i++)
614 iassert(array[i] == ivilayers[LAYER_NUM - (i + 1)]);
615
616 if (length > 0)
617 free(array);
618
619 for (i = 0; i < LAYER_NUM; i++)
620 lyt->layer_destroy(ivilayers[i]);
621
622#undef LAYER_NUM
623}
624
625static void
Michael Teyfel156bd062017-07-26 14:22:49 +0200626test_screen_remove_layer(struct test_context *ctx)
627{
628 const struct ivi_layout_interface *lyt = ctx->layout_interface;
629 struct ivi_layout_layer *ivilayer;
630 struct weston_output *output;
631 struct ivi_layout_layer **array;
632 int32_t length = 0;
633
634 if (wl_list_empty(&ctx->compositor->output_list))
635 return;
636
637 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
638 iassert(ivilayer != NULL);
639
640 output = wl_container_of(ctx->compositor->output_list.next, output, link);
641
642 iassert(lyt->screen_add_layer(output, ivilayer) == IVI_SUCCEEDED);
643 lyt->commit_changes();
644
645 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
646 iassert(length == 1);
647 iassert(array[0] == ivilayer);
648
649 iassert(lyt->screen_remove_layer(output, ivilayer) == IVI_SUCCEEDED);
650 lyt->commit_changes();
651
652 if (length > 0)
653 free(array);
654
655 array = NULL;
656
657 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
658 iassert(length == 0);
659 iassert(array == NULL);
660
661 lyt->layer_destroy(ivilayer);
662}
663
664static void
665test_screen_bad_remove_layer(struct test_context *ctx)
666{
667 const struct ivi_layout_interface *lyt = ctx->layout_interface;
668 struct ivi_layout_layer *ivilayer;
669 struct weston_output *output;
670
671 if (wl_list_empty(&ctx->compositor->output_list))
672 return;
673
674 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
675 iassert(ivilayer != NULL);
676
677 output = wl_container_of(ctx->compositor->output_list.next, output, link);
678
679 iassert(lyt->screen_remove_layer(NULL, ivilayer) == IVI_FAILED);
680 lyt->commit_changes();
681
682 iassert(lyt->screen_remove_layer(output, NULL) == IVI_FAILED);
683 lyt->commit_changes();
684
685 iassert(lyt->screen_remove_layer(NULL, NULL) == IVI_FAILED);
686 lyt->commit_changes();
687
688 lyt->layer_destroy(ivilayer);
689}
690
691
692static void
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900693test_commit_changes_after_render_order_set_layer_destroy(
694 struct test_context *ctx)
695{
696#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000697 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000698 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900699 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
700 uint32_t i;
701
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000702 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900703 return;
704
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000705 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900706
707 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000708 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900709
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000710 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900711
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000712 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900713
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000714 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900715
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000716 lyt->layer_destroy(ivilayers[0]);
717 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900718#undef LAYER_NUM
719}
720
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900721static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000722test_layer_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900723{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000724 struct test_context *ctx =
725 container_of(listener, struct test_context,
726 layer_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000727 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000728 struct ivi_layout_layer *ivilayer = data;
729 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900730
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000731 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900732 iassert(prop->source_width == 200);
733 iassert(prop->source_height == 300);
734
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000735 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900736 prop->source_width == 200 && prop->source_height == 300)
737 ctx->user_flags = 1;
738}
739
740static void
741test_layer_properties_changed_notification(struct test_context *ctx)
742{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000743 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900744 struct ivi_layout_layer *ivilayer;
745
746 ctx->user_flags = 0;
747
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000748 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900749
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000750 ctx->layer_property_changed.notify = test_layer_properties_changed_notification_callback;
751
752 iassert(lyt->layer_add_listener(ivilayer, &ctx->layer_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900753
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000754 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900755
756 iassert(ctx->user_flags == 0);
757
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000758 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900759 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
760
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000761 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900762
763 iassert(ctx->user_flags == 1);
764
765 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000766 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900767 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
768
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900770
771 iassert(ctx->user_flags == 0);
772
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000773 // remove layer property changed listener.
774 wl_list_remove(&ctx->layer_property_changed.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900775
776 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000777 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900778
779 iassert(ctx->user_flags == 0);
780
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000781 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900782}
783
784static void
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000785test_layer_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900786{
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000787 struct test_context *ctx =
788 container_of(listener, struct test_context,
789 layer_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000790 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000791 struct ivi_layout_layer *ivilayer = data;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000792 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900793
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000794 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900795 iassert(prop->source_width == 200);
796 iassert(prop->source_height == 300);
797
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000798 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900799 prop->source_width == 200 && prop->source_height == 300)
800 ctx->user_flags = 1;
801}
802
803static void
804test_layer_create_notification(struct test_context *ctx)
805{
806#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900808 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
809 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
810
811 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000812 ctx->layer_created.notify = test_layer_create_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900813
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000814 iassert(lyt->add_listener_create_layer(&ctx->layer_created) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000815 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900816
817 iassert(ctx->user_flags == 1);
818
819 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000820 // remove layer created listener.
821 wl_list_remove(&ctx->layer_created.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900822
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000823 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900824
825 iassert(ctx->user_flags == 0);
826
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000827 lyt->layer_destroy(ivilayers[0]);
828 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900829#undef LAYER_NUM
830}
831
832static void
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000833test_layer_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900834{
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000835 struct test_context *ctx =
836 container_of(listener, struct test_context,
837 layer_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000838 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000839 struct ivi_layout_layer *ivilayer = data;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900840 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000841 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900842
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000843 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900844 iassert(prop->source_width == 200);
845 iassert(prop->source_height == 300);
846
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000847 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900848 prop->source_width == 200 && prop->source_height == 300)
849 ctx->user_flags = 1;
850}
851
852static void
853test_layer_remove_notification(struct test_context *ctx)
854{
855#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000856 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900857 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
858 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
859
860 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000861 ctx->layer_removed.notify = test_layer_remove_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900862
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000863 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000864 iassert(lyt->add_listener_remove_layer(&ctx->layer_removed) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000865 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900866
867 iassert(ctx->user_flags == 1);
868
869 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000870 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000871
872 // remove layer property changed listener.
873 wl_list_remove(&ctx->layer_removed.link);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000874 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900875
876 iassert(ctx->user_flags == 0);
877#undef LAYER_NUM
878}
879
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900880static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000881test_layer_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900882{
883}
884
885static void
886test_layer_bad_properties_changed_notification(struct test_context *ctx)
887{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000888 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900889 struct ivi_layout_layer *ivilayer;
890
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000891 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900892
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000893 ctx->layer_property_changed.notify = test_layer_bad_properties_changed_notification_callback;
894
895 iassert(lyt->layer_add_listener(NULL, &ctx->layer_property_changed) == IVI_FAILED);
896 iassert(lyt->layer_add_listener(ivilayer, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900897
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000898 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900899}
900
901static void
902test_surface_bad_configure_notification(struct test_context *ctx)
903{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000904 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900905
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000906 iassert(lyt->add_listener_configure_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900907}
908
909static void
910test_layer_bad_create_notification(struct test_context *ctx)
911{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000912 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900913
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000914 iassert(lyt->add_listener_create_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900915}
916
917static void
918test_surface_bad_create_notification(struct test_context *ctx)
919{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000920 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900921
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000922 iassert(lyt->add_listener_create_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900923}
924
925static void
926test_layer_bad_remove_notification(struct test_context *ctx)
927{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000928 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900929
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000930 iassert(lyt->add_listener_remove_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900931}
932
933static void
934test_surface_bad_remove_notification(struct test_context *ctx)
935{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000936 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900937
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000938 iassert(lyt->add_listener_remove_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900939}
940
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200941/************************ tests end ********************************/
942
943static void
944run_internal_tests(void *data)
945{
946 struct test_context *ctx = data;
947
948 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900949 test_surface_bad_destination_rectangle(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900950 test_surface_bad_source_rectangle(ctx);
951 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200952
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900953 test_layer_create(ctx);
954 test_layer_visibility(ctx);
955 test_layer_opacity(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900956 test_layer_dimension(ctx);
957 test_layer_position(ctx);
958 test_layer_destination_rectangle(ctx);
959 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900960 test_layer_bad_remove(ctx);
961 test_layer_bad_visibility(ctx);
962 test_layer_bad_opacity(ctx);
963 test_layer_bad_destination_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900964 test_layer_bad_source_rectangle(ctx);
965 test_layer_bad_properties(ctx);
966 test_commit_changes_after_visibility_set_layer_destroy(ctx);
967 test_commit_changes_after_opacity_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900968 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
969 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
970 test_layer_create_duplicate(ctx);
971 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900972
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900973 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900974 test_screen_bad_render_order(ctx);
Ucan, Emre (ADITG/SW1)fbce2f52017-01-18 15:25:36 +0000975 test_screen_add_layers(ctx);
Michael Teyfel156bd062017-07-26 14:22:49 +0200976 test_screen_remove_layer(ctx);
977 test_screen_bad_remove_layer(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900978 test_commit_changes_after_render_order_set_layer_destroy(ctx);
979
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900980 test_layer_properties_changed_notification(ctx);
981 test_layer_create_notification(ctx);
982 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900983 test_layer_bad_properties_changed_notification(ctx);
984 test_surface_bad_configure_notification(ctx);
985 test_layer_bad_create_notification(ctx);
986 test_surface_bad_create_notification(ctx);
987 test_layer_bad_remove_notification(ctx);
988 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900989
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200990 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
991 free(ctx);
992}
993
994int
995controller_module_init(struct weston_compositor *compositor,
996 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000997 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200998 size_t iface_version);
999
1000WL_EXPORT int
1001controller_module_init(struct weston_compositor *compositor,
1002 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001003 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001004 size_t iface_version)
1005{
1006 struct wl_event_loop *loop;
1007 struct test_context *ctx;
1008
1009 /* strict check, since this is an internal test module */
1010 if (iface_version != sizeof(*iface)) {
1011 weston_log("fatal: controller interface mismatch\n");
1012 return -1;
1013 }
1014
1015 ctx = zalloc(sizeof(*ctx));
1016 if (!ctx)
1017 return -1;
1018
1019 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001020 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001021
1022 loop = wl_display_get_event_loop(compositor->wl_display);
1023 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1024
1025 return 0;
1026}