f4e05dd84a29074310332071f776dd126b280196
[platform/core/uifw/libtbm.git] / haltests / tc_tbm.h
1 /**************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
4  *
5  * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
6  * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
7  * Contact: Roman Marchenko <r.marchenko@samsung.com>
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sub license, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice (including the
18  * next paragraph) shall be included in all copies or substantial portions
19  * of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
24  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
25  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28  *
29 **************************************************************************/
30
31 #ifndef UT_H
32 #define UT_H
33
34 #include <vector>
35 #include <list>
36 #include <climits>
37 #include <pthread.h>
38 #include <gmock/gmock.h>
39 #include <stdlib.h>
40 #include <tbm_bufmgr_int.h>
41 #include <wayland-server-protocol.h>
42 #include <tbm_log.h>
43
44 #undef TBM_DBG
45 #undef TBM_INFO
46 #undef TBM_WRN
47 #undef TBM_ERR
48 #define TBM_DBG(fmt, args...)  tbm_log_print(TBM_LOG_LEVEL_DBG, fmt, ##args)
49 #define TBM_INFO(fmt, args...) tbm_log_print(TBM_LOG_LEVEL_INFO, fmt, ##args)
50 #define TBM_WRN(fmt, args...)  tbm_log_print(TBM_LOG_LEVEL_WRN, fmt, ##args)
51 #define TBM_ERR(fmt, args...)  tbm_log_print(TBM_LOG_LEVEL_ERR, fmt, ##args)
52
53 #define TBM_UT_INFO(fmt, args...) tbm_log_print_stdout(TBM_LOG_LEVEL_INFO, fmt, ##args)
54 #define TBM_UT_WRN(fmt, args...)  tbm_log_print_stdout(TBM_LOG_LEVEL_WRN, fmt, ##args)
55 #define TBM_UT_ERR(fmt, args...)  tbm_log_print_stdout(TBM_LOG_LEVEL_ERR, fmt, ##args)
56
57 #define TBM_UT_ENTRY() \
58     TBM_INFO("--------------------------------------------- %s", typeid(*this).name())
59
60 #define TBM_UT_CHECK_FLAG(FLAG) \
61         do {\
62                 if(!(FLAG)) \
63                         TBM_UT_INFO("     [          ] not supported");\
64                         EXPECT_TRUE(0);\
65         } while(0)
66
67 #define TBM_UT_SKIP_FLAG(FLAG) \
68         do {\
69                 if((FLAG)) {\
70                         TBM_UT_INFO("     [  SKIPPED ] not supported");\
71                         EXPECT_TRUE(1);\
72                         return;\
73                 }\
74         } while(0)
75
76 #define TBM_UT_NEVER_GET_HERE() \
77         do {\
78                 TBM_UT_INFO("!!! TBM UT NEVER GET HERE !!!");\
79         } while(0)
80 #define TBM_UT_RETURN_IF_FAIL(cond) { \
81         if (!(cond)) { \
82                 TBM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
83                 return; \
84         } \
85 }
86 #define TBM_UT_RETURN_FALSE_IF_FAIL(cond) { \
87         if (!(cond)) { \
88                 TBM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
89                 return false; \
90         } \
91 }
92 #define TBM_UT_GOTO_IF_FAIL(cond, dst) { \
93         if (!(cond)) { \
94                 TBM_UT_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
95                 goto dst; \
96         } \
97 }
98
99 #define TBM_UT_DUMP_DIR            "/tmp/tbm_dump"
100 #define UT_TBM_INVALID_VALUE       -42
101 #define TBM_UT_INVALID_UINT_VALUE  99999
102 #define UT_TBM_BO_SIZE             1024
103 #define UT_TBM_SURFACE_QUEUE_SIZE  4
104
105 using ::testing::TestWithParam;
106 using ::testing::Bool;
107 using ::testing::Values;
108 using ::testing::Combine;
109
110 class TBMEnv : public TestWithParam< std::tuple<bool, bool, const char*> >
111 {
112 public:
113         void SetUp(void);
114         void TearDown(void);
115 };
116
117 class TBMBufmgr : public TBMEnv
118 {
119 public:
120         TBMBufmgr();
121         void SetUp(void);
122         void TearDown(void);
123
124         tbm_bufmgr bufmgr;
125 };
126
127 #endif // UT_H