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 TDMOutputHwc : public TDMOutput
45 TDMOutputHwc::TDMOutputHwc()
47 error = TDM_ERROR_NONE;
50 void TDMOutputHwc::SetUp(void)
55 void TDMOutputHwc::TearDown(void)
57 TDMOutput::TearDown();
60 /* tdm_hwc_window * tdm_hwc_create_window(tdm_output *output, tdm_error *error); */
61 TEST_P(TDMOutputHwc, CreateWindowFailNull)
63 TDM_UT_SKIP_FLAG(has_outputs);
65 ASSERT_EQ(NULL, tdm_hwc_create_window(NULL, &error));
66 ASSERT_NE(TDM_ERROR_NONE, error);
70 TEST_P(TDMOutputHwc, CreateWindowSuccessful)
72 TDM_UT_SKIP_FLAG(has_outputs);
74 tdm_hwc_window * hw = NULL;
76 for (int o = 0; o < output_count; o++) {
77 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
78 hw = tdm_hwc_create_window(hwc[o], &error);
79 ASSERT_EQ(TDM_ERROR_NONE, error);
80 tdm_hwc_window_destroy(hw);
82 ASSERT_EQ(NULL, tdm_hwc_create_window(outputs[o], &error));
83 ASSERT_NE(TDM_ERROR_NONE, error);
89 /* tdm_error tdm_hwc_set_client_target_buffer(tdm_output *output,
90 tbm_surface_h target_buffer, tdm_region damage,
91 tdm_hwc_window *composited_wnds, uint32_t num_wnds); */
92 /* TDOO: need to be fixed
93 TEST_P(TDMOutputHwc, SetClientTargetBufferFailNullOutput)
95 TDM_UT_SKIP_FLAG(has_outputs);
98 tbm_surface_h target_buff = CreateBufferForOutput(0);
99 error = tdm_hwc_set_client_target_buffer(NULL, target_buff, reg, NULL, 0 );
100 tbm_surface_internal_destroy(target_buff);
101 ASSERT_NE(TDM_ERROR_NONE, error);
104 TEST_P(TDMOutputHwc, SetClientTargetBufferFailNoHwc)
106 tdm_region damage = {.num_rects = 0, .rects = NULL};
108 for (int o = 0; o < output_count; o++) {
109 tbm_surface_h target_buff = CreateBufferForOutput(i);
110 ASSERT_NE(NULL, target_buff);
111 error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage, NULL, 0);
112 tbm_surface_internal_destroy(target_buff);
113 ASSERT_NE(TDM_ERROR_NONE, error);
117 TEST_P(TDMOutputHwc, SetClientTargetBufferSuccessfulSetBuff)
119 TDM_UT_SKIP_FLAG(has_outputs);
121 tdm_region damage = {.num_rects = 0, .rects = NULL};
123 for (int o = 0; o < output_count; o++) {
124 tbm_surface_h target_buff = CreateBufferForOutput(i);
125 ASSERT_NE(NULL, target_buff);
126 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
127 error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage,
129 tbm_surface_internal_destroy(target_buff);
130 ASSERT_EQ(TDM_ERROR_NONE, error);
132 error = tdm_hwc_set_client_target_buffer(outputs[o], target_buff, damage,
134 tbm_surface_internal_destroy(target_buff);
135 ASSERT_NE(TDM_ERROR_NONE, error);
140 TEST_P(TDMOutputHwc, SetClientTargetBufferSuccessfulResetBuff)
142 TDM_UT_SKIP_FLAG(has_outputs);
144 tdm_region damage = {.num_rects = 0, .rects = NULL};
146 for (int o = 0; o < output_count; o++) {
147 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
148 error = tdm_hwc_set_client_target_buffer(outputs[o], NULL, damage,
150 ASSERT_EQ(TDM_ERROR_NONE, error);
152 error = tdm_hwc_set_client_target_buffer(outputs[o], NULL, damage,
154 ASSERT_NE(TDM_ERROR_NONE, error);
160 /* tbm_surface_queue_h tdm_hwc_get_client_target_buffer_queue(tdm_output *output, tdm_error *error); */
162 TEST_P(TDMOutputHwc, GetTargetBufferQueueFailNullObject)
164 TDM_UT_SKIP_FLAG(has_outputs);
166 tbm_surface_queue_h queue = NULL;
168 queue = tdm_hwc_get_client_target_buffer_queue(NULL, &error);
169 ASSERT_NE(TDM_ERROR_NONE, error);
170 ASSERT_EQ(NULL, queue);
172 queue = tdm_hwc_get_client_target_buffer_queue(NULL, NULL);
173 ASSERT_EQ(NULL, queue);
176 TEST_P(TDMOutputHwc, GetTargetBufferQueueFainNoHwc)
178 TDM_UT_SKIP_FLAG(has_outputs);
180 tbm_surface_queue_h queue = NULL;
182 for (int o = 0; o < output_count; o++) {
183 queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
184 ASSERT_NE(TDM_ERROR_NONE, error);
185 ASSERT_EQ(NULL, queue);
190 TEST_P(TDMOutputHwc, GetTargetBufferQueueSuccessful)
192 TDM_UT_SKIP_FLAG(has_outputs);
194 tbm_surface_queue_h queue = NULL;
196 for (int o = 0; o < output_count; o++) {
197 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
198 queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
199 tbm_surface_queue_destroy(queue);
200 ASSERT_EQ(TDM_ERROR_NONE, error);
201 ASSERT_NE(NULL, queue);
203 queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], NULL);
204 tbm_surface_queue_destroy(queue);
205 ASSERT_EQ(TDM_ERROR_NONE, error);
206 ASSERT_NE(NULL, queue);
208 queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], &error);
209 ASSERT_NE(TDM_ERROR_NONE, error);
210 ASSERT_EQ(NULL, queue);
212 queue = tdm_hwc_get_client_target_buffer_queue(outputs[o], NULL);
213 ASSERT_NE(TDM_ERROR_NONE, error);
214 ASSERT_EQ(NULL, queue);
219 /* tdm_error tdm_hwc_validate(tdm_output *output, tdm_hwc_window **composited_wnds, uint32_t num_wnds,
220 uint32_t *num_types); */
221 /* TODO: fix the validate test later.
222 TEST_P(TDMOutputHwc, ValidateFailNull)
224 TDM_UT_SKIP_FLAG(has_outputs);
227 error = tdm_hwc_validate(NULL, NULL, 0, &num_types);
228 ASSERT_NE(TDM_ERROR_NONE, error);
231 error = tdm_hwc_validate(outputs[0], NULL, 0, NULL);
232 ASSERT_NE(TDM_ERROR_NONE, error);
236 TEST_P(TDMOutputHwc, ValidateFailNoHwc)
238 TDM_UT_SKIP_FLAG(has_outputs);
242 for (int o = 0; o < output_count; o++) {
243 error = tdm_hwc_validate(outputs[o], &num_types);
244 ASSERT_NE(TDM_ERROR_NONE, error);
248 TEST_P(TDMOutputHwc, ValidateSuccessful)
250 TDM_UT_SKIP_FLAG(has_outputs);
253 for (int o = 0; o < output_count; o++) {
254 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
255 error = tdm_hwc_validate(outputs[o], &num_types);
256 ASSERT_EQ(TDM_ERROR_NONE, error);
258 error = tdm_hwc_validate(outputs[o], &num_types);
259 ASSERT_NE(TDM_ERROR_NONE, error);
265 /* tdm_error tdm_hwc_get_changed_composition_types(tdm_hwc *hwc,
266 uint32_t *num_elements, tdm_hwc_window **hwc_window,
267 tdm_hwc_window_composition *composition_types); */
269 TEST_P(TDMOutputHwc, GetChangedCompositionTypesFailNull)
271 TDM_UT_SKIP_FLAG(has_outputs);
273 uint32_t num_elements;
275 error = tdm_hwc_get_changed_composition_types(NULL, &num_elements, NULL, NULL);
276 ASSERT_NE(TDM_ERROR_NONE, error);
279 error = tdm_hwc_get_changed_composition_types(outputs[0], NULL, NULL, NULL);
280 ASSERT_NE(TDM_ERROR_NONE, error);
284 TEST_P(TDMOutputHwc, GetChangedCompositionTypesFailNoHwc)
286 TDM_UT_SKIP_FLAG(has_outputs);
288 uint32_t get_num = 10;
290 for (int o = 0; o < output_count; o++) {
291 error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
292 ASSERT_NE(TDM_ERROR_NONE, error);
296 /* TODO: fix the validate test later.
297 TEST_P(TDMHwcWindow, GetChangedCompositionTypesSuccessful)
299 TDM_UT_SKIP_FLAG(has_outputs);
301 uint32_t validate_num;
302 uint32_t get_num = 0;
304 tdm_hwc_window_composition *composition_types;
305 tdm_hwc_window **hwc_wnds;
307 for (int i = 0; i < hwc_count; i++) {
308 error = tdm_hwc_window_set_composition_type(hwc_wins[o], TDM_COMPOSITION_DEVICE);
309 ASSERT_EQ(TDM_ERROR_NONE, error);
313 for (int i = 0; i < output_count; i++) {
314 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
315 error = tdm_hwc_validate(outputs[o], &validate_num);
316 ASSERT_EQ(TDM_ERROR_NONE, error);
318 error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
319 ASSERT_EQ(TDM_ERROR_NONE, error);
321 ASSERT_EQ(get_num, validate_num);
322 hwc_wnds = (tdm_hwc_window **)calloc(get_num, sizeof(tdm_hwc_window *));
323 composition_types = (tdm_hwc_window_composition *)calloc(get_num, sizeof(tdm_hwc_window_composition));
325 error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, hwc_wnds, composition_types);
328 free(composition_types);
330 ASSERT_EQ(TDM_ERROR_NONE, error);
332 error = tdm_hwc_get_changed_composition_types(outputs[o], &get_num, NULL, NULL);
333 ASSERT_NE(TDM_ERROR_NONE, error);
339 /* tdm_error tdm_hwc_accept_changes(tdm_hwc *hwc); */
341 TEST_P(TDMOutputHwc, AcceptChangesFailNull)
343 TDM_UT_SKIP_FLAG(has_outputs);
345 error = tdm_hwc_accept_changes(NULL);
346 ASSERT_NE(TDM_ERROR_NONE, error);
349 TEST_P(TDMOutputHwc, AcceptChangesFailNoHwc)
351 for (int o = 0; o < output_count; o++) {
352 error = tdm_hwc_accept_changes(outputs[o]);
353 ASSERT_NE(TDM_ERROR_NONE, error);
357 /* TODO: fix the validate test later.
358 TEST_P(TDMHwcWindow, AcceptChangesSuccessful)
360 TDM_UT_SKIP_FLAG(has_outputs);
362 uint32_t validate_num;
364 for (int i = 0; i < hwc_count; i++) {
365 error = tdm_hwc_window_set_composition_type(hwc_wins[o], TDM_COMPOSITION_DEVICE);
366 ASSERT_EQ(TDM_ERROR_NONE, error);
369 for (int i = 0; i < output_count; i++) {
370 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
371 error = tdm_hwc_validate(outputs[o], &validate_num);
372 ASSERT_EQ(TDM_ERROR_NONE, error);
374 if (validate_num > 0) {
375 error = tdm_hwc_accept_changes(outputs[o]);
376 ASSERT_EQ(TDM_ERROR_NONE, error);
383 /* tdm_hwc_get_supported_formats() */
385 TEST_P(TDMOutputHwc, GetVideoSupportedFormatsFailNull)
387 TDM_UT_SKIP_FLAG(has_outputs);
391 error = tdm_hwc_get_supported_formats(NULL, NULL, NULL);
392 ASSERT_NE(TDM_ERROR_NONE, error);
395 TEST_P(TDMOutputHwc, GetVideoSupportedFormatsSuccessful)
397 TDM_UT_SKIP_FLAG(has_outputs);
400 const tbm_format *formats;
403 for (int o = 0; o < output_count; o++) {
404 if (tc_tdm_output_is_hwc_enable(outputs[o])) {
405 error = tdm_hwc_get_supported_formats(outputs[o], &formats, &count);
406 if (error != TDM_ERROR_NOT_IMPLEMENTED) {
407 ASSERT_EQ(TDM_ERROR_NONE, error);
409 ASSERT_NE(NULL, formats);
412 error = tdm_hwc_get_supported_formats(outputs[o], &formats, &count);
413 ASSERT_NE(TDM_ERROR_NONE, error);
419 #ifdef TDM_UT_TEST_WITH_PARAMS
420 INSTANTIATE_TEST_CASE_P(TDMOutputHwcParams,
422 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
424 INSTANTIATE_TEST_CASE_P(TDMOutputHwcParams,
426 Values(TDM_DEFAULT_MODULE));