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;
46 tdm_hwc_window *video_hwc_win;
50 TDMHwcWindow::TDMHwcWindow()
52 error = TDM_ERROR_NONE;
58 void TDMHwcWindow::SetUp(void)
60 tdm_hwc_window *hw = NULL;
64 hwc_wins = (tdm_hwc_window **)calloc(output_count * HWC_WIN_NUM, sizeof(tdm_hwc_window *));
66 //create HWC_WIN_NUM hwc_windows for each outputs
67 for (int o = 0; o < output_count; o++) {
68 if (ut_tdm_output_is_hwc_enable(outputs[o])) {
69 for (int w = 0; w < HWC_WIN_NUM; w++) {
70 hw = tdm_output_hwc_create_window(outputs[w], &error);
71 ASSERT_EQ(TDM_ERROR_NONE, error);
72 hwc_wins[hwc_count++] = hw;
76 video_hwc_win = tdm_output_hwc_create_video_window(outputs[o], &error);
81 void TDMHwcWindow::TearDown(void)
83 for (int w = 0; w < hwc_count; w++)
84 tdm_output_hwc_destroy_window(outputs[0], hwc_wins[w]);
87 tdm_output_hwc_destroy_window(outputs[0], video_hwc_win);
89 TDMOutput::TearDown();
92 /* tdm_error tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window); */
93 TEST_P(TDMHwcWindow, DestroyWindowFailNull)
95 TDM_UT_SKIP_FLAG(has_outputs);
97 for (int o = 0; o < output_count; o++) {
98 if (ut_tdm_output_is_hwc_enable(outputs[o])) {
100 error = tdm_output_hwc_destroy_window(outputs[o], NULL);
101 ASSERT_NE(TDM_ERROR_NONE, error);
106 TEST_P(TDMHwcWindow, DestroyWindowSuccessful)
108 TDM_UT_SKIP_FLAG(has_outputs);
110 tdm_hwc_window *hw = NULL;
112 for (int o = 0; o < output_count; o++) {
113 if (ut_tdm_output_is_hwc_enable(outputs[o])) {
114 hw = tdm_output_hwc_create_window(outputs[o], &error);
115 ASSERT_EQ(TDM_ERROR_NONE, error);
116 error = tdm_output_hwc_destroy_window(outputs[o], hw);
117 ASSERT_EQ(TDM_ERROR_NONE, error);
123 /* tbm_surface_queue_h tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error); */
124 TEST_P(TDMHwcWindow, GetBufferQueueFailNull)
126 TDM_UT_SKIP_FLAG(has_outputs);
128 tbm_surface_queue_h queue = NULL;
130 queue = tdm_hwc_window_get_tbm_buffer_queue(NULL, &error);
131 ASSERT_NE(TDM_ERROR_NONE, error);
132 ASSERT_EQ(NULL, queue);
134 queue = tdm_hwc_window_get_tbm_buffer_queue(NULL, NULL);
135 ASSERT_EQ(NULL, queue);
138 TEST_P(TDMHwcWindow, GetBufferQueueSuccessful)
140 TDM_UT_SKIP_FLAG(has_outputs);
142 tbm_surface_queue_h queue = NULL;
143 tdm_hwc_window_info info = { 0 };
145 info.src_config.format = TBM_FORMAT_ARGB8888;
146 info.src_config.size.h = info.src_config.size.v = 256;
147 info.src_config.pos.h = info.src_config.pos.w = 256;
148 info.dst_pos.h = info.dst_pos.w = 256;
149 info.transform = TDM_TRANSFORM_NORMAL;
151 for (int w = 0; w < hwc_count; w++) {
152 error = tdm_hwc_window_set_info(hwc_wins[w], &info);
153 ASSERT_EQ(TDM_ERROR_NONE, error);
155 queue = tdm_hwc_window_get_tbm_buffer_queue(hwc_wins[w], &error);
156 tbm_surface_queue_destroy(queue);
157 ASSERT_EQ(TDM_ERROR_NONE, error);
158 ASSERT_NE(NULL, queue);
160 queue = tdm_hwc_window_get_tbm_buffer_queue(hwc_wins[w], NULL);
161 tbm_surface_queue_destroy(queue);
162 ASSERT_NE(NULL, queue);
166 /* tdm_error tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
167 tdm_hwc_window_composition composition_type); */
168 TEST_P(TDMHwcWindow, SetCompositionTypeFailNull)
170 TDM_UT_SKIP_FLAG(has_outputs);
172 error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE);
173 ASSERT_NE(TDM_ERROR_NONE, error);
176 TEST_P(TDMHwcWindow, SetCompositionTypeSuccessful)
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_COMPOSITION_DEVICE);
182 ASSERT_EQ(TDM_ERROR_NONE, error);
183 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CLIENT);
184 ASSERT_EQ(TDM_ERROR_NONE, error);
185 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CURSOR);
186 ASSERT_EQ(TDM_ERROR_NONE, error);
190 TEST_P(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType)
192 TDM_UT_SKIP_FLAG(has_outputs);
194 for (int w = 0; w < hwc_count; w++) {
195 error = tdm_hwc_window_set_composition_type(hwc_wins[w], tdm_hwc_window_composition(TDM_COMPOSITION_NONE - 1));
196 ASSERT_NE(TDM_ERROR_NONE, error);
200 /* tdm_error tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region damage); */
201 TEST_P(TDMHwcWindow, SetBufferDamageFailNullHwcWindow)
203 TDM_UT_SKIP_FLAG(has_outputs);
205 tdm_hwc_region damage = {.num_rects = 0, .rects = NULL};
207 error = tdm_hwc_window_set_buffer_damage(NULL, damage);
208 ASSERT_NE(TDM_ERROR_NONE, error);
211 TEST_P(TDMHwcWindow, SetBufferDamageFailNullDamageRects)
213 TDM_UT_SKIP_FLAG(has_outputs);
215 tdm_hwc_region damage = {.num_rects = 1, .rects = NULL};
217 for (int w = 0; w < hwc_count; w++) {
218 error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
219 ASSERT_NE(TDM_ERROR_NONE, error);
224 TEST_P(TDMHwcWindow, SetBufferDamageSuccessful)
226 TDM_UT_SKIP_FLAG(has_outputs);
228 tdm_pos const rects[1] = {0};
229 tdm_hwc_region damage = {.num_rects = 1, .rects = rects};
231 for (int w = 0; w < hwc_count; w++) {
232 error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
233 ASSERT_EQ(TDM_ERROR_NONE, error);
238 /* tdm_error tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info); */
239 TEST_P(TDMHwcWindow, SetInfoFailNull)
241 TDM_UT_SKIP_FLAG(has_outputs);
243 tdm_hwc_window_info info = { 0 };
245 error = tdm_hwc_window_set_info(NULL, &info);
246 ASSERT_NE(TDM_ERROR_NONE, error);
249 error = tdm_hwc_window_set_info(hwc_wins[0], NULL);
250 ASSERT_NE(TDM_ERROR_NONE, error);
254 TEST_P(TDMHwcWindow, SetInfoSuccessful)
256 TDM_UT_SKIP_FLAG(has_outputs);
258 tdm_hwc_window_info info = { 0 };
260 for (int w = 0; w < hwc_count; w++) {
261 error = tdm_hwc_window_set_info(hwc_wins[w], &info);
262 ASSERT_EQ(TDM_ERROR_NONE, error);
267 /* tdm_error tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer); */
268 TEST_P(TDMHwcWindow, SetBufferFailNull)
270 TDM_UT_SKIP_FLAG(has_outputs);
272 error = tdm_hwc_window_set_buffer(NULL, NULL);
273 ASSERT_NE(TDM_ERROR_NONE, error);
276 TEST_P(TDMHwcWindow, SetBufferSuccessful)
278 TDM_UT_SKIP_FLAG(has_outputs);
280 for (int w = 0; w < hwc_count; w++) {
282 tbm_surface_h buff = tbm_surface_create(256, 256, TBM_FORMAT_ARGB8888);
285 error = tdm_hwc_window_set_buffer(hwc_wins[w], buff);
286 tbm_surface_destroy(buff);
287 ASSERT_EQ(TDM_ERROR_NONE, error);
290 error = tdm_hwc_window_set_buffer(hwc_wins[w], NULL);
291 ASSERT_EQ(TDM_ERROR_NONE, error);
295 /* tdm_error tdm_hwc_window_set_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); */
296 TEST_P(TDMHwcWindow, SetFlagsFailNull)
298 TDM_UT_SKIP_FLAG(has_outputs);
300 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
302 error = tdm_hwc_window_set_flags(NULL, flag);
303 ASSERT_NE(TDM_ERROR_NONE, error);
306 TEST_P(TDMHwcWindow, SetFlagsSuccessful)
308 TDM_UT_SKIP_FLAG(has_outputs);
310 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
312 for (int w = 0; w < hwc_count; w++) {
314 error = tdm_hwc_window_set_flags(hwc_wins[w], flag);
315 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
319 /* tdm_error tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); */
320 TEST_P(TDMHwcWindow, UnsetFlagsFailNull)
322 TDM_UT_SKIP_FLAG(has_outputs);
324 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
326 error = tdm_hwc_window_unset_flags(NULL, flag);
327 ASSERT_NE(TDM_ERROR_NONE, error);
330 TEST_P(TDMHwcWindow, UnsetFlagsSuccessful)
332 TDM_UT_SKIP_FLAG(has_outputs);
334 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
336 for (int w = 0; w < hwc_count; w++) {
338 error = tdm_hwc_window_unset_flags(hwc_wins[w], flag);
339 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
343 /* tdm_error tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
344 tdm_hwc_window_video_capability *video_capability); */
345 TEST_P(TDMHwcWindow, VideoGetCapabilityFailNull)
347 TDM_UT_SKIP_FLAG(has_outputs);
349 tdm_hwc_window_video_capability video_capability;
351 error = tdm_hwc_window_video_get_capability(NULL, &video_capability);
352 ASSERT_NE(TDM_ERROR_NONE, error);
355 error = tdm_hwc_window_video_get_capability(hwc_wins[0], NULL);
356 ASSERT_NE(TDM_ERROR_NONE, error);
361 TEST_P(TDMHwcWindow, VideoGetCapabilitySuccessful)
363 TDM_UT_SKIP_FLAG(has_outputs);
365 tdm_hwc_window_video_capability video_capability;
367 for (int w = 0; w < hwc_count; w++) {
368 /* hwc_window with TDM_COMPOSITION_CLIENT dosn't support tdm_hwc_window_video_get_capability()*/
369 error = tdm_hwc_window_video_get_capability(hwc_wins[w], &video_capability);
370 ASSERT_NE(TDM_ERROR_NONE, error);
372 if (video_hwc_win != NULL) {
373 error = tdm_hwc_window_video_get_capability(video_hwc_win, &video_capability);
374 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
380 /* tdm_hwc_window_video_get_available_properties() */
381 TEST_P(TDMHwcWindow, GetAvailablePropertiesFailNullWin)
383 TDM_UT_SKIP_FLAG(has_outputs);
385 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
386 const tdm_prop *props;
389 error = tdm_hwc_window_video_get_available_properties(NULL, &props, &count);
390 ASSERT_NE(TDM_ERROR_NONE, error);
392 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, NULL, &count);
393 ASSERT_NE(TDM_ERROR_NONE, error);
395 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, &props, NULL);
396 ASSERT_NE(TDM_ERROR_NONE, error);
399 TEST_P(TDMHwcWindow, GetAvailablePropertiesSuccess)
401 TDM_UT_SKIP_FLAG(has_outputs);
403 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
405 const tdm_prop *props;
408 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, &props, &count);
409 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
412 /* tdm_hwc_window_video_get_property() */
413 TEST_P(TDMHwcWindow, GetPropertyFailNull)
415 TDM_UT_SKIP_FLAG(has_outputs);
416 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
421 error = tdm_hwc_window_video_get_property(NULL, id, &value);
422 ASSERT_NE(TDM_ERROR_NONE, error);
424 error = tdm_hwc_window_video_get_property(video_hwc_win, id, NULL);
425 ASSERT_NE(TDM_ERROR_NONE, error);
428 TEST_P(TDMHwcWindow, GetPropertyFailWrongId)
430 TDM_UT_SKIP_FLAG(has_outputs);
431 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
436 error = tdm_hwc_window_video_get_property(video_hwc_win, id, &value);
437 ASSERT_NE(TDM_ERROR_NONE, error);
440 /* tdm_hwc_window_video_set_property() */
441 TEST_P(TDMHwcWindow, SetPropertyFailNull)
443 TDM_UT_SKIP_FLAG(has_outputs);
444 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
449 error = tdm_hwc_window_video_set_property(NULL, id, value);
450 ASSERT_NE(TDM_ERROR_NONE, error);
453 TEST_P(TDMHwcWindow, SetPropertyFailWrongId)
455 TDM_UT_SKIP_FLAG(has_outputs);
456 TDM_UT_SKIP_FLAG(video_hwc_win != NULL);
461 error = tdm_hwc_window_video_set_property(video_hwc_win, id, value);
462 ASSERT_NE(TDM_ERROR_NONE, error);
465 #ifdef TDM_UT_TEST_WITH_PARAMS
466 INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
468 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
470 INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
472 Values(TDM_DEFAULT_MODULE));