blob: 2c924e5343e3f52a0d1620ce12f621d35dd38e20 [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
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900104test_surface_bad_source_rectangle(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_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900109}
110
111static void
112test_surface_bad_properties(struct test_context *ctx)
113{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000114 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900115
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000116 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900117}
118
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900119static void
120test_layer_create(struct test_context *ctx)
121{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000122 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900123 uint32_t id1;
124 uint32_t id2;
125 struct ivi_layout_layer *ivilayer;
126 struct ivi_layout_layer *new_ivilayer;
127
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000128 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900129 iassert(ivilayer != NULL);
130
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000131 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900132
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000133 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900134 iassert(ivilayer == new_ivilayer);
135
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000136 id1 = lyt->get_id_of_layer(ivilayer);
137 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900138 iassert(id1 == id2);
139
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000140 lyt->layer_destroy(ivilayer);
141 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900142}
143
144static void
145test_layer_visibility(struct test_context *ctx)
146{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000147 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900148 struct ivi_layout_layer *ivilayer;
149 const struct ivi_layout_layer_properties *prop;
150
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000151 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900152 iassert(ivilayer != NULL);
153
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000154 prop = lyt->get_properties_of_layer(ivilayer);
155
156 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900157
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000158 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900159
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000160 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900161
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000162 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900163
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900164 iassert(prop->visibility == true);
165
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000166 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900167}
168
169static void
170test_layer_opacity(struct test_context *ctx)
171{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000172 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900173 struct ivi_layout_layer *ivilayer;
174 const struct ivi_layout_layer_properties *prop;
175
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000176 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900177 iassert(ivilayer != NULL);
178
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000179 prop = lyt->get_properties_of_layer(ivilayer);
180 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900181
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000182 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
184
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000185 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900186
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000187 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900188
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900189 iassert(prop->opacity == wl_fixed_from_double(0.5));
190
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000191 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900192}
193
194static void
195test_layer_orientation(struct test_context *ctx)
196{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000197 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198 struct ivi_layout_layer *ivilayer;
199 const struct ivi_layout_layer_properties *prop;
200
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000201 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900202 iassert(ivilayer != NULL);
203
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000204 prop = lyt->get_properties_of_layer(ivilayer);
205 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900206
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000207 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
209
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000210 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900211
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000212 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900213
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900214 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
215
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900217}
218
219static void
220test_layer_dimension(struct test_context *ctx)
221{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000222 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900223 struct ivi_layout_layer *ivilayer;
224 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900225
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000226 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900227 iassert(ivilayer != NULL);
228
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000229 prop = lyt->get_properties_of_layer(ivilayer);
230 iassert(prop->dest_width == 200);
231 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900232
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000233 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900234
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000235 iassert(prop->dest_width == 200);
236 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900237
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000238 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900239
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900240 iassert(prop->dest_width == 400);
241 iassert(prop->dest_height == 600);
242
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000243 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900244}
245
246static void
247test_layer_position(struct test_context *ctx)
248{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000249 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900250 struct ivi_layout_layer *ivilayer;
251 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900252
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000253 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900254 iassert(ivilayer != NULL);
255
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000256 prop = lyt->get_properties_of_layer(ivilayer);
257 iassert(prop->dest_x == 0);
258 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900259
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000260 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900261
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000262 iassert(prop->dest_x == 0);
263 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900264
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000265 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900266
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000267 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900268 iassert(prop->dest_x == 20);
269 iassert(prop->dest_y == 30);
270
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000271 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900272}
273
274static void
275test_layer_destination_rectangle(struct test_context *ctx)
276{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000277 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900278 struct ivi_layout_layer *ivilayer;
279 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900280
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000281 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900282 iassert(ivilayer != NULL);
283
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000284 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900285 iassert(prop->dest_width == 200);
286 iassert(prop->dest_height == 300);
287 iassert(prop->dest_x == 0);
288 iassert(prop->dest_y == 0);
289
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000290 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
292
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000293 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900294 iassert(prop->dest_width == 200);
295 iassert(prop->dest_height == 300);
296 iassert(prop->dest_x == 0);
297 iassert(prop->dest_y == 0);
298
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000299 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900300
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900301 iassert(prop->dest_width == 400);
302 iassert(prop->dest_height == 600);
303 iassert(prop->dest_x == 20);
304 iassert(prop->dest_y == 30);
305
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000306 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900307}
308
309static void
310test_layer_source_rectangle(struct test_context *ctx)
311{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000312 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900313 struct ivi_layout_layer *ivilayer;
314 const struct ivi_layout_layer_properties *prop;
315
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000316 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900317 iassert(ivilayer != NULL);
318
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000319 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900320 iassert(prop->source_width == 200);
321 iassert(prop->source_height == 300);
322 iassert(prop->source_x == 0);
323 iassert(prop->source_y == 0);
324
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000325 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900326 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
327
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 == 200);
330 iassert(prop->source_height == 300);
331 iassert(prop->source_x == 0);
332 iassert(prop->source_y == 0);
333
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000334 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900335
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000336 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900337 iassert(prop->source_width == 400);
338 iassert(prop->source_height == 600);
339 iassert(prop->source_x == 20);
340 iassert(prop->source_y == 30);
341
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000342 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900343}
344
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900345static void
346test_layer_bad_remove(struct test_context *ctx)
347{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000348 const struct ivi_layout_interface *lyt = ctx->layout_interface;
349 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900350}
351
352static void
353test_layer_bad_visibility(struct test_context *ctx)
354{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000355 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900356
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000357 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900358
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000359 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900360}
361
362static void
363test_layer_bad_opacity(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 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000367 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900368
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900370 iassert(ivilayer != NULL);
371
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000372 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900373 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
374
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000375 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900376 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
377
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)) == 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 prop = lyt->get_properties_of_layer(ivilayer);
384 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900385
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000386 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900387 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
388
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000389 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900390
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000391 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900392
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000393 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900394 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
395
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000396 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900397
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000398 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900399}
400
401static void
402test_layer_bad_destination_rectangle(struct test_context *ctx)
403{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000404 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900405
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000406 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900407 NULL, 20, 30, 200, 300) == IVI_FAILED);
408}
409
410static void
411test_layer_bad_orientation(struct test_context *ctx)
412{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000413 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900414
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000415 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900416 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
417
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000418 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900419}
420
421static void
422test_layer_bad_dimension(struct test_context *ctx)
423{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000424 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900425 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900426
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000427 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900428 iassert(ivilayer != NULL);
429
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000430 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900431
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000432 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900433
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000434 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900435}
436
437static void
438test_layer_bad_position(struct test_context *ctx)
439{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000440 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900441 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900442
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000443 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900444 iassert(ivilayer != NULL);
445
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000448 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900449
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000450 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900451}
452
453static void
454test_layer_bad_source_rectangle(struct test_context *ctx)
455{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000456 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900457
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000458 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900459 NULL, 20, 30, 200, 300) == IVI_FAILED);
460}
461
462static void
463test_layer_bad_properties(struct test_context *ctx)
464{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000465 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900466
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000467 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900468}
469
470static void
471test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
472{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000473 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900474 struct ivi_layout_layer *ivilayer;
475
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000476 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900477 iassert(ivilayer != NULL);
478
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000479 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
480 lyt->layer_destroy(ivilayer);
481 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900482}
483
484static void
485test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
486{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000487 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900488 struct ivi_layout_layer *ivilayer;
489
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900491 iassert(ivilayer != NULL);
492
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000493 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900494 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000495 lyt->layer_destroy(ivilayer);
496 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900497}
498
499static void
500test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
501{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000502 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900503 struct ivi_layout_layer *ivilayer;
504
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000505 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900506 iassert(ivilayer != NULL);
507
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000508 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900509 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000510 lyt->layer_destroy(ivilayer);
511 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900512}
513
514static void
515test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
516{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000517 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900518 struct ivi_layout_layer *ivilayer;
519
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000520 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900521 iassert(ivilayer != NULL);
522
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000523 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
524 lyt->layer_destroy(ivilayer);
525 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900526}
527
528static void
529test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
530{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000531 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900532 struct ivi_layout_layer *ivilayer;
533
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000534 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900535 iassert(ivilayer != NULL);
536
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000537 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
538 lyt->layer_destroy(ivilayer);
539 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900540}
541
542static void
543test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
544{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000545 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900546 struct ivi_layout_layer *ivilayer;
547
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000548 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900549 iassert(ivilayer != NULL);
550
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000551 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900552 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000553 lyt->layer_destroy(ivilayer);
554 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900555}
556
557static void
558test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
559{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000560 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900561 struct ivi_layout_layer *ivilayer;
562
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000563 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900564 iassert(ivilayer != NULL);
565
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000566 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900567 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000568 lyt->layer_destroy(ivilayer);
569 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900570}
571
572static void
573test_layer_create_duplicate(struct test_context *ctx)
574{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000575 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900576 struct ivi_layout_layer *ivilayer;
577 struct ivi_layout_layer *duplicatelayer;
578
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000579 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900580 iassert(ivilayer != NULL);
581
582 if (ivilayer != NULL)
583 iassert(ivilayer->ref_count == 1);
584
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000585 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900586 iassert(ivilayer == duplicatelayer);
587
588 if (ivilayer != NULL)
589 iassert(ivilayer->ref_count == 2);
590
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000591 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900592
593 if (ivilayer != NULL)
594 iassert(ivilayer->ref_count == 1);
595
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000596 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900597}
598
599static void
600test_get_layer_after_destory_layer(struct test_context *ctx)
601{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000602 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900603 struct ivi_layout_layer *ivilayer;
604
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000605 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900606 iassert(ivilayer != NULL);
607
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000608 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900609
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000610 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900611 iassert(ivilayer == NULL);
612}
613
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900614static void
615test_screen_id(struct test_context *ctx)
616{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000617 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900618 struct ivi_layout_screen **iviscrns;
619 int32_t screen_length = 0;
620 uint32_t id_screen;
621 int32_t i;
622
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000623 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900624 iassert(screen_length > 0);
625
626 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000627 id_screen = lyt->get_id_of_screen(iviscrns[i]);
628 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900629 }
630
631 if (screen_length > 0)
632 free(iviscrns);
633}
634
635static void
636test_screen_resolution(struct test_context *ctx)
637{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000638 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900639 struct ivi_layout_screen **iviscrns;
640 int32_t screen_length = 0;
641 struct weston_output *output;
642 int32_t width;
643 int32_t height;
644 int32_t i;
645
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900647 iassert(screen_length > 0);
648
649 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000650 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900651 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000652 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900653 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
654 iassert(width == output->current_mode->width);
655 iassert(height == output->current_mode->height);
656 }
657
658 if (screen_length > 0)
659 free(iviscrns);
660}
661
662static void
663test_screen_render_order(struct test_context *ctx)
664{
665#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000666 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900667 struct ivi_layout_screen **iviscrns;
668 int32_t screen_length = 0;
669 struct ivi_layout_screen *iviscrn;
670 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
671 struct ivi_layout_layer **array;
672 int32_t length = 0;
673 uint32_t i;
674
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000675 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900676 iassert(screen_length > 0);
677
678 if (screen_length <= 0)
679 return;
680
681 iviscrn = iviscrns[0];
682
683 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000684 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900685
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000686 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900687
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000688 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900689
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000690 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900691 iassert(length == LAYER_NUM);
692 for (i = 0; i < LAYER_NUM; i++)
693 iassert(array[i] == ivilayers[i]);
694
695 if (length > 0)
696 free(array);
697
698 array = NULL;
699
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900701
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000702 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900703
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000704 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900705 iassert(length == 0 && array == NULL);
706
707 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000708 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900709
710 free(iviscrns);
711#undef LAYER_NUM
712}
713
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900714static void
715test_screen_bad_resolution(struct test_context *ctx)
716{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000717 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900718 struct ivi_layout_screen **iviscrns;
719 int32_t screen_length = 0;
720 struct ivi_layout_screen *iviscrn;
721 int32_t width;
722 int32_t height;
723
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000724 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900725 iassert(screen_length > 0);
726
727 if (screen_length <= 0)
728 return;
729
730 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000731 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
732 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
733 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900734 free(iviscrns);
735}
736
737static void
738test_screen_bad_render_order(struct test_context *ctx)
739{
740#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000741 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900742 struct ivi_layout_screen **iviscrns;
743 int32_t screen_length;
744 struct ivi_layout_screen *iviscrn;
745 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
746 struct ivi_layout_layer **array;
747 int32_t length = 0;
748 uint32_t i;
749
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000750 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900751 iassert(screen_length > 0);
752
753 if (screen_length <= 0)
754 return;
755
756 iviscrn = iviscrns[0];
757
758 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000759 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900760
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000761 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900762
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000763 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900764
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000765 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
766 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
767 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900768
769 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000770 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900771
772 free(iviscrns);
773#undef LAYER_NUM
774}
775
776static void
777test_commit_changes_after_render_order_set_layer_destroy(
778 struct test_context *ctx)
779{
780#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000781 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900782 struct ivi_layout_screen **iviscrns;
783 int32_t screen_length;
784 struct ivi_layout_screen *iviscrn;
785 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
786 uint32_t i;
787
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000788 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900789 iassert(screen_length > 0);
790
791 if (screen_length <= 0)
792 return;
793
794 iviscrn = iviscrns[0];
795
796 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000797 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900798
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000799 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900800
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000801 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900802
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000803 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900804
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000805 lyt->layer_destroy(ivilayers[0]);
806 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900807
808 free(iviscrns);
809#undef LAYER_NUM
810}
811
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900812static void
813test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
814 const struct ivi_layout_layer_properties *prop,
815 enum ivi_layout_notification_mask mask,
816 void *userdata)
817{
818 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000819 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900820
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000821 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900822 iassert(prop->source_width == 200);
823 iassert(prop->source_height == 300);
824
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000825 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900826 prop->source_width == 200 && prop->source_height == 300)
827 ctx->user_flags = 1;
828}
829
830static void
831test_layer_properties_changed_notification(struct test_context *ctx)
832{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000833 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900834 struct ivi_layout_layer *ivilayer;
835
836 ctx->user_flags = 0;
837
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000838 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900839
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000840 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900841
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000842 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900843
844 iassert(ctx->user_flags == 0);
845
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000846 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900847 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
848
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000849 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900850
851 iassert(ctx->user_flags == 1);
852
853 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000854 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900855 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
856
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000857 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900858
859 iassert(ctx->user_flags == 0);
860
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000861 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900862
863 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000864 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900865
866 iassert(ctx->user_flags == 0);
867
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000868 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900869}
870
871static void
872test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
873 void *userdata)
874{
875 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000876 const struct ivi_layout_interface *lyt = ctx->layout_interface;
877 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900878
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000879 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900880 iassert(prop->source_width == 200);
881 iassert(prop->source_height == 300);
882
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000883 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900884 prop->source_width == 200 && prop->source_height == 300)
885 ctx->user_flags = 1;
886}
887
888static void
889test_layer_create_notification(struct test_context *ctx)
890{
891#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000892 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900893 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
894 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
895
896 ctx->user_flags = 0;
897
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000898 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900899 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000900 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900901
902 iassert(ctx->user_flags == 1);
903
904 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000905 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900906
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000907 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900908
909 iassert(ctx->user_flags == 0);
910
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000911 lyt->layer_destroy(ivilayers[0]);
912 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900913#undef LAYER_NUM
914}
915
916static void
917test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
918 void *userdata)
919{
920 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000921 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900922 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000923 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900924
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000925 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900926 iassert(prop->source_width == 200);
927 iassert(prop->source_height == 300);
928
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000929 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900930 prop->source_width == 200 && prop->source_height == 300)
931 ctx->user_flags = 1;
932}
933
934static void
935test_layer_remove_notification(struct test_context *ctx)
936{
937#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000938 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900939 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
940 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
941
942 ctx->user_flags = 0;
943
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000944 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
945 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900946 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000947 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900948
949 iassert(ctx->user_flags == 1);
950
951 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000952 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
953 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
954 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900955
956 iassert(ctx->user_flags == 0);
957#undef LAYER_NUM
958}
959
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900960static void
961test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
962 const struct ivi_layout_layer_properties *prop,
963 enum ivi_layout_notification_mask mask,
964 void *userdata)
965{
966}
967
968static void
969test_layer_bad_properties_changed_notification(struct test_context *ctx)
970{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000971 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900972 struct ivi_layout_layer *ivilayer;
973
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000974 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900975
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000976 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900977 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000978 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900979
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000980 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900981}
982
983static void
984test_surface_bad_configure_notification(struct test_context *ctx)
985{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000986 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900987
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000988 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900989}
990
991static void
992test_layer_bad_create_notification(struct test_context *ctx)
993{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000994 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900995
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000996 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900997}
998
999static void
1000test_surface_bad_create_notification(struct test_context *ctx)
1001{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001002 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001003
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001004 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001005}
1006
1007static void
1008test_layer_bad_remove_notification(struct test_context *ctx)
1009{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001010 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001011
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001012 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001013}
1014
1015static void
1016test_surface_bad_remove_notification(struct test_context *ctx)
1017{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001018 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001019
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001020 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001021}
1022
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001023/************************ tests end ********************************/
1024
1025static void
1026run_internal_tests(void *data)
1027{
1028 struct test_context *ctx = data;
1029
1030 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001031 test_surface_bad_destination_rectangle(ctx);
1032 test_surface_bad_orientation(ctx);
1033 test_surface_bad_dimension(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001034 test_surface_bad_source_rectangle(ctx);
1035 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001036
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001037 test_layer_create(ctx);
1038 test_layer_visibility(ctx);
1039 test_layer_opacity(ctx);
1040 test_layer_orientation(ctx);
1041 test_layer_dimension(ctx);
1042 test_layer_position(ctx);
1043 test_layer_destination_rectangle(ctx);
1044 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001045 test_layer_bad_remove(ctx);
1046 test_layer_bad_visibility(ctx);
1047 test_layer_bad_opacity(ctx);
1048 test_layer_bad_destination_rectangle(ctx);
1049 test_layer_bad_orientation(ctx);
1050 test_layer_bad_dimension(ctx);
1051 test_layer_bad_position(ctx);
1052 test_layer_bad_source_rectangle(ctx);
1053 test_layer_bad_properties(ctx);
1054 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1055 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1056 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1057 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1058 test_commit_changes_after_position_set_layer_destroy(ctx);
1059 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1060 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1061 test_layer_create_duplicate(ctx);
1062 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001063
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001064 test_screen_id(ctx);
1065 test_screen_resolution(ctx);
1066 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001067 test_screen_bad_resolution(ctx);
1068 test_screen_bad_render_order(ctx);
1069 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1070
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001071 test_layer_properties_changed_notification(ctx);
1072 test_layer_create_notification(ctx);
1073 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001074 test_layer_bad_properties_changed_notification(ctx);
1075 test_surface_bad_configure_notification(ctx);
1076 test_layer_bad_create_notification(ctx);
1077 test_surface_bad_create_notification(ctx);
1078 test_layer_bad_remove_notification(ctx);
1079 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001080
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001081 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1082 free(ctx);
1083}
1084
1085int
1086controller_module_init(struct weston_compositor *compositor,
1087 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001088 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001089 size_t iface_version);
1090
1091WL_EXPORT int
1092controller_module_init(struct weston_compositor *compositor,
1093 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001094 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001095 size_t iface_version)
1096{
1097 struct wl_event_loop *loop;
1098 struct test_context *ctx;
1099
1100 /* strict check, since this is an internal test module */
1101 if (iface_version != sizeof(*iface)) {
1102 weston_log("fatal: controller interface mismatch\n");
1103 return -1;
1104 }
1105
1106 ctx = zalloc(sizeof(*ctx));
1107 if (!ctx)
1108 return -1;
1109
1110 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001111 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001112
1113 loop = wl_display_get_event_loop(compositor->wl_display);
1114 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1115
1116 return 0;
1117}