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 TDMHwcWindow::TDMHwcWindow()
49 void TDMHwcWindow::SetUp(void)
54 void TDMHwcWindow::TearDown(void)
56 TDMOutput::TearDown();
59 /* void tdm_hwc_window_destroy() */
60 TEST_P(TDMHwcWindow, DestroyWindowFailNull)
62 tdm_hwc_window_destroy(NULL);
65 TEST_P(TDMHwcWindow, DestroyWindowSuccessful)
67 TDM_UT_SKIP_FLAG(has_outputs);
70 tdm_error error = TDM_ERROR_NONE;
71 tdm_hwc_window *hw = NULL;
73 for (int o = 0; o < output_count; o++) {
74 hwc = tdm_output_get_hwc(hwc, &error);
76 hw = tdm_hwc_create_window(hwc, &error);
77 ASSERT_EQ(TDM_ERROR_NONE, error);
79 tdm_hwc_window_destroy(hw);
84 /* tbm_surface_queue_h tdm_hwc_window_get_buffer_queue() */
85 TEST_P(TDMHwcWindow, GetBufferQueueFailNull)
87 TDM_UT_SKIP_FLAG(has_outputs);
89 tdm_error error = TDM_ERROR_NONE;
90 tbm_surface_queue_h queue = NULL;
92 queue = tdm_hwc_window_get_buffer_queue(NULL, &error);
93 ASSERT_NE(TDM_ERROR_NONE, error);
94 ASSERT_EQ(NULL, queue);
96 queue = tdm_hwc_window_get_buffer_queue(NULL, NULL);
97 ASSERT_EQ(NULL, queue);
100 TEST_P(TDMHwcWindow, GetBufferQueueSuccessful)
102 TDM_UT_SKIP_FLAG(has_outputs);
105 tdm_hwc_window *hwc_wins[HWC_WIN_NUM];
106 tdm_error error = TDM_ERROR_NONE;
108 tbm_surface_queue_h queue = NULL;
109 tdm_hwc_window_info info = { 0 };
111 for (int o = 0; o < output_count; o++) {
112 hwc = tdm_output_get_hwc(hwc, &error);
114 for (w = 0; w < HWC_WIN_NUM; w++) {
115 hwc_wins[w] = tdm_hwc_create_window(hwc, &error);
116 ASSERT_NE(NULL, hwc_wins[w]);
119 info.src_config.format = TBM_FORMAT_ARGB8888;
120 info.src_config.size.h = info.src_config.size.v = 256;
121 info.src_config.pos.h = info.src_config.pos.w = 256;
122 info.dst_pos.h = info.dst_pos.w = 256;
123 info.transform = TDM_TRANSFORM_NORMAL;
125 for (w = 0; w < HWC_WIN_NUM; w++) {
126 error = tdm_hwc_window_set_info(hwc_wins[w], &info);
127 ASSERT_EQ(TDM_ERROR_NONE, error);
129 queue = tdm_hwc_window_get_buffer_queue(hwc_wins[w], &error);
130 tbm_surface_queue_destroy(queue);
131 ASSERT_EQ(TDM_ERROR_NONE, error);
132 ASSERT_NE(NULL, queue);
134 queue = tdm_hwc_window_get_buffer_queue(hwc_wins[w], NULL);
135 tbm_surface_queue_destroy(queue);
136 ASSERT_NE(NULL, queue);
139 for (w = 0; w < HWC_WIN_NUM; w++)
140 tdm_hwc_window_destroy(hwc_wins[w]);
145 /* tdm_error tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
146 tdm_hwc_window_composition composition_type); */
147 TEST_P(TDMHwcWindow, SetCompositionTypeFailNull)
149 TDM_UT_SKIP_FLAG(has_outputs);
151 tdm_error error = TDM_ERROR_NONE;
153 error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE);
154 ASSERT_NE(TDM_ERROR_NONE, error);
157 TEST_P(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType)
159 TDM_UT_SKIP_FLAG(has_outputs);
162 tdm_hwc_window *hwc_win;
163 tdm_error error = TDM_ERROR_NONE;
165 for (int o = 0; o < output_count; o++) {
166 hwc = tdm_output_get_hwc(hwc, &error);
168 hwc_win = tdm_hwc_create_window(hwc, &error);
169 ASSERT_NE(NULL, hwc_win);
170 error = tdm_hwc_window_set_composition_type(hwc_win, tdm_hwc_window_composition(TDM_COMPOSITION_NONE - 1));
171 ASSERT_NE(TDM_ERROR_NONE, error);
172 tdm_hwc_window_destroy(hwc_win);
177 TEST_P(TDMHwcWindow, SetCompositionTypeSuccessful)
179 TDM_UT_SKIP_FLAG(has_outputs);
182 tdm_hwc_window *hwc_wins[HWC_WIN_NUM];
183 tdm_error error = TDM_ERROR_NONE;
186 for (int o = 0; o < output_count; o++) {
187 hwc = tdm_output_get_hwc(hwc, &error);
189 for (w = 0; w < HWC_WIN_NUM; w++) {
190 hwc_wins[w] = tdm_hwc_create_window(hwc, &error);
191 ASSERT_NE(NULL, hwc_wins[w]);
194 for (w = 0; w < HWC_WIN_NUM; w++) {
195 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_DEVICE);
196 ASSERT_EQ(TDM_ERROR_NONE, error);
197 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CLIENT);
198 ASSERT_EQ(TDM_ERROR_NONE, error);
199 error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CURSOR);
200 ASSERT_EQ(TDM_ERROR_NONE, error);
203 for (w = 0; w < HWC_WIN_NUM; w++)
204 tdm_hwc_window_destroy(hwc_wins[w]);
209 /* tdm_error tdm_hwc_window_set_buffer_damage() */
210 TEST_P(TDMHwcWindow, SetBufferDamageFailNullHwcWindow)
212 TDM_UT_SKIP_FLAG(has_outputs);
214 tdm_error error = TDM_ERROR_NONE;
215 tdm_region damage = {.num_rects = 0, .rects = NULL};
217 error = tdm_hwc_window_set_buffer_damage(NULL, damage);
218 ASSERT_NE(TDM_ERROR_NONE, error);
221 TEST_P(TDMHwcWindow, SetBufferDamageFailNullDamageRects)
223 TDM_UT_SKIP_FLAG(has_outputs);
226 tdm_hwc_window *hwc_win;
227 tdm_error error = TDM_ERROR_NONE;
228 tdm_region damage = {.num_rects = 1, .rects = NULL};
230 for (int o = 0; o < output_count; o++) {
231 hwc = tdm_output_get_hwc(hwc, &error);
233 hwc_win = tdm_hwc_create_window(hwc, &error);
234 ASSERT_NE(NULL, hwc_win);
235 error = tdm_hwc_window_set_buffer_damage(hwc_win, damage);
236 ASSERT_NE(TDM_ERROR_NONE, error);
237 tdm_hwc_window_destroy(hwc_win);
242 TEST_P(TDMHwcWindow, SetBufferDamageSuccessful)
244 TDM_UT_SKIP_FLAG(has_outputs);
247 tdm_hwc_window *hwc_wins[HWC_WIN_NUM];
248 tdm_error error = TDM_ERROR_NONE;
249 tdm_pos const rects[1] = {0};
250 tdm_region damage = {.num_rects = 1, .rects = rects};
252 for (int o = 0; o < output_count; o++) {
253 hwc = tdm_output_get_hwc(hwc, &error);
255 for (int w = 0; w < HWC_WIN_NUM; w++) {
256 hwc_wins[w] = tdm_hwc_create_window(hwc, &error);
257 ASSERT_NE(NULL, hwc_wins[w]);
258 error = tdm_hwc_window_set_buffer_damage(hwc_wins[w], damage);
259 ASSERT_EQ(TDM_ERROR_NONE, error);
260 tdm_hwc_window_destroy(hwc_wins[w]);
266 /* tdm_error tdm_hwc_window_set_info() */
267 TEST_P(TDMHwcWindow, SetInfoFailNull)
269 TDM_UT_SKIP_FLAG(has_outputs);
272 tdm_hwc_window *hwc_win;
273 tdm_error error = TDM_ERROR_NONE;
274 tdm_hwc_window_info info = { 0 };
276 error = tdm_hwc_window_set_info(NULL, &info);
277 ASSERT_NE(TDM_ERROR_NONE, error);
279 for (int o = 0; o < output_count; o++) {
280 hwc = tdm_output_get_hwc(hwc, &error);
282 hwc_win = tdm_hwc_create_window(hwc, &error);
283 ASSERT_NE(NULL, hwc_win);
284 error = tdm_hwc_window_set_info(hwc_win, NULL);
285 ASSERT_NE(TDM_ERROR_NONE, error);
286 tdm_hwc_window_destroy(hwc_win);
291 TEST_P(TDMHwcWindow, SetInfoSuccessful)
293 TDM_UT_SKIP_FLAG(has_outputs);
296 tdm_hwc_window *hwc_win;
297 tdm_error error = TDM_ERROR_NONE;
298 tdm_hwc_window_info info = { 0 };
300 for (int o = 0; o < output_count; o++) {
301 hwc = tdm_output_get_hwc(hwc, &error);
303 hwc_win = tdm_hwc_create_window(hwc, &error);
304 ASSERT_NE(NULL, hwc_win);
305 error = tdm_hwc_window_set_info(hwc_win, &info);
306 ASSERT_NE(TDM_ERROR_NONE, error);
307 tdm_hwc_window_destroy(hwc_win);
312 /* tdm_error tdm_hwc_window_set_buffer() */
313 TEST_P(TDMHwcWindow, SetBufferFailNull)
315 TDM_UT_SKIP_FLAG(has_outputs);
317 tdm_error error = TDM_ERROR_NONE;
319 error = tdm_hwc_window_set_buffer(NULL, NULL);
320 ASSERT_NE(TDM_ERROR_NONE, error);
323 TEST_P(TDMHwcWindow, SetBufferSuccessful)
325 TDM_UT_SKIP_FLAG(has_outputs);
328 tdm_hwc_window *hwc_wins[HWC_WIN_NUM];
329 tdm_error error = TDM_ERROR_NONE;
330 tbm_surface_h buffer = NULL;
332 for (int o = 0; o < output_count; o++) {
333 hwc = tdm_output_get_hwc(hwc, &error);
335 for (int w = 0; w < HWC_WIN_NUM; w++) {
336 hwc_wins[w] = tdm_hwc_create_window(hwc, &error);
337 ASSERT_NE(NULL, hwc_wins[w]);
339 buffer = tbm_surface_create(256, 256, TBM_FORMAT_ARGB8888);
340 ASSERT_NE(NULL, buffer);
342 error = tdm_hwc_window_set_buffer(hwc_wins[w], buffer);
343 tbm_surface_destroy(buffer);
344 ASSERT_EQ(TDM_ERROR_NONE, error);
346 /* set NULL to the buffer */
347 error = tdm_hwc_window_set_buffer(hwc_wins[w], NULL);
348 ASSERT_EQ(TDM_ERROR_NONE, error);
350 tdm_hwc_window_destroy(hwc_wins[w]);
356 /* tdm_hwc_window_set_property() */
357 TEST_P(TDMHwcWindow, SetPropertyFailNull)
359 TDM_UT_SKIP_FLAG(has_outputs);
361 tdm_error error = TDM_ERROR_NONE;
365 error = tdm_hwc_window_set_property(NULL, id, value);
366 ASSERT_NE(TDM_ERROR_NONE, error);
369 TEST_P(TDMHwcWindow, SetPropertyFailWrongId)
371 TDM_UT_SKIP_FLAG(has_outputs);
374 tdm_hwc_window *hwc_win;
375 tdm_error error = TDM_ERROR_NONE;
379 for (int o = 0; o < output_count; o++) {
380 hwc = tdm_output_get_hwc(hwc, &error);
382 hwc_win = tdm_hwc_create_window(hwc, &error);
383 ASSERT_NE(NULL, hwc_win);
384 error = tdm_hwc_window_set_property(hwc_win, id, value);
385 ASSERT_NE(TDM_ERROR_NONE, error);
386 tdm_hwc_window_destroy(hwc_win);
391 /* tdm_hwc_window_get_property() */
392 TEST_P(TDMHwcWindow, GetPropertyFailNull)
394 TDM_UT_SKIP_FLAG(has_outputs);
397 tdm_hwc_window *hwc_win;
398 tdm_error error = TDM_ERROR_NONE;
402 error = tdm_hwc_window_get_property(NULL, id, &value);
403 ASSERT_NE(TDM_ERROR_NONE, error);
405 for (int o = 0; o < output_count; o++) {
406 hwc = tdm_output_get_hwc(hwc, &error);
408 hwc_win = tdm_hwc_create_window(hwc, &error);
409 ASSERT_NE(NULL, hwc_win);
410 error = tdm_hwc_window_get_property(hwc_win, id, NULL);
411 ASSERT_NE(TDM_ERROR_NONE, error);
412 tdm_hwc_window_destroy(hwc_win);
417 TEST_P(TDMHwcWindow, GetPropertyFailWrongId)
419 TDM_UT_SKIP_FLAG(has_outputs);
422 tdm_hwc_window *hwc_win;
423 tdm_error error = TDM_ERROR_NONE;
427 for (int o = 0; o < output_count; o++) {
428 hwc = tdm_output_get_hwc(hwc, &error);
430 hwc_win = tdm_hwc_create_window(hwc, &error);
431 ASSERT_NE(NULL, hwc_win);
432 error = tdm_hwc_window_get_property(hwc_win, id, &value);
433 ASSERT_NE(TDM_ERROR_NONE, error);
434 tdm_hwc_window_destroy(hwc_win);
439 #ifdef TDM_UT_TEST_WITH_PARAMS
440 INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
442 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
444 INSTANTIATE_TEST_CASE_P(TDMHwcWindowParams,
446 Values(TDM_DEFAULT_MODULE));