From c1d56f7d059dc0744fc95f35bec1e60ed46cd332 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 7 Jul 2022 19:57:35 +0900 Subject: [PATCH] remove the test files. This test files are useless. Change-Id: I0528e80430c947e1dfcf92f8b71860188d9d0ec5 --- tests/meson.build | 25 ------ tests/test_backend.c | 80 ------------------ tests/test_compositor.c | 63 --------------- tests/test_subsurface.c | 211 ------------------------------------------------ tests/test_surface.c | 162 ------------------------------------- 5 files changed, 541 deletions(-) delete mode 100644 tests/meson.build delete mode 100644 tests/test_backend.c delete mode 100644 tests/test_compositor.c delete mode 100644 tests/test_subsurface.c delete mode 100644 tests/test_surface.c diff --git a/tests/meson.build b/tests/meson.build deleted file mode 100644 index 324c760..0000000 --- a/tests/meson.build +++ /dev/null @@ -1,25 +0,0 @@ -tests = [ - { 'name': 'test_compositor' }, - { 'name': 'test_backend' }, - { - 'name': 'test_surface', - 'deps': [ dependency('wayland-client') ], - }, - { - 'name': 'test_subsurface', - 'deps': [ dependency('wayland-client') ], - }, -] - -foreach t : tests - t_deps = [ deps_libds_tizen ] - t_deps += t.get('deps', []) - - test('libds-tizen-' + t.get('name'), - executable('libds-tizen-' + t.get('name'), t.get('name') + '.c', - dependencies: t_deps , - include_directories: common_inc, - install: false - ) - ) -endforeach diff --git a/tests/test_backend.c b/tests/test_backend.c deleted file mode 100644 index 69417b6..0000000 --- a/tests/test_backend.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include - -#include -#include - -static struct ds_backend * -create_possible_wl_backend(struct wl_display *display) -{ - struct ds_backend *backend; - char wl_name[512]; - - for (int i = 0; i < 5; i++) { - snprintf(wl_name, sizeof wl_name, "wayland-%d", i); - backend = ds_wl_backend_create(display, wl_name); - if (backend) - break; - } - - return backend; -} - -static void -test_wl_backend_create(void) -{ - struct wl_display *display; - struct ds_backend *backend; - - display = wl_display_create(); - - backend = create_possible_wl_backend(display); - assert(backend); - - ds_backend_destroy(backend); -} - -struct test -{ - struct wl_listener backend_destroy; - bool cb_called; -}; - -static void -cb_backend_destroy(struct wl_listener *listener, void *data) -{ - struct test *test; - - test = wl_container_of(listener, test, backend_destroy); - test->cb_called = true; -} - -static void -test_wl_backend_destroy_signal(void) -{ - struct wl_display *display; - struct ds_backend *backend; - struct test test; - - display = wl_display_create(); - - backend = create_possible_wl_backend(display); - assert(backend); - - test.cb_called = false; - test.backend_destroy.notify = cb_backend_destroy; - ds_backend_add_destroy_listener(backend, &test.backend_destroy); - - wl_display_destroy(display); - assert(test.cb_called); -} - -int -main(void) -{ - test_wl_backend_create(); - test_wl_backend_destroy_signal(); - - return 0; -} diff --git a/tests/test_compositor.c b/tests/test_compositor.c deleted file mode 100644 index b5883a5..0000000 --- a/tests/test_compositor.c +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include - -#include -#include -#include - -static void -test_compositor_create(void) -{ - struct wl_display *display; - struct ds_compositor *compositor; - - display = wl_display_create(); - compositor = ds_compositor_create(display); - assert(compositor); - - wl_display_destroy(display); -} - -struct test -{ - struct wl_listener compositor_destroy; - bool destroyed; -}; - -static void -cb_compositor_destroy(struct wl_listener *listener, void *data) -{ - struct test *test; - - test = wl_container_of(listener, test, compositor_destroy); - test->destroyed = true; -} - -static void -test_compositor_destroy_signal(void) -{ - struct wl_display *display; - struct ds_compositor *compositor; - struct test test; - - display = wl_display_create(); - compositor = ds_compositor_create(display); - assert(compositor); - - test.destroyed = false; - test.compositor_destroy.notify = cb_compositor_destroy; - ds_compositor_add_destroy_listener(compositor, - &test.compositor_destroy); - - wl_display_destroy(display); - assert(test.destroyed == true); -} - -int -main(void) -{ - test_compositor_create(); - test_compositor_destroy_signal(); - - return 0; -} diff --git a/tests/test_subsurface.c b/tests/test_subsurface.c deleted file mode 100644 index 98e830d..0000000 --- a/tests/test_subsurface.c +++ /dev/null @@ -1,211 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -struct server_base -{ - struct wl_display *display; - struct ds_compositor *compositor; - const char *socket; -}; - -const char * -test_server_init(struct server_base *server) -{ - server->display = wl_display_create(); - assert(server->display); - server->compositor = ds_compositor_create(server->display); - assert(server->compositor); - server->socket = wl_display_add_socket_auto(server->display); - assert(server->socket); - - return server->socket; -} - -void -test_server_finish(struct server_base *server) -{ - wl_display_destroy(server->display); -} - -struct client -{ - struct wl_display *display; - struct wl_registry *registry; - struct wl_compositor *compositor; - struct wl_subcompositor *subcompositor; - struct wl_surface *surface; - struct wl_subsurface *subsurface; -}; - -static void -handle_global(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, uint32_t version) -{ - struct client *client = data; - - if (strcmp(interface, "wl_compositor") == 0) { - client->compositor = - wl_registry_bind(registry, id, &wl_compositor_interface, version); - } - else if (strcmp(interface, "wl_subcompositor") == 0) { - client->subcompositor = - wl_registry_bind(registry, id, &wl_subcompositor_interface, version); - } -} - -static const struct wl_registry_listener registry_listener = { - .global = handle_global, -}; - -void -test_client_init(struct client *client, const char *name) -{ - client->display = wl_display_connect(name); - assert(client->display); - client->registry = wl_display_get_registry(client->display); - assert(client->registry); - - wl_registry_add_listener(client->registry, ®istry_listener, client); - - wl_display_roundtrip(client->display); - - assert(client->compositor); - assert(client->subcompositor); -} - -void -test_client_finish(struct client *client) -{ - wl_subcompositor_destroy(client->subcompositor); - wl_compositor_destroy(client->compositor); - wl_registry_destroy(client->registry); - wl_display_disconnect(client->display); -} - -struct test_server -{ - struct server_base base; - bool cb_called; - - struct wl_listener new_surface; - struct wl_listener new_subsurface1; - struct wl_listener new_subsurface2; -}; - -static void -cb_new_subsurface1(struct wl_listener *listener, void *data) -{ - struct ds_subsurface *subsurface = data; - struct test_server *server; - - assert(subsurface); - - server = wl_container_of(listener, server, new_subsurface1); - server->cb_called = true; - wl_display_terminate(server->base.display); -} - -static void -cb_new_subsurface2(struct wl_listener *listener, void *data) -{ - struct ds_subsurface *subsurface = data; - struct test_server *server; - - assert(subsurface); - - server = wl_container_of(listener, server, new_subsurface2); - server->cb_called = true; - wl_display_terminate(server->base.display); -} - -static void -cb_new_surface(struct wl_listener *listener, void *data) -{ - struct ds_surface *surface = data; - struct test_server *server; - - server = wl_container_of(listener, server, new_surface); - if (!server->new_subsurface1.notify) { - server->new_subsurface1.notify = cb_new_subsurface1; - ds_surface_add_new_subsurface_listener(surface, - &server->new_subsurface1); - } - else { - server->new_subsurface2.notify = cb_new_subsurface2; - ds_surface_add_new_subsurface_listener(surface, - &server->new_subsurface2); - } -} - -static void -run_client(const char *name) -{ - struct client client; - - test_client_init(&client, name); - - struct wl_surface *surface = - wl_compositor_create_surface(client.compositor); - - struct wl_surface *child_surface = - wl_compositor_create_surface(client.compositor); - - struct wl_subsurface *subsurface = - wl_subcompositor_get_subsurface(client.subcompositor, - child_surface, surface); - - wl_display_roundtrip(client.display); - - wl_subsurface_destroy(subsurface); - wl_surface_destroy(child_surface); - wl_surface_destroy(surface); - - test_client_finish(&client); -} - -static void -test_subsurface_create(void) -{ - struct test_server server = { - .new_subsurface1 = { .notify = NULL }, - .cb_called = false - }; - pid_t pid; - - const char *socket_name = test_server_init(&server.base); - - pid = fork(); - assert(pid != -1); - - if (pid == 0) { - run_client(socket_name); - exit(0); - } - - server.new_surface.notify = cb_new_surface; - ds_compositor_add_new_surface_listener(server.base.compositor, - &server.new_surface); - - wl_display_run(server.base.display); - - assert(server.cb_called); - - test_server_finish(&server.base); -} - -int -main(void) -{ - test_subsurface_create(); - return 0; -} diff --git a/tests/test_surface.c b/tests/test_surface.c deleted file mode 100644 index eab2b77..0000000 --- a/tests/test_surface.c +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -struct server_base -{ - struct wl_display *display; - struct ds_compositor *compositor; - const char *socket; -}; - -void -test_server_init(struct server_base *server) -{ - server->display = wl_display_create(); - assert(server->display); - server->compositor = ds_compositor_create(server->display); - assert(server->compositor); - server->socket = wl_display_add_socket_auto(server->display); - assert(server->socket); -} - -void -test_server_finish(struct server_base *server) -{ - wl_display_destroy(server->display); -} - -struct client -{ - struct wl_display *display; - struct wl_registry *registry; - struct wl_compositor *compositor; - struct wl_surface *surface; -}; - -static void -handle_global(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, uint32_t version) -{ - struct client *client = data; - - if (strcmp(interface, "wl_compositor") == 0) { - client->compositor = - wl_registry_bind(registry, id, &wl_compositor_interface, version); - } -} - -static const struct wl_registry_listener registry_listener = { - .global = handle_global, -}; - -void -test_client_init(struct client *client, const char *name) -{ - client->display = wl_display_connect(name); - assert(client->display); - client->registry = wl_display_get_registry(client->display); - assert(client->registry); - - wl_registry_add_listener(client->registry, ®istry_listener, client); - - wl_display_roundtrip(client->display); - - assert(client->compositor); -} - -void -test_client_finish(struct client *client) -{ - wl_compositor_destroy(client->compositor); - wl_registry_destroy(client->registry); - wl_display_disconnect(client->display); -} - -struct test_server { - struct server_base base; - bool cb_called; - - struct wl_listener new_surface; - struct wl_listener surface_destroy; -}; - -static void -cb_surface_destroy(struct wl_listener *listener, void *data) -{ - struct test_server *server; - - server = wl_container_of(listener, server, surface_destroy); - server->cb_called = true; - wl_display_terminate(server->base.display); -} - -static void -cb_new_surface(struct wl_listener *listener, void *data) -{ - struct ds_surface *surface = data; - struct test_server *server; - - server = wl_container_of(listener, server, new_surface); - server->surface_destroy.notify = cb_surface_destroy; - ds_surface_add_destroy_listener(surface, &server->surface_destroy); -} - -static void -run_client(const char *name) -{ - struct client client; - - test_client_init(&client, name); - - struct wl_surface *surface = - wl_compositor_create_surface(client.compositor); - - wl_display_roundtrip(client.display); - - wl_surface_destroy(surface); - - test_client_finish(&client); -} - -static void -test_surface_create_and_destroy(void) -{ - struct test_server server = { .cb_called = false }; - pid_t pid; - - test_server_init(&server.base); - - pid = fork(); - assert(pid != -1); - - if (pid == 0) { - run_client(server.base.socket); - exit(0); - } - - server.new_surface.notify = cb_new_surface; - ds_compositor_add_new_surface_listener(server.base.compositor, - &server.new_surface); - - wl_display_run(server.base.display); - - assert(server.cb_called); - - test_server_finish(&server.base); -} - -int -main(void) -{ - test_surface_create_and_destroy(); - return 0; -} -- 2.7.4