ASSERT_NE(NULL, formats);
for (int i = 0; i < num; i++)
ASSERT_NE(0, formats[i]);
-
+ free(formats);
}
TEST_F(UtInit, SurfaceCeateFailInvalidGeometry)
}
}
-TEST_F(UtSurfaceInit, SurfaceGetFormatFailInvalideInput)
+TEST_F(UtSurface, SurfaceGetFormatFailInvalidInput)
{
tbm_surface_h invalide_surface = (tbm_surface_h)1;
tbm_format fmt = tbm_surface_get_format(invalide_surface);
ASSERT_EQ(0, fmt);
}
-TEST_F(UtSurfaceInit, SurfaceGetFormatFailNull)
+TEST_F(UtSurface, SurfaceGetFormatFailNull)
{
tbm_format fmt = tbm_surface_get_format(NULL);
ASSERT_EQ(0, fmt);
}
-TEST_F(UtSurfaceInit, SurfaceGetFormatSuccess)
+TEST_F(UtSurface, SurfaceGetFormatSuccess)
{
tbm_format fmt = tbm_surface_get_format(surface);
ASSERT_EQ(this->format, fmt);
}
-TEST_F(UtSurfaceInit, SurfaceGetWidthFailInvalideInput)
+TEST_F(UtSurface, SurfaceGetWidthFailInvalidInput)
{
tbm_surface_h invalide_surface = (tbm_surface_h)1;
int width = tbm_surface_get_width(invalide_surface);
ASSERT_EQ(0, width);
}
-TEST_F(UtSurfaceInit, SurfaceGetWidthFailNull)
+TEST_F(UtSurface, SurfaceGetWidthFailNull)
{
int width = tbm_surface_get_width(NULL);
ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, width);
}
-TEST_F(UtSurfaceInit, SurfaceGetWidthSuccess)
+TEST_F(UtSurface, SurfaceGetWidthSuccess)
{
int width = tbm_surface_get_width(surface);
ASSERT_EQ(this->width, width);
}
-TEST_F(UtSurfaceInit, SurfaceGetHeightFailInvalideInput)
+TEST_F(UtSurface, SurfaceGetHeightFailInvalidInput)
{
tbm_surface_h invalide_surface = (tbm_surface_h)1;
int height = tbm_surface_get_height(invalide_surface);
ASSERT_EQ(0, height);
}
-TEST_F(UtSurfaceInit, SurfaceGetHeightFailNull)
+TEST_F(UtSurface, SurfaceGetHeightFailNull)
{
int height = tbm_surface_get_height(NULL);
ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, height);
}
-TEST_F(UtSurfaceInit, SurfaceGetHeightSuccess)
+TEST_F(UtSurface, SurfaceGetHeightSuccess)
{
int height = tbm_surface_get_height(surface);
ASSERT_EQ(this->height, height);
}
-TEST_F(UtSurfaceInit, SurfaceGetInfoInvalideInput)
+TEST_F(UtSurface, SurfaceGetInfoInvalidInput)
{
tbm_surface_h invalide_surface = (tbm_surface_h)1;
tbm_surface_info_s info;
ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_OPERATION, result);
}
-TEST_F(UtSurfaceInit, SurfaceGetInfoFailNull)
+TEST_F(UtSurface, SurfaceGetInfoFailNull)
{
tbm_surface_info_s info;
tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
}
-TEST_F(UtSurfaceInit, SurfaceGetInfoSuccess)
+TEST_F(UtSurface, SurfaceGetInfoSuccess)
{
tbm_surface_info_s info;
tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
ASSERT_GT(info.size, 0);
}
-TEST_F(UtSurfaceInit, SurfaceMapFailInvalideInput)
+TEST_F(UtSurface, SurfaceMapFailInvalidInput)
{
tbm_surface_info_s info;
tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_OPERATION, result);
}
-TEST_F(UtSurfaceInit, SurfaceMapFailNull)
+TEST_F(UtSurface, SurfaceMapFailNull)
{
tbm_surface_info_s info;
tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
}
-TEST_F(UtSurfaceInit, SurfaceMapSuccess)
+TEST_F(UtSurface, SurfaceMapSuccess)
{
tbm_surface_info_s info;
tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
}
-TEST_F(UtSurfaceInit, SurfaceUnmapFailInvalideInput)
+TEST_F(UtSurface, SurfaceUnmapFailInvalidInput)
{
tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
tbm_surface_h invalide_surface = (tbm_surface_h)1;
ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
}
-TEST_F(UtSurfaceInit, SurfaceUnmapFailNull)
+TEST_F(UtSurface, SurfaceUnmapFailNull)
{
tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
--- /dev/null
+#include <gtest/gtest.h>
+#include <stdlib.h>
+
+#include <tbm_bufmgr.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+#include "ut.h"
+
+/* int tbm_surface_internal_query_supported_formats(uint32_t **formats, uint32_t *num) */
+TEST_F(UtInit, SurfaceInternalQueryFormatsFailNull)
+{
+ int num = 0;
+ tbm_format *formats = NULL;
+
+ ut_set_default_tbm_env();
+
+ ASSERT_FALSE(tbm_surface_internal_query_supported_formats(&formats, NULL));
+
+ ASSERT_FALSE(tbm_surface_internal_query_supported_formats(NULL, &num));
+}
+
+TEST_F(UtInit, SurfaceInternalQueryFormatsSuccess)
+{
+ int num = 0;
+ tbm_format *formats = NULL;
+
+ ut_set_default_tbm_env();
+
+ ASSERT_TRUE(tbm_surface_internal_query_supported_formats(&formats, &num));
+ ASSERT_NE(0, num);
+ ASSERT_NE(NULL, formats);
+ for (int i = 0; i < num; i++)
+ ASSERT_NE(0, formats[i]);
+
+ if (formats)
+ free(formats);
+}
+
+
+/* tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height, int format, int flags) */
+TEST_F(UtInit, SurfaceInternalCeatewithFlagsFailInvalidInput)
+{
+ tbm_surface_h surface = NULL;
+
+ ut_set_default_tbm_env();
+
+ surface = tbm_surface_internal_create_with_flags(-1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, surface); // Expected Value: NULL
+
+ surface = tbm_surface_internal_create_with_flags(720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, surface);
+
+ surface = tbm_surface_internal_create_with_flags(720, 1024, 0, TBM_BO_DEFAULT);
+ ASSERT_EQ(NULL, surface);
+
+ surface = tbm_surface_internal_create_with_flags(720, 1024, 0, (TBM_BO_WC << 1));
+ ASSERT_EQ(NULL, surface);
+}
+
+TEST_F(UtInit, SurfaceInternalCeatewithFlagsSuccess)
+{
+ tbm_surface_h surface = NULL;
+ int num = 0;
+ tbm_format *formats = NULL;
+
+ ut_set_default_tbm_env();
+
+ ASSERT_TRUE(tbm_surface_internal_query_supported_formats(&formats, &num));
+
+ for (int i = 0; i < num; i++) {
+ surface = tbm_surface_internal_create_with_flags(720, 1024, formats[i], TBM_BO_DEFAULT);
+ ASSERT_NE(NULL, surface);
+ tbm_surface_internal_destroy(surface);
+ }
+
+ if (formats)
+ free(formats);
+}
+
+
+/* void tbm_surface_internal_destroy(tbm_surface_h surface) */
+TEST_F(UtInit, SurfaceInternalSurfaceInteranlDestroyFailNULL)
+{
+ ut_set_default_tbm_env();
+
+ tbm_surface_internal_destroy(NULL);
+}
+
+TEST_F(UtInit, SurfaceInteranlDestroyFailTwice)
+{
+ tbm_surface_h surface = NULL;
+ int num = 0;
+ tbm_format *formats = NULL;
+
+ ASSERT_TRUE(tbm_surface_internal_query_supported_formats(&formats, &num));
+ surface = tbm_surface_internal_create_with_flags(720, 1024, formats[0], TBM_BO_DEFAULT);
+
+ tbm_surface_internal_destroy(surface);
+
+ tbm_surface_internal_destroy(surface);
+
+ if(formats)
+ free(formats);
+}
+
+
+/* tbm_surface_internal_is_valid(tbm_surface_h surface) */
+TEST_F(UtSurfaceInternal, IsValid)
+{
+ int invalid_surf;
+
+ ASSERT_FALSE(tbm_surface_internal_is_valid(NULL));
+ ASSERT_FALSE(tbm_surface_internal_is_valid((tbm_surface_h)&invalid_surf));
+ ASSERT_TRUE(tbm_surface_internal_is_valid(surface));;
+}
+
+
+/* int tbm_surface_internal_get_num_bos(tbm_surface_h surface) */
+TEST_F(UtSurfaceInternal, GetNumBosFailNULL)
+{
+ int num = tbm_surface_internal_get_num_bos(NULL);
+ ASSERT_EQ(0, num);
+}
+
+TEST_F(UtSurfaceInternal, GetNumBosSuccess)
+{
+ int num = tbm_surface_internal_get_num_bos(surface);
+ ASSERT_TRUE(num > 0);
+}
+
+/* tbm_bo tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx) */
+TEST_F(UtSurfaceInternal, GetBoFailNULL)
+{
+ tbm_bo bo = tbm_surface_internal_get_bo(NULL, 0);
+ ASSERT_EQ(NULL, bo);
+}
+
+TEST_F(UtSurfaceInternal, GetBoFailInvalideInput)
+{
+ tbm_surface_h invalide_surface = (tbm_surface_h)1;
+ tbm_bo bo = NULL;
+ int num = 0;
+
+ /* invalid surface */
+ bo = tbm_surface_internal_get_bo(invalide_surface, 0);
+ ASSERT_EQ(NULL, bo);
+
+ num = tbm_surface_internal_get_num_bos(surface);
+ ASSERT_TRUE(num > 0);
+
+ /* invalid index of bo */
+ bo = tbm_surface_internal_get_bo(surface, -1);
+ ASSERT_EQ(NULL, bo);
+ bo = tbm_surface_internal_get_bo(surface, num);
+ ASSERT_EQ(NULL, bo);
+}
+
+TEST_F(UtSurfaceInternal, GetBoSuccess)
+{
+ tbm_bo bo = NULL;
+ int num = 0;
+
+ num = tbm_surface_internal_get_num_bos(surface);
+ ASSERT_TRUE(num > 0);
+
+ for (int i = 0; i < num; i++) {
+ bo = tbm_surface_internal_get_bo(surface, i);
+ ASSERT_NE(NULL, bo);
+ }
+}
+
+/* tbm_surface_h tbm_surface_internal_create_with_bos(tbm_surface_info_s *info, tbm_bo *bos, int num) */
+TEST_F(UtSurfaceInternal, CreateWithBosNullInput)
+{
+ tbm_surface_h surf = NULL;
+ tbm_surface_info_s info = { 0 };
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+ tbm_bo bos[1];
+
+ result = tbm_surface_get_info(surface, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+
+ surf = tbm_surface_internal_create_with_bos(NULL, NULL, 1);
+
+ surf = tbm_surface_internal_create_with_bos(&info, NULL, 1);
+ ASSERT_EQ(NULL, surf);
+
+ surf = tbm_surface_internal_create_with_bos(NULL, bos, 1);
+ ASSERT_EQ(NULL, surf);
+}
+
+TEST_F(UtSurfaceInternal, CreateWithBosFailInvalidInput)
+{
+ tbm_surface_h surf = NULL;
+ tbm_surface_info_s info;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+ tbm_bo bos[4] = { NULL };
+ int num;
+
+ result = tbm_surface_get_info(surface, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+
+ num = tbm_surface_internal_get_num_bos(surface);
+ ASSERT_TRUE(num > 0);
+
+ for (int i = 0; i < num; i++) {
+ bos[i] = tbm_surface_internal_get_bo(surface, i);
+ ASSERT_NE(NULL, bos[i]);
+ }
+
+
+ /* wrong number of bo */
+ surf = tbm_surface_internal_create_with_bos(&info, bos, num + 1);
+ ASSERT_EQ(NULL, surf);
+ surf = tbm_surface_internal_create_with_bos(&info, bos, num - 1);
+ ASSERT_EQ(NULL, surf);
+
+ /* invalid bo */
+ bos[num-1] = NULL;
+ surf = tbm_surface_internal_create_with_bos(&info, bos, num);
+ ASSERT_EQ(NULL, surf);
+}
+
+TEST_F(UtSurfaceInternal, CreateWithBosSuccess)
+{
+ tbm_surface_h surf = NULL;
+ tbm_surface_info_s info;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+ tbm_bo bos[4] = { NULL };
+ int num = 0;
+
+ result = tbm_surface_get_info(surface, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+
+ num = tbm_surface_internal_get_num_bos(surface);
+ ASSERT_TRUE(num > 0);
+
+ for (int i = 0; i < num; i++) {
+ bos[i] = tbm_surface_internal_get_bo(surface, i);
+ ASSERT_NE(NULL, bos[i]);
+ }
+
+ surf = tbm_surface_internal_create_with_bos(&info, bos, num);
+ ASSERT_NE(NULL, surf);
+ tbm_surface_internal_destroy(surf);
+
+ /* set size plane to zero*/
+ info.planes[0].size = 0;
+ surf = tbm_surface_internal_create_with_bos(&info, bos, num);
+ ASSERT_NE(NULL, surf);
+ tbm_surface_internal_destroy(surf);
+
+ /* set bpp to zero*/
+ info.bpp = 0;
+ surf = tbm_surface_internal_create_with_bos(&info, bos, num);
+ ASSERT_NE(NULL, surf);
+ tbm_surface_internal_destroy(surf);
+
+ /* set size to zero*/
+ info.size = 0;
+ surf = tbm_surface_internal_create_with_bos(&info, bos, num);
+ ASSERT_NE(NULL, surf);
+ tbm_surface_internal_destroy(surf);
+}
+
+/* void tbm_surface_internal_unref(tbm_surface_h surface) */
+TEST_F(UtSurfaceInternal, UnrefFailNull)
+{
+ tbm_surface_internal_unref(NULL);
+}
+
+TEST_F(UtSurfaceInternal, UnrefFailInvaildInput)
+{
+ int surf;
+ tbm_surface_internal_unref((tbm_surface_h)&surf);
+}
+
+TEST_F(UtSurfaceInternal, UnrefSuccess)
+{
+ tbm_surface_internal_unref(surface);
+
+ ASSERT_FALSE(tbm_surface_internal_is_valid(surface)) ;
+
+ surface = NULL;
+}
+
+/* void tbm_surface_internal_ref(tbm_surface_h surface) */
+TEST_F(UtInit, RefFailNull)
+{
+ tbm_surface_internal_ref(NULL);
+}
+
+TEST_F(UtInit, RefFailInvaildInput)
+{
+ int surf;
+ tbm_surface_internal_ref((tbm_surface_h)&surf);
+}
+
+TEST_F(UtSurfaceInternal, RefSuccess)
+{
+ tbm_surface_internal_ref(surface);
+ tbm_surface_internal_unref(surface);
+ ASSERT_TRUE(tbm_surface_internal_is_valid(surface)) ;
+}
+
+/* tbm_surface_internal_get_num_planes() */
+TEST_F(UtInit, GetNumPlanes)
+{
+ int num = 0;
+ num = tbm_surface_internal_get_num_planes(0);
+ ASSERT_EQ(0, num);
+
+ num = tbm_surface_internal_get_num_planes(TBM_FORMAT_ARGB8888);
+ ASSERT_EQ(1, num);
+
+ num = tbm_surface_internal_get_num_planes(TBM_FORMAT_NV12);
+ ASSERT_EQ(2, num);
+
+ num = tbm_surface_internal_get_num_planes(TBM_FORMAT_YUV410);
+ ASSERT_EQ(3, num);
+}
+
+/* tbm_surface_internal_get_size() */
+TEST_F(UtSurfaceInternal, GetSizeFailNull)
+{
+ int size = tbm_surface_internal_get_size(NULL);
+ ASSERT_EQ(0, size);
+}
+
+TEST_F(UtSurfaceInternal, GetSizeFailInvaildInput)
+{
+ int surf;
+ int size = tbm_surface_internal_get_size((tbm_surface_h)&surf);
+ ASSERT_EQ(0, size);
+}
+
+TEST_F(UtSurfaceInternal, GetSizeSuccess)
+{
+ int size = tbm_surface_internal_get_size(surface);
+ ASSERT_GT(size, 0);
+}
+
+/* tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch) */
+TEST_F(UtSurfaceInternal, GetPlaneDataFailNull)
+{
+ ASSERT_FALSE(tbm_surface_internal_get_plane_data(NULL, 0, NULL, NULL, NULL));
+}
+
+TEST_F(UtSurfaceInternal, GetPlaneDataFailInvaildInput)
+{
+ int surf;
+
+ ASSERT_FALSE(tbm_surface_internal_get_plane_data((tbm_surface_h)&surf, 0, NULL, NULL, NULL));
+ ASSERT_FALSE(tbm_surface_internal_get_plane_data(surface, -1, NULL, NULL, NULL));
+ ASSERT_FALSE(tbm_surface_internal_get_plane_data(surface, 4, NULL, NULL, NULL));
+}
+
+TEST_F(UtSurfaceInternal, GetPlaneDataSuccess)
+{
+ uint32_t size = 0, offset = 0, pitch = 0;
+
+ ASSERT_TRUE(tbm_surface_internal_get_plane_data(surface, 0, &size, NULL, NULL));
+ ASSERT_GT(size, 0);
+
+ ASSERT_TRUE(tbm_surface_internal_get_plane_data(surface, 0, NULL, &offset, NULL));
+
+ ASSERT_TRUE(tbm_surface_internal_get_plane_data(surface, 0, NULL, NULL, &pitch));
+ ASSERT_GT(pitch, 0);
+}
+
+/* tbm_surface_internal_get_bpp(tbm_format format) */
+TEST_F(UtInit, GetBpp)
+{
+ int bpp = 0;
+ bpp = tbm_surface_internal_get_bpp(0);
+ ASSERT_EQ(0, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_RGB332);
+ ASSERT_EQ(8, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_RGB565);
+ ASSERT_EQ(16, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_RGB888);
+ ASSERT_EQ(24, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_ARGB8888);
+ ASSERT_EQ(32, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_NV12);
+ ASSERT_EQ(12, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_NV16);
+ ASSERT_EQ(16, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_YUV410);
+ ASSERT_EQ(9, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_YUV411);
+ ASSERT_EQ(12, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_YUV422);
+ ASSERT_EQ(16, bpp);
+
+ bpp = tbm_surface_internal_get_bpp(TBM_FORMAT_YUV444);
+ ASSERT_EQ(24, bpp);
+}
+/* tbm_surface_internal_get_plane_bo_idx(tbm_surface_h surface, int plane_idx) */
+TEST_F(UtSurfaceInternal, GetPlaneBoIndexFailNull)
+{
+ int idx = tbm_surface_internal_get_plane_bo_idx(NULL, 0);
+ ASSERT_EQ(0, idx);
+}
+
+TEST_F(UtSurfaceInternal, GetPlaneBoIndexFailInvaildInput)
+{
+ int surf;
+ int idx;
+
+ idx = tbm_surface_internal_get_plane_bo_idx((tbm_surface_h)&surf, 0);
+ ASSERT_EQ(0, idx);
+
+ idx = tbm_surface_internal_get_plane_bo_idx(surface, -1);
+ ASSERT_EQ(0, idx);
+}
+
+TEST_F(UtSurfaceInternal, GetPlaneBoIndexSuccess)
+{
+ int idx;
+
+ idx = tbm_surface_internal_get_plane_bo_idx(surface, 0);
+ ASSERT_EQ(0, idx);
+}
+
+static int tbm_data_free_is_called = 0;
+void data_free_handle(void *user_data)
+{
+ ASSERT_TRUE(user_data == &tbm_data_free_is_called);
+ int * is_called = user_data;
+ *((int *)user_data) = 1;
+}
+
+/* tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key, tbm_data_free data_free_func) */
+TEST_F(UtSurfaceInternal, AddUserDataFailNull)
+{
+ static const int key_ud;
+ ASSERT_FALSE(tbm_surface_internal_add_user_data(NULL, &key_ud, NULL));
+}
+
+TEST_F(UtSurfaceInternal, AddUserDataFailInvaildInput)
+{
+ static const int key_ud;
+ int surf;
+ ASSERT_FALSE(tbm_surface_internal_add_user_data((tbm_surface_h)&surf, &key_ud, NULL));
+}
+
+TEST_F(UtSurfaceInternal, AddUserDataSuccess)
+{
+ int key_ud;
+ ASSERT_TRUE(tbm_surface_internal_add_user_data(surface, &key_ud, NULL));
+}
+
+TEST_F(UtSurfaceInternal, AddUserDataFailDoubleKey)
+{
+ int key_ud;
+ ASSERT_TRUE(tbm_surface_internal_add_user_data(surface, &key_ud, NULL));
+
+ ASSERT_FALSE(tbm_surface_internal_add_user_data(surface, &key_ud, NULL));
+}
+
+/* tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key, void *data) */
+TEST_F(UtSurfaceInternal, SetUserDataFailNull)
+{
+ static const int key_ud;
+ ASSERT_FALSE(tbm_surface_internal_set_user_data(NULL, &key_ud, &tbm_data_free_is_called));
+}
+
+TEST_F(UtSurfaceInternal, SetUserDataFailInvaildInput)
+{
+ static const int key_ud;
+ int surf;
+
+ ASSERT_FALSE(tbm_surface_internal_set_user_data(surface,
+ &key_ud, &tbm_data_free_is_called)) << "invalid key";
+
+ ASSERT_FALSE(tbm_surface_internal_set_user_data((tbm_surface_h)&surf,
+ &key_ud, &tbm_data_free_is_called)) << "invalid surface";
+
+}
+
+TEST_F(UtSurfaceInternal, SetUserDataSuccess)
+{
+ int key_ud;
+ ASSERT_TRUE(tbm_surface_internal_add_user_data(surface, &key_ud, data_free_handle));
+
+ /*the first call*/
+ ASSERT_TRUE(tbm_surface_internal_set_user_data(surface, &key_ud, &tbm_data_free_is_called));
+
+ /*the second call: previous data has to be released*/
+ tbm_data_free_is_called = 0;
+ ASSERT_TRUE(tbm_surface_internal_set_user_data(surface, &key_ud, NULL));
+ ASSERT_TRUE(tbm_data_free_is_called);
+
+ /*the third call: previous data(NULL) hasn't to be released*/
+ tbm_data_free_is_called = 0;
+ ASSERT_TRUE(tbm_surface_internal_set_user_data(surface, &key_ud, NULL));
+ ASSERT_FALSE(tbm_data_free_is_called);
+}
+
+/* tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key, void **data) */
+TEST_F(UtSurfaceInternal, GetUserDataFailNull)
+{
+ static const int key_ud;
+ int * data = NULL;
+ ASSERT_FALSE(tbm_surface_internal_get_user_data(NULL, &key_ud, &data));
+
+ ASSERT_FALSE(tbm_surface_internal_get_user_data(surface, &key_ud, NULL));
+}
+
+TEST_F(UtSurfaceInternal, GetUserDataFailInvaildInput)
+{
+ static const int key_ud;
+ int surf;
+ int * data = NULL;
+
+ ASSERT_FALSE(tbm_surface_internal_get_user_data(surface,
+ &key_ud, &data)) << "invalid key";
+
+ ASSERT_FALSE(tbm_surface_internal_get_user_data((tbm_surface_h)&surf,
+ &key_ud, &data)) << "invalid surface";
+
+}
+
+TEST_F(UtSurfaceInternal, GetUserDataSuccess)
+{
+ int key_ud;
+ int * data = NULL;
+
+ ASSERT_TRUE(tbm_surface_internal_add_user_data(surface, &key_ud, data_free_handle));
+ ASSERT_TRUE(tbm_surface_internal_set_user_data(surface, &key_ud, &tbm_data_free_is_called));
+
+ /* check set data */
+ ASSERT_TRUE(tbm_surface_internal_get_user_data(surface, &key_ud, &data));
+ ASSERT_TRUE(data == &tbm_data_free_is_called);
+
+ /* check if data is NULL */
+ ASSERT_TRUE(tbm_surface_internal_set_user_data(surface, &key_ud, NULL));
+ ASSERT_TRUE(tbm_surface_internal_get_user_data(surface, &key_ud, &data));
+ ASSERT_TRUE(data == NULL);
+}
+
+/* tbm_surface_internal_delete_user_data(tbm_surface_h surface, unsigned long key) */
+TEST_F(UtSurfaceInternal, DeleteUserDataFailNull)
+{
+ static const int key_ud;
+ ASSERT_FALSE(tbm_surface_internal_delete_user_data(NULL, &key_ud));
+}
+
+TEST_F(UtSurfaceInternal, DeleteUserDataFailInvaildInput)
+{
+ static const int key_ud;
+ int surf;
+ ASSERT_FALSE(tbm_surface_internal_delete_user_data(surface, &key_ud)) << "invalid key";
+
+ ASSERT_FALSE(tbm_surface_internal_delete_user_data((tbm_surface_h)&surf, &key_ud)) << "invalid surface";
+
+}
+
+TEST_F(UtSurfaceInternal, DeleteUserDataSuccess)
+{
+ int key_ud;
+
+ ASSERT_TRUE(tbm_surface_internal_add_user_data(surface, &key_ud, data_free_handle));
+ ASSERT_TRUE(tbm_surface_internal_set_user_data(surface, &key_ud, &tbm_data_free_is_called));
+
+ tbm_data_free_is_called = 0;
+ ASSERT_TRUE(tbm_surface_internal_delete_user_data(surface, &key_ud));
+ ASSERT_TRUE(tbm_data_free_is_called);
+ ASSERT_FALSE(tbm_surface_internal_set_user_data(surface, &key_ud, &tbm_data_free_is_called));
+}