blob: 8dd2e6ac616909673292f8456d8b72a86ff40df5 [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}
92
93static void
94test_surface_bad_dimension(struct test_context *ctx)
95{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000096 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090097
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000098 iassert(lyt->surface_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090099
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000100 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900101}
102
103static void
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900104test_surface_bad_source_rectangle(struct test_context *ctx)
105{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000106 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900107
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000108 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900109}
110
111static void
112test_surface_bad_properties(struct test_context *ctx)
113{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000114 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900115
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000116 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900117}
118
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900119static void
120test_layer_create(struct test_context *ctx)
121{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000122 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900123 uint32_t id1;
124 uint32_t id2;
125 struct ivi_layout_layer *ivilayer;
126 struct ivi_layout_layer *new_ivilayer;
127
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000128 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900129 iassert(ivilayer != NULL);
130
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000131 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900132
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000133 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900134 iassert(ivilayer == new_ivilayer);
135
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000136 id1 = lyt->get_id_of_layer(ivilayer);
137 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900138 iassert(id1 == id2);
139
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000140 lyt->layer_destroy(ivilayer);
141 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900142}
143
144static void
145test_layer_visibility(struct test_context *ctx)
146{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000147 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900148 struct ivi_layout_layer *ivilayer;
149 const struct ivi_layout_layer_properties *prop;
150
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000151 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900152 iassert(ivilayer != NULL);
153
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000154 prop = lyt->get_properties_of_layer(ivilayer);
155
156 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900157
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000158 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900159
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000160 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900161
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000162 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900163
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900164 iassert(prop->visibility == true);
165
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000166 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900167}
168
169static void
170test_layer_opacity(struct test_context *ctx)
171{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000172 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900173 struct ivi_layout_layer *ivilayer;
174 const struct ivi_layout_layer_properties *prop;
175
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000176 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900177 iassert(ivilayer != NULL);
178
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000179 prop = lyt->get_properties_of_layer(ivilayer);
180 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900181
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000182 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900183 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
184
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000185 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900186
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000187 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900188
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900189 iassert(prop->opacity == wl_fixed_from_double(0.5));
190
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000191 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900192}
193
194static void
195test_layer_orientation(struct test_context *ctx)
196{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000197 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198 struct ivi_layout_layer *ivilayer;
199 const struct ivi_layout_layer_properties *prop;
200
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000201 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900202 iassert(ivilayer != NULL);
203
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000204 prop = lyt->get_properties_of_layer(ivilayer);
205 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900206
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000207 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
209
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000210 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900211
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000212 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900213
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900214 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
215
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900217}
218
219static void
220test_layer_dimension(struct test_context *ctx)
221{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000222 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900223 struct ivi_layout_layer *ivilayer;
224 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900225
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000226 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900227 iassert(ivilayer != NULL);
228
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000229 prop = lyt->get_properties_of_layer(ivilayer);
230 iassert(prop->dest_width == 200);
231 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900232
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000233 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900234
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000235 iassert(prop->dest_width == 200);
236 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900237
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000238 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900239
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900240 iassert(prop->dest_width == 400);
241 iassert(prop->dest_height == 600);
242
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000243 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900244}
245
246static void
247test_layer_position(struct test_context *ctx)
248{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000249 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900250 struct ivi_layout_layer *ivilayer;
251 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900252
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000253 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900254 iassert(ivilayer != NULL);
255
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000256 prop = lyt->get_properties_of_layer(ivilayer);
257 iassert(prop->dest_x == 0);
258 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900259
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +0000260 iassert(lyt->layer_set_destination_rectangle(ivilayer, 20, 30,
261 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900262
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000263 iassert(prop->dest_x == 0);
264 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900265
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000266 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900267
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000268 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900269 iassert(prop->dest_x == 20);
270 iassert(prop->dest_y == 30);
271
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000272 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900273}
274
275static void
276test_layer_destination_rectangle(struct test_context *ctx)
277{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000278 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900279 struct ivi_layout_layer *ivilayer;
280 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900281
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000282 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900283 iassert(ivilayer != NULL);
284
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000285 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900286 iassert(prop->dest_width == 200);
287 iassert(prop->dest_height == 300);
288 iassert(prop->dest_x == 0);
289 iassert(prop->dest_y == 0);
290
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000291 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900292 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
293
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000294 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900295 iassert(prop->dest_width == 200);
296 iassert(prop->dest_height == 300);
297 iassert(prop->dest_x == 0);
298 iassert(prop->dest_y == 0);
299
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000300 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900301
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900302 iassert(prop->dest_width == 400);
303 iassert(prop->dest_height == 600);
304 iassert(prop->dest_x == 20);
305 iassert(prop->dest_y == 30);
306
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000307 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900308}
309
310static void
311test_layer_source_rectangle(struct test_context *ctx)
312{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000313 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900314 struct ivi_layout_layer *ivilayer;
315 const struct ivi_layout_layer_properties *prop;
316
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000317 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900318 iassert(ivilayer != NULL);
319
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000320 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900321 iassert(prop->source_width == 200);
322 iassert(prop->source_height == 300);
323 iassert(prop->source_x == 0);
324 iassert(prop->source_y == 0);
325
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000326 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900327 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
328
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000329 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900330 iassert(prop->source_width == 200);
331 iassert(prop->source_height == 300);
332 iassert(prop->source_x == 0);
333 iassert(prop->source_y == 0);
334
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000335 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900336
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000337 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900338 iassert(prop->source_width == 400);
339 iassert(prop->source_height == 600);
340 iassert(prop->source_x == 20);
341 iassert(prop->source_y == 30);
342
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000343 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900344}
345
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900346static void
347test_layer_bad_remove(struct test_context *ctx)
348{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000349 const struct ivi_layout_interface *lyt = ctx->layout_interface;
350 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900351}
352
353static void
354test_layer_bad_visibility(struct test_context *ctx)
355{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000356 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900357
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000358 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900359
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000360 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900361}
362
363static void
364test_layer_bad_opacity(struct test_context *ctx)
365{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000366 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900367 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000368 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900369
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000370 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900371 iassert(ivilayer != NULL);
372
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000373 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900374 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
375
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000376 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900377 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
378
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000379 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900380 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
381
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000382 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900383
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000384 prop = lyt->get_properties_of_layer(ivilayer);
385 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900386
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000387 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900388 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
389
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000390 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900391
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000392 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900393
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000394 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900395 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
396
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000397 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900398
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000399 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900400}
401
402static void
403test_layer_bad_destination_rectangle(struct test_context *ctx)
404{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000405 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900406
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000407 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900408 NULL, 20, 30, 200, 300) == IVI_FAILED);
409}
410
411static void
412test_layer_bad_orientation(struct test_context *ctx)
413{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000414 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900415
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
418
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000419 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900420}
421
422static void
423test_layer_bad_dimension(struct test_context *ctx)
424{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900426 struct ivi_layout_layer *ivilayer;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900427
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000428 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900429 iassert(ivilayer != NULL);
430
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000431 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900432
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000433 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900434
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000435 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900436}
437
438static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900439test_layer_bad_source_rectangle(struct test_context *ctx)
440{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000441 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900442
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000443 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900444 NULL, 20, 30, 200, 300) == IVI_FAILED);
445}
446
447static void
448test_layer_bad_properties(struct test_context *ctx)
449{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000450 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900451
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000452 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900453}
454
455static void
456test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
457{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000458 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900459 struct ivi_layout_layer *ivilayer;
460
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000461 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900462 iassert(ivilayer != NULL);
463
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000464 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
465 lyt->layer_destroy(ivilayer);
466 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900467}
468
469static void
470test_commit_changes_after_opacity_set_layer_destroy(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 struct ivi_layout_layer *ivilayer;
474
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900476 iassert(ivilayer != NULL);
477
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000478 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900479 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000480 lyt->layer_destroy(ivilayer);
481 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900482}
483
484static void
485test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
486{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000487 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900488 struct ivi_layout_layer *ivilayer;
489
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900491 iassert(ivilayer != NULL);
492
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000493 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900494 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000495 lyt->layer_destroy(ivilayer);
496 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900497}
498
499static void
500test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
501{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000502 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900503 struct ivi_layout_layer *ivilayer;
504
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000505 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900506 iassert(ivilayer != NULL);
507
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000508 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
509 lyt->layer_destroy(ivilayer);
510 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900511}
512
513static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900514test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
515{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000516 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900517 struct ivi_layout_layer *ivilayer;
518
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000519 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900520 iassert(ivilayer != NULL);
521
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000522 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900523 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000524 lyt->layer_destroy(ivilayer);
525 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900526}
527
528static void
529test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
530{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000531 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900532 struct ivi_layout_layer *ivilayer;
533
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000534 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900535 iassert(ivilayer != NULL);
536
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000537 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900538 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 lyt->layer_destroy(ivilayer);
540 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900541}
542
543static void
544test_layer_create_duplicate(struct test_context *ctx)
545{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900547 struct ivi_layout_layer *ivilayer;
548 struct ivi_layout_layer *duplicatelayer;
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
553 if (ivilayer != NULL)
554 iassert(ivilayer->ref_count == 1);
555
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000556 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900557 iassert(ivilayer == duplicatelayer);
558
559 if (ivilayer != NULL)
560 iassert(ivilayer->ref_count == 2);
561
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000562 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900563
564 if (ivilayer != NULL)
565 iassert(ivilayer->ref_count == 1);
566
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000567 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900568}
569
570static void
571test_get_layer_after_destory_layer(struct test_context *ctx)
572{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000573 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900574 struct ivi_layout_layer *ivilayer;
575
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000576 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900577 iassert(ivilayer != NULL);
578
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000579 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900580
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000581 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900582 iassert(ivilayer == NULL);
583}
584
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900585static void
586test_screen_id(struct test_context *ctx)
587{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000588 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900589 struct ivi_layout_screen **iviscrns;
590 int32_t screen_length = 0;
591 uint32_t id_screen;
592 int32_t i;
593
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000594 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900595 iassert(screen_length > 0);
596
597 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000598 id_screen = lyt->get_id_of_screen(iviscrns[i]);
599 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900600 }
601
602 if (screen_length > 0)
603 free(iviscrns);
604}
605
606static void
607test_screen_resolution(struct test_context *ctx)
608{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000609 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900610 struct ivi_layout_screen **iviscrns;
611 int32_t screen_length = 0;
612 struct weston_output *output;
613 int32_t width;
614 int32_t height;
615 int32_t i;
616
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000617 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900618 iassert(screen_length > 0);
619
620 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000621 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900622 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000623 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900624 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
625 iassert(width == output->current_mode->width);
626 iassert(height == output->current_mode->height);
627 }
628
629 if (screen_length > 0)
630 free(iviscrns);
631}
632
633static void
634test_screen_render_order(struct test_context *ctx)
635{
636#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000637 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900638 struct ivi_layout_screen **iviscrns;
639 int32_t screen_length = 0;
640 struct ivi_layout_screen *iviscrn;
641 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
642 struct ivi_layout_layer **array;
643 int32_t length = 0;
644 uint32_t i;
645
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900647 iassert(screen_length > 0);
648
649 if (screen_length <= 0)
650 return;
651
652 iviscrn = iviscrns[0];
653
654 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000655 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900656
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000657 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900658
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000659 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900660
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000661 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900662 iassert(length == LAYER_NUM);
663 for (i = 0; i < LAYER_NUM; i++)
664 iassert(array[i] == ivilayers[i]);
665
666 if (length > 0)
667 free(array);
668
669 array = NULL;
670
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000671 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900672
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000673 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900674
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000675 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900676 iassert(length == 0 && array == NULL);
677
678 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000679 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900680
681 free(iviscrns);
682#undef LAYER_NUM
683}
684
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900685static void
686test_screen_bad_resolution(struct test_context *ctx)
687{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000688 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900689 struct ivi_layout_screen **iviscrns;
690 int32_t screen_length = 0;
691 struct ivi_layout_screen *iviscrn;
692 int32_t width;
693 int32_t height;
694
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000695 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900696 iassert(screen_length > 0);
697
698 if (screen_length <= 0)
699 return;
700
701 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000702 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
703 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
704 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900705 free(iviscrns);
706}
707
708static void
709test_screen_bad_render_order(struct test_context *ctx)
710{
711#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000712 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900713 struct ivi_layout_screen **iviscrns;
714 int32_t screen_length;
715 struct ivi_layout_screen *iviscrn;
716 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
717 struct ivi_layout_layer **array;
718 int32_t length = 0;
719 uint32_t i;
720
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000721 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900722 iassert(screen_length > 0);
723
724 if (screen_length <= 0)
725 return;
726
727 iviscrn = iviscrns[0];
728
729 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000730 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900731
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000732 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900733
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000734 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900735
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000736 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
737 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
738 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900739
740 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000741 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900742
743 free(iviscrns);
744#undef LAYER_NUM
745}
746
747static void
748test_commit_changes_after_render_order_set_layer_destroy(
749 struct test_context *ctx)
750{
751#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000752 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900753 struct ivi_layout_screen **iviscrns;
754 int32_t screen_length;
755 struct ivi_layout_screen *iviscrn;
756 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
757 uint32_t i;
758
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000759 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900760 iassert(screen_length > 0);
761
762 if (screen_length <= 0)
763 return;
764
765 iviscrn = iviscrns[0];
766
767 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000768 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900769
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000770 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900771
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000772 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900773
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900775
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000776 lyt->layer_destroy(ivilayers[0]);
777 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900778
779 free(iviscrns);
780#undef LAYER_NUM
781}
782
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900783static void
784test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
785 const struct ivi_layout_layer_properties *prop,
786 enum ivi_layout_notification_mask mask,
787 void *userdata)
788{
789 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000790 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900791
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000792 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900793 iassert(prop->source_width == 200);
794 iassert(prop->source_height == 300);
795
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000796 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900797 prop->source_width == 200 && prop->source_height == 300)
798 ctx->user_flags = 1;
799}
800
801static void
802test_layer_properties_changed_notification(struct test_context *ctx)
803{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000804 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900805 struct ivi_layout_layer *ivilayer;
806
807 ctx->user_flags = 0;
808
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000809 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900810
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000811 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900812
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000813 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900814
815 iassert(ctx->user_flags == 0);
816
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000817 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900818 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
819
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000820 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900821
822 iassert(ctx->user_flags == 1);
823
824 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000825 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900826 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
827
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000828 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900829
830 iassert(ctx->user_flags == 0);
831
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000832 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900833
834 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000835 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900836
837 iassert(ctx->user_flags == 0);
838
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000839 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900840}
841
842static void
843test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
844 void *userdata)
845{
846 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000847 const struct ivi_layout_interface *lyt = ctx->layout_interface;
848 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900849
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000850 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900851 iassert(prop->source_width == 200);
852 iassert(prop->source_height == 300);
853
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000854 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900855 prop->source_width == 200 && prop->source_height == 300)
856 ctx->user_flags = 1;
857}
858
859static void
860test_layer_create_notification(struct test_context *ctx)
861{
862#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000863 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900864 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
865 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
866
867 ctx->user_flags = 0;
868
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000869 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900870 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000871 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900872
873 iassert(ctx->user_flags == 1);
874
875 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000876 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900877
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000878 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900879
880 iassert(ctx->user_flags == 0);
881
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 lyt->layer_destroy(ivilayers[0]);
883 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900884#undef LAYER_NUM
885}
886
887static void
888test_layer_remove_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;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900893 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000894 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900895
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000896 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900897 iassert(prop->source_width == 200);
898 iassert(prop->source_height == 300);
899
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000900 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900901 prop->source_width == 200 && prop->source_height == 300)
902 ctx->user_flags = 1;
903}
904
905static void
906test_layer_remove_notification(struct test_context *ctx)
907{
908#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000909 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900910 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
911 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
912
913 ctx->user_flags = 0;
914
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000915 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
916 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900917 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000918 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900919
920 iassert(ctx->user_flags == 1);
921
922 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000923 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
924 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
925 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900926
927 iassert(ctx->user_flags == 0);
928#undef LAYER_NUM
929}
930
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900931static void
932test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
933 const struct ivi_layout_layer_properties *prop,
934 enum ivi_layout_notification_mask mask,
935 void *userdata)
936{
937}
938
939static void
940test_layer_bad_properties_changed_notification(struct test_context *ctx)
941{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000942 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900943 struct ivi_layout_layer *ivilayer;
944
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000945 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900946
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000947 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900948 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000949 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900950
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000951 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900952}
953
954static void
955test_surface_bad_configure_notification(struct test_context *ctx)
956{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000957 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900958
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000959 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900960}
961
962static void
963test_layer_bad_create_notification(struct test_context *ctx)
964{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000965 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900966
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000967 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900968}
969
970static void
971test_surface_bad_create_notification(struct test_context *ctx)
972{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000973 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900974
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000975 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900976}
977
978static void
979test_layer_bad_remove_notification(struct test_context *ctx)
980{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000981 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900982
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000983 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900984}
985
986static void
987test_surface_bad_remove_notification(struct test_context *ctx)
988{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000989 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900990
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000991 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900992}
993
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200994/************************ tests end ********************************/
995
996static void
997run_internal_tests(void *data)
998{
999 struct test_context *ctx = data;
1000
1001 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001002 test_surface_bad_destination_rectangle(ctx);
1003 test_surface_bad_orientation(ctx);
1004 test_surface_bad_dimension(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001005 test_surface_bad_source_rectangle(ctx);
1006 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001007
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001008 test_layer_create(ctx);
1009 test_layer_visibility(ctx);
1010 test_layer_opacity(ctx);
1011 test_layer_orientation(ctx);
1012 test_layer_dimension(ctx);
1013 test_layer_position(ctx);
1014 test_layer_destination_rectangle(ctx);
1015 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001016 test_layer_bad_remove(ctx);
1017 test_layer_bad_visibility(ctx);
1018 test_layer_bad_opacity(ctx);
1019 test_layer_bad_destination_rectangle(ctx);
1020 test_layer_bad_orientation(ctx);
1021 test_layer_bad_dimension(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001022 test_layer_bad_source_rectangle(ctx);
1023 test_layer_bad_properties(ctx);
1024 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1025 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1026 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1027 test_commit_changes_after_dimension_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001028 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1029 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1030 test_layer_create_duplicate(ctx);
1031 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001032
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001033 test_screen_id(ctx);
1034 test_screen_resolution(ctx);
1035 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001036 test_screen_bad_resolution(ctx);
1037 test_screen_bad_render_order(ctx);
1038 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1039
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001040 test_layer_properties_changed_notification(ctx);
1041 test_layer_create_notification(ctx);
1042 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001043 test_layer_bad_properties_changed_notification(ctx);
1044 test_surface_bad_configure_notification(ctx);
1045 test_layer_bad_create_notification(ctx);
1046 test_surface_bad_create_notification(ctx);
1047 test_layer_bad_remove_notification(ctx);
1048 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001049
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001050 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1051 free(ctx);
1052}
1053
1054int
1055controller_module_init(struct weston_compositor *compositor,
1056 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001057 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001058 size_t iface_version);
1059
1060WL_EXPORT int
1061controller_module_init(struct weston_compositor *compositor,
1062 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001063 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001064 size_t iface_version)
1065{
1066 struct wl_event_loop *loop;
1067 struct test_context *ctx;
1068
1069 /* strict check, since this is an internal test module */
1070 if (iface_version != sizeof(*iface)) {
1071 weston_log("fatal: controller interface mismatch\n");
1072 return -1;
1073 }
1074
1075 ctx = zalloc(sizeof(*ctx));
1076 if (!ctx)
1077 return -1;
1078
1079 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001080 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001081
1082 loop = wl_display_get_event_loop(compositor->wl_display);
1083 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1084
1085 return 0;
1086}