blob: 7ec294827a70bf0756dd2ac6b94d663a89ed3514 [file] [log] [blame]
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001/*
2 * Copyright © 2013 DENSO CORPORATION
3 * Copyright © 2015 Collabora, Ltd.
4 *
Bryce Harrington2cc92972015-06-11 15:39:40 -07005 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
Pekka Paalanen46804ca2015-03-27 11:55:21 +020012 *
Bryce Harrington2cc92972015-06-11 15:39:40 -070013 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
Pekka Paalanen46804ca2015-03-27 11:55:21 +020025 */
26
27#include "config.h"
28
29#include <unistd.h>
30#include <signal.h>
31#include <string.h>
32#include <stdbool.h>
33
Jon Cruz4678bab2015-06-15 15:37:07 -070034#include "src/compositor.h"
35#include "ivi-shell/ivi-layout-export.h"
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +090036#include "ivi-shell/ivi-layout-private.h"
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +090037#include "ivi-test.h"
Pekka Paalanen46804ca2015-03-27 11:55:21 +020038
39struct test_context {
40 struct weston_compositor *compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000041 const struct ivi_layout_interface *layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +090042 uint32_t user_flags;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020043};
44
45static void
46iassert_fail(const char *cond, const char *file, int line,
47 const char *func, struct test_context *ctx)
48{
49 weston_log("Assert failure in %s:%d, %s: '%s'\n",
50 file, line, func, cond);
51 weston_compositor_exit_with_code(ctx->compositor, EXIT_FAILURE);
52}
53
54#define iassert(cond) ({ \
55 bool b_ = (cond); \
56 if (!b_) \
57 iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx); \
58 b_; \
59})
60
61/************************ tests begin ******************************/
62
63/*
64 * These are all internal ivi_layout API tests that do not require
65 * any client objects.
66 */
Pekka Paalanen46804ca2015-03-27 11:55:21 +020067static void
68test_surface_bad_visibility(struct test_context *ctx)
69{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000070 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020071
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000072 iassert(lyt->surface_set_visibility(NULL, true) == IVI_FAILED);
Pekka Paalanen46804ca2015-03-27 11:55:21 +020073
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000074 lyt->commit_changes();
Pekka Paalanen46804ca2015-03-27 11:55:21 +020075}
76
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090077static void
78test_surface_bad_destination_rectangle(struct test_context *ctx)
79{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000080 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090081
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000082 iassert(lyt->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090083}
84
85static void
86test_surface_bad_orientation(struct test_context *ctx)
87{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000088 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090089
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000090 iassert(lyt->surface_set_orientation(NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090091}
92
93static void
94test_surface_bad_dimension(struct test_context *ctx)
95{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000096 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090097
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000098 iassert(lyt->surface_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090099
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000100 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900101}
102
103static void
104test_surface_bad_position(struct test_context *ctx)
105{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000106 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900107
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000108 iassert(lyt->surface_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900109
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000110 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900111}
112
113static void
114test_surface_bad_source_rectangle(struct test_context *ctx)
115{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000116 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900117
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000118 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900119}
120
121static void
122test_surface_bad_properties(struct test_context *ctx)
123{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000124 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900125
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000126 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900127}
128
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900129static void
130test_layer_create(struct test_context *ctx)
131{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000132 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900133 uint32_t id1;
134 uint32_t id2;
135 struct ivi_layout_layer *ivilayer;
136 struct ivi_layout_layer *new_ivilayer;
137
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000138 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900139 iassert(ivilayer != NULL);
140
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000141 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900142
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000143 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900144 iassert(ivilayer == new_ivilayer);
145
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000146 id1 = lyt->get_id_of_layer(ivilayer);
147 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900148 iassert(id1 == id2);
149
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000150 lyt->layer_destroy(ivilayer);
151 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900152}
153
154static void
155test_layer_visibility(struct test_context *ctx)
156{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000157 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900158 struct ivi_layout_layer *ivilayer;
159 const struct ivi_layout_layer_properties *prop;
160
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000161 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900162 iassert(ivilayer != NULL);
163
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000164 prop = lyt->get_properties_of_layer(ivilayer);
165
166 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900167
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000168 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900169
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000170 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900171
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000172 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900173
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900174 iassert(prop->visibility == true);
175
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000176 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900177}
178
179static void
180test_layer_opacity(struct test_context *ctx)
181{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000182 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183 struct ivi_layout_layer *ivilayer;
184 const struct ivi_layout_layer_properties *prop;
185
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000186 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900187 iassert(ivilayer != NULL);
188
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000189 prop = lyt->get_properties_of_layer(ivilayer);
190 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900191
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000192 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900193 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
194
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000195 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900196
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000197 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900199 iassert(prop->opacity == wl_fixed_from_double(0.5));
200
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000201 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900202}
203
204static void
205test_layer_orientation(struct test_context *ctx)
206{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000207 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208 struct ivi_layout_layer *ivilayer;
209 const struct ivi_layout_layer_properties *prop;
210
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000211 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900212 iassert(ivilayer != NULL);
213
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000214 prop = lyt->get_properties_of_layer(ivilayer);
215 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900216
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000217 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900218 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
219
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000220 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900221
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000222 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900223
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900224 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
225
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000226 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900227}
228
229static void
230test_layer_dimension(struct test_context *ctx)
231{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000232 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900233 struct ivi_layout_layer *ivilayer;
234 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900235
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000236 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900237 iassert(ivilayer != NULL);
238
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000239 prop = lyt->get_properties_of_layer(ivilayer);
240 iassert(prop->dest_width == 200);
241 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900242
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000243 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900244
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000245 iassert(prop->dest_width == 200);
246 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900247
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000248 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900249
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900250 iassert(prop->dest_width == 400);
251 iassert(prop->dest_height == 600);
252
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000253 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900254}
255
256static void
257test_layer_position(struct test_context *ctx)
258{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000259 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900260 struct ivi_layout_layer *ivilayer;
261 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900262
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000263 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900264 iassert(ivilayer != NULL);
265
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000266 prop = lyt->get_properties_of_layer(ivilayer);
267 iassert(prop->dest_x == 0);
268 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900269
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000270 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900271
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000272 iassert(prop->dest_x == 0);
273 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900274
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000275 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900276
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000277 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900278 iassert(prop->dest_x == 20);
279 iassert(prop->dest_y == 30);
280
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000281 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900282}
283
284static void
285test_layer_destination_rectangle(struct test_context *ctx)
286{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000287 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900288 struct ivi_layout_layer *ivilayer;
289 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900290
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000291 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900292 iassert(ivilayer != NULL);
293
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000294 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900295 iassert(prop->dest_width == 200);
296 iassert(prop->dest_height == 300);
297 iassert(prop->dest_x == 0);
298 iassert(prop->dest_y == 0);
299
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000300 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900301 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
302
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000303 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900304 iassert(prop->dest_width == 200);
305 iassert(prop->dest_height == 300);
306 iassert(prop->dest_x == 0);
307 iassert(prop->dest_y == 0);
308
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000309 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900310
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900311 iassert(prop->dest_width == 400);
312 iassert(prop->dest_height == 600);
313 iassert(prop->dest_x == 20);
314 iassert(prop->dest_y == 30);
315
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000316 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900317}
318
319static void
320test_layer_source_rectangle(struct test_context *ctx)
321{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000322 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900323 struct ivi_layout_layer *ivilayer;
324 const struct ivi_layout_layer_properties *prop;
325
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000326 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900327 iassert(ivilayer != NULL);
328
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000329 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900330 iassert(prop->source_width == 200);
331 iassert(prop->source_height == 300);
332 iassert(prop->source_x == 0);
333 iassert(prop->source_y == 0);
334
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000335 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900336 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
337
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000338 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900339 iassert(prop->source_width == 200);
340 iassert(prop->source_height == 300);
341 iassert(prop->source_x == 0);
342 iassert(prop->source_y == 0);
343
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000344 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900345
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900347 iassert(prop->source_width == 400);
348 iassert(prop->source_height == 600);
349 iassert(prop->source_x == 20);
350 iassert(prop->source_y == 30);
351
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000352 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900353}
354
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900355static void
356test_layer_bad_remove(struct test_context *ctx)
357{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000358 const struct ivi_layout_interface *lyt = ctx->layout_interface;
359 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900360}
361
362static void
363test_layer_bad_visibility(struct test_context *ctx)
364{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000365 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900366
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000367 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900368
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900370}
371
372static void
373test_layer_bad_opacity(struct test_context *ctx)
374{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000375 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900376 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000377 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900378
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000379 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900380 iassert(ivilayer != NULL);
381
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000382 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900383 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
384
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000385 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900386 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
387
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000388 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900389 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
390
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000391 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900392
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000393 prop = lyt->get_properties_of_layer(ivilayer);
394 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900395
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000396 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900397 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
398
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000399 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900400
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000401 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900402
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000403 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900404 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
405
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000406 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900407
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000408 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900409}
410
411static void
412test_layer_bad_destination_rectangle(struct test_context *ctx)
413{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000414 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900415
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417 NULL, 20, 30, 200, 300) == IVI_FAILED);
418}
419
420static void
421test_layer_bad_orientation(struct test_context *ctx)
422{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000423 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900424
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900426 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
427
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000428 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900429}
430
431static void
432test_layer_bad_dimension(struct test_context *ctx)
433{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000434 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900435 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900436
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000437 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900438 iassert(ivilayer != NULL);
439
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000440 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900441
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000442 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900443
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000444 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900445}
446
447static void
448test_layer_bad_position(struct test_context *ctx)
449{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000450 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900451 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900452
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454 iassert(ivilayer != NULL);
455
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000456 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900457
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000458 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900459
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000460 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900461}
462
463static void
464test_layer_bad_source_rectangle(struct test_context *ctx)
465{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000466 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900467
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000468 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900469 NULL, 20, 30, 200, 300) == IVI_FAILED);
470}
471
472static void
473test_layer_bad_properties(struct test_context *ctx)
474{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900476
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000477 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900478}
479
480static void
481test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
482{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000483 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900484 struct ivi_layout_layer *ivilayer;
485
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000486 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900487 iassert(ivilayer != NULL);
488
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000489 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
490 lyt->layer_destroy(ivilayer);
491 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900492}
493
494static void
495test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
496{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000497 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900498 struct ivi_layout_layer *ivilayer;
499
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900501 iassert(ivilayer != NULL);
502
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000503 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900504 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000505 lyt->layer_destroy(ivilayer);
506 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900507}
508
509static void
510test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
511{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000512 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900513 struct ivi_layout_layer *ivilayer;
514
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000515 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900516 iassert(ivilayer != NULL);
517
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000518 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900519 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000520 lyt->layer_destroy(ivilayer);
521 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900522}
523
524static void
525test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
526{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000527 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900528 struct ivi_layout_layer *ivilayer;
529
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000530 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900531 iassert(ivilayer != NULL);
532
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000533 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
534 lyt->layer_destroy(ivilayer);
535 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900536}
537
538static void
539test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
540{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000541 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900542 struct ivi_layout_layer *ivilayer;
543
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000544 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900545 iassert(ivilayer != NULL);
546
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000547 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
548 lyt->layer_destroy(ivilayer);
549 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900550}
551
552static void
553test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
554{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000555 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900556 struct ivi_layout_layer *ivilayer;
557
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000558 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900559 iassert(ivilayer != NULL);
560
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000561 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900562 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000563 lyt->layer_destroy(ivilayer);
564 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900565}
566
567static void
568test_commit_changes_after_destination_rectangle_set_layer_destroy(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 Tanibata17d44942015-06-22 15:35:12 +0900571 struct ivi_layout_layer *ivilayer;
572
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000573 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900574 iassert(ivilayer != NULL);
575
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000576 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900577 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000578 lyt->layer_destroy(ivilayer);
579 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900580}
581
582static void
583test_layer_create_duplicate(struct test_context *ctx)
584{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000585 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900586 struct ivi_layout_layer *ivilayer;
587 struct ivi_layout_layer *duplicatelayer;
588
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000589 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900590 iassert(ivilayer != NULL);
591
592 if (ivilayer != NULL)
593 iassert(ivilayer->ref_count == 1);
594
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000595 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900596 iassert(ivilayer == duplicatelayer);
597
598 if (ivilayer != NULL)
599 iassert(ivilayer->ref_count == 2);
600
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000601 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900602
603 if (ivilayer != NULL)
604 iassert(ivilayer->ref_count == 1);
605
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000606 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900607}
608
609static void
610test_get_layer_after_destory_layer(struct test_context *ctx)
611{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000612 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900613 struct ivi_layout_layer *ivilayer;
614
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000615 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900616 iassert(ivilayer != NULL);
617
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000618 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900619
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000620 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900621 iassert(ivilayer == NULL);
622}
623
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900624static void
625test_screen_id(struct test_context *ctx)
626{
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 uint32_t id_screen;
631 int32_t i;
632
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000633 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900634 iassert(screen_length > 0);
635
636 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000637 id_screen = lyt->get_id_of_screen(iviscrns[i]);
638 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900639 }
640
641 if (screen_length > 0)
642 free(iviscrns);
643}
644
645static void
646test_screen_resolution(struct test_context *ctx)
647{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000648 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900649 struct ivi_layout_screen **iviscrns;
650 int32_t screen_length = 0;
651 struct weston_output *output;
652 int32_t width;
653 int32_t height;
654 int32_t i;
655
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000656 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900657 iassert(screen_length > 0);
658
659 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000660 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900661 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000662 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900663 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
664 iassert(width == output->current_mode->width);
665 iassert(height == output->current_mode->height);
666 }
667
668 if (screen_length > 0)
669 free(iviscrns);
670}
671
672static void
673test_screen_render_order(struct test_context *ctx)
674{
675#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000676 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900677 struct ivi_layout_screen **iviscrns;
678 int32_t screen_length = 0;
679 struct ivi_layout_screen *iviscrn;
680 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
681 struct ivi_layout_layer **array;
682 int32_t length = 0;
683 uint32_t i;
684
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000685 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900686 iassert(screen_length > 0);
687
688 if (screen_length <= 0)
689 return;
690
691 iviscrn = iviscrns[0];
692
693 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000694 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900695
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000696 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900697
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000698 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900699
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900701 iassert(length == LAYER_NUM);
702 for (i = 0; i < LAYER_NUM; i++)
703 iassert(array[i] == ivilayers[i]);
704
705 if (length > 0)
706 free(array);
707
708 array = NULL;
709
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000710 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900711
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000712 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900713
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000714 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900715 iassert(length == 0 && array == NULL);
716
717 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000718 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900719
720 free(iviscrns);
721#undef LAYER_NUM
722}
723
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900724static void
725test_screen_bad_resolution(struct test_context *ctx)
726{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000727 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900728 struct ivi_layout_screen **iviscrns;
729 int32_t screen_length = 0;
730 struct ivi_layout_screen *iviscrn;
731 int32_t width;
732 int32_t height;
733
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000734 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900735 iassert(screen_length > 0);
736
737 if (screen_length <= 0)
738 return;
739
740 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000741 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
742 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
743 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900744 free(iviscrns);
745}
746
747static void
748test_screen_bad_render_order(struct test_context *ctx)
749{
750#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000751 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900752 struct ivi_layout_screen **iviscrns;
753 int32_t screen_length;
754 struct ivi_layout_screen *iviscrn;
755 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
756 struct ivi_layout_layer **array;
757 int32_t length = 0;
758 uint32_t i;
759
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000760 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900761 iassert(screen_length > 0);
762
763 if (screen_length <= 0)
764 return;
765
766 iviscrn = iviscrns[0];
767
768 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900770
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000771 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900772
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000773 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900774
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000775 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
776 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
777 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900778
779 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000780 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900781
782 free(iviscrns);
783#undef LAYER_NUM
784}
785
786static void
787test_commit_changes_after_render_order_set_layer_destroy(
788 struct test_context *ctx)
789{
790#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000791 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900792 struct ivi_layout_screen **iviscrns;
793 int32_t screen_length;
794 struct ivi_layout_screen *iviscrn;
795 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
796 uint32_t i;
797
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000798 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900799 iassert(screen_length > 0);
800
801 if (screen_length <= 0)
802 return;
803
804 iviscrn = iviscrns[0];
805
806 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900808
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000809 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900810
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000811 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900812
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000813 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900814
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000815 lyt->layer_destroy(ivilayers[0]);
816 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900817
818 free(iviscrns);
819#undef LAYER_NUM
820}
821
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900822static void
823test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
824 const struct ivi_layout_layer_properties *prop,
825 enum ivi_layout_notification_mask mask,
826 void *userdata)
827{
828 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000829 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900830
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000831 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900832 iassert(prop->source_width == 200);
833 iassert(prop->source_height == 300);
834
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000835 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900836 prop->source_width == 200 && prop->source_height == 300)
837 ctx->user_flags = 1;
838}
839
840static void
841test_layer_properties_changed_notification(struct test_context *ctx)
842{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000843 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900844 struct ivi_layout_layer *ivilayer;
845
846 ctx->user_flags = 0;
847
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000848 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900849
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000850 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900851
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000852 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900853
854 iassert(ctx->user_flags == 0);
855
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000856 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900857 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
858
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000859 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900860
861 iassert(ctx->user_flags == 1);
862
863 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000864 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900865 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
866
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000867 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900868
869 iassert(ctx->user_flags == 0);
870
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000871 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900872
873 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000874 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900875
876 iassert(ctx->user_flags == 0);
877
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000878 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900879}
880
881static void
882test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
883 void *userdata)
884{
885 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000886 const struct ivi_layout_interface *lyt = ctx->layout_interface;
887 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900888
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000889 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900890 iassert(prop->source_width == 200);
891 iassert(prop->source_height == 300);
892
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000893 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900894 prop->source_width == 200 && prop->source_height == 300)
895 ctx->user_flags = 1;
896}
897
898static void
899test_layer_create_notification(struct test_context *ctx)
900{
901#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000902 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900903 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
904 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
905
906 ctx->user_flags = 0;
907
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000908 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900909 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000910 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900911
912 iassert(ctx->user_flags == 1);
913
914 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000915 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900916
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000917 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900918
919 iassert(ctx->user_flags == 0);
920
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000921 lyt->layer_destroy(ivilayers[0]);
922 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900923#undef LAYER_NUM
924}
925
926static void
927test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
928 void *userdata)
929{
930 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000931 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900932 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000933 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900934
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000935 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900936 iassert(prop->source_width == 200);
937 iassert(prop->source_height == 300);
938
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000939 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900940 prop->source_width == 200 && prop->source_height == 300)
941 ctx->user_flags = 1;
942}
943
944static void
945test_layer_remove_notification(struct test_context *ctx)
946{
947#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000948 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900949 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
950 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
951
952 ctx->user_flags = 0;
953
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000954 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
955 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900956 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000957 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900958
959 iassert(ctx->user_flags == 1);
960
961 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000962 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
963 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
964 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900965
966 iassert(ctx->user_flags == 0);
967#undef LAYER_NUM
968}
969
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900970static void
971test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
972 const struct ivi_layout_layer_properties *prop,
973 enum ivi_layout_notification_mask mask,
974 void *userdata)
975{
976}
977
978static void
979test_layer_bad_properties_changed_notification(struct test_context *ctx)
980{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000981 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900982 struct ivi_layout_layer *ivilayer;
983
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000984 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900985
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000986 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900987 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000988 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900989
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000990 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900991}
992
993static void
994test_surface_bad_configure_notification(struct test_context *ctx)
995{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000996 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900997
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000998 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900999}
1000
1001static void
1002test_layer_bad_create_notification(struct test_context *ctx)
1003{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001004 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001005
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001006 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001007}
1008
1009static void
1010test_surface_bad_create_notification(struct test_context *ctx)
1011{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001012 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001013
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001014 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001015}
1016
1017static void
1018test_layer_bad_remove_notification(struct test_context *ctx)
1019{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001020 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001021
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001022 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001023}
1024
1025static void
1026test_surface_bad_remove_notification(struct test_context *ctx)
1027{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001028 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001029
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001030 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001031}
1032
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001033/************************ tests end ********************************/
1034
1035static void
1036run_internal_tests(void *data)
1037{
1038 struct test_context *ctx = data;
1039
1040 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001041 test_surface_bad_destination_rectangle(ctx);
1042 test_surface_bad_orientation(ctx);
1043 test_surface_bad_dimension(ctx);
1044 test_surface_bad_position(ctx);
1045 test_surface_bad_source_rectangle(ctx);
1046 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001047
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001048 test_layer_create(ctx);
1049 test_layer_visibility(ctx);
1050 test_layer_opacity(ctx);
1051 test_layer_orientation(ctx);
1052 test_layer_dimension(ctx);
1053 test_layer_position(ctx);
1054 test_layer_destination_rectangle(ctx);
1055 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001056 test_layer_bad_remove(ctx);
1057 test_layer_bad_visibility(ctx);
1058 test_layer_bad_opacity(ctx);
1059 test_layer_bad_destination_rectangle(ctx);
1060 test_layer_bad_orientation(ctx);
1061 test_layer_bad_dimension(ctx);
1062 test_layer_bad_position(ctx);
1063 test_layer_bad_source_rectangle(ctx);
1064 test_layer_bad_properties(ctx);
1065 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1066 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1067 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1068 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1069 test_commit_changes_after_position_set_layer_destroy(ctx);
1070 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1071 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1072 test_layer_create_duplicate(ctx);
1073 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001074
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001075 test_screen_id(ctx);
1076 test_screen_resolution(ctx);
1077 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001078 test_screen_bad_resolution(ctx);
1079 test_screen_bad_render_order(ctx);
1080 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1081
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001082 test_layer_properties_changed_notification(ctx);
1083 test_layer_create_notification(ctx);
1084 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001085 test_layer_bad_properties_changed_notification(ctx);
1086 test_surface_bad_configure_notification(ctx);
1087 test_layer_bad_create_notification(ctx);
1088 test_surface_bad_create_notification(ctx);
1089 test_layer_bad_remove_notification(ctx);
1090 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001091
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001092 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1093 free(ctx);
1094}
1095
1096int
1097controller_module_init(struct weston_compositor *compositor,
1098 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001099 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001100 size_t iface_version);
1101
1102WL_EXPORT int
1103controller_module_init(struct weston_compositor *compositor,
1104 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001105 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001106 size_t iface_version)
1107{
1108 struct wl_event_loop *loop;
1109 struct test_context *ctx;
1110
1111 /* strict check, since this is an internal test module */
1112 if (iface_version != sizeof(*iface)) {
1113 weston_log("fatal: controller interface mismatch\n");
1114 return -1;
1115 }
1116
1117 ctx = zalloc(sizeof(*ctx));
1118 if (!ctx)
1119 return -1;
1120
1121 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001122 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001123
1124 loop = wl_display_get_event_loop(compositor->wl_display);
1125 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1126
1127 return 0;
1128}