blob: e56eb12500701bbd732193f36688a03231a74dde [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
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900626test_commit_changes_after_render_order_set_layer_destroy(
627 struct test_context *ctx)
628{
629#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000630 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000631 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900632 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
633 uint32_t i;
634
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000635 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900636 return;
637
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000638 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900639
640 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000641 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900642
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000643 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900644
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000645 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900646
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000647 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900648
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 lyt->layer_destroy(ivilayers[0]);
650 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900651#undef LAYER_NUM
652}
653
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900654static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000655test_layer_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900656{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000657 struct test_context *ctx =
658 container_of(listener, struct test_context,
659 layer_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000660 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000661 struct ivi_layout_layer *ivilayer = data;
662 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900663
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000664 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900665 iassert(prop->source_width == 200);
666 iassert(prop->source_height == 300);
667
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000668 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900669 prop->source_width == 200 && prop->source_height == 300)
670 ctx->user_flags = 1;
671}
672
673static void
674test_layer_properties_changed_notification(struct test_context *ctx)
675{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000676 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900677 struct ivi_layout_layer *ivilayer;
678
679 ctx->user_flags = 0;
680
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000681 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900682
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000683 ctx->layer_property_changed.notify = test_layer_properties_changed_notification_callback;
684
685 iassert(lyt->layer_add_listener(ivilayer, &ctx->layer_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900686
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000687 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900688
689 iassert(ctx->user_flags == 0);
690
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000691 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900692 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
693
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000694 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900695
696 iassert(ctx->user_flags == 1);
697
698 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000699 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900700 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
701
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000702 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900703
704 iassert(ctx->user_flags == 0);
705
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000706 // remove layer property changed listener.
707 wl_list_remove(&ctx->layer_property_changed.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900708
709 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000710 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900711
712 iassert(ctx->user_flags == 0);
713
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000714 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900715}
716
717static void
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000718test_layer_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900719{
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000720 struct test_context *ctx =
721 container_of(listener, struct test_context,
722 layer_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000723 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000724 struct ivi_layout_layer *ivilayer = data;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000725 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900726
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000727 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900728 iassert(prop->source_width == 200);
729 iassert(prop->source_height == 300);
730
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000731 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900732 prop->source_width == 200 && prop->source_height == 300)
733 ctx->user_flags = 1;
734}
735
736static void
737test_layer_create_notification(struct test_context *ctx)
738{
739#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000740 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900741 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
742 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
743
744 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000745 ctx->layer_created.notify = test_layer_create_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900746
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000747 iassert(lyt->add_listener_create_layer(&ctx->layer_created) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000748 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900749
750 iassert(ctx->user_flags == 1);
751
752 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000753 // remove layer created listener.
754 wl_list_remove(&ctx->layer_created.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900755
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000756 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900757
758 iassert(ctx->user_flags == 0);
759
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000760 lyt->layer_destroy(ivilayers[0]);
761 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900762#undef LAYER_NUM
763}
764
765static void
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000766test_layer_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900767{
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000768 struct test_context *ctx =
769 container_of(listener, struct test_context,
770 layer_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000771 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000772 struct ivi_layout_layer *ivilayer = data;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900773 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900775
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000776 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900777 iassert(prop->source_width == 200);
778 iassert(prop->source_height == 300);
779
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000780 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900781 prop->source_width == 200 && prop->source_height == 300)
782 ctx->user_flags = 1;
783}
784
785static void
786test_layer_remove_notification(struct test_context *ctx)
787{
788#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000789 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900790 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
791 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
792
793 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000794 ctx->layer_removed.notify = test_layer_remove_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900795
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000796 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000797 iassert(lyt->add_listener_remove_layer(&ctx->layer_removed) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000798 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900799
800 iassert(ctx->user_flags == 1);
801
802 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000803 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000804
805 // remove layer property changed listener.
806 wl_list_remove(&ctx->layer_removed.link);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900808
809 iassert(ctx->user_flags == 0);
810#undef LAYER_NUM
811}
812
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900813static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000814test_layer_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900815{
816}
817
818static void
819test_layer_bad_properties_changed_notification(struct test_context *ctx)
820{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000821 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900822 struct ivi_layout_layer *ivilayer;
823
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000824 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900825
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000826 ctx->layer_property_changed.notify = test_layer_bad_properties_changed_notification_callback;
827
828 iassert(lyt->layer_add_listener(NULL, &ctx->layer_property_changed) == IVI_FAILED);
829 iassert(lyt->layer_add_listener(ivilayer, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900830
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000831 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900832}
833
834static void
835test_surface_bad_configure_notification(struct test_context *ctx)
836{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000837 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900838
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000839 iassert(lyt->add_listener_configure_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900840}
841
842static void
843test_layer_bad_create_notification(struct test_context *ctx)
844{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000845 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900846
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000847 iassert(lyt->add_listener_create_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900848}
849
850static void
851test_surface_bad_create_notification(struct test_context *ctx)
852{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000853 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900854
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000855 iassert(lyt->add_listener_create_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900856}
857
858static void
859test_layer_bad_remove_notification(struct test_context *ctx)
860{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000861 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900862
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000863 iassert(lyt->add_listener_remove_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900864}
865
866static void
867test_surface_bad_remove_notification(struct test_context *ctx)
868{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000869 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900870
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000871 iassert(lyt->add_listener_remove_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900872}
873
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200874/************************ tests end ********************************/
875
876static void
877run_internal_tests(void *data)
878{
879 struct test_context *ctx = data;
880
881 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900882 test_surface_bad_destination_rectangle(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900883 test_surface_bad_source_rectangle(ctx);
884 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200885
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900886 test_layer_create(ctx);
887 test_layer_visibility(ctx);
888 test_layer_opacity(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900889 test_layer_dimension(ctx);
890 test_layer_position(ctx);
891 test_layer_destination_rectangle(ctx);
892 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900893 test_layer_bad_remove(ctx);
894 test_layer_bad_visibility(ctx);
895 test_layer_bad_opacity(ctx);
896 test_layer_bad_destination_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900897 test_layer_bad_source_rectangle(ctx);
898 test_layer_bad_properties(ctx);
899 test_commit_changes_after_visibility_set_layer_destroy(ctx);
900 test_commit_changes_after_opacity_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900901 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
902 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
903 test_layer_create_duplicate(ctx);
904 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900905
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900906 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900907 test_screen_bad_render_order(ctx);
Ucan, Emre (ADITG/SW1)fbce2f52017-01-18 15:25:36 +0000908 test_screen_add_layers(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900909 test_commit_changes_after_render_order_set_layer_destroy(ctx);
910
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900911 test_layer_properties_changed_notification(ctx);
912 test_layer_create_notification(ctx);
913 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900914 test_layer_bad_properties_changed_notification(ctx);
915 test_surface_bad_configure_notification(ctx);
916 test_layer_bad_create_notification(ctx);
917 test_surface_bad_create_notification(ctx);
918 test_layer_bad_remove_notification(ctx);
919 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900920
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200921 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
922 free(ctx);
923}
924
925int
926controller_module_init(struct weston_compositor *compositor,
927 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000928 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200929 size_t iface_version);
930
931WL_EXPORT int
932controller_module_init(struct weston_compositor *compositor,
933 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000934 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200935 size_t iface_version)
936{
937 struct wl_event_loop *loop;
938 struct test_context *ctx;
939
940 /* strict check, since this is an internal test module */
941 if (iface_version != sizeof(*iface)) {
942 weston_log("fatal: controller interface mismatch\n");
943 return -1;
944 }
945
946 ctx = zalloc(sizeof(*ctx));
947 if (!ctx)
948 return -1;
949
950 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000951 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200952
953 loop = wl_display_get_event_loop(compositor->wl_display);
954 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
955
956 return 0;
957}