From: SooChan Lim Date: Mon, 5 Mar 2018 03:51:35 +0000 (+0900) Subject: utest: redesign the utest X-Git-Tag: submit/tizen/20180307.041358~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15cad1cc4a1d78b0928a16be30fa28b8b9a7c7e0;p=platform%2Fcore%2Fuifw%2Flibtbm.git utest: redesign the utest Change-Id: Iaa0d5308b1992c3ef496d3364d21316b5c70d61c --- diff --git a/Makefile.am b/Makefile.am index ff28ee4..f058365 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,3 @@ - if HAVE_UTEST SUBDIRS = src utests else diff --git a/utests/Makefile.am b/utests/Makefile.am index 1f4ca95..7b70a5c 100644 --- a/utests/Makefile.am +++ b/utests/Makefile.am @@ -1,9 +1,10 @@ bin_PROGRAMS = tbm-utests tbm_utests_SOURCES = \ - ut.cpp \ ut_main.cpp \ + ut_tbm_env.cpp \ ut_tbm_bufmgr.cpp \ + ut_tbm_bo.cpp \ ut_tbm_surface.cpp \ ut_tbm_surface_internal.cpp \ ut_tbm_surface_queue.cpp diff --git a/utests/ut.cpp b/utests/ut.cpp deleted file mode 100644 index 2c3ce8a..0000000 --- a/utests/ut.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "ut.h" - -void BufmgrTest::SetUp() -{ - ut_set_default_tbm_env(); - - bufmgr = tbm_bufmgr_init(-1); - ASSERT_TRUE(bufmgr != NULL); - - bufmgr_capability = tbm_bufmgr_get_capability(bufmgr); -} - -void BufmgrTest::TearDown() -{ - tbm_bufmgr_deinit(bufmgr); -} - -void BufmgrBoTest::SetUp() -{ - ut_set_default_tbm_env(); - - bufmgr = tbm_bufmgr_init(-1); - ASSERT_TRUE(bufmgr != NULL); - - bufmgr_capability = tbm_bufmgr_get_capability(bufmgr); - - bo_size = 1024; - bo_flags = 154797; - - bo = tbm_bo_alloc(bufmgr, bo_size, bo_flags); - ASSERT_TRUE(bo != NULL); -} - -void BufmgrBoTest::TearDown() -{ - tbm_bo_unref(bo); - tbm_bufmgr_deinit(bufmgr); -} - -void BufmgrBoLockTypeTest::UtBufmgrInit() -{ - ut_set_default_tbm_env(); - - bufmgr = tbm_bufmgr_init(-1); - ASSERT_TRUE(bufmgr != NULL); -} - -void BufmgrBoLockTypeTest::SetUp() -{ - bufmgr = NULL; -} - -void BufmgrBoLockTypeTest::TearDown() -{ - if (bufmgr) - tbm_bufmgr_deinit(bufmgr); -} - -void ut_set_default_tbm_env() -{ - setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("TBM_DISPLAY_SERVER", "1", 1); -} - -int SurfaceTest::width = 720; -int SurfaceTest::height = 1024; -tbm_format SurfaceTest::format; -uint32_t SurfaceTest::num_formats; -tbm_format *SurfaceTest::formats; - -void SurfaceTest::SetUpTestCase() -{ - tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; - - ut_set_default_tbm_env(); - - result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, &num_formats); - ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result); - - for (uint32_t i = 0; i < num_formats; i++) - if (formats[i] == TBM_FORMAT_ARGB8888) - format = TBM_FORMAT_ARGB8888; - - /* if TBM_FORMAT_ARGB8888 isn't supported take the first */ - if (format == 0) - format = formats[0]; -} - -void SurfaceTest::TearDownTestCase() -{ - if (formats) - free(formats); -} - - -void SurfaceTest::SetUp() -{ - surface = tbm_surface_create(width, height, format); - ASSERT_TRUE(surface != NULL); -} - -void SurfaceTest::TearDown() -{ - if (surface) - tbm_surface_destroy(surface); -} - -void SurfaceQueryFormatsTest::SetUp() -{} - -void SurfaceQueryFormatsTest::TearDown() -{} - -int SurfaceQueueTest::width = 720; -int SurfaceQueueTest::height = 1024; -int SurfaceQueueTest::format; -uint32_t SurfaceQueueTest::num_formats; -tbm_format *SurfaceQueueTest::formats; - -void SurfaceQueueTest::SetUpTestCase() -{ - tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; - - ut_set_default_tbm_env(); - - result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, &num_formats); - ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result); - - for (uint32_t i = 0; i < num_formats; i++) - if (formats[i] == TBM_FORMAT_ARGB8888) - format = TBM_FORMAT_ARGB8888; - - /* if TBM_FORMAT_ARGB8888 isn't supported take the first */ - if (format == 0) - format = formats[0]; -} - -void SurfaceQueueTest::TearDownTestCase() -{ - if (formats) - free(formats); -} - -void SurfaceQueueTest::SetUp() -{ - alien_surface = tbm_surface_create(width, height, format); - ASSERT_NE((tbm_surface_h)NULL, alien_surface); - - queue = tbm_surface_queue_create(QUEUE_SIZE, width, height, format, TBM_BO_DEFAULT); - ASSERT_NE((tbm_surface_queue_h)NULL, queue); -} - -void SurfaceQueueTest::TearDown() -{ - if (alien_surface) - tbm_surface_destroy(alien_surface); - - if (queue) - tbm_surface_queue_destroy(queue); - -} - diff --git a/utests/ut.h b/utests/ut.h deleted file mode 100644 index a048350..0000000 --- a/utests/ut.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef UT_H -#define UT_H - -#include "gtest/gtest.h" -#include -#include -#include -#include -#include - -/* The test fixture class, which initializes the bufmgr before and deinitializes - * after the tests which use the test fixture with this class */ -class BufmgrTest : public ::testing::Test -{ -protected: - void SetUp(); - void TearDown(); -public: - tbm_bufmgr bufmgr; - unsigned int bufmgr_capability; -}; - -/* test fixture class, which initializes bufmgr and allocate the bo before the tests and - * deinitializes bufmgr after tests which use the test fixture with this class */ -class BufmgrBoTest : public ::testing::Test -{ -protected: - void SetUp(); - void TearDown(); -public: - tbm_bufmgr bufmgr; - unsigned int bufmgr_capability; - tbm_bo bo; - int bo_size; - int bo_flags; -}; - -/* The test fixture class, which deinitializes bufmgr after the test is finished. -To init bufmgr you need to call UtBufmgrInit() func. Do not call tbm_bufmgr_init() -directly because deinitialization won't be called if test is failed */ -class BufmgrBoLockTypeTest : public ::testing::Test -{ -protected: - void SetUp(); - void TearDown(); -public: - void UtBufmgrInit(); - tbm_bufmgr bufmgr; -}; - -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 SurfaceTest : public ::testing::Test -{ -protected: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); -public: - static int width; - static int height; - static tbm_format format; - - static uint32_t num_formats; - static tbm_format *formats; - - tbm_surface_h surface; -}; - -/* The test fixture class, which deinitializes bufmgr after the test is finished. -To init bufmgr you need to call UtBufmgrInit() func. Do not call tbm_bufmgr_init() -directly because deinitialization won't be called if test is failed */ -class SurfaceQueryFormatsTest : public ::testing::Test -{ -protected: - void SetUp(); - void TearDown(); -public: -}; - -typedef SurfaceTest SurfaceInternalTest; -typedef SurfaceQueryFormatsTest SurfaceInternalQueryFormatsTest; - -#define QUEUE_SIZE 3 - -class SurfaceQueueTest : public ::testing::Test -{ -protected: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); -public: - static int width; - static int height; - static int format; - - static uint32_t num_formats; - static tbm_format *formats; - - tbm_surface_h alien_surface; - tbm_surface_queue_h queue; - - tbm_surface_queue_error_e result; - tbm_surface_h surface; -}; - - - -#endif // UT_H diff --git a/utests/ut_main.cpp b/utests/ut_main.cpp index 64b9c32..48fedd6 100644 --- a/utests/ut_main.cpp +++ b/utests/ut_main.cpp @@ -1,3 +1,33 @@ +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Konstantin Drabeniuk + * Contact: Andrii Sokolenko + * Contact: Roman Marchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + #include "gtest/gtest.h" #ifdef TIZEN_TEST_GCOV diff --git a/utests/ut_tbm.h b/utests/ut_tbm.h new file mode 100644 index 0000000..a3f05aa --- /dev/null +++ b/utests/ut_tbm.h @@ -0,0 +1,128 @@ +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Konstantin Drabeniuk + * Contact: Andrii Sokolenko + * Contact: Roman Marchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#ifndef UT_H +#define UT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#undef TBM_DBG +#define TBM_DBG(fmt, args...) \ + TBM_LOG_D(fmt, ##args); +#undef TBM_INFO +#define TBM_INFO(fmt, args...) \ + TBM_LOG_I(fmt, ##args); +#undef TBM_WRN +#define TBM_WRN(fmt, args...) \ + TBM_LOG_W(fmt, ##args); +#undef TBM_ERR +#define TBM_ERR(fmt, args...) \ + TBM_LOG_E(fmt, ##args); + +#define TBM_UT_ENTRY() \ + TBM_INFO("--------------------------------------------- %s", typeid(*this).name()) + +#define TBM_UT_CHECK_FLAG(FLAG) \ + do {\ + if(!(FLAG)) \ + TBM_INFO("[ ] not supported");\ + } while(0) + +#define TBM_UT_SKIP_FLAG(FLAG) \ + do {\ + if(!(FLAG)) {\ + TBM_INFO("[ SKIPPED ] not supported");\ + return;\ + }\ + } while(0) + +#define TBM_UT_NEVER_GET_HERE() \ + do {\ + TBM_INFO("!!! TBM UT NEVER GET HERE !!!");\ + } while(0) +#define TBM_UT_RETURN_IF_FAIL(cond) { \ + if (!(cond)) { \ + TBM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \ + return; \ + } \ +} +#define TBM_UT_RETURN_FALSE_IF_FAIL(cond) { \ + if (!(cond)) { \ + TBM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \ + return false; \ + } \ +} +#define TBM_UT_GOTO_IF_FAIL(cond, dst) { \ + if (!(cond)) { \ + TBM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \ + goto dst; \ + } \ +} + +#define TBM_UT_DUMP_DIR "/tmp/tbm_dump" +#define UT_TBM_INVALID_VALUE -42 +#define TBM_UT_INVALID_UINT_VALUE 99999 +#define UT_TBM_BO_SIZE 1024 +#define UT_TBM_SURFACE_QUEUE_SIZE 4 + +using ::testing::TestWithParam; +using ::testing::Bool; +using ::testing::Values; +using ::testing::Combine; + +class TBMEnv : public TestWithParam< ::testing::tuple > +{ +public: + void SetUp(void); + void TearDown(void); +}; + +class TBMBufmgr : public TBMEnv +{ +public: + TBMBufmgr(); + void SetUp(void); + void TearDown(void); + + tbm_bufmgr bufmgr; +}; + +#endif // UT_H diff --git a/utests/ut_tbm_bo.cpp b/utests/ut_tbm_bo.cpp new file mode 100644 index 0000000..2e176f8 --- /dev/null +++ b/utests/ut_tbm_bo.cpp @@ -0,0 +1,1076 @@ + +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Konstantin Drabeniuk + * Contact: Andrii Sokolenko + * Contact: Roman Marchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#include "ut_tbm.h" + +class TBMBo : public TBMBufmgr +{ +public: + TBMBo(); + void SetUp(void); + void TearDown(void); + + unsigned int bufmgr_capability; +}; + +TBMBo::TBMBo() +{ + bufmgr_capability = TBM_BUFMGR_CAPABILITY_NONE; +} + +void TBMBo::SetUp() +{ + TBMBufmgr::SetUp(); + + bufmgr_capability = tbm_bufmgr_get_capability(bufmgr); + ASSERT_TRUE(bufmgr_capability != TBM_BUFMGR_CAPABILITY_NONE); +} + +void TBMBo::TearDown() +{ + TBMBufmgr::TearDown(); +} + +/* tbm_bo_alloc() */ + +TEST_P(TBMBo, BoAllocUnref) +{ + tbm_bo bo; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoAllocWithBufmgrParamTest) +{ + tbm_bo bo; + tbm_bufmgr invalid_bufmgr; + + invalid_bufmgr = NULL; + bo = tbm_bo_alloc(invalid_bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo == NULL); + + invalid_bufmgr = (tbm_bufmgr)TBM_UT_INVALID_UINT_VALUE; + bo = tbm_bo_alloc(invalid_bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo == NULL); +} + +TEST_P(TBMBo, BoAllocWithSizeParamTest) +{ + tbm_bo bo; + + bo = tbm_bo_alloc(bufmgr, -1, TBM_BO_DEFAULT); + ASSERT_TRUE(bo == NULL); +} + +TEST_P(TBMBo, BoAllocWithFlagsParamTest) +{ + tbm_bo bo; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + tbm_bo_unref(bo); + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_SCANOUT); + ASSERT_TRUE(bo != NULL); + tbm_bo_unref(bo); + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_NONCACHABLE); + ASSERT_TRUE(bo != NULL); + tbm_bo_unref(bo); + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_WC); + ASSERT_TRUE(bo != NULL); + tbm_bo_unref(bo); +} + +/* tbm_bo_ref() */ + +TEST_P(TBMBo, BoRef) +{ + tbm_bo bo; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + bo = tbm_bo_ref(bo); + ASSERT_TRUE(bo != NULL); + + tbm_bo_unref(bo); + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoRefWithBoParamTest) +{ + tbm_bo bo, invalid_bo; + + bo = tbm_bo_ref(NULL); + ASSERT_TRUE(bo == NULL); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + bo = tbm_bo_ref(invalid_bo); + ASSERT_TRUE(bo == NULL); +} + +/* tbm_bo_unref() */ + +TEST_P(TBMBo, BoUnrefWithBoParamTest) +{ + tbm_bo invalid_bo; + + tbm_bo_unref(NULL); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + tbm_bo_unref(invalid_bo); + + SUCCEED(); +} + +/* tbm_bo_map() */ + +TEST_P(TBMBo, BoMapUnmap) +{ + tbm_bo bo; + tbm_bo_handle bo_handle; + int ret; + tbm_error_e error; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ); + error = tbm_get_last_error(); + EXPECT_TRUE(error != TBM_BO_ERROR_LOCK_FAILED); + error = tbm_get_last_error(); + EXPECT_TRUE(error != TBM_BO_ERROR_MAP_FAILED); + ASSERT_TRUE(bo_handle.ptr != NULL); + + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoMapWithBoParamTest) +{ + tbm_bo invalid_bo; + tbm_bo_handle bo_handle; + + bo_handle = tbm_bo_map(NULL, TBM_DEVICE_CPU, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr == NULL); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + bo_handle = tbm_bo_map(invalid_bo, TBM_DEVICE_CPU, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr == NULL); +} + +// TODO:: Use Value-Parameterized?? +TEST_P(TBMBo, BoMapWithDeviceParamTest) +{ + tbm_bo bo; + tbm_bo_handle bo_handle; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_DEFAULT, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr != NULL); + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr != NULL); + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr != NULL); + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_3D, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr != NULL); + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_MM, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr != NULL); + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + tbm_bo_unref(bo); +} + +// TODO:: Use Value-Parameterized?? +TEST_P(TBMBo, BoMapWithOptParamTest) +{ + tbm_bo bo; + tbm_bo_handle bo_handle; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr != NULL); + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE); + ASSERT_TRUE(bo_handle.ptr != NULL); + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ|TBM_OPTION_WRITE); + ASSERT_TRUE(bo_handle.ptr != NULL); + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + tbm_bo_unref(bo); +} + +/* tbm_bo_unmap() */ + +TEST_P(TBMBo, BoUnmapWithBoParamTest) +{ + tbm_bo bo; + tbm_bo invalid_bo; + int ret; + + ret = tbm_bo_unmap(NULL); + ASSERT_TRUE(ret == 0); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + ret = tbm_bo_unmap(invalid_bo); + ASSERT_TRUE(ret == 0); + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + ret = tbm_bo_unmap(invalid_bo); + ASSERT_TRUE(ret == 0); + tbm_bo_unref(bo); + +} + +/* tbm_bo_get_handle() */ + +TEST_P(TBMBo, BoGetHandle) +{ + tbm_bo bo; + tbm_bo_handle bo_handle; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_CPU); + ASSERT_TRUE(bo_handle.ptr != NULL); + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoGetHandleWithBoParamTest) +{ + tbm_bo_handle bo_handle; + tbm_bo invalid_bo; + + bo_handle = tbm_bo_get_handle(NULL, TBM_DEVICE_DEFAULT); + ASSERT_TRUE(bo_handle.ptr == NULL); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + bo_handle = tbm_bo_get_handle(invalid_bo, TBM_DEVICE_DEFAULT); + ASSERT_TRUE(bo_handle.ptr == NULL); +} + +TEST_P(TBMBo, BoGetHandleWithDeviceParamTest) +{ + tbm_bo bo; + tbm_bo_handle bo_handle; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_DEFAULT); + ASSERT_TRUE(bo_handle.ptr != NULL); + + bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_CPU); + ASSERT_TRUE(bo_handle.ptr != NULL); + + bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_2D); + ASSERT_TRUE(bo_handle.ptr != NULL); + + bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_3D); + ASSERT_TRUE(bo_handle.ptr != NULL); + + bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_MM); + ASSERT_TRUE(bo_handle.ptr != NULL); + + tbm_bo_unref(bo); +} + +/* tbm_bo_export() */ + +TEST_P(TBMBo, BoExport) +{ + tbm_bo bo; + tbm_key bo_key; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) + return; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + bo_key = tbm_bo_export(bo); + ASSERT_TRUE(bo_key != 0); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoExportWithBoParamTest) +{ + tbm_bo invalid_bo; + tbm_key bo_key; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) + return; + + bo_key = tbm_bo_export(NULL); + ASSERT_TRUE(bo_key == 0); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + bo_key = tbm_bo_export(invalid_bo); + ASSERT_TRUE(bo_key == 0); +} + +/* tbm_bo_export_fd() */ + +TEST_P(TBMBo, BoExportFd) +{ + tbm_bo bo; + tbm_fd bo_fd; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) + return; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + bo_fd = tbm_bo_export_fd(bo); + ASSERT_TRUE(bo_fd != 0); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoExportFdWithBoParamTest) +{ + tbm_bo invalid_bo; + tbm_fd bo_fd; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) + return; + + bo_fd = tbm_bo_export_fd(NULL); + ASSERT_TRUE(bo_fd == -1); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + bo_fd = tbm_bo_export_fd(invalid_bo); + ASSERT_TRUE(bo_fd == -1); +} + +/* tbm_bo_import() */ + +TEST_P(TBMBo, BoImport) +{ + tbm_bo bo1, bo2; + tbm_key bo_key; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) + return; + + bo1 = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo1 != NULL); + + bo_key = tbm_bo_export(bo1); + ASSERT_TRUE(bo_key != 0); + + bo2 = tbm_bo_import(bufmgr, bo_key); + ASSERT_TRUE(bo2 != NULL); + + tbm_bo_unref(bo2); + tbm_bo_unref(bo1); +} + +TEST_P(TBMBo, BoImportWithBufmgrParamTest) +{ + tbm_bufmgr invalid_bufmgr; + tbm_bo bo; + tbm_key bo_key = (tbm_key)TBM_UT_INVALID_UINT_VALUE; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) + return; + + bo = tbm_bo_import(NULL, bo_key); + ASSERT_TRUE(bo == NULL); + + invalid_bufmgr = (tbm_bufmgr)TBM_UT_INVALID_UINT_VALUE; + bo = tbm_bo_import(invalid_bufmgr, bo_key); + ASSERT_TRUE(bo == NULL); +} + +TEST_P(TBMBo, BoImportWithKeyParamTest) +{ + tbm_bo bo; + tbm_key bo_key_invalid; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) + return; + + bo_key_invalid = (tbm_key)TBM_UT_INVALID_UINT_VALUE; + bo = tbm_bo_import(bufmgr, bo_key_invalid); + ASSERT_TRUE(bo == NULL); +} + +TEST_P(TBMBo, BoImportTwice) +{ + tbm_bo bo1, bo2, bo3; + tbm_key bo_key; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) + return; + + bo1 = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo1 != NULL); + + bo_key = tbm_bo_export(bo1); + ASSERT_TRUE(bo_key != 0); + + bo2 = tbm_bo_import(bufmgr, bo_key); + ASSERT_TRUE(bo2 != NULL); + + bo3 = tbm_bo_import(bufmgr, bo_key); + ASSERT_TRUE(bo3 != NULL); + + ASSERT_EQ(bo2, bo3); + + tbm_bo_unref(bo3); + tbm_bo_unref(bo2); + tbm_bo_unref(bo1); +} + +/* tbm_bo_import_fd() */ + +TEST_P(TBMBo, BoImportFd) +{ + tbm_bo bo1, bo2; + tbm_fd bo_fd; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) + return; + + bo1 = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo1 != NULL); + + bo_fd = tbm_bo_export_fd(bo1); + ASSERT_TRUE(bo_fd != 0); + + bo2 = tbm_bo_import_fd(bufmgr, bo_fd); + ASSERT_TRUE(bo2 != NULL); + + tbm_bo_unref(bo2); + tbm_bo_unref(bo1); +} + +TEST_P(TBMBo, BoImportFdWithBufmgrParamTest) +{ + tbm_bufmgr invalid_bufmgr; + tbm_bo bo; + tbm_fd bo_fd = (tbm_fd)TBM_UT_INVALID_UINT_VALUE; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) + return; + + bo = tbm_bo_import_fd(NULL, bo_fd); + ASSERT_TRUE(bo == NULL); + + invalid_bufmgr = (tbm_bufmgr)TBM_UT_INVALID_UINT_VALUE; + bo = tbm_bo_import_fd(invalid_bufmgr, bo_fd); + ASSERT_TRUE(bo == NULL); +} + +TEST_P(TBMBo, BoImportFdWithFdParamTest) +{ + tbm_bo bo; + tbm_fd bo_fd_invalid; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) + return; + + bo_fd_invalid = (tbm_fd)TBM_UT_INVALID_UINT_VALUE; + bo = tbm_bo_import_fd(bufmgr, bo_fd_invalid); + ASSERT_TRUE(bo == NULL); +} + +TEST_P(TBMBo, BoImportFdTwice) +{ + tbm_bo bo1, bo2, bo3; + tbm_fd bo_fd; + + if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) + return; + + bo1 = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo1 != NULL); + + bo_fd = tbm_bo_export_fd(bo1); + ASSERT_TRUE(bo_fd != 0); + + bo2 = tbm_bo_import_fd(bufmgr, bo_fd); + ASSERT_TRUE(bo2 != NULL); + + bo3 = tbm_bo_import_fd(bufmgr, bo_fd); + ASSERT_TRUE(bo3 != NULL); + + ASSERT_EQ(bo2, bo3); + + tbm_bo_unref(bo3); + tbm_bo_unref(bo2); + tbm_bo_unref(bo1); +} + +/* tbm_bo_size() */ + +TEST_P(TBMBo, BoSize) +{ + tbm_bo bo; + int size = 0; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + size = tbm_bo_size(bo); + ASSERT_TRUE(size == UT_TBM_BO_SIZE); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoSizeWithBoParamTest) +{ + tbm_bo invalid_bo; + int size = 0; + + size = tbm_bo_size(NULL); + ASSERT_TRUE(size == 0); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + size = tbm_bo_size(invalid_bo); + ASSERT_TRUE(size == 0); +} + +/* tbm_bo_locked() */ + +TEST_P(TBMBo, BoLocked) +{ + tbm_bo bo; + tbm_bo_handle bo_handle; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + /* unlocked */ + ret = tbm_bo_locked(bo); + ASSERT_TRUE(ret == 0); + + bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ); + ASSERT_TRUE(bo_handle.ptr != NULL); + + /* locked */ + ret = tbm_bo_locked(bo); + ASSERT_TRUE(ret == 1); + + ret = tbm_bo_unmap(bo); + ASSERT_TRUE(ret != 0); + + /* unlocked */ + ret = tbm_bo_locked(bo); + ASSERT_TRUE(ret == 0); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoLockedWithBoParamTest) +{ + tbm_bo invalid_bo; + int ret; + + ret = tbm_bo_locked(NULL); + ASSERT_TRUE(ret == 0); + + invalid_bo = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + ret = tbm_bo_locked(invalid_bo); + ASSERT_TRUE(ret == 0); +} + +#if 0 +TEST_P(TBMBo, BoLockedOnce) +{ + // TODO: need to be fixed. use tbm_bufmgr_set_bo_lock_type instead of BUFMGR_LOCK_TYPE + tbm_bo_handle bo_handle1, bo_handle2; + tbm_bo bo; + int ret_locked; + + setenv("BUFMGR_LOCK_TYPE", "once", 1); + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_NE(nullptr, bo); + + bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); + bo_handle2 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); + (void) bo_handle1; + (void) bo_handle2; + + tbm_bo_unmap(bo); + + ret_locked = tbm_bo_locked(bo); + + tbm_bo_unmap(bo); + + ASSERT_EQ(ret_locked, 0); +} + +TEST_P(TBMBo, BoLockedAlways) +{ + // TODO: need to be fixed. use tbm_bufmgr_set_bo_lock_type instead of BUFMGR_LOCK_TYPE + tbm_bo_handle bo_handle1, bo_handle2; + tbm_bo bo; + int ret_locked; + + setenv("BUFMGR_LOCK_TYPE", "always", 1); + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_NE(nullptr, bo); + + bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); + bo_handle2 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); + (void) bo_handle1; + (void) bo_handle2; + + tbm_bo_unmap(bo); + + ret_locked = tbm_bo_locked(bo); + + tbm_bo_unmap(bo); + + ASSERT_EQ(ret_locked, 1); +} + +TEST_P(TBMBo, BoLockedNone) +{ + // TODO: need to be fixed. use tbm_bufmgr_set_bo_lock_type instead of BUFMGR_LOCK_TYPE + tbm_bo_handle bo_handle1; + tbm_bo bo; + int ret_locked; + + setenv("BUFMGR_LOCK_TYPE", "none", 1); + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_NE(nullptr, bo); + + bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); + (void) bo_handle1; + + ret_locked = tbm_bo_locked(bo); + + tbm_bo_unmap(bo); + + ASSERT_EQ(ret_locked, 0); +} +#endif + +/* tbm_bo_swap() */ + +TEST_P(TBMBo, BoSwap) +{ + tbm_bo bo1, bo2; + int ret; + + bo1 = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo1 != NULL); + + bo2 = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo2 != NULL); + + ret = tbm_bo_swap(bo1, bo2); + ASSERT_TRUE(ret == 1); + + tbm_bo_unref(bo1); + tbm_bo_unref(bo2); +} + +TEST_P(TBMBo, BoSwapWithBo1Bo2ParamTest) +{ + tbm_bo bo, invalid_bo1, invalid_bo2; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + invalid_bo1 = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + invalid_bo2 = (tbm_bo)TBM_UT_INVALID_UINT_VALUE; + + ret = tbm_bo_swap(NULL, NULL); + ASSERT_TRUE(ret == 0); + ret = tbm_bo_swap(bo, NULL); + ASSERT_TRUE(ret == 0); + ret = tbm_bo_swap(NULL, bo); + ASSERT_TRUE(ret == 0); + + ret = tbm_bo_swap(invalid_bo1, invalid_bo2); + ASSERT_TRUE(ret == 0); + ret = tbm_bo_swap(bo, invalid_bo2); + ASSERT_TRUE(ret == 0); + ret = tbm_bo_swap(invalid_bo1, bo); + ASSERT_TRUE(ret == 0); + ret = tbm_bo_swap(invalid_bo1, NULL); + ASSERT_TRUE(ret == 0); + ret = tbm_bo_swap(NULL, invalid_bo2); + ASSERT_TRUE(ret == 0); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoSwapWithDifferentSizedBos) +{ + tbm_bo bo1, bo2; + int ret; + tbm_error_e error; + + bo1 = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_NE(nullptr, bo1); + + bo2 = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE + 256, TBM_BO_DEFAULT); + ASSERT_NE(nullptr, bo2); + + ret = tbm_bo_swap(bo1, bo2); + error = tbm_get_last_error(); + + ASSERT_TRUE(ret == 0); + ASSERT_TRUE(error == TBM_BO_ERROR_SWAP_FAILED); + + tbm_bo_unref(bo2); + tbm_bo_unref(bo1); +} + +/* tbm_bo_add_user_data() */ + +TEST_P(TBMBo, BoAddUserData) +{ + tbm_bo bo; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + ret = tbm_bo_add_user_data(bo, 4887, NULL); + ASSERT_TRUE(ret == 1); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoAddUserDataWithBoParamTest) +{ + tbm_bo invalid_bo; + int ret; + + ret = tbm_bo_add_user_data(NULL, 4887, NULL); + ASSERT_TRUE(ret == 0); + + invalid_bo = (tbm_bo)UT_TBM_INVALID_VALUE; + ret = tbm_bo_add_user_data(invalid_bo, 4887, NULL); + ASSERT_TRUE(ret == 0); +} + +TEST_P(TBMBo, BoAddUserDataSameKeyTwiceTest) +{ + tbm_bo bo; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + ret = tbm_bo_add_user_data(bo, 4887, NULL); + ASSERT_TRUE(ret == 1); + + ret = tbm_bo_add_user_data(bo, 4887, NULL); + ASSERT_TRUE(ret == 0); + + tbm_bo_unref(bo); +} + +/* tbm_bo_delete_user_data() */ + +TEST_P(TBMBo, BoDeleteUserData) +{ + tbm_bo bo; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + ret = tbm_bo_add_user_data(bo, 4887, NULL); + ASSERT_TRUE(ret == 1); + + ret = tbm_bo_delete_user_data(bo, 4887); + ASSERT_TRUE(ret == 1); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoDeleteUserDataWithBoParam) +{ + tbm_bo invalid_bo; + int ret; + + ret = tbm_bo_delete_user_data(NULL, 4887); + ASSERT_TRUE(ret == 0); + + invalid_bo = (tbm_bo)UT_TBM_INVALID_VALUE; + ret = tbm_bo_delete_user_data(invalid_bo, 4887); + ASSERT_TRUE(ret == 0); +} + +TEST_P(TBMBo, BoDeleteUserDataWithKeyParam) +{ + tbm_bo bo; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + /* no use_data in bo */ + ret = tbm_bo_delete_user_data(bo, 4887); + ASSERT_TRUE(ret == 0); + + /* delete the data with the wrong key */ + ret = tbm_bo_add_user_data(bo, 4887, NULL); + ASSERT_TRUE(ret == 1); + ret = tbm_bo_delete_user_data(bo, 4887 + 10); + ASSERT_TRUE(ret == 0); + + tbm_bo_unref(bo); +} + +/* tbm_bo_set_user_data() */ + +static void +_ut_tbm_bo_user_data_free(void *user_data) +{ + int *i = (int *)user_data; + *i = 1; +} + +TEST_P(TBMBo, BoSetUserData) +{ + tbm_bo bo; + unsigned long key = 4887; + int data1 = 0, data2 = 0; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + ret = tbm_bo_add_user_data(bo, key, _ut_tbm_bo_user_data_free); + ASSERT_TRUE(ret == 1); + + ret = tbm_bo_set_user_data(bo, key, &data1); + ASSERT_TRUE(ret == 1); + ret = tbm_bo_set_user_data(bo, key, &data2); + ASSERT_TRUE(ret == 1); + + ret = tbm_bo_delete_user_data(bo, key); + ASSERT_TRUE(ret == 1); + + ASSERT_TRUE(data1 == 1); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoSetUserDataWithBoParamTest) +{ + tbm_bo invalid_bo; + unsigned long key = 4887; + int data1 = 0, data2 = 0; + int ret; + + ret = tbm_bo_set_user_data(NULL, key, &data1); + ASSERT_TRUE(ret == 0); + + invalid_bo = (tbm_bo)UT_TBM_INVALID_VALUE; + ret = tbm_bo_set_user_data(invalid_bo, key, &data2); + ASSERT_TRUE(ret == 0); +} + +TEST_P(TBMBo, BoSetUserDataWithKeyParamTest) +{ + tbm_bo bo; + unsigned long key = 4887; + int data = 0; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + /* no add_user_data */ + ret = tbm_bo_set_user_data(bo, 4887, &data); + ASSERT_TRUE(ret == 0); + + ret = tbm_bo_add_user_data(bo, key, _ut_tbm_bo_user_data_free); + ASSERT_TRUE(ret == 1); + + /* with non-existed key */ + ret = tbm_bo_set_user_data(bo, key + 10, &data); + ASSERT_TRUE(ret == 0); + + ret = tbm_bo_delete_user_data(bo, key); + ASSERT_TRUE(ret == 1); + + tbm_bo_unref(bo); +} + +/* tbm_bo_get_user_data() */ + +TEST_P(TBMBo, BoGetUserData) +{ + tbm_bo bo; + unsigned long key = 4887; + int data1 = 0; + int *data2; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + ret = tbm_bo_add_user_data(bo, key, NULL); + ASSERT_TRUE(ret == 1); + + ret = tbm_bo_set_user_data(bo, key, &data1); + ASSERT_TRUE(ret == 1); + + /* success */ + ret = tbm_bo_get_user_data(bo, key, (void **)&data2); + ASSERT_TRUE(ret == 1); + ASSERT_TRUE(data2 == &data1); + + ret = tbm_bo_delete_user_data(bo, key); + ASSERT_TRUE(ret == 1); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoGetUserDataWithBoParamTest) +{ + tbm_bo invalid_bo; + unsigned long key = 4887; + int *data1; + int *data2; + int ret; + + ret = tbm_bo_get_user_data(NULL, key, (void **)&data1); + ASSERT_TRUE(ret == 0); + + invalid_bo = (tbm_bo)UT_TBM_INVALID_VALUE; + ret = tbm_bo_get_user_data(invalid_bo, key, (void **)&data2); + ASSERT_TRUE(ret == 0); +} + +TEST_P(TBMBo, BoGetUserDataWithKeyParamTest) +{ + tbm_bo bo; + unsigned long key = 4887; + int *data; + int ret; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, TBM_BO_DEFAULT); + ASSERT_TRUE(bo != NULL); + + /* no add_user_data/set_user_data */ + ret = tbm_bo_get_user_data(bo, 4887, (void **)&data); + ASSERT_TRUE(ret == 0); + + ret = tbm_bo_add_user_data(bo, key, _ut_tbm_bo_user_data_free); + ASSERT_TRUE(ret == 1); + + /* with non-existed key */ + ret = tbm_bo_get_user_data(bo, key + 10, (void **)&data); + ASSERT_TRUE(ret == 0); + + ret = tbm_bo_delete_user_data(bo, key); + ASSERT_TRUE(ret == 1); + + /* removed data */ + ret = tbm_bo_get_user_data(bo, key, (void **)&data); + ASSERT_TRUE(ret == 0); + + tbm_bo_unref(bo); +} + +/* tbm_bo_get_flags() */ + +TEST_P(TBMBo, BoGetFlags) +{ + tbm_bo bo; + int flags1 = TBM_BO_DEFAULT, flags2 = -1; + + bo = tbm_bo_alloc(bufmgr, UT_TBM_BO_SIZE, flags1); + ASSERT_TRUE(bo != NULL); + + flags2 = tbm_bo_get_flags(bo); + ASSERT_TRUE(flags1 == flags2); + + tbm_bo_unref(bo); +} + +TEST_P(TBMBo, BoGetFlagsWithBoParamTest) +{ + tbm_bo invalid_bo; + int flags = -1; + + flags = tbm_bo_get_flags(NULL); + ASSERT_TRUE(flags == 0); + + invalid_bo = (tbm_bo)UT_TBM_INVALID_VALUE; + flags = tbm_bo_get_flags(invalid_bo); + ASSERT_TRUE(flags == 0); +} + +INSTANTIATE_TEST_CASE_P(TBMBoParams, + TBMBo, + Combine(Bool(), Bool(), Values("none"))); diff --git a/utests/ut_tbm_bufmgr.cpp b/utests/ut_tbm_bufmgr.cpp index ea6af98..eb9e593 100644 --- a/utests/ut_tbm_bufmgr.cpp +++ b/utests/ut_tbm_bufmgr.cpp @@ -1,1117 +1,152 @@ -#include "gtest/gtest.h" +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Konstantin Drabeniuk + * Contact: Andrii Sokolenko + * Contact: Roman Marchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ -#include -#include "ut.h" +#include "ut_tbm.h" -/* tbm_bufmgr_init() */ - -TEST_F(BufmgrTest, BufmgrInitSuccessIniteTwice) -{ - tbm_bufmgr bufmgr2; - tbm_bo bo; - - bufmgr2 = tbm_bufmgr_init(-1); - tbm_bufmgr_deinit(bufmgr2); - - ASSERT_TRUE(bufmgr2 != NULL); - ASSERT_TRUE(bufmgr == bufmgr2); - - bo = tbm_bo_alloc(bufmgr, 128 * 128, TBM_BO_DEFAULT); - ASSERT_NE(nullptr, bo); -} - -/* tbm_bo_alloc() */ - -TEST_F(BufmgrTest, BoAllocFailNulbufmgr) -{ - tbm_bo bo; - - bo = tbm_bo_alloc(NULL, 128 * 128, TBM_BO_DEFAULT); - - ASSERT_EQ(nullptr, bo); -} - -TEST_F(BufmgrTest, BoAllocFailSizeLessThenZero) -{ - tbm_bo bo; - - bo = tbm_bo_alloc(bufmgr, -1, TBM_BO_DEFAULT); - - ASSERT_EQ(nullptr, bo); -} - -TEST_F(BufmgrTest, BoAllocFailNoValidBufmgr) -{ - tbm_bo bo; - int bufmgr; - - bo = tbm_bo_alloc((tbm_bufmgr)&bufmgr, -1, TBM_BO_DEFAULT); - - ASSERT_EQ(nullptr, bo); -} - -TEST_F(BufmgrTest, BoAllocSuccess) -{ - tbm_bo ret_bo; - - ret_bo = tbm_bo_alloc(bufmgr, 128 * 128, TBM_BO_DEFAULT); - - ASSERT_NE(nullptr, ret_bo); -} - -/* tbm_bo_ref() */ - -TEST(NoBufmgrTest, BoRefFailBufmgrWasNotInited) -{ - int bo; - tbm_bo ret_bo; - - ret_bo = tbm_bo_ref((tbm_bo)&bo); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrTest, BoRefFailNullBo) -{ - tbm_bo ret_bo; - - ret_bo = tbm_bo_ref(NULL); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrTest, BoRefFailNoValidBo) -{ - tbm_bo ret_bo; - int bo; - - ret_bo = tbm_bo_ref((tbm_bo)&bo); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrBoTest, BoRefSuccess) -{ - tbm_bo ret_bo; - - ret_bo = tbm_bo_ref(bo); - - ASSERT_NE(nullptr, ret_bo); -} - -/* tbm_bo_unref() */ - -TEST_F(BufmgrBoTest, BoUnrefSuccess) -{ - tbm_bo ret_bo; - - tbm_bo_unref(bo); - - ret_bo = tbm_bo_ref(bo); - - ASSERT_EQ(nullptr, ret_bo); -} - -/* tbm_bo_map() */ - -TEST(NoBufmgrTest, BoMapFailBufmgrWasNotInited) -{ - int bo; - tbm_bo_handle bo_handle; - - bo_handle = tbm_bo_map((tbm_bo)&bo, TBM_DEVICE_CPU, TBM_OPTION_READ); - - ASSERT_EQ(nullptr, bo_handle.ptr); -} - -TEST_F(BufmgrTest, BoMapFailNullBo) -{ - tbm_bo_handle bo_handle; - - bo_handle = tbm_bo_map(NULL, TBM_DEVICE_CPU, TBM_OPTION_READ); - - ASSERT_EQ(nullptr, bo_handle.ptr); -} - -TEST_F(BufmgrTest, BoMapFailNoValidBo) -{ - tbm_bo_handle bo_handle; - int bo; - - bo_handle = tbm_bo_map((tbm_bo)&bo, TBM_DEVICE_CPU, TBM_OPTION_READ); - - ASSERT_EQ(nullptr, bo_handle.ptr); -} - -TEST_F(BufmgrBoTest, BoMapSuccess) -{ - tbm_bo_handle bo_handle; - - bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ); - - ASSERT_NE(nullptr, bo_handle.ptr); -} - -/* tbm_bo_unmap() */ - -TEST(NoBufmgrTest, BoUnmapFailBufmgrWasNotInited) -{ - int bo; - int ret; - - ret = tbm_bo_unmap((tbm_bo)&bo); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoUnmapFailNullBo) -{ - int ret; - - ret = tbm_bo_unmap(NULL); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoUnmapFailNoValidBo) -{ - int ret; - int bo; - - ret = tbm_bo_unmap((tbm_bo)&bo); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoUnmapFailUnmapWithoutMap) -{ - int ret; - - ret = tbm_bo_unmap(bo); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoUnmapSuccess) -{ - int ret; - tbm_bo_handle bo_handle; - - bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ); - ASSERT_NE(nullptr, bo_handle.ptr); - - ret = tbm_bo_unmap(bo); - - ASSERT_NE(ret, 0); -} - -/* tbm_bo_get_handle() */ - -TEST(NoBufmgrTest, BoGetHandleFailBufmgrWasNotInited) -{ - int bo; - tbm_bo_handle bo_handle; - - bo_handle = tbm_bo_get_handle((tbm_bo)&bo, TBM_DEVICE_DEFAULT); - - ASSERT_EQ(nullptr, bo_handle.ptr); -} - -TEST_F(BufmgrTest, BoGetHandleFailNullBo) -{ - tbm_bo_handle bo_handle; - - bo_handle = tbm_bo_get_handle(NULL, TBM_DEVICE_DEFAULT); - - ASSERT_EQ(nullptr, bo_handle.ptr); -} - -TEST_F(BufmgrTest, BoGetHandleFailNoValidBo) -{ - tbm_bo_handle bo_handle; - int bo; - - bo_handle = tbm_bo_get_handle((tbm_bo)&bo, TBM_DEVICE_DEFAULT); - - ASSERT_EQ(nullptr, bo_handle.ptr); -} - -TEST_F(BufmgrBoTest, BoGetHandleSuccess) -{ - tbm_bo_handle bo_handle; - - bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_DEFAULT); - - ASSERT_NE(nullptr, bo_handle.ptr); -} - -/* tbm_bo_export() */ - -TEST(NoBufmgrTest, BoExportFailBufmgrWasNotInited) -{ - int bo; - tbm_key ret_key; - - ret_key = tbm_bo_export((tbm_bo)&bo); - - ASSERT_EQ(ret_key, 0); -} - -TEST_F(BufmgrTest, BoExportFailNullBo) -{ - tbm_key ret_key; - - if (!(bufmgr_capability == TBM_BUFMGR_CAPABILITY_SHARE_KEY)) - return; - - ret_key = tbm_bo_export(NULL); - - ASSERT_EQ(ret_key, 0); -} - -TEST_F(BufmgrTest, BoExportFailNoValidBo) -{ - tbm_key ret_key; - int bo; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) - return; - - ret_key = tbm_bo_export((tbm_bo)&bo); - - ASSERT_EQ(ret_key, 0); -} - -TEST_F(BufmgrBoTest, BoExportSuccess) -{ - tbm_key ret_key; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) - return; - - ret_key = tbm_bo_export(bo); - - ASSERT_NE(0, ret_key); -} - -/* tbmBoExportfd() */ - -TEST(NoBufmgrTest, BoExportFdFailBufmgrWasNotInited) -{ - int bo; - tbm_key ret_fd; - - ret_fd = tbm_bo_export_fd((tbm_bo)&bo); - - ASSERT_EQ(ret_fd, -1); -} - -TEST_F(BufmgrTest, BoExportFdFailNullBo) -{ - tbm_key ret_fd; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) - return; - - ret_fd = tbm_bo_export_fd(NULL); - - ASSERT_EQ(ret_fd, -1); -} - -TEST_F(BufmgrTest, BoExportFdFailNoValidBo) -{ - tbm_key ret_fd; - int bo; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) - return; - - ret_fd = tbm_bo_export_fd((tbm_bo)&bo); - - ASSERT_EQ(ret_fd, -1); -} - -TEST_F(BufmgrBoTest, BoExportFdSuccess) -{ - tbm_key ret_fd; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) - return; - - ret_fd = tbm_bo_export_fd(bo); - - ASSERT_NE(ret_fd, -1); -} - -/* tbm_bo_import() */ - -TEST(NoBufmgrTest, BoImportFailBufmgrWasNotInited) -{ - int bufmgr; - tbm_bo ret_bo; - - ret_bo = tbm_bo_import((tbm_bufmgr)&bufmgr, 20); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrTest, BoImportFailNullBufmgr) -{ - tbm_bo ret_bo; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) - return; - - ret_bo = tbm_bo_import(NULL, 20); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrTest, BoImportFailNoValidBufmgr) -{ - tbm_bo ret_bo; - int bufmgr; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) - return; - - ret_bo = tbm_bo_import((tbm_bufmgr)&bufmgr, 20); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrTest, BoImportFailNoValidKey) -{ - tbm_bo ret_bo; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) - return; - - ret_bo = tbm_bo_import(bufmgr, 20); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrBoTest, BoImportSuccess) -{ - tbm_bo ret_bo; - tbm_key exported_bo_key; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) - return; - - exported_bo_key = tbm_bo_export(bo); - ASSERT_NE(exported_bo_key, 0); - - ret_bo = tbm_bo_import(bufmgr, exported_bo_key); - - ASSERT_NE(nullptr, ret_bo); -} - -TEST_F(BufmgrBoTest, BoImportSuccessWhenWeImportTwice) -{ - tbm_bo ret_bo_1; - tbm_bo ret_bo_2; - tbm_key exported_bo_key; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_KEY)) - return; - - exported_bo_key = tbm_bo_export(bo); - ASSERT_NE(exported_bo_key, 0); - - ret_bo_1 = tbm_bo_import(bufmgr, exported_bo_key); - ASSERT_NE(nullptr, ret_bo_1); - - ret_bo_2 = tbm_bo_import(bufmgr, exported_bo_key); - ASSERT_NE(nullptr, ret_bo_2); - - ASSERT_EQ(ret_bo_1, ret_bo_2); -} - -/* tbm_bo_import_fd() */ - -TEST(NoBufmgrTest, BoImportFdFailBufmgrWasNotInited) -{ - int bufmgr; - tbm_bo ret_bo; - - ret_bo = tbm_bo_import_fd((tbm_bufmgr)&bufmgr, 20); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrTest, BoImportFdFailNullBufmgr) -{ - tbm_bo ret_bo; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) - return; - - ret_bo = tbm_bo_import_fd(NULL, 20); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrTest, BoImportFdFailNoValidBufmgr) -{ - tbm_bo ret_bo; - int bufmgr; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) - return; - - ret_bo = tbm_bo_import_fd((tbm_bufmgr)&bufmgr, 20); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrTest, BoImportFdFailNoValidFd) -{ - tbm_bo ret_bo; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) - return; - - ret_bo = tbm_bo_import_fd(bufmgr, 20); - - ASSERT_EQ(nullptr, ret_bo); -} - -TEST_F(BufmgrBoTest, BoImportFdSuccess) -{ - tbm_bo ret_bo; - tbm_key exported_bo_fd; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) - return; - - exported_bo_fd = tbm_bo_export_fd(bo); - ASSERT_NE(exported_bo_fd, 0); - - ret_bo = tbm_bo_import_fd(bufmgr, exported_bo_fd); - - ASSERT_NE(nullptr, ret_bo); -} - -TEST_F(BufmgrBoTest, BoImportFdSuccessWhenWeImportTwice) -{ - tbm_bo ret_bo_1; - tbm_bo ret_bo_2; - tbm_key exported_bo_fd; - - if (!(bufmgr_capability & TBM_BUFMGR_CAPABILITY_SHARE_FD)) - return; - - exported_bo_fd = tbm_bo_export_fd(bo); - ASSERT_NE(exported_bo_fd, 0); - - ret_bo_1 = tbm_bo_import_fd(bufmgr, exported_bo_fd); - ASSERT_NE(nullptr, ret_bo_1); - - ret_bo_2 = tbm_bo_import_fd(bufmgr, exported_bo_fd); - ASSERT_NE(nullptr, ret_bo_2); - - ASSERT_EQ(ret_bo_1, ret_bo_2); -} - -/* tbm_bo_size() */ - -TEST(NoBufmgrTest, BoSizeFailBufmgrWasNotInited) -{ - int bo; - int ret_size; - - ret_size = tbm_bo_size((tbm_bo)&bo); - - ASSERT_EQ(ret_size, 0); -} - -TEST_F(BufmgrTest, BoSizeFailNullBo) -{ - int ret_size; - - ret_size = tbm_bo_size(NULL); - - ASSERT_EQ(ret_size, 0); -} - -TEST_F(BufmgrTest, BoSizeFailNoValidBo) -{ - int bo; - int ret_size; - - ret_size = tbm_bo_size((tbm_bo)&bo); - - ASSERT_EQ(ret_size, 0); -} - -TEST_F(BufmgrBoTest, BoSizeSuccess) -{ - int ret_size; - - ret_size = tbm_bo_size(bo); - - ASSERT_EQ(ret_size, bo_size); -} - -/* tbm_bo_locked() */ - -TEST(NoBufmgrTest, BoLockedFailWhenBufmgrWasNotInited) -{ - int bo; - int ret; - - ret = tbm_bo_locked((tbm_bo)&bo); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoLockedFailNullBo) -{ - int ret; - - ret = tbm_bo_locked(NULL); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoLockedFailNoValidBo) -{ - int bo; - int ret; - - ret = tbm_bo_locked((tbm_bo)&bo); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoLockTypeTest, BoLockedOnce) -{ - tbm_bo_handle bo_handle1, bo_handle2; - tbm_bo bo; - int ret_locked; - - setenv("BUFMGR_LOCK_TYPE", "once", 1); - - UtBufmgrInit(); - - bo = tbm_bo_alloc(bufmgr, 128 * 128, TBM_BO_DEFAULT); - ASSERT_NE(nullptr, bo); - - bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - bo_handle2 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - (void) bo_handle1; - (void) bo_handle2; - - tbm_bo_unmap(bo); - - ret_locked = tbm_bo_locked(bo); - - tbm_bo_unmap(bo); - - ASSERT_EQ(ret_locked, 0); -} - -TEST_F(BufmgrBoLockTypeTest, BoLockedAlways) -{ - tbm_bo_handle bo_handle1, bo_handle2; - tbm_bo bo; - int ret_locked; - - setenv("BUFMGR_LOCK_TYPE", "always", 1); - - UtBufmgrInit(); - - bo = tbm_bo_alloc(bufmgr, 128 * 128, TBM_BO_DEFAULT); - ASSERT_NE(nullptr, bo); - - bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - bo_handle2 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - (void) bo_handle1; - (void) bo_handle2; - - tbm_bo_unmap(bo); - - ret_locked = tbm_bo_locked(bo); - - tbm_bo_unmap(bo); - - ASSERT_EQ(ret_locked, 1); -} - -TEST_F(BufmgrBoLockTypeTest, BoLockedNone) -{ - tbm_bo_handle bo_handle1; - tbm_bo bo; - int ret_locked; - - setenv("BUFMGR_LOCK_TYPE", "none", 1); - - UtBufmgrInit(); - - bo = tbm_bo_alloc(bufmgr, 128 * 128, TBM_BO_DEFAULT); - ASSERT_NE(nullptr, bo); - - bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - (void) bo_handle1; - - ret_locked = tbm_bo_locked(bo); - - tbm_bo_unmap(bo); - - ASSERT_EQ(ret_locked, 0); -} - -/* tbm_bo_swap() */ - -TEST(NoBufmgrTest, BoSwapFailWhenBufmgrWasNotInited) -{ - int bo1, bo2; - int ret; - - ret = tbm_bo_swap((tbm_bo)&bo1, (tbm_bo)&bo2); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoSwapFailNullAll) -{ - int ret; - - ret = tbm_bo_swap(NULL, NULL); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoSwapFailNoValidBo1) -{ - int ret; - - ret = tbm_bo_swap((tbm_bo)&bo, bo); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoSwapFailNoValidBo2) -{ - int bo2; - int ret; - - ret = tbm_bo_swap(bo, (tbm_bo)&bo2); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoSwapFailWhenBosSizeAreDifferent) -{ - tbm_bo bo1, bo2; - int ret; - tbm_error_e error; - - bo1 = tbm_bo_alloc(bufmgr, 128 * 128, TBM_BO_DEFAULT); - ASSERT_NE(nullptr, bo1); - - bo2 = tbm_bo_alloc(bufmgr, 256 * 256, TBM_BO_DEFAULT); - ASSERT_NE(nullptr, bo2); - - ret = tbm_bo_swap(bo1, bo2); - - error = tbm_get_last_error(); - - tbm_bo_unref(bo1); - tbm_bo_unref(bo2); - - ASSERT_EQ(ret, 0); - ASSERT_EQ(error, TBM_BO_ERROR_SWAP_FAILED); -} - -TEST_F(BufmgrTest, BoSwapSuccess) -{ - tbm_bo bo1, bo2; - int ret; - - bo1 = tbm_bo_alloc(bufmgr, 128 * 128, TBM_BO_DEFAULT); - ASSERT_NE(nullptr, bo1); - - bo2 = tbm_bo_alloc(bufmgr, 128 * 128, TBM_BO_DEFAULT); - ASSERT_NE(nullptr, bo2); - - ret = tbm_bo_swap(bo1, bo2); - - tbm_bo_unref(bo1); - tbm_bo_unref(bo2); - - ASSERT_TRUE(ret); -} - -/* tbm_bo_add_user_data() */ - -TEST(NoBufmgrTest, BoAddUserDataFailBufmgrWasNotInited) -{ - int bo; - int ret; - - ret = tbm_bo_add_user_data((tbm_bo)&bo, 7878, NULL); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoAddUserDataFailNullBo) -{ - int ret; - - ret = tbm_bo_add_user_data(NULL, 4484, NULL); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoAddUserDataFailNoValidBo) -{ - int ret; - - ret = tbm_bo_add_user_data((tbm_bo)&bo, 4887, NULL); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoAddUserDataSuccess) -{ - int ret; - - ret = tbm_bo_add_user_data(bo, 4887, NULL); - ASSERT_NE(ret, 0); -} - -TEST_F(BufmgrBoTest, BoAddUserDataFailDataAlreadyExist) -{ - int ret; - - ret = tbm_bo_add_user_data(bo, 4887, NULL); - ASSERT_NE(ret, 0); - - ret = tbm_bo_add_user_data(bo, 4887, NULL); - ASSERT_EQ(ret, 0); -} - -/* tbm_bo_delete_user_data() */ - -TEST(NoBufmgrTest, BoDeleteUserDataFailBufmgrWasNotInited) -{ - int bo; - int ret; - - ret = tbm_bo_delete_user_data((tbm_bo)&bo, 7878); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoDeleteUserDataFailNullBo) -{ - int ret; - - ret = tbm_bo_delete_user_data(NULL, 4484); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoDeleteUserDataFailNoValidBo) -{ - int bo; - int ret; - - ret = tbm_bo_delete_user_data((tbm_bo)&bo, 4887); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoDeleteUserDataFailDataListIsEmpty) -{ - int ret; - - ret = tbm_bo_delete_user_data(bo, 4887); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoDeleteUserDataFailDataDonNotExist) -{ - int ret; - unsigned long key = 487879887; - - ret = tbm_bo_add_user_data(bo, key, NULL); - ASSERT_NE(ret, 0); - - ret = tbm_bo_delete_user_data(bo, key + 10); - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoDeleteUserSuccess) -{ - int ret; - unsigned long key = 487879887; - - ret = tbm_bo_add_user_data(bo, key, NULL); - ASSERT_NE(ret, 0); - - ret = tbm_bo_delete_user_data(bo, key); - ASSERT_NE(ret, 0); -} - -/* tbm_bo_set_user_data() */ - -TEST(NoBufmgrTest, BoSetUserDataFailBufmgrWasNotInited) -{ - int bo; - int ret; - int data; - - ret = tbm_bo_set_user_data((tbm_bo)&bo, 7878, &data); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrTest, BoSetUserDataFailNullBo) -{ - int ret; - int data; - - ret = tbm_bo_set_user_data(NULL, 787, &data); - - ASSERT_EQ(ret, 0); -} - -TEST_F(BufmgrBoTest, BoSetUserDataFailNoValidBo) +/* TODO:: + * 1. Test When there is no bufmgr. + * + */ +TBMBufmgr::TBMBufmgr() { - int bo, data; - int ret; - - ret = tbm_bo_set_user_data((tbm_bo)&bo, 4887, &data); - - ASSERT_EQ(ret, 0); + bufmgr = NULL; } -TEST_F(BufmgrBoTest, BoSetUserDataFailDataListIsEmpty) +void TBMBufmgr::SetUp() { - int ret, data; + TBMEnv::SetUp(); - ret = tbm_bo_set_user_data(bo, 4887, &data); - - ASSERT_EQ(ret, 0); + bufmgr = tbm_bufmgr_init(-1); + ASSERT_TRUE(bufmgr != NULL); } -TEST_F(BufmgrBoTest, BoSetUserDataFailDataDonNotExist) +void TBMBufmgr::TearDown() { - int ret; - unsigned long key = 487879887; - int data; - - ret = tbm_bo_add_user_data(bo, key, NULL); - ASSERT_NE(ret, 0); + tbm_bufmgr_deinit(bufmgr); - ret = tbm_bo_set_user_data(bo, key + 10, &data); - ASSERT_EQ(ret, 0); -} + ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0); -static void -ut_data_free(void *user_data) -{ - int *i = (int *)user_data; - *i = 1; + TBMEnv::TearDown(); } -TEST_F(BufmgrBoTest, BoSetUserDataSuccess) +/* tbm_bufmgr_get_capability() */ +TEST_P(TBMBufmgr, BufmgrGetCapability) { - int ret; - unsigned long key = 487879887; - int data1 = 0; - int data2 = 0; - - ret = tbm_bo_add_user_data(bo, key, ut_data_free); - ASSERT_NE(ret, 0); - - ret = tbm_bo_set_user_data(bo, key, &data1); - ASSERT_NE(ret, 0); - - ret = tbm_bo_set_user_data(bo, key, &data2); - tbm_bo_delete_user_data(bo, key); - - ASSERT_NE(ret, 0); + unsigned int capability; - ASSERT_EQ(data1, 1); + capability = tbm_bufmgr_get_capability(bufmgr); + ASSERT_NE(capability, TBM_BUFMGR_CAPABILITY_NONE); } -/* tbm_bo_get_user_data() */ - -TEST(NoBufmgrTest, BoGetUserDataFailBufmgrWasNotInited) +TEST_P(TBMBufmgr, BufmgrGetCapabilityWithNullBufmgr) { - int bo; - int ret; - int *data; - - ret = tbm_bo_get_user_data((tbm_bo)&bo, 7878, (void **)&data); + unsigned int capability; - ASSERT_EQ(ret, 0); + capability = tbm_bufmgr_get_capability(NULL); + ASSERT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE); } -TEST_F(BufmgrTest, BoGetUserDataFailNullBo) +TEST_P(TBMBufmgr, BufmgrGetCapabilityWithWrongBufmgr) { - int ret; - int *data; - - ret = tbm_bo_get_user_data(NULL, 7878, (void **)&data); + tbm_bufmgr bufmgr = (tbm_bufmgr)UT_TBM_INVALID_VALUE; + unsigned int capability; - ASSERT_EQ(ret, 0); + capability = tbm_bufmgr_get_capability(bufmgr); + ASSERT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE); } -TEST_F(BufmgrBoTest, BoGetUserDataFailNoValidBo) +/* tbm_bufmgr_bind_native_display() */ +#if 0 // TDDO:: fix the crash... +TEST_P(TBMBufmgr, BufmgrBindNativeDisplay) { - int bo, *data; int ret; + void *native_display = (void *)UT_TBM_INVALID_VALUE; - ret = tbm_bo_get_user_data((tbm_bo)&bo, 4887, (void **)&data); - - ASSERT_EQ(ret, 0); + ret = tbm_bufmgr_bind_native_display(bufmgr, native_display); + ASSERT_EQ(ret, 1); } -TEST_F(BufmgrBoTest, BoGetUserDataFailDataListIsEmpty) +TEST_P(TBMBufmgr, BufmgrBindNativeDisplayWithNullBufmgr) { - int *data; int ret; + void *native_display = (void *)UT_TBM_INVALID_VALUE; - ret = tbm_bo_get_user_data((tbm_bo)&bo, 4887, (void **)&data); - + ret = tbm_bufmgr_bind_native_display(NULL, native_display); ASSERT_EQ(ret, 0); } -TEST_F(BufmgrBoTest, BoGetUserDataFailDataDonNotExist) +TEST_P(TBMBufmgr, BufmgrBindNativeDisplayWithWrongBufmgr) { int ret; - unsigned long key = 487879887; - int *data; - - ret = tbm_bo_add_user_data(bo, key, NULL); - ASSERT_NE(ret, 0); - - ret = tbm_bo_set_user_data(bo, key, &data); - ASSERT_NE(ret, 0); + void *native_display = (void *)UT_TBM_INVALID_VALUE; - ret = tbm_bo_get_user_data((tbm_bo)&bo, key + 10, (void **)&data); + ret = tbm_bufmgr_bind_native_display(NULL, native_display); ASSERT_EQ(ret, 0); } +#endif -TEST_F(BufmgrBoTest, BoGetUserDataSuccess) +/* tbm_bufmgr_set_bo_lock_type() */ +TEST_P(TBMBufmgr, BufmgrSetBoLockType) { int ret; - unsigned long key = 487879887; - int data = 0, *ret_data; - ret = tbm_bo_add_user_data(bo, key, NULL); - ASSERT_NE(ret, 0); - - ret = tbm_bo_set_user_data(bo, key, &data); - ASSERT_NE(ret, 0); - - ret = tbm_bo_get_user_data(bo, key, (void **)&ret_data); - ASSERT_NE(ret, 0); - ASSERT_TRUE(ret_data == &data); + ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_NEVER); + ASSERT_TRUE(ret == 1); + ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_ONCE); + ASSERT_TRUE(ret == 1); + ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS); + ASSERT_TRUE(ret == 1); } -TEST_F(BufmgrBoTest, BoGetUserDataFailDataWasRemoved) +TEST_P(TBMBufmgr, BufmgrSetBoLockTypeWithBufmgrParamTest) { + tbm_bufmgr invalid_bufmgr; int ret; - unsigned long key = 487879887; - int data = 0, *ret_data; - - ret = tbm_bo_add_user_data(bo, key, NULL); - ASSERT_NE(ret, 0); - - ret = tbm_bo_set_user_data(bo, key, &data); - ASSERT_NE(ret, 0); - - ret = tbm_bo_delete_user_data(bo, key); - ASSERT_NE(ret, 0); - - ret = tbm_bo_get_user_data(bo, key, (void **)&ret_data); - ASSERT_EQ(ret, 0); -} - -/* tbm_bufmgr_get_capability() */ - -TEST(NoBufmgrTest, BufmgrGetCapabilityFailBufmgrWasNotInited) -{ - int bufmgr; - unsigned int capability; - - capability = tbm_bufmgr_get_capability((tbm_bufmgr)&bufmgr); - - ASSERT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE); -} - -TEST_F(BufmgrTest, BufmgrGetCapabilityFailNullBufmgr) -{ - unsigned int capability; - - capability = tbm_bufmgr_get_capability(NULL); - - ASSERT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE); -} - -TEST_F(BufmgrTest, BufmgrGetCapabilityFailNoValidbufmgr) -{ - int bufmgr; - unsigned int capability; - - capability = tbm_bufmgr_get_capability((tbm_bufmgr)&bufmgr); - - ASSERT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE); -} - -TEST_F(BufmgrTest, BufmgrGetCapabilitySuccess) -{ - unsigned int capability; - - capability = tbm_bufmgr_get_capability(bufmgr); - - ASSERT_NE(capability, TBM_BUFMGR_CAPABILITY_NONE); -} -/* tbm_bo_get_flags() */ - -TEST(NoBufmgrTest, BoGetFlagsFailBufmgrWasNotInited) -{ - int bo; - int flags; - - flags = tbm_bo_get_flags((tbm_bo)&bo); - - ASSERT_EQ(flags, 0); -} - -TEST_F(BufmgrTest, BoGetFlagsFailNullBo) -{ - int flags; - - flags = tbm_bo_get_flags(NULL); - - ASSERT_EQ(flags, 0); -} - -TEST_F(BufmgrTest, BoGetFlagsFailNoValidBo) -{ - int bo; - int flags; - - flags = tbm_bo_get_flags((tbm_bo)&bo); - - ASSERT_EQ(flags, 0); + ret = tbm_bufmgr_set_bo_lock_type(NULL, TBM_BUFMGR_BO_LOCK_TYPE_NEVER); + ASSERT_TRUE(ret == 0); + invalid_bufmgr = (tbm_bufmgr)UT_TBM_INVALID_VALUE; + ret = tbm_bufmgr_set_bo_lock_type(invalid_bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_NEVER); + ASSERT_TRUE(ret == 0); } -TEST_F(BufmgrBoTest, BoGetFlagsSuccess) -{ - int actual_flags; +// TODO:::: +/* tbm_bufmgr_debug_show() */ +/* tbm_bufmgr_debug_tbm_info_get() */ +/* tbm_bufmgr_debug_trace() */ +/* tbm_bufmgr_debug_dump_all() */ +/* tbm_bufmgr_debug_queue_dump() */ +/* tbm_bufmgr_debug_dump_set_scale() */ +/* tbm_bufmgr_debug_get_ref_count */ - actual_flags = tbm_bo_get_flags(bo); +INSTANTIATE_TEST_CASE_P(TBMBufmgrParams, + TBMBufmgr, + Combine(Bool(), Bool(), Values("none"))); - ASSERT_EQ(actual_flags, bo_flags); -} diff --git a/utests/ut_tbm_env.cpp b/utests/ut_tbm_env.cpp new file mode 100644 index 0000000..2119627 --- /dev/null +++ b/utests/ut_tbm_env.cpp @@ -0,0 +1,217 @@ +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Konstantin Drabeniuk + * Contact: Andrii Sokolenko + * Contact: Roman Marchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#include "ut_tbm.h" + +void TBMEnv::SetUp(void) +{ + setenv("XDG_RUNTIME_DIR", "/run", 1); + setenv("TBM_DISPLAY_SERVER", "1", 1); +#if 0 + const char *test_backend; + + tdm_config_set_int(TBM_CONFIG_KEY_GENERAL_THREAD, ::testing::get<0>(GetParam())); + tdm_config_set_int(TBM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, ::testing::get<1>(GetParam())); + if (getenv("TBM_DEBUG_MODULE")) + tdm_config_set_string(TBM_CONFIG_KEY_DEBUG_MODULE, "buffer,thread,event,vblank,commit,pp,capture"); + + test_backend = ::testing::get<2>(GetParam()); + if (!test_backend) + test_backend = TBM_DEFAULT_MODULE; + tdm_config_set_string(TBM_CONFIG_KEY_GENERAL_BACKENDS, test_backend); +#endif +} + +void TBMEnv::TearDown(void) +{ + unsetenv("XDG_RUNTIME_DIR"); + unsetenv("TBM_DISPLAY_SERVER"); +} + +/* tbm_bufmgr_init(), tbm_bufmgr_deinit() */ + +TEST_P(TBMEnv, BufmgrInitDeinit) +{ + tbm_bufmgr bufmgr; + + bufmgr = tbm_bufmgr_init(-1); + ASSERT_TRUE(bufmgr != NULL); + + tbm_bufmgr_deinit(bufmgr); + + ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0); +} + +TEST_P(TBMEnv, BufmgrInitWithoutEnv) +{ + tbm_bufmgr bufmgr; + + TBMEnv::TearDown(); + + bufmgr = tbm_bufmgr_init(-1); + ASSERT_TRUE(bufmgr == NULL); + + ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0); +} + +TEST_P(TBMEnv, BufmgrInitFewTimes) +{ + tbm_bufmgr bufmgr[10]; + int i; + + for (i = 0; i < 10; i++) { + bufmgr[i] = tbm_bufmgr_init(-1); + ASSERT_TRUE(bufmgr[i] != NULL); + } + + for (i = 0; i < 10; i++) + tbm_bufmgr_deinit(bufmgr[i]); + + ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0); +} + +TEST_P(TBMEnv, BufmgrDeinitWithNULL) +{ + tbm_bufmgr_deinit(NULL); + + ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0); +} + +/* tbm_bufmgr_server_init() */ +TEST_P(TBMEnv, BufmgrServerInitDeinit) +{ + tbm_bufmgr bufmgr; + + bufmgr = tbm_bufmgr_server_init(); + ASSERT_TRUE(bufmgr != NULL); + + tbm_bufmgr_deinit(bufmgr); + + ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0); +} + +TEST_P(TBMEnv, BufmgrServerInitWithoutEnv) +{ + tbm_bufmgr bufmgr; + + TBMEnv::TearDown(); + + bufmgr = tbm_bufmgr_server_init(); + ASSERT_TRUE(bufmgr != NULL); + + tbm_bufmgr_deinit(bufmgr); + + ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0); +} + +TEST_P(TBMEnv, BufmgrServerInitFewTimes) +{ + tbm_bufmgr bufmgr[10]; + int i; + + for (i = 0; i < 10; i++) { + bufmgr[i] = tbm_bufmgr_server_init(); + ASSERT_TRUE(bufmgr[i] != NULL); + } + + for (i = 0; i < 10; i++) + tbm_bufmgr_deinit(bufmgr[i]); + + ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0); +} + +/* int tbm_surface_internal_query_supported_formats(uint32_t **formats, uint32_t *num) */ +TEST_F(TBMEnv, SurfaceInternalQueryFormats) +{ + tbm_bufmgr bufmgr; + uint32_t num = 0; + tbm_format *formats = NULL; + + bufmgr = tbm_bufmgr_server_init(); + ASSERT_TRUE(bufmgr != NULL); + + ASSERT_TRUE(tbm_surface_internal_query_supported_formats(&formats, &num)); + ASSERT_TRUE(num > 0); + ASSERT_TRUE(formats != NULL); + for (uint32_t i = 0; i < num; i++) + ASSERT_TRUE(formats[i] != 0); + + if (formats) + free(formats); + + tbm_bufmgr_deinit(bufmgr); +} + +TEST_F(TBMEnv, SurfaceInternalQueryFormatsFailNull) +{ + tbm_bufmgr bufmgr; + uint32_t num = 0; + tbm_format *formats = NULL; + + bufmgr = tbm_bufmgr_server_init(); + ASSERT_TRUE(bufmgr != NULL); + + ASSERT_FALSE(tbm_surface_internal_query_supported_formats(&formats, NULL)); + ASSERT_FALSE(tbm_surface_internal_query_supported_formats(NULL, &num)); + + tbm_bufmgr_deinit(bufmgr); +} + +TEST_F(TBMEnv, SurfaceQueryFormatsFailNull) +{ + uint32_t num = 0; + tbm_format *formats = NULL; + tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; + + result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, NULL); + ASSERT_NE(TBM_SURFACE_ERROR_NONE, result); + + result = (tbm_surface_error_e)tbm_surface_query_formats(NULL, &num); + ASSERT_NE(TBM_SURFACE_ERROR_NONE, result); +} + +TEST_F(TBMEnv, SurfaceQueryFormatSuccess) +{ + uint32_t num = 0; + tbm_format *formats = NULL; + tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; + + result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, &num); + ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result); + ASSERT_NE(0, num); + ASSERT_NE((tbm_format *)NULL, formats); + for (uint32_t i = 0; i < num; i++) + ASSERT_NE(0, formats[i]); + free(formats); +} + +INSTANTIATE_TEST_CASE_P(TBMEnvParams, + TBMEnv, + Combine(Bool(), Bool(), Values("none"))); \ No newline at end of file diff --git a/utests/ut_tbm_surface.cpp b/utests/ut_tbm_surface.cpp index b263a24..ed56774 100644 --- a/utests/ut_tbm_surface.cpp +++ b/utests/ut_tbm_surface.cpp @@ -1,48 +1,86 @@ -#include -#include - -#include -#include -#include "ut.h" - -TEST_F(SurfaceQueryFormatsTest, SurfaceQueryFormatsFailNull) +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Konstantin Drabeniuk + * Contact: Andrii Sokolenko + * Contact: Roman Marchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#include "ut_tbm.h" + +class TBMSurface : public TBMBufmgr +{ +protected: + void SetUp(); + void TearDown(); +public: + uint32_t num_formats; + tbm_format *formats; + tbm_format format; + + int width, height; + tbm_surface_h surface; +}; + +void TBMSurface::SetUp() { - uint32_t num = 0; - tbm_format *formats = NULL; tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; - ut_set_default_tbm_env(); + TBMBufmgr::SetUp(); + + result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, &num_formats); + ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result); - result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, NULL); - ASSERT_NE(TBM_SURFACE_ERROR_NONE, result); + for (uint32_t i = 0; i < num_formats; i++) + if (formats[i] == TBM_FORMAT_ARGB8888) + format = TBM_FORMAT_ARGB8888; - result = (tbm_surface_error_e)tbm_surface_query_formats(NULL, &num); - ASSERT_NE(TBM_SURFACE_ERROR_NONE, result); + /* fail if there is no TBM_FORMAT_ARGB8888 format */ + ASSERT_TRUE(format == TBM_FORMAT_ARGB8888); + + width = 720; + height = 1024; + surface = tbm_surface_internal_create_with_flags(width, height, format, TBM_BO_DEFAULT); + ASSERT_TRUE(surface != NULL); } -TEST_F(SurfaceQueryFormatsTest, SurfaceQueryFormatSuccess) +void TBMSurface::TearDown() { - uint32_t num = 0; - tbm_format *formats = NULL; - tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; + if (surface) + tbm_surface_internal_destroy(surface); - ut_set_default_tbm_env(); + if (formats) + free(formats); - result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, &num); - ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result); - ASSERT_NE(0, num); - ASSERT_NE((tbm_format *)NULL, formats); - for (uint32_t i = 0; i < num; i++) - ASSERT_NE(0, formats[i]); - free(formats); + TBMBufmgr::TearDown(); } -TEST_F(SurfaceTest, SurfaceCeateFailInvalidGeometry) +TEST_F(TBMSurface, SurfaceCeateFailInvalidGeometry) { tbm_surface_h surf1 = NULL; - ut_set_default_tbm_env(); - surf1 = tbm_surface_create(-1, 1024, TBM_FORMAT_ARGB8888); ASSERT_EQ(nullptr, surf1); // Expected Value: NULL @@ -53,7 +91,7 @@ TEST_F(SurfaceTest, SurfaceCeateFailInvalidGeometry) ASSERT_EQ(nullptr, surf1); } -TEST_F(SurfaceTest, SurfaceCeateSuccess) +TEST_F(TBMSurface, SurfaceCeateSuccess) { tbm_surface_h surf1 = NULL; tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; @@ -66,64 +104,64 @@ TEST_F(SurfaceTest, SurfaceCeateSuccess) } } -TEST_F(SurfaceTest, SurfaceGetFormatFailInvalidInput) +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); } -TEST_F(SurfaceTest, SurfaceGetFormatFailNull) +TEST_F(TBMSurface, SurfaceGetFormatFailNull) { tbm_format fmt = tbm_surface_get_format(NULL); ASSERT_EQ(0, fmt); } -TEST_F(SurfaceTest, SurfaceGetFormatSuccess) +TEST_F(TBMSurface, SurfaceGetFormatSuccess) { tbm_format fmt = tbm_surface_get_format(surface); ASSERT_EQ(this->format, fmt); } -TEST_F(SurfaceTest, SurfaceGetWidthFailInvalidInput) +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); } -TEST_F(SurfaceTest, SurfaceGetWidthFailNull) +TEST_F(TBMSurface, SurfaceGetWidthFailNull) { int width = tbm_surface_get_width(NULL); ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, width); } -TEST_F(SurfaceTest, SurfaceGetWidthSuccess) +TEST_F(TBMSurface, SurfaceGetWidthSuccess) { int width = tbm_surface_get_width(surface); ASSERT_EQ(this->width, width); } -TEST_F(SurfaceTest, SurfaceGetHeightFailInvalidInput) +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); } -TEST_F(SurfaceTest, SurfaceGetHeightFailNull) +TEST_F(TBMSurface, SurfaceGetHeightFailNull) { int height = tbm_surface_get_height(NULL); ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, height); } -TEST_F(SurfaceTest, SurfaceGetHeightSuccess) +TEST_F(TBMSurface, SurfaceGetHeightSuccess) { int height = tbm_surface_get_height(surface); ASSERT_EQ(this->height, height); } -TEST_F(SurfaceTest, SurfaceGetInfoInvalidInput) +TEST_F(TBMSurface, SurfaceGetInfoInvalidInput) { tbm_surface_h invalid_surface = (tbm_surface_h)1; tbm_surface_info_s info; @@ -133,7 +171,7 @@ TEST_F(SurfaceTest, SurfaceGetInfoInvalidInput) ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_OPERATION, result); } -TEST_F(SurfaceTest, SurfaceGetInfoFailNull) +TEST_F(TBMSurface, SurfaceGetInfoFailNull) { tbm_surface_info_s info; tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; @@ -148,7 +186,7 @@ TEST_F(SurfaceTest, SurfaceGetInfoFailNull) ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result); } -TEST_F(SurfaceTest, SurfaceGetInfoSuccess) +TEST_F(TBMSurface, SurfaceGetInfoSuccess) { tbm_surface_info_s info; tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; @@ -163,7 +201,7 @@ TEST_F(SurfaceTest, SurfaceGetInfoSuccess) ASSERT_GT(info.size, 0); } -TEST_F(SurfaceTest, SurfaceMapFailInvalidInput) +TEST_F(TBMSurface, SurfaceMapFailInvalidInput) { tbm_surface_info_s info; tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; @@ -173,7 +211,7 @@ TEST_F(SurfaceTest, SurfaceMapFailInvalidInput) ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_OPERATION, result); } -TEST_F(SurfaceTest, SurfaceMapFailNull) +TEST_F(TBMSurface, SurfaceMapFailNull) { tbm_surface_info_s info; tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; @@ -185,7 +223,7 @@ TEST_F(SurfaceTest, SurfaceMapFailNull) ASSERT_EQ(TBM_SURFACE_ERROR_INVALID_PARAMETER, result); } -TEST_F(SurfaceTest, SurfaceMapSuccess) +TEST_F(TBMSurface, SurfaceMapSuccess) { tbm_surface_info_s info; tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; @@ -203,7 +241,7 @@ TEST_F(SurfaceTest, SurfaceMapSuccess) ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result); } -TEST_F(SurfaceTest, SurfaceUnmapFailInvalidInput) +TEST_F(TBMSurface, SurfaceUnmapFailInvalidInput) { tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; tbm_surface_h invalid_surface = (tbm_surface_h)1; @@ -211,7 +249,7 @@ TEST_F(SurfaceTest, SurfaceUnmapFailInvalidInput) ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result); } -TEST_F(SurfaceTest, SurfaceUnmapFailNull) +TEST_F(TBMSurface, 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 index bcbbbce..6f47ab3 100644 --- a/utests/ut_tbm_surface_internal.cpp +++ b/utests/ut_tbm_surface_internal.cpp @@ -1,131 +1,156 @@ -#include -#include - -#include -#include -#include -#include -#include "ut.h" - -/* int tbm_surface_internal_query_supported_formats(uint32_t **formats, uint32_t *num) */ -TEST_F(SurfaceInternalQueryFormatsTest, SurfaceInternalQueryFormatsFailNull) -{ - uint32_t 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(SurfaceInternalQueryFormatsTest, SurfaceInternalQueryFormatsSuccess) -{ - uint32_t 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((tbm_format *)NULL, formats); - for (uint32_t i = 0; i < num; i++) - ASSERT_NE(0, formats[i]); +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Konstantin Drabeniuk + * Contact: Andrii Sokolenko + * Contact: Roman Marchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#include "ut_tbm.h" + +class TBMSurfaceInternal : public TBMBufmgr +{ +protected: + void SetUp(); + void TearDown(); +public: + uint32_t num_formats; + tbm_format *formats; + tbm_format argb8888_format; + + tbm_surface_h surface; +}; + +void TBMSurfaceInternal::SetUp() +{ + int ret = 0; + + TBMBufmgr::SetUp(); + + ret = tbm_surface_internal_query_supported_formats(&formats, &num_formats); + ASSERT_TRUE(ret == 1); + + for (uint32_t i = 0; i < num_formats; i++) + if (formats[i] == TBM_FORMAT_ARGB8888) + argb8888_format = TBM_FORMAT_ARGB8888; + + /* fail if there is no TBM_FORMAT_ARGB8888 format */ + ASSERT_TRUE(argb8888_format == TBM_FORMAT_ARGB8888); + + surface = tbm_surface_internal_create_with_flags(720, 1024, argb8888_format, TBM_BO_DEFAULT); + ASSERT_TRUE(surface != NULL); +} + +void TBMSurfaceInternal::TearDown() +{ + if (surface) + tbm_surface_internal_destroy(surface); if (formats) free(formats); -} + TBMBufmgr::TearDown(); +} /* tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height, int format, int flags) */ -TEST_F(SurfaceInternalTest, SurfaceInternalCeatewithFlagsFailInvalidInput) +TEST_F(TBMSurfaceInternal, SurfaceInternalCeateDestroyTest) { - tbm_surface_h surf1 = NULL; - - ut_set_default_tbm_env(); - - surf1 = tbm_surface_internal_create_with_flags(-1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, surf1); // Expected Value: NULL - - surf1 = tbm_surface_internal_create_with_flags(720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, surf1); - - surf1 = tbm_surface_internal_create_with_flags(720, 1024, 0, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, surf1); + tbm_surface_h surface1 = NULL; - surf1 = tbm_surface_internal_create_with_flags(720, 1024, 0, (TBM_BO_WC << 1)); - ASSERT_EQ(nullptr, surf1); + for (uint32_t i = 0; i < 1; i++) { + surface1 = tbm_surface_internal_create_with_flags(720, 1024, formats[i], TBM_BO_DEFAULT); + ASSERT_TRUE(surface1 != NULL); + tbm_surface_internal_destroy(surface1); + printf("!!!!!!!!!!!!!![soolim]: refcnt=%d\n", tbm_bufmgr_debug_get_ref_count()); + } } -TEST_F(SurfaceInternalTest, SurfaceInternalCeatewithFlagsSuccess) +TEST_F(TBMSurfaceInternal, SurfaceInternalCeatewithParamsTest) { - tbm_surface_h surf1 = NULL; - uint32_t num = 0; - - ut_set_default_tbm_env(); + tbm_surface_h surface1 = NULL; - for (uint32_t i = 0; i < num; i++) { - surf1 = tbm_surface_internal_create_with_flags(720, 1024, formats[i], TBM_BO_DEFAULT); - ASSERT_NE(nullptr, surf1); - tbm_surface_internal_destroy(surface); - } + surface1 = tbm_surface_internal_create_with_flags(-1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, surface1); // Expected Value: NULL + surface1 = tbm_surface_internal_create_with_flags(720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, surface1); + surface1 = tbm_surface_internal_create_with_flags(720, 1024, 0, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, surface1); + surface1 = tbm_surface_internal_create_with_flags(720, 1024, 0, (TBM_BO_WC << 1)); + ASSERT_EQ(nullptr, surface1); } - /* void tbm_surface_internal_destroy(tbm_surface_h surface) */ -TEST_F(SurfaceInternalTest, SurfaceInternalSurfaceInteranlDestroyFailNULL) +TEST_F(TBMSurfaceInternal, SurfaceInternalSurfaceInteranlDestroyWithParamsTest) { - ut_set_default_tbm_env(); - tbm_surface_internal_destroy(NULL); } -TEST_F(SurfaceInternalTest, SurfaceInteranlDestroyFailTwice) +TEST_F(TBMSurfaceInternal, SurfaceInteranlDestroyTwiceTest) { - tbm_surface_h surf = NULL; - - surf = tbm_surface_internal_create_with_flags(720, 1024, formats[0], TBM_BO_DEFAULT); - - tbm_surface_internal_destroy(surf); - - tbm_surface_internal_destroy(surf); + tbm_surface_h surface1 = NULL; + surface1 = tbm_surface_internal_create_with_flags(720, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + tbm_surface_internal_destroy(surface1); + tbm_surface_internal_destroy(surface1); } - /* tbm_surface_internal_is_valid(tbm_surface_h surface) */ -TEST_F(SurfaceInternalTest, IsValid) +TEST_F(TBMSurfaceInternal, SurfaceInteranlIsValid) { - int invalid_surf; + tbm_surface_h invalid_surface; + + ASSERT_TRUE(tbm_surface_internal_is_valid(surface)); + tbm_surface_internal_destroy(surface); 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));; -} + invalid_surface = (tbm_surface_h)UT_TBM_INVALID_VALUE; + ASSERT_FALSE(tbm_surface_internal_is_valid((tbm_surface_h)&invalid_surface)); +} /* int tbm_surface_internal_get_num_bos(tbm_surface_h surface) */ -TEST_F(SurfaceInternalTest, GetNumBosFailNULL) +TEST_F(TBMSurfaceInternal, GetNumBosFailNULL) { int num = tbm_surface_internal_get_num_bos(NULL); ASSERT_EQ(0, num); } -TEST_F(SurfaceInternalTest, GetNumBosSuccess) +TEST_F(TBMSurfaceInternal, 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(SurfaceInternalTest, GetBoFailNULL) +TEST_F(TBMSurfaceInternal, GetBoFailNULL) { tbm_bo bo = tbm_surface_internal_get_bo(NULL, 0); ASSERT_EQ(nullptr, bo); } -TEST_F(SurfaceInternalTest, GetBoFailInvalideInput) +TEST_F(TBMSurfaceInternal, GetBoFailInvalideInput) { tbm_surface_h invalide_surface = (tbm_surface_h)1; tbm_bo bo = NULL; @@ -145,7 +170,7 @@ TEST_F(SurfaceInternalTest, GetBoFailInvalideInput) ASSERT_EQ(nullptr, bo); } -TEST_F(SurfaceInternalTest, GetBoSuccess) +TEST_F(TBMSurfaceInternal, GetBoSuccess) { tbm_bo bo = NULL; int num = 0; @@ -160,7 +185,7 @@ TEST_F(SurfaceInternalTest, GetBoSuccess) } /* tbm_surface_h tbm_surface_internal_create_with_bos(tbm_surface_info_s *info, tbm_bo *bos, int num) */ -TEST_F(SurfaceInternalTest, CreateWithBosNullInput) +TEST_F(TBMSurfaceInternal, CreateWithBosNullInput) { tbm_surface_h surf = NULL; tbm_surface_info_s info = { 0 }; @@ -179,7 +204,7 @@ TEST_F(SurfaceInternalTest, CreateWithBosNullInput) ASSERT_EQ(nullptr, surf); } -TEST_F(SurfaceInternalTest, CreateWithBosFailInvalidInput) +TEST_F(TBMSurfaceInternal, CreateWithBosFailInvalidInput) { tbm_surface_h surf = NULL; tbm_surface_info_s info; @@ -211,7 +236,7 @@ TEST_F(SurfaceInternalTest, CreateWithBosFailInvalidInput) ASSERT_EQ(nullptr, surf); } -TEST_F(SurfaceInternalTest, CreateWithBosSuccess) +TEST_F(TBMSurfaceInternal, CreateWithBosSuccess) { tbm_surface_h surf = NULL; tbm_surface_info_s info; @@ -254,18 +279,18 @@ TEST_F(SurfaceInternalTest, CreateWithBosSuccess) } /* void tbm_surface_internal_unref(tbm_surface_h surface) */ -TEST_F(SurfaceInternalTest, UnrefFailNull) +TEST_F(TBMSurfaceInternal, UnrefFailNull) { tbm_surface_internal_unref(NULL); } -TEST_F(SurfaceInternalTest, UnrefFailInvaildInput) +TEST_F(TBMSurfaceInternal, UnrefFailInvaildInput) { int surf; tbm_surface_internal_unref((tbm_surface_h)&surf); } -TEST_F(SurfaceInternalTest, UnrefSuccess) +TEST_F(TBMSurfaceInternal, UnrefSuccess) { tbm_surface_internal_unref(surface); @@ -275,18 +300,18 @@ TEST_F(SurfaceInternalTest, UnrefSuccess) } /* void tbm_surface_internal_ref(tbm_surface_h surface) */ -TEST_F(SurfaceInternalTest, RefFailNull) +TEST_F(TBMSurfaceInternal, RefFailNull) { tbm_surface_internal_ref(NULL); } -TEST_F(SurfaceInternalTest, RefFailInvaildInput) +TEST_F(TBMSurfaceInternal, RefFailInvaildInput) { int surf; tbm_surface_internal_ref((tbm_surface_h)&surf); } -TEST_F(SurfaceInternalTest, RefSuccess) +TEST_F(TBMSurfaceInternal, RefSuccess) { tbm_surface_internal_ref(surface); tbm_surface_internal_unref(surface); @@ -294,7 +319,7 @@ TEST_F(SurfaceInternalTest, RefSuccess) } /* tbm_surface_internal_get_num_planes() */ -TEST_F(SurfaceInternalTest, GetNumPlanes) +TEST_F(TBMSurfaceInternal, GetNumPlanes) { int num = 0; num = tbm_surface_internal_get_num_planes(0); @@ -311,32 +336,32 @@ TEST_F(SurfaceInternalTest, GetNumPlanes) } /* tbm_surface_internal_get_size() */ -TEST_F(SurfaceInternalTest, GetSizeFailNull) +TEST_F(TBMSurfaceInternal, GetSizeFailNull) { int size = tbm_surface_internal_get_size(NULL); ASSERT_EQ(0, size); } -TEST_F(SurfaceInternalTest, GetSizeFailInvaildInput) +TEST_F(TBMSurfaceInternal, GetSizeFailInvaildInput) { int surf; int size = tbm_surface_internal_get_size((tbm_surface_h)&surf); ASSERT_EQ(0, size); } -TEST_F(SurfaceInternalTest, GetSizeSuccess) +TEST_F(TBMSurfaceInternal, 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(SurfaceInternalTest, GetPlaneDataFailNull) +TEST_F(TBMSurfaceInternal, GetPlaneDataFailNull) { ASSERT_FALSE(tbm_surface_internal_get_plane_data(NULL, 0, NULL, NULL, NULL)); } -TEST_F(SurfaceInternalTest, GetPlaneDataFailInvaildInput) +TEST_F(TBMSurfaceInternal, GetPlaneDataFailInvaildInput) { int surf; @@ -345,7 +370,7 @@ TEST_F(SurfaceInternalTest, GetPlaneDataFailInvaildInput) ASSERT_FALSE(tbm_surface_internal_get_plane_data(surface, 3, NULL, NULL, NULL)); } -TEST_F(SurfaceInternalTest, GetPlaneDataSuccess) +TEST_F(TBMSurfaceInternal, GetPlaneDataSuccess) { uint32_t size = 0, offset = 0, pitch = 0; @@ -359,7 +384,7 @@ TEST_F(SurfaceInternalTest, GetPlaneDataSuccess) } /* tbm_surface_internal_get_bpp(tbm_format format) */ -TEST_F(SurfaceInternalTest, GetBpp) +TEST_F(TBMSurfaceInternal, GetBpp) { int bpp = 0; bpp = tbm_surface_internal_get_bpp(0); @@ -396,13 +421,13 @@ TEST_F(SurfaceInternalTest, GetBpp) ASSERT_EQ(24, bpp); } /* tbm_surface_internal_get_plane_bo_idx(tbm_surface_h surface, int plane_idx) */ -TEST_F(SurfaceInternalTest, GetPlaneBoIndexFailNull) +TEST_F(TBMSurfaceInternal, GetPlaneBoIndexFailNull) { int idx = tbm_surface_internal_get_plane_bo_idx(NULL, 0); ASSERT_EQ(0, idx); } -TEST_F(SurfaceInternalTest, GetPlaneBoIndexFailInvaildInput) +TEST_F(TBMSurfaceInternal, GetPlaneBoIndexFailInvaildInput) { int surf; int idx; @@ -414,7 +439,7 @@ TEST_F(SurfaceInternalTest, GetPlaneBoIndexFailInvaildInput) ASSERT_EQ(0, idx); } -TEST_F(SurfaceInternalTest, GetPlaneBoIndexSuccess) +TEST_F(TBMSurfaceInternal, GetPlaneBoIndexSuccess) { int idx; @@ -431,26 +456,26 @@ void data_free_handle(void *user_data) } /* tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key, tbm_data_free data_free_func) */ -TEST_F(SurfaceInternalTest, AddUserDataFailNull) +TEST_F(TBMSurfaceInternal, AddUserDataFailNull) { static const unsigned long key_ud = 0; ASSERT_FALSE(tbm_surface_internal_add_user_data(NULL, key_ud, NULL)); } -TEST_F(SurfaceInternalTest, AddUserDataFailInvaildInput) +TEST_F(TBMSurfaceInternal, AddUserDataFailInvaildInput) { static const unsigned long key_ud = 0; int surf; ASSERT_FALSE(tbm_surface_internal_add_user_data((tbm_surface_h)&surf, key_ud, NULL)); } -TEST_F(SurfaceInternalTest, AddUserDataSuccess) +TEST_F(TBMSurfaceInternal, AddUserDataSuccess) { unsigned long key_ud = 157; ASSERT_TRUE(tbm_surface_internal_add_user_data(surface, key_ud, NULL)); } -TEST_F(SurfaceInternalTest, AddUserDataFailDoubleKey) +TEST_F(TBMSurfaceInternal, AddUserDataFailDoubleKey) { unsigned long key_ud = 5487; ASSERT_TRUE(tbm_surface_internal_add_user_data(surface, key_ud, NULL)); @@ -459,13 +484,13 @@ TEST_F(SurfaceInternalTest, AddUserDataFailDoubleKey) } /* tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key, void *data) */ -TEST_F(SurfaceInternalTest, SetUserDataFailNull) +TEST_F(TBMSurfaceInternal, SetUserDataFailNull) { static const unsigned long key_ud = 0; ASSERT_FALSE(tbm_surface_internal_set_user_data(NULL, key_ud, &tbm_data_free_is_called)); } -TEST_F(SurfaceInternalTest, SetUserDataFailInvaildInput) +TEST_F(TBMSurfaceInternal, SetUserDataFailInvaildInput) { static const unsigned long key_ud = 0; int surf; @@ -478,7 +503,7 @@ TEST_F(SurfaceInternalTest, SetUserDataFailInvaildInput) } -TEST_F(SurfaceInternalTest, SetUserDataSuccess) +TEST_F(TBMSurfaceInternal, SetUserDataSuccess) { unsigned long key_ud = 87947; ASSERT_TRUE(tbm_surface_internal_add_user_data(surface, key_ud, data_free_handle)); @@ -498,7 +523,7 @@ TEST_F(SurfaceInternalTest, SetUserDataSuccess) } /* tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key, void **data) */ -TEST_F(SurfaceInternalTest, GetUserDataFailNull) +TEST_F(TBMSurfaceInternal, GetUserDataFailNull) { static const unsigned long key_ud = 0; int *data = NULL; @@ -507,7 +532,7 @@ TEST_F(SurfaceInternalTest, GetUserDataFailNull) ASSERT_FALSE(tbm_surface_internal_get_user_data(surface, key_ud, NULL)); } -TEST_F(SurfaceInternalTest, GetUserDataFailInvaildInput) +TEST_F(TBMSurfaceInternal, GetUserDataFailInvaildInput) { static const unsigned long key_ud = 0; int surf; @@ -521,7 +546,7 @@ TEST_F(SurfaceInternalTest, GetUserDataFailInvaildInput) } -TEST_F(SurfaceInternalTest, GetUserDataSuccess) +TEST_F(TBMSurfaceInternal, GetUserDataSuccess) { unsigned long key_ud = 97456789; int *data = NULL; @@ -540,13 +565,13 @@ TEST_F(SurfaceInternalTest, GetUserDataSuccess) } /* tbm_surface_internal_delete_user_data(tbm_surface_h surface, unsigned long key) */ -TEST_F(SurfaceInternalTest, DeleteUserDataFailNull) +TEST_F(TBMSurfaceInternal, DeleteUserDataFailNull) { static const int key_ud = 0; ASSERT_FALSE(tbm_surface_internal_delete_user_data(NULL, key_ud)); } -TEST_F(SurfaceInternalTest, DeleteUserDataFailInvaildInput) +TEST_F(TBMSurfaceInternal, DeleteUserDataFailInvaildInput) { static const int key_ud = 0; int surf; @@ -555,7 +580,7 @@ TEST_F(SurfaceInternalTest, DeleteUserDataFailInvaildInput) ASSERT_FALSE(tbm_surface_internal_delete_user_data((tbm_surface_h)&surf, key_ud)) << "invalid surface"; } -TEST_F(SurfaceInternalTest, DeleteUserDataSuccess) +TEST_F(TBMSurfaceInternal, DeleteUserDataSuccess) { unsigned long key_ud = UINT_MAX; @@ -566,4 +591,4 @@ TEST_F(SurfaceInternalTest, DeleteUserDataSuccess) 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)); -} +} \ No newline at end of file diff --git a/utests/ut_tbm_surface_queue.cpp b/utests/ut_tbm_surface_queue.cpp index 7da92ff..99eb43a 100644 --- a/utests/ut_tbm_surface_queue.cpp +++ b/utests/ut_tbm_surface_queue.cpp @@ -1,15 +1,97 @@ -#include -#include -#include -#include -#include -#include "ut.h" +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Konstantin Drabeniuk + * Contact: Andrii Sokolenko + * Contact: Roman Marchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ -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; +#include "ut_tbm.h" +class TBMSurfaceQueue : public TBMBufmgr +{ +protected: + void SetUp(); + void TearDown(); +public: + int width; + int height; + int format; + + uint32_t num_formats; + tbm_format *formats; + + tbm_surface_h alien_surface; + tbm_surface_queue_h queue; + + tbm_surface_queue_error_e result; + tbm_surface_h surface; +}; + +void TBMSurfaceQueue::SetUp() +{ + tbm_surface_error_e result = TBM_SURFACE_ERROR_NONE; + + TBMBufmgr::SetUp(); + + result = (tbm_surface_error_e)tbm_surface_query_formats(&formats, &num_formats); + ASSERT_EQ(TBM_SURFACE_ERROR_NONE, result); + + for (uint32_t i = 0; i < num_formats; i++) + if (formats[i] == TBM_FORMAT_ARGB8888) + format = TBM_FORMAT_ARGB8888; + + /* fail if there is no TBM_FORMAT_ARGB8888 format */ + ASSERT_TRUE(format == TBM_FORMAT_ARGB8888); + + width = 720; + height = 1024; + alien_surface = tbm_surface_create(width, height, format); + ASSERT_NE((tbm_surface_h)NULL, alien_surface); + + queue = tbm_surface_queue_create(UT_TBM_SURFACE_QUEUE_SIZE, width, height, format, TBM_BO_DEFAULT); + ASSERT_NE((tbm_surface_queue_h)NULL, queue); +} + +void TBMSurfaceQueue::TearDown() +{ + if (alien_surface) + tbm_surface_destroy(alien_surface); + + if (queue) + tbm_surface_queue_destroy(queue); + + if (formats) + free(formats); + + TBMBufmgr::TearDown(); +} + +static int memory_for_invalid_param; +static tbm_surface_queue_h invalid_queue = (tbm_surface_queue_h)&memory_for_invalid_param; +static 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) @@ -37,91 +119,72 @@ void tbm_surface_free_cb_handler(tbm_surface_queue_h surface_queue, void *data, tbm_surface_destroy(surface); } -/* tbm_surface_queue_h tbm_surface_queue_create(int QUEUE_SIZE, int width, - int height, int format, int flags); */ -TEST(SurfaceQueueCreateTest, CreateFailInvalidInput) +TEST_F(TBMSurfaceQueue, CreateDestroyQueue) { - 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(nullptr, queue); // Expected Value: NULL - - queue = tbm_surface_queue_create(QUEUE_SIZE, -1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, queue); + tbm_surface_queue_h queue1 = NULL; - queue = tbm_surface_queue_create(QUEUE_SIZE, 720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, queue); + queue1 = tbm_surface_queue_create(UT_TBM_SURFACE_QUEUE_SIZE, 720, 1024, format, TBM_BO_DEFAULT); + ASSERT_NE(nullptr, queue1); - queue = tbm_surface_queue_create(QUEUE_SIZE, 720, 1024, 0, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, queue); + tbm_surface_queue_destroy(queue1); } -TEST(SurfaceQueueCreateTest, CreateSuccess) +/* tbm_surface_queue_h tbm_surface_queue_create(int UT_TBM_SURFACE_QUEUE_SIZE, int width, + int height, int format, int flags); */ +TEST_F(TBMSurfaceQueue, CreateFailInvalidInput) { - tbm_surface_queue_h queue = NULL; - uint32_t num = 0; - tbm_format *formats = NULL; - - ut_set_default_tbm_env(); + tbm_surface_queue_h queue1 = NULL; - ASSERT_TRUE(tbm_surface_internal_query_supported_formats(&formats, &num)); + queue1 = tbm_surface_queue_create(-1, 720, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, queue1); // Expected Value: NULL - queue = tbm_surface_queue_create(QUEUE_SIZE, 720, 1024, formats[0], TBM_BO_DEFAULT); - ASSERT_NE(nullptr, queue); + queue1 = tbm_surface_queue_create(UT_TBM_SURFACE_QUEUE_SIZE, -1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, queue1); - tbm_surface_queue_destroy(queue); + queue1 = tbm_surface_queue_create(UT_TBM_SURFACE_QUEUE_SIZE, 720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, queue1); - free(formats); + queue1 = tbm_surface_queue_create(UT_TBM_SURFACE_QUEUE_SIZE, 720, 1024, 0, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, queue1); } - -/* tbm_surface_queue_h tbm_surface_queue_sequence_create(int QUEUE_SIZE, int width, +/* tbm_surface_queue_h tbm_surface_queue_sequence_create(int UT_TBM_SURFACE_QUEUE_SIZE, int width, int height, int format, int flags); */ -TEST(SurfaceQueueCreateTest, SequenceCreateFailInvalidInput) +TEST_F(TBMSurfaceQueue, SequenceCreateFailInvalidInput) { - tbm_surface_queue_h queue = NULL; + tbm_surface_queue_h queue1 = NULL; - ut_set_default_tbm_env(); + queue1 = tbm_surface_queue_sequence_create(-1, 720, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, queue1); // Expected Value: NULL - queue = tbm_surface_queue_sequence_create(-1, 720, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, queue); // Expected Value: NULL + queue1 = tbm_surface_queue_sequence_create(UT_TBM_SURFACE_QUEUE_SIZE, -1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, queue1); - queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, -1, 1024, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, queue); + queue1 = tbm_surface_queue_sequence_create(UT_TBM_SURFACE_QUEUE_SIZE, 720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, queue1); - queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, 720, -1, TBM_FORMAT_ARGB8888, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, queue); - - queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, 720, 1024, 0, TBM_BO_DEFAULT); - ASSERT_EQ(nullptr, queue); + queue1 = tbm_surface_queue_sequence_create(UT_TBM_SURFACE_QUEUE_SIZE, 720, 1024, 0, TBM_BO_DEFAULT); + ASSERT_EQ(nullptr, queue1); } -TEST(SurfaceQueueCreateTest, SequenceCreateSuccess) +TEST_F(TBMSurfaceQueue, CreateDestroySequenceQueue) { - tbm_surface_queue_h queue = NULL; - uint32_t num = 0; - tbm_format *formats = NULL; - - ut_set_default_tbm_env(); + tbm_surface_queue_h queue1 = NULL; - ASSERT_TRUE(tbm_surface_internal_query_supported_formats(&formats, &num)); + queue1 = tbm_surface_queue_sequence_create(UT_TBM_SURFACE_QUEUE_SIZE, 720, 1024, formats[0], TBM_BO_DEFAULT); + ASSERT_NE(nullptr, queue1); - queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, 720, 1024, formats[0], TBM_BO_DEFAULT); - ASSERT_NE(nullptr, queue); - - free(formats); + tbm_surface_queue_destroy(queue1); } /* void tbm_surface_queue_destroy(tbm_surface_queue_h surface_queue); */ -TEST_F(SurfaceQueueTest, DestroyNULL) +TEST_F(TBMSurfaceQueue, DestroyNULL) { tbm_surface_queue_destroy(NULL); } -TEST_F(SurfaceQueueTest, DestroyTwice) +TEST_F(TBMSurfaceQueue, DestroyTwice) { tbm_surface_queue_destroy(queue); @@ -133,7 +196,7 @@ TEST_F(SurfaceQueueTest, DestroyTwice) /* tbm_surface_queue_error_e tbm_surface_queue_dequeue( tbm_surface_queue_h surface_queue, tbm_surface_h *surface); */ -TEST_F(SurfaceQueueTest, DequeueFailNull) +TEST_F(TBMSurfaceQueue, DequeueFailNull) { ASSERT_EXIT({ @@ -147,16 +210,16 @@ TEST_F(SurfaceQueueTest, DequeueFailNull) }, ::testing::ExitedWithCode(0), ""); } -TEST_F(SurfaceQueueTest, DequeueFailInvaildInput) +TEST_F(TBMSurfaceQueue, DequeueFailInvaildInput) { result = tbm_surface_queue_dequeue(invalid_queue, &surface); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, DequeueSuccess) +TEST_F(TBMSurfaceQueue, DequeueSuccess) { /* do dequeue three times */ - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_QUEUE_SIZE; i++) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); ASSERT_NE((tbm_surface_h)NULL, surface); @@ -169,9 +232,9 @@ TEST_F(SurfaceQueueTest, DequeueSuccess) /* tbm_surface_queue_error_e tbm_surface_queue_get_surfaces( tbm_surface_queue_h surface_queue, tbm_surface_h *surfaces, int *num); */ -TEST_F(SurfaceQueueTest, GetSurfacesFailNull) +TEST_F(TBMSurfaceQueue, GetSurfacesFailNull) { - tbm_surface_h surfaces[QUEUE_SIZE]; + tbm_surface_h surfaces[UT_TBM_SURFACE_QUEUE_SIZE]; int num; result = tbm_surface_queue_get_surfaces(NULL, surfaces, &num); @@ -181,18 +244,18 @@ TEST_F(SurfaceQueueTest, GetSurfacesFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, GetSurfacesFailInvaildInput) +TEST_F(TBMSurfaceQueue, GetSurfacesFailInvaildInput) { - tbm_surface_h surfaces[QUEUE_SIZE]; + tbm_surface_h surfaces[UT_TBM_SURFACE_QUEUE_SIZE]; int num; result = tbm_surface_queue_get_surfaces(invalid_queue, surfaces, &num); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, GetSurfacesSuccess) +TEST_F(TBMSurfaceQueue, GetSurfacesSuccess) { - tbm_surface_h surfaces[QUEUE_SIZE]; + tbm_surface_h surfaces[UT_TBM_SURFACE_QUEUE_SIZE]; int num = 0; /* test: empty queue*/ @@ -201,7 +264,7 @@ TEST_F(SurfaceQueueTest, GetSurfacesSuccess) ASSERT_EQ(0, num); /* do dequeue three times */ - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_QUEUE_SIZE; i++) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); ASSERT_NE(nullptr, surface); @@ -210,19 +273,19 @@ TEST_F(SurfaceQueueTest, GetSurfacesSuccess) /* 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_EQ(UT_TBM_SURFACE_QUEUE_SIZE, num); + for (int i = 0; i < UT_TBM_SURFACE_QUEUE_SIZE; i++) ASSERT_NE(nullptr, surfaces[i]); /* test: get only number of surfaces */ result = tbm_surface_queue_get_surfaces(queue, NULL, &num); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); - ASSERT_EQ(QUEUE_SIZE, num); + ASSERT_EQ(UT_TBM_SURFACE_QUEUE_SIZE, num); } /* tbm_surface_queue_error_e tbm_surface_queue_cancel_dequeue( tbm_surface_queue_h surface_queue, tbm_surface_h surface); */ -TEST_F(SurfaceQueueTest, CancelDequeueFailNull) +TEST_F(TBMSurfaceQueue, CancelDequeueFailNull) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -234,7 +297,7 @@ TEST_F(SurfaceQueueTest, CancelDequeueFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, CancelDequeueFailInvaildInput) +TEST_F(TBMSurfaceQueue, CancelDequeueFailInvaildInput) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -250,11 +313,11 @@ TEST_F(SurfaceQueueTest, CancelDequeueFailInvaildInput) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, CancelDequeueSuccess) +TEST_F(TBMSurfaceQueue, CancelDequeueSuccess) { tbm_surface_h last_surface = NULL; - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_QUEUE_SIZE; i++) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); ASSERT_NE(nullptr, surface); @@ -277,7 +340,7 @@ TEST_F(SurfaceQueueTest, CancelDequeueSuccess) /* tbm_surface_queue_error_e tbm_surface_queue_enqueue( tbm_surface_queue_h surface_queue, tbm_surface_h surface); */ -TEST_F(SurfaceQueueTest, EnqueueFailNull) +TEST_F(TBMSurfaceQueue, EnqueueFailNull) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -290,7 +353,7 @@ TEST_F(SurfaceQueueTest, EnqueueFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, EnqueueFailInvaildInput) +TEST_F(TBMSurfaceQueue, EnqueueFailInvaildInput) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -306,24 +369,24 @@ TEST_F(SurfaceQueueTest, EnqueueFailInvaildInput) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, EnqueueSuccess) +TEST_F(TBMSurfaceQueue, EnqueueSuccess) { - tbm_surface_h surfaces[QUEUE_SIZE] = { NULL }; + tbm_surface_h surfaces[UT_TBM_SURFACE_QUEUE_SIZE] = { NULL }; - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_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++) { + for (int i = 0; i < UT_TBM_SURFACE_QUEUE_SIZE; i++) { result = tbm_surface_queue_enqueue(queue, surfaces[i]); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); } } -TEST_F(SurfaceQueueTest, EnqueueFailTwice) +TEST_F(TBMSurfaceQueue, EnqueueFailTwice) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -338,7 +401,7 @@ TEST_F(SurfaceQueueTest, EnqueueFailTwice) /* tbm_surface_queue_error_e tbm_surface_queue_acquire( tbm_surface_queue_h surface_queue, tbm_surface_h *surface); */ -TEST_F(SurfaceQueueTest, AcquireFailNull) +TEST_F(TBMSurfaceQueue, AcquireFailNull) { /* test */ result = tbm_surface_queue_acquire(NULL, &surface); @@ -348,25 +411,25 @@ TEST_F(SurfaceQueueTest, AcquireFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AcquireFailInvaildInput) +TEST_F(TBMSurfaceQueue, AcquireFailInvaildInput) { result = tbm_surface_queue_acquire(invalid_queue, &surface); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AcquireFailAcquireEmptyQueue) +TEST_F(TBMSurfaceQueue, AcquireFailAcquireEmptyQueue) { result = tbm_surface_queue_acquire(invalid_queue, &surface); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AcquireSuccess) +TEST_F(TBMSurfaceQueue, AcquireSuccess) { - tbm_surface_h surfaces[QUEUE_SIZE] = { NULL }; + tbm_surface_h surfaces[UT_TBM_SURFACE_QUEUE_SIZE] = { NULL }; tbm_surface_h acquired_surface = NULL; - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_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]); @@ -374,7 +437,7 @@ TEST_F(SurfaceQueueTest, AcquireSuccess) } /* test */ - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_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); @@ -388,7 +451,7 @@ TEST_F(SurfaceQueueTest, AcquireSuccess) /* tbm_surface_queue_error_e tbm_surface_queue_cancel_acquire( tbm_surface_queue_h surface_queue, tbm_surface_h surface); */ -TEST_F(SurfaceQueueTest, CancelAcquireFailNull) +TEST_F(TBMSurfaceQueue, CancelAcquireFailNull) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -402,7 +465,7 @@ TEST_F(SurfaceQueueTest, CancelAcquireFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, CancelAcquireFailInvaildInput) +TEST_F(TBMSurfaceQueue, CancelAcquireFailInvaildInput) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -420,18 +483,18 @@ TEST_F(SurfaceQueueTest, CancelAcquireFailInvaildInput) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, CancelAcquireSuccess) +TEST_F(TBMSurfaceQueue, CancelAcquireSuccess) { tbm_surface_h last_surface = NULL; - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_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++) { + for (int i = 0; i < UT_TBM_SURFACE_QUEUE_SIZE; i++) { result = tbm_surface_queue_acquire(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); } @@ -453,7 +516,7 @@ TEST_F(SurfaceQueueTest, CancelAcquireSuccess) /* tbm_surface_queue_error_e tbm_surface_queue_release( tbm_surface_queue_h surface_queue, tbm_surface_h surface); */ -TEST_F(SurfaceQueueTest, ReleaseFailNull) +TEST_F(TBMSurfaceQueue, ReleaseFailNull) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -470,7 +533,7 @@ TEST_F(SurfaceQueueTest, ReleaseFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, ReleaseFailInvaildInput) +TEST_F(TBMSurfaceQueue, ReleaseFailInvaildInput) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -490,11 +553,11 @@ TEST_F(SurfaceQueueTest, ReleaseFailInvaildInput) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, ReleaseSuccess) +TEST_F(TBMSurfaceQueue, ReleaseSuccess) { - tbm_surface_h surfaces[QUEUE_SIZE] = { NULL }; + tbm_surface_h surfaces[UT_TBM_SURFACE_QUEUE_SIZE] = { NULL }; - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_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]); @@ -504,22 +567,22 @@ TEST_F(SurfaceQueueTest, ReleaseSuccess) } /* test */ - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_QUEUE_SIZE; i++) { result = tbm_surface_queue_release(queue, surfaces[i]); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); } } -TEST_F(SurfaceQueueTest, ReleaseSequenceSuccess) +TEST_F(TBMSurfaceQueue, ReleaseSequenceSuccess) { - tbm_surface_h surfaces[QUEUE_SIZE] = { NULL }; + tbm_surface_h surfaces[UT_TBM_SURFACE_QUEUE_SIZE] = { NULL }; /* create a sequence queue instead of a default one*/ tbm_surface_queue_destroy(queue); - queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, width, height, format, TBM_BO_DEFAULT); + queue = tbm_surface_queue_sequence_create(UT_TBM_SURFACE_QUEUE_SIZE, width, height, format, TBM_BO_DEFAULT); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_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]); @@ -529,13 +592,13 @@ TEST_F(SurfaceQueueTest, ReleaseSequenceSuccess) } /* test */ - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_QUEUE_SIZE; i++) { result = tbm_surface_queue_release(queue, surfaces[i]); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); } } -TEST_F(SurfaceQueueTest, ReleaseFailTwice) +TEST_F(TBMSurfaceQueue, ReleaseFailTwice) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -553,90 +616,90 @@ TEST_F(SurfaceQueueTest, ReleaseFailTwice) } /* int tbm_surface_queue_get_width(tbm_surface_queue_h surface_queue); */ -TEST_F(SurfaceQueueTest, GetWidthFailNull) +TEST_F(TBMSurfaceQueue, GetWidthFailNull) { int width = tbm_surface_queue_get_width(NULL); ASSERT_EQ(0, width); } -TEST_F(SurfaceQueueTest, GetWidthFailInvalidInput) +TEST_F(TBMSurfaceQueue, GetWidthFailInvalidInput) { int width = tbm_surface_queue_get_width(invalid_queue); ASSERT_EQ(0, width); } -TEST_F(SurfaceQueueTest, GetWidthSuccess) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, GetHeightFailNull) +TEST_F(TBMSurfaceQueue, GetHeightFailNull) { int height = tbm_surface_queue_get_height(NULL); ASSERT_EQ(0, height); } -TEST_F(SurfaceQueueTest, GetHeightFailInvalidInput) +TEST_F(TBMSurfaceQueue, GetHeightFailInvalidInput) { int height = tbm_surface_queue_get_height(invalid_queue); ASSERT_EQ(0, height); } -TEST_F(SurfaceQueueTest, GetHeightSuccess) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, GetFormatFailNull) +TEST_F(TBMSurfaceQueue, GetFormatFailNull) { int format = tbm_surface_queue_get_format(NULL); ASSERT_EQ(0, format); } -TEST_F(SurfaceQueueTest, GetFormatFailInvalidInput) +TEST_F(TBMSurfaceQueue, GetFormatFailInvalidInput) { int format = tbm_surface_queue_get_format(invalid_queue); ASSERT_EQ(0, format); } -TEST_F(SurfaceQueueTest, GetFormatSuccess) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, GetSizeFailNull) +TEST_F(TBMSurfaceQueue, GetSizeFailNull) { int q_size = tbm_surface_queue_get_size(NULL); ASSERT_EQ(0, q_size); } -TEST_F(SurfaceQueueTest, GetSizeFailInvalidInput) +TEST_F(TBMSurfaceQueue, GetSizeFailInvalidInput) { int q_size = tbm_surface_queue_get_size(invalid_queue); ASSERT_EQ(0, q_size); } -TEST_F(SurfaceQueueTest, GetSizeSuccess) +TEST_F(TBMSurfaceQueue, GetSizeSuccess) { int q_size = tbm_surface_queue_get_size(queue); - ASSERT_EQ(QUEUE_SIZE, q_size); + ASSERT_EQ(UT_TBM_SURFACE_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(SurfaceQueueTest, ResetFailNull) +TEST_F(TBMSurfaceQueue, ResetFailNull) { result = tbm_surface_queue_reset(NULL, width, height, format); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, ResetFailInvalidInput) +TEST_F(TBMSurfaceQueue, ResetFailInvalidInput) { result = tbm_surface_queue_reset(invalid_queue, width, height, format); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -651,13 +714,13 @@ TEST_F(SurfaceQueueTest, ResetFailInvalidInput) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, ResetSuccessEmptyQueue) +TEST_F(TBMSurfaceQueue, ResetSuccessEmptyQueue) { result = tbm_surface_queue_reset(queue, width-10, height-10, format); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, ResetSuccessSameParams) +TEST_F(TBMSurfaceQueue, ResetSuccessSameParams) { tbm_surface_h surface = NULL; @@ -673,7 +736,7 @@ TEST_F(SurfaceQueueTest, ResetSuccessSameParams) ASSERT_TRUE(tbm_surface_internal_is_valid(surface)) << "old surface mast be valid"; } -TEST_F(SurfaceQueueTest, ResetSuccess) +TEST_F(TBMSurfaceQueue, ResetSuccess) { tbm_surface_h surface = NULL; @@ -689,13 +752,13 @@ TEST_F(SurfaceQueueTest, ResetSuccess) ASSERT_FALSE(tbm_surface_internal_is_valid(surface)) << "old surface has to be deleted"; } -TEST_F(SurfaceQueueTest, ResetSequenceSuccess) +TEST_F(TBMSurfaceQueue, ResetSequenceSuccess) { tbm_surface_h surface = NULL; /* create a sequence queue instead of a default one*/ tbm_surface_queue_destroy(queue); - queue = tbm_surface_queue_sequence_create(QUEUE_SIZE, width, height, format, TBM_BO_DEFAULT); + queue = tbm_surface_queue_sequence_create(UT_TBM_SURFACE_QUEUE_SIZE, width, height, format, TBM_BO_DEFAULT); ASSERT_TRUE(queue != NULL); result = tbm_surface_queue_dequeue(queue, &surface); @@ -710,23 +773,23 @@ TEST_F(SurfaceQueueTest, ResetSequenceSuccess) } /* tbm_surface_queue_error_e tbm_surface_queue_set_size( - tbm_surface_queue_h surface_queue, int QUEUE_SIZE, int flush); */ -TEST_F(SurfaceQueueTest, SetSizeFailNull) + tbm_surface_queue_h surface_queue, int UT_TBM_SURFACE_QUEUE_SIZE, int flush); */ +TEST_F(TBMSurfaceQueue, SetSizeFailNull) { - result = tbm_surface_queue_set_size(NULL, QUEUE_SIZE, 0); + result = tbm_surface_queue_set_size(NULL, UT_TBM_SURFACE_QUEUE_SIZE, 0); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, SetSizeFailInvalidInput) +TEST_F(TBMSurfaceQueue, SetSizeFailInvalidInput) { - result = tbm_surface_queue_set_size(invalid_queue, QUEUE_SIZE, 0); + result = tbm_surface_queue_set_size(invalid_queue, UT_TBM_SURFACE_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(SurfaceQueueTest, SetSizeSuccessTheSameSize) +TEST_F(TBMSurfaceQueue, SetSizeSuccessTheSameSize) { tbm_surface_h surface = NULL; @@ -734,17 +797,17 @@ TEST_F(SurfaceQueueTest, SetSizeSuccessTheSameSize) ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); /*test: */ - result = tbm_surface_queue_set_size(queue, QUEUE_SIZE, 0); + result = tbm_surface_queue_set_size(queue, UT_TBM_SURFACE_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); + result = tbm_surface_queue_set_size(queue, UT_TBM_SURFACE_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(SurfaceQueueTest, SetSizeSuccessIncrease) +TEST_F(TBMSurfaceQueue, SetSizeSuccessIncrease) { tbm_surface_h surface = NULL; @@ -752,17 +815,17 @@ TEST_F(SurfaceQueueTest, SetSizeSuccessIncrease) ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); /*test: */ - result = tbm_surface_queue_set_size(queue, QUEUE_SIZE+1, 0); + result = tbm_surface_queue_set_size(queue, UT_TBM_SURFACE_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); + result = tbm_surface_queue_set_size(queue, UT_TBM_SURFACE_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(SurfaceQueueTest, SetSizeSuccessReduce) +TEST_F(TBMSurfaceQueue, SetSizeSuccessReduce) { tbm_surface_h surface = NULL; @@ -770,39 +833,39 @@ TEST_F(SurfaceQueueTest, SetSizeSuccessReduce) ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); /*test: */ - result = tbm_surface_queue_set_size(queue, QUEUE_SIZE-1, 0); + result = tbm_surface_queue_set_size(queue, UT_TBM_SURFACE_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); + result = tbm_surface_queue_set_size(queue, UT_TBM_SURFACE_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(SurfaceQueueTest, FlushFailNull) +TEST_F(TBMSurfaceQueue, FlushFailNull) { result = tbm_surface_queue_flush(NULL); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, FlushFailInvalidInput) +TEST_F(TBMSurfaceQueue, FlushFailInvalidInput) { result = tbm_surface_queue_flush(invalid_queue); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, FlushSuccess) +TEST_F(TBMSurfaceQueue, FlushSuccess) { - tbm_surface_h surfaces[QUEUE_SIZE]; + tbm_surface_h surfaces[UT_TBM_SURFACE_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++) { + for (int i = 0; i < UT_TBM_SURFACE_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]); @@ -814,26 +877,26 @@ TEST_F(SurfaceQueueTest, FlushSuccess) ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); /* extra check */ - for (int i = 0; i < QUEUE_SIZE; i++) + for (int i = 0; i < UT_TBM_SURFACE_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(SurfaceQueueTest, FreeFlushFailNull) +TEST_F(TBMSurfaceQueue, FreeFlushFailNull) { result = tbm_surface_queue_free_flush(NULL); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, FreeFlushFailInvalidInput) +TEST_F(TBMSurfaceQueue, FreeFlushFailInvalidInput) { result = tbm_surface_queue_free_flush(invalid_queue); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, FreeFlushSuccess) +TEST_F(TBMSurfaceQueue, FreeFlushSuccess) { - tbm_surface_h surfaces[QUEUE_SIZE]; + tbm_surface_h surfaces[UT_TBM_SURFACE_QUEUE_SIZE]; /*test: flushing not initialized queue*/ result = tbm_surface_queue_free_flush(queue); @@ -841,7 +904,7 @@ TEST_F(SurfaceQueueTest, FreeFlushSuccess) /* init queue */ - for (int i = 0; i < QUEUE_SIZE; i++) { + for (int i = 0; i < UT_TBM_SURFACE_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]); @@ -853,13 +916,13 @@ TEST_F(SurfaceQueueTest, FreeFlushSuccess) ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); /* extra check */ - for (int i = 0; i < QUEUE_SIZE; i++) + for (int i = 0; i < UT_TBM_SURFACE_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(SurfaceQueueTest, AddResetCbFailNull) +TEST_F(TBMSurfaceQueue, AddResetCbFailNull) { result = tbm_surface_queue_add_reset_cb(NULL, tbm_surface_queue_event_handler, &cb_data); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -868,13 +931,13 @@ TEST_F(SurfaceQueueTest, AddResetCbFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AddResetCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, AddResetCbSuccess) +TEST_F(TBMSurfaceQueue, AddResetCbSuccess) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -894,13 +957,13 @@ TEST_F(SurfaceQueueTest, AddResetCbSuccess) /* 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(SurfaceQueueTest, RemoveResetCbFailNull) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveResetCbSuccess) +TEST_F(TBMSurfaceQueue, RemoveResetCbSuccess) { result = tbm_surface_queue_dequeue(queue, &surface); result = tbm_surface_queue_enqueue(queue, surface); @@ -917,7 +980,7 @@ TEST_F(SurfaceQueueTest, RemoveResetCbSuccess) ASSERT_TRUE(cb_data == 0); } -TEST_F(SurfaceQueueTest, RemoveResetCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, RemoveResetCbFailInvalidInput) { result = tbm_surface_queue_dequeue(queue, &surface); result = tbm_surface_queue_enqueue(queue, surface); @@ -943,19 +1006,19 @@ TEST_F(SurfaceQueueTest, RemoveResetCbFailInvalidInput) } /* tbm_surface_queue_error_e tbm_surface_queue_notify_reset(tbm_surface_queue_h surface_queue); */ -TEST_F(SurfaceQueueTest, NotifyResetFailNull) +TEST_F(TBMSurfaceQueue, NotifyResetFailNull) { result = tbm_surface_queue_notify_reset(NULL); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, NotifyResetFailInvalidInput) +TEST_F(TBMSurfaceQueue, NotifyResetFailInvalidInput) { result = tbm_surface_queue_notify_reset(invalid_queue); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, NotifyResetCbSuccess) +TEST_F(TBMSurfaceQueue, NotifyResetCbSuccess) { result = tbm_surface_queue_add_reset_cb(queue, tbm_surface_queue_event_handler, &cb_data); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -968,17 +1031,17 @@ TEST_F(SurfaceQueueTest, NotifyResetCbSuccess) } /* int tbm_surface_queue_can_dequeue(tbm_surface_queue_h surface_queue, int wait); */ -TEST_F(SurfaceQueueTest, CanDequeueFailNull) +TEST_F(TBMSurfaceQueue, CanDequeueFailNull) { ASSERT_FALSE(tbm_surface_queue_can_dequeue(NULL, 0)); } -TEST_F(SurfaceQueueTest, CanDequeueFailInvalidInput) +TEST_F(TBMSurfaceQueue, CanDequeueFailInvalidInput) { ASSERT_FALSE(tbm_surface_queue_can_dequeue(invalid_queue, 0)); } -TEST_F(SurfaceQueueTest, CanDequeueSuccess) +TEST_F(TBMSurfaceQueue, CanDequeueSuccess) { int dq_count = 0; @@ -988,10 +1051,10 @@ TEST_F(SurfaceQueueTest, CanDequeueSuccess) ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); dq_count++; } - ASSERT_EQ(QUEUE_SIZE, dq_count); + ASSERT_EQ(UT_TBM_SURFACE_QUEUE_SIZE, dq_count); } -TEST_F(SurfaceQueueTest, CanDequeueFailEmptyQueue) +TEST_F(TBMSurfaceQueue, CanDequeueFailEmptyQueue) { /*Dequeue all*/ while (tbm_surface_queue_can_dequeue(queue, 0)) { @@ -1005,22 +1068,22 @@ TEST_F(SurfaceQueueTest, CanDequeueFailEmptyQueue) /* int tbm_surface_queue_can_acquire(tbm_surface_queue_h surface_queue, int wait); */ -TEST_F(SurfaceQueueTest, CanAcquireFailNull) +TEST_F(TBMSurfaceQueue, CanAcquireFailNull) { ASSERT_FALSE(tbm_surface_queue_can_acquire(NULL, 0)); } -TEST_F(SurfaceQueueTest, CanAcquireFailInvalidInput) +TEST_F(TBMSurfaceQueue, CanAcquireFailInvalidInput) { ASSERT_FALSE(tbm_surface_queue_can_acquire(invalid_queue, 0)); } -TEST_F(SurfaceQueueTest, CanAcquireFailEmptyQueue) +TEST_F(TBMSurfaceQueue, CanAcquireFailEmptyQueue) { ASSERT_FALSE(tbm_surface_queue_can_acquire(queue, 0)); } -TEST_F(SurfaceQueueTest, CanAcquireSuccess) +TEST_F(TBMSurfaceQueue, CanAcquireSuccess) { int acq_count = 0; @@ -1037,12 +1100,12 @@ TEST_F(SurfaceQueueTest, CanAcquireSuccess) acq_count++; } - ASSERT_EQ(QUEUE_SIZE, acq_count); + ASSERT_EQ(UT_TBM_SURFACE_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(SurfaceQueueTest, AddDestroyCbFailNull) +TEST_F(TBMSurfaceQueue, AddDestroyCbFailNull) { result = tbm_surface_queue_add_destroy_cb(NULL, tbm_surface_queue_event_handler, &cb_data); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1051,13 +1114,13 @@ TEST_F(SurfaceQueueTest, AddDestroyCbFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AddDestroyCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, AddDestroyCbSuccess) +TEST_F(TBMSurfaceQueue, AddDestroyCbSuccess) { /* test */ result = tbm_surface_queue_add_destroy_cb(queue, tbm_surface_queue_event_handler, &cb_data); @@ -1073,19 +1136,19 @@ TEST_F(SurfaceQueueTest, AddDestroyCbSuccess) /* 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(SurfaceQueueTest, RemoveDestroyCbFailNull) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveDestroyCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveDestroyCbSuccess) +TEST_F(TBMSurfaceQueue, RemoveDestroyCbSuccess) { result = tbm_surface_queue_add_destroy_cb(queue, tbm_surface_queue_event_handler, &cb_data); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1102,7 +1165,7 @@ TEST_F(SurfaceQueueTest, RemoveDestroyCbSuccess) /* 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(SurfaceQueueTest, AddDequeuableCbFailNull) +TEST_F(TBMSurfaceQueue, AddDequeuableCbFailNull) { result = tbm_surface_queue_add_dequeuable_cb(NULL, tbm_surface_queue_event_handler, &cb_data); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1111,13 +1174,13 @@ TEST_F(SurfaceQueueTest, AddDequeuableCbFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AddDequeuableCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, AddDequeuableCbSuccess) +TEST_F(TBMSurfaceQueue, AddDequeuableCbSuccess) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1139,20 +1202,20 @@ TEST_F(SurfaceQueueTest, AddDequeuableCbSuccess) /* 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(SurfaceQueueTest, RemoveDequeuableCbFailNull) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveDequeuableCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveDequeuableCbSuccess) +TEST_F(TBMSurfaceQueue, RemoveDequeuableCbSuccess) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1175,7 +1238,7 @@ TEST_F(SurfaceQueueTest, RemoveDequeuableCbSuccess) /* 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(SurfaceQueueTest, AddDequeueCbFailNull) +TEST_F(TBMSurfaceQueue, AddDequeueCbFailNull) { result = tbm_surface_queue_add_dequeue_cb(NULL, tbm_surface_queue_event_handler, &cb_data); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1184,13 +1247,13 @@ TEST_F(SurfaceQueueTest, AddDequeueCbFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AddDequeueCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, AddDequeueCbSuccess) +TEST_F(TBMSurfaceQueue, AddDequeueCbSuccess) { /* test */ result = tbm_surface_queue_add_dequeue_cb(queue, tbm_surface_queue_event_handler, &cb_data); @@ -1204,20 +1267,20 @@ TEST_F(SurfaceQueueTest, AddDequeueCbSuccess) /* 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(SurfaceQueueTest, RemoveDequeueCbFailNull) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveDequeueCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveDequeueCbSuccess) +TEST_F(TBMSurfaceQueue, RemoveDequeueCbSuccess) { /* test */ result = tbm_surface_queue_add_dequeue_cb(queue, tbm_surface_queue_event_handler, &cb_data); @@ -1239,7 +1302,7 @@ TEST_F(SurfaceQueueTest, RemoveDequeueCbSuccess) /* 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(SurfaceQueueTest, AddCanDequeueCbFailNull) +TEST_F(TBMSurfaceQueue, 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); @@ -1248,13 +1311,13 @@ TEST_F(SurfaceQueueTest, AddCanDequeueCbFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AddCanDequeueCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, AddCanDequeueCbSuccess) +TEST_F(TBMSurfaceQueue, AddCanDequeueCbSuccess) { /* test */ result = tbm_surface_queue_add_can_dequeue_cb(queue, tbm_surface_queue_event_handler, &cb_data); @@ -1267,20 +1330,20 @@ TEST_F(SurfaceQueueTest, AddCanDequeueCbSuccess) /* 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(SurfaceQueueTest, RemoveCanDequeueCbFailNull) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveCanDequeueCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveCanDequeueCbSuccess) +TEST_F(TBMSurfaceQueue, 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); @@ -1296,7 +1359,7 @@ TEST_F(SurfaceQueueTest, RemoveCanDequeueCbSuccess) /* 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(SurfaceQueueTest, AddAcquirableCbFailNull) +TEST_F(TBMSurfaceQueue, AddAcquirableCbFailNull) { result = tbm_surface_queue_add_acquirable_cb(NULL, tbm_surface_queue_event_handler, &cb_data); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1305,13 +1368,13 @@ TEST_F(SurfaceQueueTest, AddAcquirableCbFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AddAcquirableCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, AddAcquirableCbSuccess) +TEST_F(TBMSurfaceQueue, AddAcquirableCbSuccess) { tbm_surface_queue_dequeue(queue, &surface); @@ -1327,20 +1390,20 @@ TEST_F(SurfaceQueueTest, AddAcquirableCbSuccess) /* 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(SurfaceQueueTest, RemoveAcquirableCbFailNull) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveAcquirableCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveAcquirableCbSuccess) +TEST_F(TBMSurfaceQueue, RemoveAcquirableCbSuccess) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1359,7 +1422,7 @@ TEST_F(SurfaceQueueTest, RemoveAcquirableCbSuccess) /* 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(SurfaceQueueTest, AddTraceCbFailNull) +TEST_F(TBMSurfaceQueue, 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); @@ -1368,13 +1431,13 @@ TEST_F(SurfaceQueueTest, AddTraceCbFailNull) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, AddTraceCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, AddTraceCbSuccess) +TEST_F(TBMSurfaceQueue, AddTraceCbSuccess) { trace_cb_data = TBM_SURFACE_QUEUE_TRACE_NONE; @@ -1411,20 +1474,20 @@ TEST_F(SurfaceQueueTest, AddTraceCbSuccess) /* 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(SurfaceQueueTest, RemoveTraceCbFailNull) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveTraceCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, RemoveTraceCbSuccess) +TEST_F(TBMSurfaceQueue, RemoveTraceCbSuccess) { trace_cb_data = TBM_SURFACE_QUEUE_TRACE_NONE; @@ -1442,21 +1505,21 @@ TEST_F(SurfaceQueueTest, RemoveTraceCbSuccess) /* 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(SurfaceQueueTest, SetAllocCbFailNull) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, SetAllocCbFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, SetAllocCbSuccess) +TEST_F(TBMSurfaceQueue, SetAllocCbSuccess) { result = tbm_surface_queue_set_alloc_cb(queue, tbm_surface_alloc_cb_handler, tbm_surface_free_cb_handler, alien_surface); @@ -1476,7 +1539,7 @@ TEST_F(SurfaceQueueTest, SetAllocCbSuccess) /* 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(SurfaceQueueTest, GetTraceSurfaceNumFailNull) +TEST_F(TBMSurfaceQueue, GetTraceSurfaceNumFailNull) { int num = 0; @@ -1493,7 +1556,7 @@ TEST_F(SurfaceQueueTest, GetTraceSurfaceNumFailNull) } -TEST_F(SurfaceQueueTest, GetTraceSurfaceNumFailInvalidInput) +TEST_F(TBMSurfaceQueue, GetTraceSurfaceNumFailInvalidInput) { int num = 0; @@ -1501,7 +1564,7 @@ TEST_F(SurfaceQueueTest, GetTraceSurfaceNumFailInvalidInput) ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, GetTraceSurfaceNumSuccess) +TEST_F(TBMSurfaceQueue, GetTraceSurfaceNumSuccess) { int num = 0; @@ -1547,38 +1610,38 @@ TEST_F(SurfaceQueueTest, GetTraceSurfaceNumSuccess) } /* tbm_surface_queue_error_e tbm_surface_queue_set_modes( tbm_surface_queue_h surface_queue, int modes); */ -TEST_F(SurfaceQueueTest, SetModesFailNull) +TEST_F(TBMSurfaceQueue, SetModesFailNull) { result = tbm_surface_queue_set_modes(NULL, TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, SetModesFailInvalidInput) +TEST_F(TBMSurfaceQueue, 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(SurfaceQueueTest, SetModesSuccess) +TEST_F(TBMSurfaceQueue, SetModesSuccess) { result = tbm_surface_queue_set_modes(queue, TBM_SURFACE_QUEUE_MODE_GUARANTEE_CYCLE); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); } /* tbm_surface_queue_set_sync_count() */ -TEST_F(SurfaceQueueTest, SetSyncCountFailNull) +TEST_F(TBMSurfaceQueue, SetSyncCountFailNull) { result = tbm_surface_queue_set_sync_count(NULL, 1); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, SetSyncCountFailInvalidInput) +TEST_F(TBMSurfaceQueue, SetSyncCountFailInvalidInput) { result = tbm_surface_queue_set_sync_count(invalid_queue, 1); ASSERT_NE(TBM_SURFACE_QUEUE_ERROR_NONE, result); } -TEST_F(SurfaceQueueTest, SetSyncCountSuccess) +TEST_F(TBMSurfaceQueue, SetSyncCountSuccess) { result = tbm_surface_queue_dequeue(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); @@ -1597,4 +1660,4 @@ TEST_F(SurfaceQueueTest, SetSyncCountSuccess) result = tbm_surface_queue_acquire(queue, &surface); ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, result); -} +} \ No newline at end of file