blob: 37e5cc7fa25d025b44e47b5754a7086dd613d85a [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;
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +000086
87 struct wl_listener surface_property_changed;
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +000088 struct wl_listener surface_created;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090089};
90
91static struct test_context static_context;
92
93static void
94destroy_runner(struct wl_resource *resource)
95{
96 assert(static_context.runner_resource == NULL ||
97 static_context.runner_resource == resource);
98
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000099 static_context.layout_interface = NULL;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900100 static_context.runner_resource = NULL;
101}
102
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200103static void
104runner_destroy_handler(struct wl_client *client, struct wl_resource *resource)
105{
106 wl_resource_destroy(resource);
107}
108
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200109static void
110runner_run_handler(struct wl_client *client, struct wl_resource *resource,
111 const char *test_name)
112{
113 struct test_launcher *launcher;
114 const struct runner_test *t;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900115
116 assert(static_context.runner_resource == NULL ||
117 static_context.runner_resource == resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200118
119 launcher = wl_resource_get_user_data(resource);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000120 static_context.layout_interface = launcher->layout_interface;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900121 static_context.runner_resource = resource;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200122
123 t = find_runner_test(test_name);
124 if (!t) {
125 weston_log("Error: runner test \"%s\" not found.\n",
126 test_name);
127 wl_resource_post_error(resource,
128 WESTON_TEST_RUNNER_ERROR_UNKNOWN_TEST,
129 "weston_test_runner: unknown: '%s'",
130 test_name);
131 return;
132 }
133
134 weston_log("weston_test_runner.run(\"%s\")\n", test_name);
135
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900136 t->run(&static_context);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200137
138 weston_test_runner_send_finished(resource);
139}
140
141static const struct weston_test_runner_interface runner_implementation = {
142 runner_destroy_handler,
143 runner_run_handler
144};
145
146static void
147bind_runner(struct wl_client *client, void *data,
148 uint32_t version, uint32_t id)
149{
150 struct test_launcher *launcher = data;
151 struct wl_resource *resource;
152
153 resource = wl_resource_create(client, &weston_test_runner_interface,
154 1, id);
155 if (!resource) {
156 wl_client_post_no_memory(client);
157 return;
158 }
159
160 wl_resource_set_implementation(resource, &runner_implementation,
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900161 launcher, destroy_runner);
162
163 if (static_context.runner_resource != NULL) {
164 weston_log("test FATAL: "
165 "attempting to run several tests in parallel.\n");
166 wl_resource_post_error(resource,
167 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
168 "attempt to run parallel tests");
169 }
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200170}
171
172static void
173test_client_sigchld(struct weston_process *process, int status)
174{
175 struct test_launcher *launcher =
176 container_of(process, struct test_launcher, process);
177 struct weston_compositor *c = launcher->compositor;
178
179 /* Chain up from weston-test-runner's exit code so that automake
180 * knows the exit status and can report e.g. skipped tests. */
181 if (WIFEXITED(status))
182 weston_compositor_exit_with_code(c, WEXITSTATUS(status));
183 else
184 weston_compositor_exit_with_code(c, EXIT_FAILURE);
185}
186
187static void
188idle_launch_client(void *data)
189{
190 struct test_launcher *launcher = data;
191 pid_t pid;
192 sigset_t allsigs;
193
194 pid = fork();
195 if (pid == -1) {
196 weston_log("fatal: failed to fork '%s': %m\n", launcher->exe);
197 weston_compositor_exit_with_code(launcher->compositor,
198 EXIT_FAILURE);
199 return;
200 }
201
202 if (pid == 0) {
203 sigfillset(&allsigs);
204 sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
205 execl(launcher->exe, launcher->exe, NULL);
206 weston_log("compositor: executing '%s' failed: %m\n",
207 launcher->exe);
208 _exit(EXIT_FAILURE);
209 }
210
211 launcher->process.pid = pid;
212 launcher->process.cleanup = test_client_sigchld;
213 weston_watch_process(&launcher->process);
214}
215
216int
217controller_module_init(struct weston_compositor *compositor,
218 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000219 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200220 size_t iface_version);
221
222WL_EXPORT int
223controller_module_init(struct weston_compositor *compositor,
224 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000225 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200226 size_t iface_version)
227{
228 struct wl_event_loop *loop;
229 struct test_launcher *launcher;
230 const char *path;
231
232 /* strict check, since this is an internal test module */
233 if (iface_version != sizeof(*iface)) {
234 weston_log("fatal: controller interface mismatch\n");
235 return -1;
236 }
237
238 path = getenv("WESTON_BUILD_DIR");
239 if (!path) {
240 weston_log("test setup failure: WESTON_BUILD_DIR not set\n");
241 return -1;
242 }
243
244 launcher = zalloc(sizeof *launcher);
245 if (!launcher)
246 return -1;
247
248 launcher->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000249 launcher->layout_interface = iface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200250 snprintf(launcher->exe, sizeof launcher->exe,
251 "%s/ivi-layout.ivi", path);
252
253 if (wl_global_create(compositor->wl_display,
254 &weston_test_runner_interface, 1,
255 launcher, bind_runner) == NULL)
256 return -1;
257
258 loop = wl_display_get_event_loop(compositor->wl_display);
259 wl_event_loop_add_idle(loop, idle_launch_client, launcher);
260
261 return 0;
262}
263
264static void
265runner_assert_fail(const char *cond, const char *file, int line,
266 const char *func, struct test_context *ctx)
267{
268 weston_log("Assert failure in %s:%d, %s: '%s'\n",
269 file, line, func, cond);
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900270
271 assert(ctx->runner_resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200272 wl_resource_post_error(ctx->runner_resource,
273 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
274 "Assert failure in %s:%d, %s: '%s'\n",
275 file, line, func, cond);
276}
277
278#define runner_assert(cond) ({ \
279 bool b_ = (cond); \
280 if (!b_) \
281 runner_assert_fail(#cond, __FILE__, __LINE__, \
282 __func__, ctx); \
283 b_; \
284})
285
286#define runner_assert_or_return(cond) do { \
287 bool b_ = (cond); \
288 if (!b_) { \
289 runner_assert_fail(#cond, __FILE__, __LINE__, \
290 __func__, ctx); \
291 return; \
292 } \
293} while (0)
294
295
296/*************************** tests **********************************/
297
298/*
299 * This is a controller module: a plugin to ivi-shell.so, i.e. a sub-plugin.
300 * This module is specially written to execute tests that target the
301 * ivi_layout API.
302 *
303 * This module is listed in TESTS in Makefile.am. weston-tests-env handles
304 * this module specially by loading it in ivi-shell.
305 *
306 * Once Weston init completes, this module launches one test program:
307 * ivi-layout.ivi (ivi_layout-test.c). That program uses the weston-test-runner
308 * framework to fork and exec each TEST() in ivi_layout-test.c with a fresh
309 * connection to the single compositor instance.
310 *
311 * Each TEST() in ivi_layout-test.c will bind to weston_test_runner global
312 * interface. A TEST() will set up the client state, and issue
313 * weston_test_runner.run request to execute the compositor-side of the test.
314 *
315 * The compositor-side parts of the tests are in this file. They are specified
316 * by RUNNER_TEST() macro, where the name argument matches the name string
317 * passed to weston_test_runner.run.
318 *
319 * A RUNNER_TEST() function simply returns when it succeeds. If it fails,
320 * a fatal protocol error is sent to the client from runner_assert() or
321 * runner_assert_or_return(). This module catches the test program exit
322 * code and passes it out of Weston to the test harness.
323 *
324 * A single TEST() in ivi_layout-test.c may use multiple RUNNER_TEST()s to
325 * achieve multiple test points over a client action sequence.
326 */
327
328RUNNER_TEST(surface_create_p1)
329{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000330 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200331 struct ivi_layout_surface *ivisurf[2];
332 uint32_t ivi_id;
333
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000334 ivisurf[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900335 runner_assert(ivisurf[0]);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200336
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000337 ivisurf[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(1));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900338 runner_assert(ivisurf[1]);
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[0]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900341 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200342
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000343 ivi_id = lyt->get_id_of_surface(ivisurf[1]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900344 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(1));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200345}
346
347RUNNER_TEST(surface_create_p2)
348{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000349 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200350 struct ivi_layout_surface *ivisurf;
351
352 /* the ivi_surface was destroyed by the client */
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000353 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900354 runner_assert(ivisurf == NULL);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200355}
356
357RUNNER_TEST(surface_visibility)
358{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000359 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200360 struct ivi_layout_surface *ivisurf;
361 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200362 const struct ivi_layout_surface_properties *prop;
363
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000364 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900365 runner_assert(ivisurf);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200366
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000367 ret = lyt->surface_set_visibility(ivisurf, true);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900368 runner_assert(ret == IVI_SUCCEEDED);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200369
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000370 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200371
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000372 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900373 runner_assert(prop->visibility == true);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200374}
375
376RUNNER_TEST(surface_opacity)
377{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000378 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200379 struct ivi_layout_surface *ivisurf;
380 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200381 const struct ivi_layout_surface_properties *prop;
382
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000383 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900384 runner_assert(ivisurf);
385
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000386 prop = lyt->get_properties_of_surface(ivisurf);
387 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200388
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000389 ret = lyt->surface_set_opacity(ivisurf, wl_fixed_from_double(0.5));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900390 runner_assert(ret == IVI_SUCCEEDED);
391
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000392 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200393
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000394 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200395
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900396 runner_assert(prop->opacity == wl_fixed_from_double(0.5));
397}
398
399RUNNER_TEST(surface_orientation)
400{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000401 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900402 struct ivi_layout_surface *ivisurf;
403 const struct ivi_layout_surface_properties *prop;
404
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000405 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900406 runner_assert(ivisurf != NULL);
407
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000408 prop = lyt->get_properties_of_surface(ivisurf);
409 runner_assert_or_return(prop);
410 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900411
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000412 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900413 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
414
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000415 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900416
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000417 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900418
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900419 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
420}
421
422RUNNER_TEST(surface_dimension)
423{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000424 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900425 struct ivi_layout_surface *ivisurf;
426 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900427
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000428 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900429 runner_assert(ivisurf != NULL);
430
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000431 prop = lyt->get_properties_of_surface(ivisurf);
432 runner_assert_or_return(prop);
433 runner_assert(prop->dest_width == 1);
434 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900435
436 runner_assert(IVI_SUCCEEDED ==
Ucan, Emre \(ADITG/SW1\)45d39422016-03-04 12:50:50 +0000437 lyt->surface_set_destination_rectangle(ivisurf, prop->dest_x,
438 prop->dest_y, 200, 300));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900439
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000440 runner_assert(prop->dest_width == 1);
441 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900442
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000443 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900444
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000445 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900446 runner_assert_or_return(prop);
447 runner_assert(prop->dest_width == 200);
448 runner_assert(prop->dest_height == 300);
449}
450
451RUNNER_TEST(surface_position)
452{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000453 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900454 struct ivi_layout_surface *ivisurf;
455 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900456
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000457 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900458 runner_assert(ivisurf != NULL);
459
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000460 prop = lyt->get_properties_of_surface(ivisurf);
461 runner_assert_or_return(prop);
462 runner_assert(prop->dest_x == 0);
463 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900464
Ucan, Emre \(ADITG/SW1\)161da402016-03-04 12:50:43 +0000465 runner_assert(lyt->surface_set_destination_rectangle(
466 ivisurf, 20, 30,
467 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900468
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
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900628RUNNER_TEST(commit_changes_after_source_rectangle_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_source_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900636 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
637}
638
639RUNNER_TEST(commit_changes_after_destination_rectangle_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_destination_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900647 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
648}
649
650RUNNER_TEST(get_surface_after_destroy_surface)
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);
657}
658
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900659RUNNER_TEST(layer_render_order)
660{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000661 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900662 struct ivi_layout_layer *ivilayer;
663 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
664 struct ivi_layout_surface **array;
665 int32_t length = 0;
666 uint32_t i;
667
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000668 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900669
670 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000671 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900672
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000673 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900674 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
675
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000676 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900677
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000678 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900679 ivilayer, &length, &array) == IVI_SUCCEEDED);
680 runner_assert(IVI_TEST_SURFACE_COUNT == length);
681 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
682 runner_assert(array[i] == ivisurfs[i]);
683
684 if (length > 0)
685 free(array);
686
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000687 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900688 ivilayer, NULL, 0) == IVI_SUCCEEDED);
689
690 array = NULL;
691
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000692 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900693
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000694 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900695 ivilayer, &length, &array) == IVI_SUCCEEDED);
696 runner_assert(length == 0 && array == NULL);
697
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000698 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900699}
700
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900701RUNNER_TEST(test_layer_render_order_destroy_one_surface_p1)
702{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000703 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900704 struct ivi_layout_layer *ivilayer;
705 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
706 struct ivi_layout_surface **array;
707 int32_t length = 0;
708 int32_t i;
709
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000710 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900711
712 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000713 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900714
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000715 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900716 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
717
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000718 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900719
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900721 ivilayer, &length, &array) == IVI_SUCCEEDED);
722 runner_assert(IVI_TEST_SURFACE_COUNT == length);
723 for (i = 0; i < length; i++)
724 runner_assert(array[i] == ivisurfs[i]);
725
726 if (length > 0)
727 free(array);
728}
729
730RUNNER_TEST(test_layer_render_order_destroy_one_surface_p2)
731{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000732 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900733 struct ivi_layout_layer *ivilayer;
734 struct ivi_layout_surface *ivisurfs[2] = {};
735 struct ivi_layout_surface **array;
736 int32_t length = 0;
737 int32_t i;
738
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000739 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
740 ivisurfs[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
741 ivisurfs[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(2));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900742
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000743 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900744 ivilayer, &length, &array) == IVI_SUCCEEDED);
745 runner_assert(2 == length);
746 for (i = 0; i < length; i++)
747 runner_assert(array[i] == ivisurfs[i]);
748
749 if (length > 0)
750 free(array);
751
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000752 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900753}
754
755RUNNER_TEST(layer_bad_render_order)
756{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000757 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900758 struct ivi_layout_layer *ivilayer;
759 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
760 struct ivi_layout_surface **array = NULL;
761 int32_t length = 0;
762 uint32_t i;
763
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000764 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900765
766 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000767 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900768
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900770 NULL, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_FAILED);
771
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000772 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900773
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900775 NULL, &length, &array) == IVI_FAILED);
776 runner_assert(length == 0 && array == NULL);
777
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000778 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900779 ivilayer, NULL, &array) == IVI_FAILED);
780 runner_assert(array == NULL);
781
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000782 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900783 ivilayer, &length, NULL) == IVI_FAILED);
784 runner_assert(length == 0);
785
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000786 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900787}
788
789RUNNER_TEST(commit_changes_after_render_order_set_surface_destroy)
790{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000791 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900792 struct ivi_layout_layer *ivilayer;
793 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
794 int i;
795
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000796 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900797
798 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000799 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900800
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000801 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900802 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
803}
804
805RUNNER_TEST(cleanup_layer)
806{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000807 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900808 struct ivi_layout_layer *ivilayer;
809
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000810 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
811 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900812}
813
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900814static void
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000815test_surface_properties_changed_notification_callback(struct wl_listener *listener, void *data)
816
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900817{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000818 struct test_context *ctx =
819 container_of(listener, struct test_context,
820 surface_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000821 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000822 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900823
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000824 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900825
826 ctx->user_flags = 1;
827}
828
829RUNNER_TEST(surface_properties_changed_notification)
830{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000831 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900832 const uint32_t id_surface = IVI_TEST_SURFACE_ID(0);
833 struct ivi_layout_surface *ivisurf;
834
835 ctx->user_flags = 0;
836
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000837 ivisurf = lyt->get_surface_from_id(id_surface);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900838 runner_assert(ivisurf != NULL);
839
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000840 ctx->surface_property_changed.notify = test_surface_properties_changed_notification_callback;
841
842 runner_assert(lyt->surface_add_listener(
843 ivisurf, &ctx->surface_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900844
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000845 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900846
847 runner_assert(ctx->user_flags == 0);
848
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000849 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900850 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
851
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000852 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900853
854 runner_assert(ctx->user_flags == 1);
855
856 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000857 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900858 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
859
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000860 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900861
862 runner_assert(ctx->user_flags == 0);
863
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000864 // remove surface property changed listener.
865 wl_list_remove(&ctx->surface_property_changed.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900866 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000867 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900868 ivisurf, 40, 50, 400, 500) == IVI_SUCCEEDED);
869
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000870 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900871
872 runner_assert(ctx->user_flags == 0);
873}
874
875static void
876test_surface_configure_notification_callback(struct ivi_layout_surface *ivisurf,
877 void *userdata)
878{
879 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000880 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900881
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000882 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900883
884 ctx->user_flags = 1;
885}
886
887RUNNER_TEST(surface_configure_notification_p1)
888{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000889 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900890
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000891 runner_assert(IVI_SUCCEEDED == lyt->add_notification_configure_surface(test_surface_configure_notification_callback, ctx));
892 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900893
894 ctx->user_flags = 0;
895}
896
897RUNNER_TEST(surface_configure_notification_p2)
898{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000899 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900900
901 runner_assert(ctx->user_flags == 1);
902
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000903 lyt->remove_notification_configure_surface(test_surface_configure_notification_callback, ctx);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900904 ctx->user_flags = 0;
905}
906
907RUNNER_TEST(surface_configure_notification_p3)
908{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000909 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900910
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000911 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900912 runner_assert(ctx->user_flags == 0);
913}
914
915static void
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000916test_surface_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900917{
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000918 struct test_context *ctx =
919 container_of(listener, struct test_context,
920 surface_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000921 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000922 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900923
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000924 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900925
926 ctx->user_flags = 1;
927}
928
929RUNNER_TEST(surface_create_notification_p1)
930{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000931 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900932
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000933 ctx->surface_created.notify = test_surface_create_notification_callback;
934 runner_assert(lyt->add_listener_create_surface(
935 &ctx->surface_created) == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900936
937 ctx->user_flags = 0;
938}
939
940RUNNER_TEST(surface_create_notification_p2)
941{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900942 runner_assert(ctx->user_flags == 1);
943
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000944 // remove surface created listener.
945 wl_list_remove(&ctx->surface_created.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900946 ctx->user_flags = 0;
947}
948
949RUNNER_TEST(surface_create_notification_p3)
950{
951 runner_assert(ctx->user_flags == 0);
952}
953
954static void
955test_surface_remove_notification_callback(struct ivi_layout_surface *ivisurf,
956 void *userdata)
957{
958 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000959 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900960
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000961 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900962
963 ctx->user_flags = 1;
964}
965
966RUNNER_TEST(surface_remove_notification_p1)
967{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000968 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900969
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000970 runner_assert(lyt->add_notification_remove_surface(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900971 test_surface_remove_notification_callback, ctx) == IVI_SUCCEEDED);
972
973 ctx->user_flags = 0;
974}
975
976RUNNER_TEST(surface_remove_notification_p2)
977{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000978 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900979
980 runner_assert(ctx->user_flags == 1);
981
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000982 lyt->remove_notification_remove_surface(test_surface_remove_notification_callback, ctx);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900983 ctx->user_flags = 0;
984}
985
986RUNNER_TEST(surface_remove_notification_p3)
987{
988 runner_assert(ctx->user_flags == 0);
989}
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900990
991static void
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000992test_surface_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900993{
994}
995
996RUNNER_TEST(surface_bad_properties_changed_notification)
997{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000998 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900999 struct ivi_layout_surface *ivisurf;
1000
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001001 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001002 runner_assert(ivisurf != NULL);
1003
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001004 ctx->surface_property_changed.notify = test_surface_bad_properties_changed_notification_callback;
1005
1006 runner_assert(lyt->surface_add_listener(
1007 NULL, &ctx->surface_property_changed) == IVI_FAILED);
1008 runner_assert(lyt->surface_add_listener(
1009 ivisurf, NULL) == IVI_FAILED);
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001010}