blob: d0c759b5815a926115537dbded62580b9a015534 [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 bool visibility;
72
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000073 iassert(lyt->surface_set_visibility(NULL, true) == IVI_FAILED);
Pekka Paalanen46804ca2015-03-27 11:55:21 +020074
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000075 lyt->commit_changes();
Pekka Paalanen46804ca2015-03-27 11:55:21 +020076
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000077 visibility = lyt->surface_get_visibility(NULL);
Pekka Paalanen46804ca2015-03-27 11:55:21 +020078 iassert(visibility == false);
79}
80
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090081static void
82test_surface_bad_destination_rectangle(struct test_context *ctx)
83{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000084 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090085
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000086 iassert(lyt->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090087}
88
89static void
90test_surface_bad_orientation(struct test_context *ctx)
91{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000092 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090093
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000094 iassert(lyt->surface_set_orientation(NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090095
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000096 iassert(lyt->surface_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090097}
98
99static void
100test_surface_bad_dimension(struct test_context *ctx)
101{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000102 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900103 struct ivi_layout_surface *ivisurf = NULL;
104 int32_t dest_width;
105 int32_t dest_height;
106
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000107 iassert(lyt->surface_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900108
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000109 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900110
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000111 iassert(lyt->surface_get_dimension(NULL, &dest_width, &dest_height) == IVI_FAILED);
112 iassert(lyt->surface_get_dimension(ivisurf, NULL, &dest_height) == IVI_FAILED);
113 iassert(lyt->surface_get_dimension(ivisurf, &dest_width, NULL) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900114}
115
116static void
117test_surface_bad_position(struct test_context *ctx)
118{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000119 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900120 struct ivi_layout_surface *ivisurf = NULL;
121 int32_t dest_x;
122 int32_t dest_y;
123
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000124 iassert(lyt->surface_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900125
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000126 lyt->commit_changes();
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900127
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000128 iassert(lyt->surface_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED);
129 iassert(lyt->surface_get_position(ivisurf, NULL, &dest_y) == IVI_FAILED);
130 iassert(lyt->surface_get_position(ivisurf, &dest_x, NULL) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900131}
132
133static void
134test_surface_bad_source_rectangle(struct test_context *ctx)
135{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000136 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900137
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000138 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900139}
140
141static void
142test_surface_bad_properties(struct test_context *ctx)
143{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000144 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900145
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000146 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900147}
148
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900149static void
150test_layer_create(struct test_context *ctx)
151{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000152 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900153 uint32_t id1;
154 uint32_t id2;
155 struct ivi_layout_layer *ivilayer;
156 struct ivi_layout_layer *new_ivilayer;
157
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000158 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900159 iassert(ivilayer != NULL);
160
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000161 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900162
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000163 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900164 iassert(ivilayer == new_ivilayer);
165
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000166 id1 = lyt->get_id_of_layer(ivilayer);
167 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900168 iassert(id1 == id2);
169
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000170 lyt->layer_destroy(ivilayer);
171 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900172}
173
174static void
175test_layer_visibility(struct test_context *ctx)
176{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000177 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900178 struct ivi_layout_layer *ivilayer;
179 const struct ivi_layout_layer_properties *prop;
180
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000181 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900182 iassert(ivilayer != NULL);
183
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000184 iassert(lyt->layer_get_visibility(ivilayer) == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900185
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000186 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900187
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000188 iassert(lyt->layer_get_visibility(ivilayer) == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900189
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000190 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900191
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000192 iassert(lyt->layer_get_visibility(ivilayer) == true);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900193
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000194 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900195 iassert(prop->visibility == true);
196
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000197 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198}
199
200static void
201test_layer_opacity(struct test_context *ctx)
202{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000203 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900204 struct ivi_layout_layer *ivilayer;
205 const struct ivi_layout_layer_properties *prop;
206
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000207 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900208 iassert(ivilayer != NULL);
209
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000210 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900211
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000212 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900213 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
214
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000215 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900216
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000217 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900218
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000219 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.5));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900220
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000221 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900222 iassert(prop->opacity == wl_fixed_from_double(0.5));
223
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000224 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900225}
226
227static void
228test_layer_orientation(struct test_context *ctx)
229{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000230 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231 struct ivi_layout_layer *ivilayer;
232 const struct ivi_layout_layer_properties *prop;
233
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000234 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900235 iassert(ivilayer != NULL);
236
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000237 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900238
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000239 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900240 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
241
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000242 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900243
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000244 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900245
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000246 iassert(lyt->layer_get_orientation(ivilayer) == WL_OUTPUT_TRANSFORM_90);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900247
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000248 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900249 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
250
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000251 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900252}
253
254static void
255test_layer_dimension(struct test_context *ctx)
256{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000257 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900258 struct ivi_layout_layer *ivilayer;
259 const struct ivi_layout_layer_properties *prop;
260 int32_t dest_width;
261 int32_t dest_height;
262
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000263 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900264 iassert(ivilayer != NULL);
265
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000266 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900267 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
268 iassert(dest_width == 200);
269 iassert(dest_height == 300);
270
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000271 iassert(lyt->layer_set_dimension(ivilayer, 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900272
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000273 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900274 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
275 iassert(dest_width == 200);
276 iassert(dest_height == 300);
277
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000278 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900279
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000280 iassert(IVI_SUCCEEDED == lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900281 ivilayer, &dest_width, &dest_height));
282 iassert(dest_width == 400);
283 iassert(dest_height == 600);
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 == 400);
287 iassert(prop->dest_height == 600);
288
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000289 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900290}
291
292static void
293test_layer_position(struct test_context *ctx)
294{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000295 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900296 struct ivi_layout_layer *ivilayer;
297 const struct ivi_layout_layer_properties *prop;
298 int32_t dest_x;
299 int32_t dest_y;
300
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000301 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900302 iassert(ivilayer != NULL);
303
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000304 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900305 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
306 iassert(dest_x == 0);
307 iassert(dest_y == 0);
308
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000309 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900310
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000311 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900312 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
313 iassert(dest_x == 0);
314 iassert(dest_y == 0);
315
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000316 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900317
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000318 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900319 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
320 iassert(dest_x == 20);
321 iassert(dest_y == 30);
322
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000323 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900324 iassert(prop->dest_x == 20);
325 iassert(prop->dest_y == 30);
326
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000327 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900328}
329
330static void
331test_layer_destination_rectangle(struct test_context *ctx)
332{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000333 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900334 struct ivi_layout_layer *ivilayer;
335 const struct ivi_layout_layer_properties *prop;
336 int32_t dest_width;
337 int32_t dest_height;
338 int32_t dest_x;
339 int32_t dest_y;
340
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000341 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900342 iassert(ivilayer != NULL);
343
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000344 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900345 iassert(prop->dest_width == 200);
346 iassert(prop->dest_height == 300);
347 iassert(prop->dest_x == 0);
348 iassert(prop->dest_y == 0);
349
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000350 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900351 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
352
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000353 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900354 iassert(prop->dest_width == 200);
355 iassert(prop->dest_height == 300);
356 iassert(prop->dest_x == 0);
357 iassert(prop->dest_y == 0);
358
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000359 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900360
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000361 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900362 ivilayer, &dest_width, &dest_height) == IVI_SUCCEEDED);
363 iassert(dest_width == 400);
364 iassert(dest_height == 600);
365
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000366 iassert(lyt->layer_get_position(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900367 ivilayer, &dest_x, &dest_y) == IVI_SUCCEEDED);
368 iassert(dest_x == 20);
369 iassert(dest_y == 30);
370
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000371 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900372 iassert(prop->dest_width == 400);
373 iassert(prop->dest_height == 600);
374 iassert(prop->dest_x == 20);
375 iassert(prop->dest_y == 30);
376
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000377 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900378}
379
380static void
381test_layer_source_rectangle(struct test_context *ctx)
382{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000383 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900384 struct ivi_layout_layer *ivilayer;
385 const struct ivi_layout_layer_properties *prop;
386
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000387 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900388 iassert(ivilayer != NULL);
389
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000390 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900391 iassert(prop->source_width == 200);
392 iassert(prop->source_height == 300);
393 iassert(prop->source_x == 0);
394 iassert(prop->source_y == 0);
395
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000396 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900397 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
398
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000399 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900400 iassert(prop->source_width == 200);
401 iassert(prop->source_height == 300);
402 iassert(prop->source_x == 0);
403 iassert(prop->source_y == 0);
404
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000405 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900406
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000407 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900408 iassert(prop->source_width == 400);
409 iassert(prop->source_height == 600);
410 iassert(prop->source_x == 20);
411 iassert(prop->source_y == 30);
412
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000413 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900414}
415
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900416static void
417test_layer_bad_remove(struct test_context *ctx)
418{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000419 const struct ivi_layout_interface *lyt = ctx->layout_interface;
420 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900421}
422
423static void
424test_layer_bad_visibility(struct test_context *ctx)
425{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000426 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900427
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000428 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900429
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000430 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900431
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000432 iassert(lyt->layer_get_visibility(NULL) == false);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900433}
434
435static void
436test_layer_bad_opacity(struct test_context *ctx)
437{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000438 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900439 struct ivi_layout_layer *ivilayer;
440
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000441 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900442 iassert(ivilayer != NULL);
443
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000444 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900445 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
446
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000447 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900448 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
449
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000450 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900451 ivilayer, wl_fixed_from_double(-1)) == IVI_FAILED);
452
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000455 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900456
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000457 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900458 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
459
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000460 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900461
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000462 iassert(lyt->layer_get_opacity(ivilayer) == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900463
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000464 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900465 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
466
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000467 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900468
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000469 iassert(lyt->layer_get_opacity(NULL) == wl_fixed_from_double(0.0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900470
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000471 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900472}
473
474static void
475test_layer_bad_destination_rectangle(struct test_context *ctx)
476{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000477 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900478
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000479 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900480 NULL, 20, 30, 200, 300) == IVI_FAILED);
481}
482
483static void
484test_layer_bad_orientation(struct test_context *ctx)
485{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000486 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900487
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000488 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900489 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
490
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000491 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900492
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000493 iassert(lyt->layer_get_orientation(NULL) == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900494}
495
496static void
497test_layer_bad_dimension(struct test_context *ctx)
498{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000499 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900500 struct ivi_layout_layer *ivilayer;
501 int32_t dest_width;
502 int32_t dest_height;
503
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000504 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900505 iassert(ivilayer != NULL);
506
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000507 iassert(lyt->layer_set_dimension(NULL, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900508
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900510
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000511 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900512 NULL, &dest_width, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000513 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900514 ivilayer, NULL, &dest_height) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000515 iassert(lyt->layer_get_dimension(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900516 ivilayer, &dest_width, NULL) == IVI_FAILED);
517
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000518 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900519}
520
521static void
522test_layer_bad_position(struct test_context *ctx)
523{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000524 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900525 struct ivi_layout_layer *ivilayer;
526 int32_t dest_x;
527 int32_t dest_y;
528
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000529 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900530 iassert(ivilayer != NULL);
531
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000532 iassert(lyt->layer_set_position(NULL, 20, 30) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900533
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000534 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900535
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000536 iassert(lyt->layer_get_position(NULL, &dest_x, &dest_y) == IVI_FAILED);
537 iassert(lyt->layer_get_position(ivilayer, NULL, &dest_y) == IVI_FAILED);
538 iassert(lyt->layer_get_position(ivilayer, &dest_x, NULL) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900539
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000540 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900541}
542
543static void
544test_layer_bad_source_rectangle(struct test_context *ctx)
545{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900547
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000548 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900549 NULL, 20, 30, 200, 300) == IVI_FAILED);
550}
551
552static void
553test_layer_bad_properties(struct test_context *ctx)
554{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000555 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900556
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000557 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900558}
559
560static void
561test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
562{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000563 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900564 struct ivi_layout_layer *ivilayer;
565
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000566 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900567 iassert(ivilayer != NULL);
568
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000569 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
570 lyt->layer_destroy(ivilayer);
571 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900572}
573
574static void
575test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
576{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000577 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900578 struct ivi_layout_layer *ivilayer;
579
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000580 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900581 iassert(ivilayer != NULL);
582
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000583 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900584 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000585 lyt->layer_destroy(ivilayer);
586 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900587}
588
589static void
590test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
591{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000592 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900593 struct ivi_layout_layer *ivilayer;
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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000598 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900599 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000600 lyt->layer_destroy(ivilayer);
601 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900602}
603
604static void
605test_commit_changes_after_dimension_set_layer_destroy(struct test_context *ctx)
606{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000607 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900608 struct ivi_layout_layer *ivilayer;
609
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000610 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900611 iassert(ivilayer != NULL);
612
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000613 iassert(lyt->layer_set_dimension(ivilayer, 200, 300) == IVI_SUCCEEDED);
614 lyt->layer_destroy(ivilayer);
615 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900616}
617
618static void
619test_commit_changes_after_position_set_layer_destroy(struct test_context *ctx)
620{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000621 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900622 struct ivi_layout_layer *ivilayer;
623
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000624 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900625 iassert(ivilayer != NULL);
626
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000627 iassert(lyt->layer_set_position(ivilayer, 20, 30) == IVI_SUCCEEDED);
628 lyt->layer_destroy(ivilayer);
629 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900630}
631
632static void
633test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
634{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000635 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900636 struct ivi_layout_layer *ivilayer;
637
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000638 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900639 iassert(ivilayer != NULL);
640
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000641 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900642 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000643 lyt->layer_destroy(ivilayer);
644 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900645}
646
647static void
648test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
649{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000650 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900651 struct ivi_layout_layer *ivilayer;
652
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000653 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900654 iassert(ivilayer != NULL);
655
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000656 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900657 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000658 lyt->layer_destroy(ivilayer);
659 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900660}
661
662static void
663test_layer_create_duplicate(struct test_context *ctx)
664{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000665 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900666 struct ivi_layout_layer *ivilayer;
667 struct ivi_layout_layer *duplicatelayer;
668
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000669 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900670 iassert(ivilayer != NULL);
671
672 if (ivilayer != NULL)
673 iassert(ivilayer->ref_count == 1);
674
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000675 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900676 iassert(ivilayer == duplicatelayer);
677
678 if (ivilayer != NULL)
679 iassert(ivilayer->ref_count == 2);
680
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000681 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900682
683 if (ivilayer != NULL)
684 iassert(ivilayer->ref_count == 1);
685
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000686 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900687}
688
689static void
690test_get_layer_after_destory_layer(struct test_context *ctx)
691{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000692 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900693 struct ivi_layout_layer *ivilayer;
694
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000695 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900696 iassert(ivilayer != NULL);
697
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000698 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900699
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900701 iassert(ivilayer == NULL);
702}
703
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900704static void
705test_screen_id(struct test_context *ctx)
706{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000707 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900708 struct ivi_layout_screen **iviscrns;
709 int32_t screen_length = 0;
710 uint32_t id_screen;
711 int32_t i;
712
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000713 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900714 iassert(screen_length > 0);
715
716 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000717 id_screen = lyt->get_id_of_screen(iviscrns[i]);
718 iassert(lyt->get_screen_from_id(id_screen) == iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900719 }
720
721 if (screen_length > 0)
722 free(iviscrns);
723}
724
725static void
726test_screen_resolution(struct test_context *ctx)
727{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000728 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900729 struct ivi_layout_screen **iviscrns;
730 int32_t screen_length = 0;
731 struct weston_output *output;
732 int32_t width;
733 int32_t height;
734 int32_t i;
735
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000736 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900737 iassert(screen_length > 0);
738
739 for (i = 0; i < screen_length; ++i) {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000740 output = lyt->screen_get_output(iviscrns[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900741 iassert(output != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000742 iassert(lyt->get_screen_resolution(
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900743 iviscrns[i], &width, &height) == IVI_SUCCEEDED);
744 iassert(width == output->current_mode->width);
745 iassert(height == output->current_mode->height);
746 }
747
748 if (screen_length > 0)
749 free(iviscrns);
750}
751
752static void
753test_screen_render_order(struct test_context *ctx)
754{
755#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000756 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900757 struct ivi_layout_screen **iviscrns;
758 int32_t screen_length = 0;
759 struct ivi_layout_screen *iviscrn;
760 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
761 struct ivi_layout_layer **array;
762 int32_t length = 0;
763 uint32_t i;
764
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000765 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900766 iassert(screen_length > 0);
767
768 if (screen_length <= 0)
769 return;
770
771 iviscrn = iviscrns[0];
772
773 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900775
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000776 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900777
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000778 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900779
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000780 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900781 iassert(length == LAYER_NUM);
782 for (i = 0; i < LAYER_NUM; i++)
783 iassert(array[i] == ivilayers[i]);
784
785 if (length > 0)
786 free(array);
787
788 array = NULL;
789
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000790 iassert(lyt->screen_set_render_order(iviscrn, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900791
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000792 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900793
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000794 iassert(lyt->get_layers_on_screen(iviscrn, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900795 iassert(length == 0 && array == NULL);
796
797 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000798 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900799
800 free(iviscrns);
801#undef LAYER_NUM
802}
803
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900804static void
805test_screen_bad_resolution(struct test_context *ctx)
806{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900808 struct ivi_layout_screen **iviscrns;
809 int32_t screen_length = 0;
810 struct ivi_layout_screen *iviscrn;
811 int32_t width;
812 int32_t height;
813
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000814 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900815 iassert(screen_length > 0);
816
817 if (screen_length <= 0)
818 return;
819
820 iviscrn = iviscrns[0];
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000821 iassert(lyt->get_screen_resolution(NULL, &width, &height) == IVI_FAILED);
822 iassert(lyt->get_screen_resolution(iviscrn, NULL, &height) == IVI_FAILED);
823 iassert(lyt->get_screen_resolution(iviscrn, &width, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900824 free(iviscrns);
825}
826
827static void
828test_screen_bad_render_order(struct test_context *ctx)
829{
830#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000831 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900832 struct ivi_layout_screen **iviscrns;
833 int32_t screen_length;
834 struct ivi_layout_screen *iviscrn;
835 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
836 struct ivi_layout_layer **array;
837 int32_t length = 0;
838 uint32_t i;
839
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000840 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900841 iassert(screen_length > 0);
842
843 if (screen_length <= 0)
844 return;
845
846 iviscrn = iviscrns[0];
847
848 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000849 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900850
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000851 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900852
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000853 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900854
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000855 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
856 iassert(lyt->get_layers_on_screen(iviscrn, NULL, &array) == IVI_FAILED);
857 iassert(lyt->get_layers_on_screen(iviscrn, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900858
859 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000860 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900861
862 free(iviscrns);
863#undef LAYER_NUM
864}
865
866static void
867test_commit_changes_after_render_order_set_layer_destroy(
868 struct test_context *ctx)
869{
870#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000871 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900872 struct ivi_layout_screen **iviscrns;
873 int32_t screen_length;
874 struct ivi_layout_screen *iviscrn;
875 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
876 uint32_t i;
877
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000878 iassert(lyt->get_screens(&screen_length, &iviscrns) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900879 iassert(screen_length > 0);
880
881 if (screen_length <= 0)
882 return;
883
884 iviscrn = iviscrns[0];
885
886 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000887 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900888
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000889 iassert(lyt->screen_set_render_order(iviscrn, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900890
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000891 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900892
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000893 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900894
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000895 lyt->layer_destroy(ivilayers[0]);
896 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900897
898 free(iviscrns);
899#undef LAYER_NUM
900}
901
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900902static void
903test_layer_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
904 const struct ivi_layout_layer_properties *prop,
905 enum ivi_layout_notification_mask mask,
906 void *userdata)
907{
908 struct test_context *ctx = userdata;
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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000911 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900912 iassert(prop->source_width == 200);
913 iassert(prop->source_height == 300);
914
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000915 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900916 prop->source_width == 200 && prop->source_height == 300)
917 ctx->user_flags = 1;
918}
919
920static void
921test_layer_properties_changed_notification(struct test_context *ctx)
922{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000923 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900924 struct ivi_layout_layer *ivilayer;
925
926 ctx->user_flags = 0;
927
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000928 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900929
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000930 iassert(lyt->layer_add_notification(ivilayer, test_layer_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900931
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000932 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900933
934 iassert(ctx->user_flags == 0);
935
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000936 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900937 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
938
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000939 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900940
941 iassert(ctx->user_flags == 1);
942
943 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000944 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900945 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
946
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000947 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900948
949 iassert(ctx->user_flags == 0);
950
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000951 lyt->layer_remove_notification(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900952
953 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000954 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900955
956 iassert(ctx->user_flags == 0);
957
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000958 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900959}
960
961static void
962test_layer_create_notification_callback(struct ivi_layout_layer *ivilayer,
963 void *userdata)
964{
965 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000966 const struct ivi_layout_interface *lyt = ctx->layout_interface;
967 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900968
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000969 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900970 iassert(prop->source_width == 200);
971 iassert(prop->source_height == 300);
972
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000973 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900974 prop->source_width == 200 && prop->source_height == 300)
975 ctx->user_flags = 1;
976}
977
978static void
979test_layer_create_notification(struct test_context *ctx)
980{
981#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000982 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900983 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
984 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
985
986 ctx->user_flags = 0;
987
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000988 iassert(lyt->add_notification_create_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900989 test_layer_create_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000990 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900991
992 iassert(ctx->user_flags == 1);
993
994 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000995 lyt->remove_notification_create_layer(test_layer_create_notification_callback, ctx);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900996
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000997 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900998
999 iassert(ctx->user_flags == 0);
1000
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001001 lyt->layer_destroy(ivilayers[0]);
1002 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001003#undef LAYER_NUM
1004}
1005
1006static void
1007test_layer_remove_notification_callback(struct ivi_layout_layer *ivilayer,
1008 void *userdata)
1009{
1010 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001011 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001012 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001013 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001014
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001015 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001016 iassert(prop->source_width == 200);
1017 iassert(prop->source_height == 300);
1018
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001019 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001020 prop->source_width == 200 && prop->source_height == 300)
1021 ctx->user_flags = 1;
1022}
1023
1024static void
1025test_layer_remove_notification(struct test_context *ctx)
1026{
1027#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001028 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001029 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
1030 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
1031
1032 ctx->user_flags = 0;
1033
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001034 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
1035 iassert(lyt->add_notification_remove_layer(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001036 test_layer_remove_notification_callback, ctx) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001037 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001038
1039 iassert(ctx->user_flags == 1);
1040
1041 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001042 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
1043 lyt->remove_notification_remove_layer(test_layer_remove_notification_callback, ctx);
1044 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001045
1046 iassert(ctx->user_flags == 0);
1047#undef LAYER_NUM
1048}
1049
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001050static void
1051test_layer_bad_properties_changed_notification_callback(struct ivi_layout_layer *ivilayer,
1052 const struct ivi_layout_layer_properties *prop,
1053 enum ivi_layout_notification_mask mask,
1054 void *userdata)
1055{
1056}
1057
1058static void
1059test_layer_bad_properties_changed_notification(struct test_context *ctx)
1060{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001061 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001062 struct ivi_layout_layer *ivilayer;
1063
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001064 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001065
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001066 iassert(lyt->layer_add_notification(
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001067 NULL, test_layer_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001068 iassert(lyt->layer_add_notification(ivilayer, NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001069
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001070 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001071}
1072
1073static void
1074test_surface_bad_configure_notification(struct test_context *ctx)
1075{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001076 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001077
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001078 iassert(lyt->add_notification_configure_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001079}
1080
1081static void
1082test_layer_bad_create_notification(struct test_context *ctx)
1083{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001084 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001085
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001086 iassert(lyt->add_notification_create_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001087}
1088
1089static void
1090test_surface_bad_create_notification(struct test_context *ctx)
1091{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001092 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001093
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001094 iassert(lyt->add_notification_create_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001095}
1096
1097static void
1098test_layer_bad_remove_notification(struct test_context *ctx)
1099{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001100 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001101
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001102 iassert(lyt->add_notification_remove_layer(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001103}
1104
1105static void
1106test_surface_bad_remove_notification(struct test_context *ctx)
1107{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001108 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001109
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001110 iassert(lyt->add_notification_remove_surface(NULL, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001111}
1112
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001113/************************ tests end ********************************/
1114
1115static void
1116run_internal_tests(void *data)
1117{
1118 struct test_context *ctx = data;
1119
1120 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +09001121 test_surface_bad_destination_rectangle(ctx);
1122 test_surface_bad_orientation(ctx);
1123 test_surface_bad_dimension(ctx);
1124 test_surface_bad_position(ctx);
1125 test_surface_bad_source_rectangle(ctx);
1126 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001127
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001128 test_layer_create(ctx);
1129 test_layer_visibility(ctx);
1130 test_layer_opacity(ctx);
1131 test_layer_orientation(ctx);
1132 test_layer_dimension(ctx);
1133 test_layer_position(ctx);
1134 test_layer_destination_rectangle(ctx);
1135 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +09001136 test_layer_bad_remove(ctx);
1137 test_layer_bad_visibility(ctx);
1138 test_layer_bad_opacity(ctx);
1139 test_layer_bad_destination_rectangle(ctx);
1140 test_layer_bad_orientation(ctx);
1141 test_layer_bad_dimension(ctx);
1142 test_layer_bad_position(ctx);
1143 test_layer_bad_source_rectangle(ctx);
1144 test_layer_bad_properties(ctx);
1145 test_commit_changes_after_visibility_set_layer_destroy(ctx);
1146 test_commit_changes_after_opacity_set_layer_destroy(ctx);
1147 test_commit_changes_after_orientation_set_layer_destroy(ctx);
1148 test_commit_changes_after_dimension_set_layer_destroy(ctx);
1149 test_commit_changes_after_position_set_layer_destroy(ctx);
1150 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
1151 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
1152 test_layer_create_duplicate(ctx);
1153 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +09001154
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001155 test_screen_id(ctx);
1156 test_screen_resolution(ctx);
1157 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +09001158 test_screen_bad_resolution(ctx);
1159 test_screen_bad_render_order(ctx);
1160 test_commit_changes_after_render_order_set_layer_destroy(ctx);
1161
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +09001162 test_layer_properties_changed_notification(ctx);
1163 test_layer_create_notification(ctx);
1164 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +09001165 test_layer_bad_properties_changed_notification(ctx);
1166 test_surface_bad_configure_notification(ctx);
1167 test_layer_bad_create_notification(ctx);
1168 test_surface_bad_create_notification(ctx);
1169 test_layer_bad_remove_notification(ctx);
1170 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +09001171
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001172 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
1173 free(ctx);
1174}
1175
1176int
1177controller_module_init(struct weston_compositor *compositor,
1178 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001179 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001180 size_t iface_version);
1181
1182WL_EXPORT int
1183controller_module_init(struct weston_compositor *compositor,
1184 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001185 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001186 size_t iface_version)
1187{
1188 struct wl_event_loop *loop;
1189 struct test_context *ctx;
1190
1191 /* strict check, since this is an internal test module */
1192 if (iface_version != sizeof(*iface)) {
1193 weston_log("fatal: controller interface mismatch\n");
1194 return -1;
1195 }
1196
1197 ctx = zalloc(sizeof(*ctx));
1198 if (!ctx)
1199 return -1;
1200
1201 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001202 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001203
1204 loop = wl_display_get_event_loop(compositor->wl_display);
1205 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1206
1207 return 0;
1208}