}
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,
{
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) {
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);
}
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;
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;
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);
ASSERT_EQ(CheckServerError(), 0);
}
-TEST_F(UtWlTbm, BufQueueCheckActiveReq)
+TEST_F(UtWlTbm, BufQueueActiveReq)
{
struct wl_surface *wlt_surface;
tbm_surface_queue_h tbm_queue;
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);
ASSERT_EQ(CheckServerError(), 0);
}
-TEST_F(UtWlTbm, BufQueueCheckActiveReqNoFlush)
+TEST_F(UtWlTbm, BufQueueActiveReqNoFlush)
{
struct wl_surface *wlt_surface;
tbm_surface_queue_h tbm_queue;
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);
ASSERT_EQ(CheckServerError(), 0);
}
-TEST_F(UtWlTbm, BufQueueCheckDeactiveReq)
+TEST_F(UtWlTbm, BufQueueDeactiveReq)
{
struct wl_surface *wlt_surface;
tbm_surface_queue_h tbm_queue;
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);
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