utest: add TCs for surface_queue 03/170103/3
authorSangjin.Lee <lsj119@samsung.com>
Tue, 13 Feb 2018 09:07:18 +0000 (18:07 +0900)
committerSangjin.Lee <lsj119@samsung.com>
Mon, 19 Feb 2018 04:43:46 +0000 (13:43 +0900)
Change-Id: Iaa929b01421dd54732f961faee4093f7dc973543

utests/src/ut_base.cpp
utests/src/ut_wayland_tbm.cpp

index e3ecfd8..35f5df6 100644 (file)
@@ -216,6 +216,18 @@ _wl_tbm_test_create_surface(struct wl_client *client, struct wl_resource *resour
 }
 
 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_set_active(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface,
                                        uint32_t active,
                                        uint32_t usage,
@@ -224,6 +236,8 @@ _wl_tbm_test_set_active(struct wl_client *client, struct wl_resource *resource,
 {
        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) {
@@ -236,10 +250,26 @@ _wl_tbm_test_set_active(struct wl_client *client, struct wl_resource *resource,
                return;
 
        wlt_surf->is_active = active;
-       if (active)
+       if (active) {
+               uint32_t i = 0;
+               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);
+                       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
+       } else {
                wayland_tbm_server_client_queue_deactivate(wlt_queue);
+       }
 
        wl_client_flush(client);
 }
index 3a76a68..e0e0b90 100644 (file)
@@ -177,6 +177,18 @@ TEST_F(UtWlTbm, GetWlTbm)
        ASSERT_NE(wayland_tbm_client_get_wl_tbm(wl_tbm_client), 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;
@@ -197,6 +209,33 @@ TEST_F(UtWlTbm, BufCreate)
        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;
@@ -363,7 +402,7 @@ TEST_F(UtWlTbm, BufQueueCheckActive)
        ASSERT_NE(wlt_surface, nullptr);
        ASSERT_EQ(CheckServerError(), 0);
 
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 2, 100, 200, TBM_FORMAT_ABGR8888);
+       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);
 
@@ -376,7 +415,7 @@ TEST_F(UtWlTbm, BufQueueCheckActive)
        ASSERT_EQ(CheckServerError(), 0);
 }
 
-TEST_F(UtWlTbm, BufQueueCheckActiveReq)
+TEST_F(UtWlTbm, BufQueueActiveReq)
 {
        struct wl_surface *wlt_surface;
        tbm_surface_queue_h tbm_queue;
@@ -386,7 +425,7 @@ TEST_F(UtWlTbm, BufQueueCheckActiveReq)
        ASSERT_NE(wlt_surface, nullptr);
        ASSERT_EQ(CheckServerError(), 0);
 
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 2, 100, 200, TBM_FORMAT_ABGR8888);
+       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);
 
@@ -401,7 +440,7 @@ TEST_F(UtWlTbm, BufQueueCheckActiveReq)
        ASSERT_EQ(CheckServerError(), 0);
 }
 
-TEST_F(UtWlTbm, BufQueueCheckActiveReqNoFlush)
+TEST_F(UtWlTbm, BufQueueActiveReqNoFlush)
 {
        struct wl_surface *wlt_surface;
        tbm_surface_queue_h tbm_queue;
@@ -411,7 +450,7 @@ TEST_F(UtWlTbm, BufQueueCheckActiveReqNoFlush)
        ASSERT_NE(wlt_surface, nullptr);
        ASSERT_EQ(CheckServerError(), 0);
 
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 2, 100, 200, TBM_FORMAT_ABGR8888);
+       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);
 
@@ -426,7 +465,7 @@ TEST_F(UtWlTbm, BufQueueCheckActiveReqNoFlush)
        ASSERT_EQ(CheckServerError(), 0);
 }
 
-TEST_F(UtWlTbm, BufQueueCheckDeactiveReq)
+TEST_F(UtWlTbm, BufQueueDeactiveReq)
 {
        struct wl_surface *wlt_surface;
        tbm_surface_queue_h tbm_queue;
@@ -436,7 +475,7 @@ TEST_F(UtWlTbm, BufQueueCheckDeactiveReq)
        ASSERT_NE(wlt_surface, nullptr);
        ASSERT_EQ(CheckServerError(), 0);
 
-       tbm_queue = wayland_tbm_client_create_surface_queue(wl_tbm_client, wlt_surface, 2, 100, 200, TBM_FORMAT_ABGR8888);
+       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);
 
@@ -456,3 +495,38 @@ TEST_F(UtWlTbm, BufQueueCheckDeactiveReq)
        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_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);
+
+       while (i < 3) {
+               tbm_err = tbm_surface_queue_dequeue(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);
+
+               wayland_tbm_client_destroy_buffer(wl_tbm_client, wl_buf);
+               i++;
+       }
+
+       tbm_surface_queue_destroy(tbm_queue);
+       wl_surface_destroy(wlt_surface);
+       ASSERT_EQ(CheckServerError(), 0);
+}
\ No newline at end of file