--- /dev/null
+#include <gtest/gtest.h>
+#include <stdlib.h>
+
+#include <tbm_bufmgr.h>
+#include <tbm_surface.h>
+#include "ut.h"
+
+TEST_F(UtInit, SurfaceQueryFormatsFailNull)
+{
+ int num = 0;
+ tbm_format *formats = NULL;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ ut_set_default_tbm_env();
+
+ result = tbm_surface_query_formats(&formats, NULL);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+
+ result = tbm_surface_query_formats(NULL, &num);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+}
+
+TEST_F(UtInit, SurfaceQueryFormatSuccess)
+{
+ int num = 0;
+ tbm_format *formats = NULL;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ ut_set_default_tbm_env();
+
+ result = tbm_surface_query_formats(&formats, &num);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+ ASSERT_NE(0, num);
+ ASSERT_NE(NULL, formats);
+ for (int i = 0; i < num; i++)
+ ASSERT_NE(0, formats[i]);
+
+}
+
+TEST_F(UtInit, SurfaceCeateFailInvalidGeometry)
+{
+ tbm_surface_h surface = NULL;
+
+ ut_set_default_tbm_env();
+
+ surface = tbm_surface_create(-1, 1024, TBM_FORMAT_ARGB8888);
+ ASSERT_EQ(NULL, surface); // Expected Value: NULL
+
+ surface = tbm_surface_create(720, -1, TBM_FORMAT_ARGB8888);
+ ASSERT_EQ(NULL, surface);
+
+ surface = tbm_surface_create(720, 1024, 0);
+ ASSERT_EQ(NULL, surface);
+}
+
+TEST_F(UtInit, SurfaceCeateSuccess)
+{
+ tbm_surface_h surface = NULL;
+ int num = 0;
+ tbm_format *formats = NULL;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ ut_set_default_tbm_env();
+
+ result = tbm_surface_query_formats(&formats, &num);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+
+ for (int i = 0; i < num; i++) {
+ surface = tbm_surface_create(720, 1024, formats[i]);
+ ASSERT_NE(NULL, surface);
+ result = tbm_surface_destroy(surface);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+ }
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetFormatFailInvalideInput)
+{
+ 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)
+{
+ tbm_format fmt = tbm_surface_get_format(NULL);
+ ASSERT_EQ(0, fmt);
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetFormatSuccess)
+{
+ tbm_format fmt = tbm_surface_get_format(surface);
+ ASSERT_EQ(this->format, fmt);
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetWidthFailInvalideInput)
+{
+ 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)
+{
+ int width = tbm_surface_get_width(NULL);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, width);
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetWidthSuccess)
+{
+ int width = tbm_surface_get_width(surface);
+ ASSERT_EQ(this->width, width);
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetHeightFailInvalideInput)
+{
+ 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)
+{
+ int height = tbm_surface_get_height(NULL);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, height);
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetHeightSuccess)
+{
+ int height = tbm_surface_get_height(surface);
+ ASSERT_EQ(this->height, height);
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetInfoInvalideInput)
+{
+ tbm_surface_h invalide_surface = (tbm_surface_h)1;
+ tbm_surface_info_s info;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ result = tbm_surface_get_info(invalide_surface, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_OPERATION, result);
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetInfoFailNull)
+{
+ tbm_surface_info_s info;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ result = tbm_surface_get_info(surface, NULL);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+
+ result = tbm_surface_get_info(NULL, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+
+ result = tbm_surface_get_info(NULL, NULL);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+}
+
+TEST_F(UtSurfaceInit, SurfaceGetInfoSuccess)
+{
+ tbm_surface_info_s info;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ result = tbm_surface_get_info(surface, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+ ASSERT_EQ(this->format, info.format);
+ ASSERT_EQ(this->height, info.height);
+ ASSERT_EQ(this->width, info.width);
+ ASSERT_GT(info.num_planes, 0);
+ ASSERT_GT(info.bpp, 0);
+ ASSERT_GT(info.size, 0);
+}
+
+TEST_F(UtSurfaceInit, SurfaceMapFailInvalideInput)
+{
+ tbm_surface_info_s info;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+ tbm_surface_h invalide_surface = (tbm_surface_h)1;
+
+ result = tbm_surface_map(invalide_surface, 0, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_OPERATION, result);
+}
+
+TEST_F(UtSurfaceInit, SurfaceMapFailNull)
+{
+ tbm_surface_info_s info;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ result = tbm_surface_map(surface, 0, NULL);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+
+ result = tbm_surface_map(NULL, 0, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+}
+
+TEST_F(UtSurfaceInit, SurfaceMapSuccess)
+{
+ tbm_surface_info_s info;
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ result = tbm_surface_map(surface, 0, &info);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+ ASSERT_EQ(this->format, info.format);
+ ASSERT_EQ(this->height, info.height);
+ ASSERT_EQ(this->width, info.width);
+ ASSERT_GT(info.num_planes, 0);
+ ASSERT_GT(info.bpp, 0);
+ ASSERT_GT(info.size, 0);
+
+ result = tbm_surface_unmap(surface);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceInit, SurfaceUnmapFailInvalideInput)
+{
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+ tbm_surface_h invalide_surface = (tbm_surface_h)1;
+ result = tbm_surface_unmap(invalide_surface);
+ ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+}
+
+TEST_F(UtSurfaceInit, SurfaceUnmapFailNull)
+{
+ tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
+
+ result = tbm_surface_unmap(NULL);
+ ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+}
+