blob: ec4c8d3a11e77910d329cadc6b25c5ef00f78cd4 [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\)0c0e51e2015-10-15 14:51:41 +0000180 iassert(lyt->layer_get_visibility(ivilayer) == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900181
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000182 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000184 iassert(lyt->layer_get_visibility(ivilayer) == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900185
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000186 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900187
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000188 iassert(lyt->layer_get_visibility(ivilayer) == true);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900189
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000190 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900191 iassert(prop->visibility == true);
192
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000193 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900194}
195
196static void
197test_layer_opacity(struct test_context *ctx)
198{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000199 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900200 struct ivi_layout_layer *ivilayer;
201 const struct ivi_layout_layer_properties *prop;
202
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000203 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900204 iassert(ivilayer != NULL);
205
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000206 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900207
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000208 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900209 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
210
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000211 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900212
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000213 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900214
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000215 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.5));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900216
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000217 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900218 iassert(prop->opacity == wl_fixed_from_double(0.5));
219
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000220 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900221}
222
223static void
224test_layer_orientation(struct test_context *ctx)
225{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000226 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900227 struct ivi_layout_layer *ivilayer;
228 const struct ivi_layout_layer_properties *prop;
229
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000230 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231 iassert(ivilayer != NULL);
232
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000233 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900234
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000235 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900236 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
237
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000238 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900239
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000240 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900241
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000242 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900243
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000244 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900245 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
246
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000247 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900248}
249
250static void
251test_layer_dimension(struct test_context *ctx)
252{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000253 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900254 struct ivi_layout_layer *ivilayer;
255 const struct ivi_layout_layer_properties *prop;
256 int32_t dest_width;
257 int32_t dest_height;
258
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000259 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900260 iassert(ivilayer != NULL);
261
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000262 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900263 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
264 iassert(dest_width == 200);
265 iassert(dest_height == 300);
266
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000267 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900268
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000269 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900270 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
271 iassert(dest_width == 200);
272 iassert(dest_height == 300);
273
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000274 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900275
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000276 iassert(IVI_SUCCEEDED == lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900277 ivilayer, &dest_width, &dest_height));
278 iassert(dest_width == 400);
279 iassert(dest_height == 600);
280
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000281 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900282 iassert(prop->dest_width == 400);
283 iassert(prop->dest_height == 600);
284
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000285 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900286}
287
288static void
289test_layer_position(struct test_context *ctx)
290{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000291 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900292 struct ivi_layout_layer *ivilayer;
293 const struct ivi_layout_layer_properties *prop;
294 int32_t dest_x;
295 int32_t dest_y;
296
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000297 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900298 iassert(ivilayer != NULL);
299
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000300 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900301 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
302 iassert(dest_x == 0);
303 iassert(dest_y == 0);
304
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000305 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900306
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000307 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900308 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
309 iassert(dest_x == 0);
310 iassert(dest_y == 0);
311
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000312 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900313
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000314 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900315 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
316 iassert(dest_x == 20);
317 iassert(dest_y == 30);
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->dest_x == 20);
321 iassert(prop->dest_y == 30);
322
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000323 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900324}
325
326static void
327test_layer_destination_rectangle(struct test_context *ctx)
328{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000329 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900330 struct ivi_layout_layer *ivilayer;
331 const struct ivi_layout_layer_properties *prop;
332 int32_t dest_width;
333 int32_t dest_height;
334 int32_t dest_x;
335 int32_t dest_y;
336
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000337 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900338 iassert(ivilayer != NULL);
339
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000340 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900341 iassert(prop->dest_width == 200);
342 iassert(prop->dest_height == 300);
343 iassert(prop->dest_x == 0);
344 iassert(prop->dest_y == 0);
345
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900347 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
348
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000349 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900350 iassert(prop->dest_width == 200);
351 iassert(prop->dest_height == 300);
352 iassert(prop->dest_x == 0);
353 iassert(prop->dest_y == 0);
354
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000355 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900356
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000357 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900358 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
359 iassert(dest_width == 400);
360 iassert(dest_height == 600);
361
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000362 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900363 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
364 iassert(dest_x == 20);
365 iassert(dest_y == 30);
366
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000367 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900368 iassert(prop->dest_width == 400);
369 iassert(prop->dest_height == 600);
370 iassert(prop->dest_x == 20);
371 iassert(prop->dest_y == 30);
372
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000373 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900374}
375
376static void
377test_layer_source_rectangle(struct test_context *ctx)
378{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000379 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900380 struct ivi_layout_layer *ivilayer;
381 const struct ivi_layout_layer_properties *prop;
382
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000383 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900384 iassert(ivilayer != NULL);
385
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000386 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900387 iassert(prop->source_width == 200);
388 iassert(prop->source_height == 300);
389 iassert(prop->source_x == 0);
390 iassert(prop->source_y == 0);
391
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000392 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900393 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
394
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000395 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900396 iassert(prop->source_width == 200);
397 iassert(prop->source_height == 300);
398 iassert(prop->source_x == 0);
399 iassert(prop->source_y == 0);
400
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000401 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900402
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000403 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900404 iassert(prop->source_width == 400);
405 iassert(prop->source_height == 600);
406 iassert(prop->source_x == 20);
407 iassert(prop->source_y == 30);
408
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000409 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900410}
411
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900412static void
413test_layer_bad_remove(struct test_context *ctx)
414{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000415 const struct ivi_layout_interface *lyt = ctx->layout_interface;
416 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417}
418
419static void
420test_layer_bad_visibility(struct test_context *ctx)
421{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000422 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900423
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000424 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900425
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000426 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900427
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000428 iassert(lyt->layer_get_visibility(NULL) == false);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900429}
430
431static void
432test_layer_bad_opacity(struct test_context *ctx)
433{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000434 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900435 struct ivi_layout_layer *ivilayer;
436
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000437 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900438 iassert(ivilayer != NULL);
439
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000440 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900441 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
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(0.3)) == IVI_SUCCEEDED);
445
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
448
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000449 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900450
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000451 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900452
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
455
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000456 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900457
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000458 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900459
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000460 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900461 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
462
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000463 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900464
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000465 iassert(lyt->layer_get_opacity(NULL) == wl_fixed_from_double(0.0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900466
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000467 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900468}
469
470static void
471test_layer_bad_destination_rectangle(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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900476 NULL, 20, 30, 200, 300) == IVI_FAILED);
477}
478
479static void
480test_layer_bad_orientation(struct test_context *ctx)
481{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000482 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900483
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000484 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900485 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
486
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000487 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900488
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000489 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900490}
491
492static void
493test_layer_bad_dimension(struct test_context *ctx)
494{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000495 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900496 struct ivi_layout_layer *ivilayer;
497 int32_t dest_width;
498 int32_t dest_height;
499
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900501 iassert(ivilayer != NULL);
502
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000503 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900504
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000505 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900506
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000507 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900508 NULL, &dest_width, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900510 ivilayer, NULL, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000511 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900512 ivilayer, &dest_width, NULL) == IVI_FAILED);
513
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000514 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900515}
516
517static void
518test_layer_bad_position(struct test_context *ctx)
519{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000520 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900521 struct ivi_layout_layer *ivilayer;
522 int32_t dest_x;
523 int32_t dest_y;
524
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000525 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900526 iassert(ivilayer != NULL);
527
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000528 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900529
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000530 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900531
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000532 iassert(lyt->layer_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED);
533 iassert(lyt->layer_get_position(ivilayer, NULL, &dest_y) == IVI_FAILED);
534 iassert(lyt->layer_get_position(ivilayer, &dest_x, NULL) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900535
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000536 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900537}
538
539static void
540test_layer_bad_source_rectangle(struct test_context *ctx)
541{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000542 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900543
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000544 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900545 NULL, 20, 30, 200, 300) == IVI_FAILED);
546}
547
548static void
549test_layer_bad_properties(struct test_context *ctx)
550{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000551 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900552
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000553 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900554}
555
556static void
557test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
558{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000559 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900560 struct ivi_layout_layer *ivilayer;
561
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000562 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900563 iassert(ivilayer != NULL);
564
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000565 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
566 lyt->layer_destroy(ivilayer);
567 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900568}
569
570static void
571test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
572{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000573 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900574 struct ivi_layout_layer *ivilayer;
575
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000576 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900577 iassert(ivilayer != NULL);
578
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000579 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900580 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000581 lyt->layer_destroy(ivilayer);
582 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900583}
584
585static void
586test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
587{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000588 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900589 struct ivi_layout_layer *ivilayer;
590
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000591 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900592 iassert(ivilayer != NULL);
593
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000594 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900595 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000596 lyt->layer_destroy(ivilayer);
597 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900598}
599
600static void
601test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
602{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000603 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900604 struct ivi_layout_layer *ivilayer;
605
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000606 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900607 iassert(ivilayer != NULL);
608
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000609 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
610 lyt->layer_destroy(ivilayer);
611 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900612}
613
614static void
615test_commit_changes_after_position_set_layer_destroy(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 Tanibata17d44942015-06-22 15:35:12 +0900618 struct ivi_layout_layer *ivilayer;
619
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000620 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900621 iassert(ivilayer != NULL);
622
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000623 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
624 lyt->layer_destroy(ivilayer);
625 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900626}
627
628static void
629test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
630{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000631 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900632 struct ivi_layout_layer *ivilayer;
633
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000634 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900635 iassert(ivilayer != NULL);
636
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000637 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900638 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000639 lyt->layer_destroy(ivilayer);
640 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900641}
642
643static void
644test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
645{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900647 struct ivi_layout_layer *ivilayer;
648
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900650 iassert(ivilayer != NULL);
651
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000652 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900653 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000654 lyt->layer_destroy(ivilayer);
655 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900656}
657
658static void
659test_layer_create_duplicate(struct test_context *ctx)
660{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000661 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900662 struct ivi_layout_layer *ivilayer;
663 struct ivi_layout_layer *duplicatelayer;
664
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000665 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900666 iassert(ivilayer != NULL);
667
668 if (ivilayer != NULL)
669 iassert(ivilayer->ref_count == 1);
670
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000671 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900672 iassert(ivilayer == duplicatelayer);
673
674 if (ivilayer != NULL)
675 iassert(ivilayer->ref_count == 2);
676
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000677 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900678
679 if (ivilayer != NULL)
680 iassert(ivilayer->ref_count == 1);
681
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000682 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900683}
684
685static void
686test_get_layer_after_destory_layer(struct test_context *ctx)
687{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000688 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900689 struct ivi_layout_layer *ivilayer;
690
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000691 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900692 iassert(ivilayer != NULL);
693
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000694 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900695
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000696 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900697 iassert(ivilayer == NULL);
698}
699
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900700static void
701test_screen_id(struct test_context *ctx)
702{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000703 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900704 struct ivi_layout_screen **iviscrns;
705 int32_t screen_length = 0;
706 uint32_t id_screen;
707 int32_t i;
708
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000709 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900710 iassert(screen_length > 0);
711
712 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000713 id_screen = lyt->get_id_of_screen(iviscrns[i]);
714 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900715 }
716
717 if (screen_length > 0)
718 free(iviscrns);
719}
720
721static void
722test_screen_resolution(struct test_context *ctx)
723{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000724 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900725 struct ivi_layout_screen **iviscrns;
726 int32_t screen_length = 0;
727 struct weston_output *output;
728 int32_t width;
729 int32_t height;
730 int32_t i;
731
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000732 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900733 iassert(screen_length > 0);
734
735 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000736 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900737 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000738 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900739 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
740 iassert(width == output->current_mode->width);
741 iassert(height == output->current_mode->height);
742 }
743
744 if (screen_length > 0)
745 free(iviscrns);
746}
747
748static void
749test_screen_render_order(struct test_context *ctx)
750{
751#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000752 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900753 struct ivi_layout_screen **iviscrns;
754 int32_t screen_length = 0;
755 struct ivi_layout_screen *iviscrn;
756 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
757 struct ivi_layout_layer **array;
758 int32_t length = 0;
759 uint32_t i;
760
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000761 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900762 iassert(screen_length > 0);
763
764 if (screen_length <= 0)
765 return;
766
767 iviscrn = iviscrns[0];
768
769 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000770 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900771
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000772 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900773
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900775
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000776 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900777 iassert(length == LAYER_NUM);
778 for (i = 0; i < LAYER_NUM; i++)
779 iassert(array[i] == ivilayers[i]);
780
781 if (length > 0)
782 free(array);
783
784 array = NULL;
785
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000786 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900787
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000788 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900789
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000790 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900791 iassert(length == 0 && array == NULL);
792
793 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000794 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900795
796 free(iviscrns);
797#undef LAYER_NUM
798}
799
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900800static void
801test_screen_bad_resolution(struct test_context *ctx)
802{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000803 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900804 struct ivi_layout_screen **iviscrns;
805 int32_t screen_length = 0;
806 struct ivi_layout_screen *iviscrn;
807 int32_t width;
808 int32_t height;
809
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000810 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900811 iassert(screen_length > 0);
812
813 if (screen_length <= 0)
814 return;
815
816 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000817 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
818 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
819 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900820 free(iviscrns);
821}
822
823static void
824test_screen_bad_render_order(struct test_context *ctx)
825{
826#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000827 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900828 struct ivi_layout_screen **iviscrns;
829 int32_t screen_length;
830 struct ivi_layout_screen *iviscrn;
831 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
832 struct ivi_layout_layer **array;
833 int32_t length = 0;
834 uint32_t i;
835
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000836 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900837 iassert(screen_length > 0);
838
839 if (screen_length <= 0)
840 return;
841
842 iviscrn = iviscrns[0];
843
844 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000845 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900846
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000847 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900848
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000849 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900850
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000851 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
852 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
853 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900854
855 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000856 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900857
858 free(iviscrns);
859#undef LAYER_NUM
860}
861
862static void
863test_commit_changes_after_render_order_set_layer_destroy(
864 struct test_context *ctx)
865{
866#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000867 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900868 struct ivi_layout_screen **iviscrns;
869 int32_t screen_length;
870 struct ivi_layout_screen *iviscrn;
871 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
872 uint32_t i;
873
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000874 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900875 iassert(screen_length > 0);
876
877 if (screen_length <= 0)
878 return;
879
880 iviscrn = iviscrns[0];
881
882 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000883 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900884
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000885 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900886
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000887 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900888
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000889 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900890
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000891 lyt->layer_destroy(ivilayers[0]);
892 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900893
894 free(iviscrns);
895#undef LAYER_NUM
896}
897
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900898static void
899test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
900 const struct ivi_layout_layer_properties *prop,
901 enum ivi_layout_notification_mask mask,
902 void *userdata)
903{
904 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000905 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900906
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000907 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900908 iassert(prop->source_width == 200);
909 iassert(prop->source_height == 300);
910
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000911 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900912 prop->source_width == 200 && prop->source_height == 300)
913 ctx->user_flags = 1;
914}
915
916static void
917test_layer_properties_changed_notification(struct test_context *ctx)
918{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000919 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900920 struct ivi_layout_layer *ivilayer;
921
922 ctx->user_flags = 0;
923
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000924 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900925
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000926 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900927
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000928 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900929
930 iassert(ctx->user_flags == 0);
931
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000932 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900933 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
934
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000935 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900936
937 iassert(ctx->user_flags == 1);
938
939 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000940 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900941 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
942
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000943 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900944
945 iassert(ctx->user_flags == 0);
946
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000947 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900948
949 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000950 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900951
952 iassert(ctx->user_flags == 0);
953
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000954 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900955}
956
957static void
958test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
959 void *userdata)
960{
961 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000962 const struct ivi_layout_interface *lyt = ctx->layout_interface;
963 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900964
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000965 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900966 iassert(prop->source_width == 200);
967 iassert(prop->source_height == 300);
968
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000969 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900970 prop->source_width == 200 && prop->source_height == 300)
971 ctx->user_flags = 1;
972}
973
974static void
975test_layer_create_notification(struct test_context *ctx)
976{
977#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000978 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900979 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
980 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
981
982 ctx->user_flags = 0;
983
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000984 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900985 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000986 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900987
988 iassert(ctx->user_flags == 1);
989
990 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000991 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900992
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000993 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900994
995 iassert(ctx->user_flags == 0);
996
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000997 lyt->layer_destroy(ivilayers[0]);
998 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900999#undef LAYER_NUM
1000}
1001
1002static void
1003test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
1004 void *userdata)
1005{
1006 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001007 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001008 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001009 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001010
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001011 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001012 iassert(prop->source_width == 200);
1013 iassert(prop->source_height == 300);
1014
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001015 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001016 prop->source_width == 200 && prop->source_height == 300)
1017 ctx->user_flags = 1;
1018}
1019
1020static void
1021test_layer_remove_notification(struct test_context *ctx)
1022{
1023#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001024 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001025 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
1026 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
1027
1028 ctx->user_flags = 0;
1029
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001030 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
1031 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001032 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001033 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001034
1035 iassert(ctx->user_flags == 1);
1036
1037 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001038 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
1039 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
1040 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001041
1042 iassert(ctx->user_flags == 0);
1043#undef LAYER_NUM
1044}
1045
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001046static void
1047test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
1048 const struct ivi_layout_layer_properties *prop,
1049 enum ivi_layout_notification_mask mask,
1050 void *userdata)
1051{
1052}
1053
1054static void
1055test_layer_bad_properties_changed_notification(struct test_context *ctx)
1056{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001057 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001058 struct ivi_layout_layer *ivilayer;
1059
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001060 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001061
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001062 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001063 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001064 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001065
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001066 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001067}
1068
1069static void
1070test_surface_bad_configure_notification(struct test_context *ctx)
1071{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001072 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001073
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001074 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001075}
1076
1077static void
1078test_layer_bad_create_notification(struct test_context *ctx)
1079{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001080 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001081
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001082 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001083}
1084
1085static void
1086test_surface_bad_create_notification(struct test_context *ctx)
1087{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001088 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001089
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001090 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001091}
1092
1093static void
1094test_layer_bad_remove_notification(struct test_context *ctx)
1095{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001096 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001097
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001098 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001099}
1100
1101static void
1102test_surface_bad_remove_notification(struct test_context *ctx)
1103{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001104 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001105
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001106 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001107}
1108
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001109/************************ tests end ********************************/
1110
1111static void
1112run_internal_tests(void *data)
1113{
1114 struct test_context *ctx = data;
1115
1116 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001117 test_surface_bad_destination_rectangle(ctx);
1118 test_surface_bad_orientation(ctx);
1119 test_surface_bad_dimension(ctx);
1120 test_surface_bad_position(ctx);
1121 test_surface_bad_source_rectangle(ctx);
1122 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001123
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001124 test_layer_create(ctx);
1125 test_layer_visibility(ctx);
1126 test_layer_opacity(ctx);
1127 test_layer_orientation(ctx);
1128 test_layer_dimension(ctx);
1129 test_layer_position(ctx);
1130 test_layer_destination_rectangle(ctx);
1131 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001132 test_layer_bad_remove(ctx);
1133 test_layer_bad_visibility(ctx);
1134 test_layer_bad_opacity(ctx);
1135 test_layer_bad_destination_rectangle(ctx);
1136 test_layer_bad_orientation(ctx);
1137 test_layer_bad_dimension(ctx);
1138 test_layer_bad_position(ctx);
1139 test_layer_bad_source_rectangle(ctx);
1140 test_layer_bad_properties(ctx);
1141 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1142 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1143 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1144 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1145 test_commit_changes_after_position_set_layer_destroy(ctx);
1146 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1147 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1148 test_layer_create_duplicate(ctx);
1149 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001150
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001151 test_screen_id(ctx);
1152 test_screen_resolution(ctx);
1153 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001154 test_screen_bad_resolution(ctx);
1155 test_screen_bad_render_order(ctx);
1156 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1157
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001158 test_layer_properties_changed_notification(ctx);
1159 test_layer_create_notification(ctx);
1160 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001161 test_layer_bad_properties_changed_notification(ctx);
1162 test_surface_bad_configure_notification(ctx);
1163 test_layer_bad_create_notification(ctx);
1164 test_surface_bad_create_notification(ctx);
1165 test_layer_bad_remove_notification(ctx);
1166 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001167
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001168 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1169 free(ctx);
1170}
1171
1172int
1173controller_module_init(struct weston_compositor *compositor,
1174 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001175 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001176 size_t iface_version);
1177
1178WL_EXPORT int
1179controller_module_init(struct weston_compositor *compositor,
1180 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001181 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001182 size_t iface_version)
1183{
1184 struct wl_event_loop *loop;
1185 struct test_context *ctx;
1186
1187 /* strict check, since this is an internal test module */
1188 if (iface_version != sizeof(*iface)) {
1189 weston_log("fatal: controller interface mismatch\n");
1190 return -1;
1191 }
1192
1193 ctx = zalloc(sizeof(*ctx));
1194 if (!ctx)
1195 return -1;
1196
1197 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001198 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001199
1200 loop = wl_display_get_event_loop(compositor->wl_display);
1201 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1202
1203 return 0;
1204}