blob: 1ba53b7814751c8f682b84932420aaaa5b42048d [file] [log] [blame]
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001/*
2 * Copyright © 2013 DENSO CORPORATION
3 * Copyright © 2015 Collabora, Ltd.
4 *
Bryce Harrington2cc92972015-06-11 15:39:40 -07005 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
Pekka Paalanen46804ca2015-03-27 11:55:21 +020012 *
Bryce Harrington2cc92972015-06-11 15:39:40 -070013 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
Pekka Paalanen46804ca2015-03-27 11:55:21 +020025 */
26
27#include "config.h"
28
29#include <unistd.h>
30#include <signal.h>
31#include <string.h>
32#include <stdbool.h>
33
Jon Cruz4678bab2015-06-15 15:37:07 -070034#include "src/compositor.h"
35#include "ivi-shell/ivi-layout-export.h"
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +090036#include "ivi-shell/ivi-layout-private.h"
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +090037#include "ivi-test.h"
Pekka Paalanen46804ca2015-03-27 11:55:21 +020038
39struct test_context {
40 struct weston_compositor *compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000041 const struct ivi_layout_interface *layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +090042 uint32_t user_flags;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020043};
44
45static void
46iassert_fail(const char *cond, const char *file, int line,
47 const char *func, struct test_context *ctx)
48{
49 weston_log("Assert failure in %s:%d, %s: '%s'\n",
50 file, line, func, cond);
51 weston_compositor_exit_with_code(ctx->compositor, EXIT_FAILURE);
52}
53
54#define iassert(cond) ({ \
55 bool b_ = (cond); \
56 if (!b_) \
57 iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx); \
58 b_; \
59})
60
61/************************ tests begin ******************************/
62
63/*
64 * These are all internal ivi_layout API tests that do not require
65 * any client objects.
66 */
Pekka Paalanen46804ca2015-03-27 11:55:21 +020067static void
68test_surface_bad_visibility(struct test_context *ctx)
69{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000070 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020071
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000072 iassert(lyt->surface_set_visibility(NULL, true) == IVI_FAILED);
Pekka Paalanen46804ca2015-03-27 11:55:21 +020073
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000074 lyt->commit_changes();
Pekka Paalanen46804ca2015-03-27 11:55:21 +020075}
76
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090077static void
78test_surface_bad_destination_rectangle(struct test_context *ctx)
79{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000080 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090081
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000082 iassert(lyt->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090083}
84
85static void
86test_surface_bad_orientation(struct test_context *ctx)
87{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000088 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090089
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000090 iassert(lyt->surface_set_orientation(NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090091
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000092 iassert(lyt->surface_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090093}
94
95static void
96test_surface_bad_dimension(struct test_context *ctx)
97{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000098 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090099 struct ivi_layout_surface *ivisurf = NULL;
100 int32_t dest_width;
101 int32_t dest_height;
102
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000103 iassert(lyt->surface_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900104
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000105 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900106
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000107 iassert(lyt->surface_get_dimension(NULL, &dest_width, &dest_height) == IVI_FAILED);
108 iassert(lyt->surface_get_dimension(ivisurf, NULL, &dest_height) == IVI_FAILED);
109 iassert(lyt->surface_get_dimension(ivisurf, &dest_width, NULL) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900110}
111
112static void
113test_surface_bad_position(struct test_context *ctx)
114{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000115 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900116 struct ivi_layout_surface *ivisurf = NULL;
117 int32_t dest_x;
118 int32_t dest_y;
119
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000120 iassert(lyt->surface_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900121
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000122 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900123
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000124 iassert(lyt->surface_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED);
125 iassert(lyt->surface_get_position(ivisurf, NULL, &dest_y) == IVI_FAILED);
126 iassert(lyt->surface_get_position(ivisurf, &dest_x, NULL) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900127}
128
129static void
130test_surface_bad_source_rectangle(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 Tanibata16ed5432015-06-22 15:33:59 +0900133
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000134 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900135}
136
137static void
138test_surface_bad_properties(struct test_context *ctx)
139{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000140 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900141
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000142 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900143}
144
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900145static void
146test_layer_create(struct test_context *ctx)
147{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000148 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900149 uint32_t id1;
150 uint32_t id2;
151 struct ivi_layout_layer *ivilayer;
152 struct ivi_layout_layer *new_ivilayer;
153
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000154 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900155 iassert(ivilayer != NULL);
156
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000157 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900158
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000159 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900160 iassert(ivilayer == new_ivilayer);
161
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000162 id1 = lyt->get_id_of_layer(ivilayer);
163 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900164 iassert(id1 == id2);
165
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000166 lyt->layer_destroy(ivilayer);
167 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900168}
169
170static void
171test_layer_visibility(struct test_context *ctx)
172{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000173 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900174 struct ivi_layout_layer *ivilayer;
175 const struct ivi_layout_layer_properties *prop;
176
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000177 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900178 iassert(ivilayer != NULL);
179
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000180 prop = lyt->get_properties_of_layer(ivilayer);
181
182 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000184 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900185
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000186 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900187
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000188 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900189
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900190 iassert(prop->visibility == true);
191
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000192 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900193}
194
195static void
196test_layer_opacity(struct test_context *ctx)
197{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000198 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900199 struct ivi_layout_layer *ivilayer;
200 const struct ivi_layout_layer_properties *prop;
201
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000202 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900203 iassert(ivilayer != NULL);
204
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000205 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900206
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000207 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
209
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000210 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(1.0));
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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000214 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.5));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900215
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900217 iassert(prop->opacity == wl_fixed_from_double(0.5));
218
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000219 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900220}
221
222static void
223test_layer_orientation(struct test_context *ctx)
224{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000225 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900226 struct ivi_layout_layer *ivilayer;
227 const struct ivi_layout_layer_properties *prop;
228
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000229 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900230 iassert(ivilayer != NULL);
231
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000232 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900233
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000234 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900235 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
236
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000237 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900238
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000239 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900240
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000241 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900242
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000243 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900244 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
245
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000246 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900247}
248
249static void
250test_layer_dimension(struct test_context *ctx)
251{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000252 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900253 struct ivi_layout_layer *ivilayer;
254 const struct ivi_layout_layer_properties *prop;
255 int32_t dest_width;
256 int32_t dest_height;
257
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000258 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900259 iassert(ivilayer != NULL);
260
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000261 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900262 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
263 iassert(dest_width == 200);
264 iassert(dest_height == 300);
265
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000266 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900267
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000268 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900269 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
270 iassert(dest_width == 200);
271 iassert(dest_height == 300);
272
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000273 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900274
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000275 iassert(IVI_SUCCEEDED == lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900276 ivilayer, &dest_width, &dest_height));
277 iassert(dest_width == 400);
278 iassert(dest_height == 600);
279
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000280 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900281 iassert(prop->dest_width == 400);
282 iassert(prop->dest_height == 600);
283
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000284 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900285}
286
287static void
288test_layer_position(struct test_context *ctx)
289{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000290 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291 struct ivi_layout_layer *ivilayer;
292 const struct ivi_layout_layer_properties *prop;
293 int32_t dest_x;
294 int32_t dest_y;
295
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000296 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900297 iassert(ivilayer != NULL);
298
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000299 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900300 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
301 iassert(dest_x == 0);
302 iassert(dest_y == 0);
303
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000304 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900305
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000306 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900307 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
308 iassert(dest_x == 0);
309 iassert(dest_y == 0);
310
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000311 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900312
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000313 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900314 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
315 iassert(dest_x == 20);
316 iassert(dest_y == 30);
317
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000318 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900319 iassert(prop->dest_x == 20);
320 iassert(prop->dest_y == 30);
321
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000322 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900323}
324
325static void
326test_layer_destination_rectangle(struct test_context *ctx)
327{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000328 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900329 struct ivi_layout_layer *ivilayer;
330 const struct ivi_layout_layer_properties *prop;
331 int32_t dest_width;
332 int32_t dest_height;
333 int32_t dest_x;
334 int32_t dest_y;
335
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000336 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900337 iassert(ivilayer != NULL);
338
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000339 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900340 iassert(prop->dest_width == 200);
341 iassert(prop->dest_height == 300);
342 iassert(prop->dest_x == 0);
343 iassert(prop->dest_y == 0);
344
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000345 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900346 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
347
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000348 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900349 iassert(prop->dest_width == 200);
350 iassert(prop->dest_height == 300);
351 iassert(prop->dest_x == 0);
352 iassert(prop->dest_y == 0);
353
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000354 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900355
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000356 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900357 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
358 iassert(dest_width == 400);
359 iassert(dest_height == 600);
360
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000361 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900362 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
363 iassert(dest_x == 20);
364 iassert(dest_y == 30);
365
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000366 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900367 iassert(prop->dest_width == 400);
368 iassert(prop->dest_height == 600);
369 iassert(prop->dest_x == 20);
370 iassert(prop->dest_y == 30);
371
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000372 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900373}
374
375static void
376test_layer_source_rectangle(struct test_context *ctx)
377{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000378 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900379 struct ivi_layout_layer *ivilayer;
380 const struct ivi_layout_layer_properties *prop;
381
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000382 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900383 iassert(ivilayer != NULL);
384
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000385 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900386 iassert(prop->source_width == 200);
387 iassert(prop->source_height == 300);
388 iassert(prop->source_x == 0);
389 iassert(prop->source_y == 0);
390
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000391 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900392 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
393
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000394 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900395 iassert(prop->source_width == 200);
396 iassert(prop->source_height == 300);
397 iassert(prop->source_x == 0);
398 iassert(prop->source_y == 0);
399
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000400 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900401
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000402 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900403 iassert(prop->source_width == 400);
404 iassert(prop->source_height == 600);
405 iassert(prop->source_x == 20);
406 iassert(prop->source_y == 30);
407
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000408 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900409}
410
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900411static void
412test_layer_bad_remove(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;
415 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900416}
417
418static void
419test_layer_bad_visibility(struct test_context *ctx)
420{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000421 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900422
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000423 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900424
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900426}
427
428static void
429test_layer_bad_opacity(struct test_context *ctx)
430{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000431 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900432 struct ivi_layout_layer *ivilayer;
433
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000434 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900435 iassert(ivilayer != NULL);
436
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000437 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900438 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
439
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000440 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900441 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
442
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000443 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900444 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
445
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000448 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900449
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000450 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900451 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
452
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000455 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900456
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000457 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900458 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
459
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000460 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900461
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000462 iassert(lyt->layer_get_opacity(NULL) == wl_fixed_from_double(0.0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900463
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000464 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900465}
466
467static void
468test_layer_bad_destination_rectangle(struct test_context *ctx)
469{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000470 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900471
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000472 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900473 NULL, 20, 30, 200, 300) == IVI_FAILED);
474}
475
476static void
477test_layer_bad_orientation(struct test_context *ctx)
478{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000479 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900480
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000481 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900482 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
483
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000484 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900485
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000486 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900487}
488
489static void
490test_layer_bad_dimension(struct test_context *ctx)
491{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000492 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900493 struct ivi_layout_layer *ivilayer;
494 int32_t dest_width;
495 int32_t dest_height;
496
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000497 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900498 iassert(ivilayer != NULL);
499
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900501
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000502 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900503
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000504 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900505 NULL, &dest_width, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000506 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900507 ivilayer, NULL, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000508 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900509 ivilayer, &dest_width, NULL) == IVI_FAILED);
510
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000511 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900512}
513
514static void
515test_layer_bad_position(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 int32_t dest_x;
520 int32_t dest_y;
521
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000522 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900523 iassert(ivilayer != NULL);
524
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000525 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900526
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000527 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900528
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000529 iassert(lyt->layer_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED);
530 iassert(lyt->layer_get_position(ivilayer, NULL, &dest_y) == IVI_FAILED);
531 iassert(lyt->layer_get_position(ivilayer, &dest_x, NULL) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900532
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000533 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900534}
535
536static void
537test_layer_bad_source_rectangle(struct test_context *ctx)
538{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900540
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000541 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900542 NULL, 20, 30, 200, 300) == IVI_FAILED);
543}
544
545static void
546test_layer_bad_properties(struct test_context *ctx)
547{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000548 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900549
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000550 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900551}
552
553static void
554test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
555{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000556 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900557 struct ivi_layout_layer *ivilayer;
558
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000559 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900560 iassert(ivilayer != NULL);
561
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000562 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
563 lyt->layer_destroy(ivilayer);
564 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900565}
566
567static void
568test_commit_changes_after_opacity_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_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900577 ivilayer, wl_fixed_from_double(0.5)) == 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_commit_changes_after_orientation_set_layer_destroy(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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000588 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900589 iassert(ivilayer != NULL);
590
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000591 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900592 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000593 lyt->layer_destroy(ivilayer);
594 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900595}
596
597static void
598test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
599{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000600 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900601 struct ivi_layout_layer *ivilayer;
602
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000603 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900604 iassert(ivilayer != NULL);
605
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000606 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
607 lyt->layer_destroy(ivilayer);
608 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900609}
610
611static void
612test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
613{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000614 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900615 struct ivi_layout_layer *ivilayer;
616
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000617 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900618 iassert(ivilayer != NULL);
619
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000620 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
621 lyt->layer_destroy(ivilayer);
622 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900623}
624
625static void
626test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
627{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000628 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900629 struct ivi_layout_layer *ivilayer;
630
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000631 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900632 iassert(ivilayer != NULL);
633
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000634 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900635 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000636 lyt->layer_destroy(ivilayer);
637 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900638}
639
640static void
641test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
642{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000643 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900644 struct ivi_layout_layer *ivilayer;
645
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900647 iassert(ivilayer != NULL);
648
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900650 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000651 lyt->layer_destroy(ivilayer);
652 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900653}
654
655static void
656test_layer_create_duplicate(struct test_context *ctx)
657{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000658 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900659 struct ivi_layout_layer *ivilayer;
660 struct ivi_layout_layer *duplicatelayer;
661
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000662 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900663 iassert(ivilayer != NULL);
664
665 if (ivilayer != NULL)
666 iassert(ivilayer->ref_count == 1);
667
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000668 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900669 iassert(ivilayer == duplicatelayer);
670
671 if (ivilayer != NULL)
672 iassert(ivilayer->ref_count == 2);
673
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000674 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900675
676 if (ivilayer != NULL)
677 iassert(ivilayer->ref_count == 1);
678
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000679 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900680}
681
682static void
683test_get_layer_after_destory_layer(struct test_context *ctx)
684{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000685 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900686 struct ivi_layout_layer *ivilayer;
687
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000688 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900689 iassert(ivilayer != NULL);
690
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000691 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900692
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000693 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900694 iassert(ivilayer == NULL);
695}
696
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900697static void
698test_screen_id(struct test_context *ctx)
699{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900701 struct ivi_layout_screen **iviscrns;
702 int32_t screen_length = 0;
703 uint32_t id_screen;
704 int32_t i;
705
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000706 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900707 iassert(screen_length > 0);
708
709 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000710 id_screen = lyt->get_id_of_screen(iviscrns[i]);
711 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900712 }
713
714 if (screen_length > 0)
715 free(iviscrns);
716}
717
718static void
719test_screen_resolution(struct test_context *ctx)
720{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000721 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900722 struct ivi_layout_screen **iviscrns;
723 int32_t screen_length = 0;
724 struct weston_output *output;
725 int32_t width;
726 int32_t height;
727 int32_t i;
728
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000729 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900730 iassert(screen_length > 0);
731
732 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000733 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900734 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000735 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900736 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
737 iassert(width == output->current_mode->width);
738 iassert(height == output->current_mode->height);
739 }
740
741 if (screen_length > 0)
742 free(iviscrns);
743}
744
745static void
746test_screen_render_order(struct test_context *ctx)
747{
748#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000749 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900750 struct ivi_layout_screen **iviscrns;
751 int32_t screen_length = 0;
752 struct ivi_layout_screen *iviscrn;
753 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
754 struct ivi_layout_layer **array;
755 int32_t length = 0;
756 uint32_t i;
757
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000758 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900759 iassert(screen_length > 0);
760
761 if (screen_length <= 0)
762 return;
763
764 iviscrn = iviscrns[0];
765
766 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000767 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900768
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900770
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000771 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900772
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000773 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900774 iassert(length == LAYER_NUM);
775 for (i = 0; i < LAYER_NUM; i++)
776 iassert(array[i] == ivilayers[i]);
777
778 if (length > 0)
779 free(array);
780
781 array = NULL;
782
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000783 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900784
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000785 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900786
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000787 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900788 iassert(length == 0 && array == NULL);
789
790 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000791 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900792
793 free(iviscrns);
794#undef LAYER_NUM
795}
796
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900797static void
798test_screen_bad_resolution(struct test_context *ctx)
799{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000800 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900801 struct ivi_layout_screen **iviscrns;
802 int32_t screen_length = 0;
803 struct ivi_layout_screen *iviscrn;
804 int32_t width;
805 int32_t height;
806
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900808 iassert(screen_length > 0);
809
810 if (screen_length <= 0)
811 return;
812
813 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000814 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
815 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
816 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900817 free(iviscrns);
818}
819
820static void
821test_screen_bad_render_order(struct test_context *ctx)
822{
823#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000824 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900825 struct ivi_layout_screen **iviscrns;
826 int32_t screen_length;
827 struct ivi_layout_screen *iviscrn;
828 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
829 struct ivi_layout_layer **array;
830 int32_t length = 0;
831 uint32_t i;
832
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000833 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900834 iassert(screen_length > 0);
835
836 if (screen_length <= 0)
837 return;
838
839 iviscrn = iviscrns[0];
840
841 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000842 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900843
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000844 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900845
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000846 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900847
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000848 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
849 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
850 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900851
852 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000853 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900854
855 free(iviscrns);
856#undef LAYER_NUM
857}
858
859static void
860test_commit_changes_after_render_order_set_layer_destroy(
861 struct test_context *ctx)
862{
863#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000864 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900865 struct ivi_layout_screen **iviscrns;
866 int32_t screen_length;
867 struct ivi_layout_screen *iviscrn;
868 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
869 uint32_t i;
870
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000871 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900872 iassert(screen_length > 0);
873
874 if (screen_length <= 0)
875 return;
876
877 iviscrn = iviscrns[0];
878
879 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000880 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900881
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900883
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000884 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900885
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000886 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900887
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000888 lyt->layer_destroy(ivilayers[0]);
889 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900890
891 free(iviscrns);
892#undef LAYER_NUM
893}
894
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900895static void
896test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
897 const struct ivi_layout_layer_properties *prop,
898 enum ivi_layout_notification_mask mask,
899 void *userdata)
900{
901 struct test_context *ctx = userdata;
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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000904 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900905 iassert(prop->source_width == 200);
906 iassert(prop->source_height == 300);
907
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000908 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900909 prop->source_width == 200 && prop->source_height == 300)
910 ctx->user_flags = 1;
911}
912
913static void
914test_layer_properties_changed_notification(struct test_context *ctx)
915{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000916 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900917 struct ivi_layout_layer *ivilayer;
918
919 ctx->user_flags = 0;
920
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000921 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900922
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000923 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900924
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000925 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900926
927 iassert(ctx->user_flags == 0);
928
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000929 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900930 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
931
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000932 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900933
934 iassert(ctx->user_flags == 1);
935
936 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000937 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900938 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
939
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000940 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900941
942 iassert(ctx->user_flags == 0);
943
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000944 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900945
946 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000947 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900948
949 iassert(ctx->user_flags == 0);
950
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000951 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900952}
953
954static void
955test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
956 void *userdata)
957{
958 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000959 const struct ivi_layout_interface *lyt = ctx->layout_interface;
960 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900961
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000962 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900963 iassert(prop->source_width == 200);
964 iassert(prop->source_height == 300);
965
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000966 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900967 prop->source_width == 200 && prop->source_height == 300)
968 ctx->user_flags = 1;
969}
970
971static void
972test_layer_create_notification(struct test_context *ctx)
973{
974#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000975 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900976 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
977 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
978
979 ctx->user_flags = 0;
980
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000981 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900982 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000983 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900984
985 iassert(ctx->user_flags == 1);
986
987 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000988 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900989
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000990 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900991
992 iassert(ctx->user_flags == 0);
993
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000994 lyt->layer_destroy(ivilayers[0]);
995 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900996#undef LAYER_NUM
997}
998
999static void
1000test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
1001 void *userdata)
1002{
1003 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001004 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001005 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001006 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001007
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001008 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001009 iassert(prop->source_width == 200);
1010 iassert(prop->source_height == 300);
1011
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001012 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001013 prop->source_width == 200 && prop->source_height == 300)
1014 ctx->user_flags = 1;
1015}
1016
1017static void
1018test_layer_remove_notification(struct test_context *ctx)
1019{
1020#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001021 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001022 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
1023 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
1024
1025 ctx->user_flags = 0;
1026
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001027 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
1028 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001029 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001030 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001031
1032 iassert(ctx->user_flags == 1);
1033
1034 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001035 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
1036 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
1037 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001038
1039 iassert(ctx->user_flags == 0);
1040#undef LAYER_NUM
1041}
1042
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001043static void
1044test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
1045 const struct ivi_layout_layer_properties *prop,
1046 enum ivi_layout_notification_mask mask,
1047 void *userdata)
1048{
1049}
1050
1051static void
1052test_layer_bad_properties_changed_notification(struct test_context *ctx)
1053{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001054 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001055 struct ivi_layout_layer *ivilayer;
1056
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001057 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001058
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001059 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001060 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001061 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001062
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001063 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001064}
1065
1066static void
1067test_surface_bad_configure_notification(struct test_context *ctx)
1068{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001069 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001070
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001071 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001072}
1073
1074static void
1075test_layer_bad_create_notification(struct test_context *ctx)
1076{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001077 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001078
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001079 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001080}
1081
1082static void
1083test_surface_bad_create_notification(struct test_context *ctx)
1084{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001085 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001086
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001087 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001088}
1089
1090static void
1091test_layer_bad_remove_notification(struct test_context *ctx)
1092{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001093 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001094
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001095 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001096}
1097
1098static void
1099test_surface_bad_remove_notification(struct test_context *ctx)
1100{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001101 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001102
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001103 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001104}
1105
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001106/************************ tests end ********************************/
1107
1108static void
1109run_internal_tests(void *data)
1110{
1111 struct test_context *ctx = data;
1112
1113 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001114 test_surface_bad_destination_rectangle(ctx);
1115 test_surface_bad_orientation(ctx);
1116 test_surface_bad_dimension(ctx);
1117 test_surface_bad_position(ctx);
1118 test_surface_bad_source_rectangle(ctx);
1119 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001120
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001121 test_layer_create(ctx);
1122 test_layer_visibility(ctx);
1123 test_layer_opacity(ctx);
1124 test_layer_orientation(ctx);
1125 test_layer_dimension(ctx);
1126 test_layer_position(ctx);
1127 test_layer_destination_rectangle(ctx);
1128 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001129 test_layer_bad_remove(ctx);
1130 test_layer_bad_visibility(ctx);
1131 test_layer_bad_opacity(ctx);
1132 test_layer_bad_destination_rectangle(ctx);
1133 test_layer_bad_orientation(ctx);
1134 test_layer_bad_dimension(ctx);
1135 test_layer_bad_position(ctx);
1136 test_layer_bad_source_rectangle(ctx);
1137 test_layer_bad_properties(ctx);
1138 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1139 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1140 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1141 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1142 test_commit_changes_after_position_set_layer_destroy(ctx);
1143 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1144 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1145 test_layer_create_duplicate(ctx);
1146 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001147
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001148 test_screen_id(ctx);
1149 test_screen_resolution(ctx);
1150 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001151 test_screen_bad_resolution(ctx);
1152 test_screen_bad_render_order(ctx);
1153 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1154
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001155 test_layer_properties_changed_notification(ctx);
1156 test_layer_create_notification(ctx);
1157 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001158 test_layer_bad_properties_changed_notification(ctx);
1159 test_surface_bad_configure_notification(ctx);
1160 test_layer_bad_create_notification(ctx);
1161 test_surface_bad_create_notification(ctx);
1162 test_layer_bad_remove_notification(ctx);
1163 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001164
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001165 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1166 free(ctx);
1167}
1168
1169int
1170controller_module_init(struct weston_compositor *compositor,
1171 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001172 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001173 size_t iface_version);
1174
1175WL_EXPORT int
1176controller_module_init(struct weston_compositor *compositor,
1177 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001178 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001179 size_t iface_version)
1180{
1181 struct wl_event_loop *loop;
1182 struct test_context *ctx;
1183
1184 /* strict check, since this is an internal test module */
1185 if (iface_version != sizeof(*iface)) {
1186 weston_log("fatal: controller interface mismatch\n");
1187 return -1;
1188 }
1189
1190 ctx = zalloc(sizeof(*ctx));
1191 if (!ctx)
1192 return -1;
1193
1194 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001195 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001196
1197 loop = wl_display_get_event_loop(compositor->wl_display);
1198 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1199
1200 return 0;
1201}