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 **************************************************************************/
32 #include "gtest/gtest.h"
37 #include "tdm_config.h"
38 #include "tdm_backend.h"
40 #include "tbm_bufmgr.h"
41 #include "tbm_drm_helper.h"
44 class TDMOutputHwc : public ::testing::Test {
46 tdm_display *dpy = NULL;
47 tbm_bufmgr tbm_bufmgr = NULL;
49 /*list of connected outputs*/
51 const tdm_output_mode **preferred_mode_array = NULL;
56 setenv("TDM_HWC", "1", 1);
57 setenv("XDG_RUNTIME_DIR", "/run", 1);
58 setenv("TBM_DISPLAY_SERVER", "1", 1);
59 tdm_config_set_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1);
60 tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_THREAD, 1);
61 tdm_config_set_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 1);
67 unsetenv("XDG_RUNTIME_DIR");
68 unsetenv("TBM_DISPLAY_SERVER");
71 int IsHwcEnable(int i)
73 tdm_output_capability capabilities = (tdm_output_capability)0;
74 tdm_output_get_capabilities(outputs[i], &capabilities);
75 return capabilities & TDM_OUTPUT_CAPABILITY_HWC;
78 tbm_surface_h CreateBufferForOutput(int i)
80 int w = preferred_mode_array[i]->hdisplay;
81 int h = preferred_mode_array[i]->vdisplay;
82 return tbm_surface_internal_create_with_flags(w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
87 const tdm_output_mode *preferred_mode = NULL;
88 tdm_error error = TDM_ERROR_NONE;
89 int all_output_count = 0;
94 /* FIXME: fix the error. If we initialize TBM before TDM we get fail
95 * in the tdm_output_set_dpms */
97 tbm_bufmgr = tbm_bufmgr_init(-1);
98 ASSERT_FALSE(tbm_bufmgr == NULL);
101 dpy = tdm_display_init(&error);
102 ASSERT_TRUE(error == TDM_ERROR_NONE);
103 ASSERT_FALSE(dpy == NULL);
105 master_fd = tbm_drm_helper_get_master_fd();
106 ASSERT_TRUE(tdm_display_get_output_count(dpy, &all_output_count) == TDM_ERROR_NONE);
108 outputs = (tdm_output **)calloc(all_output_count, sizeof(tdm_output *));
109 ASSERT_FALSE(NULL == outputs);
111 preferred_mode_array = (const tdm_output_mode **)calloc(all_output_count, sizeof(tdm_output_mode *));
112 ASSERT_FALSE(NULL == preferred_mode_array);
116 for (int i = 0; i < all_output_count; i++) {
117 tdm_output *output = tdm_display_get_output(dpy, i, &error);
118 int output_modes_cnt = 0;
119 const tdm_output_mode *output_modes;
121 if (TDM_ERROR_NONE != error || NULL == output)
124 tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
125 if (TDM_ERROR_NONE != tdm_output_get_conn_status(output, &status))
128 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
131 error = tdm_output_get_available_modes(output, &output_modes, &output_modes_cnt);
132 if (TDM_ERROR_NONE != error)
134 if (output_modes_cnt <= 0) {
138 for(int j = 0; j < output_modes_cnt; j++)
139 if(output_modes[j].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
140 preferred_mode = &output_modes[j];
145 if (preferred_mode_array)
146 preferred_mode_array[output_count] = preferred_mode;
148 outputs[output_count] = output;
151 error = tdm_output_set_mode(output, preferred_mode);
152 ASSERT_EQ(TDM_ERROR_NONE, error);
157 tdm_display_deinit(dpy);
159 tbm_bufmgr_deinit(tbm_bufmgr);
163 if (preferred_mode_array)
164 free(preferred_mode_array);
165 if (master_fd > -1) {
166 int temp_master_fd = tbm_drm_helper_get_master_fd();
167 EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
168 if (temp_master_fd > -1)
177 class TDMOutputHwcWithoutHwcCap : public TDMOutputHwc {
180 TDMOutputHwc::SetEnv();
181 setenv("TDM_HWC", "0", 1);
185 #define HWC_WIN_NUM 5
186 class TDMHwcWindow : public TDMOutputHwc {
188 tdm_hwc_window **hwc_wins;
189 tdm_hwc_window *video_hwc_win;
195 video_hwc_win = NULL;
197 TDMOutputHwc::SetUp();
198 hwc_wins = (tdm_hwc_window **)calloc(output_count * HWC_WIN_NUM, sizeof(tdm_hwc_window *));
200 //create HWC_WIN_NUM hwc_windows for each outputs
201 for (int i = 0; i < output_count; i++) {
202 if (IsHwcEnable(i)) {
203 for (int j = 0; j < HWC_WIN_NUM; j++) {
204 tdm_hwc_window * hw = tdm_output_hwc_create_window(outputs[i], &error);
205 ASSERT_EQ(TDM_ERROR_NONE, error);
206 hwc_wins[hwc_count++] = hw;
208 if (!video_hwc_win) {
209 video_hwc_win = tdm_output_hwc_create_video_window(outputs[i], &error);
217 for (int i = 0; i < hwc_count; i++) {
218 tdm_output_hwc_destroy_window(outputs[0], hwc_wins[i]);
222 tdm_output_hwc_destroy_window(outputs[0], video_hwc_win);
224 TDMOutputHwc::TearDown();
229 /* tdm_hwc_window * tdm_output_hwc_create_window(tdm_output *output, tdm_error *error); */
230 TEST_F(TDMOutputHwc, CreateWindowFailNull)
232 ASSERT_EQ(NULL, tdm_output_hwc_create_window(NULL, &error));
233 ASSERT_NE(TDM_ERROR_NONE, error);
236 TEST_F(TDMOutputHwc, CreateWindowSuccessful)
238 for (int i = 0; i < output_count; i++) {
239 if (IsHwcEnable(i)) {
240 tdm_hwc_window * hw = tdm_output_hwc_create_window(outputs[i], &error);
241 ASSERT_EQ(TDM_ERROR_NONE, error);
242 error = tdm_output_hwc_destroy_window(outputs[i], hw);
243 ASSERT_EQ(TDM_ERROR_NONE, error);
245 ASSERT_EQ(NULL, tdm_output_hwc_create_window(outputs[i], &error));
246 ASSERT_NE(TDM_ERROR_NONE, error);
252 /* tdm_error tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window); */
253 TEST_F(TDMOutputHwc, DestroyWindowFailNull)
255 for (int i = 0; i < output_count; i++) {
256 tdm_hwc_window * hw = NULL;
258 if (IsHwcEnable(i)) {
259 hw = tdm_output_hwc_create_window(outputs[i], &error);
260 ASSERT_EQ(TDM_ERROR_NONE, error);
263 /* test: output is NULL*/
264 error = tdm_output_hwc_destroy_window(NULL, hw);
265 ASSERT_NE(TDM_ERROR_NONE, error);
267 /* test: hw is NULL*/
268 error = tdm_output_hwc_destroy_window(outputs[i], NULL);
269 ASSERT_NE(TDM_ERROR_NONE, error);
273 TEST_F(TDMOutputHwc, DestroyWindowSuccessful)
276 for (int i = 0; i < output_count; i++) {
277 if (IsHwcEnable(i)) {
278 hw = tdm_output_hwc_create_window(outputs[i], &error);
279 ASSERT_EQ(TDM_ERROR_NONE, error);
280 error = tdm_output_hwc_destroy_window(outputs[i], hw);
281 ASSERT_EQ(TDM_ERROR_NONE, error);
287 /* tdm_error tdm_output_hwc_set_client_target_buffer(tdm_output *output,
288 tbm_surface_h target_buffer, tdm_hwc_region damage,
289 tdm_hwc_window *composited_wnds, uint32_t num_wnds); */
290 /* TDOO: need to be fixed
291 TEST_F(TDMOutputHwc, SetClientTargetBufferFailNullOutput)
294 tbm_surface_h target_buff = CreateBufferForOutput(0);
295 error = tdm_output_hwc_set_client_target_buffer(NULL, target_buff, reg, NULL, 0 );
296 tbm_surface_internal_destroy(target_buff);
297 ASSERT_NE(TDM_ERROR_NONE, error);
300 TEST_F(TDMOutputHwcWithoutHwcCap, SetClientTargetBufferFailNoHwc)
302 tdm_hwc_region damage = {.num_rects = 0, .rects = NULL};
304 for (int i = 0; i < output_count; i++) {
305 tbm_surface_h target_buff = CreateBufferForOutput(i);
306 ASSERT_NE(NULL, target_buff);
307 error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage, NULL, 0);
308 tbm_surface_internal_destroy(target_buff);
309 ASSERT_NE(TDM_ERROR_NONE, error);
313 TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulSetBuff)
315 tdm_hwc_region damage = {.num_rects = 0, .rects = NULL};
317 for (int i = 0; i < output_count; i++) {
318 tbm_surface_h target_buff = CreateBufferForOutput(i);
319 ASSERT_NE(NULL, target_buff);
320 if (IsHwcEnable(i)) {
321 error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage,
323 tbm_surface_internal_destroy(target_buff);
324 ASSERT_EQ(TDM_ERROR_NONE, error);
326 error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage,
328 tbm_surface_internal_destroy(target_buff);
329 ASSERT_NE(TDM_ERROR_NONE, error);
334 TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulResetBuff)
336 tdm_hwc_region damage = {.num_rects = 0, .rects = NULL};
338 for (int i = 0; i < output_count; i++) {
339 if (IsHwcEnable(i)) {
340 error = tdm_output_hwc_set_client_target_buffer(outputs[i], NULL, damage,
342 ASSERT_EQ(TDM_ERROR_NONE, error);
344 error = tdm_output_hwc_set_client_target_buffer(outputs[i], NULL, damage,
346 ASSERT_NE(TDM_ERROR_NONE, error);
352 /* tbm_surface_queue_h tdm_output_hwc_get_target_buffer_queue(tdm_output *output, tdm_error *error); */
353 TEST_F(TDMOutputHwc, GetTargetBufferQueueFailNullOutput)
355 tbm_surface_queue_h queue = NULL;
357 queue = tdm_output_hwc_get_target_buffer_queue(NULL, &error);
358 ASSERT_NE(TDM_ERROR_NONE, error);
359 ASSERT_EQ(NULL, queue);
361 queue = tdm_output_hwc_get_target_buffer_queue(NULL, NULL);
362 ASSERT_EQ(NULL, queue);
365 TEST_F(TDMOutputHwcWithoutHwcCap, GetTargetBufferQueueFainNoHwc)
367 tbm_surface_queue_h queue = NULL;
369 for (int i = 0; i < output_count; i++) {
370 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], &error);
371 ASSERT_NE(TDM_ERROR_NONE, error);
372 ASSERT_EQ(NULL, queue);
376 TEST_F(TDMOutputHwc, GetTargetBufferQueueSuccessful)
378 tbm_surface_queue_h queue = NULL;
380 for (int i = 0; i < output_count; i++) {
381 if (IsHwcEnable(i)) {
382 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], &error);
383 tbm_surface_queue_destroy(queue);
384 ASSERT_EQ(TDM_ERROR_NONE, error);
385 ASSERT_NE(NULL, queue);
387 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], NULL);
388 tbm_surface_queue_destroy(queue);
389 ASSERT_EQ(TDM_ERROR_NONE, error);
390 ASSERT_NE(NULL, queue);
392 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], &error);
393 ASSERT_NE(TDM_ERROR_NONE, error);
394 ASSERT_EQ(NULL, queue);
396 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], NULL);
397 ASSERT_NE(TDM_ERROR_NONE, error);
398 ASSERT_EQ(NULL, queue);
403 /* tbm_surface_queue_h tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error); */
404 TEST_F(TDMHwcWindow, GetBufferQueueFailNull)
406 tbm_surface_queue_h queue = NULL;
408 queue = tdm_hwc_window_get_tbm_buffer_queue(NULL, &error);
409 ASSERT_NE(TDM_ERROR_NONE, error);
410 ASSERT_EQ(NULL, queue);
412 queue = tdm_hwc_window_get_tbm_buffer_queue(NULL, NULL);
413 ASSERT_EQ(NULL, queue);
416 TEST_F(TDMHwcWindow, GetBufferQueueSuccessful)
418 tbm_surface_queue_h queue = NULL;
419 tdm_hwc_window_info info = { 0 };
421 info.src_config.format = TBM_FORMAT_ARGB8888;
422 info.src_config.size.h = info.src_config.size.v = 256;
423 info.src_config.pos.h = info.src_config.pos.w = 256;
424 info.dst_pos.h = info.dst_pos.w = 256;
425 info.transform = TDM_TRANSFORM_NORMAL;
427 for (int i = 0; i < hwc_count; i++) {
428 error = tdm_hwc_window_set_info(hwc_wins[i], &info);
429 ASSERT_EQ(TDM_ERROR_NONE, error);
431 queue = tdm_hwc_window_get_tbm_buffer_queue(hwc_wins[i], &error);
432 tbm_surface_queue_destroy(queue);
433 ASSERT_EQ(TDM_ERROR_NONE, error);
434 ASSERT_NE(NULL, queue);
436 queue = tdm_hwc_window_get_tbm_buffer_queue(hwc_wins[i], NULL);
437 tbm_surface_queue_destroy(queue);
438 ASSERT_NE(NULL, queue);
442 /* tdm_error tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
443 tdm_hwc_window_composition composition_type); */
444 TEST_F(TDMHwcWindow, SetCompositionTypeFailNull)
446 error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE);
447 ASSERT_NE(TDM_ERROR_NONE, error);
450 TEST_F(TDMHwcWindow, SetCompositionTypeSuccessful)
452 for (int i = 0; i < hwc_count; i++) {
453 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_DEVICE);
454 ASSERT_EQ(TDM_ERROR_NONE, error);
455 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_CLIENT);
456 ASSERT_EQ(TDM_ERROR_NONE, error);
457 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_CURSOR);
458 ASSERT_EQ(TDM_ERROR_NONE, error);
462 TEST_F(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType)
464 for (int i = 0; i < hwc_count; i++) {
465 error = tdm_hwc_window_set_composition_type(hwc_wins[i], tdm_hwc_window_composition(TDM_COMPOSITION_NONE-1));
466 ASSERT_NE(TDM_ERROR_NONE, error);
470 /* tdm_error tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region damage); */
471 TEST_F(TDMHwcWindow, SetBufferDamageFailNullHwcWindow)
473 tdm_hwc_region damage = {.num_rects = 0, .rects = NULL};
475 error = tdm_hwc_window_set_buffer_damage(NULL, damage);
476 ASSERT_NE(TDM_ERROR_NONE, error);
479 TEST_F(TDMHwcWindow, SetBufferDamageFailNullDamageRects)
481 tdm_hwc_region damage = {.num_rects = 1, .rects = NULL};
483 for (int i = 0; i < hwc_count; i++) {
484 error = tdm_hwc_window_set_buffer_damage(hwc_wins[i], damage);
485 ASSERT_NE(TDM_ERROR_NONE, error);
490 TEST_F(TDMHwcWindow, SetBufferDamageSuccessful)
492 tdm_pos const rects[1] = {0};
493 tdm_hwc_region damage = {.num_rects = 1, .rects = rects};
495 for (int i = 0; i < hwc_count; i++) {
496 error = tdm_hwc_window_set_buffer_damage(hwc_wins[i], damage);
497 ASSERT_EQ(TDM_ERROR_NONE, error);
502 /* tdm_error tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info); */
503 TEST_F(TDMHwcWindow, SetInfoFailNull)
505 tdm_hwc_window_info info = { 0 };
507 error = tdm_hwc_window_set_info(NULL, &info);
508 ASSERT_NE(TDM_ERROR_NONE, error);
511 error = tdm_hwc_window_set_info(hwc_wins[0], NULL);
512 ASSERT_NE(TDM_ERROR_NONE, error);
515 TEST_F(TDMHwcWindow, SetInfoSuccessful)
517 tdm_hwc_window_info info = { 0 };
519 for (int i = 0; i < hwc_count; i++) {
520 error = tdm_hwc_window_set_info(hwc_wins[i], &info);
521 ASSERT_EQ(TDM_ERROR_NONE, error);
526 /* tdm_error tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer); */
527 TEST_F(TDMHwcWindow, SetBufferFailNull)
529 error = tdm_hwc_window_set_buffer(NULL, NULL);
530 ASSERT_NE(TDM_ERROR_NONE, error);
533 TEST_F(TDMHwcWindow, SetBufferSuccessful)
535 for (int i = 0; i < hwc_count; i++) {
537 tbm_surface_h buff = tbm_surface_create(256, 256, TBM_FORMAT_ARGB8888);
540 error = tdm_hwc_window_set_buffer(hwc_wins[i], buff);
541 tbm_surface_destroy(buff);
542 ASSERT_EQ(TDM_ERROR_NONE, error);
545 error = tdm_hwc_window_set_buffer(hwc_wins[i], NULL);
546 ASSERT_EQ(TDM_ERROR_NONE, error);
550 /* tdm_error tdm_hwc_window_set_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); */
551 TEST_F(TDMHwcWindow, SetFlagsFailNull)
553 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
555 error = tdm_hwc_window_set_flags(NULL, flag);
556 ASSERT_NE(TDM_ERROR_NONE, error);
559 TEST_F(TDMHwcWindow, SetFlagsSuccessful)
561 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
563 for (int i = 0; i < hwc_count; i++) {
565 error = tdm_hwc_window_set_flags(hwc_wins[i], flag);
566 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
570 /* tdm_error tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); */
571 TEST_F(TDMHwcWindow, UnsetFlagsFailNull)
573 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
575 error = tdm_hwc_window_unset_flags(NULL, flag);
576 ASSERT_NE(TDM_ERROR_NONE, error);
579 TEST_F(TDMHwcWindow, UnsetFlagsSuccessful)
581 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
583 for (int i = 0; i < hwc_count; i++) {
585 error = tdm_hwc_window_unset_flags(hwc_wins[i], flag);
586 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
590 /* tdm_error tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
591 tdm_hwc_window_video_capability *video_capability); */
592 TEST_F(TDMHwcWindow, VideoGetCapabilityFailNull)
594 tdm_hwc_window_video_capability video_capability;
596 error = tdm_hwc_window_video_get_capability(NULL, &video_capability);
597 ASSERT_NE(TDM_ERROR_NONE, error);
600 error = tdm_hwc_window_video_get_capability(hwc_wins[0], NULL);
601 ASSERT_NE(TDM_ERROR_NONE, error);
606 TEST_F(TDMHwcWindow, VideoGetCapabilitySuccessful)
608 tdm_hwc_window_video_capability video_capability;
610 for (int i = 0; i < hwc_count; i++) {
611 /* hwc_window with TDM_COMPOSITION_CLIENT dosn't support tdm_hwc_window_video_get_capability()*/
612 error = tdm_hwc_window_video_get_capability(hwc_wins[i], &video_capability);
613 ASSERT_NE(TDM_ERROR_NONE, error);
615 if (video_hwc_win != NULL) {
616 error = tdm_hwc_window_video_get_capability(video_hwc_win, &video_capability);
617 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
622 /* tdm_error tdm_output_hwc_validate(tdm_output *output, tdm_hwc_window **composited_wnds, uint32_t num_wnds,
623 uint32_t *num_types); */
624 /* TODO: fix the validate test later.
625 TEST_F(TDMOutputHwc, ValidateFailNull)
628 error = tdm_output_hwc_validate(NULL, NULL, 0, &num_types);
629 ASSERT_NE(TDM_ERROR_NONE, error);
632 error = tdm_output_hwc_validate(outputs[0], NULL, 0, NULL);
633 ASSERT_NE(TDM_ERROR_NONE, error);
637 TEST_F(TDMOutputHwcWithoutHwcCap, ValidateFailNoHwc)
641 for (int i = 0; i < output_count; i++) {
642 error = tdm_output_hwc_validate(outputs[i], &num_types);
643 ASSERT_NE(TDM_ERROR_NONE, error);
647 TEST_F(TDMOutputHwc, ValidateSuccessful)
650 for (int i = 0; i < output_count; i++) {
651 if (IsHwcEnable(i)) {
652 error = tdm_output_hwc_validate(outputs[i], &num_types);
653 ASSERT_EQ(TDM_ERROR_NONE, error);
655 error = tdm_output_hwc_validate(outputs[i], &num_types);
656 ASSERT_NE(TDM_ERROR_NONE, error);
662 /* tdm_error tdm_output_hwc_get_changed_composition_types(tdm_output *output,
663 uint32_t *num_elements, tdm_hwc_window **hwc_window,
664 tdm_hwc_window_composition *composition_types); */
666 TEST_F(TDMOutputHwc, GetChangedCompositionTypesFailNull)
668 uint32_t num_elements;
670 error = tdm_output_hwc_get_changed_composition_types(NULL, &num_elements, NULL, NULL);
671 ASSERT_NE(TDM_ERROR_NONE, error);
674 error = tdm_output_hwc_get_changed_composition_types(outputs[0], NULL, NULL, NULL);
675 ASSERT_NE(TDM_ERROR_NONE, error);
679 TEST_F(TDMOutputHwcWithoutHwcCap, GetChangedCompositionTypesFailNoHwc)
681 uint32_t get_num = 10;
683 for (int i = 0; i < output_count; i++) {
684 error = tdm_output_hwc_get_changed_composition_types(outputs[i], &get_num, NULL, NULL);
685 ASSERT_NE(TDM_ERROR_NONE, error);
689 /* TODO: fix the validate test later.
690 TEST_F(TDMHwcWindow, GetChangedCompositionTypesSuccessful)
692 uint32_t validate_num;
693 uint32_t get_num = 0;
695 tdm_hwc_window_composition *composition_types;
696 tdm_hwc_window **hwc_wnds;
698 for (int i = 0; i < hwc_count; i++) {
699 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_DEVICE);
700 ASSERT_EQ(TDM_ERROR_NONE, error);
704 for (int i = 0; i < output_count; i++) {
705 if (IsHwcEnable(i)) {
706 error = tdm_output_hwc_validate(outputs[i], &validate_num);
707 ASSERT_EQ(TDM_ERROR_NONE, error);
709 error = tdm_output_hwc_get_changed_composition_types(outputs[i], &get_num, NULL, NULL);
710 ASSERT_EQ(TDM_ERROR_NONE, error);
712 ASSERT_TRUE(get_num == validate_num);
713 hwc_wnds = (tdm_hwc_window **)calloc(get_num, sizeof(tdm_hwc_window *));
714 composition_types = (tdm_hwc_window_composition *)calloc(get_num, sizeof(tdm_hwc_window_composition));
716 error = tdm_output_hwc_get_changed_composition_types(outputs[i], &get_num, hwc_wnds, composition_types);
719 free(composition_types);
721 ASSERT_EQ(TDM_ERROR_NONE, error);
723 error = tdm_output_hwc_get_changed_composition_types(outputs[i], &get_num, NULL, NULL);
724 ASSERT_NE(TDM_ERROR_NONE, error);
730 /* tdm_error tdm_output_hwc_accept_changes(tdm_output *output); */
732 TEST_F(TDMOutputHwc, AcceptChangesFailNull)
734 error = tdm_output_hwc_accept_changes(NULL);
735 ASSERT_NE(TDM_ERROR_NONE, error);
738 TEST_F(TDMOutputHwcWithoutHwcCap, AcceptChangesFailNoHwc)
740 for (int i = 0; i < output_count; i++) {
741 error = tdm_output_hwc_accept_changes(outputs[i]);
742 ASSERT_NE(TDM_ERROR_NONE, error);
746 /* TODO: fix the validate test later.
747 TEST_F(TDMHwcWindow, AcceptChangesSuccessful)
749 uint32_t validate_num;
751 for (int i = 0; i < hwc_count; i++) {
752 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_DEVICE);
753 ASSERT_EQ(TDM_ERROR_NONE, error);
756 for (int i = 0; i < output_count; i++) {
757 if (IsHwcEnable(i)) {
758 error = tdm_output_hwc_validate(outputs[i], &validate_num);
759 ASSERT_EQ(TDM_ERROR_NONE, error);
761 if (validate_num > 0) {
762 error = tdm_output_hwc_accept_changes(outputs[i]);
763 ASSERT_EQ(TDM_ERROR_NONE, error);
770 static int need_validate_handler_is_called = 0;
771 static void need_validate_handler(tdm_output *output)
773 need_validate_handler_is_called = 1;
775 /* tdm_error tdm_output_hwc_set_need_validate_handler(tdm_output *output,
776 tdm_output_need_validate_handler hndl); */
777 TEST_F(TDMOutputHwc, SetNeedValidateHandlerFailNull)
779 error = tdm_output_hwc_set_need_validate_handler(NULL, &need_validate_handler);
780 ASSERT_NE(TDM_ERROR_NONE, error);
782 error = tdm_output_hwc_set_need_validate_handler(outputs[0], NULL);
783 ASSERT_NE(TDM_ERROR_NONE, error);
787 TEST_F(TDMOutputHwcWithoutHwcCap, SetNeedValidateHandlerFailNoHwc)
789 for (int i = 0; i < output_count; i++) {
790 error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
791 ASSERT_NE(TDM_ERROR_NONE, error);
795 TEST_F(TDMOutputHwc, SetNeedValidateHandlerSuccessful)
797 for (int i = 0; i < output_count; i++) {
798 if (IsHwcEnable(i)) {
800 * This event can't be generated form user side.
801 * So just check a set and double set
805 error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
806 ASSERT_EQ(TDM_ERROR_NONE, error);
807 /* test: second isn't allowed*/
808 error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
809 ASSERT_NE(TDM_ERROR_NONE, error);
811 error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
812 ASSERT_NE(TDM_ERROR_NONE, error);
817 /* tdm_hwc_window * tdm_output_hwc_create_video_window(tdm_output *output, tdm_error *error); */
818 TEST_F(TDMOutputHwc, CreateVideoWindowFailNull)
820 ASSERT_EQ(NULL, tdm_output_hwc_create_video_window(NULL, &error));
821 ASSERT_NE(TDM_ERROR_NONE, error);
824 TEST_F(TDMOutputHwc, CreateVideoWindowSuccessful)
826 for (int i = 0; i < output_count; i++) {
827 if (IsHwcEnable(i)) {
828 tdm_hwc_window * hw = tdm_output_hwc_create_video_window(outputs[i], &error);
829 if (error != TDM_ERROR_NOT_IMPLEMENTED) {
830 ASSERT_EQ(TDM_ERROR_NONE, error);
832 error = tdm_output_hwc_destroy_window(outputs[i], hw);
833 ASSERT_EQ(TDM_ERROR_NONE, error);
836 ASSERT_EQ(NULL, tdm_output_hwc_create_video_window(outputs[i], &error));
837 ASSERT_NE(TDM_ERROR_NONE, error);
842 /* tdm_output_hwc_get_video_supported_formats() */
843 TEST_F(TDMOutputHwc, GetVideoSupportedFormatsFailNull)
847 error = tdm_output_hwc_get_video_supported_formats(NULL, NULL, NULL);
848 ASSERT_NE(TDM_ERROR_NONE, error);
851 TEST_F(TDMOutputHwc, GetVideoSupportedFormatsSuccessful)
854 const tbm_format *formats;
857 for (int i = 0; i < output_count; i++) {
858 if (IsHwcEnable(i)) {
859 error = tdm_output_hwc_get_video_supported_formats(outputs[i], &formats, &count);
860 if (error != TDM_ERROR_NOT_IMPLEMENTED) {
861 ASSERT_EQ(TDM_ERROR_NONE, error);
863 ASSERT_NE(NULL, formats);
866 error = tdm_output_hwc_get_video_supported_formats(outputs[i], &formats, &count);
867 ASSERT_NE(TDM_ERROR_NONE, error);
872 /* tdm_hwc_window_video_get_available_properties() */
873 TEST_F(TDMHwcWindow, GetAvailablePropertiesFailNullWin)
875 SKIP_FLAG(video_hwc_win != NULL);
876 const tdm_prop *props;
879 error = tdm_hwc_window_video_get_available_properties(NULL, &props, &count);
880 ASSERT_NE(TDM_ERROR_NONE, error);
882 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, NULL, &count);
883 ASSERT_NE(TDM_ERROR_NONE, error);
885 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, &props, NULL);
886 ASSERT_NE(TDM_ERROR_NONE, error);
889 TEST_F(TDMHwcWindow, GetAvailablePropertiesSuccess)
891 SKIP_FLAG(video_hwc_win != NULL);
893 const tdm_prop *props;
896 error = tdm_hwc_window_video_get_available_properties(video_hwc_win, &props, &count);
897 ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
900 /* tdm_hwc_window_video_get_property() */
901 TEST_F(TDMHwcWindow, GetPropertyFailNull)
903 SKIP_FLAG(video_hwc_win != NULL);
908 error = tdm_hwc_window_video_get_property(NULL, id, &value);
909 ASSERT_NE(TDM_ERROR_NONE, error);
911 error = tdm_hwc_window_video_get_property(video_hwc_win, id, NULL);
912 ASSERT_NE(TDM_ERROR_NONE, error);
915 TEST_F(TDMHwcWindow, GetPropertyFailWrongId)
917 SKIP_FLAG(video_hwc_win != NULL);
922 error = tdm_hwc_window_video_get_property(video_hwc_win, id, &value);
923 ASSERT_NE(TDM_ERROR_NONE, error);
926 /* tdm_hwc_window_video_set_property() */
927 TEST_F(TDMHwcWindow, SetPropertyFailNull)
929 SKIP_FLAG(video_hwc_win != NULL);
933 error = tdm_hwc_window_video_set_property(NULL, id, value);
934 ASSERT_NE(TDM_ERROR_NONE, error);
937 TEST_F(TDMHwcWindow, SetPropertyFailWrongId)
939 SKIP_FLAG(video_hwc_win != NULL);
944 error = tdm_hwc_window_video_set_property(video_hwc_win, id, value);
945 ASSERT_NE(TDM_ERROR_NONE, error);