blob: 7c72c36cadd85a7a5cd3bfc09859e7a1198ae042 [file] [log] [blame]
Pekka Paalanenf5b74f72015-03-25 12:50:31 +02001/*
2 * Copyright © 2012 Intel Corporation
3 * Copyright © 2013 DENSO CORPORATION
4 * Copyright © 2015 Collabora, Ltd.
5 *
Bryce Harrington2cc92972015-06-11 15:39:40 -07006 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020013 *
Bryce Harrington2cc92972015-06-11 15:39:40 -070014 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020026 */
27
28#include "config.h"
29
30#include <unistd.h>
31#include <signal.h>
32#include <string.h>
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090033#include <assert.h>
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020034
Jon Cruz4678bab2015-06-15 15:37:07 -070035#include "src/compositor.h"
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020036#include "weston-test-server-protocol.h"
37#include "ivi-test.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070038#include "ivi-shell/ivi-layout-export.h"
Jon Cruz867d50e2015-06-15 15:37:10 -070039#include "shared/helpers.h"
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020040
41struct test_context;
42
43struct runner_test {
44 const char *name;
45 void (*run)(struct test_context *);
46} __attribute__ ((aligned (32)));
47
48#define RUNNER_TEST(name) \
49 static void runner_func_##name(struct test_context *); \
50 \
51 const struct runner_test runner_test_##name \
52 __attribute__ ((section ("test_section"))) = \
53 { \
54 #name, runner_func_##name \
55 }; \
56 \
57 static void runner_func_##name(struct test_context *ctx)
58
59extern const struct runner_test __start_test_section;
60extern const struct runner_test __stop_test_section;
61
62static const struct runner_test *
63find_runner_test(const char *name)
64{
65 const struct runner_test *t;
66
67 for (t = &__start_test_section; t < &__stop_test_section; t++) {
68 if (strcmp(t->name, name) == 0)
69 return t;
70 }
71
72 return NULL;
73}
74
75struct test_launcher {
76 struct weston_compositor *compositor;
77 char exe[2048];
78 struct weston_process process;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000079 const struct ivi_layout_interface *layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020080};
81
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090082struct test_context {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000083 const struct ivi_layout_interface *layout_interface;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090084 struct wl_resource *runner_resource;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +090085 uint32_t user_flags;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090086};
87
88static struct test_context static_context;
89
90static void
91destroy_runner(struct wl_resource *resource)
92{
93 assert(static_context.runner_resource == NULL ||
94 static_context.runner_resource == resource);
95
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000096 static_context.layout_interface = NULL;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090097 static_context.runner_resource = NULL;
98}
99
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200100static void
101runner_destroy_handler(struct wl_client *client, struct wl_resource *resource)
102{
103 wl_resource_destroy(resource);
104}
105
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200106static void
107runner_run_handler(struct wl_client *client, struct wl_resource *resource,
108 const char *test_name)
109{
110 struct test_launcher *launcher;
111 const struct runner_test *t;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900112
113 assert(static_context.runner_resource == NULL ||
114 static_context.runner_resource == resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200115
116 launcher = wl_resource_get_user_data(resource);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000117 static_context.layout_interface = launcher->layout_interface;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900118 static_context.runner_resource = resource;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200119
120 t = find_runner_test(test_name);
121 if (!t) {
122 weston_log("Error: runner test \"%s\" not found.\n",
123 test_name);
124 wl_resource_post_error(resource,
125 WESTON_TEST_RUNNER_ERROR_UNKNOWN_TEST,
126 "weston_test_runner: unknown: '%s'",
127 test_name);
128 return;
129 }
130
131 weston_log("weston_test_runner.run(\"%s\")\n", test_name);
132
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900133 t->run(&static_context);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200134
135 weston_test_runner_send_finished(resource);
136}
137
138static const struct weston_test_runner_interface runner_implementation = {
139 runner_destroy_handler,
140 runner_run_handler
141};
142
143static void
144bind_runner(struct wl_client *client, void *data,
145 uint32_t version, uint32_t id)
146{
147 struct test_launcher *launcher = data;
148 struct wl_resource *resource;
149
150 resource = wl_resource_create(client, &weston_test_runner_interface,
151 1, id);
152 if (!resource) {
153 wl_client_post_no_memory(client);
154 return;
155 }
156
157 wl_resource_set_implementation(resource, &runner_implementation,
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900158 launcher, destroy_runner);
159
160 if (static_context.runner_resource != NULL) {
161 weston_log("test FATAL: "
162 "attempting to run several tests in parallel.\n");
163 wl_resource_post_error(resource,
164 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
165 "attempt to run parallel tests");
166 }
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200167}
168
169static void
170test_client_sigchld(struct weston_process *process, int status)
171{
172 struct test_launcher *launcher =
173 container_of(process, struct test_launcher, process);
174 struct weston_compositor *c = launcher->compositor;
175
176 /* Chain up from weston-test-runner's exit code so that automake
177 * knows the exit status and can report e.g. skipped tests. */
178 if (WIFEXITED(status))
179 weston_compositor_exit_with_code(c, WEXITSTATUS(status));
180 else
181 weston_compositor_exit_with_code(c, EXIT_FAILURE);
182}
183
184static void
185idle_launch_client(void *data)
186{
187 struct test_launcher *launcher = data;
188 pid_t pid;
189 sigset_t allsigs;
190
191 pid = fork();
192 if (pid == -1) {
193 weston_log("fatal: failed to fork '%s': %m\n", launcher->exe);
194 weston_compositor_exit_with_code(launcher->compositor,
195 EXIT_FAILURE);
196 return;
197 }
198
199 if (pid == 0) {
200 sigfillset(&allsigs);
201 sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
202 execl(launcher->exe, launcher->exe, NULL);
203 weston_log("compositor: executing '%s' failed: %m\n",
204 launcher->exe);
205 _exit(EXIT_FAILURE);
206 }
207
208 launcher->process.pid = pid;
209 launcher->process.cleanup = test_client_sigchld;
210 weston_watch_process(&launcher->process);
211}
212
213int
214controller_module_init(struct weston_compositor *compositor,
215 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000216 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200217 size_t iface_version);
218
219WL_EXPORT int
220controller_module_init(struct weston_compositor *compositor,
221 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000222 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200223 size_t iface_version)
224{
225 struct wl_event_loop *loop;
226 struct test_launcher *launcher;
227 const char *path;
228
229 /* strict check, since this is an internal test module */
230 if (iface_version != sizeof(*iface)) {
231 weston_log("fatal: controller interface mismatch\n");
232 return -1;
233 }
234
235 path = getenv("WESTON_BUILD_DIR");
236 if (!path) {
237 weston_log("test setup failure: WESTON_BUILD_DIR not set\n");
238 return -1;
239 }
240
241 launcher = zalloc(sizeof *launcher);
242 if (!launcher)
243 return -1;
244
245 launcher->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000246 launcher->layout_interface = iface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200247 snprintf(launcher->exe, sizeof launcher->exe,
248 "%s/ivi-layout.ivi", path);
249
250 if (wl_global_create(compositor->wl_display,
251 &weston_test_runner_interface, 1,
252 launcher, bind_runner) == NULL)
253 return -1;
254
255 loop = wl_display_get_event_loop(compositor->wl_display);
256 wl_event_loop_add_idle(loop, idle_launch_client, launcher);
257
258 return 0;
259}
260
261static void
262runner_assert_fail(const char *cond, const char *file, int line,
263 const char *func, struct test_context *ctx)
264{
265 weston_log("Assert failure in %s:%d, %s: '%s'\n",
266 file, line, func, cond);
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900267
268 assert(ctx->runner_resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200269 wl_resource_post_error(ctx->runner_resource,
270 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
271 "Assert failure in %s:%d, %s: '%s'\n",
272 file, line, func, cond);
273}
274
275#define runner_assert(cond) ({ \
276 bool b_ = (cond); \
277 if (!b_) \
278 runner_assert_fail(#cond, __FILE__, __LINE__, \
279 __func__, ctx); \
280 b_; \
281})
282
283#define runner_assert_or_return(cond) do { \
284 bool b_ = (cond); \
285 if (!b_) { \
286 runner_assert_fail(#cond, __FILE__, __LINE__, \
287 __func__, ctx); \
288 return; \
289 } \
290} while (0)
291
292
293/*************************** tests **********************************/
294
295/*
296 * This is a controller module: a plugin to ivi-shell.so, i.e. a sub-plugin.
297 * This module is specially written to execute tests that target the
298 * ivi_layout API.
299 *
300 * This module is listed in TESTS in Makefile.am. weston-tests-env handles
301 * this module specially by loading it in ivi-shell.
302 *
303 * Once Weston init completes, this module launches one test program:
304 * ivi-layout.ivi (ivi_layout-test.c). That program uses the weston-test-runner
305 * framework to fork and exec each TEST() in ivi_layout-test.c with a fresh
306 * connection to the single compositor instance.
307 *
308 * Each TEST() in ivi_layout-test.c will bind to weston_test_runner global
309 * interface. A TEST() will set up the client state, and issue
310 * weston_test_runner.run request to execute the compositor-side of the test.
311 *
312 * The compositor-side parts of the tests are in this file. They are specified
313 * by RUNNER_TEST() macro, where the name argument matches the name string
314 * passed to weston_test_runner.run.
315 *
316 * A RUNNER_TEST() function simply returns when it succeeds. If it fails,
317 * a fatal protocol error is sent to the client from runner_assert() or
318 * runner_assert_or_return(). This module catches the test program exit
319 * code and passes it out of Weston to the test harness.
320 *
321 * A single TEST() in ivi_layout-test.c may use multiple RUNNER_TEST()s to
322 * achieve multiple test points over a client action sequence.
323 */
324
325RUNNER_TEST(surface_create_p1)
326{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000327 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200328 struct ivi_layout_surface *ivisurf[2];
329 uint32_t ivi_id;
330
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000331 ivisurf[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900332 runner_assert(ivisurf[0]);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200333
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000334 ivisurf[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(1));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900335 runner_assert(ivisurf[1]);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200336
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000337 ivi_id = lyt->get_id_of_surface(ivisurf[0]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900338 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200339
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000340 ivi_id = lyt->get_id_of_surface(ivisurf[1]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900341 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(1));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200342}
343
344RUNNER_TEST(surface_create_p2)
345{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000346 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200347 struct ivi_layout_surface *ivisurf;
348
349 /* the ivi_surface was destroyed by the client */
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000350 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900351 runner_assert(ivisurf == NULL);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200352}
353
354RUNNER_TEST(surface_visibility)
355{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000356 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200357 struct ivi_layout_surface *ivisurf;
358 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200359 const struct ivi_layout_surface_properties *prop;
360
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000361 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900362 runner_assert(ivisurf);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200363
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000364 ret = lyt->surface_set_visibility(ivisurf, true);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900365 runner_assert(ret == IVI_SUCCEEDED);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200366
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000367 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200368
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900370 runner_assert(prop->visibility == true);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200371}
372
373RUNNER_TEST(surface_opacity)
374{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000375 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200376 struct ivi_layout_surface *ivisurf;
377 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200378 const struct ivi_layout_surface_properties *prop;
379
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000380 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900381 runner_assert(ivisurf);
382
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000383 prop = lyt->get_properties_of_surface(ivisurf);
384 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200385
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000386 ret = lyt->surface_set_opacity(ivisurf, wl_fixed_from_double(0.5));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900387 runner_assert(ret == IVI_SUCCEEDED);
388
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000389 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200390
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000391 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200392
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900393 runner_assert(prop->opacity == wl_fixed_from_double(0.5));
394}
395
396RUNNER_TEST(surface_orientation)
397{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000398 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900399 struct ivi_layout_surface *ivisurf;
400 const struct ivi_layout_surface_properties *prop;
401
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000402 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900403 runner_assert(ivisurf != NULL);
404
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000405 prop = lyt->get_properties_of_surface(ivisurf);
406 runner_assert_or_return(prop);
407 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900408
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000409 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900410 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
411
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000412 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900413
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000414 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900415
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900416 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
417}
418
419RUNNER_TEST(surface_dimension)
420{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000421 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900422 struct ivi_layout_surface *ivisurf;
423 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900424
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900426 runner_assert(ivisurf != NULL);
427
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000428 prop = lyt->get_properties_of_surface(ivisurf);
429 runner_assert_or_return(prop);
430 runner_assert(prop->dest_width == 1);
431 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900432
433 runner_assert(IVI_SUCCEEDED ==
Ucan, Emre \(ADITG/SW1\)45d39422016-03-04 12:50:50 +0000434 lyt->surface_set_destination_rectangle(ivisurf, prop->dest_x,
435 prop->dest_y, 200, 300));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900436
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000437 runner_assert(prop->dest_width == 1);
438 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900439
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000440 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900441
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000442 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900443 runner_assert_or_return(prop);
444 runner_assert(prop->dest_width == 200);
445 runner_assert(prop->dest_height == 300);
446}
447
448RUNNER_TEST(surface_position)
449{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000450 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900451 struct ivi_layout_surface *ivisurf;
452 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900453
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000454 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900455 runner_assert(ivisurf != NULL);
456
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000457 prop = lyt->get_properties_of_surface(ivisurf);
458 runner_assert_or_return(prop);
459 runner_assert(prop->dest_x == 0);
460 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900461
Ucan, Emre \(ADITG/SW1\)161da402016-03-04 12:50:43 +0000462 runner_assert(lyt->surface_set_destination_rectangle(
463 ivisurf, 20, 30,
464 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900465
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000466 runner_assert(prop->dest_x == 0);
467 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900468
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000469 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900470
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000471 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900472 runner_assert_or_return(prop);
473 runner_assert(prop->dest_x == 20);
474 runner_assert(prop->dest_y == 30);
475}
476
477RUNNER_TEST(surface_destination_rectangle)
478{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000479 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900480 struct ivi_layout_surface *ivisurf;
481 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900482
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000483 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900484 runner_assert(ivisurf != NULL);
485
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000486 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900487 runner_assert_or_return(prop);
488 runner_assert(prop->dest_width == 1);
489 runner_assert(prop->dest_height == 1);
490 runner_assert(prop->dest_x == 0);
491 runner_assert(prop->dest_y == 0);
492
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000493 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900494 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
495
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000496 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900497 runner_assert_or_return(prop);
498 runner_assert(prop->dest_width == 1);
499 runner_assert(prop->dest_height == 1);
500 runner_assert(prop->dest_x == 0);
501 runner_assert(prop->dest_y == 0);
502
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000503 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900504
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000505 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900506 runner_assert_or_return(prop);
507 runner_assert(prop->dest_width == 200);
508 runner_assert(prop->dest_height == 300);
509 runner_assert(prop->dest_x == 20);
510 runner_assert(prop->dest_y == 30);
511}
512
513RUNNER_TEST(surface_source_rectangle)
514{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000515 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900516 struct ivi_layout_surface *ivisurf;
517 const struct ivi_layout_surface_properties *prop;
518
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000519 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900520 runner_assert(ivisurf != NULL);
521
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000522 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900523 runner_assert_or_return(prop);
524 runner_assert(prop->source_width == 0);
525 runner_assert(prop->source_height == 0);
526 runner_assert(prop->source_x == 0);
527 runner_assert(prop->source_y == 0);
528
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000529 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900530 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
531
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000532 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900533 runner_assert_or_return(prop);
534 runner_assert(prop->source_width == 0);
535 runner_assert(prop->source_height == 0);
536 runner_assert(prop->source_x == 0);
537 runner_assert(prop->source_y == 0);
538
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900540
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000541 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900542 runner_assert_or_return(prop);
543 runner_assert(prop->source_width == 200);
544 runner_assert(prop->source_height == 300);
545 runner_assert(prop->source_x == 20);
546 runner_assert(prop->source_y == 30);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200547}
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900548
549RUNNER_TEST(surface_bad_opacity)
550{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000551 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900552 struct ivi_layout_surface *ivisurf;
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000553 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900554
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000555 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900556 runner_assert(ivisurf != NULL);
557
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000558 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900559 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
560
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000561 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900562 ivisurf, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
563
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000564 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900565 ivisurf, wl_fixed_from_double(-1)) == IVI_FAILED);
566
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000567 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900568
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000569 prop = lyt->get_properties_of_surface(ivisurf);
570 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900571
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000572 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900573 ivisurf, wl_fixed_from_double(1.1)) == IVI_FAILED);
574
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000575 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900576
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000577 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900578
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000579 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900580 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
581
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000582 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900583}
584
585RUNNER_TEST(ivi_layout_commit_changes)
586{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000587 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900588
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000589 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900590}
591
592RUNNER_TEST(commit_changes_after_visibility_set_surface_destroy)
593{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000594 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900595 struct ivi_layout_surface *ivisurf;
596
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000597 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900598 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000599 runner_assert(lyt->surface_set_visibility(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900600 ivisurf, true) == IVI_SUCCEEDED);
601}
602
603RUNNER_TEST(commit_changes_after_opacity_set_surface_destroy)
604{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000605 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900606 struct ivi_layout_surface *ivisurf;
607
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000608 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900609 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000610 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900611 ivisurf, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
612}
613
614RUNNER_TEST(commit_changes_after_orientation_set_surface_destroy)
615{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000616 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900617 struct ivi_layout_surface *ivisurf;
618
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000619 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900620 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000621 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900622 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
623}
624
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900625RUNNER_TEST(commit_changes_after_source_rectangle_set_surface_destroy)
626{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000627 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900628 struct ivi_layout_surface *ivisurf;
629
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000630 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900631 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000632 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900633 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
634}
635
636RUNNER_TEST(commit_changes_after_destination_rectangle_set_surface_destroy)
637{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000638 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900639 struct ivi_layout_surface *ivisurf;
640
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000641 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900642 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000643 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900644 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
645}
646
647RUNNER_TEST(get_surface_after_destroy_surface)
648{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900650 struct ivi_layout_surface *ivisurf;
651
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000652 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900653 runner_assert(ivisurf == NULL);
654}
655
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900656RUNNER_TEST(layer_render_order)
657{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000658 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900659 struct ivi_layout_layer *ivilayer;
660 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
661 struct ivi_layout_surface **array;
662 int32_t length = 0;
663 uint32_t i;
664
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000665 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900666
667 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000668 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900669
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000670 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900671 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
672
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000673 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900674
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000675 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900676 ivilayer, &length, &array) == IVI_SUCCEEDED);
677 runner_assert(IVI_TEST_SURFACE_COUNT == length);
678 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
679 runner_assert(array[i] == ivisurfs[i]);
680
681 if (length > 0)
682 free(array);
683
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000684 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900685 ivilayer, NULL, 0) == IVI_SUCCEEDED);
686
687 array = NULL;
688
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000689 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900690
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000691 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900692 ivilayer, &length, &array) == IVI_SUCCEEDED);
693 runner_assert(length == 0 && array == NULL);
694
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000695 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900696}
697
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900698RUNNER_TEST(test_layer_render_order_destroy_one_surface_p1)
699{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900701 struct ivi_layout_layer *ivilayer;
702 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
703 struct ivi_layout_surface **array;
704 int32_t length = 0;
705 int32_t i;
706
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000707 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900708
709 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000710 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900711
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000712 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900713 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
714
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000715 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900716
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000717 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900718 ivilayer, &length, &array) == IVI_SUCCEEDED);
719 runner_assert(IVI_TEST_SURFACE_COUNT == length);
720 for (i = 0; i < length; i++)
721 runner_assert(array[i] == ivisurfs[i]);
722
723 if (length > 0)
724 free(array);
725}
726
727RUNNER_TEST(test_layer_render_order_destroy_one_surface_p2)
728{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000729 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900730 struct ivi_layout_layer *ivilayer;
731 struct ivi_layout_surface *ivisurfs[2] = {};
732 struct ivi_layout_surface **array;
733 int32_t length = 0;
734 int32_t i;
735
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000736 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
737 ivisurfs[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
738 ivisurfs[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(2));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900739
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000740 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900741 ivilayer, &length, &array) == IVI_SUCCEEDED);
742 runner_assert(2 == length);
743 for (i = 0; i < length; i++)
744 runner_assert(array[i] == ivisurfs[i]);
745
746 if (length > 0)
747 free(array);
748
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000749 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900750}
751
752RUNNER_TEST(layer_bad_render_order)
753{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000754 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900755 struct ivi_layout_layer *ivilayer;
756 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
757 struct ivi_layout_surface **array = NULL;
758 int32_t length = 0;
759 uint32_t i;
760
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000761 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900762
763 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000764 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900765
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000766 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900767 NULL, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_FAILED);
768
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900770
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000771 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900772 NULL, &length, &array) == IVI_FAILED);
773 runner_assert(length == 0 && array == NULL);
774
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000775 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900776 ivilayer, NULL, &array) == IVI_FAILED);
777 runner_assert(array == NULL);
778
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000779 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900780 ivilayer, &length, NULL) == IVI_FAILED);
781 runner_assert(length == 0);
782
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000783 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900784}
785
786RUNNER_TEST(commit_changes_after_render_order_set_surface_destroy)
787{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000788 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900789 struct ivi_layout_layer *ivilayer;
790 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
791 int i;
792
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000793 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900794
795 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000796 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900797
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000798 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900799 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
800}
801
802RUNNER_TEST(cleanup_layer)
803{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000804 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900805 struct ivi_layout_layer *ivilayer;
806
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
808 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900809}
810
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900811static void
812test_surface_properties_changed_notification_callback(struct ivi_layout_surface *ivisurf,
813 const struct ivi_layout_surface_properties *prop,
814 enum ivi_layout_notification_mask mask,
815 void *userdata)
816{
817 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000818 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900819
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000820 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900821
822 ctx->user_flags = 1;
823}
824
825RUNNER_TEST(surface_properties_changed_notification)
826{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000827 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900828 const uint32_t id_surface = IVI_TEST_SURFACE_ID(0);
829 struct ivi_layout_surface *ivisurf;
830
831 ctx->user_flags = 0;
832
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000833 ivisurf = lyt->get_surface_from_id(id_surface);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900834 runner_assert(ivisurf != NULL);
835
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000836 runner_assert(lyt->surface_add_notification(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900837 ivisurf, test_surface_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
838
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000839 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900840
841 runner_assert(ctx->user_flags == 0);
842
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000843 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900844 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
845
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000846 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900847
848 runner_assert(ctx->user_flags == 1);
849
850 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000851 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900852 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
853
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000854 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900855
856 runner_assert(ctx->user_flags == 0);
857
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000858 lyt->surface_remove_notification(ivisurf);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900859 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000860 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900861 ivisurf, 40, 50, 400, 500) == IVI_SUCCEEDED);
862
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000863 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900864
865 runner_assert(ctx->user_flags == 0);
866}
867
868static void
869test_surface_configure_notification_callback(struct ivi_layout_surface *ivisurf,
870 void *userdata)
871{
872 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000873 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900874
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000875 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900876
877 ctx->user_flags = 1;
878}
879
880RUNNER_TEST(surface_configure_notification_p1)
881{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900883
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000884 runner_assert(IVI_SUCCEEDED == lyt->add_notification_configure_surface(test_surface_configure_notification_callback, ctx));
885 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900886
887 ctx->user_flags = 0;
888}
889
890RUNNER_TEST(surface_configure_notification_p2)
891{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000892 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900893
894 runner_assert(ctx->user_flags == 1);
895
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000896 lyt->remove_notification_configure_surface(test_surface_configure_notification_callback, ctx);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900897 ctx->user_flags = 0;
898}
899
900RUNNER_TEST(surface_configure_notification_p3)
901{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000902 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900903
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000904 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900905 runner_assert(ctx->user_flags == 0);
906}
907
908static void
909test_surface_create_notification_callback(struct ivi_layout_surface *ivisurf,
910 void *userdata)
911{
912 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000913 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900914
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000915 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900916
917 ctx->user_flags = 1;
918}
919
920RUNNER_TEST(surface_create_notification_p1)
921{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000922 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900923
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000924 runner_assert(lyt->add_notification_create_surface(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900925 test_surface_create_notification_callback, ctx) == IVI_SUCCEEDED);
926
927 ctx->user_flags = 0;
928}
929
930RUNNER_TEST(surface_create_notification_p2)
931{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000932 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900933
934 runner_assert(ctx->user_flags == 1);
935
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000936 lyt->remove_notification_create_surface(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900937 test_surface_create_notification_callback, ctx);
938 ctx->user_flags = 0;
939}
940
941RUNNER_TEST(surface_create_notification_p3)
942{
943 runner_assert(ctx->user_flags == 0);
944}
945
946static void
947test_surface_remove_notification_callback(struct ivi_layout_surface *ivisurf,
948 void *userdata)
949{
950 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000951 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900952
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000953 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900954
955 ctx->user_flags = 1;
956}
957
958RUNNER_TEST(surface_remove_notification_p1)
959{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000960 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900961
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000962 runner_assert(lyt->add_notification_remove_surface(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900963 test_surface_remove_notification_callback, ctx) == IVI_SUCCEEDED);
964
965 ctx->user_flags = 0;
966}
967
968RUNNER_TEST(surface_remove_notification_p2)
969{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000970 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900971
972 runner_assert(ctx->user_flags == 1);
973
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000974 lyt->remove_notification_remove_surface(test_surface_remove_notification_callback, ctx);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900975 ctx->user_flags = 0;
976}
977
978RUNNER_TEST(surface_remove_notification_p3)
979{
980 runner_assert(ctx->user_flags == 0);
981}
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900982
983static void
984test_surface_bad_properties_changed_notification_callback(struct ivi_layout_surface *ivisurf,
985 const struct ivi_layout_surface_properties *prop,
986 enum ivi_layout_notification_mask mask,
987 void *userdata)
988{
989}
990
991RUNNER_TEST(surface_bad_properties_changed_notification)
992{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000993 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900994 struct ivi_layout_surface *ivisurf;
995
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000996 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900997 runner_assert(ivisurf != NULL);
998
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000999 runner_assert(lyt->surface_add_notification(
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001000 NULL, test_surface_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001001 runner_assert(lyt->surface_add_notification(
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001002 ivisurf, NULL, NULL) == IVI_FAILED);
1003}