blob: 609c71ffc8e76d9da7c750607573741f71d66ec9 [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
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030030#include <stdint.h>
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020031#include <unistd.h>
32#include <signal.h>
33#include <string.h>
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090034#include <assert.h>
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020035
Pekka Paalanenb5e3ea22016-06-03 17:12:10 +030036#include "compositor.h"
Pekka Paalanen58f98c92016-06-03 16:45:21 +030037#include "compositor/weston.h"
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020038#include "weston-test-server-protocol.h"
39#include "ivi-test.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070040#include "ivi-shell/ivi-layout-export.h"
Jon Cruz867d50e2015-06-15 15:37:10 -070041#include "shared/helpers.h"
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020042
43struct test_context;
44
45struct runner_test {
46 const char *name;
47 void (*run)(struct test_context *);
48} __attribute__ ((aligned (32)));
49
50#define RUNNER_TEST(name) \
51 static void runner_func_##name(struct test_context *); \
52 \
53 const struct runner_test runner_test_##name \
54 __attribute__ ((section ("test_section"))) = \
55 { \
56 #name, runner_func_##name \
57 }; \
58 \
59 static void runner_func_##name(struct test_context *ctx)
60
61extern const struct runner_test __start_test_section;
62extern const struct runner_test __stop_test_section;
63
64static const struct runner_test *
65find_runner_test(const char *name)
66{
67 const struct runner_test *t;
68
69 for (t = &__start_test_section; t < &__stop_test_section; t++) {
70 if (strcmp(t->name, name) == 0)
71 return t;
72 }
73
74 return NULL;
75}
76
77struct test_launcher {
78 struct weston_compositor *compositor;
79 char exe[2048];
80 struct weston_process process;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000081 const struct ivi_layout_interface *layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +020082};
83
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090084struct test_context {
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +000085 const struct ivi_layout_interface *layout_interface;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090086 struct wl_resource *runner_resource;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +090087 uint32_t user_flags;
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +000088
89 struct wl_listener surface_property_changed;
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +000090 struct wl_listener surface_created;
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +000091 struct wl_listener surface_removed;
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +000092 struct wl_listener surface_configured;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090093};
94
95static struct test_context static_context;
96
97static void
98destroy_runner(struct wl_resource *resource)
99{
100 assert(static_context.runner_resource == NULL ||
101 static_context.runner_resource == resource);
102
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000103 static_context.layout_interface = NULL;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900104 static_context.runner_resource = NULL;
105}
106
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200107static void
108runner_destroy_handler(struct wl_client *client, struct wl_resource *resource)
109{
110 wl_resource_destroy(resource);
111}
112
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200113static void
114runner_run_handler(struct wl_client *client, struct wl_resource *resource,
115 const char *test_name)
116{
117 struct test_launcher *launcher;
118 const struct runner_test *t;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900119
120 assert(static_context.runner_resource == NULL ||
121 static_context.runner_resource == resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200122
123 launcher = wl_resource_get_user_data(resource);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000124 static_context.layout_interface = launcher->layout_interface;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900125 static_context.runner_resource = resource;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200126
127 t = find_runner_test(test_name);
128 if (!t) {
129 weston_log("Error: runner test \"%s\" not found.\n",
130 test_name);
131 wl_resource_post_error(resource,
132 WESTON_TEST_RUNNER_ERROR_UNKNOWN_TEST,
133 "weston_test_runner: unknown: '%s'",
134 test_name);
135 return;
136 }
137
138 weston_log("weston_test_runner.run(\"%s\")\n", test_name);
139
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900140 t->run(&static_context);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200141
142 weston_test_runner_send_finished(resource);
143}
144
145static const struct weston_test_runner_interface runner_implementation = {
146 runner_destroy_handler,
147 runner_run_handler
148};
149
150static void
151bind_runner(struct wl_client *client, void *data,
152 uint32_t version, uint32_t id)
153{
154 struct test_launcher *launcher = data;
155 struct wl_resource *resource;
156
157 resource = wl_resource_create(client, &weston_test_runner_interface,
158 1, id);
159 if (!resource) {
160 wl_client_post_no_memory(client);
161 return;
162 }
163
164 wl_resource_set_implementation(resource, &runner_implementation,
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900165 launcher, destroy_runner);
166
167 if (static_context.runner_resource != NULL) {
168 weston_log("test FATAL: "
169 "attempting to run several tests in parallel.\n");
170 wl_resource_post_error(resource,
171 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
172 "attempt to run parallel tests");
173 }
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200174}
175
176static void
177test_client_sigchld(struct weston_process *process, int status)
178{
179 struct test_launcher *launcher =
180 container_of(process, struct test_launcher, process);
181 struct weston_compositor *c = launcher->compositor;
182
183 /* Chain up from weston-test-runner's exit code so that automake
184 * knows the exit status and can report e.g. skipped tests. */
185 if (WIFEXITED(status))
186 weston_compositor_exit_with_code(c, WEXITSTATUS(status));
187 else
188 weston_compositor_exit_with_code(c, EXIT_FAILURE);
189}
190
191static void
192idle_launch_client(void *data)
193{
194 struct test_launcher *launcher = data;
195 pid_t pid;
196 sigset_t allsigs;
197
198 pid = fork();
199 if (pid == -1) {
200 weston_log("fatal: failed to fork '%s': %m\n", launcher->exe);
201 weston_compositor_exit_with_code(launcher->compositor,
202 EXIT_FAILURE);
203 return;
204 }
205
206 if (pid == 0) {
207 sigfillset(&allsigs);
208 sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
209 execl(launcher->exe, launcher->exe, NULL);
210 weston_log("compositor: executing '%s' failed: %m\n",
211 launcher->exe);
212 _exit(EXIT_FAILURE);
213 }
214
215 launcher->process.pid = pid;
216 launcher->process.cleanup = test_client_sigchld;
217 weston_watch_process(&launcher->process);
218}
219
220int
221controller_module_init(struct weston_compositor *compositor,
222 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000223 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200224 size_t iface_version);
225
226WL_EXPORT int
227controller_module_init(struct weston_compositor *compositor,
228 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000229 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200230 size_t iface_version)
231{
232 struct wl_event_loop *loop;
233 struct test_launcher *launcher;
234 const char *path;
235
236 /* strict check, since this is an internal test module */
237 if (iface_version != sizeof(*iface)) {
238 weston_log("fatal: controller interface mismatch\n");
239 return -1;
240 }
241
242 path = getenv("WESTON_BUILD_DIR");
243 if (!path) {
244 weston_log("test setup failure: WESTON_BUILD_DIR not set\n");
245 return -1;
246 }
247
248 launcher = zalloc(sizeof *launcher);
249 if (!launcher)
250 return -1;
251
252 launcher->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000253 launcher->layout_interface = iface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200254 snprintf(launcher->exe, sizeof launcher->exe,
255 "%s/ivi-layout.ivi", path);
256
257 if (wl_global_create(compositor->wl_display,
258 &weston_test_runner_interface, 1,
259 launcher, bind_runner) == NULL)
260 return -1;
261
262 loop = wl_display_get_event_loop(compositor->wl_display);
263 wl_event_loop_add_idle(loop, idle_launch_client, launcher);
264
265 return 0;
266}
267
268static void
269runner_assert_fail(const char *cond, const char *file, int line,
270 const char *func, struct test_context *ctx)
271{
272 weston_log("Assert failure in %s:%d, %s: '%s'\n",
273 file, line, func, cond);
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900274
275 assert(ctx->runner_resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200276 wl_resource_post_error(ctx->runner_resource,
277 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
278 "Assert failure in %s:%d, %s: '%s'\n",
279 file, line, func, cond);
280}
281
282#define runner_assert(cond) ({ \
283 bool b_ = (cond); \
284 if (!b_) \
285 runner_assert_fail(#cond, __FILE__, __LINE__, \
286 __func__, ctx); \
287 b_; \
288})
289
290#define runner_assert_or_return(cond) do { \
291 bool b_ = (cond); \
292 if (!b_) { \
293 runner_assert_fail(#cond, __FILE__, __LINE__, \
294 __func__, ctx); \
295 return; \
296 } \
297} while (0)
298
299
300/*************************** tests **********************************/
301
302/*
303 * This is a controller module: a plugin to ivi-shell.so, i.e. a sub-plugin.
304 * This module is specially written to execute tests that target the
305 * ivi_layout API.
306 *
307 * This module is listed in TESTS in Makefile.am. weston-tests-env handles
308 * this module specially by loading it in ivi-shell.
309 *
310 * Once Weston init completes, this module launches one test program:
311 * ivi-layout.ivi (ivi_layout-test.c). That program uses the weston-test-runner
312 * framework to fork and exec each TEST() in ivi_layout-test.c with a fresh
313 * connection to the single compositor instance.
314 *
315 * Each TEST() in ivi_layout-test.c will bind to weston_test_runner global
316 * interface. A TEST() will set up the client state, and issue
317 * weston_test_runner.run request to execute the compositor-side of the test.
318 *
319 * The compositor-side parts of the tests are in this file. They are specified
320 * by RUNNER_TEST() macro, where the name argument matches the name string
321 * passed to weston_test_runner.run.
322 *
323 * A RUNNER_TEST() function simply returns when it succeeds. If it fails,
324 * a fatal protocol error is sent to the client from runner_assert() or
325 * runner_assert_or_return(). This module catches the test program exit
326 * code and passes it out of Weston to the test harness.
327 *
328 * A single TEST() in ivi_layout-test.c may use multiple RUNNER_TEST()s to
329 * achieve multiple test points over a client action sequence.
330 */
331
332RUNNER_TEST(surface_create_p1)
333{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000334 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200335 struct ivi_layout_surface *ivisurf[2];
336 uint32_t ivi_id;
337
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000338 ivisurf[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900339 runner_assert(ivisurf[0]);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200340
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000341 ivisurf[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(1));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900342 runner_assert(ivisurf[1]);
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[0]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900345 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200346
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000347 ivi_id = lyt->get_id_of_surface(ivisurf[1]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900348 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(1));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200349}
350
351RUNNER_TEST(surface_create_p2)
352{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000353 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200354 struct ivi_layout_surface *ivisurf;
355
356 /* the ivi_surface was destroyed by the client */
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000357 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900358 runner_assert(ivisurf == NULL);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200359}
360
361RUNNER_TEST(surface_visibility)
362{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000363 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200364 struct ivi_layout_surface *ivisurf;
365 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200366 const struct ivi_layout_surface_properties *prop;
367
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000368 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900369 runner_assert(ivisurf);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200370
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000371 ret = lyt->surface_set_visibility(ivisurf, true);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900372 runner_assert(ret == IVI_SUCCEEDED);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200373
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000374 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200375
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000376 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900377 runner_assert(prop->visibility == true);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200378}
379
380RUNNER_TEST(surface_opacity)
381{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000382 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200383 struct ivi_layout_surface *ivisurf;
384 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200385 const struct ivi_layout_surface_properties *prop;
386
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000387 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900388 runner_assert(ivisurf);
389
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000390 prop = lyt->get_properties_of_surface(ivisurf);
391 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200392
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000393 ret = lyt->surface_set_opacity(ivisurf, wl_fixed_from_double(0.5));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900394 runner_assert(ret == IVI_SUCCEEDED);
395
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000396 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200397
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000398 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200399
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900400 runner_assert(prop->opacity == wl_fixed_from_double(0.5));
401}
402
403RUNNER_TEST(surface_orientation)
404{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000405 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900406 struct ivi_layout_surface *ivisurf;
407 const struct ivi_layout_surface_properties *prop;
408
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000409 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900410 runner_assert(ivisurf != NULL);
411
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000412 prop = lyt->get_properties_of_surface(ivisurf);
413 runner_assert_or_return(prop);
414 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900415
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000416 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900417 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
418
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000419 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900420
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000421 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900422
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900423 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
424}
425
426RUNNER_TEST(surface_dimension)
427{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000428 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900429 struct ivi_layout_surface *ivisurf;
430 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900431
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000432 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900433 runner_assert(ivisurf != NULL);
434
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000435 prop = lyt->get_properties_of_surface(ivisurf);
436 runner_assert_or_return(prop);
437 runner_assert(prop->dest_width == 1);
438 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900439
440 runner_assert(IVI_SUCCEEDED ==
Ucan, Emre \(ADITG/SW1\)45d39422016-03-04 12:50:50 +0000441 lyt->surface_set_destination_rectangle(ivisurf, prop->dest_x,
442 prop->dest_y, 200, 300));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900443
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000444 runner_assert(prop->dest_width == 1);
445 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900446
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000447 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900448
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000449 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900450 runner_assert_or_return(prop);
451 runner_assert(prop->dest_width == 200);
452 runner_assert(prop->dest_height == 300);
453}
454
455RUNNER_TEST(surface_position)
456{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000457 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900458 struct ivi_layout_surface *ivisurf;
459 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900460
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000461 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900462 runner_assert(ivisurf != NULL);
463
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000464 prop = lyt->get_properties_of_surface(ivisurf);
465 runner_assert_or_return(prop);
466 runner_assert(prop->dest_x == 0);
467 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900468
Ucan, Emre \(ADITG/SW1\)161da402016-03-04 12:50:43 +0000469 runner_assert(lyt->surface_set_destination_rectangle(
470 ivisurf, 20, 30,
471 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900472
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000473 runner_assert(prop->dest_x == 0);
474 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900475
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000476 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900477
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000478 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900479 runner_assert_or_return(prop);
480 runner_assert(prop->dest_x == 20);
481 runner_assert(prop->dest_y == 30);
482}
483
484RUNNER_TEST(surface_destination_rectangle)
485{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000486 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900487 struct ivi_layout_surface *ivisurf;
488 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900489
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000490 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900491 runner_assert(ivisurf != NULL);
492
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000493 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900494 runner_assert_or_return(prop);
495 runner_assert(prop->dest_width == 1);
496 runner_assert(prop->dest_height == 1);
497 runner_assert(prop->dest_x == 0);
498 runner_assert(prop->dest_y == 0);
499
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000500 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900501 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
502
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000503 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900504 runner_assert_or_return(prop);
505 runner_assert(prop->dest_width == 1);
506 runner_assert(prop->dest_height == 1);
507 runner_assert(prop->dest_x == 0);
508 runner_assert(prop->dest_y == 0);
509
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000510 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900511
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000512 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900513 runner_assert_or_return(prop);
514 runner_assert(prop->dest_width == 200);
515 runner_assert(prop->dest_height == 300);
516 runner_assert(prop->dest_x == 20);
517 runner_assert(prop->dest_y == 30);
518}
519
520RUNNER_TEST(surface_source_rectangle)
521{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000522 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900523 struct ivi_layout_surface *ivisurf;
524 const struct ivi_layout_surface_properties *prop;
525
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000526 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900527 runner_assert(ivisurf != NULL);
528
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000529 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900530 runner_assert_or_return(prop);
531 runner_assert(prop->source_width == 0);
532 runner_assert(prop->source_height == 0);
533 runner_assert(prop->source_x == 0);
534 runner_assert(prop->source_y == 0);
535
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000536 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900537 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
538
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000539 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900540 runner_assert_or_return(prop);
541 runner_assert(prop->source_width == 0);
542 runner_assert(prop->source_height == 0);
543 runner_assert(prop->source_x == 0);
544 runner_assert(prop->source_y == 0);
545
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900547
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000548 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900549 runner_assert_or_return(prop);
550 runner_assert(prop->source_width == 200);
551 runner_assert(prop->source_height == 300);
552 runner_assert(prop->source_x == 20);
553 runner_assert(prop->source_y == 30);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200554}
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900555
556RUNNER_TEST(surface_bad_opacity)
557{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000558 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900559 struct ivi_layout_surface *ivisurf;
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000560 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900561
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000562 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900563 runner_assert(ivisurf != NULL);
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 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
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(0.3)) == IVI_SUCCEEDED);
570
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000571 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900572 ivisurf, wl_fixed_from_double(-1)) == IVI_FAILED);
573
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000574 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900575
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000576 prop = lyt->get_properties_of_surface(ivisurf);
577 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900578
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000579 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900580 ivisurf, wl_fixed_from_double(1.1)) == IVI_FAILED);
581
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000582 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900583
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000584 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900585
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000586 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900587 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
588
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000589 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900590}
591
Ucan, Emre (ADITG/SW1)37d25bb2016-06-07 09:40:21 +0000592RUNNER_TEST(surface_on_many_layer)
593{
594 const struct ivi_layout_interface *lyt = ctx->layout_interface;
595 struct ivi_layout_surface *ivisurf;
596 struct ivi_layout_layer *ivilayers[IVI_TEST_LAYER_COUNT] = {};
597 struct ivi_layout_layer **array;
598 int32_t length = 0;
599 uint32_t i;
600
601 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
602 runner_assert(ivisurf != NULL);
603
604 for (i = 0; i < IVI_TEST_LAYER_COUNT; i++) {
605 ivilayers[i] = lyt->layer_create_with_dimension(
606 IVI_TEST_LAYER_ID(i), 200, 300);
607 runner_assert(lyt->layer_add_surface(
608 ivilayers[i], ivisurf) == IVI_SUCCEEDED);
609 }
610
611 lyt->commit_changes();
612
613 runner_assert(lyt->get_layers_under_surface(
614 ivisurf, &length, &array) == IVI_SUCCEEDED);
615 runner_assert(IVI_TEST_LAYER_COUNT == length);
616 for (i = 0; i < IVI_TEST_LAYER_COUNT; i++)
617 runner_assert(array[i] == ivilayers[i]);
618
619 if (length > 0)
620 free(array);
621
622 for (i = 0; i < IVI_TEST_LAYER_COUNT; i++)
623 lyt->layer_remove_surface(ivilayers[i], ivisurf);
624
625 array = NULL;
626
627 lyt->commit_changes();
628
629 runner_assert(lyt->get_layers_under_surface(
630 ivisurf, &length, &array) == IVI_SUCCEEDED);
631 runner_assert(length == 0 && array == NULL);
632
633 for (i = 0; i < IVI_TEST_LAYER_COUNT; i++)
634 lyt->layer_destroy(ivilayers[i]);
635}
636
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900637RUNNER_TEST(ivi_layout_commit_changes)
638{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000639 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900640
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000641 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900642}
643
644RUNNER_TEST(commit_changes_after_visibility_set_surface_destroy)
645{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900647 struct ivi_layout_surface *ivisurf;
648
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000649 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900650 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000651 runner_assert(lyt->surface_set_visibility(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900652 ivisurf, true) == IVI_SUCCEEDED);
653}
654
655RUNNER_TEST(commit_changes_after_opacity_set_surface_destroy)
656{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000657 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900658 struct ivi_layout_surface *ivisurf;
659
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000660 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900661 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000662 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900663 ivisurf, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
664}
665
666RUNNER_TEST(commit_changes_after_orientation_set_surface_destroy)
667{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000668 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900669 struct ivi_layout_surface *ivisurf;
670
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000671 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900672 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000673 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900674 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
675}
676
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900677RUNNER_TEST(commit_changes_after_source_rectangle_set_surface_destroy)
678{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000679 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900680 struct ivi_layout_surface *ivisurf;
681
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000682 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900683 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000684 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900685 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
686}
687
688RUNNER_TEST(commit_changes_after_destination_rectangle_set_surface_destroy)
689{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000690 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900691 struct ivi_layout_surface *ivisurf;
692
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000693 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900694 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000695 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900696 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
697}
698
699RUNNER_TEST(get_surface_after_destroy_surface)
700{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000701 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900702 struct ivi_layout_surface *ivisurf;
703
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000704 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900705 runner_assert(ivisurf == NULL);
706}
707
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900708RUNNER_TEST(layer_render_order)
709{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000710 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900711 struct ivi_layout_layer *ivilayer;
712 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
713 struct ivi_layout_surface **array;
714 int32_t length = 0;
715 uint32_t i;
716
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000717 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900718
719 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900721
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000722 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900723 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
724
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000725 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900726
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000727 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900728 ivilayer, &length, &array) == IVI_SUCCEEDED);
729 runner_assert(IVI_TEST_SURFACE_COUNT == length);
730 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
731 runner_assert(array[i] == ivisurfs[i]);
732
733 if (length > 0)
734 free(array);
735
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000736 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900737 ivilayer, NULL, 0) == IVI_SUCCEEDED);
738
739 array = NULL;
740
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000741 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900742
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000743 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900744 ivilayer, &length, &array) == IVI_SUCCEEDED);
745 runner_assert(length == 0 && array == NULL);
746
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000747 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900748}
749
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900750RUNNER_TEST(test_layer_render_order_destroy_one_surface_p1)
751{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000752 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900753 struct ivi_layout_layer *ivilayer;
754 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
755 struct ivi_layout_surface **array;
756 int32_t length = 0;
757 int32_t i;
758
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000759 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900760
761 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000762 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900763
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000764 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900765 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
766
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000767 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900768
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900770 ivilayer, &length, &array) == IVI_SUCCEEDED);
771 runner_assert(IVI_TEST_SURFACE_COUNT == length);
772 for (i = 0; i < length; i++)
773 runner_assert(array[i] == ivisurfs[i]);
774
775 if (length > 0)
776 free(array);
777}
778
779RUNNER_TEST(test_layer_render_order_destroy_one_surface_p2)
780{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000781 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900782 struct ivi_layout_layer *ivilayer;
783 struct ivi_layout_surface *ivisurfs[2] = {};
784 struct ivi_layout_surface **array;
785 int32_t length = 0;
786 int32_t i;
787
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000788 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
789 ivisurfs[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
790 ivisurfs[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(2));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900791
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000792 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900793 ivilayer, &length, &array) == IVI_SUCCEEDED);
794 runner_assert(2 == length);
795 for (i = 0; i < length; i++)
796 runner_assert(array[i] == ivisurfs[i]);
797
798 if (length > 0)
799 free(array);
800
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000801 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900802}
803
804RUNNER_TEST(layer_bad_render_order)
805{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000806 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900807 struct ivi_layout_layer *ivilayer;
808 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
809 struct ivi_layout_surface **array = NULL;
810 int32_t length = 0;
811 uint32_t i;
812
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000813 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900814
815 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000816 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900817
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000818 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900819 NULL, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_FAILED);
820
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000821 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900822
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000823 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900824 NULL, &length, &array) == IVI_FAILED);
825 runner_assert(length == 0 && array == NULL);
826
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000827 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900828 ivilayer, NULL, &array) == IVI_FAILED);
829 runner_assert(array == NULL);
830
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000831 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900832 ivilayer, &length, NULL) == IVI_FAILED);
833 runner_assert(length == 0);
834
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000835 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900836}
837
Ucan, Emre (ADITG/SW1)5d6aa9b2017-01-18 15:25:35 +0000838RUNNER_TEST(layer_add_surfaces)
839{
840 const struct ivi_layout_interface *lyt = ctx->layout_interface;
841 struct ivi_layout_layer *ivilayer;
842 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
843 struct ivi_layout_surface **array;
844 int32_t length = 0;
845 uint32_t i;
846
847 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
848
849 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++) {
850 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
851 runner_assert(lyt->layer_add_surface(
852 ivilayer, ivisurfs[i]) == IVI_SUCCEEDED);
853 }
854
855 lyt->commit_changes();
856
857 runner_assert(lyt->get_surfaces_on_layer(
858 ivilayer, &length, &array) == IVI_SUCCEEDED);
859 runner_assert(IVI_TEST_SURFACE_COUNT == length);
860 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
861 runner_assert(array[i] == ivisurfs[i]);
862
863 if (length > 0)
864 free(array);
865
866 runner_assert(lyt->layer_set_render_order(
867 ivilayer, NULL, 0) == IVI_SUCCEEDED);
868
869 for (i = IVI_TEST_SURFACE_COUNT; i-- > 0;)
870 runner_assert(lyt->layer_add_surface(
871 ivilayer, ivisurfs[i]) == IVI_SUCCEEDED);
872
873 lyt->commit_changes();
874
875 runner_assert(lyt->get_surfaces_on_layer(
876 ivilayer, &length, &array) == IVI_SUCCEEDED);
877 runner_assert(IVI_TEST_SURFACE_COUNT == length);
878 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
879 runner_assert(array[i] == ivisurfs[IVI_TEST_SURFACE_COUNT - (i + 1)]);
880
881 if (length > 0)
882 free(array);
883
884 lyt->layer_destroy(ivilayer);
885}
886
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900887RUNNER_TEST(commit_changes_after_render_order_set_surface_destroy)
888{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000889 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900890 struct ivi_layout_layer *ivilayer;
891 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
892 int i;
893
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000894 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900895
896 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000897 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900898
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000899 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900900 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
901}
902
903RUNNER_TEST(cleanup_layer)
904{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000905 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900906 struct ivi_layout_layer *ivilayer;
907
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000908 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
909 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900910}
911
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900912static void
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000913test_surface_properties_changed_notification_callback(struct wl_listener *listener, void *data)
914
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900915{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000916 struct test_context *ctx =
917 container_of(listener, struct test_context,
918 surface_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000919 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000920 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900921
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000922 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900923
924 ctx->user_flags = 1;
925}
926
927RUNNER_TEST(surface_properties_changed_notification)
928{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000929 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900930 const uint32_t id_surface = IVI_TEST_SURFACE_ID(0);
931 struct ivi_layout_surface *ivisurf;
932
933 ctx->user_flags = 0;
934
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000935 ivisurf = lyt->get_surface_from_id(id_surface);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900936 runner_assert(ivisurf != NULL);
937
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000938 ctx->surface_property_changed.notify = test_surface_properties_changed_notification_callback;
939
940 runner_assert(lyt->surface_add_listener(
941 ivisurf, &ctx->surface_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900942
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000943 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900944
945 runner_assert(ctx->user_flags == 0);
946
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000947 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900948 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
949
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000950 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900951
952 runner_assert(ctx->user_flags == 1);
953
954 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000955 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900956 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
957
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000958 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900959
960 runner_assert(ctx->user_flags == 0);
961
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000962 // remove surface property changed listener.
963 wl_list_remove(&ctx->surface_property_changed.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900964 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000965 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900966 ivisurf, 40, 50, 400, 500) == IVI_SUCCEEDED);
967
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000968 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900969
970 runner_assert(ctx->user_flags == 0);
971}
972
973static void
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000974test_surface_configure_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900975{
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000976 struct test_context *ctx =
977 container_of(listener, struct test_context,
978 surface_configured);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000979 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000980 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900981
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000982 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900983
984 ctx->user_flags = 1;
985}
986
987RUNNER_TEST(surface_configure_notification_p1)
988{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000989 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900990
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000991 ctx->surface_configured.notify = test_surface_configure_notification_callback;
992 runner_assert(IVI_SUCCEEDED == lyt->add_listener_configure_surface(&ctx->surface_configured));
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000993 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900994
995 ctx->user_flags = 0;
996}
997
998RUNNER_TEST(surface_configure_notification_p2)
999{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001000 runner_assert(ctx->user_flags == 1);
1001
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001002 // remove surface configured listener.
1003 wl_list_remove(&ctx->surface_configured.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001004 ctx->user_flags = 0;
1005}
1006
1007RUNNER_TEST(surface_configure_notification_p3)
1008{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001009 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001010
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001011 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001012 runner_assert(ctx->user_flags == 0);
1013}
1014
1015static void
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001016test_surface_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001017{
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001018 struct test_context *ctx =
1019 container_of(listener, struct test_context,
1020 surface_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001021 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001022 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001023
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001024 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001025
1026 ctx->user_flags = 1;
1027}
1028
1029RUNNER_TEST(surface_create_notification_p1)
1030{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001031 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001032
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001033 ctx->surface_created.notify = test_surface_create_notification_callback;
1034 runner_assert(lyt->add_listener_create_surface(
1035 &ctx->surface_created) == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001036
1037 ctx->user_flags = 0;
1038}
1039
1040RUNNER_TEST(surface_create_notification_p2)
1041{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001042 runner_assert(ctx->user_flags == 1);
1043
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001044 // remove surface created listener.
1045 wl_list_remove(&ctx->surface_created.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001046 ctx->user_flags = 0;
1047}
1048
1049RUNNER_TEST(surface_create_notification_p3)
1050{
1051 runner_assert(ctx->user_flags == 0);
1052}
1053
1054static void
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001055test_surface_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001056{
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001057 struct test_context *ctx =
1058 container_of(listener, struct test_context,
1059 surface_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001060 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001061 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001062
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001063 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001064
1065 ctx->user_flags = 1;
1066}
1067
1068RUNNER_TEST(surface_remove_notification_p1)
1069{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001070 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001071
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001072 ctx->surface_removed.notify = test_surface_remove_notification_callback;
1073 runner_assert(lyt->add_listener_remove_surface(&ctx->surface_removed)
1074 == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001075
1076 ctx->user_flags = 0;
1077}
1078
1079RUNNER_TEST(surface_remove_notification_p2)
1080{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001081 runner_assert(ctx->user_flags == 1);
1082
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001083 // remove surface removed listener.
1084 wl_list_remove(&ctx->surface_removed.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +09001085 ctx->user_flags = 0;
1086}
1087
1088RUNNER_TEST(surface_remove_notification_p3)
1089{
1090 runner_assert(ctx->user_flags == 0);
1091}
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001092
1093static void
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001094test_surface_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001095{
1096}
1097
1098RUNNER_TEST(surface_bad_properties_changed_notification)
1099{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001100 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001101 struct ivi_layout_surface *ivisurf;
1102
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001103 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001104 runner_assert(ivisurf != NULL);
1105
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001106 ctx->surface_property_changed.notify = test_surface_bad_properties_changed_notification_callback;
1107
1108 runner_assert(lyt->surface_add_listener(
1109 NULL, &ctx->surface_property_changed) == IVI_FAILED);
1110 runner_assert(lyt->surface_add_listener(
1111 ivisurf, NULL) == IVI_FAILED);
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001112}