blob: f5e2763f93e234d6cf0c4d2057325cd3aa4e7f2c [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
183test_layer_orientation(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;
188
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\)5bb068d2016-03-04 12:50:39 +0000192 prop = lyt->get_properties_of_layer(ivilayer);
193 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900194
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000195 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900196 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
197
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000198 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900199
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000200 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900201
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900202 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
203
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000204 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900205}
206
207static void
208test_layer_dimension(struct test_context *ctx)
209{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000210 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900211 struct ivi_layout_layer *ivilayer;
212 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900213
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000214 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900215 iassert(ivilayer != NULL);
216
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000217 prop = lyt->get_properties_of_layer(ivilayer);
218 iassert(prop->dest_width == 200);
219 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900220
Ucan, Emre \(ADITG/SW1\)16d1fa12016-03-04 12:50:52 +0000221 iassert(lyt->layer_set_destination_rectangle(ivilayer, prop->dest_x, prop->dest_y,
222 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900223
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000224 iassert(prop->dest_width == 200);
225 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900226
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000227 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900228
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900229 iassert(prop->dest_width == 400);
230 iassert(prop->dest_height == 600);
231
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000232 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900233}
234
235static void
236test_layer_position(struct test_context *ctx)
237{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000238 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900239 struct ivi_layout_layer *ivilayer;
240 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900241
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000242 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900243 iassert(ivilayer != NULL);
244
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000245 prop = lyt->get_properties_of_layer(ivilayer);
246 iassert(prop->dest_x == 0);
247 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900248
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +0000249 iassert(lyt->layer_set_destination_rectangle(ivilayer, 20, 30,
250 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900251
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000252 iassert(prop->dest_x == 0);
253 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900254
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000255 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900256
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000257 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900258 iassert(prop->dest_x == 20);
259 iassert(prop->dest_y == 30);
260
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000261 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900262}
263
264static void
265test_layer_destination_rectangle(struct test_context *ctx)
266{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000267 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900268 struct ivi_layout_layer *ivilayer;
269 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900270
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000271 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900272 iassert(ivilayer != NULL);
273
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000274 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900275 iassert(prop->dest_width == 200);
276 iassert(prop->dest_height == 300);
277 iassert(prop->dest_x == 0);
278 iassert(prop->dest_y == 0);
279
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000280 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900281 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
282
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000283 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900284 iassert(prop->dest_width == 200);
285 iassert(prop->dest_height == 300);
286 iassert(prop->dest_x == 0);
287 iassert(prop->dest_y == 0);
288
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000289 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900290
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291 iassert(prop->dest_width == 400);
292 iassert(prop->dest_height == 600);
293 iassert(prop->dest_x == 20);
294 iassert(prop->dest_y == 30);
295
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000296 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900297}
298
299static void
300test_layer_source_rectangle(struct test_context *ctx)
301{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000302 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900303 struct ivi_layout_layer *ivilayer;
304 const struct ivi_layout_layer_properties *prop;
305
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000306 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900307 iassert(ivilayer != NULL);
308
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000309 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900310 iassert(prop->source_width == 200);
311 iassert(prop->source_height == 300);
312 iassert(prop->source_x == 0);
313 iassert(prop->source_y == 0);
314
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000315 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900316 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
317
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000318 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900319 iassert(prop->source_width == 200);
320 iassert(prop->source_height == 300);
321 iassert(prop->source_x == 0);
322 iassert(prop->source_y == 0);
323
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000324 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900325
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000326 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900327 iassert(prop->source_width == 400);
328 iassert(prop->source_height == 600);
329 iassert(prop->source_x == 20);
330 iassert(prop->source_y == 30);
331
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000332 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900333}
334
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900335static void
336test_layer_bad_remove(struct test_context *ctx)
337{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000338 const struct ivi_layout_interface *lyt = ctx->layout_interface;
339 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900340}
341
342static void
343test_layer_bad_visibility(struct test_context *ctx)
344{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000345 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900346
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000347 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900348
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000349 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900350}
351
352static void
353test_layer_bad_opacity(struct test_context *ctx)
354{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000355 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900356 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000357 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900358
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000359 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900360 iassert(ivilayer != NULL);
361
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000362 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900363 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
364
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000365 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900366 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
367
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000368 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900369 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
370
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000371 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900372
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000373 prop = lyt->get_properties_of_layer(ivilayer);
374 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900375
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000376 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900377 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
378
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000379 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900380
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000381 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900382
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000383 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900384 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
385
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000386 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900387
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000388 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900389}
390
391static void
392test_layer_bad_destination_rectangle(struct test_context *ctx)
393{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000394 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900395
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000396 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900397 NULL, 20, 30, 200, 300) == IVI_FAILED);
398}
399
400static void
401test_layer_bad_orientation(struct test_context *ctx)
402{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000403 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900404
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000405 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900406 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
407
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000408 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900409}
410
411static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900412test_layer_bad_source_rectangle(struct test_context *ctx)
413{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000414 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900415
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417 NULL, 20, 30, 200, 300) == IVI_FAILED);
418}
419
420static void
421test_layer_bad_properties(struct test_context *ctx)
422{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000423 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900424
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900426}
427
428static void
429test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
430{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000431 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900432 struct ivi_layout_layer *ivilayer;
433
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000434 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900435 iassert(ivilayer != NULL);
436
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000437 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
438 lyt->layer_destroy(ivilayer);
439 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900440}
441
442static void
443test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
444{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000445 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900446 struct ivi_layout_layer *ivilayer;
447
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000448 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900449 iassert(ivilayer != NULL);
450
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000451 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900452 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 lyt->layer_destroy(ivilayer);
454 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900455}
456
457static void
458test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
459{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000460 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900461 struct ivi_layout_layer *ivilayer;
462
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000463 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900464 iassert(ivilayer != NULL);
465
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000466 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900467 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000468 lyt->layer_destroy(ivilayer);
469 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900470}
471
472static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900473test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
474{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900476 struct ivi_layout_layer *ivilayer;
477
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000478 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900479 iassert(ivilayer != NULL);
480
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000481 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900482 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000483 lyt->layer_destroy(ivilayer);
484 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900485}
486
487static void
488test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
489{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900491 struct ivi_layout_layer *ivilayer;
492
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000493 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900494 iassert(ivilayer != NULL);
495
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000496 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900497 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000498 lyt->layer_destroy(ivilayer);
499 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900500}
501
502static void
503test_layer_create_duplicate(struct test_context *ctx)
504{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000505 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900506 struct ivi_layout_layer *ivilayer;
507 struct ivi_layout_layer *duplicatelayer;
508
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900510 iassert(ivilayer != NULL);
511
512 if (ivilayer != NULL)
513 iassert(ivilayer->ref_count == 1);
514
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000515 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900516 iassert(ivilayer == duplicatelayer);
517
518 if (ivilayer != NULL)
519 iassert(ivilayer->ref_count == 2);
520
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000521 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900522
523 if (ivilayer != NULL)
524 iassert(ivilayer->ref_count == 1);
525
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000526 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900527}
528
529static void
530test_get_layer_after_destory_layer(struct test_context *ctx)
531{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000532 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900533 struct ivi_layout_layer *ivilayer;
534
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000535 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900536 iassert(ivilayer != NULL);
537
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000538 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900539
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000540 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900541 iassert(ivilayer == NULL);
542}
543
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900544static void
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900545test_screen_render_order(struct test_context *ctx)
546{
547#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000548 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000549 struct weston_output *output;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900550 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
551 struct ivi_layout_layer **array;
552 int32_t length = 0;
553 uint32_t i;
554
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000555 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900556 return;
557
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000558 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900559
560 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000561 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900562
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000563 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900564
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000565 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900566
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000567 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900568 iassert(length == LAYER_NUM);
569 for (i = 0; i < LAYER_NUM; i++)
570 iassert(array[i] == ivilayers[i]);
571
572 if (length > 0)
573 free(array);
574
575 array = NULL;
576
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000577 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900578
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000579 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900580
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000581 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900582 iassert(length == 0 && array == NULL);
583
584 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000585 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900586
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900587#undef LAYER_NUM
588}
589
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900590static void
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900591test_screen_bad_render_order(struct test_context *ctx)
592{
593#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000594 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000595 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900596 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
597 struct ivi_layout_layer **array;
598 int32_t length = 0;
599 uint32_t i;
600
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000601 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900602 return;
603
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000604 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900605
606 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000607 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900608
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000609 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900610
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000611 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900612
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000613 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000614 iassert(lyt->get_layers_on_screen(output, NULL, &array) == IVI_FAILED);
615 iassert(lyt->get_layers_on_screen(output, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900616
617 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000618 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900619
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900620#undef LAYER_NUM
621}
622
623static void
Ucan, Emre (ADITG/SW1)fbce2f52017-01-18 15:25:36 +0000624test_screen_add_layers(struct test_context *ctx)
625{
626#define LAYER_NUM (3)
627 const struct ivi_layout_interface *lyt = ctx->layout_interface;
628 struct weston_output *output;
629 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
630 struct ivi_layout_layer **array;
631 int32_t length = 0;
632 uint32_t i;
633
634 if (wl_list_empty(&ctx->compositor->output_list))
635 return;
636
637 output = wl_container_of(ctx->compositor->output_list.next, output, link);
638
639 for (i = 0; i < LAYER_NUM; i++) {
640 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
641 iassert(lyt->screen_add_layer(output, ivilayers[i]) == IVI_SUCCEEDED);
642 }
643
644 lyt->commit_changes();
645
646 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
647 iassert(length == LAYER_NUM);
648 for (i = 0; i < (uint32_t)length; i++)
649 iassert(array[i] == ivilayers[i]);
650
651 if (length > 0)
652 free(array);
653
654 array = NULL;
655
656 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
657 for (i = LAYER_NUM; i-- > 0;)
658 iassert(lyt->screen_add_layer(output, ivilayers[i]) == IVI_SUCCEEDED);
659
660 lyt->commit_changes();
661
662 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
663 iassert(length == LAYER_NUM);
664 for (i = 0; i < (uint32_t)length; i++)
665 iassert(array[i] == ivilayers[LAYER_NUM - (i + 1)]);
666
667 if (length > 0)
668 free(array);
669
670 for (i = 0; i < LAYER_NUM; i++)
671 lyt->layer_destroy(ivilayers[i]);
672
673#undef LAYER_NUM
674}
675
676static void
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900677test_commit_changes_after_render_order_set_layer_destroy(
678 struct test_context *ctx)
679{
680#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000681 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000682 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900683 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
684 uint32_t i;
685
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000686 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900687 return;
688
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000689 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900690
691 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000692 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900693
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000694 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900695
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000696 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900697
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000698 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900699
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 lyt->layer_destroy(ivilayers[0]);
701 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900702#undef LAYER_NUM
703}
704
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900705static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000706test_layer_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900707{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000708 struct test_context *ctx =
709 container_of(listener, struct test_context,
710 layer_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000711 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000712 struct ivi_layout_layer *ivilayer = data;
713 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900714
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000715 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900716 iassert(prop->source_width == 200);
717 iassert(prop->source_height == 300);
718
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000719 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900720 prop->source_width == 200 && prop->source_height == 300)
721 ctx->user_flags = 1;
722}
723
724static void
725test_layer_properties_changed_notification(struct test_context *ctx)
726{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000727 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900728 struct ivi_layout_layer *ivilayer;
729
730 ctx->user_flags = 0;
731
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000732 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900733
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000734 ctx->layer_property_changed.notify = test_layer_properties_changed_notification_callback;
735
736 iassert(lyt->layer_add_listener(ivilayer, &ctx->layer_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900737
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000738 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900739
740 iassert(ctx->user_flags == 0);
741
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000742 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900743 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
744
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000745 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900746
747 iassert(ctx->user_flags == 1);
748
749 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000750 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900751 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
752
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000753 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900754
755 iassert(ctx->user_flags == 0);
756
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000757 // remove layer property changed listener.
758 wl_list_remove(&ctx->layer_property_changed.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900759
760 ctx->user_flags = 0;
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 == 0);
764
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000765 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900766}
767
768static void
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000769test_layer_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900770{
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000771 struct test_context *ctx =
772 container_of(listener, struct test_context,
773 layer_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000775 struct ivi_layout_layer *ivilayer = data;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000776 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900777
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000778 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900779 iassert(prop->source_width == 200);
780 iassert(prop->source_height == 300);
781
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000782 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900783 prop->source_width == 200 && prop->source_height == 300)
784 ctx->user_flags = 1;
785}
786
787static void
788test_layer_create_notification(struct test_context *ctx)
789{
790#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000791 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900792 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
793 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
794
795 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000796 ctx->layer_created.notify = test_layer_create_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900797
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000798 iassert(lyt->add_listener_create_layer(&ctx->layer_created) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000799 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900800
801 iassert(ctx->user_flags == 1);
802
803 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000804 // remove layer created listener.
805 wl_list_remove(&ctx->layer_created.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900806
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900808
809 iassert(ctx->user_flags == 0);
810
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000811 lyt->layer_destroy(ivilayers[0]);
812 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900813#undef LAYER_NUM
814}
815
816static void
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000817test_layer_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900818{
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000819 struct test_context *ctx =
820 container_of(listener, struct test_context,
821 layer_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000822 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000823 struct ivi_layout_layer *ivilayer = data;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900824 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000825 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900826
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000827 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900828 iassert(prop->source_width == 200);
829 iassert(prop->source_height == 300);
830
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000831 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900832 prop->source_width == 200 && prop->source_height == 300)
833 ctx->user_flags = 1;
834}
835
836static void
837test_layer_remove_notification(struct test_context *ctx)
838{
839#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000840 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900841 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
842 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
843
844 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000845 ctx->layer_removed.notify = test_layer_remove_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900846
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000847 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000848 iassert(lyt->add_listener_remove_layer(&ctx->layer_removed) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000849 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900850
851 iassert(ctx->user_flags == 1);
852
853 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000854 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000855
856 // remove layer property changed listener.
857 wl_list_remove(&ctx->layer_removed.link);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000858 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900859
860 iassert(ctx->user_flags == 0);
861#undef LAYER_NUM
862}
863
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900864static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000865test_layer_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900866{
867}
868
869static void
870test_layer_bad_properties_changed_notification(struct test_context *ctx)
871{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000872 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900873 struct ivi_layout_layer *ivilayer;
874
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000875 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900876
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000877 ctx->layer_property_changed.notify = test_layer_bad_properties_changed_notification_callback;
878
879 iassert(lyt->layer_add_listener(NULL, &ctx->layer_property_changed) == IVI_FAILED);
880 iassert(lyt->layer_add_listener(ivilayer, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900881
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900883}
884
885static void
886test_surface_bad_configure_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
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000890 iassert(lyt->add_listener_configure_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900891}
892
893static void
894test_layer_bad_create_notification(struct test_context *ctx)
895{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000896 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900897
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000898 iassert(lyt->add_listener_create_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900899}
900
901static void
902test_surface_bad_create_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)970f8312016-04-04 08:05:09 +0000906 iassert(lyt->add_listener_create_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900907}
908
909static void
910test_layer_bad_remove_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)562f2ec2016-04-04 08:05:15 +0000914 iassert(lyt->add_listener_remove_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900915}
916
917static void
918test_surface_bad_remove_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)67f0aa82016-04-04 08:05:18 +0000922 iassert(lyt->add_listener_remove_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900923}
924
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200925/************************ tests end ********************************/
926
927static void
928run_internal_tests(void *data)
929{
930 struct test_context *ctx = data;
931
932 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900933 test_surface_bad_destination_rectangle(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900934 test_surface_bad_source_rectangle(ctx);
935 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200936
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900937 test_layer_create(ctx);
938 test_layer_visibility(ctx);
939 test_layer_opacity(ctx);
940 test_layer_orientation(ctx);
941 test_layer_dimension(ctx);
942 test_layer_position(ctx);
943 test_layer_destination_rectangle(ctx);
944 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900945 test_layer_bad_remove(ctx);
946 test_layer_bad_visibility(ctx);
947 test_layer_bad_opacity(ctx);
948 test_layer_bad_destination_rectangle(ctx);
949 test_layer_bad_orientation(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900950 test_layer_bad_source_rectangle(ctx);
951 test_layer_bad_properties(ctx);
952 test_commit_changes_after_visibility_set_layer_destroy(ctx);
953 test_commit_changes_after_opacity_set_layer_destroy(ctx);
954 test_commit_changes_after_orientation_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900955 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
956 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
957 test_layer_create_duplicate(ctx);
958 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900959
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900960 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900961 test_screen_bad_render_order(ctx);
Ucan, Emre (ADITG/SW1)fbce2f52017-01-18 15:25:36 +0000962 test_screen_add_layers(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900963 test_commit_changes_after_render_order_set_layer_destroy(ctx);
964
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900965 test_layer_properties_changed_notification(ctx);
966 test_layer_create_notification(ctx);
967 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900968 test_layer_bad_properties_changed_notification(ctx);
969 test_surface_bad_configure_notification(ctx);
970 test_layer_bad_create_notification(ctx);
971 test_surface_bad_create_notification(ctx);
972 test_layer_bad_remove_notification(ctx);
973 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900974
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200975 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
976 free(ctx);
977}
978
979int
980controller_module_init(struct weston_compositor *compositor,
981 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000982 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200983 size_t iface_version);
984
985WL_EXPORT int
986controller_module_init(struct weston_compositor *compositor,
987 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000988 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200989 size_t iface_version)
990{
991 struct wl_event_loop *loop;
992 struct test_context *ctx;
993
994 /* strict check, since this is an internal test module */
995 if (iface_version != sizeof(*iface)) {
996 weston_log("fatal: controller interface mismatch\n");
997 return -1;
998 }
999
1000 ctx = zalloc(sizeof(*ctx));
1001 if (!ctx)
1002 return -1;
1003
1004 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001005 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001006
1007 loop = wl_display_get_event_loop(compositor->wl_display);
1008 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1009
1010 return 0;
1011}