blob: 06abcaa9bf4668e9ec0fcc6ec47f99d89418dd4e [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\)16d1fa12016-03-04 12:50:52 +0000223 iassert(lyt->layer_set_destination_rectangle(ivilayer, prop->dest_x, prop->dest_y,
224 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900225
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000226 iassert(prop->dest_width == 200);
227 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900228
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000229 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900230
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231 iassert(prop->dest_width == 400);
232 iassert(prop->dest_height == 600);
233
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000234 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900235}
236
237static void
238test_layer_position(struct test_context *ctx)
239{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000240 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900241 struct ivi_layout_layer *ivilayer;
242 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900243
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000244 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900245 iassert(ivilayer != NULL);
246
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000247 prop = lyt->get_properties_of_layer(ivilayer);
248 iassert(prop->dest_x == 0);
249 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900250
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +0000251 iassert(lyt->layer_set_destination_rectangle(ivilayer, 20, 30,
252 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900253
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000254 iassert(prop->dest_x == 0);
255 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900256
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 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900260 iassert(prop->dest_x == 20);
261 iassert(prop->dest_y == 30);
262
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000263 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900264}
265
266static void
267test_layer_destination_rectangle(struct test_context *ctx)
268{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000269 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900270 struct ivi_layout_layer *ivilayer;
271 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900272
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000273 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900274 iassert(ivilayer != NULL);
275
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000276 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900277 iassert(prop->dest_width == 200);
278 iassert(prop->dest_height == 300);
279 iassert(prop->dest_x == 0);
280 iassert(prop->dest_y == 0);
281
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000282 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900283 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
284
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000285 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900286 iassert(prop->dest_width == 200);
287 iassert(prop->dest_height == 300);
288 iassert(prop->dest_x == 0);
289 iassert(prop->dest_y == 0);
290
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000291 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900292
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900293 iassert(prop->dest_width == 400);
294 iassert(prop->dest_height == 600);
295 iassert(prop->dest_x == 20);
296 iassert(prop->dest_y == 30);
297
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000298 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900299}
300
301static void
302test_layer_source_rectangle(struct test_context *ctx)
303{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000304 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900305 struct ivi_layout_layer *ivilayer;
306 const struct ivi_layout_layer_properties *prop;
307
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->source_width == 200);
313 iassert(prop->source_height == 300);
314 iassert(prop->source_x == 0);
315 iassert(prop->source_y == 0);
316
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000317 iassert(lyt->layer_set_source_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->source_width == 200);
322 iassert(prop->source_height == 300);
323 iassert(prop->source_x == 0);
324 iassert(prop->source_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 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900329 iassert(prop->source_width == 400);
330 iassert(prop->source_height == 600);
331 iassert(prop->source_x == 20);
332 iassert(prop->source_y == 30);
333
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000334 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900335}
336
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900337static void
338test_layer_bad_remove(struct test_context *ctx)
339{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000340 const struct ivi_layout_interface *lyt = ctx->layout_interface;
341 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900342}
343
344static void
345test_layer_bad_visibility(struct test_context *ctx)
346{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000347 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900348
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000349 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900350
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000351 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900352}
353
354static void
355test_layer_bad_opacity(struct test_context *ctx)
356{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000357 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900358 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000359 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900360
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000361 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900362 iassert(ivilayer != NULL);
363
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000364 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900365 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
366
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000367 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900368 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
369
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000370 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900371 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
372
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000373 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900374
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000375 prop = lyt->get_properties_of_layer(ivilayer);
376 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900377
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000378 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900379 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
380
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000381 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900382
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000383 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900384
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000385 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900386 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
387
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000388 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900389
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000390 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900391}
392
393static void
394test_layer_bad_destination_rectangle(struct test_context *ctx)
395{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000396 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900397
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000398 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900399 NULL, 20, 30, 200, 300) == IVI_FAILED);
400}
401
402static void
403test_layer_bad_orientation(struct test_context *ctx)
404{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000405 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900406
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000407 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900408 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
409
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000410 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900411}
412
413static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900414test_layer_bad_source_rectangle(struct test_context *ctx)
415{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000418 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900419 NULL, 20, 30, 200, 300) == IVI_FAILED);
420}
421
422static void
423test_layer_bad_properties(struct test_context *ctx)
424{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900426
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000427 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900428}
429
430static void
431test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
432{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000433 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900434 struct ivi_layout_layer *ivilayer;
435
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000436 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900437 iassert(ivilayer != NULL);
438
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000439 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
440 lyt->layer_destroy(ivilayer);
441 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900442}
443
444static void
445test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
446{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000447 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900448 struct ivi_layout_layer *ivilayer;
449
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000450 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900451 iassert(ivilayer != NULL);
452
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000455 lyt->layer_destroy(ivilayer);
456 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900457}
458
459static void
460test_commit_changes_after_orientation_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_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900469 ivilayer, WL_OUTPUT_TRANSFORM_90) == 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
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900475test_commit_changes_after_source_rectangle_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_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900484 ivilayer, 20, 30, 200, 300) == 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_destination_rectangle_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_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900499 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 lyt->layer_destroy(ivilayer);
501 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900502}
503
504static void
505test_layer_create_duplicate(struct test_context *ctx)
506{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000507 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900508 struct ivi_layout_layer *ivilayer;
509 struct ivi_layout_layer *duplicatelayer;
510
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000511 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900512 iassert(ivilayer != NULL);
513
514 if (ivilayer != NULL)
515 iassert(ivilayer->ref_count == 1);
516
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000517 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900518 iassert(ivilayer == duplicatelayer);
519
520 if (ivilayer != NULL)
521 iassert(ivilayer->ref_count == 2);
522
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000523 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900524
525 if (ivilayer != NULL)
526 iassert(ivilayer->ref_count == 1);
527
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000528 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900529}
530
531static void
532test_get_layer_after_destory_layer(struct test_context *ctx)
533{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000534 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900535 struct ivi_layout_layer *ivilayer;
536
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000537 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900538 iassert(ivilayer != NULL);
539
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000540 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900541
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000542 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900543 iassert(ivilayer == NULL);
544}
545
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900546static void
547test_screen_id(struct test_context *ctx)
548{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000549 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900550 struct ivi_layout_screen **iviscrns;
551 int32_t screen_length = 0;
552 uint32_t id_screen;
553 int32_t i;
554
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000555 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900556 iassert(screen_length > 0);
557
558 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000559 id_screen = lyt->get_id_of_screen(iviscrns[i]);
560 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900561 }
562
563 if (screen_length > 0)
564 free(iviscrns);
565}
566
567static void
568test_screen_resolution(struct test_context *ctx)
569{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000570 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900571 struct ivi_layout_screen **iviscrns;
572 int32_t screen_length = 0;
573 struct weston_output *output;
574 int32_t width;
575 int32_t height;
576 int32_t i;
577
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000578 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900579 iassert(screen_length > 0);
580
581 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000582 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900583 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000584 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900585 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
586 iassert(width == output->current_mode->width);
587 iassert(height == output->current_mode->height);
588 }
589
590 if (screen_length > 0)
591 free(iviscrns);
592}
593
594static void
595test_screen_render_order(struct test_context *ctx)
596{
597#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000598 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900599 struct ivi_layout_screen **iviscrns;
600 int32_t screen_length = 0;
601 struct ivi_layout_screen *iviscrn;
602 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
603 struct ivi_layout_layer **array;
604 int32_t length = 0;
605 uint32_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 if (screen_length <= 0)
611 return;
612
613 iviscrn = iviscrns[0];
614
615 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000616 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900617
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000618 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900619
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000620 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900621
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000622 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900623 iassert(length == LAYER_NUM);
624 for (i = 0; i < LAYER_NUM; i++)
625 iassert(array[i] == ivilayers[i]);
626
627 if (length > 0)
628 free(array);
629
630 array = NULL;
631
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000632 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900633
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000634 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900635
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000636 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900637 iassert(length == 0 && array == NULL);
638
639 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000640 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900641
642 free(iviscrns);
643#undef LAYER_NUM
644}
645
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900646static void
647test_screen_bad_resolution(struct test_context *ctx)
648{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900650 struct ivi_layout_screen **iviscrns;
651 int32_t screen_length = 0;
652 struct ivi_layout_screen *iviscrn;
653 int32_t width;
654 int32_t height;
655
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000656 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900657 iassert(screen_length > 0);
658
659 if (screen_length <= 0)
660 return;
661
662 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000663 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
664 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
665 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900666 free(iviscrns);
667}
668
669static void
670test_screen_bad_render_order(struct test_context *ctx)
671{
672#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000673 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900674 struct ivi_layout_screen **iviscrns;
675 int32_t screen_length;
676 struct ivi_layout_screen *iviscrn;
677 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
678 struct ivi_layout_layer **array;
679 int32_t length = 0;
680 uint32_t i;
681
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000682 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900683 iassert(screen_length > 0);
684
685 if (screen_length <= 0)
686 return;
687
688 iviscrn = iviscrns[0];
689
690 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000691 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900692
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000693 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900694
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000695 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900696
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000697 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
698 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
699 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900700
701 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000702 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900703
704 free(iviscrns);
705#undef LAYER_NUM
706}
707
708static void
709test_commit_changes_after_render_order_set_layer_destroy(
710 struct test_context *ctx)
711{
712#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000713 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900714 struct ivi_layout_screen **iviscrns;
715 int32_t screen_length;
716 struct ivi_layout_screen *iviscrn;
717 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
718 uint32_t i;
719
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900721 iassert(screen_length > 0);
722
723 if (screen_length <= 0)
724 return;
725
726 iviscrn = iviscrns[0];
727
728 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000729 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900730
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000731 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900732
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000733 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900734
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000735 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900736
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000737 lyt->layer_destroy(ivilayers[0]);
738 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900739
740 free(iviscrns);
741#undef LAYER_NUM
742}
743
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900744static void
745test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
746 const struct ivi_layout_layer_properties *prop,
747 enum ivi_layout_notification_mask mask,
748 void *userdata)
749{
750 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000751 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900752
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000753 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900754 iassert(prop->source_width == 200);
755 iassert(prop->source_height == 300);
756
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000757 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900758 prop->source_width == 200 && prop->source_height == 300)
759 ctx->user_flags = 1;
760}
761
762static void
763test_layer_properties_changed_notification(struct test_context *ctx)
764{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000765 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900766 struct ivi_layout_layer *ivilayer;
767
768 ctx->user_flags = 0;
769
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000770 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900771
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000772 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900773
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900775
776 iassert(ctx->user_flags == 0);
777
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000778 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900779 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
780
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000781 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900782
783 iassert(ctx->user_flags == 1);
784
785 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000786 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900787 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
788
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000789 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900790
791 iassert(ctx->user_flags == 0);
792
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000793 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900794
795 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000796 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900797
798 iassert(ctx->user_flags == 0);
799
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000800 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900801}
802
803static void
804test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
805 void *userdata)
806{
807 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000808 const struct ivi_layout_interface *lyt = ctx->layout_interface;
809 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900810
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000811 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900812 iassert(prop->source_width == 200);
813 iassert(prop->source_height == 300);
814
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000815 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900816 prop->source_width == 200 && prop->source_height == 300)
817 ctx->user_flags = 1;
818}
819
820static void
821test_layer_create_notification(struct test_context *ctx)
822{
823#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000824 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900825 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
826 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
827
828 ctx->user_flags = 0;
829
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000830 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900831 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000832 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900833
834 iassert(ctx->user_flags == 1);
835
836 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000837 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900838
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000839 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900840
841 iassert(ctx->user_flags == 0);
842
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000843 lyt->layer_destroy(ivilayers[0]);
844 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900845#undef LAYER_NUM
846}
847
848static void
849test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
850 void *userdata)
851{
852 struct test_context *ctx = userdata;
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 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000855 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900856
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000857 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900858 iassert(prop->source_width == 200);
859 iassert(prop->source_height == 300);
860
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000861 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900862 prop->source_width == 200 && prop->source_height == 300)
863 ctx->user_flags = 1;
864}
865
866static void
867test_layer_remove_notification(struct test_context *ctx)
868{
869#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000870 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900871 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
872 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
873
874 ctx->user_flags = 0;
875
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000876 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
877 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900878 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000879 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900880
881 iassert(ctx->user_flags == 1);
882
883 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000884 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
885 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
886 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900887
888 iassert(ctx->user_flags == 0);
889#undef LAYER_NUM
890}
891
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900892static void
893test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
894 const struct ivi_layout_layer_properties *prop,
895 enum ivi_layout_notification_mask mask,
896 void *userdata)
897{
898}
899
900static void
901test_layer_bad_properties_changed_notification(struct test_context *ctx)
902{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000903 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900904 struct ivi_layout_layer *ivilayer;
905
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000906 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900907
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000908 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900909 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000910 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900911
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000912 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900913}
914
915static void
916test_surface_bad_configure_notification(struct test_context *ctx)
917{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000918 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900919
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000920 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900921}
922
923static void
924test_layer_bad_create_notification(struct test_context *ctx)
925{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000926 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900927
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000928 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900929}
930
931static void
932test_surface_bad_create_notification(struct test_context *ctx)
933{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000934 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900935
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000936 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900937}
938
939static void
940test_layer_bad_remove_notification(struct test_context *ctx)
941{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000942 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900943
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000944 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900945}
946
947static void
948test_surface_bad_remove_notification(struct test_context *ctx)
949{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000950 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900951
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000952 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900953}
954
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200955/************************ tests end ********************************/
956
957static void
958run_internal_tests(void *data)
959{
960 struct test_context *ctx = data;
961
962 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900963 test_surface_bad_destination_rectangle(ctx);
964 test_surface_bad_orientation(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900965 test_surface_bad_source_rectangle(ctx);
966 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200967
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900968 test_layer_create(ctx);
969 test_layer_visibility(ctx);
970 test_layer_opacity(ctx);
971 test_layer_orientation(ctx);
972 test_layer_dimension(ctx);
973 test_layer_position(ctx);
974 test_layer_destination_rectangle(ctx);
975 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900976 test_layer_bad_remove(ctx);
977 test_layer_bad_visibility(ctx);
978 test_layer_bad_opacity(ctx);
979 test_layer_bad_destination_rectangle(ctx);
980 test_layer_bad_orientation(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900981 test_layer_bad_source_rectangle(ctx);
982 test_layer_bad_properties(ctx);
983 test_commit_changes_after_visibility_set_layer_destroy(ctx);
984 test_commit_changes_after_opacity_set_layer_destroy(ctx);
985 test_commit_changes_after_orientation_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900986 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
987 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
988 test_layer_create_duplicate(ctx);
989 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900990
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900991 test_screen_id(ctx);
992 test_screen_resolution(ctx);
993 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900994 test_screen_bad_resolution(ctx);
995 test_screen_bad_render_order(ctx);
996 test_commit_changes_after_render_order_set_layer_destroy(ctx);
997
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900998 test_layer_properties_changed_notification(ctx);
999 test_layer_create_notification(ctx);
1000 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001001 test_layer_bad_properties_changed_notification(ctx);
1002 test_surface_bad_configure_notification(ctx);
1003 test_layer_bad_create_notification(ctx);
1004 test_surface_bad_create_notification(ctx);
1005 test_layer_bad_remove_notification(ctx);
1006 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001007
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001008 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1009 free(ctx);
1010}
1011
1012int
1013controller_module_init(struct weston_compositor *compositor,
1014 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001015 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001016 size_t iface_version);
1017
1018WL_EXPORT int
1019controller_module_init(struct weston_compositor *compositor,
1020 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001021 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001022 size_t iface_version)
1023{
1024 struct wl_event_loop *loop;
1025 struct test_context *ctx;
1026
1027 /* strict check, since this is an internal test module */
1028 if (iface_version != sizeof(*iface)) {
1029 weston_log("fatal: controller interface mismatch\n");
1030 return -1;
1031 }
1032
1033 ctx = zalloc(sizeof(*ctx));
1034 if (!ctx)
1035 return -1;
1036
1037 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001038 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001039
1040 loop = wl_display_get_event_loop(compositor->wl_display);
1041 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1042
1043 return 0;
1044}