use gmock intead of gtest
[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
43 #define TBM_UT_ENTRY() \
44     TBM_INFO("--------------------------------------------- %s", typeid(*this).name())
45
46 #define TBM_UT_CHECK_FLAG(FLAG) \
47         do {\
48                 if(!(FLAG)) \
49                         TBM_INFO("[          ] not supported");\
50         } while(0)
51
52 #define TBM_UT_SKIP_FLAG(FLAG) \
53         do {\
54                 if(!(FLAG)) {\
55                         TBM_INFO("[  SKIPPED ] not supported");\
56                         return;\
57                 }\
58         } while(0)
59
60 #define TBM_UT_NEVER_GET_HERE() \
61         do {\
62                 TBM_INFO("!!! TBM UT NEVER GET HERE !!!");\
63         } while(0)
64 #define TBM_UT_RETURN_IF_FAIL(cond) { \
65         if (!(cond)) { \
66                 TBM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
67                 return; \
68         } \
69 }
70 #define TBM_UT_RETURN_FALSE_IF_FAIL(cond) { \
71         if (!(cond)) { \
72                 TBM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
73                 return false; \
74         } \
75 }
76 #define TBM_UT_GOTO_IF_FAIL(cond, dst) { \
77         if (!(cond)) { \
78                 TBM_ERR("[%s,%d] '%s' failed", __FUNCTION__, __LINE__, #cond); \
79                 goto dst; \
80         } \
81 }
82
83 #define TBM_UT_DUMP_DIR            "/tmp/tbm_dump"
84 #define UT_TBM_INVALID_VALUE       -42
85 #define TBM_UT_INVALID_UINT_VALUE  99999
86 #define UT_TBM_BO_SIZE             1024
87 #define UT_TBM_SURFACE_QUEUE_SIZE  4
88
89 using ::testing::TestWithParam;
90 using ::testing::Bool;
91 using ::testing::Values;
92 using ::testing::Combine;
93
94 class TBMEnv : public TestWithParam< std::tuple<bool, bool, const char*> >
95 {
96 public:
97         void SetUp(void);
98         void TearDown(void);
99 };
100
101 class TBMBufmgr : public TBMEnv
102 {
103 public:
104         TBMBufmgr();
105         void SetUp(void);
106         void TearDown(void);
107
108         tbm_bufmgr bufmgr;
109 };
110
111 #endif // UT_H