utest: check the tbm_error_e for the surface tests 98/177198/1
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 24 Apr 2018 12:24:18 +0000 (21:24 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 26 Apr 2018 04:03:55 +0000 (13:03 +0900)
Change-Id: I17ab9c4a65e177c3df5a6c04b4a6da972c94870d

utests/ut_tbm_surface.cpp

index ed56774a34b00e62d2f9a4d994047ef417529c41..4e4f64cd3a173203f384d3d0af3abb008cd0f8b2 100644 (file)
 
 #include "ut_tbm.h"
 
+/* The tbm_surface.h contains the public APIs. Therefore, the error values has TBM_SURFACE_ prefix,
+ * but the values of the TBM_SURFACE_ prefix error types has the same vaules as TBM_ERROR_ prefix types.
+ * We check the two error types in this TBMSurface testcase.
+ */
+
 class TBMSurface : public TBMBufmgr
 {
 protected:
@@ -51,7 +56,8 @@ void TBMSurface::SetUp()
        TBMBufmgr::SetUp();
 
        result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, &num_formats);
-       ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+       ASSERT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       ASSERT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_NONE));
 
        for (uint32_t i = 0; i < num_formats; i++)
                if (formats[i] == TBM_FORMAT_ARGB8888)
@@ -64,12 +70,16 @@ void TBMSurface::SetUp()
        height = 1024;
        surface = tbm_surface_internal_create_with_flags(width, height, format, TBM_BO_DEFAULT);
        ASSERT_TRUE(surface != NULL);
+       ASSERT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       ASSERT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
 }
 
 void TBMSurface::TearDown()
 {
        if (surface)
                tbm_surface_internal_destroy(surface);
+       ASSERT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       ASSERT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
 
        if (formats)
                free(formats);
@@ -82,13 +92,19 @@ TEST_F(TBMSurface, SurfaceCeateFailInvalidGeometry)
        tbm_surface_h surf1 = NULL;
 
        surf1 = tbm_surface_create(-1, 1024, TBM_FORMAT_ARGB8888);
-       ASSERT_EQ(nullptr, surf1); // Expected Value: NULL
+       EXPECT_EQ(nullptr, surf1); // Expected Value: NULL
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 
        surf1 = tbm_surface_create(720, -1, TBM_FORMAT_ARGB8888);
-       ASSERT_EQ(nullptr, surf1);
+       EXPECT_EQ(nullptr, surf1);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 
        surf1 = tbm_surface_create(720, 1024, 0);
-       ASSERT_EQ(nullptr, surf1);
+       EXPECT_EQ(nullptr, surf1);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceCeateSuccess)
@@ -98,9 +114,12 @@ TEST_F(TBMSurface, SurfaceCeateSuccess)
 
        for (uint32_t i = 0; i < num_formats; i++) {
                surf1 = tbm_surface_create(720, 1024, formats[i]);
-               ASSERT_NE((tbm_surface_h)NULL, surf1);
+               EXPECT_NE((tbm_surface_h)NULL, surf1);
+               EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+               EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
                result = (tbm_surface_error_e)tbm_surface_destroy(surf1);
-               ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+               EXPECT_EQ(TBM_SURFACE_ERROR_NONE, result);
+               EXPECT_EQ(TBM_ERROR_NONE, result);
        }
 }
 
@@ -108,57 +127,75 @@ TEST_F(TBMSurface, SurfaceGetFormatFailInvalidInput)
 {
        tbm_surface_h invalid_surface = (tbm_surface_h)1;
        tbm_format fmt = tbm_surface_get_format(invalid_surface);
-       ASSERT_EQ(0, fmt);
+       EXPECT_EQ(0, fmt);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceGetFormatFailNull)
 {
        tbm_format fmt = tbm_surface_get_format(NULL);
-       ASSERT_EQ(0, fmt);
+       EXPECT_EQ(0, fmt);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceGetFormatSuccess)
 {
        tbm_format fmt = tbm_surface_get_format(surface);
-       ASSERT_EQ(this->format, fmt);
+       EXPECT_EQ(this->format, fmt);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
 }
 
 TEST_F(TBMSurface, SurfaceGetWidthFailInvalidInput)
 {
        tbm_surface_h invalid_surface = (tbm_surface_h)1;
        int width = tbm_surface_get_width(invalid_surface);
-       ASSERT_EQ(0, width);
+       EXPECT_EQ(0, width);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceGetWidthFailNull)
 {
        int width = tbm_surface_get_width(NULL);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, width);
+       EXPECT_EQ(width, 0);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceGetWidthSuccess)
 {
        int width = tbm_surface_get_width(surface);
-       ASSERT_EQ(this->width, width);
+       EXPECT_EQ(this->width, width);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
 }
 
 TEST_F(TBMSurface, SurfaceGetHeightFailInvalidInput)
 {
        tbm_surface_h invalid_surface = (tbm_surface_h)1;
        int height = tbm_surface_get_height(invalid_surface);
-       ASSERT_EQ(0, height);
+       EXPECT_EQ(0, height);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceGetHeightFailNull)
 {
        int height = tbm_surface_get_height(NULL);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, height);
+       EXPECT_EQ(height, 0);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceGetHeightSuccess)
 {
        int height = tbm_surface_get_height(surface);
-       ASSERT_EQ(this->height, height);
+       EXPECT_EQ(this->height, height);
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
 }
 
 TEST_F(TBMSurface, SurfaceGetInfoInvalidInput)
@@ -168,7 +205,8 @@ TEST_F(TBMSurface, SurfaceGetInfoInvalidInput)
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
 
        result = (tbm_surface_error_e)tbm_surface_get_info(invalid_surface, &info);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_OPERATION, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceGetInfoFailNull)
@@ -177,13 +215,16 @@ TEST_F(TBMSurface, SurfaceGetInfoFailNull)
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
 
        result = (tbm_surface_error_e)tbm_surface_get_info(surface, NULL);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 
        result = (tbm_surface_error_e)tbm_surface_get_info(NULL, &info);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 
        result = (tbm_surface_error_e)tbm_surface_get_info(NULL, NULL);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceGetInfoSuccess)
@@ -192,13 +233,14 @@ TEST_F(TBMSurface, SurfaceGetInfoSuccess)
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
 
        result = (tbm_surface_error_e)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);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_NONE));
+       EXPECT_EQ(this->format, info.format);
+       EXPECT_EQ(this->height, info.height);
+       EXPECT_EQ(this->width, info.width);
+       EXPECT_GT(info.num_planes, 0);
+       EXPECT_GT(info.bpp, 0);
+       EXPECT_GT(info.size, 0);
 }
 
 TEST_F(TBMSurface, SurfaceMapFailInvalidInput)
@@ -208,7 +250,8 @@ TEST_F(TBMSurface, SurfaceMapFailInvalidInput)
        tbm_surface_h invalid_surface = (tbm_surface_h)1;
 
        result = (tbm_surface_error_e)tbm_surface_map(invalid_surface, 0, &info);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_OPERATION, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceMapFailNull)
@@ -217,10 +260,12 @@ TEST_F(TBMSurface, SurfaceMapFailNull)
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
 
        result = (tbm_surface_error_e)tbm_surface_map(surface, 0, NULL);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 
        result = (tbm_surface_error_e)tbm_surface_map(NULL, 0, &info);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceMapSuccess)
@@ -229,16 +274,18 @@ TEST_F(TBMSurface, SurfaceMapSuccess)
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
 
        result = (tbm_surface_error_e)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);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_NONE));
+       EXPECT_EQ(this->format, info.format);
+       EXPECT_EQ(this->height, info.height);
+       EXPECT_EQ(this->width, info.width);
+       EXPECT_GT(info.num_planes, 0);
+       EXPECT_GT(info.bpp, 0);
+       EXPECT_GT(info.size, 0);
 
        result = (tbm_surface_error_e)tbm_surface_unmap(surface);
-       ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_NONE));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_NONE));
 }
 
 TEST_F(TBMSurface, SurfaceUnmapFailInvalidInput)
@@ -246,7 +293,8 @@ TEST_F(TBMSurface, SurfaceUnmapFailInvalidInput)
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
        tbm_surface_h invalid_surface = (tbm_surface_h)1;
        result = (tbm_surface_error_e)tbm_surface_unmap(invalid_surface);
-       ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }
 
 TEST_F(TBMSurface, SurfaceUnmapFailNull)
@@ -254,6 +302,7 @@ TEST_F(TBMSurface, SurfaceUnmapFailNull)
        tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE;
 
        result = (tbm_surface_error_e)tbm_surface_unmap(NULL);
-       ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result);
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_SURFACE_ERROR_INVALID_PARAMETER));
+       EXPECT_STREQ(tbm_error_str(result), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
 }