blob: 4e1735717a3a743742e78873f75a92faf0d1403d [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>
33
Jon Cruz4678bab2015-06-15 15:37:07 -070034#include "src/compositor.h"
35#include "ivi-shell/ivi-layout-export.h"
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +090036#include "ivi-shell/ivi-layout-private.h"
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +090037#include "ivi-test.h"
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +000038#include "shared/helpers.h"
Pekka Paalanen46804ca2015-03-27 11:55:21 +020039
40struct test_context {
41 struct weston_compositor *compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000042 const struct ivi_layout_interface *layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +090043 uint32_t user_flags;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +000044
45 struct wl_listener layer_property_changed;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +000046 struct wl_listener layer_created;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +000047 struct wl_listener layer_removed;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020048};
49
50static void
51iassert_fail(const char *cond, const char *file, int line,
52 const char *func, struct test_context *ctx)
53{
54 weston_log("Assert failure in %s:%d, %s: '%s'\n",
55 file, line, func, cond);
56 weston_compositor_exit_with_code(ctx->compositor, EXIT_FAILURE);
57}
58
59#define iassert(cond) ({ \
60 bool b_ = (cond); \
61 if (!b_) \
62 iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx); \
63 b_; \
64})
65
66/************************ tests begin ******************************/
67
68/*
69 * These are all internal ivi_layout API tests that do not require
70 * any client objects.
71 */
Pekka Paalanen46804ca2015-03-27 11:55:21 +020072static void
73test_surface_bad_visibility(struct test_context *ctx)
74{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000075 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020076
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000077 iassert(lyt->surface_set_visibility(NULL, true) == IVI_FAILED);
Pekka Paalanen46804ca2015-03-27 11:55:21 +020078
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000079 lyt->commit_changes();
Pekka Paalanen46804ca2015-03-27 11:55:21 +020080}
81
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090082static void
83test_surface_bad_destination_rectangle(struct test_context *ctx)
84{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000085 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090086
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000087 iassert(lyt->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090088}
89
90static void
91test_surface_bad_orientation(struct test_context *ctx)
92{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000093 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090094
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000095 iassert(lyt->surface_set_orientation(NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090096}
97
98static void
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090099test_surface_bad_source_rectangle(struct test_context *ctx)
100{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000101 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900102
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000103 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900104}
105
106static void
107test_surface_bad_properties(struct test_context *ctx)
108{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000109 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900110
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000111 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900112}
113
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900114static void
115test_layer_create(struct test_context *ctx)
116{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000117 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900118 uint32_t id1;
119 uint32_t id2;
120 struct ivi_layout_layer *ivilayer;
121 struct ivi_layout_layer *new_ivilayer;
122
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000123 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900124 iassert(ivilayer != NULL);
125
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000126 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900127
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000128 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900129 iassert(ivilayer == new_ivilayer);
130
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000131 id1 = lyt->get_id_of_layer(ivilayer);
132 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900133 iassert(id1 == id2);
134
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000135 lyt->layer_destroy(ivilayer);
136 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900137}
138
139static void
140test_layer_visibility(struct test_context *ctx)
141{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000142 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900143 struct ivi_layout_layer *ivilayer;
144 const struct ivi_layout_layer_properties *prop;
145
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000146 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900147 iassert(ivilayer != NULL);
148
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000149 prop = lyt->get_properties_of_layer(ivilayer);
150
151 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900152
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000153 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900154
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000155 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900156
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000157 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900158
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900159 iassert(prop->visibility == true);
160
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000161 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900162}
163
164static void
165test_layer_opacity(struct test_context *ctx)
166{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000167 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900168 struct ivi_layout_layer *ivilayer;
169 const struct ivi_layout_layer_properties *prop;
170
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000171 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900172 iassert(ivilayer != NULL);
173
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000174 prop = lyt->get_properties_of_layer(ivilayer);
175 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900176
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000177 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900178 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
179
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000180 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900181
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000182 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900184 iassert(prop->opacity == wl_fixed_from_double(0.5));
185
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000186 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900187}
188
189static void
190test_layer_orientation(struct test_context *ctx)
191{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000192 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900193 struct ivi_layout_layer *ivilayer;
194 const struct ivi_layout_layer_properties *prop;
195
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000196 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900197 iassert(ivilayer != NULL);
198
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000199 prop = lyt->get_properties_of_layer(ivilayer);
200 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900201
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000202 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900203 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
204
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000205 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900206
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000207 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900209 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
210
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000211 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900212}
213
214static void
215test_layer_dimension(struct test_context *ctx)
216{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000217 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900218 struct ivi_layout_layer *ivilayer;
219 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900220
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000221 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900222 iassert(ivilayer != NULL);
223
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000224 prop = lyt->get_properties_of_layer(ivilayer);
225 iassert(prop->dest_width == 200);
226 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900227
Ucan, Emre \(ADITG/SW1\)16d1fa12016-03-04 12:50:52 +0000228 iassert(lyt->layer_set_destination_rectangle(ivilayer, prop->dest_x, prop->dest_y,
229 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900230
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000231 iassert(prop->dest_width == 200);
232 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900233
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000234 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900235
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900236 iassert(prop->dest_width == 400);
237 iassert(prop->dest_height == 600);
238
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000239 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900240}
241
242static void
243test_layer_position(struct test_context *ctx)
244{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000245 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900246 struct ivi_layout_layer *ivilayer;
247 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900248
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000249 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900250 iassert(ivilayer != NULL);
251
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000252 prop = lyt->get_properties_of_layer(ivilayer);
253 iassert(prop->dest_x == 0);
254 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900255
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +0000256 iassert(lyt->layer_set_destination_rectangle(ivilayer, 20, 30,
257 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900258
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000259 iassert(prop->dest_x == 0);
260 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900261
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000262 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900263
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000264 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900265 iassert(prop->dest_x == 20);
266 iassert(prop->dest_y == 30);
267
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000268 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900269}
270
271static void
272test_layer_destination_rectangle(struct test_context *ctx)
273{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000274 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900275 struct ivi_layout_layer *ivilayer;
276 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900277
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000278 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900279 iassert(ivilayer != NULL);
280
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000281 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900282 iassert(prop->dest_width == 200);
283 iassert(prop->dest_height == 300);
284 iassert(prop->dest_x == 0);
285 iassert(prop->dest_y == 0);
286
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000287 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900288 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
289
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000290 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291 iassert(prop->dest_width == 200);
292 iassert(prop->dest_height == 300);
293 iassert(prop->dest_x == 0);
294 iassert(prop->dest_y == 0);
295
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000296 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900297
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900298 iassert(prop->dest_width == 400);
299 iassert(prop->dest_height == 600);
300 iassert(prop->dest_x == 20);
301 iassert(prop->dest_y == 30);
302
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000303 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900304}
305
306static void
307test_layer_source_rectangle(struct test_context *ctx)
308{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000309 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900310 struct ivi_layout_layer *ivilayer;
311 const struct ivi_layout_layer_properties *prop;
312
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000313 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900314 iassert(ivilayer != NULL);
315
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000316 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900317 iassert(prop->source_width == 200);
318 iassert(prop->source_height == 300);
319 iassert(prop->source_x == 0);
320 iassert(prop->source_y == 0);
321
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000322 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900323 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
324
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000325 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900326 iassert(prop->source_width == 200);
327 iassert(prop->source_height == 300);
328 iassert(prop->source_x == 0);
329 iassert(prop->source_y == 0);
330
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000331 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900332
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000333 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900334 iassert(prop->source_width == 400);
335 iassert(prop->source_height == 600);
336 iassert(prop->source_x == 20);
337 iassert(prop->source_y == 30);
338
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000339 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900340}
341
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900342static void
343test_layer_bad_remove(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;
346 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900347}
348
349static void
350test_layer_bad_visibility(struct test_context *ctx)
351{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000352 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900353
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000354 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900355
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000356 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900357}
358
359static void
360test_layer_bad_opacity(struct test_context *ctx)
361{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000362 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900363 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000364 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900365
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000366 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900367 iassert(ivilayer != NULL);
368
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900370 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
371
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000372 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900373 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
374
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000375 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900376 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
377
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000378 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900379
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000380 prop = lyt->get_properties_of_layer(ivilayer);
381 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 ivilayer, wl_fixed_from_double(1.1)) == 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\)c3aee1f2016-03-04 12:50:16 +0000388 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900389
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000390 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900391 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
392
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000393 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900394
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000395 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900396}
397
398static void
399test_layer_bad_destination_rectangle(struct test_context *ctx)
400{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000401 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900402
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000403 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900404 NULL, 20, 30, 200, 300) == IVI_FAILED);
405}
406
407static void
408test_layer_bad_orientation(struct test_context *ctx)
409{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000410 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900411
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000412 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900413 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
414
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000415 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900416}
417
418static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900419test_layer_bad_source_rectangle(struct test_context *ctx)
420{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000421 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900422
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000423 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900424 NULL, 20, 30, 200, 300) == IVI_FAILED);
425}
426
427static void
428test_layer_bad_properties(struct test_context *ctx)
429{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000430 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900431
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000432 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900433}
434
435static void
436test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
437{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000438 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900439 struct ivi_layout_layer *ivilayer;
440
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000441 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900442 iassert(ivilayer != NULL);
443
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000444 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
445 lyt->layer_destroy(ivilayer);
446 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447}
448
449static void
450test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
451{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000452 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900453 struct ivi_layout_layer *ivilayer;
454
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000455 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900456 iassert(ivilayer != NULL);
457
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000458 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900459 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000460 lyt->layer_destroy(ivilayer);
461 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900462}
463
464static void
465test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
466{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000467 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900468 struct ivi_layout_layer *ivilayer;
469
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000470 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900471 iassert(ivilayer != NULL);
472
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000473 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900474 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 lyt->layer_destroy(ivilayer);
476 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900477}
478
479static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900480test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
481{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000482 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900483 struct ivi_layout_layer *ivilayer;
484
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000485 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900486 iassert(ivilayer != NULL);
487
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000488 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900489 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 lyt->layer_destroy(ivilayer);
491 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900492}
493
494static void
495test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
496{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000497 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900498 struct ivi_layout_layer *ivilayer;
499
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900501 iassert(ivilayer != NULL);
502
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000503 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900504 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000505 lyt->layer_destroy(ivilayer);
506 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900507}
508
509static void
510test_layer_create_duplicate(struct test_context *ctx)
511{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000512 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900513 struct ivi_layout_layer *ivilayer;
514 struct ivi_layout_layer *duplicatelayer;
515
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000516 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900517 iassert(ivilayer != NULL);
518
519 if (ivilayer != NULL)
520 iassert(ivilayer->ref_count == 1);
521
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000522 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900523 iassert(ivilayer == duplicatelayer);
524
525 if (ivilayer != NULL)
526 iassert(ivilayer->ref_count == 2);
527
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000528 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900529
530 if (ivilayer != NULL)
531 iassert(ivilayer->ref_count == 1);
532
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000533 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900534}
535
536static void
537test_get_layer_after_destory_layer(struct test_context *ctx)
538{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900540 struct ivi_layout_layer *ivilayer;
541
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000542 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900543 iassert(ivilayer != NULL);
544
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000545 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900546
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000547 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900548 iassert(ivilayer == NULL);
549}
550
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900551static void
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900552test_screen_render_order(struct test_context *ctx)
553{
554#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000555 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000556 struct weston_output *output;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900557 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
558 struct ivi_layout_layer **array;
559 int32_t length = 0;
560 uint32_t i;
561
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000562 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900563 return;
564
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000565 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900566
567 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000568 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900569
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000570 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900571
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000572 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900573
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000574 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900575 iassert(length == LAYER_NUM);
576 for (i = 0; i < LAYER_NUM; i++)
577 iassert(array[i] == ivilayers[i]);
578
579 if (length > 0)
580 free(array);
581
582 array = NULL;
583
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000584 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900585
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000586 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900587
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000588 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900589 iassert(length == 0 && array == NULL);
590
591 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000592 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900593
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900594#undef LAYER_NUM
595}
596
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900597static void
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900598test_screen_bad_render_order(struct test_context *ctx)
599{
600#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000601 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000602 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900603 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
604 struct ivi_layout_layer **array;
605 int32_t length = 0;
606 uint32_t i;
607
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000608 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900609 return;
610
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000611 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900612
613 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000614 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900615
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000616 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900617
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000618 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900619
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000620 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000621 iassert(lyt->get_layers_on_screen(output, NULL, &array) == IVI_FAILED);
622 iassert(lyt->get_layers_on_screen(output, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900623
624 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000625 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900626
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900627#undef LAYER_NUM
628}
629
630static void
631test_commit_changes_after_render_order_set_layer_destroy(
632 struct test_context *ctx)
633{
634#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000635 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000636 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900637 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
638 uint32_t i;
639
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000640 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900641 return;
642
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000643 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900644
645 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900647
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000648 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900649
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000650 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900651
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000652 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900653
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000654 lyt->layer_destroy(ivilayers[0]);
655 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900656#undef LAYER_NUM
657}
658
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900659static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000660test_layer_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900661{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000662 struct test_context *ctx =
663 container_of(listener, struct test_context,
664 layer_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000665 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000666 struct ivi_layout_layer *ivilayer = data;
667 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900668
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000669 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900670 iassert(prop->source_width == 200);
671 iassert(prop->source_height == 300);
672
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000673 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900674 prop->source_width == 200 && prop->source_height == 300)
675 ctx->user_flags = 1;
676}
677
678static void
679test_layer_properties_changed_notification(struct test_context *ctx)
680{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000681 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900682 struct ivi_layout_layer *ivilayer;
683
684 ctx->user_flags = 0;
685
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000686 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900687
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000688 ctx->layer_property_changed.notify = test_layer_properties_changed_notification_callback;
689
690 iassert(lyt->layer_add_listener(ivilayer, &ctx->layer_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900691
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000692 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900693
694 iassert(ctx->user_flags == 0);
695
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000696 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900697 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
698
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000699 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900700
701 iassert(ctx->user_flags == 1);
702
703 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000704 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900705 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
706
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000707 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900708
709 iassert(ctx->user_flags == 0);
710
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000711 // remove layer property changed listener.
712 wl_list_remove(&ctx->layer_property_changed.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900713
714 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000715 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900716
717 iassert(ctx->user_flags == 0);
718
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000719 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900720}
721
722static void
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000723test_layer_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900724{
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000725 struct test_context *ctx =
726 container_of(listener, struct test_context,
727 layer_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000728 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000729 struct ivi_layout_layer *ivilayer = data;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000730 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900731
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000732 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900733 iassert(prop->source_width == 200);
734 iassert(prop->source_height == 300);
735
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000736 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900737 prop->source_width == 200 && prop->source_height == 300)
738 ctx->user_flags = 1;
739}
740
741static void
742test_layer_create_notification(struct test_context *ctx)
743{
744#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000745 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900746 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
747 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
748
749 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000750 ctx->layer_created.notify = test_layer_create_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900751
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000752 iassert(lyt->add_listener_create_layer(&ctx->layer_created) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000753 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900754
755 iassert(ctx->user_flags == 1);
756
757 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000758 // remove layer created listener.
759 wl_list_remove(&ctx->layer_created.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900760
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000761 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
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(ivilayers[0]);
766 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900767#undef LAYER_NUM
768}
769
770static void
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000771test_layer_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900772{
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000773 struct test_context *ctx =
774 container_of(listener, struct test_context,
775 layer_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000776 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000777 struct ivi_layout_layer *ivilayer = data;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900778 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000779 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900780
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000781 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900782 iassert(prop->source_width == 200);
783 iassert(prop->source_height == 300);
784
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000785 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900786 prop->source_width == 200 && prop->source_height == 300)
787 ctx->user_flags = 1;
788}
789
790static void
791test_layer_remove_notification(struct test_context *ctx)
792{
793#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000794 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900795 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
796 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
797
798 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000799 ctx->layer_removed.notify = test_layer_remove_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900800
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000801 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000802 iassert(lyt->add_listener_remove_layer(&ctx->layer_removed) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000803 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900804
805 iassert(ctx->user_flags == 1);
806
807 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000808 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000809
810 // remove layer property changed listener.
811 wl_list_remove(&ctx->layer_removed.link);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000812 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900813
814 iassert(ctx->user_flags == 0);
815#undef LAYER_NUM
816}
817
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900818static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000819test_layer_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900820{
821}
822
823static void
824test_layer_bad_properties_changed_notification(struct test_context *ctx)
825{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000826 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900827 struct ivi_layout_layer *ivilayer;
828
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000829 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900830
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000831 ctx->layer_property_changed.notify = test_layer_bad_properties_changed_notification_callback;
832
833 iassert(lyt->layer_add_listener(NULL, &ctx->layer_property_changed) == IVI_FAILED);
834 iassert(lyt->layer_add_listener(ivilayer, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900835
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000836 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900837}
838
839static void
840test_surface_bad_configure_notification(struct test_context *ctx)
841{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000842 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900843
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000844 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900845}
846
847static void
848test_layer_bad_create_notification(struct test_context *ctx)
849{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000850 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900851
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000852 iassert(lyt->add_listener_create_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900853}
854
855static void
856test_surface_bad_create_notification(struct test_context *ctx)
857{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000858 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900859
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000860 iassert(lyt->add_listener_create_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900861}
862
863static void
864test_layer_bad_remove_notification(struct test_context *ctx)
865{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000866 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900867
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000868 iassert(lyt->add_listener_remove_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900869}
870
871static void
872test_surface_bad_remove_notification(struct test_context *ctx)
873{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000874 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900875
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000876 iassert(lyt->add_listener_remove_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900877}
878
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200879/************************ tests end ********************************/
880
881static void
882run_internal_tests(void *data)
883{
884 struct test_context *ctx = data;
885
886 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900887 test_surface_bad_destination_rectangle(ctx);
888 test_surface_bad_orientation(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900889 test_surface_bad_source_rectangle(ctx);
890 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200891
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900892 test_layer_create(ctx);
893 test_layer_visibility(ctx);
894 test_layer_opacity(ctx);
895 test_layer_orientation(ctx);
896 test_layer_dimension(ctx);
897 test_layer_position(ctx);
898 test_layer_destination_rectangle(ctx);
899 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900900 test_layer_bad_remove(ctx);
901 test_layer_bad_visibility(ctx);
902 test_layer_bad_opacity(ctx);
903 test_layer_bad_destination_rectangle(ctx);
904 test_layer_bad_orientation(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900905 test_layer_bad_source_rectangle(ctx);
906 test_layer_bad_properties(ctx);
907 test_commit_changes_after_visibility_set_layer_destroy(ctx);
908 test_commit_changes_after_opacity_set_layer_destroy(ctx);
909 test_commit_changes_after_orientation_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900910 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
911 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
912 test_layer_create_duplicate(ctx);
913 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900914
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900915 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900916 test_screen_bad_render_order(ctx);
917 test_commit_changes_after_render_order_set_layer_destroy(ctx);
918
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900919 test_layer_properties_changed_notification(ctx);
920 test_layer_create_notification(ctx);
921 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900922 test_layer_bad_properties_changed_notification(ctx);
923 test_surface_bad_configure_notification(ctx);
924 test_layer_bad_create_notification(ctx);
925 test_surface_bad_create_notification(ctx);
926 test_layer_bad_remove_notification(ctx);
927 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900928
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200929 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
930 free(ctx);
931}
932
933int
934controller_module_init(struct weston_compositor *compositor,
935 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000936 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200937 size_t iface_version);
938
939WL_EXPORT int
940controller_module_init(struct weston_compositor *compositor,
941 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000942 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200943 size_t iface_version)
944{
945 struct wl_event_loop *loop;
946 struct test_context *ctx;
947
948 /* strict check, since this is an internal test module */
949 if (iface_version != sizeof(*iface)) {
950 weston_log("fatal: controller interface mismatch\n");
951 return -1;
952 }
953
954 ctx = zalloc(sizeof(*ctx));
955 if (!ctx)
956 return -1;
957
958 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000959 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200960
961 loop = wl_display_get_event_loop(compositor->wl_display);
962 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
963
964 return 0;
965}