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 **************************************************************************/
37 class TDMHwcWindow : public TDMOutput
45 tdm_hwc_window **hwc_wins;
49 TDMHwcWindow::TDMHwcWindow()
51 error = TDM_ERROR_NONE;
57 void TDMHwcWindow::SetUp(void)
59 tdm_hwc_window *hw = NULL;
63 hwc_wins = (tdm_hwc_window **)calloc(output_count * HWC_WIN_NUM, sizeof(tdm_hwc_window *));
65 //create HWC_WIN_NUM hwc_windows for each outputs
66 for (int o = 0; o < output_count; o++) {
67 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
68 for (int w = 0; w < HWC_WIN_NUM; w++) {
69 hw = tdm_hwc_create_window(outputs[w], &error);
70 ASSERT_EQ(TDM_ERROR_NONE, error);
71 hwc_wins[hwc_count++] = hw;
77 void TDMHwcWindow::TearDown(void)
79 for (int w = 0; w < hwc_count; w++)
80 tdm_hwc_window_destroy(hwc_wins[w]);
82 TDMOutput::TearDown();
85 /* void tdm_hwc_window_destroy(tdm_hwc_window *hwc_window); */
87 TEST_P(TDMHwcWindow, DestroyWindowFailNull)
89 tdm_hwc_window_destroy(NULL);
92 TEST_P(TDMHwcWindow, DestroyWindowSuccessful)
94 TDM_UT_SKIP_FLAG(has_outputs);
96 tdm_hwc_window *hw = NULL;
98 for (int o = 0; o < output_count; o++) {
99 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
100 hw = tdm_hwc_create_window(outputs[o], &error);
101 ASSERT_EQ(TDM_ERROR_NONE, error);
102 error = tdm_hwc_window_destroy(outputs[o], hw);
103 ASSERT_EQ(TDM_ERROR_NONE, error);
109 /* tbm_surface_queue_h tdm_hwc_window_get_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error); */
110 TEST_P(TDMHwcWindow, GetBufferQueueFailNull)
112 TDM_UT_SKIP_FLAG(has_outputs);
114 tbm_surface_queue_h queue = NULL;
116 queue = tdm_hwc_window_get_buffer_queue(NULL, &error);
117 ASSERT_NE(TDM_ERROR_NONE, error);
118 ASSERT_EQ(NULL, queue);
120 queue = tdm_hwc_window_get_buffer_queue(NULL, NULL);
121 ASSERT_EQ(NULL, queue);
124 TEST_P(TDMHwcWindow, GetBufferQueueSuccessful)
126 TDM_UT_SKIP_FLAG(has_outputs);
128 tbm_surface_queue_h queue = NULL;
129 tdm_hwc_window_info info = { 0 };
131 info.src_config.format = TBM_FORMAT_ARGB8888;
132 info.src_config.size.h = info.src_config.size.v = 256;
133 info.src_config.pos.h = info.src_config.pos.w = 256;
134 info.dst_pos.h = info.dst_pos.w = 256;
135 info.transform = TDM_TRANSFORM_NORMAL;
137 for (int w = 0; w < hwc_count; w++) {
138 error = tdm_hwc_window_set_info(hwc_wins[w], &info);
139 ASSERT_EQ(TDM_ERROR_NONE, error);
141 queue = tdm_hwc_window_get_buffer_queue(hwc_wins[w], &error);
142 tbm_surface_queue_destroy(queue);
143 ASSERT_EQ(TDM_ERROR_NONE, error);
144 ASSERT_NE(NULL, queue);
146 queue = tdm_hwc_window_get_buffer_queue(hwc_wins[w], NULL);
147 tbm_surface_queue_destroy(queue);
148 ASSERT_NE(NULL, queue);
152 /* tdm_error tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
153 tdm_hwc_window_composition composition_type); */
154 TEST_P(TDMHwcWindow, SetCompositionTypeFailNull)
156 TDM_UT_SKIP_FLAG(has_outputs);
158 error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE);
159 ASSERT_NE(TDM_ERROR_NONE, error);
162 TEST_P(TDMHwcWindow, SetCompositionTypeSuccessful)
164 TDM_UT_SKIP_FLAG(has_outputs);
166 for (int w = 0; w < hwc_count; w++) {
167 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_DEVICE);
168 ASSERT_EQ(TDM_ERROR_NONE, error);
169 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CLIENT);
170 ASSERT_EQ(TDM_ERROR_NONE, error);
171 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CURSOR);
172 ASSERT_EQ(TDM_ERROR_NONE, error);
176 TEST_P(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType)
178 TDM_UT_SKIP_FLAG(has_outputs);
180 for (int w = 0; w < hwc_count; w++) {
181 error = tdm_hwc_window_set_composition_type(hwc_wins[w], tdm_hwc_window_composition(TDM_COMPOSITION_NONE - 1));
182 ASSERT_NE(TDM_ERROR_NONE, error);
186 /* tdm_error tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_region damage); */
187 TEST_P(TDMHwcWindow, SetBufferDamageFailNullHwcWindow)
189 TDM_UT_SKIP_FLAG(has_outputs);
191 tdm_region damage = {.num_rects = 0, .rects = NULL};
193 error = tdm_hwc_window_set_buffer_damage(NULL, damage);
194 ASSERT_NE(TDM_ERROR_NONE, error);
197 TEST_P(TDMHwcWindow, SetBufferDamageFailNullDamageRects)
199 TDM_UT_SKIP_FLAG(has_outputs);
201 tdm_region damage = {.num_rects = 1, .rects = NULL};
203 for (int w = 0; w < hwc_count; w++) {
204 error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
205 ASSERT_NE(TDM_ERROR_NONE, error);
210 TEST_P(TDMHwcWindow, SetBufferDamageSuccessful)
212 TDM_UT_SKIP_FLAG(has_outputs);
214 tdm_pos const rects[1] = {0};
215 tdm_region damage = {.num_rects = 1, .rects = rects};
217 for (int w = 0; w < hwc_count; w++) {
218 error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
219 ASSERT_EQ(TDM_ERROR_NONE, error);
224 /* tdm_error tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info); */
225 TEST_P(TDMHwcWindow, SetInfoFailNull)
227 TDM_UT_SKIP_FLAG(has_outputs);
229 tdm_hwc_window_info info = { 0 };
231 error = tdm_hwc_window_set_info(NULL, &info);
232 ASSERT_NE(TDM_ERROR_NONE, error);
235 error = tdm_hwc_window_set_info(hwc_wins[0], NULL);
236 ASSERT_NE(TDM_ERROR_NONE, error);
240 TEST_P(TDMHwcWindow, SetInfoSuccessful)
242 TDM_UT_SKIP_FLAG(has_outputs);
244 tdm_hwc_window_info info = { 0 };
246 for (int w = 0; w < hwc_count; w++) {
247 error = tdm_hwc_window_set_info(hwc_wins[w], &info);
248 ASSERT_EQ(TDM_ERROR_NONE, error);
253 /* tdm_error tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer); */
254 TEST_P(TDMHwcWindow, SetBufferFailNull)
256 TDM_UT_SKIP_FLAG(has_outputs);
258 error = tdm_hwc_window_set_buffer(NULL, NULL);
259 ASSERT_NE(TDM_ERROR_NONE, error);
262 TEST_P(TDMHwcWindow, SetBufferSuccessful)
264 TDM_UT_SKIP_FLAG(has_outputs);
266 for (int w = 0; w < hwc_count; w++) {
268 tbm_surface_h buff = tbm_surface_create(256, 256, TBM_FORMAT_ARGB8888);
271 error = tdm_hwc_window_set_buffer(hwc_wins[w], buff);
272 tbm_surface_destroy(buff);
273 ASSERT_EQ(TDM_ERROR_NONE, error);
276 error = tdm_hwc_window_set_buffer(hwc_wins[w], NULL);
277 ASSERT_EQ(TDM_ERROR_NONE, error);
281 /* tdm_hwc_get_available_properties() */
283 TEST_P(TDMHwcWindow, GetAvailablePropertiesFailNullWin)
285 TDM_UT_SKIP_FLAG(has_outputs);
287 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
288 const tdm_prop *props;
291 error = tdm_hwc_get_available_properties(NULL, &props, &count);
292 ASSERT_NE(TDM_ERROR_NONE, error);
294 error = tdm_hwc_get_available_properties(video_hwc_win, NULL, &count);
295 ASSERT_NE(TDM_ERROR_NONE, error);
297 error = tdm_hwc_get_available_properties(video_hwc_win, &props, NULL);
298 ASSERT_NE(TDM_ERROR_NONE, error);
301 TEST_P(TDMHwcWindow, GetAvailablePropertiesSuccess)
303 TDM_UT_SKIP_FLAG(has_outputs);
305 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
307 const tdm_prop *props;
310 error = tdm_hwc_get_available_properties(video_hwc_win, &props, &count);
311 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
315 /* tdm_hwc_window_get_property() */
316 TEST_P(TDMHwcWindow, GetPropertyFailNull)
318 TDM_UT_SKIP_FLAG(has_outputs);
319 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
324 error = tdm_hwc_window_get_property(NULL, id, &value);
325 ASSERT_NE(TDM_ERROR_NONE, error);
327 error = tdm_hwc_window_get_property(video_hwc_win, id, NULL);
328 ASSERT_NE(TDM_ERROR_NONE, error);
331 TEST_P(TDMHwcWindow, GetPropertyFailWrongId)
333 TDM_UT_SKIP_FLAG(has_outputs);
334 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
339 error = tdm_hwc_window_get_property(video_hwc_win, id, &value);
340 ASSERT_NE(TDM_ERROR_NONE, error);
343 /* tdm_hwc_window_set_property() */
344 TEST_P(TDMHwcWindow, SetPropertyFailNull)
346 TDM_UT_SKIP_FLAG(has_outputs);
347 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
352 error = tdm_hwc_window_set_property(NULL, id, value);
353 ASSERT_NE(TDM_ERROR_NONE, error);
356 TEST_P(TDMHwcWindow, SetPropertyFailWrongId)
358 TDM_UT_SKIP_FLAG(has_outputs);
359 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
364 error = tdm_hwc_window_set_property(video_hwc_win, id, value);
365 ASSERT_NE(TDM_ERROR_NONE, error);
368 #ifdef TDM_UT_TEST_WITH_PARAMS
369 INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
371 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
373 INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
375 Values(TDM_DEFAULT_MODULE));