blob: 9596a4050fd80ac9b75224559c9b3cfef7ece015 [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"
Pekka Paalanen46804ca2015-03-27 11:55:21 +020038
39struct test_context {
40 struct weston_compositor *compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000041 const struct ivi_layout_interface *layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +090042 uint32_t user_flags;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020043};
44
45static void
46iassert_fail(const char *cond, const char *file, int line,
47 const char *func, struct test_context *ctx)
48{
49 weston_log("Assert failure in %s:%d, %s: '%s'\n",
50 file, line, func, cond);
51 weston_compositor_exit_with_code(ctx->compositor, EXIT_FAILURE);
52}
53
54#define iassert(cond) ({ \
55 bool b_ = (cond); \
56 if (!b_) \
57 iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx); \
58 b_; \
59})
60
61/************************ tests begin ******************************/
62
63/*
64 * These are all internal ivi_layout API tests that do not require
65 * any client objects.
66 */
Pekka Paalanen46804ca2015-03-27 11:55:21 +020067static void
68test_surface_bad_visibility(struct test_context *ctx)
69{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000070 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020071
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000072 iassert(lyt->surface_set_visibility(NULL, true) == IVI_FAILED);
Pekka Paalanen46804ca2015-03-27 11:55:21 +020073
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000074 lyt->commit_changes();
Pekka Paalanen46804ca2015-03-27 11:55:21 +020075}
76
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090077static void
78test_surface_bad_destination_rectangle(struct test_context *ctx)
79{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000080 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090081
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000082 iassert(lyt->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090083}
84
85static void
86test_surface_bad_orientation(struct test_context *ctx)
87{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000088 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090089
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000090 iassert(lyt->surface_set_orientation(NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090091}
92
93static void
94test_surface_bad_dimension(struct test_context *ctx)
95{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000096 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090097
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000098 iassert(lyt->surface_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090099
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000100 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900101}
102
103static void
104test_surface_bad_position(struct test_context *ctx)
105{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000106 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900107
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000108 iassert(lyt->surface_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900109
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000110 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900111}
112
113static void
114test_surface_bad_source_rectangle(struct test_context *ctx)
115{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000116 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900117
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000118 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900119}
120
121static void
122test_surface_bad_properties(struct test_context *ctx)
123{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000124 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900125
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000126 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900127}
128
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900129static void
130test_layer_create(struct test_context *ctx)
131{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000132 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900133 uint32_t id1;
134 uint32_t id2;
135 struct ivi_layout_layer *ivilayer;
136 struct ivi_layout_layer *new_ivilayer;
137
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000138 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900139 iassert(ivilayer != NULL);
140
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000141 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900142
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000143 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900144 iassert(ivilayer == new_ivilayer);
145
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000146 id1 = lyt->get_id_of_layer(ivilayer);
147 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900148 iassert(id1 == id2);
149
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000150 lyt->layer_destroy(ivilayer);
151 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900152}
153
154static void
155test_layer_visibility(struct test_context *ctx)
156{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000157 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900158 struct ivi_layout_layer *ivilayer;
159 const struct ivi_layout_layer_properties *prop;
160
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000161 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900162 iassert(ivilayer != NULL);
163
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000164 prop = lyt->get_properties_of_layer(ivilayer);
165
166 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900167
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000168 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900169
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000170 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900171
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000172 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900173
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900174 iassert(prop->visibility == true);
175
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000176 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900177}
178
179static void
180test_layer_opacity(struct test_context *ctx)
181{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000182 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183 struct ivi_layout_layer *ivilayer;
184 const struct ivi_layout_layer_properties *prop;
185
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000186 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900187 iassert(ivilayer != NULL);
188
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000189 prop = lyt->get_properties_of_layer(ivilayer);
190 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900191
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000192 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900193 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
194
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000195 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900196
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000197 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900199 iassert(prop->opacity == wl_fixed_from_double(0.5));
200
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000201 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900202}
203
204static void
205test_layer_orientation(struct test_context *ctx)
206{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000207 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208 struct ivi_layout_layer *ivilayer;
209 const struct ivi_layout_layer_properties *prop;
210
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000211 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900212 iassert(ivilayer != NULL);
213
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000214 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900215
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900217 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
218
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000219 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900220
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000221 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900222
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000223 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900224
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000225 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900226 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
227
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000228 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900229}
230
231static void
232test_layer_dimension(struct test_context *ctx)
233{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000234 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900235 struct ivi_layout_layer *ivilayer;
236 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900237
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000238 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900239 iassert(ivilayer != NULL);
240
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000241 prop = lyt->get_properties_of_layer(ivilayer);
242 iassert(prop->dest_width == 200);
243 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900244
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000245 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900246
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000247 iassert(prop->dest_width == 200);
248 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900249
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000250 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900251
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900252 iassert(prop->dest_width == 400);
253 iassert(prop->dest_height == 600);
254
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000255 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900256}
257
258static void
259test_layer_position(struct test_context *ctx)
260{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000261 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900262 struct ivi_layout_layer *ivilayer;
263 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900264
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000265 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900266 iassert(ivilayer != NULL);
267
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000268 prop = lyt->get_properties_of_layer(ivilayer);
269 iassert(prop->dest_x == 0);
270 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900271
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000272 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900273
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000274 iassert(prop->dest_x == 0);
275 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900276
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000277 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900278
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000279 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900280 iassert(prop->dest_x == 20);
281 iassert(prop->dest_y == 30);
282
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000283 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900284}
285
286static void
287test_layer_destination_rectangle(struct test_context *ctx)
288{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000289 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900290 struct ivi_layout_layer *ivilayer;
291 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900292
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000293 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900294 iassert(ivilayer != NULL);
295
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000296 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900297 iassert(prop->dest_width == 200);
298 iassert(prop->dest_height == 300);
299 iassert(prop->dest_x == 0);
300 iassert(prop->dest_y == 0);
301
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000302 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900303 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
304
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000305 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900306 iassert(prop->dest_width == 200);
307 iassert(prop->dest_height == 300);
308 iassert(prop->dest_x == 0);
309 iassert(prop->dest_y == 0);
310
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000311 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900312
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900313 iassert(prop->dest_width == 400);
314 iassert(prop->dest_height == 600);
315 iassert(prop->dest_x == 20);
316 iassert(prop->dest_y == 30);
317
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000318 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900319}
320
321static void
322test_layer_source_rectangle(struct test_context *ctx)
323{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000324 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900325 struct ivi_layout_layer *ivilayer;
326 const struct ivi_layout_layer_properties *prop;
327
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000328 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900329 iassert(ivilayer != NULL);
330
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000331 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900332 iassert(prop->source_width == 200);
333 iassert(prop->source_height == 300);
334 iassert(prop->source_x == 0);
335 iassert(prop->source_y == 0);
336
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000337 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900338 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
339
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000340 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900341 iassert(prop->source_width == 200);
342 iassert(prop->source_height == 300);
343 iassert(prop->source_x == 0);
344 iassert(prop->source_y == 0);
345
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900347
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000348 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900349 iassert(prop->source_width == 400);
350 iassert(prop->source_height == 600);
351 iassert(prop->source_x == 20);
352 iassert(prop->source_y == 30);
353
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000354 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900355}
356
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900357static void
358test_layer_bad_remove(struct test_context *ctx)
359{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000360 const struct ivi_layout_interface *lyt = ctx->layout_interface;
361 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900362}
363
364static void
365test_layer_bad_visibility(struct test_context *ctx)
366{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000367 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900368
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900370
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000371 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900372}
373
374static void
375test_layer_bad_opacity(struct test_context *ctx)
376{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000377 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900378 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000379 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900380
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000381 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900382 iassert(ivilayer != NULL);
383
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000384 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900385 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
386
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000387 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900388 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
389
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000390 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900391 ivilayer, wl_fixed_from_double(-1)) == 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\)c3aee1f2016-03-04 12:50:16 +0000395 prop = lyt->get_properties_of_layer(ivilayer);
396 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900397
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000398 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900399 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
400
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000401 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900402
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000403 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900404
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000405 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900406 NULL, wl_fixed_from_double(0.5)) == 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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000410 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900411}
412
413static void
414test_layer_bad_destination_rectangle(struct test_context *ctx)
415{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000418 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900419 NULL, 20, 30, 200, 300) == IVI_FAILED);
420}
421
422static void
423test_layer_bad_orientation(struct test_context *ctx)
424{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900426
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000427 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900428 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
429
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000430 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900431
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000432 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900433}
434
435static void
436test_layer_bad_dimension(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;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900440
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_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900445
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000448 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900449}
450
451static void
452test_layer_bad_position(struct test_context *ctx)
453{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000454 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900455 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900456
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000457 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900458 iassert(ivilayer != NULL);
459
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000460 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900461
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000462 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900463
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000464 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900465}
466
467static void
468test_layer_bad_source_rectangle(struct test_context *ctx)
469{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000470 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900471
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000472 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900473 NULL, 20, 30, 200, 300) == IVI_FAILED);
474}
475
476static void
477test_layer_bad_properties(struct test_context *ctx)
478{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000479 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900480
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000481 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900482}
483
484static void
485test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
486{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000487 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900488 struct ivi_layout_layer *ivilayer;
489
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900491 iassert(ivilayer != NULL);
492
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000493 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
494 lyt->layer_destroy(ivilayer);
495 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900496}
497
498static void
499test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
500{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000501 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900502 struct ivi_layout_layer *ivilayer;
503
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000504 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900505 iassert(ivilayer != NULL);
506
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000507 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900508 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 lyt->layer_destroy(ivilayer);
510 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900511}
512
513static void
514test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
515{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000516 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900517 struct ivi_layout_layer *ivilayer;
518
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000519 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900520 iassert(ivilayer != NULL);
521
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000522 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900523 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000524 lyt->layer_destroy(ivilayer);
525 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900526}
527
528static void
529test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
530{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000531 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900532 struct ivi_layout_layer *ivilayer;
533
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000534 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900535 iassert(ivilayer != NULL);
536
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000537 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
538 lyt->layer_destroy(ivilayer);
539 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900540}
541
542static void
543test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
544{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000545 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900546 struct ivi_layout_layer *ivilayer;
547
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000548 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900549 iassert(ivilayer != NULL);
550
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000551 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
552 lyt->layer_destroy(ivilayer);
553 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900554}
555
556static void
557test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
558{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000559 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900560 struct ivi_layout_layer *ivilayer;
561
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000562 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900563 iassert(ivilayer != NULL);
564
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000565 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900566 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000567 lyt->layer_destroy(ivilayer);
568 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900569}
570
571static void
572test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
573{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000574 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900575 struct ivi_layout_layer *ivilayer;
576
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000577 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900578 iassert(ivilayer != NULL);
579
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000580 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900581 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000582 lyt->layer_destroy(ivilayer);
583 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900584}
585
586static void
587test_layer_create_duplicate(struct test_context *ctx)
588{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000589 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900590 struct ivi_layout_layer *ivilayer;
591 struct ivi_layout_layer *duplicatelayer;
592
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000593 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900594 iassert(ivilayer != NULL);
595
596 if (ivilayer != NULL)
597 iassert(ivilayer->ref_count == 1);
598
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000599 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900600 iassert(ivilayer == duplicatelayer);
601
602 if (ivilayer != NULL)
603 iassert(ivilayer->ref_count == 2);
604
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000605 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900606
607 if (ivilayer != NULL)
608 iassert(ivilayer->ref_count == 1);
609
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000610 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900611}
612
613static void
614test_get_layer_after_destory_layer(struct test_context *ctx)
615{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000616 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900617 struct ivi_layout_layer *ivilayer;
618
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000619 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900620 iassert(ivilayer != NULL);
621
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000622 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900623
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000624 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900625 iassert(ivilayer == NULL);
626}
627
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900628static void
629test_screen_id(struct test_context *ctx)
630{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000631 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900632 struct ivi_layout_screen **iviscrns;
633 int32_t screen_length = 0;
634 uint32_t id_screen;
635 int32_t i;
636
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000637 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900638 iassert(screen_length > 0);
639
640 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000641 id_screen = lyt->get_id_of_screen(iviscrns[i]);
642 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900643 }
644
645 if (screen_length > 0)
646 free(iviscrns);
647}
648
649static void
650test_screen_resolution(struct test_context *ctx)
651{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000652 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900653 struct ivi_layout_screen **iviscrns;
654 int32_t screen_length = 0;
655 struct weston_output *output;
656 int32_t width;
657 int32_t height;
658 int32_t i;
659
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000660 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900661 iassert(screen_length > 0);
662
663 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000664 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900665 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000666 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900667 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
668 iassert(width == output->current_mode->width);
669 iassert(height == output->current_mode->height);
670 }
671
672 if (screen_length > 0)
673 free(iviscrns);
674}
675
676static void
677test_screen_render_order(struct test_context *ctx)
678{
679#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000680 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900681 struct ivi_layout_screen **iviscrns;
682 int32_t screen_length = 0;
683 struct ivi_layout_screen *iviscrn;
684 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
685 struct ivi_layout_layer **array;
686 int32_t length = 0;
687 uint32_t i;
688
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000689 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900690 iassert(screen_length > 0);
691
692 if (screen_length <= 0)
693 return;
694
695 iviscrn = iviscrns[0];
696
697 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000698 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900699
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900701
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000702 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900703
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000704 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900705 iassert(length == LAYER_NUM);
706 for (i = 0; i < LAYER_NUM; i++)
707 iassert(array[i] == ivilayers[i]);
708
709 if (length > 0)
710 free(array);
711
712 array = NULL;
713
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000714 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900715
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000716 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900717
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000718 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900719 iassert(length == 0 && array == NULL);
720
721 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000722 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900723
724 free(iviscrns);
725#undef LAYER_NUM
726}
727
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900728static void
729test_screen_bad_resolution(struct test_context *ctx)
730{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000731 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900732 struct ivi_layout_screen **iviscrns;
733 int32_t screen_length = 0;
734 struct ivi_layout_screen *iviscrn;
735 int32_t width;
736 int32_t height;
737
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000738 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900739 iassert(screen_length > 0);
740
741 if (screen_length <= 0)
742 return;
743
744 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000745 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
746 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
747 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900748 free(iviscrns);
749}
750
751static void
752test_screen_bad_render_order(struct test_context *ctx)
753{
754#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000755 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900756 struct ivi_layout_screen **iviscrns;
757 int32_t screen_length;
758 struct ivi_layout_screen *iviscrn;
759 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
760 struct ivi_layout_layer **array;
761 int32_t length = 0;
762 uint32_t i;
763
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000764 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900765 iassert(screen_length > 0);
766
767 if (screen_length <= 0)
768 return;
769
770 iviscrn = iviscrns[0];
771
772 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000773 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900774
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000775 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900776
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000777 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900778
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000779 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
780 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
781 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900782
783 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000784 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900785
786 free(iviscrns);
787#undef LAYER_NUM
788}
789
790static void
791test_commit_changes_after_render_order_set_layer_destroy(
792 struct test_context *ctx)
793{
794#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000795 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900796 struct ivi_layout_screen **iviscrns;
797 int32_t screen_length;
798 struct ivi_layout_screen *iviscrn;
799 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
800 uint32_t i;
801
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000802 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900803 iassert(screen_length > 0);
804
805 if (screen_length <= 0)
806 return;
807
808 iviscrn = iviscrns[0];
809
810 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000811 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900812
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000813 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900814
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000815 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900816
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000817 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900818
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000819 lyt->layer_destroy(ivilayers[0]);
820 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900821
822 free(iviscrns);
823#undef LAYER_NUM
824}
825
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900826static void
827test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
828 const struct ivi_layout_layer_properties *prop,
829 enum ivi_layout_notification_mask mask,
830 void *userdata)
831{
832 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000833 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900834
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000835 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900836 iassert(prop->source_width == 200);
837 iassert(prop->source_height == 300);
838
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000839 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900840 prop->source_width == 200 && prop->source_height == 300)
841 ctx->user_flags = 1;
842}
843
844static void
845test_layer_properties_changed_notification(struct test_context *ctx)
846{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000847 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900848 struct ivi_layout_layer *ivilayer;
849
850 ctx->user_flags = 0;
851
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000852 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900853
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000854 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900855
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000856 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900857
858 iassert(ctx->user_flags == 0);
859
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000860 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900861 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
862
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000863 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900864
865 iassert(ctx->user_flags == 1);
866
867 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000868 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900869 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
870
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000871 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900872
873 iassert(ctx->user_flags == 0);
874
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000875 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900876
877 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000878 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900879
880 iassert(ctx->user_flags == 0);
881
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900883}
884
885static void
886test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
887 void *userdata)
888{
889 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000890 const struct ivi_layout_interface *lyt = ctx->layout_interface;
891 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900892
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000893 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900894 iassert(prop->source_width == 200);
895 iassert(prop->source_height == 300);
896
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000897 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900898 prop->source_width == 200 && prop->source_height == 300)
899 ctx->user_flags = 1;
900}
901
902static void
903test_layer_create_notification(struct test_context *ctx)
904{
905#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000906 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900907 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
908 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
909
910 ctx->user_flags = 0;
911
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000912 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900913 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000914 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900915
916 iassert(ctx->user_flags == 1);
917
918 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000919 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900920
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000921 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900922
923 iassert(ctx->user_flags == 0);
924
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000925 lyt->layer_destroy(ivilayers[0]);
926 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900927#undef LAYER_NUM
928}
929
930static void
931test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
932 void *userdata)
933{
934 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000935 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900936 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000937 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900938
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000939 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900940 iassert(prop->source_width == 200);
941 iassert(prop->source_height == 300);
942
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000943 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900944 prop->source_width == 200 && prop->source_height == 300)
945 ctx->user_flags = 1;
946}
947
948static void
949test_layer_remove_notification(struct test_context *ctx)
950{
951#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000952 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900953 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
954 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
955
956 ctx->user_flags = 0;
957
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000958 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
959 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900960 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000961 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900962
963 iassert(ctx->user_flags == 1);
964
965 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000966 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
967 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
968 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900969
970 iassert(ctx->user_flags == 0);
971#undef LAYER_NUM
972}
973
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900974static void
975test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
976 const struct ivi_layout_layer_properties *prop,
977 enum ivi_layout_notification_mask mask,
978 void *userdata)
979{
980}
981
982static void
983test_layer_bad_properties_changed_notification(struct test_context *ctx)
984{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000985 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900986 struct ivi_layout_layer *ivilayer;
987
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000988 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900989
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000990 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900991 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000992 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900993
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000994 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900995}
996
997static void
998test_surface_bad_configure_notification(struct test_context *ctx)
999{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001000 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001001
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001002 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001003}
1004
1005static void
1006test_layer_bad_create_notification(struct test_context *ctx)
1007{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001008 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001009
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001010 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001011}
1012
1013static void
1014test_surface_bad_create_notification(struct test_context *ctx)
1015{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001016 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001017
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001018 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001019}
1020
1021static void
1022test_layer_bad_remove_notification(struct test_context *ctx)
1023{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001024 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001025
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001026 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001027}
1028
1029static void
1030test_surface_bad_remove_notification(struct test_context *ctx)
1031{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001032 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001033
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001034 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001035}
1036
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001037/************************ tests end ********************************/
1038
1039static void
1040run_internal_tests(void *data)
1041{
1042 struct test_context *ctx = data;
1043
1044 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001045 test_surface_bad_destination_rectangle(ctx);
1046 test_surface_bad_orientation(ctx);
1047 test_surface_bad_dimension(ctx);
1048 test_surface_bad_position(ctx);
1049 test_surface_bad_source_rectangle(ctx);
1050 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001051
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001052 test_layer_create(ctx);
1053 test_layer_visibility(ctx);
1054 test_layer_opacity(ctx);
1055 test_layer_orientation(ctx);
1056 test_layer_dimension(ctx);
1057 test_layer_position(ctx);
1058 test_layer_destination_rectangle(ctx);
1059 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001060 test_layer_bad_remove(ctx);
1061 test_layer_bad_visibility(ctx);
1062 test_layer_bad_opacity(ctx);
1063 test_layer_bad_destination_rectangle(ctx);
1064 test_layer_bad_orientation(ctx);
1065 test_layer_bad_dimension(ctx);
1066 test_layer_bad_position(ctx);
1067 test_layer_bad_source_rectangle(ctx);
1068 test_layer_bad_properties(ctx);
1069 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1070 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1071 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1072 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1073 test_commit_changes_after_position_set_layer_destroy(ctx);
1074 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1075 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1076 test_layer_create_duplicate(ctx);
1077 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001078
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001079 test_screen_id(ctx);
1080 test_screen_resolution(ctx);
1081 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001082 test_screen_bad_resolution(ctx);
1083 test_screen_bad_render_order(ctx);
1084 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1085
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001086 test_layer_properties_changed_notification(ctx);
1087 test_layer_create_notification(ctx);
1088 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001089 test_layer_bad_properties_changed_notification(ctx);
1090 test_surface_bad_configure_notification(ctx);
1091 test_layer_bad_create_notification(ctx);
1092 test_surface_bad_create_notification(ctx);
1093 test_layer_bad_remove_notification(ctx);
1094 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001095
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001096 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1097 free(ctx);
1098}
1099
1100int
1101controller_module_init(struct weston_compositor *compositor,
1102 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001103 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001104 size_t iface_version);
1105
1106WL_EXPORT int
1107controller_module_init(struct weston_compositor *compositor,
1108 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001109 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001110 size_t iface_version)
1111{
1112 struct wl_event_loop *loop;
1113 struct test_context *ctx;
1114
1115 /* strict check, since this is an internal test module */
1116 if (iface_version != sizeof(*iface)) {
1117 weston_log("fatal: controller interface mismatch\n");
1118 return -1;
1119 }
1120
1121 ctx = zalloc(sizeof(*ctx));
1122 if (!ctx)
1123 return -1;
1124
1125 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001126 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001127
1128 loop = wl_display_get_event_loop(compositor->wl_display);
1129 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1130
1131 return 0;
1132}