utest: change name to unittests 06/195906/3
authorJunkyeong Kim <jk0430.kim@samsung.com>
Wed, 19 Dec 2018 09:48:07 +0000 (18:48 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 20 Dec 2018 06:07:35 +0000 (06:07 +0000)
Change-Id: I6384ebfff09694b3aa601128821f40c939d4d015
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
13 files changed:
Makefile.am
configure.ac
packaging/libwayland-tbm.spec
unittests/Makefile.am [new file with mode: 0644]
unittests/src/ut_base.cpp [new file with mode: 0644]
unittests/src/ut_base.h [new file with mode: 0644]
unittests/src/ut_main.cpp [new file with mode: 0644]
unittests/src/ut_wayland_tbm.cpp [new file with mode: 0644]
utests/Makefile.am [deleted file]
utests/src/ut_base.cpp [deleted file]
utests/src/ut_base.h [deleted file]
utests/src/ut_main.cpp [deleted file]
utests/src/ut_wayland_tbm.cpp [deleted file]

index 1c6b3c78c01f0240a82a616c0f06c488ca7adfd9..7fff03ae3c0257b75ff9da2d7be7e6d52518cf8f 100644 (file)
@@ -1,7 +1,7 @@
 MAINTAINERCLEANFILES = Makefile.in
 
 if HAVE_UTEST
-SUBDIRS = src tool utests
+SUBDIRS = src tool unittests
 else
 SUBDIRS = src tool
 endif
index 9a7c0a65289d68d467f85b8954b2c5d4ccc8ed55..34ba00f473af808f53f31153d8b50f54007d52e9 100644 (file)
@@ -11,11 +11,11 @@ AC_PROG_CC
 AC_PROG_CXX
 AC_PROG_LIBTOOL
 
-AC_ARG_WITH(utests, AS_HELP_STRING([--with-utests=yes/no], [whether build/run unit tests or not]),
-                               [ utests="$withval" ],
-                               [ utests="no" ])
+AC_ARG_WITH(unittests, AS_HELP_STRING([--with-unittests=yes/no], [whether build/run unit tests or not]),
+                               [ unittests="$withval" ],
+                               [ unittests="no" ])
 
-AM_CONDITIONAL(HAVE_UTEST, test "x$utests" = "xyes")
+AM_CONDITIONAL(HAVE_UTEST, test "x$unittests" = "xyes")
 
 AC_PATH_PROG([wayland_scanner], [wayland-scanner])
 if test x$wayland_scanner = x; then
@@ -32,7 +32,7 @@ AC_CONFIG_FILES([
     src/Makefile
     test/Makefile
     tool/Makefile
-    utests/Makefile
+    unittests/Makefile
        wayland-tbm-server.pc
        wayland-tbm-client.pc
 ])
index 5cb74197f0c86437574d31cf3ab8451e5a41b7ee..6c59ffb17b5db8f61551265173dbba547a3f323a 100644 (file)
@@ -51,10 +51,10 @@ Requires:   pkgconfig(libtbm)
 Development header files for use with Wayland protocol
 
 %if "%{UTEST_PACKAGE}" == "1"
-%package utests
+%package unittests
 Summary:    Wayland TBM unit test package
 Group:         Graphics & UI Framework/Wayland Window System
-%description utests
+%description unittests
 Test module for testing wayland-tbm APIs
 %endif
 
@@ -77,7 +77,7 @@ CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV"
 LDFLAGS+=" -lgcov"
 %endif
 
-%reconfigure --with-utests=${UTEST} \
+%reconfigure --with-unittests=${UTEST} \
              CFLAGS="${CFLAGS} -Wall -Werror" \
              CXXFLAGS="${CXXFLAGS} -Wall -Werror" \
              LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed"
@@ -116,9 +116,9 @@ rm -rf %{buildroot}
 %doc README TODO
 
 %if "%{UTEST_PACKAGE}" == "1"
-%files utests
+%files unittests
 %defattr(-,root,root,-)
-%{_bindir}/wayland-tbm-utests
+%{_bindir}/wayland-tbm-unittests
 %endif
 
 %changelog
diff --git a/unittests/Makefile.am b/unittests/Makefile.am
new file mode 100644 (file)
index 0000000..d30af5c
--- /dev/null
@@ -0,0 +1,32 @@
+bin_PROGRAMS = wayland-tbm-unittests
+
+wayland_tbm_unittests_CXXFLAGS = \
+       $(CXXFLAGS) \
+       $(WL_TBM_COMMON_CFLAGS) \
+       $(WL_TBM_CLIENT_CFLAGS) \
+       $(WL_TBM_SERVER_CFLAGS) \
+       -I../src \
+       -I./ \
+       -I$(includedir)/gtest \
+       -fpermissive
+
+# The flag -w is used, because there are many warnings in wayland-tbm sources.
+# Warnings occur because we build project with g++.
+# In C++ we need to use explicit types conversion.
+
+wayland_tbm_unittests_LDFLAGS = \
+       ${LDFLAGS} \
+       $(WL_TBM_COMMON_LIBS) \
+       $(WL_TBM_CLIENT_LIBS) \
+       $(WL_TBM_SERVER_LIBS) \
+       $(top_builddir)/src/libwayland-tbm-client.la \
+       $(top_builddir)/src/libwayland-tbm-server.la \
+       -lgtest
+
+wayland_tbm_unittests_SOURCES = \
+       src/ut_main.cpp \
+       src/ut_base.cpp \
+       src/ut_wayland_tbm.cpp
+
+check:
+       ./wayland-tbm-unittests
diff --git a/unittests/src/ut_base.cpp b/unittests/src/ut_base.cpp
new file mode 100644 (file)
index 0000000..319d086
--- /dev/null
@@ -0,0 +1,484 @@
+/*
+Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+      SooChan Lim <sc1.lim@samsung.com>,
+      Sangjin Lee <lsj119@samsung.com>,
+      Boram Park <boram1288.park@samsung.com>,
+      Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+#include "gtest/gtest.h"
+#include "ut_base.h"
+#include "wayland-tbm-server.h"
+#include "wayland-tbm-test-server-protocol.h"
+#include "wayland-tbm-int.h"
+
+typedef struct
+{
+       struct wl_display *wl_disp;
+       struct wayland_tbm_server *wl_tbm_server;
+       struct wl_global *wl_tbm_test;
+
+       struct wl_listener client_add_cb;
+       struct wl_listener client_destroy_cb;
+} wlt_server_t;
+
+typedef struct
+{
+       struct wl_resource *test;
+       struct wl_resource *buffer;
+       struct wl_listener buf_destroy_cb;
+       uint32_t is_active;
+
+       struct wl_list export_bufs;
+} wlt_surface;
+
+wlt_server_t wlt_server;
+
+static void
+_res_wl_tbm_test_buffer_destroy(struct wl_listener *listener, void *data)
+{
+       wlt_surface *wlt_surf = wl_container_of(listener, wlt_surf, buf_destroy_cb);
+       wlt_surf->buffer = nullptr;
+}
+
+static void
+_res_wl_tbm_test_surface_destroy(struct wl_resource *res)
+{
+       wlt_surface *wlt_surf = (wlt_surface *)wl_resource_get_user_data(res);
+       if (wlt_surf->buffer)
+       {
+               wl_list_remove(&wlt_surf->buf_destroy_cb.link);
+       }
+       free(wlt_surf);
+}
+
+static void
+_wl_tbm_test_surface_destroy(struct wl_client *client,
+                       struct wl_resource *resource)
+{
+       wl_resource_destroy(resource);
+}
+
+static void
+_wl_tbm_test_surface_attach(struct wl_client *client,
+                      struct wl_resource *resource,
+                      struct wl_resource *buffer,
+                      int32_t x,
+                      int32_t y)
+{
+       wlt_surface *wlt_surf = (wlt_surface *)wl_resource_get_user_data(resource);
+       tbm_surface_h tbm_buf;
+
+       if (wlt_surf->buffer == buffer)
+       {
+               wl_tbm_test_send_error(wlt_surf->test, resource, WL_TBM_TEST_ERROR_INVALID_OBJECT, "attach the same buffer");
+               return;
+       }
+
+       if (buffer) {
+               tbm_buf = wayland_tbm_server_get_surface(wlt_server.wl_tbm_server, buffer);
+               if (tbm_buf == nullptr)
+               {
+                       wl_tbm_test_send_error(wlt_surf->test, resource, WL_TBM_TEST_ERROR_INVALID_OBJECT, "The buffer is invalid");
+                       return;
+               }
+
+               wl_resource_add_destroy_listener(buffer, &wlt_surf->buf_destroy_cb);
+       }
+
+       if (wlt_surf->buffer)
+       {
+               wl_buffer_send_release(wlt_surf->buffer);
+               wl_list_remove(&wlt_surf->buf_destroy_cb.link);
+       }
+
+       wlt_surf->buffer = buffer;
+}
+
+static void
+_wl_tbm_test_surface_damage(struct wl_client *client,
+                      struct wl_resource *resource,
+                      int32_t x,
+                      int32_t y,
+                      int32_t width,
+                      int32_t height)
+{
+}
+
+static void
+_wl_tbm_test_surface_frame(struct wl_client *client,
+                     struct wl_resource *resource,
+                     uint32_t callback)
+{
+}
+
+static void
+_wl_tbm_test_surface_set_opaque_region(struct wl_client *client,
+                                 struct wl_resource *resource,
+                                 struct wl_resource *region)
+{
+}
+
+static void
+_wl_tbm_test_surface_set_input_region(struct wl_client *client,
+                                struct wl_resource *resource,
+                                struct wl_resource *region)
+{
+}
+
+static void
+_wl_tbm_test_surface_commit(struct wl_client *client,
+                      struct wl_resource *resource)
+{
+}
+
+static void
+_wl_tbm_test_surface_set_buffer_transform(struct wl_client *client,
+                                    struct wl_resource *resource,
+                                    int32_t transform)
+{
+}
+
+static void
+_wl_tbm_test_surface_set_buffer_scale(struct wl_client *client,
+                                struct wl_resource *resource,
+                                int32_t scale)
+{
+}
+
+static void
+_wl_tbm_test_surface_damage_buffer(struct wl_client *client,
+                             struct wl_resource *resource,
+                             int32_t x,
+                             int32_t y,
+                             int32_t width,
+                             int32_t height)
+{
+}
+
+static const struct wl_surface_interface wl_tbm_test_surface_impl = {
+       _wl_tbm_test_surface_destroy,
+       _wl_tbm_test_surface_attach,
+       _wl_tbm_test_surface_damage,
+       _wl_tbm_test_surface_frame,
+       _wl_tbm_test_surface_set_opaque_region,
+       _wl_tbm_test_surface_set_input_region,
+       _wl_tbm_test_surface_commit,
+       _wl_tbm_test_surface_set_buffer_transform,
+       _wl_tbm_test_surface_set_buffer_scale,
+       _wl_tbm_test_surface_damage_buffer
+};
+
+static void
+_res_wl_tbm_test_destroy(struct wl_resource *res)
+{
+}
+
+static void
+_wl_tbm_test_destroy(struct wl_client *client, struct wl_resource *resource)
+{
+       wl_resource_destroy(resource);
+}
+
+static void
+_wl_tbm_test_create_surface(struct wl_client *client, struct wl_resource *resource, uint32_t surface)
+{
+       struct wl_resource *res;
+       wlt_surface *wlt_surf;
+
+       res = wl_resource_create(client, &wl_surface_interface, 1, surface);
+       if (!res)
+               exit(-1);
+
+       wlt_surf = (wlt_surface *)calloc(1, sizeof(wlt_surface));
+       if (!wlt_surf)
+               exit(-1);
+
+       wlt_surf->test = resource;
+       wlt_surf->buffer = (wl_resource *)nullptr;
+       wlt_surf->buf_destroy_cb.notify = _res_wl_tbm_test_buffer_destroy;
+
+       wl_resource_set_implementation(res, &wl_tbm_test_surface_impl, wlt_surf, _res_wl_tbm_test_surface_destroy);
+       wl_list_init(&wlt_surf->export_bufs);
+}
+
+static void
+_wl_tbm_test_server_surface_destroy_cb(tbm_surface_h surface, void *data)
+{
+       tbm_surface_destroy(surface);
+}
+
+static void
+_wl_tbm_test_server_surface_detach_cb(struct wayland_tbm_client_queue *cqueue, tbm_surface_h surface, void *data)
+{
+
+}
+
+static void
+_wl_tbm_test_queue_dequeue_cb(struct wayland_tbm_client_queue *queue, tbm_surface_h surface, void *data)
+{
+
+}
+
+static void
+_wl_tbm_test_set_active(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface,
+                                       uint32_t active,
+                                       uint32_t usage,
+                                       uint32_t queue_size,
+                                       uint32_t need_flush)
+{
+       wlt_surface *wlt_surf;
+       wayland_tbm_client_queue *wlt_queue;
+       tbm_surface_h tbm_surf;
+       struct wl_resource *wl_buf;
+
+       wlt_queue = wayland_tbm_server_client_queue_get(wlt_server.wl_tbm_server, surface);
+       if (!wlt_queue) {
+               wl_tbm_test_send_error(resource, surface, WL_TBM_TEST_ERROR_INVALID_OBJECT, "active: invalid surface");
+               return;
+       }
+
+       wlt_surf = (wlt_surface*)wl_resource_get_user_data(surface);
+       if (wlt_surf->is_active == active)
+               return;
+
+       wlt_surf->is_active = active;
+       if (active) {
+               uint32_t i = 0;
+               wayland_tbm_server_client_queue_set_dequeue_cb(wlt_queue, _wl_tbm_test_queue_dequeue_cb, wlt_surf);
+
+               while (i < queue_size) {
+                       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+                       if (i == 0)
+                               wl_buf = wayland_tbm_server_client_queue_export_buffer(wlt_queue, tbm_surf, 0xFF,
+                                               _wl_tbm_test_server_surface_destroy_cb, nullptr);
+                       else
+                               wl_buf = wayland_tbm_server_client_queue_export_buffer2(wlt_queue, tbm_surf, 0xFF,
+                                               _wl_tbm_test_server_surface_detach_cb,
+                                               _wl_tbm_test_server_surface_destroy_cb,
+                                               nullptr);
+                       wl_list_insert(&wlt_surf->export_bufs, wl_resource_get_link(wl_buf));
+                       wayland_tbm_server_client_queue_send_buffer_usable(wlt_queue, wl_buf);
+                       i++;
+               }
+
+               wayland_tbm_server_client_queue_activate(wlt_queue, usage, queue_size, need_flush);
+       } else {
+               wayland_tbm_server_client_queue_deactivate(wlt_queue);
+       }
+
+       wl_client_flush(client);
+}
+
+static void
+_wl_tbm_test_queue_flush(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface)
+{
+       struct wayland_tbm_client_queue *queue;
+
+       queue = wayland_tbm_server_client_queue_get(wlt_server.wl_tbm_server, surface);
+       if (!queue) {
+               wl_tbm_test_send_error(resource, surface, WL_TBM_TEST_ERROR_INVALID_OBJECT, "flush: invalid surface");
+               return;
+       }
+
+       wayland_tbm_server_client_queue_flush(queue);
+}
+
+static void
+_wl_tbm_test_check_buffer(struct wl_client *client, struct wl_resource *resource, struct wl_resource *buffer,
+                                       uint32_t property,
+                                       uint32_t value)
+{
+       tbm_surface_h tbm_surf;
+       tbm_surface_info_s info;
+       int ret;
+
+       tbm_surf = wayland_tbm_server_get_surface(wlt_server.wl_tbm_server, buffer);
+       if (!tbm_surf) {
+               wl_tbm_test_send_error(resource, buffer, WL_TBM_TEST_ERROR_INVALID_OBJECT, "Check_buffer: invalid buffer");
+               return;
+       }
+
+       ret = tbm_surface_get_info(tbm_surf, &info);
+       if (ret != TBM_SURFACE_ERROR_NONE) {
+               wl_tbm_test_send_error(resource, buffer, WL_TBM_TEST_ERROR_INVALID_OBJECT, "Check_buffer: failed get surface info");
+               return;
+       }
+
+       switch(property) {
+       case WL_TBM_TEST_PROP_BUFFER_WIDTH:
+               if (value != info.width) goto prop_error;
+               break;
+       case WL_TBM_TEST_PROP_BUFFER_HEIGHT:
+               if (value != info.height) goto prop_error;
+               break;
+       case WL_TBM_TEST_PROP_BUFFER_FORMAT:
+               if (value != info.format) goto prop_error;
+               break;
+       case WL_TBM_TEST_PROP_BUFFER_NUM_PALNE:
+               if (value != info.num_planes) goto prop_error;
+               break;
+       case WL_TBM_TEST_PROP_BUFFER_TRANSFORM:
+               if (value != (uint32_t)wayland_tbm_server_buffer_get_buffer_transform(wlt_server.wl_tbm_server, buffer))
+                       goto prop_error;
+               break;
+       case WL_TBM_TEST_PROP_BUFFER_FLAG:
+               if (value != wayland_tbm_server_get_buffer_flags(wlt_server.wl_tbm_server, buffer))
+                       goto prop_error;
+               break;
+       default:
+               break;
+       }
+
+       return;
+prop_error:
+       wl_tbm_test_send_error(resource, buffer, WL_TBM_TEST_ERROR_INVALID_OBJECT, "Check_buffer: wrong value");
+}
+
+static void
+_wl_tbm_test_destroy_queue_buffer(struct wl_client *client, struct wl_resource *resource, struct wl_resource *wl_tbm, struct wl_resource *surface)
+{
+       wlt_surface *wlt_surf;
+       struct wl_resource *wl_buf, *tmp;
+
+       wlt_surf = (wlt_surface*)wl_resource_get_user_data(surface);
+       wl_resource_for_each_safe(wl_buf, tmp, &wlt_surf->export_bufs) {
+               wl_list_remove(wl_resource_get_link(wl_buf));
+               wayland_tbm_server_send_destroy_buffer(wl_tbm, wl_buf);
+       }
+
+       wl_client_flush(client);
+}
+
+static void
+_wl_tbm_test_timeline_increase(struct wl_client *client, struct wl_resource *resource, struct wl_resource *buffer)
+{
+       if (!wayland_tbm_server_buffer_has_sync_timeline(wlt_server.wl_tbm_server, buffer)) {
+               wl_tbm_test_send_error(resource, buffer, WL_TBM_TEST_ERROR_INVALID_OBJECT, "timeline: no timeline");
+               wl_client_flush(client);
+               return;
+       }
+
+       wayland_tbm_server_increase_buffer_sync_timeline(wlt_server.wl_tbm_server, buffer, 1);
+       wl_client_flush(client);
+}
+
+static const struct wl_tbm_test_interface wl_tbm_test_impl = {
+       _wl_tbm_test_destroy,
+       _wl_tbm_test_create_surface,
+       _wl_tbm_test_set_active,
+       _wl_tbm_test_queue_flush,
+       _wl_tbm_test_check_buffer,
+       _wl_tbm_test_destroy_queue_buffer,
+       _wl_tbm_test_timeline_increase
+};
+
+static void
+_wl_tbm_test_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id)
+{
+       struct wl_resource *res;
+
+       res = wl_resource_create(client, &wl_tbm_test_interface, version, id);
+       if (!res)
+               exit(-1);
+       wl_resource_set_implementation(res, &wl_tbm_test_impl, data, _res_wl_tbm_test_destroy);
+}
+
+static void
+_wl_tbm_test_client_add_cb(struct wl_listener *listener, void *data)
+{
+       struct wl_client *client = (struct wl_client*) data;
+       wl_client_add_destroy_listener(client, &wlt_server.client_destroy_cb);
+}
+
+static void
+_wl_tbm_test_client_destory_cb(struct wl_listener *listener, void *data)
+{
+       wayland_tbm_server_deinit(wlt_server.wl_tbm_server);
+       wlt_server.wl_tbm_server = nullptr;
+
+       wl_display_terminate(wlt_server.wl_disp);
+}
+
+#ifdef TIZEN_TEST_GCOV
+extern "C" void __gcov_flush(void);
+#endif
+
+int
+launch_server(void)
+{
+       int pid;
+
+       pid = fork();
+       if (pid != 0)
+               return pid;
+
+#ifdef TIZEN_TEST_GCOV
+       setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+       unsetenv("WAYLAND_DEBUG");
+
+       wlt_server.wl_disp = wl_display_create();
+       if (!wlt_server.wl_disp)
+               exit(-1);
+
+       if (wl_display_add_socket(wlt_server.wl_disp, "ut_wayland_tbm"))
+               exit(-1);
+
+       wlt_server.wl_tbm_server = wayland_tbm_server_init(wlt_server.wl_disp, NULL, -1, 0);
+       if (!wlt_server.wl_tbm_server)
+               exit(-1);
+
+       if (!wayland_tbm_server_get_bufmgr(wlt_server.wl_tbm_server))
+               exit(-1);
+
+       wlt_server.client_add_cb.notify = _wl_tbm_test_client_add_cb;
+       wlt_server.client_destroy_cb.notify = _wl_tbm_test_client_destory_cb;
+       wl_display_add_client_created_listener(wlt_server.wl_disp, &wlt_server.client_add_cb);
+
+       wlt_server.wl_tbm_test = wl_global_create(wlt_server.wl_disp,
+                                                                                         &wl_tbm_test_interface,
+                                                                                         1,
+                                                                                         &wlt_server,
+                                                                                         _wl_tbm_test_bind_cb);
+       if (!wlt_server.wl_tbm_test)
+               exit(-1);
+
+       wl_display_run(wlt_server.wl_disp);
+
+       wl_display_destroy(wlt_server.wl_disp);
+#ifdef TIZEN_TEST_GCOV
+       __gcov_flush();
+#endif
+       exit(0);
+
+       return pid;
+}
+
+void
+kill_server(int pid)
+{
+       printf("[Client] Pre kill Server(%d)\n", pid);
+       kill(pid, SIGINT);
+       printf("[Client] Post kill Server(%d)\n", pid);
+}
\ No newline at end of file
diff --git a/unittests/src/ut_base.h b/unittests/src/ut_base.h
new file mode 100644 (file)
index 0000000..9f94df2
--- /dev/null
@@ -0,0 +1,23 @@
+#define WL_HIDE_DEPRECATED
+#include "gtest/gtest.h"
+
+#define FAIL_NE_GOTO(con1, con2, to)   \
+       do {                                            \
+               if ((con1) == (con2)) { \
+                       ADD_FAILURE();          \
+                       goto to;                        \
+               }                                               \
+       } while(0)
+
+
+#define FAIL_EQ_GOTO(con1, con2, to)   \
+                       do {                                            \
+                               if ((con1) != (con2)) { \
+                                       ADD_FAILURE();          \
+                                       goto to;                        \
+                               }                                               \
+                       } while(0)
+
+extern int launch_server(void);
+extern void kill_server(int pid);
+
diff --git a/unittests/src/ut_main.cpp b/unittests/src/ut_main.cpp
new file mode 100644 (file)
index 0000000..4112179
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+      SooChan Lim <sc1.lim@samsung.com>,
+      Sangjin Lee <lsj119@samsung.com>,
+      Boram Park <boram1288.park@samsung.com>,
+      Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+#include "gtest/gtest.h"
+
+#ifdef TIZEN_TEST_GCOV
+extern "C" void __gcov_flush(void);
+#endif
+
+int main(int argc, char **argv)
+{
+       auto AllTestSuccess = false;
+
+#ifdef TIZEN_TEST_GCOV
+       setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
+       try {
+               ::testing::InitGoogleTest(&argc, argv);
+               ::testing::FLAGS_gtest_death_test_style = "fast";
+       } catch ( ... ) {
+               std::cout << "error while trying to init google tests.\n";
+               exit(EXIT_FAILURE);
+       }
+
+       try {
+               AllTestSuccess = RUN_ALL_TESTS() == 0 ? true : false;
+       } catch (const ::testing::internal::GoogleTestFailureException & e) {
+               AllTestSuccess = false;
+               std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+               std::cout << "\n";
+       }
+
+#ifdef TIZEN_TEST_GCOV
+       __gcov_flush();
+#endif
+
+       return AllTestSuccess;
+}
\ No newline at end of file
diff --git a/unittests/src/ut_wayland_tbm.cpp b/unittests/src/ut_wayland_tbm.cpp
new file mode 100644 (file)
index 0000000..928a9f1
--- /dev/null
@@ -0,0 +1,964 @@
+/*
+Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+      SooChan Lim <sc1.lim@samsung.com>,
+      Sangjin Lee <lsj119@samsung.com>,
+      Boram Park <boram1288.park@samsung.com>,
+      Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+#define WL_HIDE_DEPRECATED
+#include "gtest/gtest.h"
+#include "ut_base.h"
+#include <wayland-client.h>
+#include <tbm_surface.h>
+#include <tbm_surface_queue.h>
+extern "C" {
+#include <tbm_sync.h>
+}
+#include "wayland-tbm-client.h"
+#include "wayland-tbm-int.h"
+#include "wayland-tbm-client-protocol.h"
+#include "wayland-tbm-test-client-protocol.h"
+
+class UtWlTbm : public ::testing::Test
+{
+  protected:
+       static void SetUpTestCase();
+       static void TearDownTestCase();
+       void SetUp();
+       void TearDown();
+       static int CheckServerError();
+
+  public:
+       static int server_error;
+       static int server_pid;
+       static int monitor_done;
+       static struct wl_display *wl_disp;
+       static struct wayland_tbm_client *wl_tbm_client;
+       static struct wl_tbm_test *wl_tbm_test;
+       static struct wl_tbm_monitor *wl_tbm_monitor;
+
+       static UtWlTbm *resolve(void *data) { return static_cast<UtWlTbm *>(data); }
+       static void wlt_test_error_cb(void *data, struct wl_tbm_test *wl_tbm_test, void *object, uint32_t code, const char *message);
+       static const struct wl_tbm_test_listener wlt_test_listener;
+
+       static void wlt_reg_handle_global_cb(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version);
+       static const struct wl_registry_listener wlt_reg_listener;
+
+       static void wlt_monitor_done_cb(void *data, struct wl_tbm_monitor *wl_tbm_monitor, const char *message);
+       static void wlt_monitor_request_to_client_cb(void *data, struct wl_tbm_monitor *wl_tbm_monitor,
+                                               const char *options, const char *request_id);
+       static const struct wl_tbm_monitor_listener wlt_monitor_listener;
+
+       static void wlt_queue_buffer_release_cb(void *data, struct wl_buffer *wl_buffer);
+       static const struct wl_buffer_listener wlt_queue_buffer_listener;
+
+       static void SendMonitorCmd(const char *cmd);
+};
+
+int UtWlTbm::server_error = 0;
+int UtWlTbm::server_pid = -1;
+int UtWlTbm::monitor_done = 0;
+struct wl_display *UtWlTbm::wl_disp = nullptr;
+struct wayland_tbm_client *UtWlTbm::wl_tbm_client = nullptr;
+struct wl_tbm_test *UtWlTbm::wl_tbm_test = nullptr;
+struct wl_tbm_monitor *UtWlTbm::wl_tbm_monitor = nullptr;
+
+const struct wl_tbm_test_listener UtWlTbm::wlt_test_listener =
+{
+       UtWlTbm::wlt_test_error_cb
+};
+
+const struct wl_registry_listener UtWlTbm::wlt_reg_listener =
+{
+       UtWlTbm::wlt_reg_handle_global_cb
+};
+
+const struct wl_tbm_monitor_listener UtWlTbm::wlt_monitor_listener =
+{
+       UtWlTbm::wlt_monitor_done_cb,
+       UtWlTbm::wlt_monitor_request_to_client_cb
+};
+
+const struct wl_buffer_listener UtWlTbm::wlt_queue_buffer_listener = {
+       UtWlTbm::wlt_queue_buffer_release_cb
+};
+
+void UtWlTbm::wlt_test_error_cb(void *data,
+                                                               struct wl_tbm_test *wl_tbm_test,
+                                                               void *object, uint32_t code, const char *message)
+{
+       server_error = code;
+       printf("[ERROR: %p(id:%d), err:%d] %s\n", object, ((object) ? wl_proxy_get_id((struct wl_proxy *)object) : -1), code, message);
+}
+
+void UtWlTbm::wlt_reg_handle_global_cb(void *data,
+                                                                          struct wl_registry *registry, uint32_t name,
+                                                                          const char *interface, uint32_t version)
+{
+       if (!strncmp(interface, "wl_tbm_test", 11))
+       {
+               UtWlTbm::wl_tbm_test = (struct wl_tbm_test *)wl_registry_bind(registry, name, &wl_tbm_test_interface, version);
+               wl_tbm_test_add_listener(UtWlTbm::wl_tbm_test, &wlt_test_listener, data);
+       } else if (!strncmp(interface, "wl_tbm_monitor", 14)) {
+               UtWlTbm::wl_tbm_monitor = (struct wl_tbm_monitor *)wl_registry_bind(registry, name, &wl_tbm_monitor_interface, version);
+               wl_tbm_monitor_add_listener(UtWlTbm::wl_tbm_monitor, &wlt_monitor_listener, data);
+       }
+}
+
+void
+UtWlTbm::wlt_monitor_done_cb(void *data, struct wl_tbm_monitor *wl_tbm_monitor, const char *message)
+{
+       UtWlTbm::monitor_done = 1;
+       printf("%s", message);
+}
+
+void
+UtWlTbm::wlt_monitor_request_to_client_cb(void *data, struct wl_tbm_monitor *wl_tbm_monitor,
+                                               const char *options, const char *request_id)
+{
+       const char *message = "\n";
+
+       wl_tbm_monitor_responce_to_server(UtWlTbm::wl_tbm_monitor, message, request_id);
+}
+
+void UtWlTbm::SetUpTestCase()
+{
+       int cnt = 0;
+       struct wl_registry *wl_reg = nullptr;
+
+       server_pid = launch_server();
+       ASSERT_NE(server_pid, -1);
+       sleep(1);
+
+       do
+       {
+               wl_disp = wl_display_connect("ut_wayland_tbm");
+               if (wl_disp == nullptr)
+               {
+                       usleep(1000);
+                       printf("Wait... connect to server\n");
+               }
+       } while (wl_disp == nullptr && cnt++ < 10);
+       ASSERT_NE(wl_disp, nullptr);
+
+       wl_tbm_client = wayland_tbm_client_init(wl_disp);
+       ASSERT_NE(wl_tbm_client, nullptr);
+
+       wl_reg = wl_display_get_registry(wl_disp);
+       wl_registry_add_listener(wl_reg, &UtWlTbm::wlt_reg_listener, nullptr);
+       wl_display_roundtrip(wl_disp);
+       wl_registry_destroy(wl_reg);
+}
+
+void UtWlTbm::TearDownTestCase()
+{
+       if (wl_tbm_monitor) {
+               wl_tbm_monitor_destroy(wl_tbm_monitor);
+               wl_tbm_monitor = nullptr;
+       }
+
+       if (wl_tbm_client) {
+               wayland_tbm_client_deinit(wl_tbm_client);
+               wl_tbm_client = nullptr;
+       }
+
+       if (wl_tbm_test) {
+               wl_tbm_test_destroy(wl_tbm_test);
+               wl_tbm_test = nullptr;
+       }
+
+       wl_display_roundtrip(wl_disp);
+       wl_display_disconnect(wl_disp);
+}
+
+void UtWlTbm::SetUp()
+{
+}
+
+void UtWlTbm::TearDown()
+{
+}
+
+int UtWlTbm::CheckServerError()
+{
+       UtWlTbm::server_error = 0;
+       wl_display_roundtrip(UtWlTbm::wl_disp);
+
+       return UtWlTbm::server_error;
+}
+
+void UtWlTbm::SendMonitorCmd(const char *cmd)
+{
+       int ret;
+
+       UtWlTbm::monitor_done = 0;
+       wl_tbm_monitor_request_to_sever(wl_tbm_monitor, cmd);
+       ASSERT_EQ(CheckServerError(), 0);
+       while(!UtWlTbm::monitor_done) {
+               ret = wl_display_dispatch(UtWlTbm::wl_disp);
+               ASSERT_NE(ret, -1);
+       }
+}
+
+void UtWlTbm::wlt_queue_buffer_release_cb(void *data, struct wl_buffer *wl_buffer)
+{
+       tbm_surface_queue_h queue = (tbm_surface_queue_h)data;
+       tbm_surface_h surface = (tbm_surface_h)wl_buffer_get_user_data(wl_buffer);
+
+       wayland_tbm_client_destroy_buffer(UtWlTbm::wl_tbm_client, wl_buffer);
+       tbm_surface_queue_release(queue, surface);
+}
+
+TEST_F(UtWlTbm, GetBufMgr)
+{
+       void *bufmgr = nullptr;
+       ASSERT_NE(wl_tbm_client, nullptr);
+
+       bufmgr = wayland_tbm_client_get_bufmgr(wl_tbm_client);
+       ASSERT_NE(bufmgr, nullptr);
+}
+
+TEST_F(UtWlTbm, GetBufMgrFail)
+{
+       void *bufmgr = nullptr;
+
+       bufmgr = wayland_tbm_client_get_bufmgr(nullptr);
+       ASSERT_EQ(bufmgr, nullptr);
+}
+
+TEST_F(UtWlTbm, GetWlTbm)
+{
+       struct wl_tbm *wl_tbm;
+
+       wl_tbm = wayland_tbm_client_get_wl_tbm(wl_tbm_client);
+       ASSERT_NE(wl_tbm, nullptr);
+       ASSERT_NE(wl_tbm_get_user_data(wl_tbm), nullptr);
+}
+
+TEST_F(UtWlTbm, SetEventQueue)
+{
+       struct wl_event_queue *queue;
+
+       queue = wl_display_create_queue(wl_disp);
+       ASSERT_NE(queue, nullptr);
+
+       ASSERT_EQ(wayland_tbm_client_set_event_queue(wl_tbm_client, queue), 1);
+       wl_event_queue_destroy(queue);
+       ASSERT_EQ(wayland_tbm_client_set_event_queue(wl_tbm_client, nullptr), 1);
+}
+
+TEST_F(UtWlTbm, BufCreate)
+{
+       tbm_surface_h tbm_surf;
+       struct wl_buffer *wl_buf;
+       int ret;
+
+       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+       ASSERT_NE(tbm_surf, nullptr);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       ASSERT_NE(wl_buf, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       ret = tbm_surface_destroy(tbm_surf);
+       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
+}
+
+TEST_F(UtWlTbm, BufCreateTwice)
+{
+       tbm_surface_h tbm_surf;
+       struct wl_buffer *wl_buf, *wl_buf2;
+       int ret;
+
+       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+       ASSERT_NE(tbm_surf, nullptr);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       ASSERT_NE(wl_buf, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_buf2 = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       ASSERT_NE(wl_buf, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       ASSERT_NE(wl_buf, wl_buf2);
+
+       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf2);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       ret = tbm_surface_destroy(tbm_surf);
+       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
+}
+
+TEST_F(UtWlTbm, ButCreateNull)
+{
+       struct wl_buffer *wl_buf;
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, (tbm_surface_h)nullptr);
+       ASSERT_EQ(wl_buf, nullptr);
+       if (wl_buf)
+               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+
+       wl_buf = wayland_tbm_client_create_buffer(nullptr, nullptr);
+       ASSERT_EQ(wl_buf, nullptr);
+       if (wl_buf)
+               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+}
+
+TEST_F(UtWlTbm, BufDestroyNull)
+{
+       wayland_tbm_client_destroy_buffer(wl_tbm_client, (wl_buffer*)nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wayland_tbm_client_destroy_buffer((wayland_tbm_client*)nullptr, (wl_buffer*)nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufTransform)
+{
+       tbm_surface_h tbm_surf;
+       struct wl_buffer *wl_buf;
+       int ret;
+
+       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+       ASSERT_NE(tbm_surf, nullptr);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       ASSERT_NE(wl_buf, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wayland_tbm_client_set_buffer_transform(wl_tbm_client, wl_buf, 5);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_tbm_test_check_buffer(wl_tbm_test, wl_buf, WL_TBM_TEST_PROP_BUFFER_TRANSFORM, 5);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       ret = tbm_surface_destroy(tbm_surf);
+       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
+}
+
+TEST_F(UtWlTbm, BufCheckFlag)
+{
+       tbm_surface_h tbm_surf;
+       struct wl_buffer *wl_buf;
+       int ret;
+
+       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+       ASSERT_NE(tbm_surf, nullptr);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       ASSERT_NE(wl_buf, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_tbm_test_check_buffer(wl_tbm_test, wl_buf, WL_TBM_TEST_PROP_BUFFER_FLAG, 0);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       ret = tbm_surface_destroy(tbm_surf);
+       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
+}
+
+TEST_F(UtWlTbm, BufAttach)
+{
+       tbm_surface_h tbm_surf;
+       struct wl_buffer *wl_buf;
+       struct wl_surface *wlt_surface;
+       int ret;
+
+       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+       ASSERT_NE(tbm_surf, nullptr);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       ASSERT_NE(wl_buf, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_surface_attach(wlt_surface, wl_buf, 0, 0);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       ret = tbm_surface_destroy(tbm_surf);
+       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
+
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueCreateNull)
+{
+       tbm_surface_queue_h tbm_queue;
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, nullptr, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_EQ(tbm_queue, nullptr);
+}
+
+TEST_F(UtWlTbm, BufQueueCreate)
+{
+       tbm_surface_queue_h tbm_queue;
+       struct wl_surface *wlt_surface;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+}
+
+TEST_F(UtWlTbm, BufQueueGetTbmQueue)
+{
+       tbm_surface_queue_h tbm_queue;
+       struct wl_surface *wlt_surface;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+       ASSERT_NE(wayland_tbm_client_get_wl_tbm_queue(wl_tbm_client, wlt_surface), nullptr);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueGetSurfaces)
+{
+       tbm_surface_queue_h tbm_queue;
+       struct wl_surface *wlt_surface;
+       int num_surf;
+       int ret;
+       tbm_surface_h surfaces[5];
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       ret = wayland_tbm_client_queue_get_surfaces(wl_tbm_client, tbm_queue, nullptr, &num_surf);
+       ASSERT_EQ(ret, 1);
+       ASSERT_EQ(num_surf, 3);
+
+       ret = wayland_tbm_client_queue_get_surfaces(wl_tbm_client, tbm_queue, surfaces, &num_surf);
+       ASSERT_EQ(ret, 1);
+       ASSERT_EQ(num_surf, 3);
+       for (int i=0; i < num_surf; i++)
+               ASSERT_NE(surfaces[i], nullptr);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueCheckActive)
+{
+       struct wl_surface *wlt_surface;
+       tbm_surface_queue_h tbm_queue;
+       int active;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
+       ASSERT_EQ(CheckServerError(), 0);
+       ASSERT_EQ(active, 0);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueActiveReq)
+{
+       struct wl_surface *wlt_surface;
+       tbm_surface_queue_h tbm_queue;
+       int active;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 1);
+       ASSERT_EQ(CheckServerError(), 0);
+       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
+       ASSERT_EQ(CheckServerError(), 0);
+       ASSERT_EQ(active, 1);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueActiveReqNoFlush)
+{
+       struct wl_surface *wlt_surface;
+       tbm_surface_queue_h tbm_queue;
+       int active;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 0);
+       ASSERT_EQ(CheckServerError(), 0);
+       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
+       ASSERT_EQ(CheckServerError(), 0);
+       ASSERT_EQ(active, 1);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueDeactiveReq)
+{
+       struct wl_surface *wlt_surface;
+       tbm_surface_queue_h tbm_queue;
+       int active;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 1);
+       ASSERT_EQ(CheckServerError(), 0);
+       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
+       ASSERT_EQ(CheckServerError(), 0);
+       ASSERT_EQ(active, 1);
+
+       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 0, 0, 0, 0);
+       ASSERT_EQ(CheckServerError(), 0);
+       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
+       ASSERT_EQ(CheckServerError(), 0);
+       ASSERT_EQ(active, 0);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueBufDestroyReq)
+{
+       struct wl_surface *wlt_surface;
+       struct wl_tbm *wlt_tbm;
+       tbm_surface_queue_h tbm_queue;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 1);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wlt_tbm = wayland_tbm_client_get_wl_tbm(wl_tbm_client);
+       wl_tbm_test_destroy_queue_buffer(wl_tbm_test, wlt_tbm, wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueDequeue)
+{
+       struct wl_surface *wlt_surface;
+       tbm_surface_queue_h tbm_queue;
+       int i = 0;
+       tbm_surface_h tbm_surf;
+       tbm_surface_queue_error_e tbm_err;
+       struct wl_buffer *wl_buf;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ARGB8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 1);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       while (i < 3) {
+               if (tbm_surface_queue_can_dequeue(tbm_queue, 0)) {
+                       tbm_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surf);
+                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+                       ASSERT_EQ(CheckServerError(), 0);
+
+                       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+                       ASSERT_NE(wl_buf, nullptr);
+                       ASSERT_EQ(CheckServerError(), 0);
+
+                       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+                       ASSERT_EQ(CheckServerError(), 0);
+               }
+               i++;
+       }
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueDequeueNotify)
+{
+       struct wl_surface *wlt_surface;
+       tbm_surface_queue_h tbm_queue;
+       int i = 0;
+       tbm_surface_h tbm_surf;
+       tbm_surface_queue_error_e tbm_err;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       while (i++ < 3) {
+               if (tbm_surface_queue_can_dequeue(tbm_queue, 1)) {
+                       tbm_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surf);
+                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+
+                       tbm_err = tbm_surface_queue_enqueue(tbm_queue, tbm_surf);
+                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+
+                       tbm_err = tbm_surface_queue_acquire(tbm_queue, &tbm_surf);
+                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+
+                       tbm_err = tbm_surface_queue_release(tbm_queue, tbm_surf);
+                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+               }
+       }
+
+       wl_tbm_test_queue_flush(wl_tbm_test, wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueAttach)
+{
+       struct wl_surface *wlt_surface;
+       struct wl_buffer *wl_buf;
+
+       tbm_surface_queue_h tbm_queue;
+       tbm_surface_h tbm_surf;
+       tbm_surface_queue_error_e tbm_err;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surf);
+       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+
+       tbm_err = tbm_surface_queue_enqueue(tbm_queue, tbm_surf);
+       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+
+       tbm_err = tbm_surface_queue_acquire(tbm_queue, &tbm_surf);
+       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       ASSERT_NE(wl_buf, nullptr);
+       wl_buffer_add_listener(wl_buf, &wlt_queue_buffer_listener, (void*)tbm_queue);
+       wl_surface_attach(wlt_surface, wl_buf, 0, 0);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       /*Make null attch for release*/
+       wl_surface_attach(wlt_surface, nullptr, 0, 0);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       wl_tbm_test_queue_flush(wl_tbm_test, wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, BufQueueFlush)
+{
+       struct wl_surface *wlt_surface;
+       tbm_surface_queue_h tbm_queue;
+       int i = 0;
+       tbm_surface_h tbm_surf;
+       tbm_surface_queue_error_e tbm_err;
+
+       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
+       ASSERT_NE(wlt_surface, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
+       ASSERT_NE(tbm_queue, nullptr);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       while (i < 3) {
+               tbm_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surf);
+               ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+
+               tbm_err = tbm_surface_queue_enqueue(tbm_queue, tbm_surf);
+               ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
+               i++;
+       }
+
+       wl_tbm_test_queue_flush(wl_tbm_test, wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
+
+TEST_F(UtWlTbm, MonitorHelp)
+{
+       SendMonitorCmd("");
+}
+
+TEST_F(UtWlTbm, MonitorList)
+{
+       SendMonitorCmd("-list");
+}
+
+TEST_F(UtWlTbm, MonitorShowAll)
+{
+       SendMonitorCmd("-show all");
+}
+
+TEST_F(UtWlTbm, MonitorShowServer)
+{
+       SendMonitorCmd("-show server");
+}
+
+TEST_F(UtWlTbm, MonitorShowClient)
+{
+       char msg[128];
+       int pid = getpid();
+
+       snprintf(msg, 127, "%s %d", "-show ", pid);
+       SendMonitorCmd(msg);
+}
+
+TEST_F(UtWlTbm, MonitorTraceOnOffAll)
+{
+       SendMonitorCmd("-trace on all");
+       SendMonitorCmd("-trace off all");
+}
+
+TEST_F(UtWlTbm, MonitorDumpSnapshot)
+{
+       SendMonitorCmd("-dump_snapshot all");
+}
+
+TEST_F(UtWlTbm, MonitorDumpQueue)
+{
+       SendMonitorCmd("-dump_queue on all");
+       SendMonitorCmd("-dump_queue off all");
+}
+
+TEST_F(UtWlTbm, SyncCreate)
+{
+       tbm_fd td = -1;
+       tbm_surface_h tbm_surf = nullptr;
+       struct wl_buffer *wl_buf = nullptr;
+
+       td = tbm_sync_timeline_create();
+       if (td == -1) {
+               ASSERT_EQ(td, -1);
+               printf("do not support sync\n");
+               goto fini;
+       }
+
+       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+       FAIL_NE_GOTO(tbm_surf, nullptr, fini);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       FAIL_NE_GOTO(wl_buf, nullptr, fini);
+       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
+
+       wayland_tbm_client_set_sync_timeline(wl_tbm_client, wl_buf, td);
+       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
+
+fini:
+       if (wl_buf)
+               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+
+       if (tbm_surf)
+               tbm_surface_destroy(tbm_surf);
+
+       if (td != -1)
+               close(td);
+}
+
+TEST_F(UtWlTbm, SyncWait)
+{
+       tbm_fd td = -1, fence = -1;
+       tbm_surface_h tbm_surf = nullptr;
+       struct wl_buffer *wl_buf = nullptr;
+
+       td = tbm_sync_timeline_create();
+       if (td == -1) {
+               ASSERT_EQ(td, -1);
+               printf("do not support sync\n");
+               goto fini;
+       }
+
+       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+       FAIL_NE_GOTO(tbm_surf, nullptr, fini);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       FAIL_NE_GOTO(wl_buf, nullptr, fini);
+       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
+
+       fence = tbm_sync_fence_create(td, "test", 0);
+       FAIL_NE_GOTO(fence, -1, fini);
+
+       wayland_tbm_client_set_sync_timeline(wl_tbm_client, wl_buf, td);
+       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
+
+       wl_tbm_test_timeline_increase(wl_tbm_test, wl_buf);
+       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
+
+       FAIL_EQ_GOTO(tbm_sync_fence_wait(fence, 1), 1, fini);
+
+fini:
+       if (wl_buf)
+               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+
+       if (tbm_surf)
+               tbm_surface_destroy(tbm_surf);
+
+       if (fence != -1)
+               close(fence);
+
+       if (td != -1)
+               close(td);
+}
+
+TEST_F(UtWlTbm, SyncWaitByTime)
+{
+       tbm_fd td = -1, fence = -1;
+       tbm_surface_h tbm_surf = nullptr;
+       struct wl_buffer *wl_buf = nullptr;
+       int cnt = 0, ret;
+
+       td = tbm_sync_timeline_create();
+       if (td == -1) {
+               ASSERT_EQ(td, -1);
+               printf("do not support sync\n");
+               goto fini;
+       }
+
+       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
+       FAIL_NE_GOTO(tbm_surf, nullptr, fini);
+
+       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
+       FAIL_NE_GOTO(wl_buf, nullptr, fini);
+       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
+
+       fence = tbm_sync_fence_create(td, "test", 10);
+       FAIL_NE_GOTO(fence, -1, fini);
+
+       wayland_tbm_client_set_sync_timeline(wl_tbm_client, wl_buf, td);
+       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
+
+       while(cnt < 20) {
+               ret = tbm_sync_fence_wait(fence, 1);
+
+               if (ret == 1) {
+                       break;
+               } else if (ret == -1) {
+                       printf("increase cnt to %d\n", ++cnt);
+                       wl_tbm_test_timeline_increase(wl_tbm_test, wl_buf);
+                       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
+                       continue;
+               } else {
+                       break;
+               }
+       }
+
+       FAIL_EQ_GOTO(ret, 1, fini);
+
+fini:
+       if (wl_buf)
+               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+       if (tbm_surf)
+               tbm_surface_destroy(tbm_surf);
+       if (fence != -1)
+               close(fence);
+       if (td != -1)
+               close(td);
+}
+
diff --git a/utests/Makefile.am b/utests/Makefile.am
deleted file mode 100644 (file)
index 9132673..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-bin_PROGRAMS = wayland-tbm-utests
-
-wayland_tbm_utests_CXXFLAGS = \
-       $(CXXFLAGS) \
-       $(WL_TBM_COMMON_CFLAGS) \
-       $(WL_TBM_CLIENT_CFLAGS) \
-       $(WL_TBM_SERVER_CFLAGS) \
-       -I../src \
-       -I./ \
-       -I$(includedir)/gtest \
-       -fpermissive
-
-# The flag -w is used, because there are many warnings in wayland-tbm sources.
-# Warnings occur because we build project with g++.
-# In C++ we need to use explicit types conversion.
-
-wayland_tbm_utests_LDFLAGS = \
-       ${LDFLAGS} \
-       $(WL_TBM_COMMON_LIBS) \
-       $(WL_TBM_CLIENT_LIBS) \
-       $(WL_TBM_SERVER_LIBS) \
-       $(top_builddir)/src/libwayland-tbm-client.la \
-       $(top_builddir)/src/libwayland-tbm-server.la \
-       -lgtest
-
-wayland_tbm_utests_SOURCES = \
-       src/ut_main.cpp \
-       src/ut_base.cpp \
-       src/ut_wayland_tbm.cpp
-
-check:
-       ./wayland-tbm-utests
diff --git a/utests/src/ut_base.cpp b/utests/src/ut_base.cpp
deleted file mode 100644 (file)
index 319d086..0000000
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
-Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
-
-Contact:
-      SooChan Lim <sc1.lim@samsung.com>,
-      Sangjin Lee <lsj119@samsung.com>,
-      Boram Park <boram1288.park@samsung.com>,
-      Changyeon Lee <cyeon.lee@samsung.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-*/
-#include "gtest/gtest.h"
-#include "ut_base.h"
-#include "wayland-tbm-server.h"
-#include "wayland-tbm-test-server-protocol.h"
-#include "wayland-tbm-int.h"
-
-typedef struct
-{
-       struct wl_display *wl_disp;
-       struct wayland_tbm_server *wl_tbm_server;
-       struct wl_global *wl_tbm_test;
-
-       struct wl_listener client_add_cb;
-       struct wl_listener client_destroy_cb;
-} wlt_server_t;
-
-typedef struct
-{
-       struct wl_resource *test;
-       struct wl_resource *buffer;
-       struct wl_listener buf_destroy_cb;
-       uint32_t is_active;
-
-       struct wl_list export_bufs;
-} wlt_surface;
-
-wlt_server_t wlt_server;
-
-static void
-_res_wl_tbm_test_buffer_destroy(struct wl_listener *listener, void *data)
-{
-       wlt_surface *wlt_surf = wl_container_of(listener, wlt_surf, buf_destroy_cb);
-       wlt_surf->buffer = nullptr;
-}
-
-static void
-_res_wl_tbm_test_surface_destroy(struct wl_resource *res)
-{
-       wlt_surface *wlt_surf = (wlt_surface *)wl_resource_get_user_data(res);
-       if (wlt_surf->buffer)
-       {
-               wl_list_remove(&wlt_surf->buf_destroy_cb.link);
-       }
-       free(wlt_surf);
-}
-
-static void
-_wl_tbm_test_surface_destroy(struct wl_client *client,
-                       struct wl_resource *resource)
-{
-       wl_resource_destroy(resource);
-}
-
-static void
-_wl_tbm_test_surface_attach(struct wl_client *client,
-                      struct wl_resource *resource,
-                      struct wl_resource *buffer,
-                      int32_t x,
-                      int32_t y)
-{
-       wlt_surface *wlt_surf = (wlt_surface *)wl_resource_get_user_data(resource);
-       tbm_surface_h tbm_buf;
-
-       if (wlt_surf->buffer == buffer)
-       {
-               wl_tbm_test_send_error(wlt_surf->test, resource, WL_TBM_TEST_ERROR_INVALID_OBJECT, "attach the same buffer");
-               return;
-       }
-
-       if (buffer) {
-               tbm_buf = wayland_tbm_server_get_surface(wlt_server.wl_tbm_server, buffer);
-               if (tbm_buf == nullptr)
-               {
-                       wl_tbm_test_send_error(wlt_surf->test, resource, WL_TBM_TEST_ERROR_INVALID_OBJECT, "The buffer is invalid");
-                       return;
-               }
-
-               wl_resource_add_destroy_listener(buffer, &wlt_surf->buf_destroy_cb);
-       }
-
-       if (wlt_surf->buffer)
-       {
-               wl_buffer_send_release(wlt_surf->buffer);
-               wl_list_remove(&wlt_surf->buf_destroy_cb.link);
-       }
-
-       wlt_surf->buffer = buffer;
-}
-
-static void
-_wl_tbm_test_surface_damage(struct wl_client *client,
-                      struct wl_resource *resource,
-                      int32_t x,
-                      int32_t y,
-                      int32_t width,
-                      int32_t height)
-{
-}
-
-static void
-_wl_tbm_test_surface_frame(struct wl_client *client,
-                     struct wl_resource *resource,
-                     uint32_t callback)
-{
-}
-
-static void
-_wl_tbm_test_surface_set_opaque_region(struct wl_client *client,
-                                 struct wl_resource *resource,
-                                 struct wl_resource *region)
-{
-}
-
-static void
-_wl_tbm_test_surface_set_input_region(struct wl_client *client,
-                                struct wl_resource *resource,
-                                struct wl_resource *region)
-{
-}
-
-static void
-_wl_tbm_test_surface_commit(struct wl_client *client,
-                      struct wl_resource *resource)
-{
-}
-
-static void
-_wl_tbm_test_surface_set_buffer_transform(struct wl_client *client,
-                                    struct wl_resource *resource,
-                                    int32_t transform)
-{
-}
-
-static void
-_wl_tbm_test_surface_set_buffer_scale(struct wl_client *client,
-                                struct wl_resource *resource,
-                                int32_t scale)
-{
-}
-
-static void
-_wl_tbm_test_surface_damage_buffer(struct wl_client *client,
-                             struct wl_resource *resource,
-                             int32_t x,
-                             int32_t y,
-                             int32_t width,
-                             int32_t height)
-{
-}
-
-static const struct wl_surface_interface wl_tbm_test_surface_impl = {
-       _wl_tbm_test_surface_destroy,
-       _wl_tbm_test_surface_attach,
-       _wl_tbm_test_surface_damage,
-       _wl_tbm_test_surface_frame,
-       _wl_tbm_test_surface_set_opaque_region,
-       _wl_tbm_test_surface_set_input_region,
-       _wl_tbm_test_surface_commit,
-       _wl_tbm_test_surface_set_buffer_transform,
-       _wl_tbm_test_surface_set_buffer_scale,
-       _wl_tbm_test_surface_damage_buffer
-};
-
-static void
-_res_wl_tbm_test_destroy(struct wl_resource *res)
-{
-}
-
-static void
-_wl_tbm_test_destroy(struct wl_client *client, struct wl_resource *resource)
-{
-       wl_resource_destroy(resource);
-}
-
-static void
-_wl_tbm_test_create_surface(struct wl_client *client, struct wl_resource *resource, uint32_t surface)
-{
-       struct wl_resource *res;
-       wlt_surface *wlt_surf;
-
-       res = wl_resource_create(client, &wl_surface_interface, 1, surface);
-       if (!res)
-               exit(-1);
-
-       wlt_surf = (wlt_surface *)calloc(1, sizeof(wlt_surface));
-       if (!wlt_surf)
-               exit(-1);
-
-       wlt_surf->test = resource;
-       wlt_surf->buffer = (wl_resource *)nullptr;
-       wlt_surf->buf_destroy_cb.notify = _res_wl_tbm_test_buffer_destroy;
-
-       wl_resource_set_implementation(res, &wl_tbm_test_surface_impl, wlt_surf, _res_wl_tbm_test_surface_destroy);
-       wl_list_init(&wlt_surf->export_bufs);
-}
-
-static void
-_wl_tbm_test_server_surface_destroy_cb(tbm_surface_h surface, void *data)
-{
-       tbm_surface_destroy(surface);
-}
-
-static void
-_wl_tbm_test_server_surface_detach_cb(struct wayland_tbm_client_queue *cqueue, tbm_surface_h surface, void *data)
-{
-
-}
-
-static void
-_wl_tbm_test_queue_dequeue_cb(struct wayland_tbm_client_queue *queue, tbm_surface_h surface, void *data)
-{
-
-}
-
-static void
-_wl_tbm_test_set_active(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface,
-                                       uint32_t active,
-                                       uint32_t usage,
-                                       uint32_t queue_size,
-                                       uint32_t need_flush)
-{
-       wlt_surface *wlt_surf;
-       wayland_tbm_client_queue *wlt_queue;
-       tbm_surface_h tbm_surf;
-       struct wl_resource *wl_buf;
-
-       wlt_queue = wayland_tbm_server_client_queue_get(wlt_server.wl_tbm_server, surface);
-       if (!wlt_queue) {
-               wl_tbm_test_send_error(resource, surface, WL_TBM_TEST_ERROR_INVALID_OBJECT, "active: invalid surface");
-               return;
-       }
-
-       wlt_surf = (wlt_surface*)wl_resource_get_user_data(surface);
-       if (wlt_surf->is_active == active)
-               return;
-
-       wlt_surf->is_active = active;
-       if (active) {
-               uint32_t i = 0;
-               wayland_tbm_server_client_queue_set_dequeue_cb(wlt_queue, _wl_tbm_test_queue_dequeue_cb, wlt_surf);
-
-               while (i < queue_size) {
-                       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-                       if (i == 0)
-                               wl_buf = wayland_tbm_server_client_queue_export_buffer(wlt_queue, tbm_surf, 0xFF,
-                                               _wl_tbm_test_server_surface_destroy_cb, nullptr);
-                       else
-                               wl_buf = wayland_tbm_server_client_queue_export_buffer2(wlt_queue, tbm_surf, 0xFF,
-                                               _wl_tbm_test_server_surface_detach_cb,
-                                               _wl_tbm_test_server_surface_destroy_cb,
-                                               nullptr);
-                       wl_list_insert(&wlt_surf->export_bufs, wl_resource_get_link(wl_buf));
-                       wayland_tbm_server_client_queue_send_buffer_usable(wlt_queue, wl_buf);
-                       i++;
-               }
-
-               wayland_tbm_server_client_queue_activate(wlt_queue, usage, queue_size, need_flush);
-       } else {
-               wayland_tbm_server_client_queue_deactivate(wlt_queue);
-       }
-
-       wl_client_flush(client);
-}
-
-static void
-_wl_tbm_test_queue_flush(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface)
-{
-       struct wayland_tbm_client_queue *queue;
-
-       queue = wayland_tbm_server_client_queue_get(wlt_server.wl_tbm_server, surface);
-       if (!queue) {
-               wl_tbm_test_send_error(resource, surface, WL_TBM_TEST_ERROR_INVALID_OBJECT, "flush: invalid surface");
-               return;
-       }
-
-       wayland_tbm_server_client_queue_flush(queue);
-}
-
-static void
-_wl_tbm_test_check_buffer(struct wl_client *client, struct wl_resource *resource, struct wl_resource *buffer,
-                                       uint32_t property,
-                                       uint32_t value)
-{
-       tbm_surface_h tbm_surf;
-       tbm_surface_info_s info;
-       int ret;
-
-       tbm_surf = wayland_tbm_server_get_surface(wlt_server.wl_tbm_server, buffer);
-       if (!tbm_surf) {
-               wl_tbm_test_send_error(resource, buffer, WL_TBM_TEST_ERROR_INVALID_OBJECT, "Check_buffer: invalid buffer");
-               return;
-       }
-
-       ret = tbm_surface_get_info(tbm_surf, &info);
-       if (ret != TBM_SURFACE_ERROR_NONE) {
-               wl_tbm_test_send_error(resource, buffer, WL_TBM_TEST_ERROR_INVALID_OBJECT, "Check_buffer: failed get surface info");
-               return;
-       }
-
-       switch(property) {
-       case WL_TBM_TEST_PROP_BUFFER_WIDTH:
-               if (value != info.width) goto prop_error;
-               break;
-       case WL_TBM_TEST_PROP_BUFFER_HEIGHT:
-               if (value != info.height) goto prop_error;
-               break;
-       case WL_TBM_TEST_PROP_BUFFER_FORMAT:
-               if (value != info.format) goto prop_error;
-               break;
-       case WL_TBM_TEST_PROP_BUFFER_NUM_PALNE:
-               if (value != info.num_planes) goto prop_error;
-               break;
-       case WL_TBM_TEST_PROP_BUFFER_TRANSFORM:
-               if (value != (uint32_t)wayland_tbm_server_buffer_get_buffer_transform(wlt_server.wl_tbm_server, buffer))
-                       goto prop_error;
-               break;
-       case WL_TBM_TEST_PROP_BUFFER_FLAG:
-               if (value != wayland_tbm_server_get_buffer_flags(wlt_server.wl_tbm_server, buffer))
-                       goto prop_error;
-               break;
-       default:
-               break;
-       }
-
-       return;
-prop_error:
-       wl_tbm_test_send_error(resource, buffer, WL_TBM_TEST_ERROR_INVALID_OBJECT, "Check_buffer: wrong value");
-}
-
-static void
-_wl_tbm_test_destroy_queue_buffer(struct wl_client *client, struct wl_resource *resource, struct wl_resource *wl_tbm, struct wl_resource *surface)
-{
-       wlt_surface *wlt_surf;
-       struct wl_resource *wl_buf, *tmp;
-
-       wlt_surf = (wlt_surface*)wl_resource_get_user_data(surface);
-       wl_resource_for_each_safe(wl_buf, tmp, &wlt_surf->export_bufs) {
-               wl_list_remove(wl_resource_get_link(wl_buf));
-               wayland_tbm_server_send_destroy_buffer(wl_tbm, wl_buf);
-       }
-
-       wl_client_flush(client);
-}
-
-static void
-_wl_tbm_test_timeline_increase(struct wl_client *client, struct wl_resource *resource, struct wl_resource *buffer)
-{
-       if (!wayland_tbm_server_buffer_has_sync_timeline(wlt_server.wl_tbm_server, buffer)) {
-               wl_tbm_test_send_error(resource, buffer, WL_TBM_TEST_ERROR_INVALID_OBJECT, "timeline: no timeline");
-               wl_client_flush(client);
-               return;
-       }
-
-       wayland_tbm_server_increase_buffer_sync_timeline(wlt_server.wl_tbm_server, buffer, 1);
-       wl_client_flush(client);
-}
-
-static const struct wl_tbm_test_interface wl_tbm_test_impl = {
-       _wl_tbm_test_destroy,
-       _wl_tbm_test_create_surface,
-       _wl_tbm_test_set_active,
-       _wl_tbm_test_queue_flush,
-       _wl_tbm_test_check_buffer,
-       _wl_tbm_test_destroy_queue_buffer,
-       _wl_tbm_test_timeline_increase
-};
-
-static void
-_wl_tbm_test_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id)
-{
-       struct wl_resource *res;
-
-       res = wl_resource_create(client, &wl_tbm_test_interface, version, id);
-       if (!res)
-               exit(-1);
-       wl_resource_set_implementation(res, &wl_tbm_test_impl, data, _res_wl_tbm_test_destroy);
-}
-
-static void
-_wl_tbm_test_client_add_cb(struct wl_listener *listener, void *data)
-{
-       struct wl_client *client = (struct wl_client*) data;
-       wl_client_add_destroy_listener(client, &wlt_server.client_destroy_cb);
-}
-
-static void
-_wl_tbm_test_client_destory_cb(struct wl_listener *listener, void *data)
-{
-       wayland_tbm_server_deinit(wlt_server.wl_tbm_server);
-       wlt_server.wl_tbm_server = nullptr;
-
-       wl_display_terminate(wlt_server.wl_disp);
-}
-
-#ifdef TIZEN_TEST_GCOV
-extern "C" void __gcov_flush(void);
-#endif
-
-int
-launch_server(void)
-{
-       int pid;
-
-       pid = fork();
-       if (pid != 0)
-               return pid;
-
-#ifdef TIZEN_TEST_GCOV
-       setenv("GCOV_PREFIX", "/tmp", 1);
-#endif
-       unsetenv("WAYLAND_DEBUG");
-
-       wlt_server.wl_disp = wl_display_create();
-       if (!wlt_server.wl_disp)
-               exit(-1);
-
-       if (wl_display_add_socket(wlt_server.wl_disp, "ut_wayland_tbm"))
-               exit(-1);
-
-       wlt_server.wl_tbm_server = wayland_tbm_server_init(wlt_server.wl_disp, NULL, -1, 0);
-       if (!wlt_server.wl_tbm_server)
-               exit(-1);
-
-       if (!wayland_tbm_server_get_bufmgr(wlt_server.wl_tbm_server))
-               exit(-1);
-
-       wlt_server.client_add_cb.notify = _wl_tbm_test_client_add_cb;
-       wlt_server.client_destroy_cb.notify = _wl_tbm_test_client_destory_cb;
-       wl_display_add_client_created_listener(wlt_server.wl_disp, &wlt_server.client_add_cb);
-
-       wlt_server.wl_tbm_test = wl_global_create(wlt_server.wl_disp,
-                                                                                         &wl_tbm_test_interface,
-                                                                                         1,
-                                                                                         &wlt_server,
-                                                                                         _wl_tbm_test_bind_cb);
-       if (!wlt_server.wl_tbm_test)
-               exit(-1);
-
-       wl_display_run(wlt_server.wl_disp);
-
-       wl_display_destroy(wlt_server.wl_disp);
-#ifdef TIZEN_TEST_GCOV
-       __gcov_flush();
-#endif
-       exit(0);
-
-       return pid;
-}
-
-void
-kill_server(int pid)
-{
-       printf("[Client] Pre kill Server(%d)\n", pid);
-       kill(pid, SIGINT);
-       printf("[Client] Post kill Server(%d)\n", pid);
-}
\ No newline at end of file
diff --git a/utests/src/ut_base.h b/utests/src/ut_base.h
deleted file mode 100644 (file)
index 9f94df2..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#define WL_HIDE_DEPRECATED
-#include "gtest/gtest.h"
-
-#define FAIL_NE_GOTO(con1, con2, to)   \
-       do {                                            \
-               if ((con1) == (con2)) { \
-                       ADD_FAILURE();          \
-                       goto to;                        \
-               }                                               \
-       } while(0)
-
-
-#define FAIL_EQ_GOTO(con1, con2, to)   \
-                       do {                                            \
-                               if ((con1) != (con2)) { \
-                                       ADD_FAILURE();          \
-                                       goto to;                        \
-                               }                                               \
-                       } while(0)
-
-extern int launch_server(void);
-extern void kill_server(int pid);
-
diff --git a/utests/src/ut_main.cpp b/utests/src/ut_main.cpp
deleted file mode 100644 (file)
index 4112179..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
-
-Contact:
-      SooChan Lim <sc1.lim@samsung.com>,
-      Sangjin Lee <lsj119@samsung.com>,
-      Boram Park <boram1288.park@samsung.com>,
-      Changyeon Lee <cyeon.lee@samsung.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-*/
-
-#include "gtest/gtest.h"
-
-#ifdef TIZEN_TEST_GCOV
-extern "C" void __gcov_flush(void);
-#endif
-
-int main(int argc, char **argv)
-{
-       auto AllTestSuccess = false;
-
-#ifdef TIZEN_TEST_GCOV
-       setenv("GCOV_PREFIX", "/tmp", 1);
-#endif
-
-       try {
-               ::testing::InitGoogleTest(&argc, argv);
-               ::testing::FLAGS_gtest_death_test_style = "fast";
-       } catch ( ... ) {
-               std::cout << "error while trying to init google tests.\n";
-               exit(EXIT_FAILURE);
-       }
-
-       try {
-               AllTestSuccess = RUN_ALL_TESTS() == 0 ? true : false;
-       } catch (const ::testing::internal::GoogleTestFailureException & e) {
-               AllTestSuccess = false;
-               std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
-               std::cout << "\n";
-       }
-
-#ifdef TIZEN_TEST_GCOV
-       __gcov_flush();
-#endif
-
-       return AllTestSuccess;
-}
\ No newline at end of file
diff --git a/utests/src/ut_wayland_tbm.cpp b/utests/src/ut_wayland_tbm.cpp
deleted file mode 100644 (file)
index 928a9f1..0000000
+++ /dev/null
@@ -1,964 +0,0 @@
-/*
-Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
-
-Contact:
-      SooChan Lim <sc1.lim@samsung.com>,
-      Sangjin Lee <lsj119@samsung.com>,
-      Boram Park <boram1288.park@samsung.com>,
-      Changyeon Lee <cyeon.lee@samsung.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-*/
-#define WL_HIDE_DEPRECATED
-#include "gtest/gtest.h"
-#include "ut_base.h"
-#include <wayland-client.h>
-#include <tbm_surface.h>
-#include <tbm_surface_queue.h>
-extern "C" {
-#include <tbm_sync.h>
-}
-#include "wayland-tbm-client.h"
-#include "wayland-tbm-int.h"
-#include "wayland-tbm-client-protocol.h"
-#include "wayland-tbm-test-client-protocol.h"
-
-class UtWlTbm : public ::testing::Test
-{
-  protected:
-       static void SetUpTestCase();
-       static void TearDownTestCase();
-       void SetUp();
-       void TearDown();
-       static int CheckServerError();
-
-  public:
-       static int server_error;
-       static int server_pid;
-       static int monitor_done;
-       static struct wl_display *wl_disp;
-       static struct wayland_tbm_client *wl_tbm_client;
-       static struct wl_tbm_test *wl_tbm_test;
-       static struct wl_tbm_monitor *wl_tbm_monitor;
-
-       static UtWlTbm *resolve(void *data) { return static_cast<UtWlTbm *>(data); }
-       static void wlt_test_error_cb(void *data, struct wl_tbm_test *wl_tbm_test, void *object, uint32_t code, const char *message);
-       static const struct wl_tbm_test_listener wlt_test_listener;
-
-       static void wlt_reg_handle_global_cb(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version);
-       static const struct wl_registry_listener wlt_reg_listener;
-
-       static void wlt_monitor_done_cb(void *data, struct wl_tbm_monitor *wl_tbm_monitor, const char *message);
-       static void wlt_monitor_request_to_client_cb(void *data, struct wl_tbm_monitor *wl_tbm_monitor,
-                                               const char *options, const char *request_id);
-       static const struct wl_tbm_monitor_listener wlt_monitor_listener;
-
-       static void wlt_queue_buffer_release_cb(void *data, struct wl_buffer *wl_buffer);
-       static const struct wl_buffer_listener wlt_queue_buffer_listener;
-
-       static void SendMonitorCmd(const char *cmd);
-};
-
-int UtWlTbm::server_error = 0;
-int UtWlTbm::server_pid = -1;
-int UtWlTbm::monitor_done = 0;
-struct wl_display *UtWlTbm::wl_disp = nullptr;
-struct wayland_tbm_client *UtWlTbm::wl_tbm_client = nullptr;
-struct wl_tbm_test *UtWlTbm::wl_tbm_test = nullptr;
-struct wl_tbm_monitor *UtWlTbm::wl_tbm_monitor = nullptr;
-
-const struct wl_tbm_test_listener UtWlTbm::wlt_test_listener =
-{
-       UtWlTbm::wlt_test_error_cb
-};
-
-const struct wl_registry_listener UtWlTbm::wlt_reg_listener =
-{
-       UtWlTbm::wlt_reg_handle_global_cb
-};
-
-const struct wl_tbm_monitor_listener UtWlTbm::wlt_monitor_listener =
-{
-       UtWlTbm::wlt_monitor_done_cb,
-       UtWlTbm::wlt_monitor_request_to_client_cb
-};
-
-const struct wl_buffer_listener UtWlTbm::wlt_queue_buffer_listener = {
-       UtWlTbm::wlt_queue_buffer_release_cb
-};
-
-void UtWlTbm::wlt_test_error_cb(void *data,
-                                                               struct wl_tbm_test *wl_tbm_test,
-                                                               void *object, uint32_t code, const char *message)
-{
-       server_error = code;
-       printf("[ERROR: %p(id:%d), err:%d] %s\n", object, ((object) ? wl_proxy_get_id((struct wl_proxy *)object) : -1), code, message);
-}
-
-void UtWlTbm::wlt_reg_handle_global_cb(void *data,
-                                                                          struct wl_registry *registry, uint32_t name,
-                                                                          const char *interface, uint32_t version)
-{
-       if (!strncmp(interface, "wl_tbm_test", 11))
-       {
-               UtWlTbm::wl_tbm_test = (struct wl_tbm_test *)wl_registry_bind(registry, name, &wl_tbm_test_interface, version);
-               wl_tbm_test_add_listener(UtWlTbm::wl_tbm_test, &wlt_test_listener, data);
-       } else if (!strncmp(interface, "wl_tbm_monitor", 14)) {
-               UtWlTbm::wl_tbm_monitor = (struct wl_tbm_monitor *)wl_registry_bind(registry, name, &wl_tbm_monitor_interface, version);
-               wl_tbm_monitor_add_listener(UtWlTbm::wl_tbm_monitor, &wlt_monitor_listener, data);
-       }
-}
-
-void
-UtWlTbm::wlt_monitor_done_cb(void *data, struct wl_tbm_monitor *wl_tbm_monitor, const char *message)
-{
-       UtWlTbm::monitor_done = 1;
-       printf("%s", message);
-}
-
-void
-UtWlTbm::wlt_monitor_request_to_client_cb(void *data, struct wl_tbm_monitor *wl_tbm_monitor,
-                                               const char *options, const char *request_id)
-{
-       const char *message = "\n";
-
-       wl_tbm_monitor_responce_to_server(UtWlTbm::wl_tbm_monitor, message, request_id);
-}
-
-void UtWlTbm::SetUpTestCase()
-{
-       int cnt = 0;
-       struct wl_registry *wl_reg = nullptr;
-
-       server_pid = launch_server();
-       ASSERT_NE(server_pid, -1);
-       sleep(1);
-
-       do
-       {
-               wl_disp = wl_display_connect("ut_wayland_tbm");
-               if (wl_disp == nullptr)
-               {
-                       usleep(1000);
-                       printf("Wait... connect to server\n");
-               }
-       } while (wl_disp == nullptr && cnt++ < 10);
-       ASSERT_NE(wl_disp, nullptr);
-
-       wl_tbm_client = wayland_tbm_client_init(wl_disp);
-       ASSERT_NE(wl_tbm_client, nullptr);
-
-       wl_reg = wl_display_get_registry(wl_disp);
-       wl_registry_add_listener(wl_reg, &UtWlTbm::wlt_reg_listener, nullptr);
-       wl_display_roundtrip(wl_disp);
-       wl_registry_destroy(wl_reg);
-}
-
-void UtWlTbm::TearDownTestCase()
-{
-       if (wl_tbm_monitor) {
-               wl_tbm_monitor_destroy(wl_tbm_monitor);
-               wl_tbm_monitor = nullptr;
-       }
-
-       if (wl_tbm_client) {
-               wayland_tbm_client_deinit(wl_tbm_client);
-               wl_tbm_client = nullptr;
-       }
-
-       if (wl_tbm_test) {
-               wl_tbm_test_destroy(wl_tbm_test);
-               wl_tbm_test = nullptr;
-       }
-
-       wl_display_roundtrip(wl_disp);
-       wl_display_disconnect(wl_disp);
-}
-
-void UtWlTbm::SetUp()
-{
-}
-
-void UtWlTbm::TearDown()
-{
-}
-
-int UtWlTbm::CheckServerError()
-{
-       UtWlTbm::server_error = 0;
-       wl_display_roundtrip(UtWlTbm::wl_disp);
-
-       return UtWlTbm::server_error;
-}
-
-void UtWlTbm::SendMonitorCmd(const char *cmd)
-{
-       int ret;
-
-       UtWlTbm::monitor_done = 0;
-       wl_tbm_monitor_request_to_sever(wl_tbm_monitor, cmd);
-       ASSERT_EQ(CheckServerError(), 0);
-       while(!UtWlTbm::monitor_done) {
-               ret = wl_display_dispatch(UtWlTbm::wl_disp);
-               ASSERT_NE(ret, -1);
-       }
-}
-
-void UtWlTbm::wlt_queue_buffer_release_cb(void *data, struct wl_buffer *wl_buffer)
-{
-       tbm_surface_queue_h queue = (tbm_surface_queue_h)data;
-       tbm_surface_h surface = (tbm_surface_h)wl_buffer_get_user_data(wl_buffer);
-
-       wayland_tbm_client_destroy_buffer(UtWlTbm::wl_tbm_client, wl_buffer);
-       tbm_surface_queue_release(queue, surface);
-}
-
-TEST_F(UtWlTbm, GetBufMgr)
-{
-       void *bufmgr = nullptr;
-       ASSERT_NE(wl_tbm_client, nullptr);
-
-       bufmgr = wayland_tbm_client_get_bufmgr(wl_tbm_client);
-       ASSERT_NE(bufmgr, nullptr);
-}
-
-TEST_F(UtWlTbm, GetBufMgrFail)
-{
-       void *bufmgr = nullptr;
-
-       bufmgr = wayland_tbm_client_get_bufmgr(nullptr);
-       ASSERT_EQ(bufmgr, nullptr);
-}
-
-TEST_F(UtWlTbm, GetWlTbm)
-{
-       struct wl_tbm *wl_tbm;
-
-       wl_tbm = wayland_tbm_client_get_wl_tbm(wl_tbm_client);
-       ASSERT_NE(wl_tbm, nullptr);
-       ASSERT_NE(wl_tbm_get_user_data(wl_tbm), nullptr);
-}
-
-TEST_F(UtWlTbm, SetEventQueue)
-{
-       struct wl_event_queue *queue;
-
-       queue = wl_display_create_queue(wl_disp);
-       ASSERT_NE(queue, nullptr);
-
-       ASSERT_EQ(wayland_tbm_client_set_event_queue(wl_tbm_client, queue), 1);
-       wl_event_queue_destroy(queue);
-       ASSERT_EQ(wayland_tbm_client_set_event_queue(wl_tbm_client, nullptr), 1);
-}
-
-TEST_F(UtWlTbm, BufCreate)
-{
-       tbm_surface_h tbm_surf;
-       struct wl_buffer *wl_buf;
-       int ret;
-
-       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-       ASSERT_NE(tbm_surf, nullptr);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       ASSERT_NE(wl_buf, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       ret = tbm_surface_destroy(tbm_surf);
-       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
-}
-
-TEST_F(UtWlTbm, BufCreateTwice)
-{
-       tbm_surface_h tbm_surf;
-       struct wl_buffer *wl_buf, *wl_buf2;
-       int ret;
-
-       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-       ASSERT_NE(tbm_surf, nullptr);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       ASSERT_NE(wl_buf, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_buf2 = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       ASSERT_NE(wl_buf, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       ASSERT_NE(wl_buf, wl_buf2);
-
-       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf2);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       ret = tbm_surface_destroy(tbm_surf);
-       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
-}
-
-TEST_F(UtWlTbm, ButCreateNull)
-{
-       struct wl_buffer *wl_buf;
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, (tbm_surface_h)nullptr);
-       ASSERT_EQ(wl_buf, nullptr);
-       if (wl_buf)
-               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-
-       wl_buf = wayland_tbm_client_create_buffer(nullptr, nullptr);
-       ASSERT_EQ(wl_buf, nullptr);
-       if (wl_buf)
-               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-}
-
-TEST_F(UtWlTbm, BufDestroyNull)
-{
-       wayland_tbm_client_destroy_buffer(wl_tbm_client, (wl_buffer*)nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wayland_tbm_client_destroy_buffer((wayland_tbm_client*)nullptr, (wl_buffer*)nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufTransform)
-{
-       tbm_surface_h tbm_surf;
-       struct wl_buffer *wl_buf;
-       int ret;
-
-       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-       ASSERT_NE(tbm_surf, nullptr);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       ASSERT_NE(wl_buf, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wayland_tbm_client_set_buffer_transform(wl_tbm_client, wl_buf, 5);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_tbm_test_check_buffer(wl_tbm_test, wl_buf, WL_TBM_TEST_PROP_BUFFER_TRANSFORM, 5);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       ret = tbm_surface_destroy(tbm_surf);
-       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
-}
-
-TEST_F(UtWlTbm, BufCheckFlag)
-{
-       tbm_surface_h tbm_surf;
-       struct wl_buffer *wl_buf;
-       int ret;
-
-       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-       ASSERT_NE(tbm_surf, nullptr);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       ASSERT_NE(wl_buf, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_tbm_test_check_buffer(wl_tbm_test, wl_buf, WL_TBM_TEST_PROP_BUFFER_FLAG, 0);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       ret = tbm_surface_destroy(tbm_surf);
-       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
-}
-
-TEST_F(UtWlTbm, BufAttach)
-{
-       tbm_surface_h tbm_surf;
-       struct wl_buffer *wl_buf;
-       struct wl_surface *wlt_surface;
-       int ret;
-
-       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-       ASSERT_NE(tbm_surf, nullptr);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       ASSERT_NE(wl_buf, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_surface_attach(wlt_surface, wl_buf, 0, 0);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       ret = tbm_surface_destroy(tbm_surf);
-       ASSERT_EQ(ret, TBM_SURFACE_ERROR_NONE);
-
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueCreateNull)
-{
-       tbm_surface_queue_h tbm_queue;
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, nullptr, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_EQ(tbm_queue, nullptr);
-}
-
-TEST_F(UtWlTbm, BufQueueCreate)
-{
-       tbm_surface_queue_h tbm_queue;
-       struct wl_surface *wlt_surface;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-}
-
-TEST_F(UtWlTbm, BufQueueGetTbmQueue)
-{
-       tbm_surface_queue_h tbm_queue;
-       struct wl_surface *wlt_surface;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-       ASSERT_NE(wayland_tbm_client_get_wl_tbm_queue(wl_tbm_client, wlt_surface), nullptr);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueGetSurfaces)
-{
-       tbm_surface_queue_h tbm_queue;
-       struct wl_surface *wlt_surface;
-       int num_surf;
-       int ret;
-       tbm_surface_h surfaces[5];
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       ret = wayland_tbm_client_queue_get_surfaces(wl_tbm_client, tbm_queue, nullptr, &num_surf);
-       ASSERT_EQ(ret, 1);
-       ASSERT_EQ(num_surf, 3);
-
-       ret = wayland_tbm_client_queue_get_surfaces(wl_tbm_client, tbm_queue, surfaces, &num_surf);
-       ASSERT_EQ(ret, 1);
-       ASSERT_EQ(num_surf, 3);
-       for (int i=0; i < num_surf; i++)
-               ASSERT_NE(surfaces[i], nullptr);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueCheckActive)
-{
-       struct wl_surface *wlt_surface;
-       tbm_surface_queue_h tbm_queue;
-       int active;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
-       ASSERT_EQ(CheckServerError(), 0);
-       ASSERT_EQ(active, 0);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueActiveReq)
-{
-       struct wl_surface *wlt_surface;
-       tbm_surface_queue_h tbm_queue;
-       int active;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 1);
-       ASSERT_EQ(CheckServerError(), 0);
-       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
-       ASSERT_EQ(CheckServerError(), 0);
-       ASSERT_EQ(active, 1);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueActiveReqNoFlush)
-{
-       struct wl_surface *wlt_surface;
-       tbm_surface_queue_h tbm_queue;
-       int active;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 0);
-       ASSERT_EQ(CheckServerError(), 0);
-       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
-       ASSERT_EQ(CheckServerError(), 0);
-       ASSERT_EQ(active, 1);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueDeactiveReq)
-{
-       struct wl_surface *wlt_surface;
-       tbm_surface_queue_h tbm_queue;
-       int active;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 1);
-       ASSERT_EQ(CheckServerError(), 0);
-       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
-       ASSERT_EQ(CheckServerError(), 0);
-       ASSERT_EQ(active, 1);
-
-       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 0, 0, 0, 0);
-       ASSERT_EQ(CheckServerError(), 0);
-       active = wayland_tbm_client_queue_check_activate(wl_tbm_client, tbm_queue);
-       ASSERT_EQ(CheckServerError(), 0);
-       ASSERT_EQ(active, 0);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueBufDestroyReq)
-{
-       struct wl_surface *wlt_surface;
-       struct wl_tbm *wlt_tbm;
-       tbm_surface_queue_h tbm_queue;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 1);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wlt_tbm = wayland_tbm_client_get_wl_tbm(wl_tbm_client);
-       wl_tbm_test_destroy_queue_buffer(wl_tbm_test, wlt_tbm, wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueDequeue)
-{
-       struct wl_surface *wlt_surface;
-       tbm_surface_queue_h tbm_queue;
-       int i = 0;
-       tbm_surface_h tbm_surf;
-       tbm_surface_queue_error_e tbm_err;
-       struct wl_buffer *wl_buf;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ARGB8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_tbm_test_set_active(wl_tbm_test, wlt_surface, 1, 0, 3, 1);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       while (i < 3) {
-               if (tbm_surface_queue_can_dequeue(tbm_queue, 0)) {
-                       tbm_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surf);
-                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-                       ASSERT_EQ(CheckServerError(), 0);
-
-                       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-                       ASSERT_NE(wl_buf, nullptr);
-                       ASSERT_EQ(CheckServerError(), 0);
-
-                       wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-                       ASSERT_EQ(CheckServerError(), 0);
-               }
-               i++;
-       }
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueDequeueNotify)
-{
-       struct wl_surface *wlt_surface;
-       tbm_surface_queue_h tbm_queue;
-       int i = 0;
-       tbm_surface_h tbm_surf;
-       tbm_surface_queue_error_e tbm_err;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       while (i++ < 3) {
-               if (tbm_surface_queue_can_dequeue(tbm_queue, 1)) {
-                       tbm_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surf);
-                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-
-                       tbm_err = tbm_surface_queue_enqueue(tbm_queue, tbm_surf);
-                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-
-                       tbm_err = tbm_surface_queue_acquire(tbm_queue, &tbm_surf);
-                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-
-                       tbm_err = tbm_surface_queue_release(tbm_queue, tbm_surf);
-                       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-               }
-       }
-
-       wl_tbm_test_queue_flush(wl_tbm_test, wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueAttach)
-{
-       struct wl_surface *wlt_surface;
-       struct wl_buffer *wl_buf;
-
-       tbm_surface_queue_h tbm_queue;
-       tbm_surface_h tbm_surf;
-       tbm_surface_queue_error_e tbm_err;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surf);
-       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-
-       tbm_err = tbm_surface_queue_enqueue(tbm_queue, tbm_surf);
-       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-
-       tbm_err = tbm_surface_queue_acquire(tbm_queue, &tbm_surf);
-       ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       ASSERT_NE(wl_buf, nullptr);
-       wl_buffer_add_listener(wl_buf, &wlt_queue_buffer_listener, (void*)tbm_queue);
-       wl_surface_attach(wlt_surface, wl_buf, 0, 0);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       /*Make null attch for release*/
-       wl_surface_attach(wlt_surface, nullptr, 0, 0);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       wl_tbm_test_queue_flush(wl_tbm_test, wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, BufQueueFlush)
-{
-       struct wl_surface *wlt_surface;
-       tbm_surface_queue_h tbm_queue;
-       int i = 0;
-       tbm_surface_h tbm_surf;
-       tbm_surface_queue_error_e tbm_err;
-
-       wlt_surface = wl_tbm_test_create_surface(wl_tbm_test);
-       ASSERT_NE(wlt_surface, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 3, 100, 200, TBM_FORMAT_ABGR8888);
-       ASSERT_NE(tbm_queue, nullptr);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       while (i < 3) {
-               tbm_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surf);
-               ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-
-               tbm_err = tbm_surface_queue_enqueue(tbm_queue, tbm_surf);
-               ASSERT_EQ(tbm_err, TBM_SURFACE_QUEUE_ERROR_NONE);
-               i++;
-       }
-
-       wl_tbm_test_queue_flush(wl_tbm_test, wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-
-       tbm_surface_queue_destroy(tbm_queue);
-       wl_surface_destroy(wlt_surface);
-       ASSERT_EQ(CheckServerError(), 0);
-}
-
-TEST_F(UtWlTbm, MonitorHelp)
-{
-       SendMonitorCmd("");
-}
-
-TEST_F(UtWlTbm, MonitorList)
-{
-       SendMonitorCmd("-list");
-}
-
-TEST_F(UtWlTbm, MonitorShowAll)
-{
-       SendMonitorCmd("-show all");
-}
-
-TEST_F(UtWlTbm, MonitorShowServer)
-{
-       SendMonitorCmd("-show server");
-}
-
-TEST_F(UtWlTbm, MonitorShowClient)
-{
-       char msg[128];
-       int pid = getpid();
-
-       snprintf(msg, 127, "%s %d", "-show ", pid);
-       SendMonitorCmd(msg);
-}
-
-TEST_F(UtWlTbm, MonitorTraceOnOffAll)
-{
-       SendMonitorCmd("-trace on all");
-       SendMonitorCmd("-trace off all");
-}
-
-TEST_F(UtWlTbm, MonitorDumpSnapshot)
-{
-       SendMonitorCmd("-dump_snapshot all");
-}
-
-TEST_F(UtWlTbm, MonitorDumpQueue)
-{
-       SendMonitorCmd("-dump_queue on all");
-       SendMonitorCmd("-dump_queue off all");
-}
-
-TEST_F(UtWlTbm, SyncCreate)
-{
-       tbm_fd td = -1;
-       tbm_surface_h tbm_surf = nullptr;
-       struct wl_buffer *wl_buf = nullptr;
-
-       td = tbm_sync_timeline_create();
-       if (td == -1) {
-               ASSERT_EQ(td, -1);
-               printf("do not support sync\n");
-               goto fini;
-       }
-
-       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-       FAIL_NE_GOTO(tbm_surf, nullptr, fini);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       FAIL_NE_GOTO(wl_buf, nullptr, fini);
-       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
-
-       wayland_tbm_client_set_sync_timeline(wl_tbm_client, wl_buf, td);
-       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
-
-fini:
-       if (wl_buf)
-               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-
-       if (tbm_surf)
-               tbm_surface_destroy(tbm_surf);
-
-       if (td != -1)
-               close(td);
-}
-
-TEST_F(UtWlTbm, SyncWait)
-{
-       tbm_fd td = -1, fence = -1;
-       tbm_surface_h tbm_surf = nullptr;
-       struct wl_buffer *wl_buf = nullptr;
-
-       td = tbm_sync_timeline_create();
-       if (td == -1) {
-               ASSERT_EQ(td, -1);
-               printf("do not support sync\n");
-               goto fini;
-       }
-
-       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-       FAIL_NE_GOTO(tbm_surf, nullptr, fini);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       FAIL_NE_GOTO(wl_buf, nullptr, fini);
-       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
-
-       fence = tbm_sync_fence_create(td, "test", 0);
-       FAIL_NE_GOTO(fence, -1, fini);
-
-       wayland_tbm_client_set_sync_timeline(wl_tbm_client, wl_buf, td);
-       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
-
-       wl_tbm_test_timeline_increase(wl_tbm_test, wl_buf);
-       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
-
-       FAIL_EQ_GOTO(tbm_sync_fence_wait(fence, 1), 1, fini);
-
-fini:
-       if (wl_buf)
-               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-
-       if (tbm_surf)
-               tbm_surface_destroy(tbm_surf);
-
-       if (fence != -1)
-               close(fence);
-
-       if (td != -1)
-               close(td);
-}
-
-TEST_F(UtWlTbm, SyncWaitByTime)
-{
-       tbm_fd td = -1, fence = -1;
-       tbm_surface_h tbm_surf = nullptr;
-       struct wl_buffer *wl_buf = nullptr;
-       int cnt = 0, ret;
-
-       td = tbm_sync_timeline_create();
-       if (td == -1) {
-               ASSERT_EQ(td, -1);
-               printf("do not support sync\n");
-               goto fini;
-       }
-
-       tbm_surf = tbm_surface_create(100, 200, TBM_FORMAT_ARGB8888);
-       FAIL_NE_GOTO(tbm_surf, nullptr, fini);
-
-       wl_buf = wayland_tbm_client_create_buffer(wl_tbm_client, tbm_surf);
-       FAIL_NE_GOTO(wl_buf, nullptr, fini);
-       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
-
-       fence = tbm_sync_fence_create(td, "test", 10);
-       FAIL_NE_GOTO(fence, -1, fini);
-
-       wayland_tbm_client_set_sync_timeline(wl_tbm_client, wl_buf, td);
-       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
-
-       while(cnt < 20) {
-               ret = tbm_sync_fence_wait(fence, 1);
-
-               if (ret == 1) {
-                       break;
-               } else if (ret == -1) {
-                       printf("increase cnt to %d\n", ++cnt);
-                       wl_tbm_test_timeline_increase(wl_tbm_test, wl_buf);
-                       FAIL_EQ_GOTO(CheckServerError(), 0, fini);
-                       continue;
-               } else {
-                       break;
-               }
-       }
-
-       FAIL_EQ_GOTO(ret, 1, fini);
-
-fini:
-       if (wl_buf)
-               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
-       if (tbm_surf)
-               tbm_surface_destroy(tbm_surf);
-       if (fence != -1)
-               close(fence);
-       if (td != -1)
-               close(td);
-}
-