blob: 78ac7de4664eec2cf80a9b94d7bf4f2d60502e3c [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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000092 iassert(lyt->surface_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090093}
94
95static void
96test_surface_bad_dimension(struct test_context *ctx)
97{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000098 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090099
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000100 iassert(lyt->surface_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900101
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000102 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900103}
104
105static void
106test_surface_bad_position(struct test_context *ctx)
107{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000108 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900109
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000110 iassert(lyt->surface_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900111
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000112 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900113}
114
115static void
116test_surface_bad_source_rectangle(struct test_context *ctx)
117{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000118 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900119
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000120 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900121}
122
123static void
124test_surface_bad_properties(struct test_context *ctx)
125{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000126 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900127
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000128 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900129}
130
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900131static void
132test_layer_create(struct test_context *ctx)
133{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000134 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900135 uint32_t id1;
136 uint32_t id2;
137 struct ivi_layout_layer *ivilayer;
138 struct ivi_layout_layer *new_ivilayer;
139
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000140 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900141 iassert(ivilayer != NULL);
142
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000143 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900144
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000145 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900146 iassert(ivilayer == new_ivilayer);
147
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000148 id1 = lyt->get_id_of_layer(ivilayer);
149 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900150 iassert(id1 == id2);
151
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000152 lyt->layer_destroy(ivilayer);
153 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900154}
155
156static void
157test_layer_visibility(struct test_context *ctx)
158{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000159 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900160 struct ivi_layout_layer *ivilayer;
161 const struct ivi_layout_layer_properties *prop;
162
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000163 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900164 iassert(ivilayer != NULL);
165
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000166 prop = lyt->get_properties_of_layer(ivilayer);
167
168 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900169
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000170 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900171
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000172 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900173
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000174 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900175
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900176 iassert(prop->visibility == true);
177
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000178 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900179}
180
181static void
182test_layer_opacity(struct test_context *ctx)
183{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000184 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900185 struct ivi_layout_layer *ivilayer;
186 const struct ivi_layout_layer_properties *prop;
187
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000188 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900189 iassert(ivilayer != NULL);
190
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000191 prop = lyt->get_properties_of_layer(ivilayer);
192 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900193
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000194 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900195 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
196
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000197 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000199 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900200
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900201 iassert(prop->opacity == wl_fixed_from_double(0.5));
202
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000203 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900204}
205
206static void
207test_layer_orientation(struct test_context *ctx)
208{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000209 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900210 struct ivi_layout_layer *ivilayer;
211 const struct ivi_layout_layer_properties *prop;
212
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000213 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900214 iassert(ivilayer != NULL);
215
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900217
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000218 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900219 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
220
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000221 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900222
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000223 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900224
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000225 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900226
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000227 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900228 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
229
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000230 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231}
232
233static void
234test_layer_dimension(struct test_context *ctx)
235{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000236 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900237 struct ivi_layout_layer *ivilayer;
238 const struct ivi_layout_layer_properties *prop;
239 int32_t dest_width;
240 int32_t dest_height;
241
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000242 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900243 iassert(ivilayer != NULL);
244
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000245 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900246 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
247 iassert(dest_width == 200);
248 iassert(dest_height == 300);
249
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000250 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900251
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000252 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900253 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
254 iassert(dest_width == 200);
255 iassert(dest_height == 300);
256
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000257 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900258
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000259 iassert(IVI_SUCCEEDED == lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900260 ivilayer, &dest_width, &dest_height));
261 iassert(dest_width == 400);
262 iassert(dest_height == 600);
263
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_width == 400);
266 iassert(prop->dest_height == 600);
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_position(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\)dfc2d762016-03-04 12:50:24 +0000281 prop = lyt->get_properties_of_layer(ivilayer);
282 iassert(prop->dest_x == 0);
283 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900284
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000285 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900286
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000287 iassert(prop->dest_x == 0);
288 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900289
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000290 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000292 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900293 iassert(prop->dest_x == 20);
294 iassert(prop->dest_y == 30);
295
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000296 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900297}
298
299static void
300test_layer_destination_rectangle(struct test_context *ctx)
301{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000302 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900303 struct ivi_layout_layer *ivilayer;
304 const struct ivi_layout_layer_properties *prop;
305 int32_t dest_width;
306 int32_t dest_height;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900307
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000308 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900309 iassert(ivilayer != NULL);
310
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000311 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900312 iassert(prop->dest_width == 200);
313 iassert(prop->dest_height == 300);
314 iassert(prop->dest_x == 0);
315 iassert(prop->dest_y == 0);
316
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000317 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900318 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
319
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000320 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900321 iassert(prop->dest_width == 200);
322 iassert(prop->dest_height == 300);
323 iassert(prop->dest_x == 0);
324 iassert(prop->dest_y == 0);
325
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000326 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900327
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000328 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900329 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
330 iassert(dest_width == 400);
331 iassert(dest_height == 600);
332
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->dest_width == 400);
335 iassert(prop->dest_height == 600);
336 iassert(prop->dest_x == 20);
337 iassert(prop->dest_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
342static void
343test_layer_source_rectangle(struct test_context *ctx)
344{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000345 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900346 struct ivi_layout_layer *ivilayer;
347 const struct ivi_layout_layer_properties *prop;
348
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000349 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900350 iassert(ivilayer != NULL);
351
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000352 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900353 iassert(prop->source_width == 200);
354 iassert(prop->source_height == 300);
355 iassert(prop->source_x == 0);
356 iassert(prop->source_y == 0);
357
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000358 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900359 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
360
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000361 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900362 iassert(prop->source_width == 200);
363 iassert(prop->source_height == 300);
364 iassert(prop->source_x == 0);
365 iassert(prop->source_y == 0);
366
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000367 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900368
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900370 iassert(prop->source_width == 400);
371 iassert(prop->source_height == 600);
372 iassert(prop->source_x == 20);
373 iassert(prop->source_y == 30);
374
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000375 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900376}
377
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900378static void
379test_layer_bad_remove(struct test_context *ctx)
380{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000381 const struct ivi_layout_interface *lyt = ctx->layout_interface;
382 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900383}
384
385static void
386test_layer_bad_visibility(struct test_context *ctx)
387{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000388 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900389
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000390 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900391
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000392 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900393}
394
395static void
396test_layer_bad_opacity(struct test_context *ctx)
397{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000398 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900399 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000400 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900401
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000402 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900403 iassert(ivilayer != NULL);
404
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.3)) == IVI_FAILED);
407
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000408 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900409 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
410
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000411 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900412 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
413
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000414 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900415
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000416 prop = lyt->get_properties_of_layer(ivilayer);
417 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900418
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000419 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900420 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
421
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000422 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900423
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000424 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900425
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000426 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900427 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
428
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000429 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900430
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000431 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900432}
433
434static void
435test_layer_bad_destination_rectangle(struct test_context *ctx)
436{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000437 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900438
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000439 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900440 NULL, 20, 30, 200, 300) == IVI_FAILED);
441}
442
443static void
444test_layer_bad_orientation(struct test_context *ctx)
445{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000448 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900449 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
450
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000451 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900452
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454}
455
456static void
457test_layer_bad_dimension(struct test_context *ctx)
458{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000459 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900460 struct ivi_layout_layer *ivilayer;
461 int32_t dest_width;
462 int32_t dest_height;
463
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000464 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900465 iassert(ivilayer != NULL);
466
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000467 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900468
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000469 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900470
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000471 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900472 NULL, &dest_width, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000473 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900474 ivilayer, NULL, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900476 ivilayer, &dest_width, NULL) == IVI_FAILED);
477
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000478 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900479}
480
481static void
482test_layer_bad_position(struct test_context *ctx)
483{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000484 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900485 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900486
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000487 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900488 iassert(ivilayer != NULL);
489
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900491
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000492 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900493
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000494 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900495}
496
497static void
498test_layer_bad_source_rectangle(struct test_context *ctx)
499{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900501
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000502 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900503 NULL, 20, 30, 200, 300) == IVI_FAILED);
504}
505
506static void
507test_layer_bad_properties(struct test_context *ctx)
508{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900510
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000511 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900512}
513
514static void
515test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
516{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000517 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900518 struct ivi_layout_layer *ivilayer;
519
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000520 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900521 iassert(ivilayer != NULL);
522
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000523 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
524 lyt->layer_destroy(ivilayer);
525 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900526}
527
528static void
529test_commit_changes_after_opacity_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_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900538 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 lyt->layer_destroy(ivilayer);
540 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900541}
542
543static void
544test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
545{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900547 struct ivi_layout_layer *ivilayer;
548
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000549 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900550 iassert(ivilayer != NULL);
551
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000552 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900553 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000554 lyt->layer_destroy(ivilayer);
555 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900556}
557
558static void
559test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
560{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000561 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900562 struct ivi_layout_layer *ivilayer;
563
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000564 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900565 iassert(ivilayer != NULL);
566
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000567 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
568 lyt->layer_destroy(ivilayer);
569 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900570}
571
572static void
573test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
574{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000575 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900576 struct ivi_layout_layer *ivilayer;
577
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000578 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900579 iassert(ivilayer != NULL);
580
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000581 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
582 lyt->layer_destroy(ivilayer);
583 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900584}
585
586static void
587test_commit_changes_after_source_rectangle_set_layer_destroy(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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000592 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900593 iassert(ivilayer != NULL);
594
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000595 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900596 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000597 lyt->layer_destroy(ivilayer);
598 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900599}
600
601static void
602test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
603{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000604 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900605 struct ivi_layout_layer *ivilayer;
606
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000607 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900608 iassert(ivilayer != NULL);
609
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000610 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900611 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000612 lyt->layer_destroy(ivilayer);
613 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900614}
615
616static void
617test_layer_create_duplicate(struct test_context *ctx)
618{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000619 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900620 struct ivi_layout_layer *ivilayer;
621 struct ivi_layout_layer *duplicatelayer;
622
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000623 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900624 iassert(ivilayer != NULL);
625
626 if (ivilayer != NULL)
627 iassert(ivilayer->ref_count == 1);
628
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000629 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900630 iassert(ivilayer == duplicatelayer);
631
632 if (ivilayer != NULL)
633 iassert(ivilayer->ref_count == 2);
634
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000635 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900636
637 if (ivilayer != NULL)
638 iassert(ivilayer->ref_count == 1);
639
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000640 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900641}
642
643static void
644test_get_layer_after_destory_layer(struct test_context *ctx)
645{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900647 struct ivi_layout_layer *ivilayer;
648
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900650 iassert(ivilayer != NULL);
651
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000652 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900653
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000654 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900655 iassert(ivilayer == NULL);
656}
657
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900658static void
659test_screen_id(struct test_context *ctx)
660{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000661 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900662 struct ivi_layout_screen **iviscrns;
663 int32_t screen_length = 0;
664 uint32_t id_screen;
665 int32_t i;
666
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000667 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900668 iassert(screen_length > 0);
669
670 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000671 id_screen = lyt->get_id_of_screen(iviscrns[i]);
672 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900673 }
674
675 if (screen_length > 0)
676 free(iviscrns);
677}
678
679static void
680test_screen_resolution(struct test_context *ctx)
681{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000682 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900683 struct ivi_layout_screen **iviscrns;
684 int32_t screen_length = 0;
685 struct weston_output *output;
686 int32_t width;
687 int32_t height;
688 int32_t i;
689
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000690 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900691 iassert(screen_length > 0);
692
693 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000694 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900695 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000696 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900697 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
698 iassert(width == output->current_mode->width);
699 iassert(height == output->current_mode->height);
700 }
701
702 if (screen_length > 0)
703 free(iviscrns);
704}
705
706static void
707test_screen_render_order(struct test_context *ctx)
708{
709#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000710 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900711 struct ivi_layout_screen **iviscrns;
712 int32_t screen_length = 0;
713 struct ivi_layout_screen *iviscrn;
714 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
715 struct ivi_layout_layer **array;
716 int32_t length = 0;
717 uint32_t i;
718
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000719 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900720 iassert(screen_length > 0);
721
722 if (screen_length <= 0)
723 return;
724
725 iviscrn = iviscrns[0];
726
727 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000728 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900729
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000730 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900731
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000732 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900733
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000734 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900735 iassert(length == LAYER_NUM);
736 for (i = 0; i < LAYER_NUM; i++)
737 iassert(array[i] == ivilayers[i]);
738
739 if (length > 0)
740 free(array);
741
742 array = NULL;
743
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000744 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900745
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000746 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900747
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000748 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900749 iassert(length == 0 && array == NULL);
750
751 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000752 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900753
754 free(iviscrns);
755#undef LAYER_NUM
756}
757
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900758static void
759test_screen_bad_resolution(struct test_context *ctx)
760{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000761 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900762 struct ivi_layout_screen **iviscrns;
763 int32_t screen_length = 0;
764 struct ivi_layout_screen *iviscrn;
765 int32_t width;
766 int32_t height;
767
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000768 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900769 iassert(screen_length > 0);
770
771 if (screen_length <= 0)
772 return;
773
774 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000775 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
776 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
777 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900778 free(iviscrns);
779}
780
781static void
782test_screen_bad_render_order(struct test_context *ctx)
783{
784#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000785 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900786 struct ivi_layout_screen **iviscrns;
787 int32_t screen_length;
788 struct ivi_layout_screen *iviscrn;
789 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
790 struct ivi_layout_layer **array;
791 int32_t length = 0;
792 uint32_t i;
793
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000794 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900795 iassert(screen_length > 0);
796
797 if (screen_length <= 0)
798 return;
799
800 iviscrn = iviscrns[0];
801
802 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000803 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900804
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000805 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900806
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900808
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000809 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
810 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
811 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900812
813 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000814 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900815
816 free(iviscrns);
817#undef LAYER_NUM
818}
819
820static void
821test_commit_changes_after_render_order_set_layer_destroy(
822 struct test_context *ctx)
823{
824#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000825 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900826 struct ivi_layout_screen **iviscrns;
827 int32_t screen_length;
828 struct ivi_layout_screen *iviscrn;
829 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
830 uint32_t i;
831
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000832 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900833 iassert(screen_length > 0);
834
835 if (screen_length <= 0)
836 return;
837
838 iviscrn = iviscrns[0];
839
840 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000841 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900842
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000843 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900844
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000845 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900846
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000847 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900848
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000849 lyt->layer_destroy(ivilayers[0]);
850 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900851
852 free(iviscrns);
853#undef LAYER_NUM
854}
855
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900856static void
857test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
858 const struct ivi_layout_layer_properties *prop,
859 enum ivi_layout_notification_mask mask,
860 void *userdata)
861{
862 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000863 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900864
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000865 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900866 iassert(prop->source_width == 200);
867 iassert(prop->source_height == 300);
868
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000869 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900870 prop->source_width == 200 && prop->source_height == 300)
871 ctx->user_flags = 1;
872}
873
874static void
875test_layer_properties_changed_notification(struct test_context *ctx)
876{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000877 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900878 struct ivi_layout_layer *ivilayer;
879
880 ctx->user_flags = 0;
881
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900883
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000884 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900885
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000886 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900887
888 iassert(ctx->user_flags == 0);
889
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000890 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900891 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
892
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000893 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900894
895 iassert(ctx->user_flags == 1);
896
897 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000898 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900899 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
900
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000901 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900902
903 iassert(ctx->user_flags == 0);
904
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000905 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900906
907 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000908 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900909
910 iassert(ctx->user_flags == 0);
911
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000912 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900913}
914
915static void
916test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
917 void *userdata)
918{
919 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000920 const struct ivi_layout_interface *lyt = ctx->layout_interface;
921 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900922
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000923 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900924 iassert(prop->source_width == 200);
925 iassert(prop->source_height == 300);
926
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000927 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900928 prop->source_width == 200 && prop->source_height == 300)
929 ctx->user_flags = 1;
930}
931
932static void
933test_layer_create_notification(struct test_context *ctx)
934{
935#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000936 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900937 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
938 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
939
940 ctx->user_flags = 0;
941
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000942 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900943 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000944 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900945
946 iassert(ctx->user_flags == 1);
947
948 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000949 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900950
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000951 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900952
953 iassert(ctx->user_flags == 0);
954
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000955 lyt->layer_destroy(ivilayers[0]);
956 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900957#undef LAYER_NUM
958}
959
960static void
961test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
962 void *userdata)
963{
964 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000965 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900966 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000967 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900968
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000969 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900970 iassert(prop->source_width == 200);
971 iassert(prop->source_height == 300);
972
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000973 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900974 prop->source_width == 200 && prop->source_height == 300)
975 ctx->user_flags = 1;
976}
977
978static void
979test_layer_remove_notification(struct test_context *ctx)
980{
981#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000982 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900983 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
984 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
985
986 ctx->user_flags = 0;
987
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000988 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
989 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900990 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000991 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900992
993 iassert(ctx->user_flags == 1);
994
995 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000996 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
997 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
998 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900999
1000 iassert(ctx->user_flags == 0);
1001#undef LAYER_NUM
1002}
1003
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001004static void
1005test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
1006 const struct ivi_layout_layer_properties *prop,
1007 enum ivi_layout_notification_mask mask,
1008 void *userdata)
1009{
1010}
1011
1012static void
1013test_layer_bad_properties_changed_notification(struct test_context *ctx)
1014{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001015 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001016 struct ivi_layout_layer *ivilayer;
1017
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001018 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001019
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001020 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001021 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001022 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001023
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001024 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001025}
1026
1027static void
1028test_surface_bad_configure_notification(struct test_context *ctx)
1029{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001030 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001031
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001032 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001033}
1034
1035static void
1036test_layer_bad_create_notification(struct test_context *ctx)
1037{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001038 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001039
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001040 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001041}
1042
1043static void
1044test_surface_bad_create_notification(struct test_context *ctx)
1045{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001046 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001047
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001048 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001049}
1050
1051static void
1052test_layer_bad_remove_notification(struct test_context *ctx)
1053{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001054 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001055
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001056 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001057}
1058
1059static void
1060test_surface_bad_remove_notification(struct test_context *ctx)
1061{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001062 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001063
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001064 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001065}
1066
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001067/************************ tests end ********************************/
1068
1069static void
1070run_internal_tests(void *data)
1071{
1072 struct test_context *ctx = data;
1073
1074 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001075 test_surface_bad_destination_rectangle(ctx);
1076 test_surface_bad_orientation(ctx);
1077 test_surface_bad_dimension(ctx);
1078 test_surface_bad_position(ctx);
1079 test_surface_bad_source_rectangle(ctx);
1080 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001081
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001082 test_layer_create(ctx);
1083 test_layer_visibility(ctx);
1084 test_layer_opacity(ctx);
1085 test_layer_orientation(ctx);
1086 test_layer_dimension(ctx);
1087 test_layer_position(ctx);
1088 test_layer_destination_rectangle(ctx);
1089 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001090 test_layer_bad_remove(ctx);
1091 test_layer_bad_visibility(ctx);
1092 test_layer_bad_opacity(ctx);
1093 test_layer_bad_destination_rectangle(ctx);
1094 test_layer_bad_orientation(ctx);
1095 test_layer_bad_dimension(ctx);
1096 test_layer_bad_position(ctx);
1097 test_layer_bad_source_rectangle(ctx);
1098 test_layer_bad_properties(ctx);
1099 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1100 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1101 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1102 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1103 test_commit_changes_after_position_set_layer_destroy(ctx);
1104 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1105 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1106 test_layer_create_duplicate(ctx);
1107 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001108
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001109 test_screen_id(ctx);
1110 test_screen_resolution(ctx);
1111 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001112 test_screen_bad_resolution(ctx);
1113 test_screen_bad_render_order(ctx);
1114 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1115
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001116 test_layer_properties_changed_notification(ctx);
1117 test_layer_create_notification(ctx);
1118 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001119 test_layer_bad_properties_changed_notification(ctx);
1120 test_surface_bad_configure_notification(ctx);
1121 test_layer_bad_create_notification(ctx);
1122 test_surface_bad_create_notification(ctx);
1123 test_layer_bad_remove_notification(ctx);
1124 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001125
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001126 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1127 free(ctx);
1128}
1129
1130int
1131controller_module_init(struct weston_compositor *compositor,
1132 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001133 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001134 size_t iface_version);
1135
1136WL_EXPORT int
1137controller_module_init(struct weston_compositor *compositor,
1138 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001139 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001140 size_t iface_version)
1141{
1142 struct wl_event_loop *loop;
1143 struct test_context *ctx;
1144
1145 /* strict check, since this is an internal test module */
1146 if (iface_version != sizeof(*iface)) {
1147 weston_log("fatal: controller interface mismatch\n");
1148 return -1;
1149 }
1150
1151 ctx = zalloc(sizeof(*ctx));
1152 if (!ctx)
1153 return -1;
1154
1155 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001156 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001157
1158 loop = wl_display_get_event_loop(compositor->wl_display);
1159 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1160
1161 return 0;
1162}