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 **************************************************************************/
31 #include "gtest/gtest.h"
32 #include "ut_common.h"
37 #include "tbm_bufmgr.h"
38 #include "tbm_drm_helper.h"
41 class TDMOutputHwc : public ::testing::Test {
43 tdm_display *dpy = NULL;
44 tbm_bufmgr tbm_bufmgr = NULL;
46 /*list of connected outputs*/
48 const tdm_output_mode **preferred_mode_array = NULL;
53 setenv("TDM_DEBUG_MODULE", "all", 1);
54 setenv("TDM_DEBUG", "1", 1);
55 setenv("TDM_THREAD", "0", 1);
56 setenv("TDM_COMMIT_PER_VBLANK", "1", 1);
57 setenv("TDM_DLOG", "1", 1);
58 setenv("TDM_HWC", "1", 1);
59 setenv("XDG_RUNTIME_DIR", ".", 1);
60 setenv("TBM_DLOG", "1", 1);
61 setenv("TBM_DISPLAY_SERVER", "1", 1);
66 unsetenv("TDM_DEBUG_MODULE");
67 unsetenv("TDM_DEBUG");
68 unsetenv("TDM_THREAD");
69 unsetenv("TDM_COMMIT_PER_VBLANK");
72 unsetenv("XDG_RUNTIME_DIR");
74 unsetenv("TBM_DISPLAY_SERVER");
77 int IsHwcEnable(int i)
79 tdm_output_capability capabilities = (tdm_output_capability)0;
80 tdm_output_get_capabilities(outputs[i], &capabilities);
81 return capabilities & TDM_OUTPUT_CAPABILITY_HWC;
84 tbm_surface_h CreateBufferForOutput(int i)
86 int w = preferred_mode_array[i]->hdisplay;
87 int h = preferred_mode_array[i]->vdisplay;
88 return tbm_surface_internal_create_with_flags(w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
93 const tdm_output_mode *preferred_mode = NULL;
94 tdm_error error = TDM_ERROR_NONE;
95 int all_output_count = 0;
99 /* FIXME: fix the error. If we initialize TBM before TDM we get fail
100 * in the tdm_output_set_dpms */
102 tbm_bufmgr = tbm_bufmgr_init(-1);
103 ASSERT_FALSE(tbm_bufmgr == NULL);
106 dpy = tdm_display_init(&error);
107 ASSERT_TRUE(error == TDM_ERROR_NONE);
108 ASSERT_FALSE(dpy == NULL);
110 master_fd = tbm_drm_helper_get_master_fd();
111 ASSERT_TRUE(tdm_display_get_output_count(dpy, &all_output_count) == TDM_ERROR_NONE);
113 outputs = (tdm_output **)calloc(all_output_count, sizeof(tdm_output *));
114 ASSERT_FALSE(NULL == outputs);
116 preferred_mode_array = (const tdm_output_mode **)calloc(all_output_count, sizeof(tdm_output_mode *));
117 ASSERT_FALSE(NULL == preferred_mode_array);
121 for (int i = 0; i < all_output_count; i++) {
122 tdm_output *output = tdm_display_get_output(dpy, i, &error);
123 int output_modes_cnt = 0;
124 const tdm_output_mode *output_modes;
126 if (TDM_ERROR_NONE != error || NULL == output)
129 tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
130 if (TDM_ERROR_NONE != tdm_output_get_conn_status(output, &status))
133 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
136 error = tdm_output_get_available_modes(output, &output_modes, &output_modes_cnt);
137 if (TDM_ERROR_NONE != error)
139 if (output_modes_cnt <= 0) {
143 for(int j = 0; j < output_modes_cnt; j++)
144 if(output_modes[j].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
145 preferred_mode = &output_modes[j];
150 if (preferred_mode_array)
151 preferred_mode_array[output_count] = preferred_mode;
153 outputs[output_count] = output;
156 error = tdm_output_set_mode(output, preferred_mode);
157 ASSERT_EQ(TDM_ERROR_NONE, error);
162 tdm_display_deinit(dpy);
164 tbm_bufmgr_deinit(tbm_bufmgr);
168 if (preferred_mode_array)
169 free(preferred_mode_array);
170 if (master_fd > -1) {
171 int temp_master_fd = tbm_drm_helper_get_master_fd();
172 EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
173 if (temp_master_fd > -1)
183 #define HWC_WIN_NUM 5
184 class TDMHwcWindow : public TDMOutputHwc {
186 tdm_hwc_window **hwc_wins;
193 TDMOutputHwc::SetUp();
194 hwc_wins = (tdm_hwc_window **)calloc(output_count * HWC_WIN_NUM, sizeof(tdm_hwc_window *));
196 //create HWC_WIN_NUM hwc_windows for each outputs
197 for (int i = 0; i < output_count; i++) {
198 if (IsHwcEnable(i)) {
199 for (int j = 0; j < HWC_WIN_NUM; j++) {
200 tdm_hwc_window * hw = tdm_output_hwc_create_window(outputs[i], &error);
201 ASSERT_EQ(TDM_ERROR_NONE, error);
202 hwc_wins[hwc_count++] = hw;
210 for (int i = 0; i < hwc_count; i++) {
211 tdm_output_hwc_destroy_window(outputs[0], hwc_wins[i]);
213 TDMOutputHwc::TearDown();
218 /* tdm_hwc_window * tdm_output_hwc_create_window(tdm_output *output, tdm_error *error); */
219 TEST_F(TDMOutputHwc, CreateWindowFailNull)
221 ASSERT_EQ(NULL, tdm_output_hwc_create_window(NULL, &error));
222 ASSERT_NE(TDM_ERROR_NONE, error);
225 TEST_F(TDMOutputHwc, CreateWindowSuccessful)
227 for (int i = 0; i < output_count; i++) {
228 if (IsHwcEnable(i)) {
229 tdm_hwc_window * hw = tdm_output_hwc_create_window(outputs[i], &error);
230 ASSERT_EQ(TDM_ERROR_NONE, error);
231 error = tdm_output_hwc_destroy_window(outputs[i], hw);
232 ASSERT_EQ(TDM_ERROR_NONE, error);
234 ASSERT_EQ(NULL, tdm_output_hwc_create_window(outputs[i], &error));
235 ASSERT_NE(TDM_ERROR_NONE, error);
241 /* tdm_error tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window); */
242 TEST_F(TDMOutputHwc, DestroyWindowFailNull)
244 for (int i = 0; i < output_count; i++) {
245 tdm_hwc_window * hw = NULL;
247 if (IsHwcEnable(i)) {
248 hw = tdm_output_hwc_create_window(outputs[i], &error);
249 ASSERT_EQ(TDM_ERROR_NONE, error);
252 /* test: output is NULL*/
253 error = tdm_output_hwc_destroy_window(NULL, hw);
254 ASSERT_NE(TDM_ERROR_NONE, error);
256 /* test: hw is NULL*/
257 error = tdm_output_hwc_destroy_window(outputs[i], NULL);
258 ASSERT_NE(TDM_ERROR_NONE, error);
262 TEST_F(TDMOutputHwc, DestroyWindowSuccessful)
265 for (int i = 0; i < output_count; i++) {
266 if (IsHwcEnable(i)) {
267 hw = tdm_output_hwc_create_window(outputs[i], &error);
268 ASSERT_EQ(TDM_ERROR_NONE, error);
269 error = tdm_output_hwc_destroy_window(outputs[i], hw);
270 ASSERT_EQ(TDM_ERROR_NONE, error);
276 /* tdm_error tdm_output_hwc_set_client_target_buffer(tdm_output *output,
277 tbm_surface_h target_buffer, tdm_hwc_region damage); */
278 TEST_F(TDMOutputHwc, SetClientTargetBufferFailNullOutput)
281 tbm_surface_h target_buff = CreateBufferForOutput(0);
282 error = tdm_output_hwc_set_client_target_buffer(NULL, target_buff, reg);
283 tbm_surface_internal_destroy(target_buff);
284 ASSERT_NE(TDM_ERROR_NONE, error);
287 TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulSetBuff)
289 tdm_hwc_region damage;
291 for (int i = 0; i < output_count; i++) {
292 tbm_surface_h target_buff = CreateBufferForOutput(i);
293 ASSERT_NE(NULL, target_buff);
294 if (IsHwcEnable(i)) {
295 error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage);
296 tbm_surface_internal_destroy(target_buff);
297 ASSERT_EQ(TDM_ERROR_NONE, error);
299 error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage);
300 tbm_surface_internal_destroy(target_buff);
301 ASSERT_NE(TDM_ERROR_NONE, error);
306 TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulResetBuff)
308 tdm_hwc_region damage;
310 for (int i = 0; i < output_count; i++) {
311 if (IsHwcEnable(i)) {
312 error = tdm_output_hwc_set_client_target_buffer(outputs[i], NULL, damage);
313 ASSERT_EQ(TDM_ERROR_NONE, error);
315 error = tdm_output_hwc_set_client_target_buffer(outputs[i], NULL, damage);
316 ASSERT_NE(TDM_ERROR_NONE, error);
321 /* tbm_surface_queue_h tdm_output_hwc_get_target_buffer_queue(tdm_output *output, tdm_error *error); */
322 TEST_F(TDMOutputHwc, GetTargetBufferQueueFailNullOutput)
324 tbm_surface_queue_h queue = NULL;
326 queue = tdm_output_hwc_get_target_buffer_queue(NULL, &error);
327 ASSERT_NE(TDM_ERROR_NONE, error);
328 ASSERT_EQ(NULL, queue);
330 queue = tdm_output_hwc_get_target_buffer_queue(NULL, NULL);
331 ASSERT_EQ(NULL, queue);
334 TEST_F(TDMOutputHwc, GetTargetBufferQueueSuccessful)
336 tbm_surface_queue_h queue = NULL;
338 for (int i = 0; i < output_count; i++) {
339 if (IsHwcEnable(i)) {
340 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], &error);
341 tbm_surface_queue_destroy(queue);
342 ASSERT_EQ(TDM_ERROR_NONE, error);
343 ASSERT_NE(NULL, queue);
345 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], NULL);
346 tbm_surface_queue_destroy(queue);
347 ASSERT_EQ(TDM_ERROR_NONE, error);
348 ASSERT_NE(NULL, queue);
350 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], &error);
351 ASSERT_NE(TDM_ERROR_NONE, error);
352 ASSERT_EQ(NULL, queue);
354 queue = tdm_output_hwc_get_target_buffer_queue(outputs[i], NULL);
355 ASSERT_NE(TDM_ERROR_NONE, error);
356 ASSERT_EQ(NULL, queue);
361 /* tbm_surface_queue_h tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error); */
362 TEST_F(TDMHwcWindow, GetBufferQueueFailNull)
364 tbm_surface_queue_h queue = NULL;
366 queue = tdm_hwc_window_get_tbm_buffer_queue(NULL, &error);
367 ASSERT_NE(TDM_ERROR_NONE, error);
368 ASSERT_EQ(NULL, queue);
370 queue = tdm_hwc_window_get_tbm_buffer_queue(NULL, NULL);
371 ASSERT_EQ(NULL, queue);
374 TEST_F(TDMHwcWindow, GetBufferQueueSuccessful)
376 tbm_surface_queue_h queue = NULL;
377 tdm_hwc_window_info info = { 0 };
379 info.src_config.format = TBM_FORMAT_ARGB8888;
380 info.src_config.size.h = info.src_config.size.v = 256;
381 info.src_config.pos.h = info.src_config.pos.w = 256;
382 info.dst_pos.h = info.dst_pos.w = 256;
383 info.transform = TDM_TRANSFORM_NORMAL;
385 for (int i = 0; i < hwc_count; i++) {
386 error = tdm_hwc_window_set_info(hwc_wins[i], &info);
387 ASSERT_EQ(TDM_ERROR_NONE, error);
389 queue = tdm_hwc_window_get_tbm_buffer_queue(hwc_wins[i], &error);
390 tbm_surface_queue_destroy(queue);
391 ASSERT_EQ(TDM_ERROR_NONE, error);
392 ASSERT_NE(NULL, queue);
394 queue = tdm_hwc_window_get_tbm_buffer_queue(hwc_wins[i], NULL);
395 tbm_surface_queue_destroy(queue);
396 ASSERT_NE(NULL, queue);
400 /* tdm_error tdm_hwc_window_set_zpos(tdm_hwc_window *hwc_window, uint32_t zpos); */
401 TEST_F(TDMHwcWindow, SetZposFailNull)
403 error = tdm_hwc_window_set_zpos(NULL, 1);
404 ASSERT_NE(TDM_ERROR_NONE, error);
407 TEST_F(TDMHwcWindow, SetZposSuccessful)
409 for (int i = 0; i < hwc_count; i++) {
410 error = tdm_hwc_window_set_zpos(hwc_wins[i], i);
411 ASSERT_EQ(TDM_ERROR_NONE, error);
415 /* tdm_error tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
416 tdm_hwc_window_composition composition_type); */
417 TEST_F(TDMHwcWindow, SetCompositionTypeFailNull)
419 error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE);
420 ASSERT_NE(TDM_ERROR_NONE, error);
423 TEST_F(TDMHwcWindow, SetCompositionTypeSuccessful)
425 for (int i = 0; i < hwc_count; i++) {
426 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_DEVICE);
427 ASSERT_EQ(TDM_ERROR_NONE, error);
428 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_CLIENT);
429 ASSERT_EQ(TDM_ERROR_NONE, error);
430 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_CURSOR);
431 ASSERT_EQ(TDM_ERROR_NONE, error);
432 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_VIDEO);
433 ASSERT_EQ(TDM_ERROR_NONE, error);
437 TEST_F(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType)
439 for (int i = 0; i < hwc_count; i++) {
440 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_DEVICE_CANDIDATE);
441 ASSERT_NE(TDM_ERROR_NONE, error);
442 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_CLIENT_CANDIDATE);
443 ASSERT_NE(TDM_ERROR_NONE, error);
444 error = tdm_hwc_window_set_composition_type(hwc_wins[i], tdm_hwc_window_composition(TDM_COMPOSITION_CLIENT+1));
445 ASSERT_NE(TDM_ERROR_NONE, error);
449 /* tdm_error tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region damage); */
450 TEST_F(TDMHwcWindow, SetBufferDamageFailNullHwcWindow)
452 tdm_hwc_region damage;
453 error = tdm_hwc_window_set_buffer_damage(NULL, damage);
454 ASSERT_NE(TDM_ERROR_NONE, error);
457 TEST_F(TDMHwcWindow, SetBufferDamageFailNullDamageRects)
459 tdm_hwc_region damage = {.num_rects = 1, .rects = NULL};
461 for (int i = 0; i < hwc_count; i++) {
462 error = tdm_hwc_window_set_buffer_damage(hwc_wins[i], damage);
463 ASSERT_NE(TDM_ERROR_NONE, error);
468 TEST_F(TDMHwcWindow, SetBufferDamageSuccessful)
470 tdm_pos const rects[1] = {0};
471 tdm_hwc_region damage = {.num_rects = 1, .rects = rects};
473 for (int i = 0; i < hwc_count; i++) {
474 error = tdm_hwc_window_set_buffer_damage(hwc_wins[i], damage);
475 ASSERT_EQ(TDM_ERROR_NONE, error);
480 /* tdm_error tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info); */
481 TEST_F(TDMHwcWindow, SetInfoFailNull)
483 tdm_hwc_window_info info = { 0 };
485 error = tdm_hwc_window_set_info(NULL, &info);
486 ASSERT_NE(TDM_ERROR_NONE, error);
489 error = tdm_hwc_window_set_info(hwc_wins[0], NULL);
490 ASSERT_NE(TDM_ERROR_NONE, error);
493 TEST_F(TDMHwcWindow, SetInfoSuccessful)
495 tdm_hwc_window_info info = { 0 };
497 for (int i = 0; i < hwc_count; i++) {
498 error = tdm_hwc_window_set_info(hwc_wins[i], &info);
499 ASSERT_EQ(TDM_ERROR_NONE, error);
504 /* tdm_error tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer); */
505 TEST_F(TDMHwcWindow, SetBufferFailNull)
507 error = tdm_hwc_window_set_buffer(NULL, NULL);
508 ASSERT_NE(TDM_ERROR_NONE, error);
511 TEST_F(TDMHwcWindow, SetBufferSuccessful)
513 for (int i = 0; i < hwc_count; i++) {
515 tbm_surface_h buff = tbm_surface_create(256, 256, TBM_FORMAT_ARGB8888);
518 error = tdm_hwc_window_set_buffer(hwc_wins[i], buff);
519 tbm_surface_destroy(buff);
520 ASSERT_EQ(TDM_ERROR_NONE, error);
523 error = tdm_hwc_window_set_buffer(hwc_wins[i], NULL);
524 ASSERT_EQ(TDM_ERROR_NONE, error);
528 /* tdm_error tdm_hwc_window_set_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); */
529 TEST_F(TDMHwcWindow, SetFlagsFailNull)
531 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
533 error = tdm_hwc_window_set_flags(NULL, flag);
534 ASSERT_NE(TDM_ERROR_NONE, error);
537 TEST_F(TDMHwcWindow, SetFlagsSuccessful)
539 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
541 for (int i = 0; i < hwc_count; i++) {
543 error = tdm_hwc_window_set_flags(hwc_wins[i], flag);
544 ASSERT_EQ(TDM_ERROR_NONE, error);
548 /* tdm_error tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); */
549 TEST_F(TDMHwcWindow, UnsetFlagsFailNull)
551 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
553 error = tdm_hwc_window_unset_flags(NULL, flag);
554 ASSERT_NE(TDM_ERROR_NONE, error);
557 TEST_F(TDMHwcWindow, UnsetFlagsSuccessful)
559 tdm_hwc_window_flag flag = (tdm_hwc_window_flag)0;
561 for (int i = 0; i < hwc_count; i++) {
563 error = tdm_hwc_window_unset_flags(hwc_wins[i], flag);
564 ASSERT_EQ(TDM_ERROR_NONE, error);
568 /* tdm_error tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
569 tdm_hwc_window_video_capability *video_capability); */
570 TEST_F(TDMHwcWindow, VideoGetCapabilityFailNull)
572 tdm_hwc_window_video_capability video_capability;
574 error = tdm_hwc_window_video_get_capability(NULL, &video_capability);
575 ASSERT_NE(TDM_ERROR_NONE, error);
578 error = tdm_hwc_window_video_get_capability(hwc_wins[0], NULL);
579 ASSERT_NE(TDM_ERROR_NONE, error);
584 TEST_F(TDMHwcWindow, VideoGetCapabilitySuccessful)
586 tdm_hwc_window_video_capability video_capability;
588 for (int i = 0; i < hwc_count; i++) {
589 /* hwc_window with TDM_COMPOSITION_CLIENT dosn't support tdm_hwc_window_video_get_capability()*/
590 error = tdm_hwc_window_video_get_capability(hwc_wins[i], &video_capability);
591 ASSERT_NE(TDM_ERROR_NONE, error);
593 /*TODO:: check video capability for TDM_COMPOSITION_VIDEO*/
598 /* tdm_error tdm_hwc_window_video_get_supported_format(tdm_hwc_window *hwc_window, const tbm_format **formats, int *count); */
599 TEST_F(TDMHwcWindow, VideoGetSupportedFormatFailNull)
601 const tbm_format *formats;
604 error = tdm_hwc_window_video_get_supported_format(NULL, &formats, &count);
605 ASSERT_NE(TDM_ERROR_NONE, error);
608 error = tdm_hwc_window_video_get_supported_format(hwc_wins[0], NULL, &count);
609 error = tdm_hwc_window_video_get_supported_format(hwc_wins[0], &formats, NULL);
613 TEST_F(TDMHwcWindow, VideoGetSupportedFormatSuccessful)
615 const tbm_format *formats;
618 for (int i = 0; i < hwc_count; i++) {
619 /* hwc_window with TDM_COMPOSITION_CLIENT dosn't support tdm_hwc_window_video_get_supported_format()*/
620 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_CLIENT);
621 ASSERT_EQ(TDM_ERROR_NONE, error);
622 error = tdm_hwc_window_video_get_supported_format(hwc_wins[i], &formats, &count);
623 ASSERT_NE(TDM_ERROR_NONE, error);
625 /*TODO:: check format for TDM_COMPOSITION_VIDEO*/
629 /* tdm_error tdm_output_hwc_validate(tdm_output *output, uint32_t *num_types); */
630 TEST_F(TDMOutputHwc, ValidateFailNull)
633 error = tdm_output_hwc_validate(NULL, &num_types);
634 ASSERT_NE(TDM_ERROR_NONE, error);
637 error = tdm_output_hwc_validate(outputs[0], NULL);
638 ASSERT_NE(TDM_ERROR_NONE, error);
642 TEST_F(TDMOutputHwc, ValidateSuccessful)
645 for (int i = 0; i < output_count; i++) {
646 if (IsHwcEnable(i)) {
647 error = tdm_output_hwc_validate(outputs[i], &num_types);
648 ASSERT_EQ(TDM_ERROR_NONE, error);
650 error = tdm_output_hwc_validate(outputs[i], &num_types);
651 ASSERT_NE(TDM_ERROR_NONE, error);
656 /* tdm_error tdm_output_hwc_get_changed_composition_types(tdm_output *output,
657 uint32_t *num_elements, tdm_hwc_window **hwc_window,
658 tdm_hwc_window_composition *composition_types); */
660 /* tdm_error tdm_output_hwc_accept_changes(tdm_output *output); */
661 TEST_F(TDMOutputHwc, GetChangedCompositionTypesFailNull)
663 uint32_t num_elements;
665 error = tdm_output_hwc_get_changed_composition_types(NULL, &num_elements, NULL, NULL);
666 ASSERT_NE(TDM_ERROR_NONE, error);
669 error = tdm_output_hwc_get_changed_composition_types(outputs[0], NULL, NULL, NULL);
670 ASSERT_NE(TDM_ERROR_NONE, error);
674 TEST_F(TDMHwcWindow, GetChangedCompositionTypesSuccessful)
676 uint32_t validate_num;
677 uint32_t get_num = 0;
679 tdm_hwc_window_composition *composition_types;
680 tdm_hwc_window **hwc_wnds;
682 for (int i = 0; i < hwc_count; i++) {
683 error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_DEVICE);
684 ASSERT_EQ(TDM_ERROR_NONE, error);
688 for (int i = 0; i < output_count; i++) {
689 if (IsHwcEnable(i)) {
690 error = tdm_output_hwc_validate(outputs[i], &validate_num);
691 ASSERT_EQ(TDM_ERROR_NONE, error);
693 error = tdm_output_hwc_get_changed_composition_types(outputs[i], &get_num, NULL, NULL);
694 ASSERT_EQ(TDM_ERROR_NONE, error);
696 ASSERT_TRUE(get_num == validate_num);
697 hwc_wnds = (tdm_hwc_window **)calloc(get_num, sizeof(tdm_hwc_window *));
698 composition_types = (tdm_hwc_window_composition *)calloc(get_num, sizeof(tdm_hwc_window_composition));
700 error = tdm_output_hwc_get_changed_composition_types(outputs[i], &get_num, hwc_wnds, composition_types);
703 free(composition_types);
704 ASSERT_EQ(TDM_ERROR_NONE, error);
706 error = tdm_output_hwc_get_changed_composition_types(outputs[i], &get_num, NULL, NULL);
707 ASSERT_NE(TDM_ERROR_NONE, error);
712 static void need_validate_handler(tdm_output *output)
715 /* tdm_error tdm_output_hwc_set_need_validate_handler(tdm_output *output,
716 tdm_output_need_validate_handler hndl); */
717 TEST_F(TDMOutputHwc, SetNeedValidateHandlerFailNull)
719 error = tdm_output_hwc_set_need_validate_handler(NULL, &need_validate_handler);
720 ASSERT_NE(TDM_ERROR_NONE, error);
722 error = tdm_output_hwc_set_need_validate_handler(outputs[0], NULL);
723 ASSERT_NE(TDM_ERROR_NONE, error);
726 TEST_F(TDMOutputHwc, SetNeedValidateHandlerSuccessful)
728 for (int i = 0; i < output_count; i++) {
729 if (IsHwcEnable(i)) {
731 error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
732 ASSERT_EQ(TDM_ERROR_NONE, error);
734 /* test: second isn't allowed*/
735 error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
736 ASSERT_NE(TDM_ERROR_NONE, error);
738 error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
739 ASSERT_NE(TDM_ERROR_NONE, error);