utest: add test for the API functions from tdm_surface_internal.h 49/159549/4
authorRoman Marchenko <r.marchenko@samsung.com>
Thu, 9 Nov 2017 14:44:47 +0000 (16:44 +0200)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 14 Nov 2017 22:28:10 +0000 (07:28 +0900)
Change-Id: I3ef4bb33238b1a8123831443ba69de8058e5a844
Signed-off-by: Roman Marchenko <r.marchenko@samsung.com>
utests/Makefile.am
utests/ut.cpp
utests/ut.h
utests/ut_tbm_surface.cpp
utests/ut_tbm_surface_internal.cpp [new file with mode: 0644]

index 8e67f5f316821720d50503a753a8bab768d0a97b..6965fd8d56f0c56211d045f95a8e0b59aa154fb5 100644 (file)
@@ -4,7 +4,8 @@ tbm_utests_SOURCES = \
        ut.cpp \
        ut_main.cpp \
        ut_tbm_bufmgr.cpp \
-       ut_tbm_surface.cpp
+       ut_tbm_surface.cpp \
+       ut_tbm_surface_internal.cpp
 
 tbm_utests_CXXFLAGS = \
        ${CXXFLAGS} \
index 4effef1d67956b3abe44ff2bfe6f6012b0a8aed4..9b769f51bd1a250a42bc5a7ef40c3b858f68daf3 100644 (file)
@@ -62,13 +62,13 @@ void ut_set_default_tbm_env()
        setenv("TBM_DISPLAY_SERVER", "1", 1);
 }
 
-int UtSurfaceInit::width = 720;
-int UtSurfaceInit::height = 1024;
-tbm_format UtSurfaceInit::format;
-int UtSurfaceInit::num_formats;
-tbm_format *UtSurfaceInit::formats;
+int UtSurface::width = 720;
+int UtSurface::height = 1024;
+tbm_format UtSurface::format;
+int UtSurface::num_formats;
+tbm_format *UtSurface::formats;
 
-void UtSurfaceInit::SetUpTestCase()
+void UtSurface::SetUpTestCase()
 {
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
 
@@ -86,13 +86,20 @@ void UtSurfaceInit::SetUpTestCase()
                format = formats[0];
 }
 
-void UtSurfaceInit::SetUp()
+void UtSurface::TearDownTestCase()
+{
+       if (formats)
+               free(formats);
+}
+
+
+void UtSurface::SetUp()
 {
        surface = tbm_surface_create(width, height, format);
        ASSERT_TRUE(surface != NULL);
 }
 
-void UtSurfaceInit::TearDown()
+void UtSurface::TearDown()
 {
        if (surface)
                tbm_surface_destroy(surface);
index 07486e740d145dd55a589c8f8245bad7ca6faa97..0d272e4697e2f09be161c0fc53e5297633fb85ab 100644 (file)
@@ -49,10 +49,11 @@ void ut_set_default_tbm_env();
 
 /* test fixture class, which initializes bufmgr and allocate the tbm surface before the tests and
  * deinitializes bufmgr after tests which use the test fixture with this class */
-class UtSurfaceInit : public ::testing::Test
+class UtSurface : public ::testing::Test
 {
 protected:
        static void SetUpTestCase();
+       static void TearDownTestCase();
        void SetUp();
        void TearDown();
 public:
@@ -66,5 +67,7 @@ public:
        tbm_surface_h surface;
 };
 
+typedef UtSurface UtSurfaceInternal;
+
 
 #endif // UT_H
index 64366c71c5894f7164d730ce97af109e807b6a60..f02ebca44a2423abe9d8ab27b23294c760b675d9 100644 (file)
@@ -34,7 +34,7 @@ TEST_F(UtInit, SurfaceQueryFormatSuccess)
        ASSERT_NE(NULL, formats);
        for (int i = 0; i < num; i++)
                ASSERT_NE(0, formats[i]);
-
+       free(formats);
 }
 
 TEST_F(UtInit, SurfaceCeateFailInvalidGeometry)
@@ -73,64 +73,64 @@ TEST_F(UtInit, SurfaceCeateSuccess)
        }
 }
 
-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;
@@ -140,7 +140,7 @@ TEST_F(UtSurfaceInit, SurfaceGetInfoInvalideInput)
        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;
@@ -155,7 +155,7 @@ TEST_F(UtSurfaceInit, SurfaceGetInfoFailNull)
        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;
@@ -170,7 +170,7 @@ TEST_F(UtSurfaceInit, SurfaceGetInfoSuccess)
        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;
@@ -180,7 +180,7 @@ TEST_F(UtSurfaceInit, SurfaceMapFailInvalideInput)
        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;
@@ -192,7 +192,7 @@ TEST_F(UtSurfaceInit, SurfaceMapFailNull)
        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;
@@ -210,7 +210,7 @@ TEST_F(UtSurfaceInit, SurfaceMapSuccess)
        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;
@@ -218,7 +218,7 @@ TEST_F(UtSurfaceInit, SurfaceUnmapFailInvalideInput)
        ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
 }
 
-TEST_F(UtSurfaceInit, SurfaceUnmapFailNull)
+TEST_F(UtSurface, SurfaceUnmapFailNull)
 {
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
 
diff --git a/utests/ut_tbm_surface_internal.cpp b/utests/ut_tbm_surface_internal.cpp
new file mode 100644 (file)
index 0000000..a69b2d8
--- /dev/null
@@ -0,0 +1,580 @@
+#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));
+}