blob: 4436c2c123f7e0dddd96320c8b63c8fe05fca7b4 [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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000100 iassert(lyt->surface_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900101
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000102 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900103}
104
105static void
106test_surface_bad_position(struct test_context *ctx)
107{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000108 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900109
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000110 iassert(lyt->surface_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900111
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000112 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900113}
114
115static void
116test_surface_bad_source_rectangle(struct test_context *ctx)
117{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000118 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900119
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000120 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900121}
122
123static void
124test_surface_bad_properties(struct test_context *ctx)
125{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000126 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900127
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000128 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900129}
130
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900131static void
132test_layer_create(struct test_context *ctx)
133{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000134 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900135 uint32_t id1;
136 uint32_t id2;
137 struct ivi_layout_layer *ivilayer;
138 struct ivi_layout_layer *new_ivilayer;
139
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000140 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900141 iassert(ivilayer != NULL);
142
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000143 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900144
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000145 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900146 iassert(ivilayer == new_ivilayer);
147
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000148 id1 = lyt->get_id_of_layer(ivilayer);
149 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900150 iassert(id1 == id2);
151
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000152 lyt->layer_destroy(ivilayer);
153 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900154}
155
156static void
157test_layer_visibility(struct test_context *ctx)
158{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000159 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900160 struct ivi_layout_layer *ivilayer;
161 const struct ivi_layout_layer_properties *prop;
162
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000163 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900164 iassert(ivilayer != NULL);
165
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000166 prop = lyt->get_properties_of_layer(ivilayer);
167
168 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900169
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000170 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900171
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000172 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900173
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000174 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900175
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900176 iassert(prop->visibility == true);
177
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000178 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900179}
180
181static void
182test_layer_opacity(struct test_context *ctx)
183{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000184 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900185 struct ivi_layout_layer *ivilayer;
186 const struct ivi_layout_layer_properties *prop;
187
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000188 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900189 iassert(ivilayer != NULL);
190
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000191 prop = lyt->get_properties_of_layer(ivilayer);
192 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900193
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000194 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900195 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
196
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000197 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000199 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900200
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900201 iassert(prop->opacity == wl_fixed_from_double(0.5));
202
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000203 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900204}
205
206static void
207test_layer_orientation(struct test_context *ctx)
208{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000209 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900210 struct ivi_layout_layer *ivilayer;
211 const struct ivi_layout_layer_properties *prop;
212
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000213 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900214 iassert(ivilayer != NULL);
215
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900217
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000218 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900219 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
220
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000221 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900222
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000223 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900224
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000225 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900226
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000227 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900228 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
229
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000230 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231}
232
233static void
234test_layer_dimension(struct test_context *ctx)
235{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000236 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900237 struct ivi_layout_layer *ivilayer;
238 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900239
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000240 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900241 iassert(ivilayer != NULL);
242
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000243 prop = lyt->get_properties_of_layer(ivilayer);
244 iassert(prop->dest_width == 200);
245 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900246
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000247 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900248
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000249 iassert(prop->dest_width == 200);
250 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900251
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000252 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900253
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900254 iassert(prop->dest_width == 400);
255 iassert(prop->dest_height == 600);
256
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000257 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900258}
259
260static void
261test_layer_position(struct test_context *ctx)
262{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000263 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900264 struct ivi_layout_layer *ivilayer;
265 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900266
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000267 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900268 iassert(ivilayer != NULL);
269
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000270 prop = lyt->get_properties_of_layer(ivilayer);
271 iassert(prop->dest_x == 0);
272 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900273
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000274 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900275
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000276 iassert(prop->dest_x == 0);
277 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900278
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000279 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900280
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000281 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900282 iassert(prop->dest_x == 20);
283 iassert(prop->dest_y == 30);
284
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000285 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900286}
287
288static void
289test_layer_destination_rectangle(struct test_context *ctx)
290{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000291 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900292 struct ivi_layout_layer *ivilayer;
293 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900294
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000295 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900296 iassert(ivilayer != NULL);
297
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000298 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900299 iassert(prop->dest_width == 200);
300 iassert(prop->dest_height == 300);
301 iassert(prop->dest_x == 0);
302 iassert(prop->dest_y == 0);
303
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000304 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900305 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
306
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000307 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900308 iassert(prop->dest_width == 200);
309 iassert(prop->dest_height == 300);
310 iassert(prop->dest_x == 0);
311 iassert(prop->dest_y == 0);
312
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000313 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900314
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900315 iassert(prop->dest_width == 400);
316 iassert(prop->dest_height == 600);
317 iassert(prop->dest_x == 20);
318 iassert(prop->dest_y == 30);
319
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000320 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900321}
322
323static void
324test_layer_source_rectangle(struct test_context *ctx)
325{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000326 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900327 struct ivi_layout_layer *ivilayer;
328 const struct ivi_layout_layer_properties *prop;
329
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000330 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900331 iassert(ivilayer != NULL);
332
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000333 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900334 iassert(prop->source_width == 200);
335 iassert(prop->source_height == 300);
336 iassert(prop->source_x == 0);
337 iassert(prop->source_y == 0);
338
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000339 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900340 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
341
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000342 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900343 iassert(prop->source_width == 200);
344 iassert(prop->source_height == 300);
345 iassert(prop->source_x == 0);
346 iassert(prop->source_y == 0);
347
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000348 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900349
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000350 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900351 iassert(prop->source_width == 400);
352 iassert(prop->source_height == 600);
353 iassert(prop->source_x == 20);
354 iassert(prop->source_y == 30);
355
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000356 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900357}
358
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900359static void
360test_layer_bad_remove(struct test_context *ctx)
361{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000362 const struct ivi_layout_interface *lyt = ctx->layout_interface;
363 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900364}
365
366static void
367test_layer_bad_visibility(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 Tanibata17d44942015-06-22 15:35:12 +0900370
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000371 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900372
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000373 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900374}
375
376static void
377test_layer_bad_opacity(struct test_context *ctx)
378{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000379 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900380 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000381 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900382
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000383 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900384 iassert(ivilayer != NULL);
385
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000386 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900387 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
388
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000389 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900390 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
391
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000392 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900393 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
394
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000395 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900396
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000397 prop = lyt->get_properties_of_layer(ivilayer);
398 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900399
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000400 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900401 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
402
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000403 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900404
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000405 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900406
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000407 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900408 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
409
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000410 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900411
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000412 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900413}
414
415static void
416test_layer_bad_destination_rectangle(struct test_context *ctx)
417{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000418 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900419
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000420 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900421 NULL, 20, 30, 200, 300) == IVI_FAILED);
422}
423
424static void
425test_layer_bad_orientation(struct test_context *ctx)
426{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000427 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900428
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000429 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900430 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
431
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000432 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900433
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000434 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900435}
436
437static void
438test_layer_bad_dimension(struct test_context *ctx)
439{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000440 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900441 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900442
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000443 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900444 iassert(ivilayer != NULL);
445
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900447
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000448 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900449
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000450 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900451}
452
453static void
454test_layer_bad_position(struct test_context *ctx)
455{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000456 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900457 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900458
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000459 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900460 iassert(ivilayer != NULL);
461
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000462 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900463
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000464 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900465
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000466 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900467}
468
469static void
470test_layer_bad_source_rectangle(struct test_context *ctx)
471{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000472 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900473
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000474 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900475 NULL, 20, 30, 200, 300) == IVI_FAILED);
476}
477
478static void
479test_layer_bad_properties(struct test_context *ctx)
480{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000481 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900482
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000483 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900484}
485
486static void
487test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
488{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000489 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900490 struct ivi_layout_layer *ivilayer;
491
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000492 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900493 iassert(ivilayer != NULL);
494
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000495 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
496 lyt->layer_destroy(ivilayer);
497 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900498}
499
500static void
501test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
502{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000503 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900504 struct ivi_layout_layer *ivilayer;
505
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000506 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900507 iassert(ivilayer != NULL);
508
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900510 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000511 lyt->layer_destroy(ivilayer);
512 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900513}
514
515static void
516test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
517{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000518 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900519 struct ivi_layout_layer *ivilayer;
520
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000521 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900522 iassert(ivilayer != NULL);
523
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000524 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900525 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000526 lyt->layer_destroy(ivilayer);
527 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900528}
529
530static void
531test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
532{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000533 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900534 struct ivi_layout_layer *ivilayer;
535
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000536 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900537 iassert(ivilayer != NULL);
538
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
540 lyt->layer_destroy(ivilayer);
541 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900542}
543
544static void
545test_commit_changes_after_position_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_position(ivilayer, 20, 30) == 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_source_rectangle_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_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900568 ivilayer, 20, 30, 200, 300) == 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_destination_rectangle_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_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900583 ivilayer, 20, 30, 200, 300) == 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_layer_create_duplicate(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 struct ivi_layout_layer *duplicatelayer;
594
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000595 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900596 iassert(ivilayer != NULL);
597
598 if (ivilayer != NULL)
599 iassert(ivilayer->ref_count == 1);
600
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000601 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900602 iassert(ivilayer == duplicatelayer);
603
604 if (ivilayer != NULL)
605 iassert(ivilayer->ref_count == 2);
606
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000607 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900608
609 if (ivilayer != NULL)
610 iassert(ivilayer->ref_count == 1);
611
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000612 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900613}
614
615static void
616test_get_layer_after_destory_layer(struct test_context *ctx)
617{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000618 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900619 struct ivi_layout_layer *ivilayer;
620
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000621 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900622 iassert(ivilayer != NULL);
623
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000624 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900625
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000626 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900627 iassert(ivilayer == NULL);
628}
629
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900630static void
631test_screen_id(struct test_context *ctx)
632{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000633 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900634 struct ivi_layout_screen **iviscrns;
635 int32_t screen_length = 0;
636 uint32_t id_screen;
637 int32_t i;
638
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000639 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900640 iassert(screen_length > 0);
641
642 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000643 id_screen = lyt->get_id_of_screen(iviscrns[i]);
644 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900645 }
646
647 if (screen_length > 0)
648 free(iviscrns);
649}
650
651static void
652test_screen_resolution(struct test_context *ctx)
653{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000654 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900655 struct ivi_layout_screen **iviscrns;
656 int32_t screen_length = 0;
657 struct weston_output *output;
658 int32_t width;
659 int32_t height;
660 int32_t i;
661
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000662 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900663 iassert(screen_length > 0);
664
665 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000666 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900667 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000668 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900669 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
670 iassert(width == output->current_mode->width);
671 iassert(height == output->current_mode->height);
672 }
673
674 if (screen_length > 0)
675 free(iviscrns);
676}
677
678static void
679test_screen_render_order(struct test_context *ctx)
680{
681#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000682 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900683 struct ivi_layout_screen **iviscrns;
684 int32_t screen_length = 0;
685 struct ivi_layout_screen *iviscrn;
686 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
687 struct ivi_layout_layer **array;
688 int32_t length = 0;
689 uint32_t i;
690
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000691 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900692 iassert(screen_length > 0);
693
694 if (screen_length <= 0)
695 return;
696
697 iviscrn = iviscrns[0];
698
699 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900701
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000702 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900703
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000704 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900705
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000706 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900707 iassert(length == LAYER_NUM);
708 for (i = 0; i < LAYER_NUM; i++)
709 iassert(array[i] == ivilayers[i]);
710
711 if (length > 0)
712 free(array);
713
714 array = NULL;
715
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000716 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900717
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000718 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900719
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900721 iassert(length == 0 && array == NULL);
722
723 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000724 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900725
726 free(iviscrns);
727#undef LAYER_NUM
728}
729
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900730static void
731test_screen_bad_resolution(struct test_context *ctx)
732{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000733 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900734 struct ivi_layout_screen **iviscrns;
735 int32_t screen_length = 0;
736 struct ivi_layout_screen *iviscrn;
737 int32_t width;
738 int32_t height;
739
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000740 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900741 iassert(screen_length > 0);
742
743 if (screen_length <= 0)
744 return;
745
746 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000747 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
748 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
749 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900750 free(iviscrns);
751}
752
753static void
754test_screen_bad_render_order(struct test_context *ctx)
755{
756#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000757 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900758 struct ivi_layout_screen **iviscrns;
759 int32_t screen_length;
760 struct ivi_layout_screen *iviscrn;
761 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
762 struct ivi_layout_layer **array;
763 int32_t length = 0;
764 uint32_t i;
765
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000766 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900767 iassert(screen_length > 0);
768
769 if (screen_length <= 0)
770 return;
771
772 iviscrn = iviscrns[0];
773
774 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000775 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900776
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000777 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900778
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000779 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900780
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000781 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
782 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
783 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900784
785 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000786 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900787
788 free(iviscrns);
789#undef LAYER_NUM
790}
791
792static void
793test_commit_changes_after_render_order_set_layer_destroy(
794 struct test_context *ctx)
795{
796#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000797 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900798 struct ivi_layout_screen **iviscrns;
799 int32_t screen_length;
800 struct ivi_layout_screen *iviscrn;
801 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
802 uint32_t i;
803
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000804 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900805 iassert(screen_length > 0);
806
807 if (screen_length <= 0)
808 return;
809
810 iviscrn = iviscrns[0];
811
812 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000813 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900814
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000815 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900816
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000817 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900818
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000819 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900820
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000821 lyt->layer_destroy(ivilayers[0]);
822 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900823
824 free(iviscrns);
825#undef LAYER_NUM
826}
827
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900828static void
829test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
830 const struct ivi_layout_layer_properties *prop,
831 enum ivi_layout_notification_mask mask,
832 void *userdata)
833{
834 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000835 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900836
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000837 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900838 iassert(prop->source_width == 200);
839 iassert(prop->source_height == 300);
840
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000841 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900842 prop->source_width == 200 && prop->source_height == 300)
843 ctx->user_flags = 1;
844}
845
846static void
847test_layer_properties_changed_notification(struct test_context *ctx)
848{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000849 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900850 struct ivi_layout_layer *ivilayer;
851
852 ctx->user_flags = 0;
853
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000854 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900855
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000856 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900857
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000858 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900859
860 iassert(ctx->user_flags == 0);
861
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000862 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900863 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
864
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000865 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900866
867 iassert(ctx->user_flags == 1);
868
869 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000870 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900871 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
872
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000873 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900874
875 iassert(ctx->user_flags == 0);
876
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000877 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900878
879 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000880 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900881
882 iassert(ctx->user_flags == 0);
883
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000884 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900885}
886
887static void
888test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
889 void *userdata)
890{
891 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000892 const struct ivi_layout_interface *lyt = ctx->layout_interface;
893 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
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_create_notification(struct test_context *ctx)
906{
907#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000908 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900909 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
910 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
911
912 ctx->user_flags = 0;
913
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000914 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900915 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000916 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900917
918 iassert(ctx->user_flags == 1);
919
920 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000921 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900922
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000923 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900924
925 iassert(ctx->user_flags == 0);
926
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000927 lyt->layer_destroy(ivilayers[0]);
928 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900929#undef LAYER_NUM
930}
931
932static void
933test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
934 void *userdata)
935{
936 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000937 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900938 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000939 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900940
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000941 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900942 iassert(prop->source_width == 200);
943 iassert(prop->source_height == 300);
944
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000945 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900946 prop->source_width == 200 && prop->source_height == 300)
947 ctx->user_flags = 1;
948}
949
950static void
951test_layer_remove_notification(struct test_context *ctx)
952{
953#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000954 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900955 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
956 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
957
958 ctx->user_flags = 0;
959
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000960 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
961 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900962 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000963 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900964
965 iassert(ctx->user_flags == 1);
966
967 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000968 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
969 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
970 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900971
972 iassert(ctx->user_flags == 0);
973#undef LAYER_NUM
974}
975
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900976static void
977test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
978 const struct ivi_layout_layer_properties *prop,
979 enum ivi_layout_notification_mask mask,
980 void *userdata)
981{
982}
983
984static void
985test_layer_bad_properties_changed_notification(struct test_context *ctx)
986{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000987 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900988 struct ivi_layout_layer *ivilayer;
989
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000990 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900991
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000992 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900993 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000994 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900995
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000996 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900997}
998
999static void
1000test_surface_bad_configure_notification(struct test_context *ctx)
1001{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001002 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001003
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001004 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001005}
1006
1007static void
1008test_layer_bad_create_notification(struct test_context *ctx)
1009{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001010 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001011
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001012 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001013}
1014
1015static void
1016test_surface_bad_create_notification(struct test_context *ctx)
1017{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001018 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001019
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001020 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001021}
1022
1023static void
1024test_layer_bad_remove_notification(struct test_context *ctx)
1025{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001026 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001027
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001028 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001029}
1030
1031static void
1032test_surface_bad_remove_notification(struct test_context *ctx)
1033{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001034 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001035
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001036 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001037}
1038
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001039/************************ tests end ********************************/
1040
1041static void
1042run_internal_tests(void *data)
1043{
1044 struct test_context *ctx = data;
1045
1046 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001047 test_surface_bad_destination_rectangle(ctx);
1048 test_surface_bad_orientation(ctx);
1049 test_surface_bad_dimension(ctx);
1050 test_surface_bad_position(ctx);
1051 test_surface_bad_source_rectangle(ctx);
1052 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001053
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001054 test_layer_create(ctx);
1055 test_layer_visibility(ctx);
1056 test_layer_opacity(ctx);
1057 test_layer_orientation(ctx);
1058 test_layer_dimension(ctx);
1059 test_layer_position(ctx);
1060 test_layer_destination_rectangle(ctx);
1061 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001062 test_layer_bad_remove(ctx);
1063 test_layer_bad_visibility(ctx);
1064 test_layer_bad_opacity(ctx);
1065 test_layer_bad_destination_rectangle(ctx);
1066 test_layer_bad_orientation(ctx);
1067 test_layer_bad_dimension(ctx);
1068 test_layer_bad_position(ctx);
1069 test_layer_bad_source_rectangle(ctx);
1070 test_layer_bad_properties(ctx);
1071 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1072 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1073 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1074 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1075 test_commit_changes_after_position_set_layer_destroy(ctx);
1076 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1077 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1078 test_layer_create_duplicate(ctx);
1079 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001080
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001081 test_screen_id(ctx);
1082 test_screen_resolution(ctx);
1083 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001084 test_screen_bad_resolution(ctx);
1085 test_screen_bad_render_order(ctx);
1086 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1087
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001088 test_layer_properties_changed_notification(ctx);
1089 test_layer_create_notification(ctx);
1090 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001091 test_layer_bad_properties_changed_notification(ctx);
1092 test_surface_bad_configure_notification(ctx);
1093 test_layer_bad_create_notification(ctx);
1094 test_surface_bad_create_notification(ctx);
1095 test_layer_bad_remove_notification(ctx);
1096 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001097
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001098 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1099 free(ctx);
1100}
1101
1102int
1103controller_module_init(struct weston_compositor *compositor,
1104 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001105 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001106 size_t iface_version);
1107
1108WL_EXPORT int
1109controller_module_init(struct weston_compositor *compositor,
1110 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001111 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001112 size_t iface_version)
1113{
1114 struct wl_event_loop *loop;
1115 struct test_context *ctx;
1116
1117 /* strict check, since this is an internal test module */
1118 if (iface_version != sizeof(*iface)) {
1119 weston_log("fatal: controller interface mismatch\n");
1120 return -1;
1121 }
1122
1123 ctx = zalloc(sizeof(*ctx));
1124 if (!ctx)
1125 return -1;
1126
1127 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001128 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001129
1130 loop = wl_display_get_event_loop(compositor->wl_display);
1131 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1132
1133 return 0;
1134}