blob: d851ec00b89ad498b2ce0be5b2559477b9f60cab [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
632test_commit_changes_after_render_order_set_layer_destroy(
633 struct test_context *ctx)
634{
635#define LAYER_NUM (3)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000636 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000637 struct weston_output *output;
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900638 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
639 uint32_t i;
640
Ucan, Emre (ADITG/SW1)3a8521e2016-03-17 15:30:39 +0000641 if (wl_list_empty(&ctx->compositor->output_list))
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900642 return;
643
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000644 output = wl_container_of(ctx->compositor->output_list.next, output, link);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900645
646 for (i = 0; i < LAYER_NUM; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000647 ivilayers[i] = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(i), 200, 300);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900648
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +0000649 iassert(lyt->screen_set_render_order(output, ivilayers, LAYER_NUM) == IVI_SUCCEEDED);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900650
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000651 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900652
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000653 lyt->commit_changes();
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900654
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000655 lyt->layer_destroy(ivilayers[0]);
656 lyt->layer_destroy(ivilayers[2]);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900657#undef LAYER_NUM
658}
659
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900660static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000661test_layer_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900662{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000663 struct test_context *ctx =
664 container_of(listener, struct test_context,
665 layer_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000666 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000667 struct ivi_layout_layer *ivilayer = data;
668 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900669
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000670 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900671 iassert(prop->source_width == 200);
672 iassert(prop->source_height == 300);
673
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000674 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900675 prop->source_width == 200 && prop->source_height == 300)
676 ctx->user_flags = 1;
677}
678
679static void
680test_layer_properties_changed_notification(struct test_context *ctx)
681{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000682 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900683 struct ivi_layout_layer *ivilayer;
684
685 ctx->user_flags = 0;
686
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000687 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900688
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000689 ctx->layer_property_changed.notify = test_layer_properties_changed_notification_callback;
690
691 iassert(lyt->layer_add_listener(ivilayer, &ctx->layer_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900692
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000693 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900694
695 iassert(ctx->user_flags == 0);
696
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000697 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900698 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
699
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900701
702 iassert(ctx->user_flags == 1);
703
704 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000705 iassert(lyt->layer_set_destination_rectangle(
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900706 ivilayer, 20, 30, 200, 300) == IVI_SUCCEEDED);
707
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000708 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900709
710 iassert(ctx->user_flags == 0);
711
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000712 // remove layer property changed listener.
713 wl_list_remove(&ctx->layer_property_changed.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900714
715 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000716 lyt->commit_changes();
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900717
718 iassert(ctx->user_flags == 0);
719
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900721}
722
723static void
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000724test_layer_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900725{
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000726 struct test_context *ctx =
727 container_of(listener, struct test_context,
728 layer_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000729 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000730 struct ivi_layout_layer *ivilayer = data;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000731 const struct ivi_layout_layer_properties *prop = lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900732
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000733 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900734 iassert(prop->source_width == 200);
735 iassert(prop->source_height == 300);
736
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000737 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900738 prop->source_width == 200 && prop->source_height == 300)
739 ctx->user_flags = 1;
740}
741
742static void
743test_layer_create_notification(struct test_context *ctx)
744{
745#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000746 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900747 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
748 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
749
750 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000751 ctx->layer_created.notify = test_layer_create_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900752
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000753 iassert(lyt->add_listener_create_layer(&ctx->layer_created) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000754 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900755
756 iassert(ctx->user_flags == 1);
757
758 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000759 // remove layer created listener.
760 wl_list_remove(&ctx->layer_created.link);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900761
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000762 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 400, 500);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900763
764 iassert(ctx->user_flags == 0);
765
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000766 lyt->layer_destroy(ivilayers[0]);
767 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900768#undef LAYER_NUM
769}
770
771static void
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000772test_layer_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900773{
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000774 struct test_context *ctx =
775 container_of(listener, struct test_context,
776 layer_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000777 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000778 struct ivi_layout_layer *ivilayer = data;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900779 const struct ivi_layout_layer_properties *prop =
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000780 lyt->get_properties_of_layer(ivilayer);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900781
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000782 iassert(lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0));
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900783 iassert(prop->source_width == 200);
784 iassert(prop->source_height == 300);
785
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000786 if (lyt->get_id_of_layer(ivilayer) == IVI_TEST_LAYER_ID(0) &&
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900787 prop->source_width == 200 && prop->source_height == 300)
788 ctx->user_flags = 1;
789}
790
791static void
792test_layer_remove_notification(struct test_context *ctx)
793{
794#define LAYER_NUM (2)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000795 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900796 static const uint32_t layers[LAYER_NUM] = {IVI_TEST_LAYER_ID(0), IVI_TEST_LAYER_ID(1)};
797 struct ivi_layout_layer *ivilayers[LAYER_NUM] = {};
798
799 ctx->user_flags = 0;
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000800 ctx->layer_removed.notify = test_layer_remove_notification_callback;
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900801
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000802 ivilayers[0] = lyt->layer_create_with_dimension(layers[0], 200, 300);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000803 iassert(lyt->add_listener_remove_layer(&ctx->layer_removed) == IVI_SUCCEEDED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000804 lyt->layer_destroy(ivilayers[0]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900805
806 iassert(ctx->user_flags == 1);
807
808 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000809 ivilayers[1] = lyt->layer_create_with_dimension(layers[1], 250, 350);
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000810
811 // remove layer property changed listener.
812 wl_list_remove(&ctx->layer_removed.link);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000813 lyt->layer_destroy(ivilayers[1]);
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900814
815 iassert(ctx->user_flags == 0);
816#undef LAYER_NUM
817}
818
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900819static void
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000820test_layer_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900821{
822}
823
824static void
825test_layer_bad_properties_changed_notification(struct test_context *ctx)
826{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000827 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900828 struct ivi_layout_layer *ivilayer;
829
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000830 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900831
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +0000832 ctx->layer_property_changed.notify = test_layer_bad_properties_changed_notification_callback;
833
834 iassert(lyt->layer_add_listener(NULL, &ctx->layer_property_changed) == IVI_FAILED);
835 iassert(lyt->layer_add_listener(ivilayer, NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900836
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000837 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900838}
839
840static void
841test_surface_bad_configure_notification(struct test_context *ctx)
842{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000843 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900844
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000845 iassert(lyt->add_listener_configure_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900846}
847
848static void
849test_layer_bad_create_notification(struct test_context *ctx)
850{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000851 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900852
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000853 iassert(lyt->add_listener_create_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900854}
855
856static void
857test_surface_bad_create_notification(struct test_context *ctx)
858{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000859 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900860
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000861 iassert(lyt->add_listener_create_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900862}
863
864static void
865test_layer_bad_remove_notification(struct test_context *ctx)
866{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000867 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900868
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000869 iassert(lyt->add_listener_remove_layer(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900870}
871
872static void
873test_surface_bad_remove_notification(struct test_context *ctx)
874{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000875 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900876
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000877 iassert(lyt->add_listener_remove_surface(NULL) == IVI_FAILED);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900878}
879
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200880/************************ tests end ********************************/
881
882static void
883run_internal_tests(void *data)
884{
885 struct test_context *ctx = data;
886
887 test_surface_bad_visibility(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900888 test_surface_bad_destination_rectangle(ctx);
889 test_surface_bad_orientation(ctx);
Nobuhiko Tanibata16ed5432015-06-22 15:33:59 +0900890 test_surface_bad_source_rectangle(ctx);
891 test_surface_bad_properties(ctx);
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200892
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900893 test_layer_create(ctx);
894 test_layer_visibility(ctx);
895 test_layer_opacity(ctx);
896 test_layer_orientation(ctx);
897 test_layer_dimension(ctx);
898 test_layer_position(ctx);
899 test_layer_destination_rectangle(ctx);
900 test_layer_source_rectangle(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900901 test_layer_bad_remove(ctx);
902 test_layer_bad_visibility(ctx);
903 test_layer_bad_opacity(ctx);
904 test_layer_bad_destination_rectangle(ctx);
905 test_layer_bad_orientation(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900906 test_layer_bad_source_rectangle(ctx);
907 test_layer_bad_properties(ctx);
908 test_commit_changes_after_visibility_set_layer_destroy(ctx);
909 test_commit_changes_after_opacity_set_layer_destroy(ctx);
910 test_commit_changes_after_orientation_set_layer_destroy(ctx);
Nobuhiko Tanibata17d44942015-06-22 15:35:12 +0900911 test_commit_changes_after_source_rectangle_set_layer_destroy(ctx);
912 test_commit_changes_after_destination_rectangle_set_layer_destroy(ctx);
913 test_layer_create_duplicate(ctx);
914 test_get_layer_after_destory_layer(ctx);
Nobuhiko Tanibata9e992d92015-06-22 15:34:18 +0900915
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900916 test_screen_render_order(ctx);
Nobuhiko Tanibata83c20bc2015-06-22 15:35:39 +0900917 test_screen_bad_render_order(ctx);
918 test_commit_changes_after_render_order_set_layer_destroy(ctx);
919
Nobuhiko Tanibata495c6ef2015-06-22 15:36:11 +0900920 test_layer_properties_changed_notification(ctx);
921 test_layer_create_notification(ctx);
922 test_layer_remove_notification(ctx);
Nobuhiko Tanibataffcc4522015-06-22 15:37:41 +0900923 test_layer_bad_properties_changed_notification(ctx);
924 test_surface_bad_configure_notification(ctx);
925 test_layer_bad_create_notification(ctx);
926 test_surface_bad_create_notification(ctx);
927 test_layer_bad_remove_notification(ctx);
928 test_surface_bad_remove_notification(ctx);
Nobuhiko Tanibatae78a7af2015-06-22 15:35:25 +0900929
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200930 weston_compositor_exit_with_code(ctx->compositor, EXIT_SUCCESS);
931 free(ctx);
932}
933
934int
935controller_module_init(struct weston_compositor *compositor,
936 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000937 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200938 size_t iface_version);
939
940WL_EXPORT int
941controller_module_init(struct weston_compositor *compositor,
942 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000943 const struct ivi_layout_interface *iface,
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200944 size_t iface_version)
945{
946 struct wl_event_loop *loop;
947 struct test_context *ctx;
948
949 /* strict check, since this is an internal test module */
950 if (iface_version != sizeof(*iface)) {
951 weston_log("fatal: controller interface mismatch\n");
952 return -1;
953 }
954
955 ctx = zalloc(sizeof(*ctx));
956 if (!ctx)
957 return -1;
958
959 ctx->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000960 ctx->layout_interface = iface;
Pekka Paalanen46804ca2015-03-27 11:55:21 +0200961
962 loop = wl_display_get_event_loop(compositor->wl_display);
963 wl_event_loop_add_idle(loop, run_internal_tests, ctx);
964
965 return 0;
966}