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 **************************************************************************/
35 class TDMHwcWindow : public TDMOutput
43 tdm_hwc_window **hwc_wins;
44 tdm_hwc_window *video_hwc_win;
48 TDMHwcWindow::TDMHwcWindow()
50 error = TDM_ERROR_NONE;
56 void TDMHwcWindow::SetUp(void)
58 tdm_hwc_window *hw = NULL;
62 hwc_wins = (tdm_hwc_window **)calloc(output_count * HWC_WIN_NUM, sizeof(tdm_hwc_window *));
64 //create HWC_WIN_NUM hwc_windows for each outputs
65 for (int o = 0; o < output_count; o++) {
66 if (ut_tdm_output_is_hwc_enable(outputs[o])) {
67 for (int w = 0; w < HWC_WIN_NUM; w++) {
68 hw = tdm_output_hwc_create_window(outputs[w], &error);
69 ASSERT_EQ(TDM_ERROR_NONE, error);
70 hwc_wins[hwc_count++] = hw;
74 video_hwc_win = tdm_output_hwc_create_video_window(outputs[o], &error);
79 void TDMHwcWindow::TearDown(void)
81 for (int w = 0; w < hwc_count; w++)
82 tdm_output_hwc_destroy_window(outputs[0], hwc_wins[w]);
85 tdm_output_hwc_destroy_window(outputs[0], video_hwc_win);
87 TDMOutput::TearDown();
90 /* tdm_error tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window); */
91 TEST_P(TDMHwcWindow, DestroyWindowFailNull)
93 TDM_UT_SKIP_FLAG(has_outputs);
95 for (int o = 0; o < output_count; o++) {
96 if (ut_tdm_output_is_hwc_enable(outputs[o])) {
98 error = tdm_output_hwc_destroy_window(outputs[o], NULL);
99 ASSERT_NE(TDM_ERROR_NONE, error);
104 TEST_P(TDMHwcWindow, DestroyWindowSuccessful)
106 TDM_UT_SKIP_FLAG(has_outputs);
108 tdm_hwc_window *hw = NULL;
110 for (int o = 0; o < output_count; o++) {
111 if (ut_tdm_output_is_hwc_enable(outputs[o])) {
112 hw = tdm_output_hwc_create_window(outputs[o], &error);
113 ASSERT_EQ(TDM_ERROR_NONE, error);
114 error = tdm_output_hwc_destroy_window(outputs[o], hw);
115 ASSERT_EQ(TDM_ERROR_NONE, error);
121 /* tbm_surface_queue_h tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error); */
122 TEST_P(TDMHwcWindow, GetBufferQueueFailNull)
124 TDM_UT_SKIP_FLAG(has_outputs);
126 tbm_surface_queue_h queue = NULL;
128 queue = tdm_hwc_window_get_tbm_buffer_queue(NULL, &error);
129 ASSERT_NE(TDM_ERROR_NONE, error);
130 ASSERT_EQ(NULL, queue);
132 queue = tdm_hwc_window_get_tbm_buffer_queue(NULL, NULL);
133 ASSERT_EQ(NULL, queue);
136 TEST_P(TDMHwcWindow, GetBufferQueueSuccessful)
138 TDM_UT_SKIP_FLAG(has_outputs);
140 tbm_surface_queue_h queue = NULL;
141 tdm_hwc_window_info info = { 0 };
143 info.src_config.format = TBM_FORMAT_ARGB8888;
144 info.src_config.size.h = info.src_config.size.v = 256;
145 info.src_config.pos.h = info.src_config.pos.w = 256;
146 info.dst_pos.h = info.dst_pos.w = 256;
147 info.transform = TDM_TRANSFORM_NORMAL;
149 for (int w = 0; w < hwc_count; w++) {
150 error = tdm_hwc_window_set_info(hwc_wins[w], &info);
151 ASSERT_EQ(TDM_ERROR_NONE, error);
153 queue = tdm_hwc_window_get_tbm_buffer_queue(hwc_wins[w], &error);
154 tbm_surface_queue_destroy(queue);
155 ASSERT_EQ(TDM_ERROR_NONE, error);
156 ASSERT_NE(NULL, queue);
158 queue = tdm_hwc_window_get_tbm_buffer_queue(hwc_wins[w], NULL);
159 tbm_surface_queue_destroy(queue);
160 ASSERT_NE(NULL, queue);
164 /* tdm_error tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
165 tdm_hwc_window_composition composition_type); */
166 TEST_P(TDMHwcWindow, SetCompositionTypeFailNull)
168 TDM_UT_SKIP_FLAG(has_outputs);
170 error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE);
171 ASSERT_NE(TDM_ERROR_NONE, error);
174 TEST_P(TDMHwcWindow, SetCompositionTypeSuccessful)
176 TDM_UT_SKIP_FLAG(has_outputs);
178 for (int w = 0; w < hwc_count; w++) {
179 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_DEVICE);
180 ASSERT_EQ(TDM_ERROR_NONE, error);
181 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CLIENT);
182 ASSERT_EQ(TDM_ERROR_NONE, error);
183 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CURSOR);
184 ASSERT_EQ(TDM_ERROR_NONE, error);
188 TEST_P(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType)
190 TDM_UT_SKIP_FLAG(has_outputs);
192 for (int w = 0; w < hwc_count; w++) {
193 error = tdm_hwc_window_set_composition_type(hwc_wins[w], tdm_hwc_window_composition(TDM_COMPOSITION_NONE - 1));
194 ASSERT_NE(TDM_ERROR_NONE, error);
198 /* tdm_error tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region damage); */
199 TEST_P(TDMHwcWindow, SetBufferDamageFailNullHwcWindow)
201 TDM_UT_SKIP_FLAG(has_outputs);
203 tdm_hwc_region damage = {.num_rects = 0, .rects = NULL};
205 error = tdm_hwc_window_set_buffer_damage(NULL, damage);
206 ASSERT_NE(TDM_ERROR_NONE, error);
209 TEST_P(TDMHwcWindow, SetBufferDamageFailNullDamageRects)
211 TDM_UT_SKIP_FLAG(has_outputs);
213 tdm_hwc_region damage = {.num_rects = 1, .rects = NULL};
215 for (int w = 0; w < hwc_count; w++) {
216 error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
217 ASSERT_NE(TDM_ERROR_NONE, error);
222 TEST_P(TDMHwcWindow, SetBufferDamageSuccessful)
224 TDM_UT_SKIP_FLAG(has_outputs);
226 tdm_pos const rects[1] = {0};
227 tdm_hwc_region damage = {.num_rects = 1, .rects = rects};
229 for (int w = 0; w < hwc_count; w++) {
230 error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
231 ASSERT_EQ(TDM_ERROR_NONE, error);
236 /* tdm_error tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info); */
237 TEST_P(TDMHwcWindow, SetInfoFailNull)
239 TDM_UT_SKIP_FLAG(has_outputs);
241 tdm_hwc_window_info info = { 0 };
243 error = tdm_hwc_window_set_info(NULL, &info);
244 ASSERT_NE(TDM_ERROR_NONE, error);
247 error = tdm_hwc_window_set_info(hwc_wins[0], NULL);
248 ASSERT_NE(TDM_ERROR_NONE, error);
252 TEST_P(TDMHwcWindow, SetInfoSuccessful)
254 TDM_UT_SKIP_FLAG(has_outputs);
256 tdm_hwc_window_info info = { 0 };
258 for (int w = 0; w < hwc_count; w++) {
259 error = tdm_hwc_window_set_info(hwc_wins[w], &info);
260 ASSERT_EQ(TDM_ERROR_NONE, error);
265 /* tdm_error tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer); */
266 TEST_P(TDMHwcWindow, SetBufferFailNull)
268 TDM_UT_SKIP_FLAG(has_outputs);
270 error = tdm_hwc_window_set_buffer(NULL, NULL);
271 ASSERT_NE(TDM_ERROR_NONE, error);
274 TEST_P(TDMHwcWindow, SetBufferSuccessful)
276 TDM_UT_SKIP_FLAG(has_outputs);
278 for (int w = 0; w < hwc_count; w++) {
280 tbm_surface_h buff = tbm_surface_create(256, 256, TBM_FORMAT_ARGB8888);
283 error = tdm_hwc_window_set_buffer(hwc_wins[w], buff);
284 tbm_surface_destroy(buff);
285 ASSERT_EQ(TDM_ERROR_NONE, error);
288 error = tdm_hwc_window_set_buffer(hwc_wins[w], NULL);
289 ASSERT_EQ(TDM_ERROR_NONE, error);
293 /* tdm_error tdm_hwc_window_set_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); */
294 TEST_P(TDMHwcWindow, SetFlagsFailNull)
296 TDM_UT_SKIP_FLAG(has_outputs);
298 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
300 error = tdm_hwc_window_set_flags(NULL, flag);
301 ASSERT_NE(TDM_ERROR_NONE, error);
304 TEST_P(TDMHwcWindow, SetFlagsSuccessful)
306 TDM_UT_SKIP_FLAG(has_outputs);
308 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
310 for (int w = 0; w < hwc_count; w++) {
312 error = tdm_hwc_window_set_flags(hwc_wins[w], flag);
313 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
317 /* tdm_error tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); */
318 TEST_P(TDMHwcWindow, UnsetFlagsFailNull)
320 TDM_UT_SKIP_FLAG(has_outputs);
322 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
324 error = tdm_hwc_window_unset_flags(NULL, flag);
325 ASSERT_NE(TDM_ERROR_NONE, error);
328 TEST_P(TDMHwcWindow, UnsetFlagsSuccessful)
330 TDM_UT_SKIP_FLAG(has_outputs);
332 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
334 for (int w = 0; w < hwc_count; w++) {
336 error = tdm_hwc_window_unset_flags(hwc_wins[w], flag);
337 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
341 /* tdm_error tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
342 tdm_hwc_window_video_capability *video_capability); */
343 TEST_P(TDMHwcWindow, VideoGetCapabilityFailNull)
345 TDM_UT_SKIP_FLAG(has_outputs);
347 tdm_hwc_window_video_capability video_capability;
349 error = tdm_hwc_window_video_get_capability(NULL, &video_capability);
350 ASSERT_NE(TDM_ERROR_NONE, error);
353 error = tdm_hwc_window_video_get_capability(hwc_wins[0], NULL);
354 ASSERT_NE(TDM_ERROR_NONE, error);
359 TEST_P(TDMHwcWindow, VideoGetCapabilitySuccessful)
361 TDM_UT_SKIP_FLAG(has_outputs);
363 tdm_hwc_window_video_capability video_capability;
365 for (int w = 0; w < hwc_count; w++) {
366 /* hwc_window with TDM_COMPOSITION_CLIENT dosn't support tdm_hwc_window_video_get_capability()*/
367 error = tdm_hwc_window_video_get_capability(hwc_wins[w], &video_capability);
368 ASSERT_NE(TDM_ERROR_NONE, error);
370 if (video_hwc_win != NULL) {
371 error = tdm_hwc_window_video_get_capability(video_hwc_win, &video_capability);
372 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
378 /* tdm_hwc_window_video_get_available_properties() */
379 TEST_P(TDMHwcWindow, GetAvailablePropertiesFailNullWin)
381 TDM_UT_SKIP_FLAG(has_outputs);
383 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
384 const tdm_prop *props;
387 error = tdm_hwc_window_video_get_available_properties(NULL, &props, &count);
388 ASSERT_NE(TDM_ERROR_NONE, error);
390 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, NULL, &count);
391 ASSERT_NE(TDM_ERROR_NONE, error);
393 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, &props, NULL);
394 ASSERT_NE(TDM_ERROR_NONE, error);
397 TEST_P(TDMHwcWindow, GetAvailablePropertiesSuccess)
399 TDM_UT_SKIP_FLAG(has_outputs);
401 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
403 const tdm_prop *props;
406 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, &props, &count);
407 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
410 /* tdm_hwc_window_video_get_property() */
411 TEST_P(TDMHwcWindow, GetPropertyFailNull)
413 TDM_UT_SKIP_FLAG(has_outputs);
414 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
419 error = tdm_hwc_window_video_get_property(NULL, id, &value);
420 ASSERT_NE(TDM_ERROR_NONE, error);
422 error = tdm_hwc_window_video_get_property(video_hwc_win, id, NULL);
423 ASSERT_NE(TDM_ERROR_NONE, error);
426 TEST_P(TDMHwcWindow, GetPropertyFailWrongId)
428 TDM_UT_SKIP_FLAG(has_outputs);
429 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
434 error = tdm_hwc_window_video_get_property(video_hwc_win, id, &value);
435 ASSERT_NE(TDM_ERROR_NONE, error);
438 /* tdm_hwc_window_video_set_property() */
439 TEST_P(TDMHwcWindow, SetPropertyFailNull)
441 TDM_UT_SKIP_FLAG(has_outputs);
442 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
447 error = tdm_hwc_window_video_set_property(NULL, id, value);
448 ASSERT_NE(TDM_ERROR_NONE, error);
451 TEST_P(TDMHwcWindow, SetPropertyFailWrongId)
453 TDM_UT_SKIP_FLAG(has_outputs);
454 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
459 error = tdm_hwc_window_video_set_property(video_hwc_win, id, value);
460 ASSERT_NE(TDM_ERROR_NONE, error);
463 #ifdef TDM_UT_TEST_WITH_PARAMS
464 INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
466 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
468 INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
470 Values(TDM_DEFAULT_MODULE));