blob: cb34fc1fd344ab1da3d8bce229cc1c46dcee931e [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;
284 int32_t dest_x;
285 int32_t dest_y;
286
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000287 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900288 iassert(ivilayer != NULL);
289
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000290 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900291 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
292 iassert(dest_x == 0);
293 iassert(dest_y == 0);
294
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000295 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900296
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 lyt->commit_changes();
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 == 20);
307 iassert(dest_y == 30);
308
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000309 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900310 iassert(prop->dest_x == 20);
311 iassert(prop->dest_y == 30);
312
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000313 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900314}
315
316static void
317test_layer_destination_rectangle(struct test_context *ctx)
318{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000319 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900320 struct ivi_layout_layer *ivilayer;
321 const struct ivi_layout_layer_properties *prop;
322 int32_t dest_width;
323 int32_t dest_height;
324 int32_t dest_x;
325 int32_t dest_y;
326
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000327 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900328 iassert(ivilayer != NULL);
329
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000330 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900331 iassert(prop->dest_width == 200);
332 iassert(prop->dest_height == 300);
333 iassert(prop->dest_x == 0);
334 iassert(prop->dest_y == 0);
335
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000336 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900337 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
338
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000339 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900340 iassert(prop->dest_width == 200);
341 iassert(prop->dest_height == 300);
342 iassert(prop->dest_x == 0);
343 iassert(prop->dest_y == 0);
344
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000345 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900346
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000347 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900348 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
349 iassert(dest_width == 400);
350 iassert(dest_height == 600);
351
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000352 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900353 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
354 iassert(dest_x == 20);
355 iassert(dest_y == 30);
356
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000357 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900358 iassert(prop->dest_width == 400);
359 iassert(prop->dest_height == 600);
360 iassert(prop->dest_x == 20);
361 iassert(prop->dest_y == 30);
362
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000363 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900364}
365
366static void
367test_layer_source_rectangle(struct test_context *ctx)
368{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900370 struct ivi_layout_layer *ivilayer;
371 const struct ivi_layout_layer_properties *prop;
372
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000373 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900374 iassert(ivilayer != NULL);
375
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 == 200);
378 iassert(prop->source_height == 300);
379 iassert(prop->source_x == 0);
380 iassert(prop->source_y == 0);
381
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000382 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900383 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
384
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000385 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900386 iassert(prop->source_width == 200);
387 iassert(prop->source_height == 300);
388 iassert(prop->source_x == 0);
389 iassert(prop->source_y == 0);
390
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000391 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900392
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000393 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900394 iassert(prop->source_width == 400);
395 iassert(prop->source_height == 600);
396 iassert(prop->source_x == 20);
397 iassert(prop->source_y == 30);
398
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000399 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900400}
401
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900402static void
403test_layer_bad_remove(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;
406 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900407}
408
409static void
410test_layer_bad_visibility(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;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900413
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000414 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900415
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417}
418
419static void
420test_layer_bad_opacity(struct test_context *ctx)
421{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000422 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900423 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000424 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900425
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000426 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900427 iassert(ivilayer != NULL);
428
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000429 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900430 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
431
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000432 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900433 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
434
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000435 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900436 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
437
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000438 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900439
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000440 prop = lyt->get_properties_of_layer(ivilayer);
441 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900442
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000443 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900444 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
445
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000448 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 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
452
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000455 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900456}
457
458static void
459test_layer_bad_destination_rectangle(struct test_context *ctx)
460{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000461 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900462
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000463 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900464 NULL, 20, 30, 200, 300) == IVI_FAILED);
465}
466
467static void
468test_layer_bad_orientation(struct test_context *ctx)
469{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000470 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900471
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000472 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900473 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
474
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900476
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000477 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900478}
479
480static void
481test_layer_bad_dimension(struct test_context *ctx)
482{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000483 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900484 struct ivi_layout_layer *ivilayer;
485 int32_t dest_width;
486 int32_t dest_height;
487
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000488 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900489 iassert(ivilayer != NULL);
490
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000491 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900492
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000493 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900494
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000495 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900496 NULL, &dest_width, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000497 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900498 ivilayer, NULL, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000499 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900500 ivilayer, &dest_width, NULL) == IVI_FAILED);
501
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000502 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900503}
504
505static void
506test_layer_bad_position(struct test_context *ctx)
507{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000508 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900509 struct ivi_layout_layer *ivilayer;
510 int32_t dest_x;
511 int32_t dest_y;
512
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000513 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900514 iassert(ivilayer != NULL);
515
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000516 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900517
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000518 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900519
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000520 iassert(lyt->layer_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED);
521 iassert(lyt->layer_get_position(ivilayer, NULL, &dest_y) == IVI_FAILED);
522 iassert(lyt->layer_get_position(ivilayer, &dest_x, NULL) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900523
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000524 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900525}
526
527static void
528test_layer_bad_source_rectangle(struct test_context *ctx)
529{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000530 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900531
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000532 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900533 NULL, 20, 30, 200, 300) == IVI_FAILED);
534}
535
536static void
537test_layer_bad_properties(struct test_context *ctx)
538{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900540
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000541 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900542}
543
544static void
545test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
546{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000547 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900548 struct ivi_layout_layer *ivilayer;
549
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000550 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900551 iassert(ivilayer != NULL);
552
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000553 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
554 lyt->layer_destroy(ivilayer);
555 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900556}
557
558static void
559test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
560{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000561 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900562 struct ivi_layout_layer *ivilayer;
563
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000564 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900565 iassert(ivilayer != NULL);
566
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000567 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900568 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000569 lyt->layer_destroy(ivilayer);
570 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900571}
572
573static void
574test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
575{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000576 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900577 struct ivi_layout_layer *ivilayer;
578
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000579 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900580 iassert(ivilayer != NULL);
581
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000582 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900583 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000584 lyt->layer_destroy(ivilayer);
585 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900586}
587
588static void
589test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
590{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000591 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900592 struct ivi_layout_layer *ivilayer;
593
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000594 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900595 iassert(ivilayer != NULL);
596
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000597 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
598 lyt->layer_destroy(ivilayer);
599 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900600}
601
602static void
603test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
604{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000605 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900606 struct ivi_layout_layer *ivilayer;
607
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000608 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900609 iassert(ivilayer != NULL);
610
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000611 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
612 lyt->layer_destroy(ivilayer);
613 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900614}
615
616static void
617test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
618{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000619 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900620 struct ivi_layout_layer *ivilayer;
621
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000622 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900623 iassert(ivilayer != NULL);
624
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000625 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900626 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000627 lyt->layer_destroy(ivilayer);
628 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900629}
630
631static void
632test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
633{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000634 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900635 struct ivi_layout_layer *ivilayer;
636
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000637 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900638 iassert(ivilayer != NULL);
639
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000640 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900641 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000642 lyt->layer_destroy(ivilayer);
643 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900644}
645
646static void
647test_layer_create_duplicate(struct test_context *ctx)
648{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900650 struct ivi_layout_layer *ivilayer;
651 struct ivi_layout_layer *duplicatelayer;
652
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000653 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900654 iassert(ivilayer != NULL);
655
656 if (ivilayer != NULL)
657 iassert(ivilayer->ref_count == 1);
658
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000659 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900660 iassert(ivilayer == duplicatelayer);
661
662 if (ivilayer != NULL)
663 iassert(ivilayer->ref_count == 2);
664
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000665 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900666
667 if (ivilayer != NULL)
668 iassert(ivilayer->ref_count == 1);
669
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000670 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900671}
672
673static void
674test_get_layer_after_destory_layer(struct test_context *ctx)
675{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000676 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900677 struct ivi_layout_layer *ivilayer;
678
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000679 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900680 iassert(ivilayer != NULL);
681
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000682 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900683
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000684 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900685 iassert(ivilayer == NULL);
686}
687
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900688static void
689test_screen_id(struct test_context *ctx)
690{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000691 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900692 struct ivi_layout_screen **iviscrns;
693 int32_t screen_length = 0;
694 uint32_t id_screen;
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 id_screen = lyt->get_id_of_screen(iviscrns[i]);
702 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900703 }
704
705 if (screen_length > 0)
706 free(iviscrns);
707}
708
709static void
710test_screen_resolution(struct test_context *ctx)
711{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000712 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900713 struct ivi_layout_screen **iviscrns;
714 int32_t screen_length = 0;
715 struct weston_output *output;
716 int32_t width;
717 int32_t height;
718 int32_t i;
719
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900721 iassert(screen_length > 0);
722
723 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000724 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900725 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000726 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900727 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
728 iassert(width == output->current_mode->width);
729 iassert(height == output->current_mode->height);
730 }
731
732 if (screen_length > 0)
733 free(iviscrns);
734}
735
736static void
737test_screen_render_order(struct test_context *ctx)
738{
739#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000740 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900741 struct ivi_layout_screen **iviscrns;
742 int32_t screen_length = 0;
743 struct ivi_layout_screen *iviscrn;
744 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
745 struct ivi_layout_layer **array;
746 int32_t length = 0;
747 uint32_t i;
748
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000749 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900750 iassert(screen_length > 0);
751
752 if (screen_length <= 0)
753 return;
754
755 iviscrn = iviscrns[0];
756
757 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000758 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900759
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000760 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900761
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000762 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900763
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000764 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900765 iassert(length == LAYER_NUM);
766 for (i = 0; i < LAYER_NUM; i++)
767 iassert(array[i] == ivilayers[i]);
768
769 if (length > 0)
770 free(array);
771
772 array = NULL;
773
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900775
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000776 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900777
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000778 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900779 iassert(length == 0 && array == NULL);
780
781 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000782 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900783
784 free(iviscrns);
785#undef LAYER_NUM
786}
787
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900788static void
789test_screen_bad_resolution(struct test_context *ctx)
790{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000791 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900792 struct ivi_layout_screen **iviscrns;
793 int32_t screen_length = 0;
794 struct ivi_layout_screen *iviscrn;
795 int32_t width;
796 int32_t height;
797
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000798 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900799 iassert(screen_length > 0);
800
801 if (screen_length <= 0)
802 return;
803
804 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000805 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
806 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
807 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900808 free(iviscrns);
809}
810
811static void
812test_screen_bad_render_order(struct test_context *ctx)
813{
814#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000815 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900816 struct ivi_layout_screen **iviscrns;
817 int32_t screen_length;
818 struct ivi_layout_screen *iviscrn;
819 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
820 struct ivi_layout_layer **array;
821 int32_t length = 0;
822 uint32_t i;
823
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000824 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900825 iassert(screen_length > 0);
826
827 if (screen_length <= 0)
828 return;
829
830 iviscrn = iviscrns[0];
831
832 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000833 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900834
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000835 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900836
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000837 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900838
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000839 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
840 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
841 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900842
843 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000844 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900845
846 free(iviscrns);
847#undef LAYER_NUM
848}
849
850static void
851test_commit_changes_after_render_order_set_layer_destroy(
852 struct test_context *ctx)
853{
854#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000855 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900856 struct ivi_layout_screen **iviscrns;
857 int32_t screen_length;
858 struct ivi_layout_screen *iviscrn;
859 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
860 uint32_t i;
861
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000862 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900863 iassert(screen_length > 0);
864
865 if (screen_length <= 0)
866 return;
867
868 iviscrn = iviscrns[0];
869
870 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000871 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900872
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000873 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900874
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000875 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900876
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000877 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900878
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000879 lyt->layer_destroy(ivilayers[0]);
880 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900881
882 free(iviscrns);
883#undef LAYER_NUM
884}
885
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900886static void
887test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
888 const struct ivi_layout_layer_properties *prop,
889 enum ivi_layout_notification_mask mask,
890 void *userdata)
891{
892 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000893 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900894
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000895 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900896 iassert(prop->source_width == 200);
897 iassert(prop->source_height == 300);
898
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000899 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900900 prop->source_width == 200 && prop->source_height == 300)
901 ctx->user_flags = 1;
902}
903
904static void
905test_layer_properties_changed_notification(struct test_context *ctx)
906{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000907 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900908 struct ivi_layout_layer *ivilayer;
909
910 ctx->user_flags = 0;
911
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000912 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900913
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000914 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900915
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000916 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900917
918 iassert(ctx->user_flags == 0);
919
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000920 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900921 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
922
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 == 1);
926
927 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000928 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900929 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
930
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000931 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900932
933 iassert(ctx->user_flags == 0);
934
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000935 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900936
937 ctx->user_flags = 0;
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_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900943}
944
945static void
946test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
947 void *userdata)
948{
949 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000950 const struct ivi_layout_interface *lyt = ctx->layout_interface;
951 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900952
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000953 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900954 iassert(prop->source_width == 200);
955 iassert(prop->source_height == 300);
956
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000957 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900958 prop->source_width == 200 && prop->source_height == 300)
959 ctx->user_flags = 1;
960}
961
962static void
963test_layer_create_notification(struct test_context *ctx)
964{
965#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000966 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900967 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
968 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
969
970 ctx->user_flags = 0;
971
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000972 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900973 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000974 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900975
976 iassert(ctx->user_flags == 1);
977
978 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000979 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900980
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000981 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900982
983 iassert(ctx->user_flags == 0);
984
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000985 lyt->layer_destroy(ivilayers[0]);
986 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900987#undef LAYER_NUM
988}
989
990static void
991test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
992 void *userdata)
993{
994 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000995 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900996 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000997 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900998
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000999 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001000 iassert(prop->source_width == 200);
1001 iassert(prop->source_height == 300);
1002
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001003 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001004 prop->source_width == 200 && prop->source_height == 300)
1005 ctx->user_flags = 1;
1006}
1007
1008static void
1009test_layer_remove_notification(struct test_context *ctx)
1010{
1011#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001012 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001013 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
1014 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
1015
1016 ctx->user_flags = 0;
1017
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001018 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
1019 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001020 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001021 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001022
1023 iassert(ctx->user_flags == 1);
1024
1025 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001026 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
1027 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
1028 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001029
1030 iassert(ctx->user_flags == 0);
1031#undef LAYER_NUM
1032}
1033
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001034static void
1035test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
1036 const struct ivi_layout_layer_properties *prop,
1037 enum ivi_layout_notification_mask mask,
1038 void *userdata)
1039{
1040}
1041
1042static void
1043test_layer_bad_properties_changed_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 struct ivi_layout_layer *ivilayer;
1047
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001048 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001049
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001050 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001051 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001052 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001053
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001054 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001055}
1056
1057static void
1058test_surface_bad_configure_notification(struct test_context *ctx)
1059{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001060 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001061
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001062 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001063}
1064
1065static void
1066test_layer_bad_create_notification(struct test_context *ctx)
1067{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001068 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001069
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001070 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001071}
1072
1073static void
1074test_surface_bad_create_notification(struct test_context *ctx)
1075{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001076 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001077
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001078 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001079}
1080
1081static void
1082test_layer_bad_remove_notification(struct test_context *ctx)
1083{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001084 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001085
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001086 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001087}
1088
1089static void
1090test_surface_bad_remove_notification(struct test_context *ctx)
1091{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001092 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001093
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001094 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001095}
1096
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001097/************************ tests end ********************************/
1098
1099static void
1100run_internal_tests(void *data)
1101{
1102 struct test_context *ctx = data;
1103
1104 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001105 test_surface_bad_destination_rectangle(ctx);
1106 test_surface_bad_orientation(ctx);
1107 test_surface_bad_dimension(ctx);
1108 test_surface_bad_position(ctx);
1109 test_surface_bad_source_rectangle(ctx);
1110 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001111
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001112 test_layer_create(ctx);
1113 test_layer_visibility(ctx);
1114 test_layer_opacity(ctx);
1115 test_layer_orientation(ctx);
1116 test_layer_dimension(ctx);
1117 test_layer_position(ctx);
1118 test_layer_destination_rectangle(ctx);
1119 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001120 test_layer_bad_remove(ctx);
1121 test_layer_bad_visibility(ctx);
1122 test_layer_bad_opacity(ctx);
1123 test_layer_bad_destination_rectangle(ctx);
1124 test_layer_bad_orientation(ctx);
1125 test_layer_bad_dimension(ctx);
1126 test_layer_bad_position(ctx);
1127 test_layer_bad_source_rectangle(ctx);
1128 test_layer_bad_properties(ctx);
1129 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1130 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1131 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1132 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1133 test_commit_changes_after_position_set_layer_destroy(ctx);
1134 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1135 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1136 test_layer_create_duplicate(ctx);
1137 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001138
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001139 test_screen_id(ctx);
1140 test_screen_resolution(ctx);
1141 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001142 test_screen_bad_resolution(ctx);
1143 test_screen_bad_render_order(ctx);
1144 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1145
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001146 test_layer_properties_changed_notification(ctx);
1147 test_layer_create_notification(ctx);
1148 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001149 test_layer_bad_properties_changed_notification(ctx);
1150 test_surface_bad_configure_notification(ctx);
1151 test_layer_bad_create_notification(ctx);
1152 test_surface_bad_create_notification(ctx);
1153 test_layer_bad_remove_notification(ctx);
1154 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001155
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001156 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1157 free(ctx);
1158}
1159
1160int
1161controller_module_init(struct weston_compositor *compositor,
1162 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001163 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001164 size_t iface_version);
1165
1166WL_EXPORT int
1167controller_module_init(struct weston_compositor *compositor,
1168 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001169 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001170 size_t iface_version)
1171{
1172 struct wl_event_loop *loop;
1173 struct test_context *ctx;
1174
1175 /* strict check, since this is an internal test module */
1176 if (iface_version != sizeof(*iface)) {
1177 weston_log("fatal: controller interface mismatch\n");
1178 return -1;
1179 }
1180
1181 ctx = zalloc(sizeof(*ctx));
1182 if (!ctx)
1183 return -1;
1184
1185 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001186 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001187
1188 loop = wl_display_get_event_loop(compositor->wl_display);
1189 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1190
1191 return 0;
1192}