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 /* tbm_bufmgr_get_capability() */
60 TEST_F(TBMBufmgr, BufmgrGetCapability)
62 unsigned int capability;
64 capability = tbm_bufmgr_get_capability(bufmgr);
65 EXPECT_NE(capability, TBM_BUFMGR_CAPABILITY_NONE);
66 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
69 TEST_F(TBMBufmgr, BufmgrGetCapabilityWithNullBufmgr)
71 unsigned int capability;
73 capability = tbm_bufmgr_get_capability(NULL);
74 EXPECT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE);
75 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
78 TEST_F(TBMBufmgr, BufmgrGetCapabilityWithWrongBufmgr)
80 tbm_bufmgr bufmgr = (tbm_bufmgr)UT_TBM_INVALID_VALUE;
81 unsigned int capability;
83 capability = tbm_bufmgr_get_capability(bufmgr);
84 EXPECT_EQ(capability, TBM_BUFMGR_CAPABILITY_NONE);
85 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
88 /* tbm_bufmgr_bind_native_display() */
89 #if 0 // TDDO:: fix the crash...
90 TEST_F(TBMBufmgr, BufmgrBindNativeDisplay)
93 void *native_display = (void *)UT_TBM_INVALID_VALUE;
95 ret = tbm_bufmgr_bind_native_display(bufmgr, native_display);
99 TEST_F(TBMBufmgr, BufmgrBindNativeDisplayWithNullBufmgr)
102 void *native_display = (void *)UT_TBM_INVALID_VALUE;
104 ret = tbm_bufmgr_bind_native_display(NULL, native_display);
108 TEST_F(TBMBufmgr, BufmgrBindNativeDisplayWithWrongBufmgr)
111 void *native_display = (void *)UT_TBM_INVALID_VALUE;
113 ret = tbm_bufmgr_bind_native_display(NULL, native_display);
118 /* tbm_bufmgr_set_bo_lock_type() */
119 TEST_F(TBMBufmgr, BufmgrSetBoLockType)
123 ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_NEVER);
125 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
126 ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_ONCE);
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_ALWAYS);
131 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE));
134 TEST_F(TBMBufmgr, BufmgrSetBoLockTypeWithBufmgrParamTest)
136 tbm_bufmgr invalid_bufmgr;
139 ret = tbm_bufmgr_set_bo_lock_type(NULL, TBM_BUFMGR_BO_LOCK_TYPE_NEVER);
141 invalid_bufmgr = (tbm_bufmgr)UT_TBM_INVALID_VALUE;
142 ret = tbm_bufmgr_set_bo_lock_type(invalid_bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_NEVER);
144 EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER));
148 /* tbm_bufmgr_debug_show() */
149 /* tbm_bufmgr_debug_tbm_info_get() */
150 /* tbm_bufmgr_debug_trace() */
151 /* tbm_bufmgr_debug_dump_all() */
152 /* tbm_bufmgr_debug_queue_dump() */
153 /* tbm_bufmgr_debug_dump_set_scale() */
154 /* tbm_bufmgr_debug_get_ref_count */
156 INSTANTIATE_TEST_CASE_P(TBMBufmgrParams,
158 Combine(Bool(), Bool(), Values("none")));