1 /**************************************************************************
3 * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
5 * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
6 * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
7 * Contact: Roman Marchenko <r.marchenko@samsung.com>
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:
17 * The above copyright notice and this permission notice (including the
18 * next paragraph) shall be included in all copies or substantial portions
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.
29 **************************************************************************/
34 * 1. Test When there is no bufmgr.
37 TBMBufmgr::TBMBufmgr()
42 void TBMBufmgr::SetUp()
46 bufmgr = tbm_bufmgr_init(-1);
47 ASSERT_TRUE(bufmgr != NULL);
50 void TBMBufmgr::TearDown()
52 tbm_bufmgr_deinit(bufmgr);
54 ASSERT_TRUE(tbm_bufmgr_debug_get_ref_count() == 0);
59 static int memory_for_invalid_param;
60 static tbm_bufmgr invalid_bufmgr = (tbm_bufmgr)&memory_for_invalid_param;
62 /* tbm_bufmgr_get_capability() */
63 TEST_F(TBMBufmgr, BufmgrGetCapability)
65 unsigned int capability;
67 capability = tbm_bufmgr_get_capability(bufmgr);
68 EXPECT_NE(capability, TBM_BUFMGR_CAPABILITY_NONE);
69 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
72 TEST_F(TBMBufmgr, BufmgrGetCapabilityWithNullBufmgr)
74 unsigned int capability;
76 capability = tbm_bufmgr_get_capability(NULL);
77 EXPECT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE);
78 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
81 TEST_F(TBMBufmgr, BufmgrGetCapabilityWithWrongBufmgr)
83 tbm_bufmgr bufmgr = (tbm_bufmgr)UT_TBM_INVALID_VALUE;
84 unsigned int capability;
86 capability = tbm_bufmgr_get_capability(bufmgr);
87 EXPECT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE);
88 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
91 /* tbm_bufmgr_bind_native_display() */
92 #if 0 // TDDO:: fix the crash...
93 TEST_F(TBMBufmgr, BufmgrBindNativeDisplay)
96 void *native_display = (void *)UT_TBM_INVALID_VALUE;
98 ret = tbm_bufmgr_bind_native_display(bufmgr, native_display);
102 TEST_F(TBMBufmgr, BufmgrBindNativeDisplayWithNullBufmgr)
105 void *native_display = (void *)UT_TBM_INVALID_VALUE;
107 ret = tbm_bufmgr_bind_native_display(NULL, native_display);
111 TEST_F(TBMBufmgr, BufmgrBindNativeDisplayWithWrongBufmgr)
114 void *native_display = (void *)UT_TBM_INVALID_VALUE;
116 ret = tbm_bufmgr_bind_native_display(NULL, native_display);
121 /* tbm_bufmgr_set_bo_lock_type() */
122 TEST_F(TBMBufmgr, BufmgrSetBoLockType)
126 ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_NEVER);
128 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
129 ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_ONCE);
131 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
132 ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS);
134 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
137 TEST_F(TBMBufmgr, BufmgrSetBoLockTypeWithBufmgrParamTest)
141 ret = tbm_bufmgr_set_bo_lock_type(NULL, TBM_BUFMGR_BO_LOCK_TYPE_NEVER);
143 ret = tbm_bufmgr_set_bo_lock_type(invalid_bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_NEVER);
145 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
149 /* tbm_bufmgr_debug_show() */
150 /* tbm_bufmgr_debug_tbm_info_get() */
151 /* tbm_bufmgr_debug_trace() */
152 /* tbm_bufmgr_debug_dump_all() */
153 /* tbm_bufmgr_debug_queue_dump() */
154 /* tbm_bufmgr_debug_dump_set_scale() */
155 /* tbm_bufmgr_debug_get_ref_count */
157 INSTANTIATE_TEST_CASE_P(TBMBufmgrParams,
159 Combine(Bool(), Bool(), Values("none")));