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 **************************************************************************/
33 void TDMEnv::SetUp(void)
35 const char *test_backend;
40 setenv("XDG_RUNTIME_DIR", "/run", 1);
41 setenv("TBM_DISPLAY_SERVER", "1", 1);
43 #ifdef TDM_UT_TEST_WITH_PARAMS
44 /* commit_per_vblank depends on backend. can't choose it in frontend side.
45 * this is only for testing.
47 int commit_per_vblank = ::testing::get<0>(GetParam());
48 tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, commit_per_vblank);
50 thread = ::testing::get<1>(GetParam());
51 test_backend = ::testing::get<2>(GetParam());
53 test_backend = ::testing::get<0>(GetParam());
56 tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, thread);
59 test_backend = TDM_DEFAULT_MODULE;
60 tdm_config_set_string(TDM_CONFIG_KEY_GENERAL_BACKENDS, test_backend);
62 const char *debug = getenv("TDM_UT_DEBUG_MODULE");
63 if (debug && strstr(debug, "1"))
64 tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_MODULE, "buffer,thread,event,vblank,commit,pp,capture");
67 void TDMEnv::TearDown(void)
69 unsetenv("XDG_RUNTIME_DIR");
70 unsetenv("TBM_DISPLAY_SERVER");
73 TEST_P(TDMEnv, DisplayInitDeinit)
78 dpy = tdm_display_init(&ret);
79 ASSERT_TRUE(ret == TDM_ERROR_NONE);
80 ASSERT_TRUE(dpy != NULL);
82 tdm_display_deinit(dpy);
85 TEST_P(TDMEnv, DisplayInitDeinitWithoutEnv)
92 dpy = tdm_display_init(&ret);
93 ASSERT_TRUE(ret == TDM_ERROR_OPERATION_FAILED);
94 ASSERT_TRUE(dpy == NULL);
97 TEST_P(TDMEnv, DisplayInitFewTimes)
103 for (d = 0; d < 10; d++) {
104 dpy[d] = tdm_display_init(&ret);
105 ASSERT_TRUE(ret == TDM_ERROR_NONE);
106 ASSERT_TRUE(dpy[d] != NULL);
109 for (d = 0; d < 9; d++)
110 ASSERT_TRUE(dpy[d] == dpy[d + 1]);
112 for (d = 0; d < 10; d++)
113 tdm_display_deinit(dpy[d]);
116 TEST_P(TDMEnv, DisplayInitDeinitWithTBM)
122 bufmgr = tbm_bufmgr_init(-1);
123 ASSERT_TRUE(bufmgr != NULL);
125 dpy = tdm_display_init(&ret);
126 ASSERT_TRUE(ret == TDM_ERROR_NONE);
127 ASSERT_TRUE(dpy != NULL);
129 tdm_display_deinit(dpy);
130 tbm_bufmgr_deinit(bufmgr);
133 TEST_P(TDMEnv, DisplayInitDeinitWithoutBackends)
138 TEST_P(TDMEnv, DisplayInitDeinitWrongDpyBadAddress)
143 dpy = tdm_display_init(&ret);
144 ASSERT_TRUE(ret == TDM_ERROR_NONE);
145 ASSERT_TRUE(dpy != NULL);
148 tdm_display *wrong_dpy = (tdm_display *)TDM_UT_INVALID_VALUE;
149 tdm_display_deinit(wrong_dpy);
151 }, ::testing::ExitedWithCode(0), "");
153 tdm_display_deinit(dpy);
156 TEST_P(TDMEnv, DisplayDeinitWithNULL)
158 tdm_display_deinit(NULL);
161 TEST_P(TDMEnv, DisplayDeinitRepeatWithSameDpy)
166 dpy = tdm_display_init(&ret);
167 ASSERT_TRUE(ret == TDM_ERROR_NONE);
168 ASSERT_TRUE(dpy != NULL);
171 tdm_display_deinit(dpy);
172 tdm_display_deinit(dpy);
174 }, ::testing::ExitedWithCode(0), "");
176 tdm_display_deinit(dpy);
179 #ifdef TDM_UT_TEST_WITH_PARAMS
180 INSTANTIATE_TEST_CASE_P(TDMEnvParams,
182 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
184 INSTANTIATE_TEST_CASE_P(TDMEnvParams,
186 Values(TDM_DEFAULT_MODULE));