blob: 37a2356347eb4989b67283edf55476b41ca64907 [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>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030033#include <stdint.h>
Pekka Paalanen46804ca2015-03-27 11:55:21 +020034
Pekka Paalanenb5e3ea22016-06-03 17:12:10 +030035#include "compositor.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070036#include "ivi-shell/ivi-layout-export.h"
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +090037#include "ivi-shell/ivi-layout-private.h"
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +090038#include "ivi-test.h"
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +000039#include "shared/helpers.h"
Pekka Paalanen46804ca2015-03-27 11:55:21 +020040
41struct test_context {
42 struct weston_compositor *compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000043 const struct ivi_layout_interface *layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +090044 uint32_t user_flags;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +000045
46 struct wl_listener layer_property_changed;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +000047 struct wl_listener layer_created;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +000048 struct wl_listener layer_removed;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020049};
50
51static void
52iassert_fail(const char *cond, const char *file, int line,
53 const char *func, struct test_context *ctx)
54{
55 weston_log("Assert failure in %s:%d, %s: '%s'\n",
56 file, line, func, cond);
57 weston_compositor_exit_with_code(ctx->compositor, EXIT_FAILURE);
58}
59
60#define iassert(cond) ({ \
61 bool b_ = (cond); \
62 if (!b_) \
63 iassert_fail(#cond, __FILE__, __LINE__, __func__, ctx); \
64 b_; \
65})
66
67/************************ tests begin ******************************/
68
69/*
70 * These are all internal ivi_layout API tests that do not require
71 * any client objects.
72 */
Pekka Paalanen46804ca2015-03-27 11:55:21 +020073static void
74test_surface_bad_visibility(struct test_context *ctx)
75{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000076 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +020077
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000078 iassert(lyt->surface_set_visibility(NULL, true) == IVI_FAILED);
Pekka Paalanen46804ca2015-03-27 11:55:21 +020079
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000080 lyt->commit_changes();
Pekka Paalanen46804ca2015-03-27 11:55:21 +020081}
82
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090083static void
84test_surface_bad_destination_rectangle(struct test_context *ctx)
85{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000086 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090087
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000088 iassert(lyt->surface_set_destination_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090089}
90
91static void
92test_surface_bad_orientation(struct test_context *ctx)
93{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000094 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090095
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000096 iassert(lyt->surface_set_orientation(NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +090097}
98
99static void
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900100test_surface_bad_source_rectangle(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
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000104 iassert(lyt->surface_set_source_rectangle(NULL, 20, 30, 200, 300) == IVI_FAILED);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900105}
106
107static void
108test_surface_bad_properties(struct test_context *ctx)
109{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000110 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900111
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000112 iassert(lyt->get_properties_of_surface(NULL) == NULL);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900113}
114
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900115static void
116test_layer_create(struct test_context *ctx)
117{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000118 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900119 uint32_t id1;
120 uint32_t id2;
121 struct ivi_layout_layer *ivilayer;
122 struct ivi_layout_layer *new_ivilayer;
123
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000124 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900125 iassert(ivilayer != NULL);
126
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000127 iassert(IVI_TEST_LAYER_ID(0) == lyt->get_id_of_layer(ivilayer));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900128
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000129 new_ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900130 iassert(ivilayer == new_ivilayer);
131
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000132 id1 = lyt->get_id_of_layer(ivilayer);
133 id2 = lyt->get_id_of_layer(new_ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900134 iassert(id1 == id2);
135
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000136 lyt->layer_destroy(ivilayer);
137 iassert(lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0)) == NULL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900138}
139
140static void
141test_layer_visibility(struct test_context *ctx)
142{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000143 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900144 struct ivi_layout_layer *ivilayer;
145 const struct ivi_layout_layer_properties *prop;
146
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000147 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900148 iassert(ivilayer != NULL);
149
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000150 prop = lyt->get_properties_of_layer(ivilayer);
151
152 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900153
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000154 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900155
Ucan, Emre \(ADITG/SW1\)17610f22016-03-04 12:50:07 +0000156 iassert(prop->visibility == false);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900157
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000158 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900159
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900160 iassert(prop->visibility == true);
161
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000162 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900163}
164
165static void
166test_layer_opacity(struct test_context *ctx)
167{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000168 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900169 struct ivi_layout_layer *ivilayer;
170 const struct ivi_layout_layer_properties *prop;
171
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000172 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900173 iassert(ivilayer != NULL);
174
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000175 prop = lyt->get_properties_of_layer(ivilayer);
176 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900177
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000178 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900179 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
180
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000181 iassert(prop->opacity == wl_fixed_from_double(1.0));
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900182
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000183 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900184
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900185 iassert(prop->opacity == wl_fixed_from_double(0.5));
186
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000187 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900188}
189
190static void
191test_layer_orientation(struct test_context *ctx)
192{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000193 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900194 struct ivi_layout_layer *ivilayer;
195 const struct ivi_layout_layer_properties *prop;
196
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000197 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900198 iassert(ivilayer != NULL);
199
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000200 prop = lyt->get_properties_of_layer(ivilayer);
201 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900202
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000203 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900204 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
205
Ucan, Emre \(ADITG/SW1\)5bb068d2016-03-04 12:50:39 +0000206 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900207
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000208 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900209
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900210 iassert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
211
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000212 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900213}
214
215static void
216test_layer_dimension(struct test_context *ctx)
217{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000218 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900219 struct ivi_layout_layer *ivilayer;
220 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900221
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000222 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900223 iassert(ivilayer != NULL);
224
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000225 prop = lyt->get_properties_of_layer(ivilayer);
226 iassert(prop->dest_width == 200);
227 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900228
Ucan, Emre \(ADITG/SW1\)16d1fa12016-03-04 12:50:52 +0000229 iassert(lyt->layer_set_destination_rectangle(ivilayer, prop->dest_x, prop->dest_y,
230 400, 600) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900231
Ucan, Emre \(ADITG/SW1\)18691f02016-03-04 12:50:32 +0000232 iassert(prop->dest_width == 200);
233 iassert(prop->dest_height == 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900234
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000235 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900236
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900237 iassert(prop->dest_width == 400);
238 iassert(prop->dest_height == 600);
239
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000240 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900241}
242
243static void
244test_layer_position(struct test_context *ctx)
245{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000246 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900247 struct ivi_layout_layer *ivilayer;
248 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900249
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000250 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900251 iassert(ivilayer != NULL);
252
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000253 prop = lyt->get_properties_of_layer(ivilayer);
254 iassert(prop->dest_x == 0);
255 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900256
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +0000257 iassert(lyt->layer_set_destination_rectangle(ivilayer, 20, 30,
258 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900259
Ucan, Emre \(ADITG/SW1\)dfc2d762016-03-04 12:50:24 +0000260 iassert(prop->dest_x == 0);
261 iassert(prop->dest_y == 0);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900262
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000263 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900264
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000265 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900266 iassert(prop->dest_x == 20);
267 iassert(prop->dest_y == 30);
268
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000269 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900270}
271
272static void
273test_layer_destination_rectangle(struct test_context *ctx)
274{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000275 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900276 struct ivi_layout_layer *ivilayer;
277 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900278
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000279 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900280 iassert(ivilayer != NULL);
281
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000282 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900283 iassert(prop->dest_width == 200);
284 iassert(prop->dest_height == 300);
285 iassert(prop->dest_x == 0);
286 iassert(prop->dest_y == 0);
287
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000288 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900289 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
290
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000291 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900292 iassert(prop->dest_width == 200);
293 iassert(prop->dest_height == 300);
294 iassert(prop->dest_x == 0);
295 iassert(prop->dest_y == 0);
296
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000297 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900298
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900299 iassert(prop->dest_width == 400);
300 iassert(prop->dest_height == 600);
301 iassert(prop->dest_x == 20);
302 iassert(prop->dest_y == 30);
303
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000304 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900305}
306
307static void
308test_layer_source_rectangle(struct test_context *ctx)
309{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000310 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900311 struct ivi_layout_layer *ivilayer;
312 const struct ivi_layout_layer_properties *prop;
313
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000314 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900315 iassert(ivilayer != NULL);
316
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000317 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900318 iassert(prop->source_width == 200);
319 iassert(prop->source_height == 300);
320 iassert(prop->source_x == 0);
321 iassert(prop->source_y == 0);
322
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000323 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900324 ivilayer, 20, 30, 400, 600) == IVI_SUCCEEDED);
325
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000326 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900327 iassert(prop->source_width == 200);
328 iassert(prop->source_height == 300);
329 iassert(prop->source_x == 0);
330 iassert(prop->source_y == 0);
331
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000332 lyt->commit_changes();
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900333
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000334 prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900335 iassert(prop->source_width == 400);
336 iassert(prop->source_height == 600);
337 iassert(prop->source_x == 20);
338 iassert(prop->source_y == 30);
339
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000340 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900341}
342
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900343static void
344test_layer_bad_remove(struct test_context *ctx)
345{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 const struct ivi_layout_interface *lyt = ctx->layout_interface;
347 lyt->layer_destroy(NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900348}
349
350static void
351test_layer_bad_visibility(struct test_context *ctx)
352{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000353 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900354
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000355 iassert(lyt->layer_set_visibility(NULL, true) == IVI_FAILED);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900356
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000357 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900358}
359
360static void
361test_layer_bad_opacity(struct test_context *ctx)
362{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000363 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900364 struct ivi_layout_layer *ivilayer;
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000365 const struct ivi_layout_layer_properties *prop;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900366
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000367 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900368 iassert(ivilayer != NULL);
369
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000370 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900371 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
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 ivilayer, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
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(-1)) == IVI_FAILED);
378
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000379 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900380
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000381 prop = lyt->get_properties_of_layer(ivilayer);
382 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900383
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000384 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900385 ivilayer, wl_fixed_from_double(1.1)) == IVI_FAILED);
386
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000387 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900388
Ucan, Emre \(ADITG/SW1\)c3aee1f2016-03-04 12:50:16 +0000389 iassert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900390
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000391 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900392 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
393
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000394 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900395
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000396 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900397}
398
399static void
400test_layer_bad_destination_rectangle(struct test_context *ctx)
401{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000402 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900403
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000404 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900405 NULL, 20, 30, 200, 300) == IVI_FAILED);
406}
407
408static void
409test_layer_bad_orientation(struct test_context *ctx)
410{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000411 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900412
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000413 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900414 NULL, WL_OUTPUT_TRANSFORM_90) == IVI_FAILED);
415
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900417}
418
419static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900420test_layer_bad_source_rectangle(struct test_context *ctx)
421{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000422 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900423
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000424 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900425 NULL, 20, 30, 200, 300) == IVI_FAILED);
426}
427
428static void
429test_layer_bad_properties(struct test_context *ctx)
430{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000431 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900432
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000433 iassert(lyt->get_properties_of_layer(NULL) == NULL);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900434}
435
436static void
437test_commit_changes_after_visibility_set_layer_destroy(struct test_context *ctx)
438{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000439 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900440 struct ivi_layout_layer *ivilayer;
441
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000442 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900443 iassert(ivilayer != NULL);
444
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000445 iassert(lyt->layer_set_visibility(ivilayer, true) == IVI_SUCCEEDED);
446 lyt->layer_destroy(ivilayer);
447 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900448}
449
450static void
451test_commit_changes_after_opacity_set_layer_destroy(struct test_context *ctx)
452{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900454 struct ivi_layout_layer *ivilayer;
455
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000456 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900457 iassert(ivilayer != NULL);
458
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000459 iassert(lyt->layer_set_opacity(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900460 ivilayer, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000461 lyt->layer_destroy(ivilayer);
462 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900463}
464
465static void
466test_commit_changes_after_orientation_set_layer_destroy(struct test_context *ctx)
467{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000468 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900469 struct ivi_layout_layer *ivilayer;
470
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000471 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900472 iassert(ivilayer != NULL);
473
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000474 iassert(lyt->layer_set_orientation(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900475 ivilayer, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000476 lyt->layer_destroy(ivilayer);
477 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900478}
479
480static void
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900481test_commit_changes_after_source_rectangle_set_layer_destroy(struct test_context *ctx)
482{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000483 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900484 struct ivi_layout_layer *ivilayer;
485
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000486 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900487 iassert(ivilayer != NULL);
488
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000489 iassert(lyt->layer_set_source_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900490 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000491 lyt->layer_destroy(ivilayer);
492 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900493}
494
495static void
496test_commit_changes_after_destination_rectangle_set_layer_destroy(struct test_context *ctx)
497{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000498 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900499 struct ivi_layout_layer *ivilayer;
500
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000501 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900502 iassert(ivilayer != NULL);
503
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000504 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900505 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000506 lyt->layer_destroy(ivilayer);
507 lyt->commit_changes();
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900508}
509
510static void
511test_layer_create_duplicate(struct test_context *ctx)
512{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000513 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900514 struct ivi_layout_layer *ivilayer;
515 struct ivi_layout_layer *duplicatelayer;
516
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000517 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900518 iassert(ivilayer != NULL);
519
520 if (ivilayer != NULL)
521 iassert(ivilayer->ref_count == 1);
522
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000523 duplicatelayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900524 iassert(ivilayer == duplicatelayer);
525
526 if (ivilayer != NULL)
527 iassert(ivilayer->ref_count == 2);
528
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000529 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900530
531 if (ivilayer != NULL)
532 iassert(ivilayer->ref_count == 1);
533
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000534 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900535}
536
537static void
538test_get_layer_after_destory_layer(struct test_context *ctx)
539{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000540 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900541 struct ivi_layout_layer *ivilayer;
542
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000543 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900544 iassert(ivilayer != NULL);
545
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900547
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000548 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900549 iassert(ivilayer == NULL);
550}
551
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900552static void
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900553test_screen_render_order(struct test_context *ctx)
554{
555#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000556 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000557 struct weston_output *output;
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900558 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
559 struct ivi_layout_layer **array;
560 int32_t length = 0;
561 uint32_t i;
562
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000563 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900564 return;
565
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000566 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900567
568 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000569 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900570
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000571 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900572
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000573 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900574
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000575 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900576 iassert(length == LAYER_NUM);
577 for (i = 0; i < LAYER_NUM; i++)
578 iassert(array[i] == ivilayers[i]);
579
580 if (length > 0)
581 free(array);
582
583 array = NULL;
584
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000585 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900586
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000587 lyt->commit_changes();
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900588
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000589 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900590 iassert(length == 0 && array == NULL);
591
592 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000593 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900594
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900595#undef LAYER_NUM
596}
597
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900598static void
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900599test_screen_bad_render_order(struct test_context *ctx)
600{
601#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000602 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000603 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900604 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
605 struct ivi_layout_layer **array;
606 int32_t length = 0;
607 uint32_t i;
608
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000609 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900610 return;
611
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000612 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900613
614 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000615 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900616
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000617 iassert(lyt->screen_set_render_order(NULL, ivilayers, LAYER_NUM) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900618
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000619 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900620
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000621 iassert(lyt->get_layers_on_screen(NULL, &length, &array) == IVI_FAILED);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000622 iassert(lyt->get_layers_on_screen(output, NULL, &array) == IVI_FAILED);
623 iassert(lyt->get_layers_on_screen(output, &length, NULL) == IVI_FAILED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900624
625 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000626 lyt->layer_destroy(ivilayers[i]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900627
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900628#undef LAYER_NUM
629}
630
631static void
Ucan, Emre (ADITG/SW1)fbce2f52017-01-18 15:25:36 +0000632test_screen_add_layers(struct test_context *ctx)
633{
634#define LAYER_NUM (3)
635 const struct ivi_layout_interface *lyt = ctx->layout_interface;
636 struct weston_output *output;
637 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
638 struct ivi_layout_layer **array;
639 int32_t length = 0;
640 uint32_t i;
641
642 if (wl_list_empty(&ctx->compositor->output_list))
643 return;
644
645 output = wl_container_of(ctx->compositor->output_list.next, output, link);
646
647 for (i = 0; i < LAYER_NUM; i++) {
648 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
649 iassert(lyt->screen_add_layer(output, ivilayers[i]) == IVI_SUCCEEDED);
650 }
651
652 lyt->commit_changes();
653
654 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
655 iassert(length == LAYER_NUM);
656 for (i = 0; i < (uint32_t)length; i++)
657 iassert(array[i] == ivilayers[i]);
658
659 if (length > 0)
660 free(array);
661
662 array = NULL;
663
664 iassert(lyt->screen_set_render_order(output, NULL, 0) == IVI_SUCCEEDED);
665 for (i = LAYER_NUM; i-- > 0;)
666 iassert(lyt->screen_add_layer(output, ivilayers[i]) == IVI_SUCCEEDED);
667
668 lyt->commit_changes();
669
670 iassert(lyt->get_layers_on_screen(output, &length, &array) == IVI_SUCCEEDED);
671 iassert(length == LAYER_NUM);
672 for (i = 0; i < (uint32_t)length; i++)
673 iassert(array[i] == ivilayers[LAYER_NUM - (i + 1)]);
674
675 if (length > 0)
676 free(array);
677
678 for (i = 0; i < LAYER_NUM; i++)
679 lyt->layer_destroy(ivilayers[i]);
680
681#undef LAYER_NUM
682}
683
684static void
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900685test_commit_changes_after_render_order_set_layer_destroy(
686 struct test_context *ctx)
687{
688#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000689 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000690 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900691 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
692 uint32_t i;
693
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000694 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900695 return;
696
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000697 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900698
699 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900701
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000702 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900703
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000704 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900705
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000706 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900707
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000708 lyt->layer_destroy(ivilayers[0]);
709 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900710#undef LAYER_NUM
711}
712
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900713static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000714test_layer_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900715{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000716 struct test_context *ctx =
717 container_of(listener, struct test_context,
718 layer_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000719 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000720 struct ivi_layout_layer *ivilayer = data;
721 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900722
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000723 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900724 iassert(prop->source_width == 200);
725 iassert(prop->source_height == 300);
726
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000727 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900728 prop->source_width == 200 && prop->source_height == 300)
729 ctx->user_flags = 1;
730}
731
732static void
733test_layer_properties_changed_notification(struct test_context *ctx)
734{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000735 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900736 struct ivi_layout_layer *ivilayer;
737
738 ctx->user_flags = 0;
739
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000740 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900741
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000742 ctx->layer_property_changed.notify = test_layer_properties_changed_notification_callback;
743
744 iassert(lyt->layer_add_listener(ivilayer, &ctx->layer_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900745
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000746 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900747
748 iassert(ctx->user_flags == 0);
749
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000750 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900751 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
752
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000753 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900754
755 iassert(ctx->user_flags == 1);
756
757 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000758 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900759 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
760
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000761 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900762
763 iassert(ctx->user_flags == 0);
764
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000765 // remove layer property changed listener.
766 wl_list_remove(&ctx->layer_property_changed.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900767
768 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900770
771 iassert(ctx->user_flags == 0);
772
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000773 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900774}
775
776static void
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000777test_layer_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900778{
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000779 struct test_context *ctx =
780 container_of(listener, struct test_context,
781 layer_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000782 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000783 struct ivi_layout_layer *ivilayer = data;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000784 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900785
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000786 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900787 iassert(prop->source_width == 200);
788 iassert(prop->source_height == 300);
789
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000790 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900791 prop->source_width == 200 && prop->source_height == 300)
792 ctx->user_flags = 1;
793}
794
795static void
796test_layer_create_notification(struct test_context *ctx)
797{
798#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000799 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900800 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
801 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
802
803 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000804 ctx->layer_created.notify = test_layer_create_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900805
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000806 iassert(lyt->add_listener_create_layer(&ctx->layer_created) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900808
809 iassert(ctx->user_flags == 1);
810
811 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000812 // remove layer created listener.
813 wl_list_remove(&ctx->layer_created.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900814
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000815 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900816
817 iassert(ctx->user_flags == 0);
818
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000819 lyt->layer_destroy(ivilayers[0]);
820 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900821#undef LAYER_NUM
822}
823
824static void
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000825test_layer_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900826{
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000827 struct test_context *ctx =
828 container_of(listener, struct test_context,
829 layer_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000830 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000831 struct ivi_layout_layer *ivilayer = data;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900832 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000833 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900834
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000835 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900836 iassert(prop->source_width == 200);
837 iassert(prop->source_height == 300);
838
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000839 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900840 prop->source_width == 200 && prop->source_height == 300)
841 ctx->user_flags = 1;
842}
843
844static void
845test_layer_remove_notification(struct test_context *ctx)
846{
847#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000848 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900849 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
850 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
851
852 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000853 ctx->layer_removed.notify = test_layer_remove_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900854
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000855 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000856 iassert(lyt->add_listener_remove_layer(&ctx->layer_removed) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000857 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900858
859 iassert(ctx->user_flags == 1);
860
861 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000862 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000863
864 // remove layer property changed listener.
865 wl_list_remove(&ctx->layer_removed.link);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000866 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900867
868 iassert(ctx->user_flags == 0);
869#undef LAYER_NUM
870}
871
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900872static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000873test_layer_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900874{
875}
876
877static void
878test_layer_bad_properties_changed_notification(struct test_context *ctx)
879{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000880 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900881 struct ivi_layout_layer *ivilayer;
882
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000883 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900884
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000885 ctx->layer_property_changed.notify = test_layer_bad_properties_changed_notification_callback;
886
887 iassert(lyt->layer_add_listener(NULL, &ctx->layer_property_changed) == IVI_FAILED);
888 iassert(lyt->layer_add_listener(ivilayer, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900889
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000890 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900891}
892
893static void
894test_surface_bad_configure_notification(struct test_context *ctx)
895{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000896 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900897
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000898 iassert(lyt->add_listener_configure_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900899}
900
901static void
902test_layer_bad_create_notification(struct test_context *ctx)
903{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000904 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900905
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000906 iassert(lyt->add_listener_create_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900907}
908
909static void
910test_surface_bad_create_notification(struct test_context *ctx)
911{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000912 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900913
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000914 iassert(lyt->add_listener_create_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900915}
916
917static void
918test_layer_bad_remove_notification(struct test_context *ctx)
919{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000920 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900921
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000922 iassert(lyt->add_listener_remove_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900923}
924
925static void
926test_surface_bad_remove_notification(struct test_context *ctx)
927{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000928 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900929
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000930 iassert(lyt->add_listener_remove_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900931}
932
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200933/************************ tests end ********************************/
934
935static void
936run_internal_tests(void *data)
937{
938 struct test_context *ctx = data;
939
940 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900941 test_surface_bad_destination_rectangle(ctx);
942 test_surface_bad_orientation(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900943 test_surface_bad_source_rectangle(ctx);
944 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200945
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900946 test_layer_create(ctx);
947 test_layer_visibility(ctx);
948 test_layer_opacity(ctx);
949 test_layer_orientation(ctx);
950 test_layer_dimension(ctx);
951 test_layer_position(ctx);
952 test_layer_destination_rectangle(ctx);
953 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900954 test_layer_bad_remove(ctx);
955 test_layer_bad_visibility(ctx);
956 test_layer_bad_opacity(ctx);
957 test_layer_bad_destination_rectangle(ctx);
958 test_layer_bad_orientation(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900959 test_layer_bad_source_rectangle(ctx);
960 test_layer_bad_properties(ctx);
961 test_commit_changes_after_visibility_set_layer_destroy(ctx);
962 test_commit_changes_after_opacity_set_layer_destroy(ctx);
963 test_commit_changes_after_orientation_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900964 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
965 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
966 test_layer_create_duplicate(ctx);
967 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900968
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900969 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900970 test_screen_bad_render_order(ctx);
Ucan, Emre (ADITG/SW1)fbce2f52017-01-18 15:25:36 +0000971 test_screen_add_layers(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900972 test_commit_changes_after_render_order_set_layer_destroy(ctx);
973
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900974 test_layer_properties_changed_notification(ctx);
975 test_layer_create_notification(ctx);
976 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900977 test_layer_bad_properties_changed_notification(ctx);
978 test_surface_bad_configure_notification(ctx);
979 test_layer_bad_create_notification(ctx);
980 test_surface_bad_create_notification(ctx);
981 test_layer_bad_remove_notification(ctx);
982 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900983
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200984 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
985 free(ctx);
986}
987
988int
989controller_module_init(struct weston_compositor *compositor,
990 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000991 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200992 size_t iface_version);
993
994WL_EXPORT int
995controller_module_init(struct weston_compositor *compositor,
996 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000997 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200998 size_t iface_version)
999{
1000 struct wl_event_loop *loop;
1001 struct test_context *ctx;
1002
1003 /* strict check, since this is an internal test module */
1004 if (iface_version != sizeof(*iface)) {
1005 weston_log("fatal: controller interface mismatch\n");
1006 return -1;
1007 }
1008
1009 ctx = zalloc(sizeof(*ctx));
1010 if (!ctx)
1011 return -1;
1012
1013 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001014 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +02001015
1016 loop = wl_display_get_event_loop(compositor->wl_display);
1017 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
1018
1019 return 0;
1020}