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"
36 #include "tbm_bufmgr.h"
37 #include "tbm_drm_helper.h"
40 class TDMOutput : public ::testing::Test {
42 tdm_display *dpy = NULL;
43 int output_count = 0, master_fd = -42, tbm_fd = -42;
44 bool has_output = false;
45 tbm_bufmgr tbm_bufmgr = NULL;
46 static unsigned int handle_call;
47 static void tdm_output_change_handler_test_func(tdm_output *output,
48 tdm_output_change_type type,
52 if ( ((int) u_data) < -100) {
53 TDMOutput::handle_call++;
58 setenv("TDM_DLOG", "1", 1);
59 setenv("XDG_RUNTIME_DIR", ".", 1);
60 setenv("TBM_DLOG", "1", 1);
61 setenv("TBM_DISPLAY_SERVER", "1", 1);
62 setenv("TDM_COMMIT_PER_VBLANK", "0", 1);
64 tdm_error error = TDM_ERROR_NONE;
65 dpy = tdm_display_init(&error);
66 ASSERT_TRUE(error == TDM_ERROR_NONE);
67 ASSERT_FALSE(dpy == NULL);
68 tbm_bufmgr = tbm_bufmgr_init(-1);
69 ASSERT_FALSE(tbm_bufmgr == NULL);
70 master_fd = tbm_drm_helper_get_master_fd();
71 tbm_fd = tbm_drm_helper_get_fd();
72 error = tdm_display_get_output_count(dpy, &output_count);
73 #ifdef FAIL_ON_UNSUPPORTED
74 ASSERT_GT(output_count, 0);
82 tdm_display_deinit(dpy);
84 tbm_bufmgr_deinit(tbm_bufmgr);
87 int temp_master_fd = tbm_drm_helper_get_master_fd();
88 EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
89 if (temp_master_fd > -1)
94 int temp_tbm_fd = tbm_drm_helper_get_fd();
95 EXPECT_EQ(temp_tbm_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
100 unsetenv("TDM_DLOG");
101 unsetenv("XDG_RUNTIME_DIR");
102 unsetenv("TBM_DLOG");
103 unsetenv("TBM_DISPLAY_SERVER");
104 unsetenv("TDM_COMMIT_PER_VBLANK");
108 class TDMOutputCommit : public TDMOutput {
110 int conn_output_count = 0;
111 tdm_output ** connected_output_array = NULL;
112 tdm_output_mode** preferred_mode = NULL;
113 bool has_output = false;
116 ASSERT_NO_FATAL_FAILURE(TDMOutput::SetUp());
117 if (TDMOutput::output_count > 0) {
118 connected_output_array = (tdm_output **) calloc(TDMOutput::output_count, sizeof(tdm_output *));
119 ASSERT_FALSE(NULL == connected_output_array);
120 preferred_mode = (tdm_output_mode **) calloc(TDMOutput::output_count, sizeof(tdm_output_mode*));
121 ASSERT_FALSE(NULL == preferred_mode);
123 conn_output_count = 0;
124 for (int i = 0; i < TDMOutput::output_count; i++) {
125 tdm_error error = TDM_ERROR_NONE;
126 int output_modes_cnt = 0;
127 const tdm_output_mode* output_modes = NULL;
128 tdm_output * output = tdm_display_get_output(TDMOutput::dpy, i, &error);
129 if (TDM_ERROR_NONE != error || NULL == output)
131 tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
132 if (TDM_ERROR_NONE != tdm_output_get_conn_status(output, &status))
134 if (TDM_OUTPUT_CONN_STATUS_DISCONNECTED == status)
136 if (TDM_ERROR_NONE != tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON))
138 if(TDM_ERROR_NONE != tdm_output_get_available_modes(output,
142 for(int k = 0; k < output_modes_cnt; k++) {
143 if(output_modes[k].type & TDM_OUTPUT_MODE_TYPE_PREFERRED) {
144 preferred_mode[conn_output_count] = &output_modes[k];
148 if (NULL == preferred_mode[conn_output_count])
150 connected_output_array[conn_output_count++] = output;
152 #ifdef FAIL_ON_UNSUPPORTED
153 ASSERT_GT(conn_output_count, 0);
156 if (conn_output_count > 0)
161 for (int i = 0; i < conn_output_count; i++) {
162 EXPECT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(connected_output_array[i],
163 TDM_OUTPUT_DPMS_OFF));
165 if (connected_output_array)
166 free(connected_output_array);
168 free(preferred_mode);
169 ASSERT_NO_FATAL_FAILURE(TDMOutput::TearDown());
174 unsigned int TDMOutput::handle_call = 0;
176 TEST_F(TDMOutput, DisplayGetOutputSuccessful)
178 SKIP_FLAG(has_output);
179 for (int i = 0; i < output_count; i++) {
180 tdm_error error = TDM_ERROR_NONE;
181 ASSERT_FALSE(NULL == tdm_display_get_output(dpy, i, &error));
182 ASSERT_TRUE(TDM_ERROR_NONE == error);
186 TEST_F(TDMOutput, DisplayGetOutputSuccessfulWrongIndex)
188 SKIP_FLAG(has_output);
189 tdm_error error = TDM_ERROR_NONE;
190 ASSERT_TRUE(NULL == tdm_display_get_output(dpy, -1, &error));
191 ASSERT_TRUE(TDM_ERROR_NONE == error);
194 TEST_F(TDMOutput, DisplayGetOutputSuccessfulBigIndex)
196 SKIP_FLAG(has_output);
197 tdm_error error = TDM_ERROR_NONE;
198 ASSERT_TRUE(NULL == tdm_display_get_output(dpy, INT_MAX, &error));
199 ASSERT_TRUE(TDM_ERROR_NONE == error);
202 TEST_F(TDMOutput, DisplayGetOutputSuccessfulSmallIndex)
204 SKIP_FLAG(has_output);
205 tdm_error error = TDM_ERROR_NONE;
206 ASSERT_TRUE(NULL == tdm_display_get_output(dpy, INT_MIN, &error));
207 ASSERT_TRUE(TDM_ERROR_NONE == error);
210 TEST_F(TDMOutput, DisplayGetOutputSuccessfulErrorNull)
212 SKIP_FLAG(has_output);
213 ASSERT_FALSE(NULL == tdm_display_get_output(dpy, 0, NULL));
216 TEST_F(TDMOutput, DisplayOutputGetCapabilitiesSuccessful)
218 SKIP_FLAG(has_output);
219 for (int i = 0; i < output_count; i++) {
220 tdm_error error = TDM_ERROR_NONE;
221 tdm_output_capability capabilities = (tdm_output_capability) -42;
222 tdm_output * output = tdm_display_get_output(dpy, i, &error);
223 ASSERT_FALSE(NULL == output);
224 ASSERT_TRUE(TDM_ERROR_NONE == error);
225 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_capabilities(output, &capabilities));
226 ASSERT_FALSE(-42 == capabilities);
230 TEST_F(TDMOutput, DisplayOutputGetCapabilitiesFailAllNull)
232 SKIP_FLAG(has_output);
233 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_capabilities(NULL, NULL));
236 TEST_F(TDMOutput, DisplayOutputGetCapabilitiesFailOnlyOutput)
238 SKIP_FLAG(has_output);
239 for (int i = 0; i < output_count; i++) {
240 tdm_error error = TDM_ERROR_NONE;
241 tdm_output * output = tdm_display_get_output(dpy, i, &error);
242 ASSERT_FALSE(NULL == output);
243 ASSERT_TRUE(TDM_ERROR_NONE == error);
244 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_capabilities(output, NULL));
248 TEST_F(TDMOutput, OutputGetModelInfoSuccessful)
250 SKIP_FLAG(has_output);
251 for (int i = 0; i < output_count; i++) {
252 tdm_error error = TDM_ERROR_NONE;
253 const char * maker = NULL, * model = NULL, * name = NULL;
254 tdm_output * output = tdm_display_get_output(dpy, i, &error);
255 ASSERT_FALSE(NULL == output);
256 ASSERT_TRUE(TDM_ERROR_NONE == error);
257 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_model_info(output, &maker, &model, &name));
258 ASSERT_FALSE(NULL == maker);
259 ASSERT_FALSE(NULL == model);
260 ASSERT_FALSE(NULL == name);
264 TEST_F(TDMOutput, OutputGetModelInfoFailAllNull)
266 SKIP_FLAG(has_output);
267 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_model_info(NULL, NULL, NULL, NULL));
270 TEST_F(TDMOutput, OutputGetModelInfoSuccessfulOnlyOutput)
272 SKIP_FLAG(has_output);
273 for (int i = 0; i < output_count; i++) {
274 tdm_error error = TDM_ERROR_NONE;
275 tdm_output * output = tdm_display_get_output(dpy, i, &error);
276 ASSERT_FALSE(NULL == output);
277 ASSERT_TRUE(TDM_ERROR_NONE == error);
278 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_model_info(output, NULL, NULL, NULL));
282 TEST_F(TDMOutput, OutputGetConnStatusSuccessful)
284 SKIP_FLAG(has_output);
285 for (int i = 0; i < output_count; i++) {
286 tdm_error error = TDM_ERROR_NONE;
287 tdm_output_conn_status status = (tdm_output_conn_status) -42;
288 tdm_output * output = tdm_display_get_output(dpy, i, &error);
289 ASSERT_FALSE(NULL == output);
290 ASSERT_TRUE(TDM_ERROR_NONE == error);
291 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
292 ASSERT_FALSE(-42 == status);
296 TEST_F(TDMOutput, OutputGetConnStatusFailAllNull)
298 SKIP_FLAG(has_output);
299 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_conn_status(NULL, NULL));
302 TEST_F(TDMOutput, OutputGetConnStatusFailOnlyOutput)
304 SKIP_FLAG(has_output);
305 for (int i = 0; i < output_count; i++) {
306 tdm_error error = TDM_ERROR_NONE;
307 tdm_output * output = tdm_display_get_output(dpy, i, &error);
308 ASSERT_FALSE(NULL == output);
309 ASSERT_TRUE(TDM_ERROR_NONE == error);
310 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, NULL));
314 TEST_F(TDMOutput, OutputSetDPMSSuccessful)
316 SKIP_FLAG(has_output);
317 bool checked = false;
318 for (int i = 0; i < output_count; i++) {
319 tdm_error error = TDM_ERROR_NONE;
320 tdm_output_conn_status status;
321 tdm_output * output = tdm_display_get_output(dpy, i, &error);
322 ASSERT_FALSE(NULL == output);
323 ASSERT_TRUE(TDM_ERROR_NONE == error);
324 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
325 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
328 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
329 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_STANDBY));
330 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_SUSPEND));
331 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
333 if (false == checked) {
334 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
338 TEST_F(TDMOutput, OutputAddChangeHandlerSuccessful)
340 SKIP_FLAG(has_output);
341 bool checked = false;
342 for (int i = 0; i < output_count; i++) {
343 tdm_error error = TDM_ERROR_NONE;
344 tdm_output * output = tdm_display_get_output(dpy, i, &error);
345 ASSERT_FALSE(NULL == output);
346 ASSERT_TRUE(TDM_ERROR_NONE == error);
347 tdm_output_conn_status status;
348 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
349 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
352 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
353 tdm_output_change_handler_test_func,
355 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
356 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
357 ASSERT_GT(handle_call, 0);
359 if (false == checked) {
360 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
364 TEST_F(TDMOutput, OutputAddChangeHandlerSuccessfulFewFuncs)
366 SKIP_FLAG(has_output);
367 bool checked = false;
368 for (int i = 0; i < output_count; i++) {
369 tdm_error error = TDM_ERROR_NONE;
370 tdm_output * output = tdm_display_get_output(dpy, i, &error);
371 ASSERT_FALSE(NULL == output);
372 ASSERT_TRUE(TDM_ERROR_NONE == error);
373 tdm_output_conn_status status;
374 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
375 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
378 for (int k = 0; k < 20; k++) {
379 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
380 tdm_output_change_handler_test_func,
383 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
384 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
385 ASSERT_GT(handle_call, 20);
387 if (false == checked) {
388 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
393 TEST_F(TDMOutput, OutputAddChangeHandlerFailAllNull)
395 SKIP_FLAG(has_output);
396 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_add_change_handler(NULL, NULL, NULL));
399 TEST_F(TDMOutput, OutputAddChangeHandlerFailOnlyOutput)
401 SKIP_FLAG(has_output);
402 for (int i = 0; i < output_count; i++) {
403 tdm_error error = TDM_ERROR_NONE;
404 tdm_output * output = tdm_display_get_output(dpy, i, &error);
405 ASSERT_FALSE(NULL == output);
406 ASSERT_TRUE(TDM_ERROR_NONE == error);
407 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_add_change_handler(output, NULL, NULL));
411 TEST_F(TDMOutput, OutputAddChangeHandlerFailWrongOutput)
413 SKIP_FLAG(has_output);
414 ASSERT_EXIT({tdm_output *output = (tdm_output *) 0xBEAF;
415 tdm_output_add_change_handler(output,
416 tdm_output_change_handler_test_func,
418 exit(0);}, ::testing::ExitedWithCode(0), "");
421 TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessful)
423 SKIP_FLAG(has_output);
424 bool checked = false;
425 for (int i = 0; i < output_count; i++) {
426 tdm_error error = TDM_ERROR_NONE;
427 tdm_output * output = tdm_display_get_output(dpy, i, &error);
428 ASSERT_FALSE(NULL == output);
429 ASSERT_TRUE(TDM_ERROR_NONE == error);
430 tdm_output_conn_status status;
431 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
432 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
435 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
436 tdm_output_change_handler_test_func,
438 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
439 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
440 ASSERT_GT(handle_call, 0);
442 tdm_output_remove_change_handler(output, tdm_output_change_handler_test_func, (void *) -101);
443 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
444 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
445 ASSERT_EQ(handle_call, 0);
447 if (false == checked) {
448 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
452 TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessfulFewFuncs)
454 SKIP_FLAG(has_output);
455 bool checked = false;
456 for (int i = 0; i < output_count; i++) {
457 tdm_error error = TDM_ERROR_NONE;
458 tdm_output * output = tdm_display_get_output(dpy, i, &error);
459 ASSERT_FALSE(NULL == output);
460 ASSERT_TRUE(TDM_ERROR_NONE == error);
461 tdm_output_conn_status status;
462 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
463 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
466 for (int k = 0; k < 20; k++) {
467 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
468 tdm_output_change_handler_test_func,
471 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
472 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
473 ASSERT_GT(handle_call, 20);
475 for (int k = 0; k < 20; k++) {
476 tdm_output_remove_change_handler(output, tdm_output_change_handler_test_func, (void *) (-101-k));
478 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
479 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
480 ASSERT_EQ(handle_call, 0);
482 if (false == checked) {
483 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
487 TEST_F(TDMOutput, OutputRemoveChangeHandlerFailAllNull)
489 SKIP_FLAG(has_output);
490 ASSERT_EXIT({tdm_output_remove_change_handler(NULL, NULL, NULL);
491 exit(0);}, ::testing::ExitedWithCode(0), "");
494 TEST_F(TDMOutput, OutputRemoveChangeHandlerFailOnlyOutput)
496 SKIP_FLAG(has_output);
497 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
498 tdm_error error = TDM_ERROR_NONE;
499 tdm_output * output = tdm_display_get_output(dpy, i, &error);
500 if (NULL == output) exit(1);
501 if (TDM_ERROR_NONE != error) exit(1);
502 tdm_output_remove_change_handler(output, NULL, NULL);
503 } exit(0);}, ::testing::ExitedWithCode(0), "");
506 TEST_F(TDMOutput, OutputRemoveChangeHandlerFailWrongOutput)
508 SKIP_FLAG(has_output);
509 ASSERT_EXIT({tdm_output *output = (tdm_output *) 0xBEAF;
510 tdm_output_remove_change_handler(output,
511 tdm_output_change_handler_test_func,
513 exit(0);}, ::testing::ExitedWithCode(0), "");
516 TEST_F(TDMOutput, OutputGetOutputTypeSuccessful)
518 SKIP_FLAG(has_output);
519 for (int i = 0; i < output_count; i++) {
520 tdm_error error = TDM_ERROR_NONE;
521 tdm_output_type type = (tdm_output_type) -42;
522 tdm_output * output = tdm_display_get_output(dpy, i, &error);
523 ASSERT_FALSE(NULL == output);
524 ASSERT_TRUE(TDM_ERROR_NONE == error);
525 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_output_type(output, &type));
526 ASSERT_NE(type, -42);
530 TEST_F(TDMOutput, OutputGetOutputTypeFailNullAll)
532 SKIP_FLAG(has_output);
533 ASSERT_EXIT({if (tdm_output_get_output_type(NULL, NULL) == TDM_ERROR_NONE) exit(1);
534 exit(0);}, ::testing::ExitedWithCode(0), "");
537 TEST_F(TDMOutput, OutputGetOutputTypeFailOnlyOutput)
539 SKIP_FLAG(has_output);
540 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
541 tdm_error error = TDM_ERROR_NONE;
542 tdm_output * output = tdm_display_get_output(dpy, i, &error);
543 if (NULL == output) exit(1);
544 if (TDM_ERROR_NONE != error) exit(1);
545 if (tdm_output_get_output_type(output, NULL) == TDM_ERROR_NONE) exit(1);
547 exit(0);}, ::testing::ExitedWithCode(0), "");
550 TEST_F(TDMOutput, OutputGetLayerCountSuccessful)
552 SKIP_FLAG(has_output);
553 for (int i = 0; i < output_count; i++) {
554 tdm_error error = TDM_ERROR_NONE;
556 tdm_output * output = tdm_display_get_output(dpy, i, &error);
557 ASSERT_FALSE(NULL == output);
558 ASSERT_TRUE(TDM_ERROR_NONE == error);
559 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_layer_count(output, &count));
560 ASSERT_NE(count, -42);
564 TEST_F(TDMOutput, OutputGetLayerCountFailNullAll)
566 SKIP_FLAG(has_output);
567 ASSERT_EXIT({if (tdm_output_get_layer_count(NULL, NULL) == TDM_ERROR_NONE) exit(1);
568 exit(0);}, ::testing::ExitedWithCode(0), "");
571 TEST_F(TDMOutput, OutputGetLayerCountFailOnlyOutput)
573 SKIP_FLAG(has_output);
574 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
575 tdm_error error = TDM_ERROR_NONE;
576 tdm_output * output = tdm_display_get_output(dpy, i, &error);
577 if (NULL == output) exit(1);
578 if (TDM_ERROR_NONE != error) exit(1);
579 if (TDM_ERROR_NONE == tdm_output_get_layer_count(output, NULL)) exit(1);
581 exit(0);}, ::testing::ExitedWithCode(0), "");
584 TEST_F(TDMOutput, OutputGetAvailablePropertiesSuccessful)
586 SKIP_FLAG(has_output);
587 for (int i = 0; i < output_count; i++) {
588 tdm_error error = TDM_ERROR_NONE;
590 const tdm_prop *tdm_prop_array = (const tdm_prop *) 0xBEAF;
591 tdm_output * output = tdm_display_get_output(dpy, i, &error);
592 ASSERT_FALSE(NULL == output);
593 ASSERT_TRUE(TDM_ERROR_NONE == error);
594 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_properties(output,
597 ASSERT_NE(count, -42);
598 ASSERT_NE(tdm_prop_array, 0xBEAF);
602 TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullAll)
604 SKIP_FLAG(has_output);
605 ASSERT_EXIT({if (tdm_output_get_available_properties(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
606 exit(0);}, ::testing::ExitedWithCode(0), "");
609 TEST_F(TDMOutput, OutputGetAvailablePropertiesFailOnlyOutput)
611 SKIP_FLAG(has_output);
612 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
613 tdm_error error = TDM_ERROR_NONE;
614 tdm_output * output = tdm_display_get_output(dpy, i, &error);
615 if (NULL == output) exit(1);
616 if (TDM_ERROR_NONE != error) exit(1);
617 if (TDM_ERROR_NONE == tdm_output_get_available_properties(output, NULL, NULL)) exit(1);
619 exit(0);}, ::testing::ExitedWithCode(0), "");
622 TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullCount)
624 SKIP_FLAG(has_output);
625 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
626 tdm_error error = TDM_ERROR_NONE;
627 const tdm_prop *tdm_prop_array = NULL;
628 tdm_output * output = tdm_display_get_output(dpy, i, &error);
629 if (NULL == output) exit(1);
630 if (TDM_ERROR_NONE != error) exit(1);
631 if (TDM_ERROR_NONE == tdm_output_get_available_properties(output,
635 exit(0);}, ::testing::ExitedWithCode(0), "");
638 TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullProperty)
640 SKIP_FLAG(has_output);
641 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
642 tdm_error error = TDM_ERROR_NONE;
644 tdm_output * output = tdm_display_get_output(dpy, i, &error);
645 if (NULL == output) exit(1);
646 if (TDM_ERROR_NONE != error) exit(1);
647 if (TDM_ERROR_NONE == tdm_output_get_available_properties(output,
651 exit(0);}, ::testing::ExitedWithCode(0), "");
654 TEST_F(TDMOutput, OutputGetAvailableModesSuccessful)
656 SKIP_FLAG(has_output);
657 for (int i = 0; i < output_count; i++) {
658 tdm_error error = TDM_ERROR_NONE;
660 const tdm_output_mode *modes_array = (const tdm_output_mode *) 0xBEAF;
661 tdm_output * output = tdm_display_get_output(dpy, i, &error);
662 ASSERT_FALSE(NULL == output);
663 ASSERT_TRUE(TDM_ERROR_NONE == error);
664 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_modes(output,
667 ASSERT_NE(count, -42);
668 ASSERT_NE(modes_array, 0xBEAF);
672 TEST_F(TDMOutput, OutputGetAvailableModesFailNullAll)
674 SKIP_FLAG(has_output);
675 ASSERT_EXIT({if (tdm_output_get_available_modes(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
676 exit(0);}, ::testing::ExitedWithCode(0), "");
679 TEST_F(TDMOutput, OutputGetAvailableModesFailOnlyOutput)
681 SKIP_FLAG(has_output);
682 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
683 tdm_error error = TDM_ERROR_NONE;
684 tdm_output * output = tdm_display_get_output(dpy, i, &error);
685 if (NULL == output) exit(1);
686 if (TDM_ERROR_NONE != error) exit(1);
687 if (TDM_ERROR_NONE == tdm_output_get_available_modes(output, NULL, NULL)) exit(1);
689 exit(0);}, ::testing::ExitedWithCode(0), "");
692 TEST_F(TDMOutput, OutputGetAvailableModesFailNullCount)
694 SKIP_FLAG(has_output);
695 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
696 tdm_error error = TDM_ERROR_NONE;
697 const tdm_output_mode *modes_array = NULL;
698 tdm_output * output = tdm_display_get_output(dpy, i, &error);
699 if (NULL == output) exit(1);
700 if (TDM_ERROR_NONE != error) exit(1);
701 if (TDM_ERROR_NONE == tdm_output_get_available_modes(output,
705 exit(0);}, ::testing::ExitedWithCode(0), "");
708 TEST_F(TDMOutput, OutputGetAvailableModesFailNullModes)
710 SKIP_FLAG(has_output);
711 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
712 tdm_error error = TDM_ERROR_NONE;
714 tdm_output * output = tdm_display_get_output(dpy, i, &error);
715 if (NULL == output) exit(1);
716 if (TDM_ERROR_NONE != error) exit(1);
717 if (TDM_ERROR_NONE == tdm_output_get_available_modes(output,
721 exit(0);}, ::testing::ExitedWithCode(0), "");
724 TEST_F(TDMOutput, OutputGetAvailableSizeSuccessful)
726 SKIP_FLAG(has_output);
727 for (int i = 0; i < output_count; i++) {
728 tdm_error error = TDM_ERROR_NONE;
729 int min_w = -42, min_h = -42, max_w = -42, max_h = -42, preferred_align = -42;
730 tdm_output * output = tdm_display_get_output(dpy, i, &error);
731 ASSERT_FALSE(NULL == output);
732 ASSERT_TRUE(TDM_ERROR_NONE == error);
733 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_size(output, &min_w, &min_h,
734 &max_w, &max_h, &preferred_align));
735 ASSERT_NE(min_w, -42);
736 ASSERT_NE(min_h, -42);
737 ASSERT_NE(max_w, -42);
738 ASSERT_NE(max_h, -42);
739 ASSERT_NE(preferred_align, -42);
743 TEST_F(TDMOutput, OutputGetAvailableSizeFailNullAll)
745 SKIP_FLAG(has_output);
746 ASSERT_EXIT({if (tdm_output_get_available_size(NULL, NULL, NULL,
747 NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
748 exit(0);}, ::testing::ExitedWithCode(0), "");
751 TEST_F(TDMOutput, OutputGetAvailableSizeSuccessfulOnlyOutput)
753 SKIP_FLAG(has_output);
754 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
755 tdm_error error = TDM_ERROR_NONE;
756 tdm_output * output = tdm_display_get_output(dpy, i, &error);
757 if (NULL == output) exit(1);
758 if (TDM_ERROR_NONE != error) exit(1);
759 if (tdm_output_get_available_size(output, NULL, NULL,
760 NULL, NULL, NULL) != TDM_ERROR_NONE) exit(1);
762 exit(0);}, ::testing::ExitedWithCode(0), "");
765 TEST_F(TDMOutput, OutputGetCursorAvailableSizeSuccessful)
767 SKIP_FLAG(has_output);
768 for (int i = 0; i < output_count; i++) {
769 tdm_error error = TDM_ERROR_NONE;
770 int min_w = -42, min_h = -42, max_w = -42, max_h = -42, preferred_align = -42;
771 tdm_output * output = tdm_display_get_output(dpy, i, &error);
772 ASSERT_FALSE(NULL == output);
773 ASSERT_TRUE(TDM_ERROR_NONE == error);
774 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_cursor_available_size(output, &min_w, &min_h,
775 &max_w, &max_h, &preferred_align));
776 ASSERT_NE(min_w, -42);
777 ASSERT_NE(min_h, -42);
778 ASSERT_NE(max_w, -42);
779 ASSERT_NE(max_h, -42);
780 ASSERT_NE(preferred_align, -42);
784 TEST_F(TDMOutput, OutputGetCursorAvailableSizeFailNullAll)
786 SKIP_FLAG(has_output);
787 ASSERT_EXIT({if (tdm_output_get_cursor_available_size(NULL, NULL, NULL,
788 NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
789 exit(0);}, ::testing::ExitedWithCode(0), "");
792 TEST_F(TDMOutput, OutputGetCursorAvailableSizeSuccessfulOnlyOutput)
794 SKIP_FLAG(has_output);
795 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
796 tdm_error error = TDM_ERROR_NONE;
797 tdm_output * output = tdm_display_get_output(dpy, i, &error);
798 if (NULL == output) exit(1);
799 if (TDM_ERROR_NONE != error) exit(1);
800 if (tdm_output_get_cursor_available_size(output, NULL, NULL,
801 NULL, NULL, NULL) != TDM_ERROR_NONE) exit(1);
803 exit(0);}, ::testing::ExitedWithCode(0), "");
806 TEST_F(TDMOutput, OutputGetPhysicalSizeSuccessful)
808 SKIP_FLAG(has_output);
809 for (int i = 0; i < output_count; i++) {
810 tdm_error error = TDM_ERROR_NONE;
811 unsigned int mmWidth = UINT_MAX, mmHeight = UINT_MAX;
812 tdm_output * output = tdm_display_get_output(dpy, i, &error);
813 ASSERT_FALSE(NULL == output);
814 ASSERT_TRUE(TDM_ERROR_NONE == error);
815 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_physical_size(output, &mmWidth, &mmHeight));
816 ASSERT_NE(mmWidth, UINT_MAX);
817 ASSERT_NE(mmHeight, UINT_MAX);
821 TEST_F(TDMOutput, OutputGetPhysicalSizeFailNullAll)
823 SKIP_FLAG(has_output);
824 ASSERT_EXIT({if (tdm_output_get_physical_size(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
825 exit(0);}, ::testing::ExitedWithCode(0), "");
828 TEST_F(TDMOutput, OutputGetPhysicalSuccessfulOnlyOutput)
830 SKIP_FLAG(has_output);
831 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
832 tdm_error error = TDM_ERROR_NONE;
833 tdm_output * output = tdm_display_get_output(dpy, i, &error);
834 if (NULL == output) exit(1);
835 if (TDM_ERROR_NONE != error) exit(1);
836 if (tdm_output_get_physical_size(output, NULL, NULL) != TDM_ERROR_NONE) exit(1);
838 exit(0);}, ::testing::ExitedWithCode(0), "");
841 TEST_F(TDMOutput, OutputGetSubpixelSuccessful)
843 SKIP_FLAG(has_output);
844 for (int i = 0; i < output_count; i++) {
845 tdm_error error = TDM_ERROR_NONE;
846 unsigned int subpixel = UINT_MAX;
847 tdm_output * output = tdm_display_get_output(dpy, i, &error);
848 ASSERT_FALSE(NULL == output);
849 ASSERT_TRUE(TDM_ERROR_NONE == error);
850 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_subpixel(output, &subpixel));
851 ASSERT_NE(subpixel, UINT_MAX);
855 TEST_F(TDMOutput, OutputGetSubpixelFailNullAll)
857 SKIP_FLAG(has_output);
858 ASSERT_EXIT({if (tdm_output_get_subpixel(NULL, NULL) == TDM_ERROR_NONE) exit(1);
859 exit(0);}, ::testing::ExitedWithCode(0), "");
862 TEST_F(TDMOutput, OutputGetSubpixelFailOnlyOutput)
864 SKIP_FLAG(has_output);
865 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
866 tdm_error error = TDM_ERROR_NONE;
867 tdm_output * output = tdm_display_get_output(dpy, i, &error);
868 if (NULL == output) exit(1);
869 if (TDM_ERROR_NONE != error) exit(1);
870 if (tdm_output_get_subpixel(output, NULL) == TDM_ERROR_NONE) exit(1);
872 exit(0);}, ::testing::ExitedWithCode(0), "");
875 TEST_F(TDMOutput, OutputGetPipeSuccessful)
877 SKIP_FLAG(has_output);
878 for (int i = 0; i < output_count; i++) {
879 tdm_error error = TDM_ERROR_NONE;
880 unsigned int pipe = UINT_MAX;
881 tdm_output * output = tdm_display_get_output(dpy, i, &error);
882 ASSERT_FALSE(NULL == output);
883 ASSERT_TRUE(TDM_ERROR_NONE == error);
884 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_pipe(output, &pipe));
885 ASSERT_NE(pipe, UINT_MAX);
889 TEST_F(TDMOutput, OutputGetPipeFailNullAll)
891 SKIP_FLAG(has_output);
892 ASSERT_EXIT({if (tdm_output_get_pipe(NULL, NULL) == TDM_ERROR_NONE) exit(1);
893 exit(0);}, ::testing::ExitedWithCode(0), "");
896 TEST_F(TDMOutput, OutputGetPipeFailOnlyOutput)
898 SKIP_FLAG(has_output);
899 ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
900 tdm_error error = TDM_ERROR_NONE;
901 tdm_output * output = tdm_display_get_output(dpy, i, &error);
902 if (NULL == output) exit(1);
903 if (TDM_ERROR_NONE != error) exit(1);
904 if (tdm_output_get_pipe(output, NULL) == TDM_ERROR_NONE) exit(1);
906 exit(0);}, ::testing::ExitedWithCode(0), "");
909 TEST_F(TDMOutput, OutputSetPropertySuccessful)
911 SKIP_FLAG(has_output);
912 for (int i = 0; i < output_count; i++) {
913 tdm_error error = TDM_ERROR_NONE;
914 tdm_value value = {.u32 = 0};
915 tdm_output * output = tdm_display_get_output(dpy, i, &error);
916 ASSERT_FALSE(NULL == output);
917 ASSERT_TRUE(TDM_ERROR_NONE == error);
918 error = tdm_output_set_property(output, UINT_MAX, value);
919 ASSERT_TRUE(error == TDM_ERROR_NOT_IMPLEMENTED || error == TDM_ERROR_OPERATION_FAILED);
923 TEST_F(TDMOutput, OutputSetPropertyFailNullAll)
925 SKIP_FLAG(has_output);
926 ASSERT_EXIT({tdm_error error = TDM_ERROR_NONE;
927 tdm_value value = {.u32 = 0};
928 error = tdm_output_set_property(NULL, 0, value);
929 if (error == TDM_ERROR_NONE || error == TDM_ERROR_NOT_IMPLEMENTED ||
930 error == TDM_ERROR_OPERATION_FAILED) exit(1);
931 exit(0);}, ::testing::ExitedWithCode(0), "");
934 TEST_F(TDMOutput, OutputGetPropertySuccessful)
936 SKIP_FLAG(has_output);
937 for (int i = 0; i < output_count; i++) {
938 tdm_error error = TDM_ERROR_NONE;
939 tdm_value value = {.u32 = 0};
940 tdm_output * output = tdm_display_get_output(dpy, i, &error);
941 ASSERT_FALSE(NULL == output);
942 ASSERT_TRUE(TDM_ERROR_NONE == error);
943 error = tdm_output_get_property(output, UINT_MAX, &value);
944 ASSERT_TRUE(error == TDM_ERROR_NOT_IMPLEMENTED || error == TDM_ERROR_OPERATION_FAILED);
948 TEST_F(TDMOutput, OutputGetPropertyFailNullAll)
950 SKIP_FLAG(has_output);
951 ASSERT_EXIT({tdm_error error = TDM_ERROR_NONE;
952 error = tdm_output_get_property(NULL, 0, NULL);
953 if (error == TDM_ERROR_NONE || error == TDM_ERROR_NOT_IMPLEMENTED ||
954 error == TDM_ERROR_OPERATION_FAILED) exit(1);
955 exit(0);}, ::testing::ExitedWithCode(0), "");
958 TEST_F(TDMOutputCommit, OutputCommit)
960 SKIP_FLAG(has_output);
961 for (int i = 0; i < conn_output_count; i++) {
962 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_mode(connected_output_array[i], preferred_mode[i]));
963 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_commit(connected_output_array[i], 0, NULL, NULL));
964 /* TODO: use a commit handler instead of an usleep to wait when
965 * commit will be applied */
970 TEST_F(TDMOutputCommit, DISABLED_OutputWaitVBlank)
972 SKIP_FLAG(has_output);