--- /dev/null
+#include <gtest/gtest.h>
+#include <stdlib.h>
+
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+#include <tbm_surface_queue.h>
+#include "ut.h"
+
+int memory_for_invalid_param;
+tbm_surface_queue_h invalid_queue = (tbm_surface_queue_h)&memory_for_invalid_param;
+int memory_for_invalid_queue;
+tbm_surface_h invalid_surface = (tbm_surface_h)&memory_for_invalid_param;
+
+static int cb_data;
+static void tbm_surface_queue_event_handler(tbm_surface_queue_h surface_queue, void *data)
+{
+ if (data == &cb_data)
+ *((int *)data) = 1;
+}
+
+static tbm_surface_queue_trace trace_cb_data;
+static void tbm_surface_queue_trace_event_handler(tbm_surface_queue_h surface_queue,
+ tbm_surface_h surface, tbm_surface_queue_trace trace, void *data)
+{
+ if (data == &trace_cb_data)
+ trace_cb_data = trace;
+}
+
+static tbm_surface_h tbm_surface_alloc_cb_handler(tbm_surface_queue_h surface_queue, void *data)
+{
+ return (tbm_surface_h)data;
+}
+
+void tbm_surface_free_cb_handler(tbm_surface_queue_h surface_queue, void *data, tbm_surface_h surface)
+{
+ if (data == surface)
+ tbm_surface_destroy(surface);
+}
+
+/* tbm_surface_queue_h tbm_surface_queue_create(int QUEUE_SIZE, int width,
+ int height, int format, int flags); */
+TEST(UtSurfaceQueueCreate, CreateFailInvalidInput)
+{
+ tbm_surface_queue_h queue = NULL;
+
+ ut_set_default_tbm_env();
+
+ queue = tbm_surface_queue_create(-1, 720, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, queue); // Expected Value: NULL
+
+ queue = tbm_surface_queue_create(QUEUE_SIZE, -1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, queue);
+
+ queue = tbm_surface_queue_create(QUEUE_SIZE, 720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, queue);
+
+ queue = tbm_surface_queue_create(QUEUE_SIZE, 720, 1024, 0, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, queue);
+}
+
+TEST(UtSurfaceQueueCreate, CreateSuccess)
+{
+ tbm_surface_queue_h queue = NULL;
+ int num = 0;
+ tbm_format *formats = NULL;
+
+ ut_set_default_tbm_env();
+
+ ASSERT_TRUE(tbm_surface_internal_query_supported_formats(&formats, &num));
+
+ queue = tbm_surface_queue_create(QUEUE_SIZE, 720, 1024, formats[0], TBM_BO_DEFAULT);
+ ASSERT_NE(NULL, queue);
+
+ tbm_surface_queue_destroy(queue);
+
+ free(formats);
+}
+
+
+/* tbm_surface_queue_h tbm_surface_queue_sequence_create(int QUEUE_SIZE, int width,
+ int height, int format, int flags); */
+TEST(UtSurfaceQueueCreate, SequenceCreateFailInvalidInput)
+{
+ tbm_surface_queue_h queue = NULL;
+
+ ut_set_default_tbm_env();
+
+ queue = tbm_surface_queue_sequence_create(-1, 720, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, queue); // Expected Value: NULL
+
+ queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, -1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, queue);
+
+ queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, 720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, queue);
+
+ queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, 720, 1024, 0, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, queue);
+}
+
+TEST(UtSurfaceQueueCreate, SequenceCreateSuccess)
+{
+ tbm_surface_queue_h queue = NULL;
+ int num = 0;
+ tbm_format *formats = NULL;
+
+ ut_set_default_tbm_env();
+
+ ASSERT_TRUE(tbm_surface_internal_query_supported_formats(&formats, &num));
+
+ queue = tbm_surface_queue_create(QUEUE_SIZE, 720, 1024, formats[0], TBM_BO_DEFAULT);
+ ASSERT_NE(NULL, queue);
+
+ free(formats);
+}
+
+
+/* void tbm_surface_queue_destroy(tbm_surface_queue_h surface_queue); */
+TEST_F(UtSurfaceQueue, DestroyNULL)
+{
+ tbm_surface_queue_destroy(NULL);
+}
+
+TEST_F(UtSurfaceQueue, DestroyTwice)
+{
+ tbm_surface_queue_destroy(queue);
+
+ tbm_surface_queue_destroy(queue);
+
+ /* to prevent destroy in TearDown */
+ queue = NULL;
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_dequeue(
+ tbm_surface_queue_h surface_queue, tbm_surface_h *surface); */
+TEST_F(UtSurfaceQueue, DequeueFailNull)
+{
+ ASSERT_EXIT({
+
+ result = tbm_surface_queue_dequeue(NULL, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_dequeue(queue, NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ exit(0);
+ }, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(UtSurfaceQueue, DequeueFailInvaildInput)
+{
+ result = tbm_surface_queue_dequeue(invalid_queue, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, DequeueSuccess)
+{
+ /* do dequeue three times */
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_NE(NULL, surface);
+ }
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(NULL, surface);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_get_surfaces( tbm_surface_queue_h surface_queue,
+ tbm_surface_h *surfaces, int *num); */
+TEST_F(UtSurfaceQueue, GetSurfacesFailNull)
+{
+ tbm_surface_h surfaces[QUEUE_SIZE];
+ int num;
+
+ result = tbm_surface_queue_get_surfaces(NULL, surfaces, &num);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_get_surfaces(queue, NULL, &num);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_get_surfaces(queue, surfaces, NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, GetSurfacesFailInvaildInput)
+{
+ tbm_surface_h surfaces[QUEUE_SIZE];
+ int num;
+
+ result = tbm_surface_queue_get_surfaces(invalid_queue, surfaces, &num);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, GetSurfacesSuccess)
+{
+ tbm_surface_h surfaces[QUEUE_SIZE];
+ int num = 0;
+
+ /* test: empty queue*/
+ result = tbm_surface_queue_get_surfaces(queue, surfaces, &num);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(0, num);
+
+ /* do dequeue three times */
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_NE(NULL, surface);
+ }
+
+ /* test */
+ result = tbm_surface_queue_get_surfaces(queue, surfaces, &num);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(QUEUE_SIZE, num);
+ for (int i = 0; i < QUEUE_SIZE; i++)
+ ASSERT_NE(NULL, surfaces[i]);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_cancel_dequeue(
+ tbm_surface_queue_h surface_queue, tbm_surface_h surface); */
+TEST_F(UtSurfaceQueue, CancelDequeueFailNull)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_cancel_dequeue(NULL, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_cancel_dequeue(queue, NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, CancelDequeueFailInvaildInput)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+
+ result = tbm_surface_queue_cancel_dequeue(invalid_queue, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_cancel_dequeue(queue, invalid_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_cancel_dequeue(queue, alien_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, CancelDequeueSuccess)
+{
+ tbm_surface_h last_surface = NULL;
+
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_NE(NULL, surface);
+ }
+
+ last_surface = surface;
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(NULL, surface);
+
+ /* test */
+ result = tbm_surface_queue_cancel_dequeue(queue, last_surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* extra check */
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(last_surface, surface);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_enqueue(
+ tbm_surface_queue_h surface_queue, tbm_surface_h surface); */
+TEST_F(UtSurfaceQueue, EnqueueFailNull)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_enqueue(NULL, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_enqueue(this->queue, NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, EnqueueFailInvaildInput)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_enqueue(invalid_queue, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_enqueue(queue, invalid_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_enqueue(queue, alien_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, EnqueueSuccess)
+{
+ tbm_surface_h surfaces[QUEUE_SIZE] = { NULL };
+
+
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+
+ /* test */
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_enqueue(queue, surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+}
+
+TEST_F(UtSurfaceQueue, EnqueueFailTwice)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_acquire(
+ tbm_surface_queue_h surface_queue, tbm_surface_h *surface); */
+TEST_F(UtSurfaceQueue, AcquireFailNull)
+{
+ /* test */
+ result = tbm_surface_queue_acquire(NULL, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AcquireFailInvaildInput)
+{
+ result = tbm_surface_queue_acquire(invalid_queue, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AcquireFailAcquireEmptyQueue)
+{
+ result = tbm_surface_queue_acquire(invalid_queue, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AcquireSuccess)
+{
+ tbm_surface_h surfaces[QUEUE_SIZE] = { NULL };
+ tbm_surface_h acquired_surface = NULL;
+
+
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+
+ /* test */
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_acquire(queue, &acquired_surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(surfaces[i], acquired_surface);
+ }
+
+ /* test: acquire empty queue*/
+ result = tbm_surface_queue_acquire(queue, &acquired_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(NULL, acquired_surface);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_cancel_acquire(
+ tbm_surface_queue_h surface_queue, tbm_surface_h surface); */
+TEST_F(UtSurfaceQueue, CancelAcquireFailNull)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+
+ /* test */
+ result = tbm_surface_queue_cancel_acquire(NULL, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_cancel_acquire(queue, NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, CancelAcquireFailInvaildInput)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_cancel_acquire(invalid_queue, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_cancel_acquire(queue, invalid_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_cancel_acquire(queue, alien_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, CancelAcquireSuccess)
+{
+ tbm_surface_h last_surface = NULL;
+
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+
+ last_surface = surface;
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(NULL, surface);
+
+ /* test */
+ result = tbm_surface_queue_cancel_acquire(queue, last_surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* extra check */
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(last_surface, surface);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_release(
+ tbm_surface_queue_h surface_queue, tbm_surface_h surface); */
+TEST_F(UtSurfaceQueue, ReleaseFailNull)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_release(NULL, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_release(this->queue, NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, ReleaseFailInvaildInput)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_release(invalid_queue, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_release(queue, invalid_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_release(queue, alien_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, ReleaseSuccess)
+{
+ tbm_surface_h surfaces[QUEUE_SIZE] = { NULL };
+
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_acquire(queue, &surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+
+ /* test */
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_release(queue, surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+}
+
+//TEST_F(UtSurfaceQueue, ReleaseFailReleaseNotAcquired)
+//{
+// result = tbm_surface_queue_dequeue(queue, &surface);
+// ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+//
+// /* test: after dequeue */
+// result = tbm_surface_queue_release(queue, surface);
+// ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+//
+// result = tbm_surface_queue_enqueue(queue, surface);
+// ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+//
+// /* test: after enqueue */
+// result = tbm_surface_queue_release(queue, surface);
+// ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+//}
+
+TEST_F(UtSurfaceQueue, ReleaseFailTwice)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_release(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_release(queue, surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+/* int tbm_surface_queue_get_width(tbm_surface_queue_h surface_queue); */
+TEST_F(UtSurfaceQueue, GetWidthFailNull)
+{
+ int width = tbm_surface_queue_get_width(NULL);
+ ASSERT_EQ(0, width);
+}
+
+TEST_F(UtSurfaceQueue, GetWidthFailInvalidInput)
+{
+ int width = tbm_surface_queue_get_width(invalid_queue);
+ ASSERT_EQ(0, width);
+}
+
+TEST_F(UtSurfaceQueue, GetWidthSuccess)
+{
+ int width = tbm_surface_queue_get_width(queue);
+ ASSERT_EQ(this->width, width);
+}
+
+/* int tbm_surface_queue_get_height(tbm_surface_queue_h surface_queue); */
+TEST_F(UtSurfaceQueue, GetHeightFailNull)
+{
+ int height = tbm_surface_queue_get_height(NULL);
+ ASSERT_EQ(0, height);
+}
+
+TEST_F(UtSurfaceQueue, GetHeightFailInvalidInput)
+{
+ int height = tbm_surface_queue_get_height(invalid_queue);
+ ASSERT_EQ(0, height);
+}
+
+TEST_F(UtSurfaceQueue, GetHeightSuccess)
+{
+ int height = tbm_surface_queue_get_height(queue);
+ ASSERT_EQ(this->height, height);
+}
+
+/* int tbm_surface_queue_get_format(tbm_surface_queue_h surface_queue); */
+TEST_F(UtSurfaceQueue, GetFormatFailNull)
+{
+ int format = tbm_surface_queue_get_format(NULL);
+ ASSERT_EQ(0, format);
+}
+
+TEST_F(UtSurfaceQueue, GetFormatFailInvalidInput)
+{
+ int format = tbm_surface_queue_get_format(invalid_queue);
+ ASSERT_EQ(0, format);
+}
+
+TEST_F(UtSurfaceQueue, GetFormatSuccess)
+{
+ int format = tbm_surface_queue_get_format(queue);
+ ASSERT_EQ((int)this->format, format);
+}
+
+/* int tbm_surface_queue_get_size(tbm_surface_queue_h surface_queue); */
+TEST_F(UtSurfaceQueue, GetSizeFailNull)
+{
+ int q_size = tbm_surface_queue_get_size(NULL);
+ ASSERT_EQ(0, q_size);
+}
+
+TEST_F(UtSurfaceQueue, GetSizeFailInvalidInput)
+{
+ int q_size = tbm_surface_queue_get_size(invalid_queue);
+ ASSERT_EQ(0, q_size);
+}
+
+TEST_F(UtSurfaceQueue, GetSizeSuccess)
+{
+ int q_size = tbm_surface_queue_get_size(queue);
+ ASSERT_EQ(QUEUE_SIZE, q_size);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_reset(
+ tbm_surface_queue_h surface_queue, int width, int height, int format); */
+TEST_F(UtSurfaceQueue, ResetFailNull)
+{
+ result = tbm_surface_queue_reset(NULL, width, height, format);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, ResetFailInvalidInput)
+{
+ result = tbm_surface_queue_reset(invalid_queue, width, height, format);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_reset(invalid_queue, -1, height, format);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_reset(invalid_queue, width, -1, format);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_reset(invalid_queue, width, height, 0);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, ResetSuccessEmptyQueue)
+{
+ result = tbm_surface_queue_reset(queue, width-10, height-10, format);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, ResetSuccessSameParams)
+{
+ tbm_surface_h surface = NULL;
+
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_reset(queue, width, height, format);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* extra check */
+ ASSERT_TRUE(tbm_surface_internal_is_valid(surface)) << "old surface mast be valid";
+}
+
+TEST_F(UtSurfaceQueue, ResetSuccess)
+{
+ tbm_surface_h surface = NULL;
+
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_reset(queue, width-10, height-10, formats[num_formats-1]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* extra check */
+ ASSERT_FALSE(tbm_surface_internal_is_valid(surface)) << "old surface has to be deleted";
+}
+
+
+/* tbm_surface_queue_error_e tbm_surface_queue_set_size(
+ tbm_surface_queue_h surface_queue, int QUEUE_SIZE, int flush); */
+TEST_F(UtSurfaceQueue, SetSizeFailNull)
+{
+ result = tbm_surface_queue_set_size(NULL, QUEUE_SIZE, 0);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, SetSizeFailInvalidInput)
+{
+ result = tbm_surface_queue_set_size(invalid_queue, QUEUE_SIZE, 0);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_set_size(NULL, 0, 0);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, SetSizeSuccessTheSameSize)
+{
+ tbm_surface_h surface = NULL;
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /*test: */
+ result = tbm_surface_queue_set_size(queue, QUEUE_SIZE, 0);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(tbm_surface_internal_is_valid(surface)) << "old surface mast be valid";
+
+ /*test: with flush*/
+ result = tbm_surface_queue_set_size(queue, QUEUE_SIZE, 1);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_FALSE(tbm_surface_internal_is_valid(surface)) << "old surface has to be deleted";
+}
+
+TEST_F(UtSurfaceQueue, SetSizeSuccessIncrease)
+{
+ tbm_surface_h surface = NULL;
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /*test: */
+ result = tbm_surface_queue_set_size(queue, QUEUE_SIZE+1, 0);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(tbm_surface_internal_is_valid(surface)) << "old surface mast be valid";
+
+ /*test: with flush*/
+ result = tbm_surface_queue_set_size(queue, QUEUE_SIZE+2, 1);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_FALSE(tbm_surface_internal_is_valid(surface)) << "old surface has to be deleted";
+}
+
+TEST_F(UtSurfaceQueue, SetSizeSuccessReduce)
+{
+ tbm_surface_h surface = NULL;
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /*test: */
+ result = tbm_surface_queue_set_size(queue, QUEUE_SIZE-1, 0);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(tbm_surface_internal_is_valid(surface)) << "old surface mast be valid";
+
+ /*test: with flush*/
+ result = tbm_surface_queue_set_size(queue, QUEUE_SIZE-2, 1);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_FALSE(tbm_surface_internal_is_valid(surface)) << "old surface has to be deleted";
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_flush(tbm_surface_queue_h surface_queue); */
+TEST_F(UtSurfaceQueue, FlushFailNull)
+{
+ result = tbm_surface_queue_flush(NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, FlushFailInvalidInput)
+{
+ result = tbm_surface_queue_flush(invalid_queue);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, FlushSuccess)
+{
+ tbm_surface_h surfaces[QUEUE_SIZE];
+
+ /*test: flushing not initialized queue*/
+ result = tbm_surface_queue_flush(queue);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+
+ /* test */
+ result = tbm_surface_queue_flush(queue);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* extra check */
+ for (int i = 0; i < QUEUE_SIZE; i++)
+ ASSERT_FALSE(tbm_surface_internal_is_valid(surfaces[i])) << "old surface has to be deleted";
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_free_flush(tbm_surface_queue_h surface_queue); */
+TEST_F(UtSurfaceQueue, FreeFlushFailNull)
+{
+ result = tbm_surface_queue_free_flush(NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, FreeFlushFailInvalidInput)
+{
+ result = tbm_surface_queue_free_flush(invalid_queue);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, FreeFlushSuccess)
+{
+ tbm_surface_h surfaces[QUEUE_SIZE];
+
+ /*test: flushing not initialized queue*/
+ result = tbm_surface_queue_free_flush(queue);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+
+ /* init queue */
+ for (int i = 0; i < QUEUE_SIZE; i++) {
+ result = tbm_surface_queue_dequeue(queue, &surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_cancel_dequeue(queue, surfaces[i]);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+
+ /* test */
+ result = tbm_surface_queue_free_flush(queue);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* extra check */
+ for (int i = 0; i < QUEUE_SIZE; i++)
+ ASSERT_FALSE(tbm_surface_internal_is_valid(surfaces[i])) << "old surface has to be deleted";
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_add_reset_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb, void *data); */
+TEST_F(UtSurfaceQueue, AddResetCbFailNull)
+{
+ result = tbm_surface_queue_add_reset_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_add_reset_cb(queue, NULL, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddResetCbFailInvalidInput)
+{
+ result = tbm_surface_queue_add_reset_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddResetCbSuccess)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_add_reset_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /*extra check: reset cb has to called after tbm_surface_queue_flush()*/
+ cb_data = 0;
+ result = tbm_surface_queue_flush(queue);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 1);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_remove_reset_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb, void *data); */
+TEST_F(UtSurfaceQueue, RemoveResetCbFailNull)
+{
+ result = tbm_surface_queue_remove_reset_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveResetCbSuccess)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ result = tbm_surface_queue_add_reset_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+
+ /* test */
+ result = tbm_surface_queue_remove_reset_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /*extra check: reset cb musn't called after tbm_surface_queue_flush()*/
+ cb_data = 0;
+ result = tbm_surface_queue_flush(queue);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 0);
+}
+
+TEST_F(UtSurfaceQueue, RemoveResetCbFailInvalidInput)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ result = tbm_surface_queue_add_reset_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+
+ /* test: invalid queue*/
+ result = tbm_surface_queue_remove_reset_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test: invalid data */
+ result = tbm_surface_queue_remove_reset_cb(queue, tbm_surface_queue_event_handler, NULL);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test: invalid cb function */
+ result = tbm_surface_queue_remove_reset_cb(queue, (tbm_surface_queue_notify_cb)1, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /*extra check: reset cb still has to be called after tbm_surface_queue_flush()*/
+ cb_data = 0;
+ result = tbm_surface_queue_flush(queue);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 1);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_notify_reset(tbm_surface_queue_h surface_queue); */
+TEST_F(UtSurfaceQueue, NotifyResetFailNull)
+{
+ result = tbm_surface_queue_notify_reset(NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, NotifyResetFailInvalidInput)
+{
+ result = tbm_surface_queue_notify_reset(invalid_queue);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, NotifyResetCbSuccess)
+{
+ result = tbm_surface_queue_add_reset_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ cb_data = 0;
+ result = tbm_surface_queue_notify_reset(queue);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 1);
+}
+
+/* int tbm_surface_queue_can_dequeue(tbm_surface_queue_h surface_queue, int wait); */
+TEST_F(UtSurfaceQueue, CanDequeueFailNull)
+{
+ ASSERT_FALSE(tbm_surface_queue_can_dequeue(NULL, 0));
+}
+
+TEST_F(UtSurfaceQueue, CanDequeueFailInvalidInput)
+{
+ ASSERT_FALSE(tbm_surface_queue_can_dequeue(invalid_queue, 0));
+}
+
+TEST_F(UtSurfaceQueue, CanDequeueSuccess)
+{
+ int dq_count = 0;
+
+ /* test: dequeue all*/
+ while (tbm_surface_queue_can_dequeue(queue, 0)) {
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ dq_count++;
+ }
+ ASSERT_EQ(QUEUE_SIZE, dq_count);
+}
+
+TEST_F(UtSurfaceQueue, CanDequeueFailEmptyQueue)
+{
+ /*Dequeue all*/
+ while (tbm_surface_queue_can_dequeue(queue, 0)) {
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ }
+
+ /* test */
+ ASSERT_FALSE(tbm_surface_queue_can_dequeue(queue, 0));
+}
+
+
+/* int tbm_surface_queue_can_acquire(tbm_surface_queue_h surface_queue, int wait); */
+TEST_F(UtSurfaceQueue, CanAcquireFailNull)
+{
+ ASSERT_FALSE(tbm_surface_queue_can_acquire(NULL, 0));
+}
+
+TEST_F(UtSurfaceQueue, CanAcquireFailInvalidInput)
+{
+ ASSERT_FALSE(tbm_surface_queue_can_acquire(invalid_queue, 0));
+}
+
+TEST_F(UtSurfaceQueue, CanAcquireFailEmptyQueue)
+{
+ ASSERT_FALSE(tbm_surface_queue_can_acquire(queue, 0));
+}
+
+TEST_F(UtSurfaceQueue, CanAcquireSuccess)
+{
+ int acq_count = 0;
+
+ while (tbm_surface_queue_can_dequeue(queue, 0)) {
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ }
+
+ /*Dequeue all*/
+ while (tbm_surface_queue_can_acquire(queue, 0)) {
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ acq_count++;
+ }
+
+ ASSERT_EQ(QUEUE_SIZE, acq_count);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_add_destroy_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb, void *data); */
+TEST_F(UtSurfaceQueue, AddDestroyCbFailNull)
+{
+ result = tbm_surface_queue_add_destroy_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_add_destroy_cb(queue, NULL, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddDestroyCbFailInvalidInput)
+{
+ result = tbm_surface_queue_add_destroy_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddDestroyCbSuccess)
+{
+ /* test */
+ result = tbm_surface_queue_add_destroy_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ tbm_surface_queue_destroy(queue);
+ ASSERT_TRUE(cb_data == 1);
+
+ /* to avoid destroying queue in TearDown*/
+ queue = NULL;
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_remove_destroy_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb, void *data); */
+TEST_F(UtSurfaceQueue, RemoveDestroyCbFailNull)
+{
+ result = tbm_surface_queue_remove_destroy_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveDestroyCbFailInvalidInput)
+{
+ result = tbm_surface_queue_remove_destroy_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveDestroyCbSuccess)
+{
+ result = tbm_surface_queue_add_destroy_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_remove_destroy_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ tbm_surface_queue_destroy(queue);
+ ASSERT_TRUE(cb_data == 0);
+
+ /* to avoid destroying queue in TearDown*/
+ queue = NULL;
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_add_dequeuable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb, void *data); */
+TEST_F(UtSurfaceQueue, AddDequeuableCbFailNull)
+{
+ result = tbm_surface_queue_add_dequeuable_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_add_dequeuable_cb(queue, NULL, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddDequeuableCbFailInvalidInput)
+{
+ result = tbm_surface_queue_add_dequeuable_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddDequeuableCbSuccess)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_add_dequeuable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ result = tbm_surface_queue_release(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 1);
+}
+
+
+/* tbm_surface_queue_error_e tbm_surface_queue_remove_dequeuable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb, void *data); */
+TEST_F(UtSurfaceQueue, RemoveDequeuableCbFailNull)
+{
+ result = tbm_surface_queue_remove_dequeuable_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveDequeuableCbFailInvalidInput)
+{
+ /* test: invalid queue */
+ result = tbm_surface_queue_remove_dequeuable_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveDequeuableCbSuccess)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_add_dequeuable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_remove_dequeuable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ result = tbm_surface_queue_release(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 0);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_add_dequeue_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeue_cb, void *data); */
+TEST_F(UtSurfaceQueue, AddDequeueCbFailNull)
+{
+ result = tbm_surface_queue_add_dequeue_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_add_dequeue_cb(queue, NULL, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddDequeueCbFailInvalidInput)
+{
+ result = tbm_surface_queue_add_dequeue_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddDequeueCbSuccess)
+{
+ tbm_surface_queue_dequeue(queue, &surface);
+ tbm_surface_queue_enqueue(queue, surface);
+ tbm_surface_queue_acquire(queue, &surface);
+
+ /* test */
+ result = tbm_surface_queue_add_dequeuable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ result = tbm_surface_queue_release(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 1);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_remove_dequeue_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeue_cb, void *data); */
+TEST_F(UtSurfaceQueue, RemoveDequeueCbFailNull)
+{
+ result = tbm_surface_queue_remove_dequeue_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveDequeueCbFailInvalidInput)
+{
+ /* test: invalid queue */
+ result = tbm_surface_queue_remove_dequeue_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveDequeueCbSuccess)
+{
+ tbm_surface_queue_dequeue(queue, &surface);
+ tbm_surface_queue_enqueue(queue, surface);
+ tbm_surface_queue_acquire(queue, &surface);
+
+ /* test */
+ result = tbm_surface_queue_add_dequeuable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_remove_dequeuable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ result = tbm_surface_queue_release(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 0);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_add_can_dequeue_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb can_dequeue_cb, void *data); */
+TEST_F(UtSurfaceQueue, AddCanDequeueCbFailNull)
+{
+ result = tbm_surface_queue_add_can_dequeue_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_add_can_dequeue_cb(queue, NULL, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddCanDequeueCbFailInvalidInput)
+{
+ result = tbm_surface_queue_add_can_dequeue_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddCanDequeueCbSuccess)
+{
+ /* test */
+ result = tbm_surface_queue_add_can_dequeue_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ tbm_surface_queue_can_dequeue(queue, 0);
+ ASSERT_TRUE(cb_data == 1);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_remove_can_dequeue_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb can_dequeue_cb, void *data); */
+TEST_F(UtSurfaceQueue, RemoveCanDequeueCbFailNull)
+{
+ result = tbm_surface_queue_remove_can_dequeue_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveCanDequeueCbFailInvalidInput)
+{
+ /* test: invalid queue */
+ result = tbm_surface_queue_remove_can_dequeue_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveCanDequeueCbSuccess)
+{
+ result = tbm_surface_queue_add_can_dequeue_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_remove_can_dequeue_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ tbm_surface_queue_can_dequeue(queue, 0);
+ ASSERT_TRUE(cb_data == 0);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_add_acquirable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb, void *data); */
+TEST_F(UtSurfaceQueue, AddAcquirableCbFailNull)
+{
+ result = tbm_surface_queue_add_acquirable_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_add_acquirable_cb(queue, NULL, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddAcquirableCbFailInvalidInput)
+{
+ result = tbm_surface_queue_add_acquirable_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddAcquirableCbSuccess)
+{
+ tbm_surface_queue_dequeue(queue, &surface);
+
+ /* test */
+ result = tbm_surface_queue_add_acquirable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 1);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_remove_acquirable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb, void *data); */
+TEST_F(UtSurfaceQueue, RemoveAcquirableCbFailNull)
+{
+ result = tbm_surface_queue_remove_acquirable_cb(NULL, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveAcquirableCbFailInvalidInput)
+{
+ /* test: invalid queue */
+ result = tbm_surface_queue_remove_acquirable_cb(invalid_queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveAcquirableCbSuccess)
+{
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ result = tbm_surface_queue_add_acquirable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_remove_acquirable_cb(queue, tbm_surface_queue_event_handler, &cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ cb_data = 0;
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(cb_data == 0);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_add_trace_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_trace_cb trace_cb, void *data); */
+TEST_F(UtSurfaceQueue, AddTraceCbFailNull)
+{
+ result = tbm_surface_queue_add_trace_cb(NULL, tbm_surface_queue_trace_event_handler, &trace_cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_add_trace_cb(queue, NULL, &trace_cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddTraceCbFailInvalidInput)
+{
+ result = tbm_surface_queue_add_trace_cb(invalid_queue, tbm_surface_queue_trace_event_handler, &trace_cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, AddTraceCbSuccess)
+{
+ trace_cb_data = TBM_SURFACE_QUEUE_TRACE_NONE;
+
+ /* test */
+ result = tbm_surface_queue_add_trace_cb(queue, tbm_surface_queue_trace_event_handler, &trace_cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(trace_cb_data == TBM_SURFACE_QUEUE_TRACE_DEQUEUE);
+
+ result = tbm_surface_queue_cancel_dequeue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(trace_cb_data == TBM_SURFACE_QUEUE_TRACE_CANCEL_DEQUEUE);
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(trace_cb_data == TBM_SURFACE_QUEUE_TRACE_ENQUEUE);
+
+ result = tbm_surface_queue_acquire(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(trace_cb_data == TBM_SURFACE_QUEUE_TRACE_ACQUIRE);
+
+ result = tbm_surface_queue_cancel_acquire(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(trace_cb_data == TBM_SURFACE_QUEUE_TRACE_CANCEL_ACQUIRE);
+
+ result = tbm_surface_queue_acquire(queue, &surface);
+ result = tbm_surface_queue_release(queue, surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(trace_cb_data == TBM_SURFACE_QUEUE_TRACE_RELEASE);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_remove_trace_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_trace_cb trace_cb, void *data); */
+TEST_F(UtSurfaceQueue, RemoveTraceCbFailNull)
+{
+ result = tbm_surface_queue_remove_trace_cb(NULL, tbm_surface_queue_trace_event_handler, &trace_cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveTraceCbFailInvalidInput)
+{
+ /* test: invalid queue */
+ result = tbm_surface_queue_remove_trace_cb(invalid_queue, tbm_surface_queue_trace_event_handler, &trace_cb_data);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, RemoveTraceCbSuccess)
+{
+ trace_cb_data = TBM_SURFACE_QUEUE_TRACE_NONE;
+
+ result = tbm_surface_queue_add_trace_cb(queue, tbm_surface_queue_trace_event_handler, &trace_cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test */
+ result = tbm_surface_queue_remove_trace_cb(queue, tbm_surface_queue_trace_event_handler, &trace_cb_data);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_TRUE(trace_cb_data == TBM_SURFACE_QUEUE_TRACE_NONE);
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_set_alloc_cb( tbm_surface_queue_h surface_queue,
+ tbm_surface_alloc_cb alloc_cb, tbm_surface_free_cb free_cb, void *data); */
+TEST_F(UtSurfaceQueue, SetAllocCbFailNull)
+{
+ result = tbm_surface_queue_set_alloc_cb(NULL, tbm_surface_alloc_cb_handler,
+ tbm_surface_free_cb_handler, alien_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, SetAllocCbFailInvalidInput)
+{
+ result = tbm_surface_queue_set_alloc_cb(invalid_queue, tbm_surface_alloc_cb_handler,
+ tbm_surface_free_cb_handler, alien_surface);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, SetAllocCbSuccess)
+{
+ result = tbm_surface_queue_set_alloc_cb(queue, tbm_surface_alloc_cb_handler,
+ tbm_surface_free_cb_handler, alien_surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ /* test: allocate */
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(alien_surface, surface);
+
+ /* test: alien_surface has to be deleted*/
+ tbm_surface_queue_destroy(queue);
+ ASSERT_FALSE(tbm_surface_internal_is_valid(alien_surface));
+
+ alien_surface = NULL;
+}
+
+/* tbm_surface_queue_error_e tbm_surface_queue_get_trace_surface_num(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_trace trace, int *num); */
+TEST_F(UtSurfaceQueue, GetTraceSurfaceNumFailNull)
+{
+ int num = 0;
+
+ ASSERT_EXIT({
+
+ result = tbm_surface_queue_get_trace_surface_num(NULL, TBM_SURFACE_QUEUE_TRACE_NONE, &num);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ result = tbm_surface_queue_get_trace_surface_num(queue, TBM_SURFACE_QUEUE_TRACE_NONE, NULL);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+
+ exit(0);
+ }, ::testing::ExitedWithCode(0), "");
+
+}
+
+TEST_F(UtSurfaceQueue, GetTraceSurfaceNumFailInvalidInput)
+{
+ int num = 0;
+
+ result = tbm_surface_queue_get_trace_surface_num(invalid_queue, TBM_SURFACE_QUEUE_TRACE_NONE, &num);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, GetTraceSurfaceNumSuccess)
+{
+ int num = 0;
+
+ result = tbm_surface_queue_set_size(queue, 4, 0);
+
+ /* one acquired */
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ result = tbm_surface_queue_enqueue(queue, surface);
+ result = tbm_surface_queue_acquire(queue, &surface);
+
+ /* one enqueued */
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ result = tbm_surface_queue_enqueue(queue, surface);
+
+ /* one dequeued */
+ result = tbm_surface_queue_dequeue(queue, &surface);
+
+ /* one released */
+ result = tbm_surface_queue_dequeue(queue, &surface);
+ result = tbm_surface_queue_cancel_dequeue(queue, surface);
+
+
+ /* test */
+ result = tbm_surface_queue_get_trace_surface_num(queue, TBM_SURFACE_QUEUE_TRACE_NONE, &num);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(0, num);
+
+ result = tbm_surface_queue_get_trace_surface_num(queue, TBM_SURFACE_QUEUE_TRACE_DEQUEUE, &num);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(1, num);
+
+ result = tbm_surface_queue_get_trace_surface_num(queue, TBM_SURFACE_QUEUE_TRACE_ENQUEUE, &num);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(1, num);
+
+ result = tbm_surface_queue_get_trace_surface_num(queue, TBM_SURFACE_QUEUE_TRACE_ACQUIRE, &num);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(1, num);
+
+ result = tbm_surface_queue_get_trace_surface_num(queue, TBM_SURFACE_QUEUE_TRACE_RELEASE, &num);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+ ASSERT_EQ(1, num);
+}
+/* tbm_surface_queue_error_e tbm_surface_queue_set_modes(
+ tbm_surface_queue_h surface_queue, int modes); */
+TEST_F(UtSurfaceQueue, SetModesFailNull)
+{
+ result = tbm_surface_queue_set_modes(NULL, TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, SetModesFailInvalidInput)
+{
+ result = tbm_surface_queue_set_modes(invalid_queue, TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE);
+ ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceQueue, SetModesSuccess)
+{
+ result = tbm_surface_queue_set_modes(queue, TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE);
+ ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result);
+}