blob: 3e31870f860f7c632d87f2a08506ee6b0f706132 [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\)c3aee1f2016-03-04 12:50:16 +0000205 prop = lyt->get_properties_of_layer(ivilayer);
206 iassert(prop->opacity == 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\)c3aee1f2016-03-04 12:50:16 +0000211 iassert(prop->opacity == 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
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900215 iassert(prop->opacity == wl_fixed_from_double(0.5));
216
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000217 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900218}
219
220static void
221test_layer_orientation(struct test_context *ctx)
222{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000223 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900224 struct ivi_layout_layer *ivilayer;
225 const struct ivi_layout_layer_properties *prop;
226
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000227 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900228 iassert(ivilayer != NULL);
229
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000230 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000232 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900233 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
234
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000235 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900236
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000237 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900238
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000239 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900240
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000241 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900242 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
243
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000244 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900245}
246
247static void
248test_layer_dimension(struct test_context *ctx)
249{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000250 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900251 struct ivi_layout_layer *ivilayer;
252 const struct ivi_layout_layer_properties *prop;
253 int32_t dest_width;
254 int32_t dest_height;
255
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000256 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900257 iassert(ivilayer != NULL);
258
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000259 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900260 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
261 iassert(dest_width == 200);
262 iassert(dest_height == 300);
263
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000264 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900265
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000266 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900267 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
268 iassert(dest_width == 200);
269 iassert(dest_height == 300);
270
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000271 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900272
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000273 iassert(IVI_SUCCEEDED == lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900274 ivilayer, &dest_width, &dest_height));
275 iassert(dest_width == 400);
276 iassert(dest_height == 600);
277
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000278 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900279 iassert(prop->dest_width == 400);
280 iassert(prop->dest_height == 600);
281
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000282 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900283}
284
285static void
286test_layer_position(struct test_context *ctx)
287{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000288 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900289 struct ivi_layout_layer *ivilayer;
290 const struct ivi_layout_layer_properties *prop;
291 int32_t dest_x;
292 int32_t dest_y;
293
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000294 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900295 iassert(ivilayer != NULL);
296
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000297 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900298 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
299 iassert(dest_x == 0);
300 iassert(dest_y == 0);
301
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000302 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900303
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000304 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900305 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
306 iassert(dest_x == 0);
307 iassert(dest_y == 0);
308
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000309 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900310
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000311 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900312 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
313 iassert(dest_x == 20);
314 iassert(dest_y == 30);
315
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000316 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900317 iassert(prop->dest_x == 20);
318 iassert(prop->dest_y == 30);
319
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000320 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900321}
322
323static void
324test_layer_destination_rectangle(struct test_context *ctx)
325{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000326 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900327 struct ivi_layout_layer *ivilayer;
328 const struct ivi_layout_layer_properties *prop;
329 int32_t dest_width;
330 int32_t dest_height;
331 int32_t dest_x;
332 int32_t dest_y;
333
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000334 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900335 iassert(ivilayer != NULL);
336
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000337 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900338 iassert(prop->dest_width == 200);
339 iassert(prop->dest_height == 300);
340 iassert(prop->dest_x == 0);
341 iassert(prop->dest_y == 0);
342
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000343 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900344 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
345
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900347 iassert(prop->dest_width == 200);
348 iassert(prop->dest_height == 300);
349 iassert(prop->dest_x == 0);
350 iassert(prop->dest_y == 0);
351
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000352 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900353
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000354 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900355 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
356 iassert(dest_width == 400);
357 iassert(dest_height == 600);
358
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000359 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900360 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
361 iassert(dest_x == 20);
362 iassert(dest_y == 30);
363
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000364 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900365 iassert(prop->dest_width == 400);
366 iassert(prop->dest_height == 600);
367 iassert(prop->dest_x == 20);
368 iassert(prop->dest_y == 30);
369
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000370 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900371}
372
373static void
374test_layer_source_rectangle(struct test_context *ctx)
375{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000376 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900377 struct ivi_layout_layer *ivilayer;
378 const struct ivi_layout_layer_properties *prop;
379
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000380 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900381 iassert(ivilayer != NULL);
382
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000383 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900384 iassert(prop->source_width == 200);
385 iassert(prop->source_height == 300);
386 iassert(prop->source_x == 0);
387 iassert(prop->source_y == 0);
388
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000389 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900390 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
391
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000392 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900393 iassert(prop->source_width == 200);
394 iassert(prop->source_height == 300);
395 iassert(prop->source_x == 0);
396 iassert(prop->source_y == 0);
397
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000398 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900399
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000400 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900401 iassert(prop->source_width == 400);
402 iassert(prop->source_height == 600);
403 iassert(prop->source_x == 20);
404 iassert(prop->source_y == 30);
405
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000406 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900407}
408
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900409static void
410test_layer_bad_remove(struct test_context *ctx)
411{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000412 const struct ivi_layout_interface *lyt = ctx->layout_interface;
413 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900414}
415
416static void
417test_layer_bad_visibility(struct test_context *ctx)
418{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000419 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900420
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000421 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900422
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000423 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900424}
425
426static void
427test_layer_bad_opacity(struct test_context *ctx)
428{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000429 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900430 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000431 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900432
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000433 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900434 iassert(ivilayer != NULL);
435
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000436 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900437 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
438
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000439 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900440 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
441
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000442 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900443 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
444
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000445 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900446
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000447 prop = lyt->get_properties_of_layer(ivilayer);
448 iassert(prop->opacity == 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\)c3aee1f2016-03-04 12:50:16 +0000455 iassert(prop->opacity == 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 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900463}
464
465static void
466test_layer_bad_destination_rectangle(struct test_context *ctx)
467{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000468 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900469
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000470 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900471 NULL, 20, 30, 200, 300) == IVI_FAILED);
472}
473
474static void
475test_layer_bad_orientation(struct test_context *ctx)
476{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000477 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900478
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000479 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900480 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
481
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000482 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900483
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000484 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900485}
486
487static void
488test_layer_bad_dimension(struct test_context *ctx)
489{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900491 struct ivi_layout_layer *ivilayer;
492 int32_t dest_width;
493 int32_t dest_height;
494
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000495 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900496 iassert(ivilayer != NULL);
497
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000498 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900499
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900501
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000502 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900503 NULL, &dest_width, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000504 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900505 ivilayer, NULL, &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, &dest_width, NULL) == IVI_FAILED);
508
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900510}
511
512static void
513test_layer_bad_position(struct test_context *ctx)
514{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000515 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900516 struct ivi_layout_layer *ivilayer;
517 int32_t dest_x;
518 int32_t dest_y;
519
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000520 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900521 iassert(ivilayer != NULL);
522
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000523 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900524
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000525 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900526
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000527 iassert(lyt->layer_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED);
528 iassert(lyt->layer_get_position(ivilayer, NULL, &dest_y) == IVI_FAILED);
529 iassert(lyt->layer_get_position(ivilayer, &dest_x, NULL) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900530
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000531 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900532}
533
534static void
535test_layer_bad_source_rectangle(struct test_context *ctx)
536{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000537 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900538
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900540 NULL, 20, 30, 200, 300) == IVI_FAILED);
541}
542
543static void
544test_layer_bad_properties(struct test_context *ctx)
545{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900547
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000548 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900549}
550
551static void
552test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
553{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000554 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900555 struct ivi_layout_layer *ivilayer;
556
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000557 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900558 iassert(ivilayer != NULL);
559
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000560 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
561 lyt->layer_destroy(ivilayer);
562 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900563}
564
565static void
566test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
567{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000568 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900569 struct ivi_layout_layer *ivilayer;
570
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000571 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900572 iassert(ivilayer != NULL);
573
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000574 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900575 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000576 lyt->layer_destroy(ivilayer);
577 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900578}
579
580static void
581test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
582{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000583 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900584 struct ivi_layout_layer *ivilayer;
585
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000586 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900587 iassert(ivilayer != NULL);
588
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000589 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900590 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000591 lyt->layer_destroy(ivilayer);
592 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900593}
594
595static void
596test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
597{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000598 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900599 struct ivi_layout_layer *ivilayer;
600
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000601 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900602 iassert(ivilayer != NULL);
603
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000604 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
605 lyt->layer_destroy(ivilayer);
606 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900607}
608
609static void
610test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
611{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000612 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900613 struct ivi_layout_layer *ivilayer;
614
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000615 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900616 iassert(ivilayer != NULL);
617
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000618 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
619 lyt->layer_destroy(ivilayer);
620 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900621}
622
623static void
624test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
625{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000626 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900627 struct ivi_layout_layer *ivilayer;
628
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000629 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900630 iassert(ivilayer != NULL);
631
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000632 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900633 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000634 lyt->layer_destroy(ivilayer);
635 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900636}
637
638static void
639test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
640{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000641 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900642 struct ivi_layout_layer *ivilayer;
643
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000644 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900645 iassert(ivilayer != NULL);
646
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000647 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900648 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 lyt->layer_destroy(ivilayer);
650 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900651}
652
653static void
654test_layer_create_duplicate(struct test_context *ctx)
655{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000656 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900657 struct ivi_layout_layer *ivilayer;
658 struct ivi_layout_layer *duplicatelayer;
659
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000660 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900661 iassert(ivilayer != NULL);
662
663 if (ivilayer != NULL)
664 iassert(ivilayer->ref_count == 1);
665
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000666 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900667 iassert(ivilayer == duplicatelayer);
668
669 if (ivilayer != NULL)
670 iassert(ivilayer->ref_count == 2);
671
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000672 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900673
674 if (ivilayer != NULL)
675 iassert(ivilayer->ref_count == 1);
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
680static void
681test_get_layer_after_destory_layer(struct test_context *ctx)
682{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000683 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900684 struct ivi_layout_layer *ivilayer;
685
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000686 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900687 iassert(ivilayer != NULL);
688
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000689 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900690
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000691 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900692 iassert(ivilayer == NULL);
693}
694
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900695static void
696test_screen_id(struct test_context *ctx)
697{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000698 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900699 struct ivi_layout_screen **iviscrns;
700 int32_t screen_length = 0;
701 uint32_t id_screen;
702 int32_t i;
703
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000704 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900705 iassert(screen_length > 0);
706
707 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000708 id_screen = lyt->get_id_of_screen(iviscrns[i]);
709 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900710 }
711
712 if (screen_length > 0)
713 free(iviscrns);
714}
715
716static void
717test_screen_resolution(struct test_context *ctx)
718{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000719 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900720 struct ivi_layout_screen **iviscrns;
721 int32_t screen_length = 0;
722 struct weston_output *output;
723 int32_t width;
724 int32_t height;
725 int32_t i;
726
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000727 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900728 iassert(screen_length > 0);
729
730 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000731 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900732 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000733 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900734 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
735 iassert(width == output->current_mode->width);
736 iassert(height == output->current_mode->height);
737 }
738
739 if (screen_length > 0)
740 free(iviscrns);
741}
742
743static void
744test_screen_render_order(struct test_context *ctx)
745{
746#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000747 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900748 struct ivi_layout_screen **iviscrns;
749 int32_t screen_length = 0;
750 struct ivi_layout_screen *iviscrn;
751 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
752 struct ivi_layout_layer **array;
753 int32_t length = 0;
754 uint32_t i;
755
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000756 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900757 iassert(screen_length > 0);
758
759 if (screen_length <= 0)
760 return;
761
762 iviscrn = iviscrns[0];
763
764 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000765 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900766
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000767 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900768
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900770
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000771 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900772 iassert(length == LAYER_NUM);
773 for (i = 0; i < LAYER_NUM; i++)
774 iassert(array[i] == ivilayers[i]);
775
776 if (length > 0)
777 free(array);
778
779 array = NULL;
780
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000781 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900782
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000783 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900784
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000785 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900786 iassert(length == 0 && array == NULL);
787
788 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000789 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900790
791 free(iviscrns);
792#undef LAYER_NUM
793}
794
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900795static void
796test_screen_bad_resolution(struct test_context *ctx)
797{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000798 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900799 struct ivi_layout_screen **iviscrns;
800 int32_t screen_length = 0;
801 struct ivi_layout_screen *iviscrn;
802 int32_t width;
803 int32_t height;
804
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000805 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900806 iassert(screen_length > 0);
807
808 if (screen_length <= 0)
809 return;
810
811 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000812 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
813 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
814 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900815 free(iviscrns);
816}
817
818static void
819test_screen_bad_render_order(struct test_context *ctx)
820{
821#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000822 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900823 struct ivi_layout_screen **iviscrns;
824 int32_t screen_length;
825 struct ivi_layout_screen *iviscrn;
826 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
827 struct ivi_layout_layer **array;
828 int32_t length = 0;
829 uint32_t i;
830
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000831 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900832 iassert(screen_length > 0);
833
834 if (screen_length <= 0)
835 return;
836
837 iviscrn = iviscrns[0];
838
839 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000840 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900841
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000842 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900843
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000844 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900845
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000846 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
847 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
848 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900849
850 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000851 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900852
853 free(iviscrns);
854#undef LAYER_NUM
855}
856
857static void
858test_commit_changes_after_render_order_set_layer_destroy(
859 struct test_context *ctx)
860{
861#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000862 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900863 struct ivi_layout_screen **iviscrns;
864 int32_t screen_length;
865 struct ivi_layout_screen *iviscrn;
866 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
867 uint32_t i;
868
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000869 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900870 iassert(screen_length > 0);
871
872 if (screen_length <= 0)
873 return;
874
875 iviscrn = iviscrns[0];
876
877 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000878 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900879
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000880 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900881
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900883
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000884 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900885
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000886 lyt->layer_destroy(ivilayers[0]);
887 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900888
889 free(iviscrns);
890#undef LAYER_NUM
891}
892
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900893static void
894test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
895 const struct ivi_layout_layer_properties *prop,
896 enum ivi_layout_notification_mask mask,
897 void *userdata)
898{
899 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000900 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900901
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000902 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900903 iassert(prop->source_width == 200);
904 iassert(prop->source_height == 300);
905
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000906 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900907 prop->source_width == 200 && prop->source_height == 300)
908 ctx->user_flags = 1;
909}
910
911static void
912test_layer_properties_changed_notification(struct test_context *ctx)
913{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000914 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900915 struct ivi_layout_layer *ivilayer;
916
917 ctx->user_flags = 0;
918
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000919 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900920
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000921 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900922
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000923 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900924
925 iassert(ctx->user_flags == 0);
926
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000927 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900928 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
929
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000930 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900931
932 iassert(ctx->user_flags == 1);
933
934 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000935 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900936 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
937
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000938 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900939
940 iassert(ctx->user_flags == 0);
941
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000942 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900943
944 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000945 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900946
947 iassert(ctx->user_flags == 0);
948
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000949 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900950}
951
952static void
953test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
954 void *userdata)
955{
956 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000957 const struct ivi_layout_interface *lyt = ctx->layout_interface;
958 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900959
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000960 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900961 iassert(prop->source_width == 200);
962 iassert(prop->source_height == 300);
963
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000964 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900965 prop->source_width == 200 && prop->source_height == 300)
966 ctx->user_flags = 1;
967}
968
969static void
970test_layer_create_notification(struct test_context *ctx)
971{
972#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000973 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900974 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
975 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
976
977 ctx->user_flags = 0;
978
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000979 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900980 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000981 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900982
983 iassert(ctx->user_flags == 1);
984
985 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000986 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900987
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000988 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900989
990 iassert(ctx->user_flags == 0);
991
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000992 lyt->layer_destroy(ivilayers[0]);
993 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900994#undef LAYER_NUM
995}
996
997static void
998test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
999 void *userdata)
1000{
1001 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001002 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001003 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001004 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001005
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001006 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001007 iassert(prop->source_width == 200);
1008 iassert(prop->source_height == 300);
1009
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001010 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001011 prop->source_width == 200 && prop->source_height == 300)
1012 ctx->user_flags = 1;
1013}
1014
1015static void
1016test_layer_remove_notification(struct test_context *ctx)
1017{
1018#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001019 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001020 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
1021 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
1022
1023 ctx->user_flags = 0;
1024
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001025 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
1026 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001027 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001028 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001029
1030 iassert(ctx->user_flags == 1);
1031
1032 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001033 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
1034 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
1035 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001036
1037 iassert(ctx->user_flags == 0);
1038#undef LAYER_NUM
1039}
1040
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001041static void
1042test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
1043 const struct ivi_layout_layer_properties *prop,
1044 enum ivi_layout_notification_mask mask,
1045 void *userdata)
1046{
1047}
1048
1049static void
1050test_layer_bad_properties_changed_notification(struct test_context *ctx)
1051{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001052 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001053 struct ivi_layout_layer *ivilayer;
1054
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001055 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001056
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001057 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001058 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001059 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001060
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001061 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001062}
1063
1064static void
1065test_surface_bad_configure_notification(struct test_context *ctx)
1066{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001067 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001068
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001069 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001070}
1071
1072static void
1073test_layer_bad_create_notification(struct test_context *ctx)
1074{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001075 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001076
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001077 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001078}
1079
1080static void
1081test_surface_bad_create_notification(struct test_context *ctx)
1082{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001083 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001084
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001085 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001086}
1087
1088static void
1089test_layer_bad_remove_notification(struct test_context *ctx)
1090{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001091 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001092
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001093 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001094}
1095
1096static void
1097test_surface_bad_remove_notification(struct test_context *ctx)
1098{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001099 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001100
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001101 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001102}
1103
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001104/************************ tests end ********************************/
1105
1106static void
1107run_internal_tests(void *data)
1108{
1109 struct test_context *ctx = data;
1110
1111 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001112 test_surface_bad_destination_rectangle(ctx);
1113 test_surface_bad_orientation(ctx);
1114 test_surface_bad_dimension(ctx);
1115 test_surface_bad_position(ctx);
1116 test_surface_bad_source_rectangle(ctx);
1117 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001118
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001119 test_layer_create(ctx);
1120 test_layer_visibility(ctx);
1121 test_layer_opacity(ctx);
1122 test_layer_orientation(ctx);
1123 test_layer_dimension(ctx);
1124 test_layer_position(ctx);
1125 test_layer_destination_rectangle(ctx);
1126 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001127 test_layer_bad_remove(ctx);
1128 test_layer_bad_visibility(ctx);
1129 test_layer_bad_opacity(ctx);
1130 test_layer_bad_destination_rectangle(ctx);
1131 test_layer_bad_orientation(ctx);
1132 test_layer_bad_dimension(ctx);
1133 test_layer_bad_position(ctx);
1134 test_layer_bad_source_rectangle(ctx);
1135 test_layer_bad_properties(ctx);
1136 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1137 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1138 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1139 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1140 test_commit_changes_after_position_set_layer_destroy(ctx);
1141 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1142 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1143 test_layer_create_duplicate(ctx);
1144 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001145
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001146 test_screen_id(ctx);
1147 test_screen_resolution(ctx);
1148 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001149 test_screen_bad_resolution(ctx);
1150 test_screen_bad_render_order(ctx);
1151 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1152
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001153 test_layer_properties_changed_notification(ctx);
1154 test_layer_create_notification(ctx);
1155 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001156 test_layer_bad_properties_changed_notification(ctx);
1157 test_surface_bad_configure_notification(ctx);
1158 test_layer_bad_create_notification(ctx);
1159 test_surface_bad_create_notification(ctx);
1160 test_layer_bad_remove_notification(ctx);
1161 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001162
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001163 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1164 free(ctx);
1165}
1166
1167int
1168controller_module_init(struct weston_compositor *compositor,
1169 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001170 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001171 size_t iface_version);
1172
1173WL_EXPORT int
1174controller_module_init(struct weston_compositor *compositor,
1175 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001176 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001177 size_t iface_version)
1178{
1179 struct wl_event_loop *loop;
1180 struct test_context *ctx;
1181
1182 /* strict check, since this is an internal test module */
1183 if (iface_version != sizeof(*iface)) {
1184 weston_log("fatal: controller interface mismatch\n");
1185 return -1;
1186 }
1187
1188 ctx = zalloc(sizeof(*ctx));
1189 if (!ctx)
1190 return -1;
1191
1192 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001193 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001194
1195 loop = wl_display_get_event_loop(compositor->wl_display);
1196 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1197
1198 return 0;
1199}