blob: 80fcdf7f25c407d1640aa6c98b6535862c18ec40 [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;
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +000090 struct wl_listener surface_configured;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +090091};
92
93static struct test_context static_context;
94
95static void
96destroy_runner(struct wl_resource *resource)
97{
98 assert(static_context.runner_resource == NULL ||
99 static_context.runner_resource == resource);
100
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000101 static_context.layout_interface = NULL;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900102 static_context.runner_resource = NULL;
103}
104
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200105static void
106runner_destroy_handler(struct wl_client *client, struct wl_resource *resource)
107{
108 wl_resource_destroy(resource);
109}
110
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200111static void
112runner_run_handler(struct wl_client *client, struct wl_resource *resource,
113 const char *test_name)
114{
115 struct test_launcher *launcher;
116 const struct runner_test *t;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900117
118 assert(static_context.runner_resource == NULL ||
119 static_context.runner_resource == resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200120
121 launcher = wl_resource_get_user_data(resource);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000122 static_context.layout_interface = launcher->layout_interface;
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900123 static_context.runner_resource = resource;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200124
125 t = find_runner_test(test_name);
126 if (!t) {
127 weston_log("Error: runner test \"%s\" not found.\n",
128 test_name);
129 wl_resource_post_error(resource,
130 WESTON_TEST_RUNNER_ERROR_UNKNOWN_TEST,
131 "weston_test_runner: unknown: '%s'",
132 test_name);
133 return;
134 }
135
136 weston_log("weston_test_runner.run(\"%s\")\n", test_name);
137
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900138 t->run(&static_context);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200139
140 weston_test_runner_send_finished(resource);
141}
142
143static const struct weston_test_runner_interface runner_implementation = {
144 runner_destroy_handler,
145 runner_run_handler
146};
147
148static void
149bind_runner(struct wl_client *client, void *data,
150 uint32_t version, uint32_t id)
151{
152 struct test_launcher *launcher = data;
153 struct wl_resource *resource;
154
155 resource = wl_resource_create(client, &weston_test_runner_interface,
156 1, id);
157 if (!resource) {
158 wl_client_post_no_memory(client);
159 return;
160 }
161
162 wl_resource_set_implementation(resource, &runner_implementation,
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900163 launcher, destroy_runner);
164
165 if (static_context.runner_resource != NULL) {
166 weston_log("test FATAL: "
167 "attempting to run several tests in parallel.\n");
168 wl_resource_post_error(resource,
169 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
170 "attempt to run parallel tests");
171 }
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200172}
173
174static void
175test_client_sigchld(struct weston_process *process, int status)
176{
177 struct test_launcher *launcher =
178 container_of(process, struct test_launcher, process);
179 struct weston_compositor *c = launcher->compositor;
180
181 /* Chain up from weston-test-runner's exit code so that automake
182 * knows the exit status and can report e.g. skipped tests. */
183 if (WIFEXITED(status))
184 weston_compositor_exit_with_code(c, WEXITSTATUS(status));
185 else
186 weston_compositor_exit_with_code(c, EXIT_FAILURE);
187}
188
189static void
190idle_launch_client(void *data)
191{
192 struct test_launcher *launcher = data;
193 pid_t pid;
194 sigset_t allsigs;
195
196 pid = fork();
197 if (pid == -1) {
198 weston_log("fatal: failed to fork '%s': %m\n", launcher->exe);
199 weston_compositor_exit_with_code(launcher->compositor,
200 EXIT_FAILURE);
201 return;
202 }
203
204 if (pid == 0) {
205 sigfillset(&allsigs);
206 sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
207 execl(launcher->exe, launcher->exe, NULL);
208 weston_log("compositor: executing '%s' failed: %m\n",
209 launcher->exe);
210 _exit(EXIT_FAILURE);
211 }
212
213 launcher->process.pid = pid;
214 launcher->process.cleanup = test_client_sigchld;
215 weston_watch_process(&launcher->process);
216}
217
218int
219controller_module_init(struct weston_compositor *compositor,
220 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000221 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200222 size_t iface_version);
223
224WL_EXPORT int
225controller_module_init(struct weston_compositor *compositor,
226 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000227 const struct ivi_layout_interface *iface,
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200228 size_t iface_version)
229{
230 struct wl_event_loop *loop;
231 struct test_launcher *launcher;
232 const char *path;
233
234 /* strict check, since this is an internal test module */
235 if (iface_version != sizeof(*iface)) {
236 weston_log("fatal: controller interface mismatch\n");
237 return -1;
238 }
239
240 path = getenv("WESTON_BUILD_DIR");
241 if (!path) {
242 weston_log("test setup failure: WESTON_BUILD_DIR not set\n");
243 return -1;
244 }
245
246 launcher = zalloc(sizeof *launcher);
247 if (!launcher)
248 return -1;
249
250 launcher->compositor = compositor;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000251 launcher->layout_interface = iface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200252 snprintf(launcher->exe, sizeof launcher->exe,
253 "%s/ivi-layout.ivi", path);
254
255 if (wl_global_create(compositor->wl_display,
256 &weston_test_runner_interface, 1,
257 launcher, bind_runner) == NULL)
258 return -1;
259
260 loop = wl_display_get_event_loop(compositor->wl_display);
261 wl_event_loop_add_idle(loop, idle_launch_client, launcher);
262
263 return 0;
264}
265
266static void
267runner_assert_fail(const char *cond, const char *file, int line,
268 const char *func, struct test_context *ctx)
269{
270 weston_log("Assert failure in %s:%d, %s: '%s'\n",
271 file, line, func, cond);
Nobuhiko Tanibataa10352e2015-06-22 15:35:49 +0900272
273 assert(ctx->runner_resource);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200274 wl_resource_post_error(ctx->runner_resource,
275 WESTON_TEST_RUNNER_ERROR_TEST_FAILED,
276 "Assert failure in %s:%d, %s: '%s'\n",
277 file, line, func, cond);
278}
279
280#define runner_assert(cond) ({ \
281 bool b_ = (cond); \
282 if (!b_) \
283 runner_assert_fail(#cond, __FILE__, __LINE__, \
284 __func__, ctx); \
285 b_; \
286})
287
288#define runner_assert_or_return(cond) do { \
289 bool b_ = (cond); \
290 if (!b_) { \
291 runner_assert_fail(#cond, __FILE__, __LINE__, \
292 __func__, ctx); \
293 return; \
294 } \
295} while (0)
296
297
298/*************************** tests **********************************/
299
300/*
301 * This is a controller module: a plugin to ivi-shell.so, i.e. a sub-plugin.
302 * This module is specially written to execute tests that target the
303 * ivi_layout API.
304 *
305 * This module is listed in TESTS in Makefile.am. weston-tests-env handles
306 * this module specially by loading it in ivi-shell.
307 *
308 * Once Weston init completes, this module launches one test program:
309 * ivi-layout.ivi (ivi_layout-test.c). That program uses the weston-test-runner
310 * framework to fork and exec each TEST() in ivi_layout-test.c with a fresh
311 * connection to the single compositor instance.
312 *
313 * Each TEST() in ivi_layout-test.c will bind to weston_test_runner global
314 * interface. A TEST() will set up the client state, and issue
315 * weston_test_runner.run request to execute the compositor-side of the test.
316 *
317 * The compositor-side parts of the tests are in this file. They are specified
318 * by RUNNER_TEST() macro, where the name argument matches the name string
319 * passed to weston_test_runner.run.
320 *
321 * A RUNNER_TEST() function simply returns when it succeeds. If it fails,
322 * a fatal protocol error is sent to the client from runner_assert() or
323 * runner_assert_or_return(). This module catches the test program exit
324 * code and passes it out of Weston to the test harness.
325 *
326 * A single TEST() in ivi_layout-test.c may use multiple RUNNER_TEST()s to
327 * achieve multiple test points over a client action sequence.
328 */
329
330RUNNER_TEST(surface_create_p1)
331{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000332 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200333 struct ivi_layout_surface *ivisurf[2];
334 uint32_t ivi_id;
335
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000336 ivisurf[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900337 runner_assert(ivisurf[0]);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200338
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000339 ivisurf[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(1));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900340 runner_assert(ivisurf[1]);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200341
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000342 ivi_id = lyt->get_id_of_surface(ivisurf[0]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900343 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200344
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000345 ivi_id = lyt->get_id_of_surface(ivisurf[1]);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900346 runner_assert(ivi_id == IVI_TEST_SURFACE_ID(1));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200347}
348
349RUNNER_TEST(surface_create_p2)
350{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000351 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200352 struct ivi_layout_surface *ivisurf;
353
354 /* the ivi_surface was destroyed by the client */
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000355 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900356 runner_assert(ivisurf == NULL);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200357}
358
359RUNNER_TEST(surface_visibility)
360{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000361 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200362 struct ivi_layout_surface *ivisurf;
363 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200364 const struct ivi_layout_surface_properties *prop;
365
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000366 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900367 runner_assert(ivisurf);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200368
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000369 ret = lyt->surface_set_visibility(ivisurf, true);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900370 runner_assert(ret == IVI_SUCCEEDED);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200371
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000372 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200373
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000374 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900375 runner_assert(prop->visibility == true);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200376}
377
378RUNNER_TEST(surface_opacity)
379{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000380 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200381 struct ivi_layout_surface *ivisurf;
382 int32_t ret;
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200383 const struct ivi_layout_surface_properties *prop;
384
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000385 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900386 runner_assert(ivisurf);
387
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000388 prop = lyt->get_properties_of_surface(ivisurf);
389 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200390
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000391 ret = lyt->surface_set_opacity(ivisurf, wl_fixed_from_double(0.5));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900392 runner_assert(ret == IVI_SUCCEEDED);
393
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000394 runner_assert(prop->opacity == wl_fixed_from_double(1.0));
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200395
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000396 lyt->commit_changes();
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200397
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900398 runner_assert(prop->opacity == wl_fixed_from_double(0.5));
399}
400
401RUNNER_TEST(surface_orientation)
402{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000403 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900404 struct ivi_layout_surface *ivisurf;
405 const struct ivi_layout_surface_properties *prop;
406
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000407 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900408 runner_assert(ivisurf != NULL);
409
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000410 prop = lyt->get_properties_of_surface(ivisurf);
411 runner_assert_or_return(prop);
412 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900413
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000414 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900415 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
416
Ucan, Emre \(ADITG/SW1\)4d9001b2016-03-04 12:50:35 +0000417 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_NORMAL);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900418
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000419 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900420
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900421 runner_assert(prop->orientation == WL_OUTPUT_TRANSFORM_90);
422}
423
424RUNNER_TEST(surface_dimension)
425{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000426 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900427 struct ivi_layout_surface *ivisurf;
428 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900429
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000430 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900431 runner_assert(ivisurf != NULL);
432
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000433 prop = lyt->get_properties_of_surface(ivisurf);
434 runner_assert_or_return(prop);
435 runner_assert(prop->dest_width == 1);
436 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900437
438 runner_assert(IVI_SUCCEEDED ==
Ucan, Emre \(ADITG/SW1\)45d39422016-03-04 12:50:50 +0000439 lyt->surface_set_destination_rectangle(ivisurf, prop->dest_x,
440 prop->dest_y, 200, 300));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900441
Ucan, Emre \(ADITG/SW1\)c507f672016-03-04 12:50:28 +0000442 runner_assert(prop->dest_width == 1);
443 runner_assert(prop->dest_height == 1);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900444
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000445 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900446
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000447 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900448 runner_assert_or_return(prop);
449 runner_assert(prop->dest_width == 200);
450 runner_assert(prop->dest_height == 300);
451}
452
453RUNNER_TEST(surface_position)
454{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000455 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900456 struct ivi_layout_surface *ivisurf;
457 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900458
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000459 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900460 runner_assert(ivisurf != NULL);
461
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000462 prop = lyt->get_properties_of_surface(ivisurf);
463 runner_assert_or_return(prop);
464 runner_assert(prop->dest_x == 0);
465 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900466
Ucan, Emre \(ADITG/SW1\)161da402016-03-04 12:50:43 +0000467 runner_assert(lyt->surface_set_destination_rectangle(
468 ivisurf, 20, 30,
469 prop->dest_width, prop->dest_height) == IVI_SUCCEEDED);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900470
Ucan, Emre \(ADITG/SW1\)b2ff2552016-03-04 12:50:20 +0000471 runner_assert(prop->dest_x == 0);
472 runner_assert(prop->dest_y == 0);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900473
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000474 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900475
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000476 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900477 runner_assert_or_return(prop);
478 runner_assert(prop->dest_x == 20);
479 runner_assert(prop->dest_y == 30);
480}
481
482RUNNER_TEST(surface_destination_rectangle)
483{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000484 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900485 struct ivi_layout_surface *ivisurf;
486 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900487
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000488 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900489 runner_assert(ivisurf != NULL);
490
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000491 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900492 runner_assert_or_return(prop);
493 runner_assert(prop->dest_width == 1);
494 runner_assert(prop->dest_height == 1);
495 runner_assert(prop->dest_x == 0);
496 runner_assert(prop->dest_y == 0);
497
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000498 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900499 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
500
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000501 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900502 runner_assert_or_return(prop);
503 runner_assert(prop->dest_width == 1);
504 runner_assert(prop->dest_height == 1);
505 runner_assert(prop->dest_x == 0);
506 runner_assert(prop->dest_y == 0);
507
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000508 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900509
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000510 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900511 runner_assert_or_return(prop);
512 runner_assert(prop->dest_width == 200);
513 runner_assert(prop->dest_height == 300);
514 runner_assert(prop->dest_x == 20);
515 runner_assert(prop->dest_y == 30);
516}
517
518RUNNER_TEST(surface_source_rectangle)
519{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000520 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900521 struct ivi_layout_surface *ivisurf;
522 const struct ivi_layout_surface_properties *prop;
523
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000524 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900525 runner_assert(ivisurf != NULL);
526
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000527 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900528 runner_assert_or_return(prop);
529 runner_assert(prop->source_width == 0);
530 runner_assert(prop->source_height == 0);
531 runner_assert(prop->source_x == 0);
532 runner_assert(prop->source_y == 0);
533
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000534 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900535 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
536
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000537 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900538 runner_assert_or_return(prop);
539 runner_assert(prop->source_width == 0);
540 runner_assert(prop->source_height == 0);
541 runner_assert(prop->source_x == 0);
542 runner_assert(prop->source_y == 0);
543
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000544 lyt->commit_changes();
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900545
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000546 prop = lyt->get_properties_of_surface(ivisurf);
Nobuhiko Tanibata23d95822015-06-22 15:33:17 +0900547 runner_assert_or_return(prop);
548 runner_assert(prop->source_width == 200);
549 runner_assert(prop->source_height == 300);
550 runner_assert(prop->source_x == 20);
551 runner_assert(prop->source_y == 30);
Pekka Paalanenf5b74f72015-03-25 12:50:31 +0200552}
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900553
554RUNNER_TEST(surface_bad_opacity)
555{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000556 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900557 struct ivi_layout_surface *ivisurf;
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000558 const struct ivi_layout_surface_properties *prop;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900559
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000560 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900561 runner_assert(ivisurf != NULL);
562
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000563 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900564 NULL, wl_fixed_from_double(0.3)) == IVI_FAILED);
565
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000566 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900567 ivisurf, wl_fixed_from_double(0.3)) == IVI_SUCCEEDED);
568
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000569 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900570 ivisurf, wl_fixed_from_double(-1)) == IVI_FAILED);
571
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000572 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900573
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000574 prop = lyt->get_properties_of_surface(ivisurf);
575 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900576
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000577 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900578 ivisurf, wl_fixed_from_double(1.1)) == IVI_FAILED);
579
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000580 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900581
Ucan, Emre \(ADITG/SW1\)995e6fb2016-03-04 12:50:12 +0000582 runner_assert(prop->opacity == wl_fixed_from_double(0.3));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900583
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000584 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900585 NULL, wl_fixed_from_double(0.5)) == IVI_FAILED);
586
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000587 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900588}
589
590RUNNER_TEST(ivi_layout_commit_changes)
591{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000592 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900593
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000594 lyt->commit_changes();
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900595}
596
597RUNNER_TEST(commit_changes_after_visibility_set_surface_destroy)
598{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000599 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900600 struct ivi_layout_surface *ivisurf;
601
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000602 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900603 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000604 runner_assert(lyt->surface_set_visibility(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900605 ivisurf, true) == IVI_SUCCEEDED);
606}
607
608RUNNER_TEST(commit_changes_after_opacity_set_surface_destroy)
609{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000610 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900611 struct ivi_layout_surface *ivisurf;
612
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000613 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900614 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000615 runner_assert(lyt->surface_set_opacity(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900616 ivisurf, wl_fixed_from_double(0.5)) == IVI_SUCCEEDED);
617}
618
619RUNNER_TEST(commit_changes_after_orientation_set_surface_destroy)
620{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000621 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900622 struct ivi_layout_surface *ivisurf;
623
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000624 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900625 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000626 runner_assert(lyt->surface_set_orientation(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900627 ivisurf, WL_OUTPUT_TRANSFORM_90) == IVI_SUCCEEDED);
628}
629
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900630RUNNER_TEST(commit_changes_after_source_rectangle_set_surface_destroy)
631{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000632 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900633 struct ivi_layout_surface *ivisurf;
634
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000635 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900636 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000637 runner_assert(lyt->surface_set_source_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900638 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
639}
640
641RUNNER_TEST(commit_changes_after_destination_rectangle_set_surface_destroy)
642{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000643 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900644 struct ivi_layout_surface *ivisurf;
645
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000646 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900647 runner_assert(ivisurf != NULL);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000648 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900649 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
650}
651
652RUNNER_TEST(get_surface_after_destroy_surface)
653{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000654 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900655 struct ivi_layout_surface *ivisurf;
656
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000657 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibatac74bafa2015-06-22 15:33:26 +0900658 runner_assert(ivisurf == NULL);
659}
660
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900661RUNNER_TEST(layer_render_order)
662{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000663 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900664 struct ivi_layout_layer *ivilayer;
665 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
666 struct ivi_layout_surface **array;
667 int32_t length = 0;
668 uint32_t i;
669
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000670 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900671
672 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000673 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900674
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000675 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900676 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
677
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000678 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900679
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000680 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900681 ivilayer, &length, &array) == IVI_SUCCEEDED);
682 runner_assert(IVI_TEST_SURFACE_COUNT == length);
683 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
684 runner_assert(array[i] == ivisurfs[i]);
685
686 if (length > 0)
687 free(array);
688
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000689 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900690 ivilayer, NULL, 0) == IVI_SUCCEEDED);
691
692 array = NULL;
693
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000694 lyt->commit_changes();
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900695
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000696 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900697 ivilayer, &length, &array) == IVI_SUCCEEDED);
698 runner_assert(length == 0 && array == NULL);
699
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000700 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibatad3643932015-06-22 15:34:09 +0900701}
702
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900703RUNNER_TEST(test_layer_render_order_destroy_one_surface_p1)
704{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000705 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900706 struct ivi_layout_layer *ivilayer;
707 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
708 struct ivi_layout_surface **array;
709 int32_t length = 0;
710 int32_t i;
711
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000712 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900713
714 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000715 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900716
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000717 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900718 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
719
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000720 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900721
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000722 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900723 ivilayer, &length, &array) == IVI_SUCCEEDED);
724 runner_assert(IVI_TEST_SURFACE_COUNT == length);
725 for (i = 0; i < length; i++)
726 runner_assert(array[i] == ivisurfs[i]);
727
728 if (length > 0)
729 free(array);
730}
731
732RUNNER_TEST(test_layer_render_order_destroy_one_surface_p2)
733{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000734 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900735 struct ivi_layout_layer *ivilayer;
736 struct ivi_layout_surface *ivisurfs[2] = {};
737 struct ivi_layout_surface **array;
738 int32_t length = 0;
739 int32_t i;
740
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000741 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
742 ivisurfs[0] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
743 ivisurfs[1] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(2));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900744
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000745 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900746 ivilayer, &length, &array) == IVI_SUCCEEDED);
747 runner_assert(2 == length);
748 for (i = 0; i < length; i++)
749 runner_assert(array[i] == ivisurfs[i]);
750
751 if (length > 0)
752 free(array);
753
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000754 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900755}
756
757RUNNER_TEST(layer_bad_render_order)
758{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000759 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900760 struct ivi_layout_layer *ivilayer;
761 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
762 struct ivi_layout_surface **array = NULL;
763 int32_t length = 0;
764 uint32_t i;
765
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000766 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900767
768 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000769 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900770
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000771 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900772 NULL, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_FAILED);
773
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000774 lyt->commit_changes();
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900775
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000776 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900777 NULL, &length, &array) == IVI_FAILED);
778 runner_assert(length == 0 && array == NULL);
779
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000780 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900781 ivilayer, NULL, &array) == IVI_FAILED);
782 runner_assert(array == NULL);
783
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000784 runner_assert(lyt->get_surfaces_on_layer(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900785 ivilayer, &length, NULL) == IVI_FAILED);
786 runner_assert(length == 0);
787
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000788 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900789}
790
791RUNNER_TEST(commit_changes_after_render_order_set_surface_destroy)
792{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000793 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900794 struct ivi_layout_layer *ivilayer;
795 struct ivi_layout_surface *ivisurfs[IVI_TEST_SURFACE_COUNT] = {};
796 int i;
797
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000798 ivilayer = lyt->layer_create_with_dimension(IVI_TEST_LAYER_ID(0), 200, 300);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900799
800 for (i = 0; i < IVI_TEST_SURFACE_COUNT; i++)
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000801 ivisurfs[i] = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(i));
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900802
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000803 runner_assert(lyt->layer_set_render_order(
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900804 ivilayer, ivisurfs, IVI_TEST_SURFACE_COUNT) == IVI_SUCCEEDED);
805}
806
807RUNNER_TEST(cleanup_layer)
808{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000809 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900810 struct ivi_layout_layer *ivilayer;
811
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000812 ivilayer = lyt->get_layer_from_id(IVI_TEST_LAYER_ID(0));
813 lyt->layer_destroy(ivilayer);
Nobuhiko Tanibata0671b4d2015-06-22 15:34:42 +0900814}
815
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900816static void
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000817test_surface_properties_changed_notification_callback(struct wl_listener *listener, void *data)
818
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900819{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000820 struct test_context *ctx =
821 container_of(listener, struct test_context,
822 surface_property_changed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000823 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000824 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900825
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000826 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900827
828 ctx->user_flags = 1;
829}
830
831RUNNER_TEST(surface_properties_changed_notification)
832{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000833 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900834 const uint32_t id_surface = IVI_TEST_SURFACE_ID(0);
835 struct ivi_layout_surface *ivisurf;
836
837 ctx->user_flags = 0;
838
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000839 ivisurf = lyt->get_surface_from_id(id_surface);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900840 runner_assert(ivisurf != NULL);
841
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000842 ctx->surface_property_changed.notify = test_surface_properties_changed_notification_callback;
843
844 runner_assert(lyt->surface_add_listener(
845 ivisurf, &ctx->surface_property_changed) == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900846
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000847 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900848
849 runner_assert(ctx->user_flags == 0);
850
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000851 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900852 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
853
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000854 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900855
856 runner_assert(ctx->user_flags == 1);
857
858 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000859 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900860 ivisurf, 20, 30, 200, 300) == IVI_SUCCEEDED);
861
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000862 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900863
864 runner_assert(ctx->user_flags == 0);
865
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000866 // remove surface property changed listener.
867 wl_list_remove(&ctx->surface_property_changed.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900868 ctx->user_flags = 0;
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000869 runner_assert(lyt->surface_set_destination_rectangle(
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900870 ivisurf, 40, 50, 400, 500) == IVI_SUCCEEDED);
871
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000872 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900873
874 runner_assert(ctx->user_flags == 0);
875}
876
877static void
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000878test_surface_configure_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900879{
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000880 struct test_context *ctx =
881 container_of(listener, struct test_context,
882 surface_configured);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000883 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000884 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900885
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000886 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900887
888 ctx->user_flags = 1;
889}
890
891RUNNER_TEST(surface_configure_notification_p1)
892{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000893 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900894
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000895 ctx->surface_configured.notify = test_surface_configure_notification_callback;
896 runner_assert(IVI_SUCCEEDED == lyt->add_listener_configure_surface(&ctx->surface_configured));
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000897 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900898
899 ctx->user_flags = 0;
900}
901
902RUNNER_TEST(surface_configure_notification_p2)
903{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900904 runner_assert(ctx->user_flags == 1);
905
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +0000906 // remove surface configured listener.
907 wl_list_remove(&ctx->surface_configured.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900908 ctx->user_flags = 0;
909}
910
911RUNNER_TEST(surface_configure_notification_p3)
912{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000913 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900914
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000915 lyt->commit_changes();
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900916 runner_assert(ctx->user_flags == 0);
917}
918
919static void
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000920test_surface_create_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900921{
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000922 struct test_context *ctx =
923 container_of(listener, struct test_context,
924 surface_created);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000925 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000926 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900927
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000928 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900929
930 ctx->user_flags = 1;
931}
932
933RUNNER_TEST(surface_create_notification_p1)
934{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000935 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900936
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000937 ctx->surface_created.notify = test_surface_create_notification_callback;
938 runner_assert(lyt->add_listener_create_surface(
939 &ctx->surface_created) == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900940
941 ctx->user_flags = 0;
942}
943
944RUNNER_TEST(surface_create_notification_p2)
945{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900946 runner_assert(ctx->user_flags == 1);
947
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000948 // remove surface created listener.
949 wl_list_remove(&ctx->surface_created.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900950 ctx->user_flags = 0;
951}
952
953RUNNER_TEST(surface_create_notification_p3)
954{
955 runner_assert(ctx->user_flags == 0);
956}
957
958static void
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000959test_surface_remove_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900960{
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000961 struct test_context *ctx =
962 container_of(listener, struct test_context,
963 surface_removed);
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000964 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000965 struct ivi_layout_surface *ivisurf = data;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900966
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000967 runner_assert_or_return(lyt->get_id_of_surface(ivisurf) == IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900968
969 ctx->user_flags = 1;
970}
971
972RUNNER_TEST(surface_remove_notification_p1)
973{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +0000974 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900975
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000976 ctx->surface_removed.notify = test_surface_remove_notification_callback;
977 runner_assert(lyt->add_listener_remove_surface(&ctx->surface_removed)
978 == IVI_SUCCEEDED);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900979
980 ctx->user_flags = 0;
981}
982
983RUNNER_TEST(surface_remove_notification_p2)
984{
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900985 runner_assert(ctx->user_flags == 1);
986
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +0000987 // remove surface removed listener.
988 wl_list_remove(&ctx->surface_removed.link);
Nobuhiko Tanibata915303a2015-06-22 15:35:58 +0900989 ctx->user_flags = 0;
990}
991
992RUNNER_TEST(surface_remove_notification_p3)
993{
994 runner_assert(ctx->user_flags == 0);
995}
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900996
997static void
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +0000998test_surface_bad_properties_changed_notification_callback(struct wl_listener *listener, void *data)
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +0900999{
1000}
1001
1002RUNNER_TEST(surface_bad_properties_changed_notification)
1003{
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001004 const struct ivi_layout_interface *lyt = ctx->layout_interface;
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001005 struct ivi_layout_surface *ivisurf;
1006
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00001007 ivisurf = lyt->get_surface_from_id(IVI_TEST_SURFACE_ID(0));
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001008 runner_assert(ivisurf != NULL);
1009
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001010 ctx->surface_property_changed.notify = test_surface_bad_properties_changed_notification_callback;
1011
1012 runner_assert(lyt->surface_add_listener(
1013 NULL, &ctx->surface_property_changed) == IVI_FAILED);
1014 runner_assert(lyt->surface_add_listener(
1015 ivisurf, NULL) == IVI_FAILED);
Nobuhiko Tanibata0af22d42015-06-22 15:36:21 +09001016}