blob: 1e22c759a9200e47f53879d6983a86fe3e0147fd [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
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090094test_surface_bad_source_rectangle(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_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090099}
100
101static void
102test_surface_bad_properties(struct test_context *ctx)
103{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000104 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900105
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000106 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900107}
108
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900109static void
110test_layer_create(struct test_context *ctx)
111{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000112 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900113 uint32_t id1;
114 uint32_t id2;
115 struct ivi_layout_layer *ivilayer;
116 struct ivi_layout_layer *new_ivilayer;
117
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000118 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900119 iassert(ivilayer != NULL);
120
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000121 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900122
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000123 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900124 iassert(ivilayer == new_ivilayer);
125
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000126 id1 = lyt->get_id_of_layer(ivilayer);
127 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900128 iassert(id1 == id2);
129
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000130 lyt->layer_destroy(ivilayer);
131 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900132}
133
134static void
135test_layer_visibility(struct test_context *ctx)
136{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000137 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900138 struct ivi_layout_layer *ivilayer;
139 const struct ivi_layout_layer_properties *prop;
140
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000141 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900142 iassert(ivilayer != NULL);
143
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000144 prop = lyt->get_properties_of_layer(ivilayer);
145
146 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900147
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000148 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900149
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000150 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900151
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000152 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900153
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900154 iassert(prop->visibility == true);
155
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000156 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900157}
158
159static void
160test_layer_opacity(struct test_context *ctx)
161{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000162 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900163 struct ivi_layout_layer *ivilayer;
164 const struct ivi_layout_layer_properties *prop;
165
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000166 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900167 iassert(ivilayer != NULL);
168
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000169 prop = lyt->get_properties_of_layer(ivilayer);
170 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900171
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000172 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900173 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
174
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000175 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900176
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000177 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900178
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900179 iassert(prop->opacity == wl_fixed_from_double(0.5));
180
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000181 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900182}
183
184static void
185test_layer_orientation(struct test_context *ctx)
186{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000187 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900188 struct ivi_layout_layer *ivilayer;
189 const struct ivi_layout_layer_properties *prop;
190
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000191 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900192 iassert(ivilayer != NULL);
193
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000194 prop = lyt->get_properties_of_layer(ivilayer);
195 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900196
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000197 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
199
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000200 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900201
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000202 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900203
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900204 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
205
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000206 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900207}
208
209static void
210test_layer_dimension(struct test_context *ctx)
211{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000212 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900213 struct ivi_layout_layer *ivilayer;
214 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900215
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900217 iassert(ivilayer != NULL);
218
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000219 prop = lyt->get_properties_of_layer(ivilayer);
220 iassert(prop->dest_width == 200);
221 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900222
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000223 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900224
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000225 iassert(prop->dest_width == 200);
226 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900227
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000228 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900229
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900230 iassert(prop->dest_width == 400);
231 iassert(prop->dest_height == 600);
232
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000233 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900234}
235
236static void
237test_layer_position(struct test_context *ctx)
238{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000239 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900240 struct ivi_layout_layer *ivilayer;
241 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900242
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000243 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900244 iassert(ivilayer != NULL);
245
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000246 prop = lyt->get_properties_of_layer(ivilayer);
247 iassert(prop->dest_x == 0);
248 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900249
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +0000250 iassert(lyt->layer_set_destination_rectangle(ivilayer, 20, 30,
251 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900252
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000253 iassert(prop->dest_x == 0);
254 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900255
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000256 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900257
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000258 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900259 iassert(prop->dest_x == 20);
260 iassert(prop->dest_y == 30);
261
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000262 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900263}
264
265static void
266test_layer_destination_rectangle(struct test_context *ctx)
267{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000268 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900269 struct ivi_layout_layer *ivilayer;
270 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900271
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000272 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900273 iassert(ivilayer != NULL);
274
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000275 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900276 iassert(prop->dest_width == 200);
277 iassert(prop->dest_height == 300);
278 iassert(prop->dest_x == 0);
279 iassert(prop->dest_y == 0);
280
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000281 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900282 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
283
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000284 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900285 iassert(prop->dest_width == 200);
286 iassert(prop->dest_height == 300);
287 iassert(prop->dest_x == 0);
288 iassert(prop->dest_y == 0);
289
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000290 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900292 iassert(prop->dest_width == 400);
293 iassert(prop->dest_height == 600);
294 iassert(prop->dest_x == 20);
295 iassert(prop->dest_y == 30);
296
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000297 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900298}
299
300static void
301test_layer_source_rectangle(struct test_context *ctx)
302{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000303 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900304 struct ivi_layout_layer *ivilayer;
305 const struct ivi_layout_layer_properties *prop;
306
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000307 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900308 iassert(ivilayer != NULL);
309
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000310 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900311 iassert(prop->source_width == 200);
312 iassert(prop->source_height == 300);
313 iassert(prop->source_x == 0);
314 iassert(prop->source_y == 0);
315
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000316 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900317 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
318
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000319 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900320 iassert(prop->source_width == 200);
321 iassert(prop->source_height == 300);
322 iassert(prop->source_x == 0);
323 iassert(prop->source_y == 0);
324
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000325 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900326
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000327 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900328 iassert(prop->source_width == 400);
329 iassert(prop->source_height == 600);
330 iassert(prop->source_x == 20);
331 iassert(prop->source_y == 30);
332
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000333 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900334}
335
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900336static void
337test_layer_bad_remove(struct test_context *ctx)
338{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000339 const struct ivi_layout_interface *lyt = ctx->layout_interface;
340 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900341}
342
343static void
344test_layer_bad_visibility(struct test_context *ctx)
345{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900347
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000348 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900349
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000350 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900351}
352
353static void
354test_layer_bad_opacity(struct test_context *ctx)
355{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000356 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900357 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000358 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900359
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000360 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900361 iassert(ivilayer != NULL);
362
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000363 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900364 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
365
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000366 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900367 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
368
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900370 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
371
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000372 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900373
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000374 prop = lyt->get_properties_of_layer(ivilayer);
375 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900376
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000377 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900378 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
379
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000380 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900381
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000382 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900383
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.5)) == IVI_FAILED);
386
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000387 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900388
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000389 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900390}
391
392static void
393test_layer_bad_destination_rectangle(struct test_context *ctx)
394{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000395 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900396
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000397 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900398 NULL, 20, 30, 200, 300) == IVI_FAILED);
399}
400
401static void
402test_layer_bad_orientation(struct test_context *ctx)
403{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000404 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900405
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000406 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900407 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
408
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000409 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900410}
411
412static void
413test_layer_bad_dimension(struct test_context *ctx)
414{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000415 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900416 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000418 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900419 iassert(ivilayer != NULL);
420
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000421 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900422
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000423 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900424
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900426}
427
428static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900429test_layer_bad_source_rectangle(struct test_context *ctx)
430{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000431 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900432
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000433 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900434 NULL, 20, 30, 200, 300) == IVI_FAILED);
435}
436
437static void
438test_layer_bad_properties(struct test_context *ctx)
439{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000440 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900441
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000442 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900443}
444
445static void
446test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
447{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000448 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900449 struct ivi_layout_layer *ivilayer;
450
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000451 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900452 iassert(ivilayer != NULL);
453
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000454 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
455 lyt->layer_destroy(ivilayer);
456 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900457}
458
459static void
460test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
461{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000462 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900463 struct ivi_layout_layer *ivilayer;
464
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000465 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900466 iassert(ivilayer != NULL);
467
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000468 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900469 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000470 lyt->layer_destroy(ivilayer);
471 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900472}
473
474static void
475test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
476{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000477 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900478 struct ivi_layout_layer *ivilayer;
479
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000480 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900481 iassert(ivilayer != NULL);
482
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000483 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900484 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000485 lyt->layer_destroy(ivilayer);
486 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900487}
488
489static void
490test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
491{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000492 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900493 struct ivi_layout_layer *ivilayer;
494
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000495 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900496 iassert(ivilayer != NULL);
497
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000498 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
499 lyt->layer_destroy(ivilayer);
500 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900501}
502
503static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900504test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
505{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000506 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900507 struct ivi_layout_layer *ivilayer;
508
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900510 iassert(ivilayer != NULL);
511
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000512 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900513 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000514 lyt->layer_destroy(ivilayer);
515 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900516}
517
518static void
519test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
520{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000521 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900522 struct ivi_layout_layer *ivilayer;
523
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000524 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900525 iassert(ivilayer != NULL);
526
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000527 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900528 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000529 lyt->layer_destroy(ivilayer);
530 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900531}
532
533static void
534test_layer_create_duplicate(struct test_context *ctx)
535{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000536 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900537 struct ivi_layout_layer *ivilayer;
538 struct ivi_layout_layer *duplicatelayer;
539
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000540 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900541 iassert(ivilayer != NULL);
542
543 if (ivilayer != NULL)
544 iassert(ivilayer->ref_count == 1);
545
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900547 iassert(ivilayer == duplicatelayer);
548
549 if (ivilayer != NULL)
550 iassert(ivilayer->ref_count == 2);
551
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000552 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900553
554 if (ivilayer != NULL)
555 iassert(ivilayer->ref_count == 1);
556
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000557 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900558}
559
560static void
561test_get_layer_after_destory_layer(struct test_context *ctx)
562{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000563 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900564 struct ivi_layout_layer *ivilayer;
565
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000566 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900567 iassert(ivilayer != NULL);
568
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000569 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900570
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000571 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900572 iassert(ivilayer == NULL);
573}
574
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900575static void
576test_screen_id(struct test_context *ctx)
577{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000578 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900579 struct ivi_layout_screen **iviscrns;
580 int32_t screen_length = 0;
581 uint32_t id_screen;
582 int32_t i;
583
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000584 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900585 iassert(screen_length > 0);
586
587 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000588 id_screen = lyt->get_id_of_screen(iviscrns[i]);
589 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900590 }
591
592 if (screen_length > 0)
593 free(iviscrns);
594}
595
596static void
597test_screen_resolution(struct test_context *ctx)
598{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000599 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900600 struct ivi_layout_screen **iviscrns;
601 int32_t screen_length = 0;
602 struct weston_output *output;
603 int32_t width;
604 int32_t height;
605 int32_t i;
606
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000607 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900608 iassert(screen_length > 0);
609
610 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000611 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900612 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000613 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900614 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
615 iassert(width == output->current_mode->width);
616 iassert(height == output->current_mode->height);
617 }
618
619 if (screen_length > 0)
620 free(iviscrns);
621}
622
623static void
624test_screen_render_order(struct test_context *ctx)
625{
626#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000627 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900628 struct ivi_layout_screen **iviscrns;
629 int32_t screen_length = 0;
630 struct ivi_layout_screen *iviscrn;
631 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
632 struct ivi_layout_layer **array;
633 int32_t length = 0;
634 uint32_t i;
635
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000636 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900637 iassert(screen_length > 0);
638
639 if (screen_length <= 0)
640 return;
641
642 iviscrn = iviscrns[0];
643
644 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000645 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900646
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000647 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900648
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900650
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000651 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900652 iassert(length == LAYER_NUM);
653 for (i = 0; i < LAYER_NUM; i++)
654 iassert(array[i] == ivilayers[i]);
655
656 if (length > 0)
657 free(array);
658
659 array = NULL;
660
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000661 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900662
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000663 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900664
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000665 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900666 iassert(length == 0 && array == NULL);
667
668 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000669 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900670
671 free(iviscrns);
672#undef LAYER_NUM
673}
674
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900675static void
676test_screen_bad_resolution(struct test_context *ctx)
677{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000678 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900679 struct ivi_layout_screen **iviscrns;
680 int32_t screen_length = 0;
681 struct ivi_layout_screen *iviscrn;
682 int32_t width;
683 int32_t height;
684
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000685 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900686 iassert(screen_length > 0);
687
688 if (screen_length <= 0)
689 return;
690
691 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000692 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
693 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
694 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900695 free(iviscrns);
696}
697
698static void
699test_screen_bad_render_order(struct test_context *ctx)
700{
701#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000702 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900703 struct ivi_layout_screen **iviscrns;
704 int32_t screen_length;
705 struct ivi_layout_screen *iviscrn;
706 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
707 struct ivi_layout_layer **array;
708 int32_t length = 0;
709 uint32_t i;
710
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000711 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900712 iassert(screen_length > 0);
713
714 if (screen_length <= 0)
715 return;
716
717 iviscrn = iviscrns[0];
718
719 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900721
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000722 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900723
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000724 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900725
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000726 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
727 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
728 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900729
730 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000731 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900732
733 free(iviscrns);
734#undef LAYER_NUM
735}
736
737static void
738test_commit_changes_after_render_order_set_layer_destroy(
739 struct test_context *ctx)
740{
741#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000742 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900743 struct ivi_layout_screen **iviscrns;
744 int32_t screen_length;
745 struct ivi_layout_screen *iviscrn;
746 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
747 uint32_t i;
748
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000749 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900750 iassert(screen_length > 0);
751
752 if (screen_length <= 0)
753 return;
754
755 iviscrn = iviscrns[0];
756
757 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000758 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900759
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000760 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900761
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000762 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900763
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000764 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900765
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000766 lyt->layer_destroy(ivilayers[0]);
767 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900768
769 free(iviscrns);
770#undef LAYER_NUM
771}
772
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900773static void
774test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
775 const struct ivi_layout_layer_properties *prop,
776 enum ivi_layout_notification_mask mask,
777 void *userdata)
778{
779 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000780 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900781
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000782 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900783 iassert(prop->source_width == 200);
784 iassert(prop->source_height == 300);
785
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000786 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900787 prop->source_width == 200 && prop->source_height == 300)
788 ctx->user_flags = 1;
789}
790
791static void
792test_layer_properties_changed_notification(struct test_context *ctx)
793{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000794 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900795 struct ivi_layout_layer *ivilayer;
796
797 ctx->user_flags = 0;
798
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000799 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900800
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000801 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900802
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000803 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900804
805 iassert(ctx->user_flags == 0);
806
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900808 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
809
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000810 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900811
812 iassert(ctx->user_flags == 1);
813
814 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000815 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900816 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
817
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000818 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900819
820 iassert(ctx->user_flags == 0);
821
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000822 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900823
824 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000825 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900826
827 iassert(ctx->user_flags == 0);
828
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000829 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900830}
831
832static void
833test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
834 void *userdata)
835{
836 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000837 const struct ivi_layout_interface *lyt = ctx->layout_interface;
838 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900839
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000840 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900841 iassert(prop->source_width == 200);
842 iassert(prop->source_height == 300);
843
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000844 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900845 prop->source_width == 200 && prop->source_height == 300)
846 ctx->user_flags = 1;
847}
848
849static void
850test_layer_create_notification(struct test_context *ctx)
851{
852#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000853 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900854 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
855 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
856
857 ctx->user_flags = 0;
858
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000859 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900860 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000861 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900862
863 iassert(ctx->user_flags == 1);
864
865 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000866 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900867
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000868 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900869
870 iassert(ctx->user_flags == 0);
871
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000872 lyt->layer_destroy(ivilayers[0]);
873 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900874#undef LAYER_NUM
875}
876
877static void
878test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
879 void *userdata)
880{
881 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900883 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000884 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900885
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000886 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900887 iassert(prop->source_width == 200);
888 iassert(prop->source_height == 300);
889
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000890 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900891 prop->source_width == 200 && prop->source_height == 300)
892 ctx->user_flags = 1;
893}
894
895static void
896test_layer_remove_notification(struct test_context *ctx)
897{
898#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000899 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900900 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
901 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
902
903 ctx->user_flags = 0;
904
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000905 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
906 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900907 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000908 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900909
910 iassert(ctx->user_flags == 1);
911
912 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000913 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
914 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
915 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900916
917 iassert(ctx->user_flags == 0);
918#undef LAYER_NUM
919}
920
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900921static void
922test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
923 const struct ivi_layout_layer_properties *prop,
924 enum ivi_layout_notification_mask mask,
925 void *userdata)
926{
927}
928
929static void
930test_layer_bad_properties_changed_notification(struct test_context *ctx)
931{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000932 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900933 struct ivi_layout_layer *ivilayer;
934
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000935 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900936
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000937 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900938 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000939 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900940
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000941 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900942}
943
944static void
945test_surface_bad_configure_notification(struct test_context *ctx)
946{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000947 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900948
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000949 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900950}
951
952static void
953test_layer_bad_create_notification(struct test_context *ctx)
954{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000955 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900956
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000957 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900958}
959
960static void
961test_surface_bad_create_notification(struct test_context *ctx)
962{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000963 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900964
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000965 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900966}
967
968static void
969test_layer_bad_remove_notification(struct test_context *ctx)
970{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000971 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900972
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000973 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900974}
975
976static void
977test_surface_bad_remove_notification(struct test_context *ctx)
978{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000979 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900980
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000981 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900982}
983
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200984/************************ tests end ********************************/
985
986static void
987run_internal_tests(void *data)
988{
989 struct test_context *ctx = data;
990
991 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900992 test_surface_bad_destination_rectangle(ctx);
993 test_surface_bad_orientation(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900994 test_surface_bad_source_rectangle(ctx);
995 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200996
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900997 test_layer_create(ctx);
998 test_layer_visibility(ctx);
999 test_layer_opacity(ctx);
1000 test_layer_orientation(ctx);
1001 test_layer_dimension(ctx);
1002 test_layer_position(ctx);
1003 test_layer_destination_rectangle(ctx);
1004 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001005 test_layer_bad_remove(ctx);
1006 test_layer_bad_visibility(ctx);
1007 test_layer_bad_opacity(ctx);
1008 test_layer_bad_destination_rectangle(ctx);
1009 test_layer_bad_orientation(ctx);
1010 test_layer_bad_dimension(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001011 test_layer_bad_source_rectangle(ctx);
1012 test_layer_bad_properties(ctx);
1013 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1014 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1015 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1016 test_commit_changes_after_dimension_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001017 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1018 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1019 test_layer_create_duplicate(ctx);
1020 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001021
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001022 test_screen_id(ctx);
1023 test_screen_resolution(ctx);
1024 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001025 test_screen_bad_resolution(ctx);
1026 test_screen_bad_render_order(ctx);
1027 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1028
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001029 test_layer_properties_changed_notification(ctx);
1030 test_layer_create_notification(ctx);
1031 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001032 test_layer_bad_properties_changed_notification(ctx);
1033 test_surface_bad_configure_notification(ctx);
1034 test_layer_bad_create_notification(ctx);
1035 test_surface_bad_create_notification(ctx);
1036 test_layer_bad_remove_notification(ctx);
1037 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001038
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001039 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1040 free(ctx);
1041}
1042
1043int
1044controller_module_init(struct weston_compositor *compositor,
1045 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001046 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001047 size_t iface_version);
1048
1049WL_EXPORT int
1050controller_module_init(struct weston_compositor *compositor,
1051 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001052 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001053 size_t iface_version)
1054{
1055 struct wl_event_loop *loop;
1056 struct test_context *ctx;
1057
1058 /* strict check, since this is an internal test module */
1059 if (iface_version != sizeof(*iface)) {
1060 weston_log("fatal: controller interface mismatch\n");
1061 return -1;
1062 }
1063
1064 ctx = zalloc(sizeof(*ctx));
1065 if (!ctx)
1066 return -1;
1067
1068 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001069 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001070
1071 loop = wl_display_get_event_loop(compositor->wl_display);
1072 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1073
1074 return 0;
1075}