blob: 6796b33e33ba424cc7603794f22c4f15549d74c5 [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;
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +000089 struct wl_listener surface_removed;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090090};
91
92static struct test_context static_context;
93
94static void
95destroy_runner(struct wl_resource *resource)
96{
97 assert(static_context.runner_resource == NULL ||
98 static_context.runner_resource == resource);
99
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000100 static_context.layout_interface = NULL;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900101 static_context.runner_resource = NULL;
102}
103
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200104static void
105runner_destroy_handler(struct wl_client *client, struct wl_resource *resource)
106{
107 wl_resource_destroy(resource);
108}
109
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200110static void
111runner_run_handler(struct wl_client *client, struct wl_resource *resource,
112 const char *test_name)
113{
114 struct test_launcher *launcher;
115 const struct runner_test *t;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900116
117 assert(static_context.runner_resource == NULL ||
118 static_context.runner_resource == resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200119
120 launcher = wl_resource_get_user_data(resource);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000121 static_context.layout_interface = launcher->layout_interface;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900122 static_context.runner_resource = resource;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200123
124 t = find_runner_test(test_name);
125 if (!t) {
126 weston_log("Error: runner test \"%s\" not found.\n",
127 test_name);
128 wl_resource_post_error(resource,
129 WESTON_TEST_RUNNER_ERROR_UNKNOWN_TEST,
130 "weston_test_runner: unknown: '%s'",
131 test_name);
132 return;
133 }
134
135 weston_log("weston_test_runner.run(\"%s\")\n", test_name);
136
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900137 t->run(&static_context);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200138
139 weston_test_runner_send_finished(resource);
140}
141
142static const struct weston_test_runner_interface runner_implementation = {
143 runner_destroy_handler,
144 runner_run_handler
145};
146
147static void
148bind_runner(struct wl_client *client, void *data,
149 uint32_t version, uint32_t id)
150{
151 struct test_launcher *launcher = data;
152 struct wl_resource *resource;
153
154 resource = wl_resource_create(client, &weston_test_runner_interface,
155 1, id);
156 if (!resource) {
157 wl_client_post_no_memory(client);
158 return;
159 }
160
161 wl_resource_set_implementation(resource, &runner_implementation,
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900162 launcher, destroy_runner);
163
164 if (static_context.runner_resource != NULL) {
165 weston_log("test FATAL: "
166 "attempting to run several tests in parallel.\n");
167 wl_resource_post_error(resource,
168 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
169 "attempt to run parallel tests");
170 }
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200171}
172
173static void
174test_client_sigchld(struct weston_process *process, int status)
175{
176 struct test_launcher *launcher =
177 container_of(process, struct test_launcher, process);
178 struct weston_compositor *c = launcher->compositor;
179
180 /* Chain up from weston-test-runner's exit code so that automake
181 * knows the exit status and can report e.g. skipped tests. */
182 if (WIFEXITED(status))
183 weston_compositor_exit_with_code(c, WEXITSTATUS(status));
184 else
185 weston_compositor_exit_with_code(c, EXIT_FAILURE);
186}
187
188static void
189idle_launch_client(void *data)
190{
191 struct test_launcher *launcher = data;
192 pid_t pid;
193 sigset_t allsigs;
194
195 pid = fork();
196 if (pid == -1) {
197 weston_log("fatal: failed to fork '%s': %m\n", launcher->exe);
198 weston_compositor_exit_with_code(launcher->compositor,
199 EXIT_FAILURE);
200 return;
201 }
202
203 if (pid == 0) {
204 sigfillset(&allsigs);
205 sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
206 execl(launcher->exe, launcher->exe, NULL);
207 weston_log("compositor: executing '%s' failed: %m\n",
208 launcher->exe);
209 _exit(EXIT_FAILURE);
210 }
211
212 launcher->process.pid = pid;
213 launcher->process.cleanup = test_client_sigchld;
214 weston_watch_process(&launcher->process);
215}
216
217int
218controller_module_init(struct weston_compositor *compositor,
219 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000220 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200221 size_t iface_version);
222
223WL_EXPORT int
224controller_module_init(struct weston_compositor *compositor,
225 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000226 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200227 size_t iface_version)
228{
229 struct wl_event_loop *loop;
230 struct test_launcher *launcher;
231 const char *path;
232
233 /* strict check, since this is an internal test module */
234 if (iface_version != sizeof(*iface)) {
235 weston_log("fatal: controller interface mismatch\n");
236 return -1;
237 }
238
239 path = getenv("WESTON_BUILD_DIR");
240 if (!path) {
241 weston_log("test setup failure: WESTON_BUILD_DIR not set\n");
242 return -1;
243 }
244
245 launcher = zalloc(sizeof *launcher);
246 if (!launcher)
247 return -1;
248
249 launcher->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000250 launcher->layout_interface = iface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200251 snprintf(launcher->exe, sizeof launcher->exe,
252 "%s/ivi-layout.ivi", path);
253
254 if (wl_global_create(compositor->wl_display,
255 &weston_test_runner_interface, 1,
256 launcher, bind_runner) == NULL)
257 return -1;
258
259 loop = wl_display_get_event_loop(compositor->wl_display);
260 wl_event_loop_add_idle(loop, idle_launch_client, launcher);
261
262 return 0;
263}
264
265static void
266runner_assert_fail(const char *cond, const char *file, int line,
267 const char *func, struct test_context *ctx)
268{
269 weston_log("Assert failure in %s:%d, %s: '%s'\n",
270 file, line, func, cond);
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900271
272 assert(ctx->runner_resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200273 wl_resource_post_error(ctx->runner_resource,
274 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
275 "Assert failure in %s:%d, %s: '%s'\n",
276 file, line, func, cond);
277}
278
279#define runner_assert(cond) ({ \
280 bool b_ = (cond); \
281 if (!b_) \
282 runner_assert_fail(#cond, __FILE__, __LINE__, \
283 __func__, ctx); \
284 b_; \
285})
286
287#define runner_assert_or_return(cond) do { \
288 bool b_ = (cond); \
289 if (!b_) { \
290 runner_assert_fail(#cond, __FILE__, __LINE__, \
291 __func__, ctx); \
292 return; \
293 } \
294} while (0)
295
296
297/*************************** tests **********************************/
298
299/*
300 * This is a controller module: a plugin to ivi-shell.so, i.e. a sub-plugin.
301 * This module is specially written to execute tests that target the
302 * ivi_layout API.
303 *
304 * This module is listed in TESTS in Makefile.am. weston-tests-env handles
305 * this module specially by loading it in ivi-shell.
306 *
307 * Once Weston init completes, this module launches one test program:
308 * ivi-layout.ivi (ivi_layout-test.c). That program uses the weston-test-runner
309 * framework to fork and exec each TEST() in ivi_layout-test.c with a fresh
310 * connection to the single compositor instance.
311 *
312 * Each TEST() in ivi_layout-test.c will bind to weston_test_runner global
313 * interface. A TEST() will set up the client state, and issue
314 * weston_test_runner.run request to execute the compositor-side of the test.
315 *
316 * The compositor-side parts of the tests are in this file. They are specified
317 * by RUNNER_TEST() macro, where the name argument matches the name string
318 * passed to weston_test_runner.run.
319 *
320 * A RUNNER_TEST() function simply returns when it succeeds. If it fails,
321 * a fatal protocol error is sent to the client from runner_assert() or
322 * runner_assert_or_return(). This module catches the test program exit
323 * code and passes it out of Weston to the test harness.
324 *
325 * A single TEST() in ivi_layout-test.c may use multiple RUNNER_TEST()s to
326 * achieve multiple test points over a client action sequence.
327 */
328
329RUNNER_TEST(surface_create_p1)
330{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000331 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200332 struct ivi_layout_surface *ivisurf[2];
333 uint32_t ivi_id;
334
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000335 ivisurf[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900336 runner_assert(ivisurf[0]);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200337
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000338 ivisurf[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(1));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900339 runner_assert(ivisurf[1]);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200340
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000341 ivi_id = lyt->get_id_of_surface(ivisurf[0]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900342 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200343
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000344 ivi_id = lyt->get_id_of_surface(ivisurf[1]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900345 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(1));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200346}
347
348RUNNER_TEST(surface_create_p2)
349{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000350 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200351 struct ivi_layout_surface *ivisurf;
352
353 /* the ivi_surface was destroyed by the client */
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000354 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900355 runner_assert(ivisurf == NULL);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200356}
357
358RUNNER_TEST(surface_visibility)
359{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000360 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200361 struct ivi_layout_surface *ivisurf;
362 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200363 const struct ivi_layout_surface_properties *prop;
364
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000365 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900366 runner_assert(ivisurf);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200367
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000368 ret = lyt->surface_set_visibility(ivisurf, true);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900369 runner_assert(ret == IVI_SUCCEEDED);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200370
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000371 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200372
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000373 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900374 runner_assert(prop->visibility == true);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200375}
376
377RUNNER_TEST(surface_opacity)
378{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000379 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200380 struct ivi_layout_surface *ivisurf;
381 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200382 const struct ivi_layout_surface_properties *prop;
383
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000384 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900385 runner_assert(ivisurf);
386
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000387 prop = lyt->get_properties_of_surface(ivisurf);
388 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200389
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000390 ret = lyt->surface_set_opacity(ivisurf, wl_fixed_from_double(0.5));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900391 runner_assert(ret == IVI_SUCCEEDED);
392
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000393 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200394
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000395 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200396
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900397 runner_assert(prop->opacity == wl_fixed_from_double(0.5));
398}
399
400RUNNER_TEST(surface_orientation)
401{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000402 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900403 struct ivi_layout_surface *ivisurf;
404 const struct ivi_layout_surface_properties *prop;
405
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000406 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900407 runner_assert(ivisurf != NULL);
408
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000409 prop = lyt->get_properties_of_surface(ivisurf);
410 runner_assert_or_return(prop);
411 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900412
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000413 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900414 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
415
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000416 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900417
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000418 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900419
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900420 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
421}
422
423RUNNER_TEST(surface_dimension)
424{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000425 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900426 struct ivi_layout_surface *ivisurf;
427 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900428
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000429 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900430 runner_assert(ivisurf != NULL);
431
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000432 prop = lyt->get_properties_of_surface(ivisurf);
433 runner_assert_or_return(prop);
434 runner_assert(prop->dest_width == 1);
435 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900436
437 runner_assert(IVI_SUCCEEDED ==
Ucan, Emre \(ADITG/SW1\)45d39422016-03-04 12:50:50 +0000438 lyt->surface_set_destination_rectangle(ivisurf, prop->dest_x,
439 prop->dest_y, 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\)161da402016-03-04 12:50:43 +0000466 runner_assert(lyt->surface_set_destination_rectangle(
467 ivisurf, 20, 30,
468 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900469
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000470 runner_assert(prop->dest_x == 0);
471 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900472
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000473 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900474
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000475 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900476 runner_assert_or_return(prop);
477 runner_assert(prop->dest_x == 20);
478 runner_assert(prop->dest_y == 30);
479}
480
481RUNNER_TEST(surface_destination_rectangle)
482{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000483 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900484 struct ivi_layout_surface *ivisurf;
485 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900486
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000487 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900488 runner_assert(ivisurf != NULL);
489
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900491 runner_assert_or_return(prop);
492 runner_assert(prop->dest_width == 1);
493 runner_assert(prop->dest_height == 1);
494 runner_assert(prop->dest_x == 0);
495 runner_assert(prop->dest_y == 0);
496
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000497 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900498 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
499
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900501 runner_assert_or_return(prop);
502 runner_assert(prop->dest_width == 1);
503 runner_assert(prop->dest_height == 1);
504 runner_assert(prop->dest_x == 0);
505 runner_assert(prop->dest_y == 0);
506
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000507 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900508
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000509 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900510 runner_assert_or_return(prop);
511 runner_assert(prop->dest_width == 200);
512 runner_assert(prop->dest_height == 300);
513 runner_assert(prop->dest_x == 20);
514 runner_assert(prop->dest_y == 30);
515}
516
517RUNNER_TEST(surface_source_rectangle)
518{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000519 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900520 struct ivi_layout_surface *ivisurf;
521 const struct ivi_layout_surface_properties *prop;
522
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000523 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900524 runner_assert(ivisurf != NULL);
525
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000526 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900527 runner_assert_or_return(prop);
528 runner_assert(prop->source_width == 0);
529 runner_assert(prop->source_height == 0);
530 runner_assert(prop->source_x == 0);
531 runner_assert(prop->source_y == 0);
532
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000533 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900534 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
535
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000536 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900537 runner_assert_or_return(prop);
538 runner_assert(prop->source_width == 0);
539 runner_assert(prop->source_height == 0);
540 runner_assert(prop->source_x == 0);
541 runner_assert(prop->source_y == 0);
542
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000543 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900544
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000545 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900546 runner_assert_or_return(prop);
547 runner_assert(prop->source_width == 200);
548 runner_assert(prop->source_height == 300);
549 runner_assert(prop->source_x == 20);
550 runner_assert(prop->source_y == 30);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200551}
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900552
553RUNNER_TEST(surface_bad_opacity)
554{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000555 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900556 struct ivi_layout_surface *ivisurf;
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000557 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900558
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000559 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900560 runner_assert(ivisurf != NULL);
561
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000562 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900563 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
564
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000565 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900566 ivisurf, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
567
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000568 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900569 ivisurf, wl_fixed_from_double(-1)) == IVI_FAILED);
570
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000571 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900572
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000573 prop = lyt->get_properties_of_surface(ivisurf);
574 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900575
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000576 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900577 ivisurf, wl_fixed_from_double(1.1)) == IVI_FAILED);
578
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000579 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900580
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000581 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900582
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000583 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900584 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
585
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000586 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900587}
588
589RUNNER_TEST(ivi_layout_commit_changes)
590{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000591 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900592
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000593 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900594}
595
596RUNNER_TEST(commit_changes_after_visibility_set_surface_destroy)
597{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000598 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900599 struct ivi_layout_surface *ivisurf;
600
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000601 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900602 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000603 runner_assert(lyt->surface_set_visibility(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900604 ivisurf, true) == IVI_SUCCEEDED);
605}
606
607RUNNER_TEST(commit_changes_after_opacity_set_surface_destroy)
608{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000609 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900610 struct ivi_layout_surface *ivisurf;
611
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000612 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900613 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000614 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900615 ivisurf, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
616}
617
618RUNNER_TEST(commit_changes_after_orientation_set_surface_destroy)
619{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000620 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900621 struct ivi_layout_surface *ivisurf;
622
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000623 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900624 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000625 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900626 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
627}
628
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900629RUNNER_TEST(commit_changes_after_source_rectangle_set_surface_destroy)
630{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000631 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900632 struct ivi_layout_surface *ivisurf;
633
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000634 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900635 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000636 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900637 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
638}
639
640RUNNER_TEST(commit_changes_after_destination_rectangle_set_surface_destroy)
641{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000642 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900643 struct ivi_layout_surface *ivisurf;
644
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000645 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900646 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000647 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900648 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
649}
650
651RUNNER_TEST(get_surface_after_destroy_surface)
652{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000653 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900654 struct ivi_layout_surface *ivisurf;
655
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000656 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900657 runner_assert(ivisurf == NULL);
658}
659
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900660RUNNER_TEST(layer_render_order)
661{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000662 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900663 struct ivi_layout_layer *ivilayer;
664 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
665 struct ivi_layout_surface **array;
666 int32_t length = 0;
667 uint32_t i;
668
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000669 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900670
671 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000672 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900673
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000674 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900675 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
676
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000677 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900678
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000679 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900680 ivilayer, &length, &array) == IVI_SUCCEEDED);
681 runner_assert(IVI_TEST_SURFACE_COUNT == length);
682 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
683 runner_assert(array[i] == ivisurfs[i]);
684
685 if (length > 0)
686 free(array);
687
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000688 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900689 ivilayer, NULL, 0) == IVI_SUCCEEDED);
690
691 array = NULL;
692
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000693 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900694
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000695 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900696 ivilayer, &length, &array) == IVI_SUCCEEDED);
697 runner_assert(length == 0 && array == NULL);
698
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000699 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900700}
701
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900702RUNNER_TEST(test_layer_render_order_destroy_one_surface_p1)
703{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000704 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900705 struct ivi_layout_layer *ivilayer;
706 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
707 struct ivi_layout_surface **array;
708 int32_t length = 0;
709 int32_t i;
710
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000711 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900712
713 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000714 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900715
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000716 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900717 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
718
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000719 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900720
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000721 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900722 ivilayer, &length, &array) == IVI_SUCCEEDED);
723 runner_assert(IVI_TEST_SURFACE_COUNT == length);
724 for (i = 0; i < length; i++)
725 runner_assert(array[i] == ivisurfs[i]);
726
727 if (length > 0)
728 free(array);
729}
730
731RUNNER_TEST(test_layer_render_order_destroy_one_surface_p2)
732{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000733 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900734 struct ivi_layout_layer *ivilayer;
735 struct ivi_layout_surface *ivisurfs[2] = {};
736 struct ivi_layout_surface **array;
737 int32_t length = 0;
738 int32_t i;
739
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000740 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
741 ivisurfs[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
742 ivisurfs[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(2));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900743
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000744 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900745 ivilayer, &length, &array) == IVI_SUCCEEDED);
746 runner_assert(2 == length);
747 for (i = 0; i < length; i++)
748 runner_assert(array[i] == ivisurfs[i]);
749
750 if (length > 0)
751 free(array);
752
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000753 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900754}
755
756RUNNER_TEST(layer_bad_render_order)
757{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000758 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900759 struct ivi_layout_layer *ivilayer;
760 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
761 struct ivi_layout_surface **array = NULL;
762 int32_t length = 0;
763 uint32_t i;
764
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000765 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900766
767 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000768 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900769
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000770 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900771 NULL, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_FAILED);
772
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000773 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900774
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000775 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900776 NULL, &length, &array) == IVI_FAILED);
777 runner_assert(length == 0 && array == NULL);
778
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000779 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900780 ivilayer, NULL, &array) == IVI_FAILED);
781 runner_assert(array == NULL);
782
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000783 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900784 ivilayer, &length, NULL) == IVI_FAILED);
785 runner_assert(length == 0);
786
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000787 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900788}
789
790RUNNER_TEST(commit_changes_after_render_order_set_surface_destroy)
791{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000792 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900793 struct ivi_layout_layer *ivilayer;
794 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
795 int i;
796
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000797 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900798
799 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000800 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900801
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000802 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900803 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
804}
805
806RUNNER_TEST(cleanup_layer)
807{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000808 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900809 struct ivi_layout_layer *ivilayer;
810
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000811 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
812 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900813}
814
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900815static void
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000816test_surface_properties_changed_notification_callback(struct wl_listener *listener, void *data)
817
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900818{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000819 struct test_context *ctx =
820 container_of(listener, struct test_context,
821 surface_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000822 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000823 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900824
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000825 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900826
827 ctx->user_flags = 1;
828}
829
830RUNNER_TEST(surface_properties_changed_notification)
831{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000832 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900833 const uint32_t id_surface = IVI_TEST_SURFACE_ID(0);
834 struct ivi_layout_surface *ivisurf;
835
836 ctx->user_flags = 0;
837
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000838 ivisurf = lyt->get_surface_from_id(id_surface);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900839 runner_assert(ivisurf != NULL);
840
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000841 ctx->surface_property_changed.notify = test_surface_properties_changed_notification_callback;
842
843 runner_assert(lyt->surface_add_listener(
844 ivisurf, &ctx->surface_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900845
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000846 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900847
848 runner_assert(ctx->user_flags == 0);
849
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000850 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900851 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
852
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000853 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900854
855 runner_assert(ctx->user_flags == 1);
856
857 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000858 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900859 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
860
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000861 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900862
863 runner_assert(ctx->user_flags == 0);
864
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000865 // remove surface property changed listener.
866 wl_list_remove(&ctx->surface_property_changed.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900867 ctx->user_flags = 0;
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, 40, 50, 400, 500) == 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 == 0);
874}
875
876static void
877test_surface_configure_notification_callback(struct ivi_layout_surface *ivisurf,
878 void *userdata)
879{
880 struct test_context *ctx = userdata;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000881 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900882
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000883 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900884
885 ctx->user_flags = 1;
886}
887
888RUNNER_TEST(surface_configure_notification_p1)
889{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000890 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900891
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000892 runner_assert(IVI_SUCCEEDED == lyt->add_notification_configure_surface(test_surface_configure_notification_callback, ctx));
893 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900894
895 ctx->user_flags = 0;
896}
897
898RUNNER_TEST(surface_configure_notification_p2)
899{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000900 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900901
902 runner_assert(ctx->user_flags == 1);
903
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000904 lyt->remove_notification_configure_surface(test_surface_configure_notification_callback, ctx);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900905 ctx->user_flags = 0;
906}
907
908RUNNER_TEST(surface_configure_notification_p3)
909{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000910 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900911
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000912 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900913 runner_assert(ctx->user_flags == 0);
914}
915
916static void
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000917test_surface_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900918{
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000919 struct test_context *ctx =
920 container_of(listener, struct test_context,
921 surface_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000922 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000923 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900924
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000925 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900926
927 ctx->user_flags = 1;
928}
929
930RUNNER_TEST(surface_create_notification_p1)
931{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000932 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900933
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000934 ctx->surface_created.notify = test_surface_create_notification_callback;
935 runner_assert(lyt->add_listener_create_surface(
936 &ctx->surface_created) == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900937
938 ctx->user_flags = 0;
939}
940
941RUNNER_TEST(surface_create_notification_p2)
942{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900943 runner_assert(ctx->user_flags == 1);
944
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000945 // remove surface created listener.
946 wl_list_remove(&ctx->surface_created.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900947 ctx->user_flags = 0;
948}
949
950RUNNER_TEST(surface_create_notification_p3)
951{
952 runner_assert(ctx->user_flags == 0);
953}
954
955static void
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000956test_surface_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900957{
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000958 struct test_context *ctx =
959 container_of(listener, struct test_context,
960 surface_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000961 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000962 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900963
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000964 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900965
966 ctx->user_flags = 1;
967}
968
969RUNNER_TEST(surface_remove_notification_p1)
970{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000971 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900972
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000973 ctx->surface_removed.notify = test_surface_remove_notification_callback;
974 runner_assert(lyt->add_listener_remove_surface(&ctx->surface_removed)
975 == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900976
977 ctx->user_flags = 0;
978}
979
980RUNNER_TEST(surface_remove_notification_p2)
981{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900982 runner_assert(ctx->user_flags == 1);
983
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000984 // remove surface removed listener.
985 wl_list_remove(&ctx->surface_removed.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900986 ctx->user_flags = 0;
987}
988
989RUNNER_TEST(surface_remove_notification_p3)
990{
991 runner_assert(ctx->user_flags == 0);
992}
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900993
994static void
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000995test_surface_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900996{
997}
998
999RUNNER_TEST(surface_bad_properties_changed_notification)
1000{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001001 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001002 struct ivi_layout_surface *ivisurf;
1003
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001004 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001005 runner_assert(ivisurf != NULL);
1006
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001007 ctx->surface_property_changed.notify = test_surface_bad_properties_changed_notification_callback;
1008
1009 runner_assert(lyt->surface_add_listener(
1010 NULL, &ctx->surface_property_changed) == IVI_FAILED);
1011 runner_assert(lyt->surface_add_listener(
1012 ivisurf, NULL) == IVI_FAILED);
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001013}