blob: 44913d63343de39f6875157972c226dfe9e42a9b [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\)0c0e51e2015-10-15 14:51:41 +0000405 runner_assert(lyt->surface_get_orientation(ivisurf) ==
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900406 WL_OUTPUT_TRANSFORM_NORMAL);
407
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000408 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900409 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
410
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000411 runner_assert(lyt->surface_get_orientation(ivisurf) ==
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900412 WL_OUTPUT_TRANSFORM_NORMAL);
413
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000414 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900415
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 runner_assert(lyt->surface_get_orientation(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900417 ivisurf) == WL_OUTPUT_TRANSFORM_90);
418
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000419 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900420 runner_assert_or_return(prop);
421 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
422}
423
424RUNNER_TEST(surface_dimension)
425{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000426 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900427 struct ivi_layout_surface *ivisurf;
428 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900429
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000430 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900431 runner_assert(ivisurf != NULL);
432
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000433 prop = lyt->get_properties_of_surface(ivisurf);
434 runner_assert_or_return(prop);
435 runner_assert(prop->dest_width == 1);
436 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900437
438 runner_assert(IVI_SUCCEEDED ==
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000439 lyt->surface_set_dimension(ivisurf, 200, 300));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900440
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000441 runner_assert(prop->dest_width == 1);
442 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900443
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000444 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900445
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000446 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900447 runner_assert_or_return(prop);
448 runner_assert(prop->dest_width == 200);
449 runner_assert(prop->dest_height == 300);
450}
451
452RUNNER_TEST(surface_position)
453{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000454 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900455 struct ivi_layout_surface *ivisurf;
456 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900457
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000458 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900459 runner_assert(ivisurf != NULL);
460
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000461 prop = lyt->get_properties_of_surface(ivisurf);
462 runner_assert_or_return(prop);
463 runner_assert(prop->dest_x == 0);
464 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900465
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000466 runner_assert(lyt->surface_set_position(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900467 ivisurf, 20, 30) == IVI_SUCCEEDED);
468
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000469 runner_assert(prop->dest_x == 0);
470 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900471
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000472 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900473
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000474 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900475 runner_assert_or_return(prop);
476 runner_assert(prop->dest_x == 20);
477 runner_assert(prop->dest_y == 30);
478}
479
480RUNNER_TEST(surface_destination_rectangle)
481{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000482 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900483 struct ivi_layout_surface *ivisurf;
484 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900485
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000486 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900487 runner_assert(ivisurf != NULL);
488
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000489 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900490 runner_assert_or_return(prop);
491 runner_assert(prop->dest_width == 1);
492 runner_assert(prop->dest_height == 1);
493 runner_assert(prop->dest_x == 0);
494 runner_assert(prop->dest_y == 0);
495
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000496 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900497 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
498
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000499 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900500 runner_assert_or_return(prop);
501 runner_assert(prop->dest_width == 1);
502 runner_assert(prop->dest_height == 1);
503 runner_assert(prop->dest_x == 0);
504 runner_assert(prop->dest_y == 0);
505
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000506 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900507
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000508 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900509 runner_assert_or_return(prop);
510 runner_assert(prop->dest_width == 200);
511 runner_assert(prop->dest_height == 300);
512 runner_assert(prop->dest_x == 20);
513 runner_assert(prop->dest_y == 30);
514}
515
516RUNNER_TEST(surface_source_rectangle)
517{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000518 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900519 struct ivi_layout_surface *ivisurf;
520 const struct ivi_layout_surface_properties *prop;
521
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000522 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900523 runner_assert(ivisurf != NULL);
524
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000525 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900526 runner_assert_or_return(prop);
527 runner_assert(prop->source_width == 0);
528 runner_assert(prop->source_height == 0);
529 runner_assert(prop->source_x == 0);
530 runner_assert(prop->source_y == 0);
531
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000532 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900533 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
534
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000535 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900536 runner_assert_or_return(prop);
537 runner_assert(prop->source_width == 0);
538 runner_assert(prop->source_height == 0);
539 runner_assert(prop->source_x == 0);
540 runner_assert(prop->source_y == 0);
541
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000542 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900543
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000544 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900545 runner_assert_or_return(prop);
546 runner_assert(prop->source_width == 200);
547 runner_assert(prop->source_height == 300);
548 runner_assert(prop->source_x == 20);
549 runner_assert(prop->source_y == 30);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200550}
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900551
552RUNNER_TEST(surface_bad_opacity)
553{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000554 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900555 struct ivi_layout_surface *ivisurf;
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000556 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900557
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000558 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900559 runner_assert(ivisurf != NULL);
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 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
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(0.3)) == IVI_SUCCEEDED);
566
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000567 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900568 ivisurf, wl_fixed_from_double(-1)) == IVI_FAILED);
569
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000570 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900571
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000572 prop = lyt->get_properties_of_surface(ivisurf);
573 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900574
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000575 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900576 ivisurf, wl_fixed_from_double(1.1)) == IVI_FAILED);
577
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000578 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900579
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000580 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900581
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000582 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900583 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
584
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000585 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900586}
587
588RUNNER_TEST(ivi_layout_commit_changes)
589{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000590 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900591
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000592 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900593}
594
595RUNNER_TEST(commit_changes_after_visibility_set_surface_destroy)
596{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000597 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900598 struct ivi_layout_surface *ivisurf;
599
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000600 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900601 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000602 runner_assert(lyt->surface_set_visibility(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900603 ivisurf, true) == IVI_SUCCEEDED);
604}
605
606RUNNER_TEST(commit_changes_after_opacity_set_surface_destroy)
607{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000608 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900609 struct ivi_layout_surface *ivisurf;
610
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000611 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900612 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000613 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900614 ivisurf, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
615}
616
617RUNNER_TEST(commit_changes_after_orientation_set_surface_destroy)
618{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000619 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900620 struct ivi_layout_surface *ivisurf;
621
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000622 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900623 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000624 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900625 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
626}
627
628RUNNER_TEST(commit_changes_after_dimension_set_surface_destroy)
629{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000630 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900631 struct ivi_layout_surface *ivisurf;
632
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000633 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900634 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000635 runner_assert(lyt->surface_set_dimension(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900636 ivisurf, 200, 300) == IVI_SUCCEEDED);
637}
638
639RUNNER_TEST(commit_changes_after_position_set_surface_destroy)
640{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000641 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900642 struct ivi_layout_surface *ivisurf;
643
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000644 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900645 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 runner_assert(lyt->surface_set_position(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900647 ivisurf, 20, 30) == IVI_SUCCEEDED);
648}
649
650RUNNER_TEST(commit_changes_after_source_rectangle_set_surface_destroy)
651{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000652 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900653 struct ivi_layout_surface *ivisurf;
654
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000655 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900656 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000657 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900658 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
659}
660
661RUNNER_TEST(commit_changes_after_destination_rectangle_set_surface_destroy)
662{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000663 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900664 struct ivi_layout_surface *ivisurf;
665
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000666 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900667 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000668 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900669 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
670}
671
672RUNNER_TEST(get_surface_after_destroy_surface)
673{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000674 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900675 struct ivi_layout_surface *ivisurf;
676
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000677 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900678 runner_assert(ivisurf == NULL);
679}
680
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900681RUNNER_TEST(layer_render_order)
682{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000683 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900684 struct ivi_layout_layer *ivilayer;
685 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
686 struct ivi_layout_surface **array;
687 int32_t length = 0;
688 uint32_t i;
689
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000690 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900691
692 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000693 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900694
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000695 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900696 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
697
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000698 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900699
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900701 ivilayer, &length, &array) == IVI_SUCCEEDED);
702 runner_assert(IVI_TEST_SURFACE_COUNT == length);
703 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
704 runner_assert(array[i] == ivisurfs[i]);
705
706 if (length > 0)
707 free(array);
708
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000709 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900710 ivilayer, NULL, 0) == IVI_SUCCEEDED);
711
712 array = NULL;
713
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000714 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900715
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000716 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900717 ivilayer, &length, &array) == IVI_SUCCEEDED);
718 runner_assert(length == 0 && array == NULL);
719
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900721}
722
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900723RUNNER_TEST(test_layer_render_order_destroy_one_surface_p1)
724{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000725 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900726 struct ivi_layout_layer *ivilayer;
727 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
728 struct ivi_layout_surface **array;
729 int32_t length = 0;
730 int32_t i;
731
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000732 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900733
734 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000735 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900736
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000737 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900738 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
739
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000740 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900741
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000742 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900743 ivilayer, &length, &array) == IVI_SUCCEEDED);
744 runner_assert(IVI_TEST_SURFACE_COUNT == length);
745 for (i = 0; i < length; i++)
746 runner_assert(array[i] == ivisurfs[i]);
747
748 if (length > 0)
749 free(array);
750}
751
752RUNNER_TEST(test_layer_render_order_destroy_one_surface_p2)
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[2] = {};
757 struct ivi_layout_surface **array;
758 int32_t length = 0;
759 int32_t i;
760
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000761 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
762 ivisurfs[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
763 ivisurfs[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(2));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900764
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000765 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900766 ivilayer, &length, &array) == IVI_SUCCEEDED);
767 runner_assert(2 == length);
768 for (i = 0; i < length; i++)
769 runner_assert(array[i] == ivisurfs[i]);
770
771 if (length > 0)
772 free(array);
773
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900775}
776
777RUNNER_TEST(layer_bad_render_order)
778{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000779 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900780 struct ivi_layout_layer *ivilayer;
781 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
782 struct ivi_layout_surface **array = NULL;
783 int32_t length = 0;
784 uint32_t i;
785
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000786 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900787
788 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000789 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900790
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000791 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900792 NULL, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_FAILED);
793
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000794 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900795
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000796 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900797 NULL, &length, &array) == IVI_FAILED);
798 runner_assert(length == 0 && array == NULL);
799
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000800 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900801 ivilayer, NULL, &array) == IVI_FAILED);
802 runner_assert(array == NULL);
803
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000804 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900805 ivilayer, &length, NULL) == IVI_FAILED);
806 runner_assert(length == 0);
807
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000808 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900809}
810
811RUNNER_TEST(commit_changes_after_render_order_set_surface_destroy)
812{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000813 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900814 struct ivi_layout_layer *ivilayer;
815 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
816 int i;
817
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000818 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900819
820 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000821 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900822
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000823 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900824 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
825}
826
827RUNNER_TEST(cleanup_layer)
828{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000829 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900830 struct ivi_layout_layer *ivilayer;
831
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000832 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
833 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900834}
835
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900836static void
837test_surface_properties_changed_notification_callback(struct ivi_layout_surface *ivisurf,
838 const struct ivi_layout_surface_properties *prop,
839 enum ivi_layout_notification_mask mask,
840 void *userdata)
841{
842 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000843 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900844
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000845 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900846
847 ctx->user_flags = 1;
848}
849
850RUNNER_TEST(surface_properties_changed_notification)
851{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000852 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900853 const uint32_t id_surface = IVI_TEST_SURFACE_ID(0);
854 struct ivi_layout_surface *ivisurf;
855
856 ctx->user_flags = 0;
857
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000858 ivisurf = lyt->get_surface_from_id(id_surface);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900859 runner_assert(ivisurf != NULL);
860
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000861 runner_assert(lyt->surface_add_notification(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900862 ivisurf, test_surface_properties_changed_notification_callback, ctx) == IVI_SUCCEEDED);
863
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000864 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900865
866 runner_assert(ctx->user_flags == 0);
867
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000868 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900869 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
870
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000871 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900872
873 runner_assert(ctx->user_flags == 1);
874
875 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000876 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900877 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
878
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000879 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900880
881 runner_assert(ctx->user_flags == 0);
882
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000883 lyt->surface_remove_notification(ivisurf);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900884 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000885 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900886 ivisurf, 40, 50, 400, 500) == IVI_SUCCEEDED);
887
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000888 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900889
890 runner_assert(ctx->user_flags == 0);
891}
892
893static void
894test_surface_configure_notification_callback(struct ivi_layout_surface *ivisurf,
895 void *userdata)
896{
897 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000898 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900899
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000900 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900901
902 ctx->user_flags = 1;
903}
904
905RUNNER_TEST(surface_configure_notification_p1)
906{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000907 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900908
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000909 runner_assert(IVI_SUCCEEDED == lyt->add_notification_configure_surface(test_surface_configure_notification_callback, ctx));
910 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900911
912 ctx->user_flags = 0;
913}
914
915RUNNER_TEST(surface_configure_notification_p2)
916{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000917 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900918
919 runner_assert(ctx->user_flags == 1);
920
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000921 lyt->remove_notification_configure_surface(test_surface_configure_notification_callback, ctx);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900922 ctx->user_flags = 0;
923}
924
925RUNNER_TEST(surface_configure_notification_p3)
926{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000927 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900928
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000929 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900930 runner_assert(ctx->user_flags == 0);
931}
932
933static void
934test_surface_create_notification_callback(struct ivi_layout_surface *ivisurf,
935 void *userdata)
936{
937 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000938 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900939
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000940 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900941
942 ctx->user_flags = 1;
943}
944
945RUNNER_TEST(surface_create_notification_p1)
946{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000947 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900948
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000949 runner_assert(lyt->add_notification_create_surface(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900950 test_surface_create_notification_callback, ctx) == IVI_SUCCEEDED);
951
952 ctx->user_flags = 0;
953}
954
955RUNNER_TEST(surface_create_notification_p2)
956{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000957 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900958
959 runner_assert(ctx->user_flags == 1);
960
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000961 lyt->remove_notification_create_surface(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900962 test_surface_create_notification_callback, ctx);
963 ctx->user_flags = 0;
964}
965
966RUNNER_TEST(surface_create_notification_p3)
967{
968 runner_assert(ctx->user_flags == 0);
969}
970
971static void
972test_surface_remove_notification_callback(struct ivi_layout_surface *ivisurf,
973 void *userdata)
974{
975 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000976 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900977
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000978 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900979
980 ctx->user_flags = 1;
981}
982
983RUNNER_TEST(surface_remove_notification_p1)
984{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000985 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900986
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000987 runner_assert(lyt->add_notification_remove_surface(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900988 test_surface_remove_notification_callback, ctx) == IVI_SUCCEEDED);
989
990 ctx->user_flags = 0;
991}
992
993RUNNER_TEST(surface_remove_notification_p2)
994{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000995 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900996
997 runner_assert(ctx->user_flags == 1);
998
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000999 lyt->remove_notification_remove_surface(test_surface_remove_notification_callback, ctx);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001000 ctx->user_flags = 0;
1001}
1002
1003RUNNER_TEST(surface_remove_notification_p3)
1004{
1005 runner_assert(ctx->user_flags == 0);
1006}
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001007
1008static void
1009test_surface_bad_properties_changed_notification_callback(struct ivi_layout_surface *ivisurf,
1010 const struct ivi_layout_surface_properties *prop,
1011 enum ivi_layout_notification_mask mask,
1012 void *userdata)
1013{
1014}
1015
1016RUNNER_TEST(surface_bad_properties_changed_notification)
1017{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001018 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001019 struct ivi_layout_surface *ivisurf;
1020
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001021 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001022 runner_assert(ivisurf != NULL);
1023
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001024 runner_assert(lyt->surface_add_notification(
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001025 NULL, test_surface_bad_properties_changed_notification_callback, NULL) == IVI_FAILED);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001026 runner_assert(lyt->surface_add_notification(
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001027 ivisurf, NULL, NULL) == IVI_FAILED);
1028}