blob: 2c52ed402b3fcfa6b58a2fe42c2ab28001f2b7d6 [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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000117 iassert(lyt->surface_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900118
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000119 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900120}
121
122static void
123test_surface_bad_source_rectangle(struct test_context *ctx)
124{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000125 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900126
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000127 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900128}
129
130static void
131test_surface_bad_properties(struct test_context *ctx)
132{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000133 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900134
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000135 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900136}
137
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900138static void
139test_layer_create(struct test_context *ctx)
140{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000141 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900142 uint32_t id1;
143 uint32_t id2;
144 struct ivi_layout_layer *ivilayer;
145 struct ivi_layout_layer *new_ivilayer;
146
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000147 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900148 iassert(ivilayer != NULL);
149
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000150 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900151
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000152 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900153 iassert(ivilayer == new_ivilayer);
154
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000155 id1 = lyt->get_id_of_layer(ivilayer);
156 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900157 iassert(id1 == id2);
158
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000159 lyt->layer_destroy(ivilayer);
160 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900161}
162
163static void
164test_layer_visibility(struct test_context *ctx)
165{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000166 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900167 struct ivi_layout_layer *ivilayer;
168 const struct ivi_layout_layer_properties *prop;
169
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000170 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900171 iassert(ivilayer != NULL);
172
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000173 prop = lyt->get_properties_of_layer(ivilayer);
174
175 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900176
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000177 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900178
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000179 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900180
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000181 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900182
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183 iassert(prop->visibility == true);
184
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000185 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900186}
187
188static void
189test_layer_opacity(struct test_context *ctx)
190{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000191 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900192 struct ivi_layout_layer *ivilayer;
193 const struct ivi_layout_layer_properties *prop;
194
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000195 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900196 iassert(ivilayer != NULL);
197
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000198 prop = lyt->get_properties_of_layer(ivilayer);
199 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900200
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000201 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900202 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
203
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000204 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900205
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000206 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900207
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208 iassert(prop->opacity == wl_fixed_from_double(0.5));
209
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000210 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900211}
212
213static void
214test_layer_orientation(struct test_context *ctx)
215{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900217 struct ivi_layout_layer *ivilayer;
218 const struct ivi_layout_layer_properties *prop;
219
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000220 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900221 iassert(ivilayer != NULL);
222
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000223 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900224
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000225 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900226 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
227
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000228 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900229
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000230 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000232 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900233
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000234 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900235 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
236
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000237 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900238}
239
240static void
241test_layer_dimension(struct test_context *ctx)
242{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000243 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900244 struct ivi_layout_layer *ivilayer;
245 const struct ivi_layout_layer_properties *prop;
246 int32_t dest_width;
247 int32_t dest_height;
248
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000249 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900250 iassert(ivilayer != NULL);
251
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000252 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900253 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
254 iassert(dest_width == 200);
255 iassert(dest_height == 300);
256
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000257 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900258
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 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900265
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000266 iassert(IVI_SUCCEEDED == lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900267 ivilayer, &dest_width, &dest_height));
268 iassert(dest_width == 400);
269 iassert(dest_height == 600);
270
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000271 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900272 iassert(prop->dest_width == 400);
273 iassert(prop->dest_height == 600);
274
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000275 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900276}
277
278static void
279test_layer_position(struct test_context *ctx)
280{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000281 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900282 struct ivi_layout_layer *ivilayer;
283 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900284
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000285 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900286 iassert(ivilayer != NULL);
287
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000288 prop = lyt->get_properties_of_layer(ivilayer);
289 iassert(prop->dest_x == 0);
290 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000292 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900293
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000294 iassert(prop->dest_x == 0);
295 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900296
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000297 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900298
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000299 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900300 iassert(prop->dest_x == 20);
301 iassert(prop->dest_y == 30);
302
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000303 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900304}
305
306static void
307test_layer_destination_rectangle(struct test_context *ctx)
308{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000309 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900310 struct ivi_layout_layer *ivilayer;
311 const struct ivi_layout_layer_properties *prop;
312 int32_t dest_width;
313 int32_t dest_height;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900314
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000315 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900316 iassert(ivilayer != NULL);
317
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000318 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900319 iassert(prop->dest_width == 200);
320 iassert(prop->dest_height == 300);
321 iassert(prop->dest_x == 0);
322 iassert(prop->dest_y == 0);
323
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000324 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900325 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
326
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000327 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900328 iassert(prop->dest_width == 200);
329 iassert(prop->dest_height == 300);
330 iassert(prop->dest_x == 0);
331 iassert(prop->dest_y == 0);
332
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000333 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900334
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000335 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900336 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
337 iassert(dest_width == 400);
338 iassert(dest_height == 600);
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 == 400);
342 iassert(prop->dest_height == 600);
343 iassert(prop->dest_x == 20);
344 iassert(prop->dest_y == 30);
345
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900347}
348
349static void
350test_layer_source_rectangle(struct test_context *ctx)
351{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000352 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900353 struct ivi_layout_layer *ivilayer;
354 const struct ivi_layout_layer_properties *prop;
355
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000356 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900357 iassert(ivilayer != NULL);
358
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000359 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900360 iassert(prop->source_width == 200);
361 iassert(prop->source_height == 300);
362 iassert(prop->source_x == 0);
363 iassert(prop->source_y == 0);
364
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000365 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900366 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
367
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000368 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900369 iassert(prop->source_width == 200);
370 iassert(prop->source_height == 300);
371 iassert(prop->source_x == 0);
372 iassert(prop->source_y == 0);
373
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000374 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900375
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000376 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900377 iassert(prop->source_width == 400);
378 iassert(prop->source_height == 600);
379 iassert(prop->source_x == 20);
380 iassert(prop->source_y == 30);
381
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000382 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900383}
384
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900385static void
386test_layer_bad_remove(struct test_context *ctx)
387{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000388 const struct ivi_layout_interface *lyt = ctx->layout_interface;
389 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900390}
391
392static void
393test_layer_bad_visibility(struct test_context *ctx)
394{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000395 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900396
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000397 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900398
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000399 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900400}
401
402static void
403test_layer_bad_opacity(struct test_context *ctx)
404{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000405 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900406 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000407 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900408
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000409 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900410 iassert(ivilayer != NULL);
411
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000412 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900413 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
414
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000415 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900416 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
417
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000418 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900419 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
420
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000421 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900422
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000423 prop = lyt->get_properties_of_layer(ivilayer);
424 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900425
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000426 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900427 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
428
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000429 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900430
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000431 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900432
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000433 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900434 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
435
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000436 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900437
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000438 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900439}
440
441static void
442test_layer_bad_destination_rectangle(struct test_context *ctx)
443{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000444 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900445
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447 NULL, 20, 30, 200, 300) == IVI_FAILED);
448}
449
450static void
451test_layer_bad_orientation(struct test_context *ctx)
452{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000455 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900456 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
457
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000458 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900459
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000460 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900461}
462
463static void
464test_layer_bad_dimension(struct test_context *ctx)
465{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000466 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900467 struct ivi_layout_layer *ivilayer;
468 int32_t dest_width;
469 int32_t dest_height;
470
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000471 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900472 iassert(ivilayer != NULL);
473
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000474 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900475
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000476 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900477
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000478 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900479 NULL, &dest_width, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000480 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900481 ivilayer, NULL, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000482 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900483 ivilayer, &dest_width, NULL) == IVI_FAILED);
484
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000485 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900486}
487
488static void
489test_layer_bad_position(struct test_context *ctx)
490{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000491 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900492 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900493
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000494 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900495 iassert(ivilayer != NULL);
496
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000497 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900498
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000499 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900500
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000501 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900502}
503
504static void
505test_layer_bad_source_rectangle(struct test_context *ctx)
506{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000507 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900508
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900510 NULL, 20, 30, 200, 300) == IVI_FAILED);
511}
512
513static void
514test_layer_bad_properties(struct test_context *ctx)
515{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000516 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900517
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000518 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900519}
520
521static void
522test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
523{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000524 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900525 struct ivi_layout_layer *ivilayer;
526
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000527 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900528 iassert(ivilayer != NULL);
529
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000530 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
531 lyt->layer_destroy(ivilayer);
532 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900533}
534
535static void
536test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
537{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000538 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900539 struct ivi_layout_layer *ivilayer;
540
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000541 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900542 iassert(ivilayer != NULL);
543
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000544 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900545 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 lyt->layer_destroy(ivilayer);
547 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900548}
549
550static void
551test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
552{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000553 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900554 struct ivi_layout_layer *ivilayer;
555
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000556 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900557 iassert(ivilayer != NULL);
558
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000559 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900560 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000561 lyt->layer_destroy(ivilayer);
562 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900563}
564
565static void
566test_commit_changes_after_dimension_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_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
575 lyt->layer_destroy(ivilayer);
576 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900577}
578
579static void
580test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
581{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000582 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900583 struct ivi_layout_layer *ivilayer;
584
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000585 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900586 iassert(ivilayer != NULL);
587
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000588 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
589 lyt->layer_destroy(ivilayer);
590 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900591}
592
593static void
594test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
595{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000596 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900597 struct ivi_layout_layer *ivilayer;
598
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000599 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900600 iassert(ivilayer != NULL);
601
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000602 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900603 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000604 lyt->layer_destroy(ivilayer);
605 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900606}
607
608static void
609test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
610{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000611 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900612 struct ivi_layout_layer *ivilayer;
613
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000614 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900615 iassert(ivilayer != NULL);
616
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000617 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900618 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000619 lyt->layer_destroy(ivilayer);
620 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900621}
622
623static void
624test_layer_create_duplicate(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 struct ivi_layout_layer *duplicatelayer;
629
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000630 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900631 iassert(ivilayer != NULL);
632
633 if (ivilayer != NULL)
634 iassert(ivilayer->ref_count == 1);
635
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000636 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900637 iassert(ivilayer == duplicatelayer);
638
639 if (ivilayer != NULL)
640 iassert(ivilayer->ref_count == 2);
641
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000642 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900643
644 if (ivilayer != NULL)
645 iassert(ivilayer->ref_count == 1);
646
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000647 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900648}
649
650static void
651test_get_layer_after_destory_layer(struct test_context *ctx)
652{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000653 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900654 struct ivi_layout_layer *ivilayer;
655
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000656 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900657 iassert(ivilayer != NULL);
658
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000659 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900660
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000661 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900662 iassert(ivilayer == NULL);
663}
664
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900665static void
666test_screen_id(struct test_context *ctx)
667{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000668 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900669 struct ivi_layout_screen **iviscrns;
670 int32_t screen_length = 0;
671 uint32_t id_screen;
672 int32_t i;
673
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000674 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900675 iassert(screen_length > 0);
676
677 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000678 id_screen = lyt->get_id_of_screen(iviscrns[i]);
679 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900680 }
681
682 if (screen_length > 0)
683 free(iviscrns);
684}
685
686static void
687test_screen_resolution(struct test_context *ctx)
688{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000689 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900690 struct ivi_layout_screen **iviscrns;
691 int32_t screen_length = 0;
692 struct weston_output *output;
693 int32_t width;
694 int32_t height;
695 int32_t i;
696
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000697 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900698 iassert(screen_length > 0);
699
700 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000701 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900702 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000703 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900704 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
705 iassert(width == output->current_mode->width);
706 iassert(height == output->current_mode->height);
707 }
708
709 if (screen_length > 0)
710 free(iviscrns);
711}
712
713static void
714test_screen_render_order(struct test_context *ctx)
715{
716#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000717 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900718 struct ivi_layout_screen **iviscrns;
719 int32_t screen_length = 0;
720 struct ivi_layout_screen *iviscrn;
721 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
722 struct ivi_layout_layer **array;
723 int32_t length = 0;
724 uint32_t i;
725
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000726 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900727 iassert(screen_length > 0);
728
729 if (screen_length <= 0)
730 return;
731
732 iviscrn = iviscrns[0];
733
734 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000735 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900736
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000737 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900738
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000739 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900740
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000741 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900742 iassert(length == LAYER_NUM);
743 for (i = 0; i < LAYER_NUM; i++)
744 iassert(array[i] == ivilayers[i]);
745
746 if (length > 0)
747 free(array);
748
749 array = NULL;
750
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000751 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900752
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000753 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900754
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000755 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900756 iassert(length == 0 && array == NULL);
757
758 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000759 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900760
761 free(iviscrns);
762#undef LAYER_NUM
763}
764
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900765static void
766test_screen_bad_resolution(struct test_context *ctx)
767{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000768 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900769 struct ivi_layout_screen **iviscrns;
770 int32_t screen_length = 0;
771 struct ivi_layout_screen *iviscrn;
772 int32_t width;
773 int32_t height;
774
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000775 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900776 iassert(screen_length > 0);
777
778 if (screen_length <= 0)
779 return;
780
781 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000782 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
783 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
784 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900785 free(iviscrns);
786}
787
788static void
789test_screen_bad_render_order(struct test_context *ctx)
790{
791#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000792 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900793 struct ivi_layout_screen **iviscrns;
794 int32_t screen_length;
795 struct ivi_layout_screen *iviscrn;
796 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
797 struct ivi_layout_layer **array;
798 int32_t length = 0;
799 uint32_t i;
800
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000801 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900802 iassert(screen_length > 0);
803
804 if (screen_length <= 0)
805 return;
806
807 iviscrn = iviscrns[0];
808
809 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000810 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900811
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000812 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900813
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000814 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900815
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000816 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
817 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
818 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900819
820 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000821 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900822
823 free(iviscrns);
824#undef LAYER_NUM
825}
826
827static void
828test_commit_changes_after_render_order_set_layer_destroy(
829 struct test_context *ctx)
830{
831#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000832 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900833 struct ivi_layout_screen **iviscrns;
834 int32_t screen_length;
835 struct ivi_layout_screen *iviscrn;
836 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
837 uint32_t i;
838
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000839 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900840 iassert(screen_length > 0);
841
842 if (screen_length <= 0)
843 return;
844
845 iviscrn = iviscrns[0];
846
847 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000848 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900849
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000850 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900851
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000852 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900853
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000854 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900855
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000856 lyt->layer_destroy(ivilayers[0]);
857 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900858
859 free(iviscrns);
860#undef LAYER_NUM
861}
862
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900863static void
864test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
865 const struct ivi_layout_layer_properties *prop,
866 enum ivi_layout_notification_mask mask,
867 void *userdata)
868{
869 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000870 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900871
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000872 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900873 iassert(prop->source_width == 200);
874 iassert(prop->source_height == 300);
875
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000876 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900877 prop->source_width == 200 && prop->source_height == 300)
878 ctx->user_flags = 1;
879}
880
881static void
882test_layer_properties_changed_notification(struct test_context *ctx)
883{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000884 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900885 struct ivi_layout_layer *ivilayer;
886
887 ctx->user_flags = 0;
888
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000889 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900890
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000891 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900892
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000893 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900894
895 iassert(ctx->user_flags == 0);
896
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000897 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900898 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
899
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000900 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900901
902 iassert(ctx->user_flags == 1);
903
904 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000905 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900906 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
907
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000908 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900909
910 iassert(ctx->user_flags == 0);
911
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000912 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900913
914 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000915 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900916
917 iassert(ctx->user_flags == 0);
918
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000919 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900920}
921
922static void
923test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
924 void *userdata)
925{
926 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000927 const struct ivi_layout_interface *lyt = ctx->layout_interface;
928 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900929
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000930 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900931 iassert(prop->source_width == 200);
932 iassert(prop->source_height == 300);
933
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000934 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900935 prop->source_width == 200 && prop->source_height == 300)
936 ctx->user_flags = 1;
937}
938
939static void
940test_layer_create_notification(struct test_context *ctx)
941{
942#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000943 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900944 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
945 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
946
947 ctx->user_flags = 0;
948
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000949 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900950 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000951 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900952
953 iassert(ctx->user_flags == 1);
954
955 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000956 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900957
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000958 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900959
960 iassert(ctx->user_flags == 0);
961
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000962 lyt->layer_destroy(ivilayers[0]);
963 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900964#undef LAYER_NUM
965}
966
967static void
968test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
969 void *userdata)
970{
971 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000972 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900973 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000974 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900975
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000976 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900977 iassert(prop->source_width == 200);
978 iassert(prop->source_height == 300);
979
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000980 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900981 prop->source_width == 200 && prop->source_height == 300)
982 ctx->user_flags = 1;
983}
984
985static void
986test_layer_remove_notification(struct test_context *ctx)
987{
988#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000989 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900990 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
991 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
992
993 ctx->user_flags = 0;
994
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000995 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
996 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900997 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000998 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900999
1000 iassert(ctx->user_flags == 1);
1001
1002 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001003 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
1004 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
1005 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001006
1007 iassert(ctx->user_flags == 0);
1008#undef LAYER_NUM
1009}
1010
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001011static void
1012test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
1013 const struct ivi_layout_layer_properties *prop,
1014 enum ivi_layout_notification_mask mask,
1015 void *userdata)
1016{
1017}
1018
1019static void
1020test_layer_bad_properties_changed_notification(struct test_context *ctx)
1021{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001022 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001023 struct ivi_layout_layer *ivilayer;
1024
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001025 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001026
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001027 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001028 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001029 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001030
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001031 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001032}
1033
1034static void
1035test_surface_bad_configure_notification(struct test_context *ctx)
1036{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001037 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001038
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001039 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001040}
1041
1042static void
1043test_layer_bad_create_notification(struct test_context *ctx)
1044{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001045 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001046
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001047 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001048}
1049
1050static void
1051test_surface_bad_create_notification(struct test_context *ctx)
1052{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001053 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001054
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001055 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001056}
1057
1058static void
1059test_layer_bad_remove_notification(struct test_context *ctx)
1060{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001061 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001062
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001063 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001064}
1065
1066static void
1067test_surface_bad_remove_notification(struct test_context *ctx)
1068{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001069 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001070
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001071 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001072}
1073
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001074/************************ tests end ********************************/
1075
1076static void
1077run_internal_tests(void *data)
1078{
1079 struct test_context *ctx = data;
1080
1081 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001082 test_surface_bad_destination_rectangle(ctx);
1083 test_surface_bad_orientation(ctx);
1084 test_surface_bad_dimension(ctx);
1085 test_surface_bad_position(ctx);
1086 test_surface_bad_source_rectangle(ctx);
1087 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001088
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001089 test_layer_create(ctx);
1090 test_layer_visibility(ctx);
1091 test_layer_opacity(ctx);
1092 test_layer_orientation(ctx);
1093 test_layer_dimension(ctx);
1094 test_layer_position(ctx);
1095 test_layer_destination_rectangle(ctx);
1096 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001097 test_layer_bad_remove(ctx);
1098 test_layer_bad_visibility(ctx);
1099 test_layer_bad_opacity(ctx);
1100 test_layer_bad_destination_rectangle(ctx);
1101 test_layer_bad_orientation(ctx);
1102 test_layer_bad_dimension(ctx);
1103 test_layer_bad_position(ctx);
1104 test_layer_bad_source_rectangle(ctx);
1105 test_layer_bad_properties(ctx);
1106 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1107 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1108 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1109 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1110 test_commit_changes_after_position_set_layer_destroy(ctx);
1111 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1112 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1113 test_layer_create_duplicate(ctx);
1114 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001115
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001116 test_screen_id(ctx);
1117 test_screen_resolution(ctx);
1118 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001119 test_screen_bad_resolution(ctx);
1120 test_screen_bad_render_order(ctx);
1121 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1122
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001123 test_layer_properties_changed_notification(ctx);
1124 test_layer_create_notification(ctx);
1125 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001126 test_layer_bad_properties_changed_notification(ctx);
1127 test_surface_bad_configure_notification(ctx);
1128 test_layer_bad_create_notification(ctx);
1129 test_surface_bad_create_notification(ctx);
1130 test_layer_bad_remove_notification(ctx);
1131 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001132
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001133 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1134 free(ctx);
1135}
1136
1137int
1138controller_module_init(struct weston_compositor *compositor,
1139 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001140 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001141 size_t iface_version);
1142
1143WL_EXPORT int
1144controller_module_init(struct weston_compositor *compositor,
1145 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001146 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001147 size_t iface_version)
1148{
1149 struct wl_event_loop *loop;
1150 struct test_context *ctx;
1151
1152 /* strict check, since this is an internal test module */
1153 if (iface_version != sizeof(*iface)) {
1154 weston_log("fatal: controller interface mismatch\n");
1155 return -1;
1156 }
1157
1158 ctx = zalloc(sizeof(*ctx));
1159 if (!ctx)
1160 return -1;
1161
1162 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001163 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001164
1165 loop = wl_display_get_event_loop(compositor->wl_display);
1166 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1167
1168 return 0;
1169}