utest: fix all failed tests and add new tests
[platform/core/uifw/libtdm.git] / utests / src / ut_tdm_output.cpp
1 /**************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
4  *
5  * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
6  * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
7  * Contact: Roman Marchenko <r.marchenko@samsung.com>
8  *
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:
16  *
17  * The above copyright notice and this permission notice (including the
18  * next paragraph) shall be included in all copies or substantial portions
19  * of the Software.
20  *
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.
28  *
29 **************************************************************************/
30
31 #include "gtest/gtest.h"
32 #include "ut_common.h"
33 #include <climits>
34 #include "tdm.h"
35 extern "C" {
36 #include "tbm_bufmgr.h"
37 #include "tbm_drm_helper.h"
38 }
39 #include <vector>
40 #include <sys/epoll.h>
41 #include <sys/timerfd.h>
42 #include <pthread.h>
43
44 class TDMOutput : public ::testing::Test {
45 protected:
46         tdm_display *dpy = NULL;
47         int output_count = 0, master_fd = -42, tbm_fd = -42;
48         bool has_output = false;
49         tbm_bufmgr tbm_bufmgr = NULL;
50         static unsigned int handle_call;
51         static void tdm_output_change_handler_test_func(tdm_output *output,
52                                                                                                         tdm_output_change_type type,
53                                                                                                         tdm_value value,
54                                                                                                         void *u_data)
55         {
56                 if ( ((intptr_t) u_data) < -100) {
57                         TDMOutput::handle_call++;
58                 }
59         }
60         virtual void SetEnvs()
61         {
62                 setenv("TDM_DEBUG_MODULE", "all", 1);
63                 setenv("TDM_DEBUG", "1", 1);
64                 setenv("TDM_DLOG", "1", 1);
65                 setenv("XDG_RUNTIME_DIR", "/run", 1);
66                 setenv("TBM_DLOG", "1", 1);
67                 setenv("TBM_DISPLAY_SERVER", "1", 1);
68                 setenv("TDM_COMMIT_PER_VBLANK", "0", 1);
69         }
70
71         virtual void UnsetEnvs()
72         {
73                 unsetenv("TDM_DEBUG_MODULE");
74                 unsetenv("TDM_DEBUG");
75                 unsetenv("TDM_DLOG");
76                 unsetenv("XDG_RUNTIME_DIR");
77                 unsetenv("TBM_DLOG");
78                 unsetenv("TBM_DISPLAY_SERVER");
79                 unsetenv("TDM_COMMIT_PER_VBLANK");
80         }
81
82         void SetUp(void)
83         {
84                 SetEnvs();
85
86                 tdm_error error = TDM_ERROR_NONE;
87                 dpy = tdm_display_init(&error);
88                 ASSERT_TRUE(error == TDM_ERROR_NONE);
89                 ASSERT_FALSE(dpy == NULL);
90                 tbm_bufmgr = tbm_bufmgr_init(-1);
91                 ASSERT_FALSE(tbm_bufmgr == NULL);
92                 master_fd = tbm_drm_helper_get_master_fd();
93                 tbm_fd = tbm_drm_helper_get_fd();
94                 error = tdm_display_get_output_count(dpy, &output_count);
95 #ifdef FAIL_ON_UNSUPPORTED
96                 ASSERT_GT(output_count, 0);
97 #endif
98                 if (output_count > 0)
99                         has_output = true;
100                 handle_call = 0;
101         }
102         void TearDown(void)
103         {
104                 tdm_display_deinit(dpy);
105                 dpy = NULL;
106                 tbm_bufmgr_deinit(tbm_bufmgr);
107                 tbm_bufmgr = NULL;
108                 if (master_fd > -1) {
109                         int temp_master_fd = tbm_drm_helper_get_master_fd();
110                         EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
111                         if (temp_master_fd > -1)
112                                 exit(1);
113                         close(master_fd);
114                 }
115                 if (tbm_fd > -1) {
116                         int temp_tbm_fd = tbm_drm_helper_get_fd();
117                         EXPECT_EQ(temp_tbm_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
118                         if (temp_tbm_fd > -1)
119                                 exit(1);
120                         close(tbm_fd);
121                 }
122
123                 UnsetEnvs();
124         }
125 };
126
127 class TDMOutputHWC : public TDMOutput {
128         void SetEnvs(void)
129         {
130                 TDMOutput::SetEnvs();
131                 setenv("TDM_HWC", "1", 1);
132         }
133         void UnsetEnvs(void)
134         {
135                 TDMOutput::UnsetEnvs();
136                 unsetenv("TDM_HWC");
137         }
138 };
139
140 class TDMOutputThread : public TDMOutput {
141         void SetEnvs(void)
142         {
143
144                 TDMOutput::SetEnvs();
145                 setenv("TDM_THREAD", "1", 1);
146         }
147         void UnsetEnvs(void)
148         {
149                 TDMOutput::UnsetEnvs();
150                 unsetenv("TDM_THREAD");
151         }
152 };
153
154 class TDMOutputCommit : public TDMOutput {
155 private:
156         int epFd = -1;
157         int timerFd = -1;
158         int tdmFd = -1;
159         static const int timeLimitSec = 1;
160         static const int timeLimitNsec = 0;
161 protected:
162         int conn_output_count = 0;
163         tdm_output ** connected_output_array = NULL;
164         const tdm_output_mode** preferred_mode = NULL;
165         bool has_output = false;
166         std::vector<std::vector<tdm_layer *>> layers_array;
167         std::vector<tbm_surface_h> buffers;
168         static unsigned int utOutputCommitHandlerCounter;
169         static void UtOutputCommitHandler(tdm_output *output, unsigned int sequence,
170                                                            unsigned int tv_sec, unsigned int tv_usec,
171                                                            void *user_data)
172         {
173                 utOutputCommitHandlerCounter++;
174         }
175
176         static unsigned int utOutputVblankHandlerCounter;
177         static void UtOutputVblankHandler(tdm_output *output, unsigned int sequence,
178                                                            unsigned int tv_sec, unsigned int tv_usec,
179                                                            void *user_data)
180         {
181                 utOutputVblankHandlerCounter++;
182         }
183         friend void *UtOutputRemoveChangeHandlerSuccessfulThread(void *ptr);
184
185         void SetUp(void)
186         {
187                 struct epoll_event ep;
188
189                 utOutputCommitHandlerCounter = 0;
190                 utOutputVblankHandlerCounter = 0;
191
192                 ASSERT_NO_FATAL_FAILURE(TDMOutput::SetUp());
193                 if (TDMOutput::output_count > 0) {
194                         connected_output_array = (tdm_output **) calloc(TDMOutput::output_count, sizeof(tdm_output *));
195                         ASSERT_FALSE(NULL == connected_output_array);
196                         preferred_mode = (const tdm_output_mode **) calloc(TDMOutput::output_count, sizeof(tdm_output_mode*));
197                         ASSERT_FALSE(NULL == preferred_mode);
198                 }
199                 conn_output_count = 0;
200                 for (int i = 0; i < TDMOutput::output_count; i++) {
201                         tdm_error error = TDM_ERROR_NONE;
202                         int output_modes_cnt = 0;
203                         int layer_count = 0;
204                         const tdm_output_mode* output_modes = NULL;
205                         tdm_output * output = tdm_display_get_output(TDMOutput::dpy, i, &error);
206                         std::vector<tdm_layer *> layers;
207                         if (TDM_ERROR_NONE != error || NULL == output)
208                                 continue;
209                         tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
210                         if (TDM_ERROR_NONE != tdm_output_get_conn_status(output, &status))
211                                 continue;
212                         if (TDM_OUTPUT_CONN_STATUS_DISCONNECTED == status)
213                                 continue;
214                         if (TDM_ERROR_NONE != tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON))
215                                 continue;
216                         if(TDM_ERROR_NONE != tdm_output_get_available_modes(output,
217                                                                                                                                 &output_modes,
218                                                                                                                                 &output_modes_cnt))
219                                 continue;
220                         for(int k = 0; k < output_modes_cnt; k++) {
221                                 if(output_modes[k].type & TDM_OUTPUT_MODE_TYPE_PREFERRED) {
222                                         preferred_mode[conn_output_count] = &output_modes[k];
223                                         break;
224                                 }
225                         }
226                         if (NULL == preferred_mode[conn_output_count])
227                                 continue;
228
229                         if (TDM_ERROR_NONE != tdm_output_get_layer_count(output, &layer_count))
230                                 continue;
231                         if (0 == layer_count)
232                                 continue;
233
234                         for (int i = 0; i < layer_count; ++i) {
235                                 tdm_layer *layer;
236                                 layer = tdm_output_get_layer(output, i, &error);
237                                 if (layer == nullptr)
238                                         continue;
239                                 layers.push_back(layer);
240                         }
241                         connected_output_array[conn_output_count++] = output;
242                         layers_array.push_back(layers);
243                 }
244 #ifdef FAIL_ON_UNSUPPORTED
245                 ASSERT_GT(conn_output_count, 0);
246 #endif
247
248                 if (conn_output_count > 0)
249                         has_output = true;
250
251                 epFd = epoll_create1(0);
252                 ASSERT_TRUE(epFd != -1);
253
254                 timerFd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
255                 ASSERT_TRUE(timerFd != -1);
256
257                 memset(&ep, 0, sizeof ep);
258                 ep.events |= EPOLLIN;
259                 ep.data.fd = timerFd;
260                 ASSERT_TRUE(epoll_ctl(epFd, EPOLL_CTL_ADD, timerFd, &ep) == 0);
261
262                 ASSERT_TRUE(tdm_display_get_fd(dpy, &tdmFd) == TDM_ERROR_NONE);
263
264                 memset(&ep, 0, sizeof ep);
265                 ep.events |= EPOLLIN;
266                 ep.data.fd = tdmFd;
267                 ASSERT_TRUE(epoll_ctl(epFd, EPOLL_CTL_ADD, tdmFd, &ep) == 0);
268         }
269         void TearDown(void)
270         {
271                 for (size_t i = 0; i < layers_array.size(); ++i) {
272                         for (tdm_layer *layer : layers_array[i]) {
273                                 tdm_layer_unset_buffer(layer);
274                         }
275                 }
276
277                 for (tbm_surface_h buffer : buffers) {
278                         tbm_surface_destroy(buffer);
279                 }
280
281                 for (int i = 0; i < conn_output_count; i++) {
282                         EXPECT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(connected_output_array[i],
283                                                                                                                           TDM_OUTPUT_DPMS_OFF));
284                 }
285                 if (connected_output_array)
286                         free(connected_output_array);
287                 if (preferred_mode)
288                         free(preferred_mode);
289                 ASSERT_NO_FATAL_FAILURE(TDMOutput::TearDown());
290         }
291
292         tbm_surface_h UtCreateBuffer(int width, int height, tbm_format format)
293         {
294                 tbm_surface_h buffer;
295
296                 buffer = tbm_surface_internal_create_with_flags(width, height, format, TBM_BO_SCANOUT);
297
298                 if (buffer)
299                         buffers.push_back(buffer);
300
301                 return buffer;
302         }
303
304         void UtPrepareToCommit()
305         {
306                 for (size_t i = 0; i < layers_array.size(); ++i) {
307                         for (tdm_layer *layer : layers_array[i]) {
308                                 int w, h;
309                                 tdm_error error;
310                                 tdm_layer_capability lcapabilities;
311                                 tbm_surface_h buffer;
312                                 tdm_info_layer layer_info = {0};
313
314                                 w = preferred_mode[i]->hdisplay;
315                                 h = preferred_mode[i]->vdisplay;
316
317                                 error = tdm_output_set_mode(connected_output_array[i], preferred_mode[i]);
318                                 ASSERT_EQ(TDM_ERROR_NONE, error);
319
320                                 error = tdm_layer_get_capabilities(layer, &lcapabilities);
321                                 ASSERT_EQ(TDM_ERROR_NONE, error);
322                                 if (!(lcapabilities & TDM_LAYER_CAPABILITY_PRIMARY)) {
323                                         w = w / 2;
324                                         h = h / 2;
325                                 }
326
327                                 buffer = UtCreateBuffer(w, h, TBM_FORMAT_ARGB8888);
328                                 ASSERT_NE(nullptr, buffer);
329
330                                 layer_info.src_config.size.h = w;
331                                 layer_info.src_config.size.v = h;
332                                 layer_info.src_config.pos.x = 0;
333                                 layer_info.src_config.pos.y = 0;
334                                 layer_info.src_config.pos.w = w;
335                                 layer_info.src_config.pos.h = h;
336                                 layer_info.src_config.format = TBM_FORMAT_ARGB8888;
337                                 layer_info.dst_pos.x = 0;
338                                 layer_info.dst_pos.y = 0;
339                                 layer_info.dst_pos.w = w;
340                                 layer_info.dst_pos.h = h;
341                                 layer_info.transform = TDM_TRANSFORM_NORMAL;
342
343                                 error = tdm_layer_set_info(layer, &layer_info);
344                                 ASSERT_EQ(TDM_ERROR_NONE, error);
345
346                                 error = tdm_layer_set_buffer(layer, buffer);
347                                 ASSERT_EQ(TDM_ERROR_NONE, error);
348                         }
349                 }
350         }
351
352         void UtHandleEvent(unsigned int & wait_var, unsigned int num)
353         {
354                 struct itimerspec its;
355                 int count;
356                 struct epoll_event ep_event[2];
357
358                 if (wait_var == num)
359                         return;
360
361                 its.it_interval.tv_sec = 0;
362                 its.it_interval.tv_nsec = 0;
363                 its.it_value.tv_sec = timeLimitSec;
364                 its.it_value.tv_nsec = timeLimitNsec;
365
366                 ASSERT_TRUE(timerfd_settime(timerFd, 0, &its, NULL) == 0);
367
368                 while (1) {
369                         count = epoll_wait(epFd, ep_event, sizeof(ep_event), -1);
370                         ASSERT_TRUE(count >= 0);
371
372                         for (int i = 0; i < count; i++) {
373                                 if (ep_event[i].data.fd == timerFd) {
374                                         return;
375                                 } else {
376                                         ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
377                                         if (wait_var == num)
378                                                 return;
379                                 }
380                         }
381                 }
382         }
383
384         void UtHandleCommitEvent()
385         {
386                 UtHandleEvent(utOutputCommitHandlerCounter, (unsigned int)conn_output_count);
387         }
388
389         void UtHandleVblankEvent()
390         {
391                 UtHandleEvent(utOutputVblankHandlerCounter, conn_output_count);
392         }
393 };
394
395 class TDMOutputCommitPerVblankEnabled : public TDMOutputCommit {
396         void SetEnvs(void)
397         {
398
399                 TDMOutputCommit::SetEnvs();
400                 setenv("TDM_COMMIT_PER_VBLANK", "1", 1);
401         }
402         void UnsetEnvs(void)
403         {
404                 TDMOutputCommit::UnsetEnvs();
405                 unsetenv("TDM_COMMIT_PER_VBLANK");
406         }
407 };
408
409 class TDMOutputCommitThread : public TDMOutputCommit {
410         void SetEnvs(void)
411         {
412                 TDMOutputCommit::SetEnvs();
413                 setenv("TDM_THREAD", "1", 1);
414         }
415
416         void UnsetEnvs(void)
417         {
418                 TDMOutputCommit::UnsetEnvs();
419                 unsetenv("TDM_THREAD");
420         }
421 };
422
423 unsigned int TDMOutput::handle_call = 0;
424 unsigned int TDMOutputCommit::utOutputCommitHandlerCounter = 0;
425 unsigned int TDMOutputCommit::utOutputVblankHandlerCounter = 0;
426
427 TEST_F(TDMOutput, DisplayGetOutputSuccessful)
428 {
429         SKIP_FLAG(has_output);
430         for (int i = 0; i < output_count; i++) {
431                 tdm_error error = TDM_ERROR_NONE;
432                 ASSERT_FALSE(NULL == tdm_display_get_output(dpy, i, &error));
433                 ASSERT_TRUE(TDM_ERROR_NONE == error);
434         }
435 }
436
437 TEST_F(TDMOutput, DisplayGetOutputSuccessfulWrongIndex)
438 {
439         SKIP_FLAG(has_output);
440         tdm_error error = TDM_ERROR_NONE;
441         ASSERT_TRUE(NULL == tdm_display_get_output(dpy, -1, &error));
442         ASSERT_TRUE(TDM_ERROR_NONE == error);
443 }
444
445 TEST_F(TDMOutput, DisplayGetOutputSuccessfulBigIndex)
446 {
447         SKIP_FLAG(has_output);
448         tdm_error error = TDM_ERROR_NONE;
449         ASSERT_TRUE(NULL == tdm_display_get_output(dpy, INT_MAX, &error));
450         ASSERT_TRUE(TDM_ERROR_NONE == error);
451 }
452
453 TEST_F(TDMOutput, DisplayGetOutputSuccessfulSmallIndex)
454 {
455         SKIP_FLAG(has_output);
456         tdm_error error = TDM_ERROR_NONE;
457         ASSERT_TRUE(NULL == tdm_display_get_output(dpy, INT_MIN, &error));
458         ASSERT_TRUE(TDM_ERROR_NONE == error);
459 }
460
461 TEST_F(TDMOutput, DisplayGetOutputSuccessfulErrorNull)
462 {
463         SKIP_FLAG(has_output);
464         ASSERT_FALSE(NULL == tdm_display_get_output(dpy, 0, NULL));
465 }
466
467 TEST_F(TDMOutput, DisplayOutputGetCapabilitiesSuccessful)
468 {
469         SKIP_FLAG(has_output);
470         for (int i = 0; i < output_count; i++) {
471                 tdm_error error = TDM_ERROR_NONE;
472                 tdm_output_capability capabilities = (tdm_output_capability) -42;
473                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
474                 ASSERT_FALSE(NULL == output);
475                 ASSERT_TRUE(TDM_ERROR_NONE == error);
476                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_capabilities(output, &capabilities));
477                 ASSERT_FALSE(-42 == capabilities);
478         }
479 }
480
481 TEST_F(TDMOutput, DisplayOutputGetCapabilitiesFailAllNull)
482 {
483         SKIP_FLAG(has_output);
484         ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_capabilities(NULL, NULL));
485 }
486
487 TEST_F(TDMOutput, DisplayOutputGetCapabilitiesFailOnlyOutput)
488 {
489         SKIP_FLAG(has_output);
490         for (int i = 0; i < output_count; i++) {
491                 tdm_error error = TDM_ERROR_NONE;
492                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
493                 ASSERT_FALSE(NULL == output);
494                 ASSERT_TRUE(TDM_ERROR_NONE == error);
495                 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_capabilities(output, NULL));
496         }
497 }
498
499 TEST_F(TDMOutput, OutputGetModelInfoSuccessful)
500 {
501         SKIP_FLAG(has_output);
502         for (int i = 0; i < output_count; i++) {
503                 tdm_error error = TDM_ERROR_NONE;
504                 const char * maker = NULL, * model = NULL, * name = NULL;
505                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
506                 ASSERT_FALSE(NULL == output);
507                 ASSERT_TRUE(TDM_ERROR_NONE == error);
508                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_model_info(output, &maker, &model, &name));
509                 ASSERT_FALSE(NULL == maker);
510                 ASSERT_FALSE(NULL == model);
511                 ASSERT_FALSE(NULL == name);
512         }
513 }
514
515 TEST_F(TDMOutput, OutputGetModelInfoFailAllNull)
516 {
517         SKIP_FLAG(has_output);
518         ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_model_info(NULL, NULL, NULL, NULL));
519 }
520
521 TEST_F(TDMOutput, OutputGetModelInfoSuccessfulOnlyOutput)
522 {
523         SKIP_FLAG(has_output);
524         for (int i = 0; i < output_count; i++) {
525                 tdm_error error = TDM_ERROR_NONE;
526                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
527                 ASSERT_FALSE(NULL == output);
528                 ASSERT_TRUE(TDM_ERROR_NONE == error);
529                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_model_info(output, NULL, NULL, NULL));
530         }
531 }
532
533 TEST_F(TDMOutput, OutputGetConnStatusSuccessful)
534 {
535         SKIP_FLAG(has_output);
536         for (int i = 0; i < output_count; i++) {
537                 tdm_error error = TDM_ERROR_NONE;
538                 tdm_output_conn_status status = (tdm_output_conn_status) -42;
539                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
540                 ASSERT_FALSE(NULL == output);
541                 ASSERT_TRUE(TDM_ERROR_NONE == error);
542                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
543                 ASSERT_FALSE(-42 == status);
544         }
545 }
546
547 TEST_F(TDMOutput, OutputGetConnStatusFailAllNull)
548 {
549         SKIP_FLAG(has_output);
550         ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_conn_status(NULL, NULL));
551 }
552
553 TEST_F(TDMOutput, OutputGetConnStatusFailOnlyOutput)
554 {
555         SKIP_FLAG(has_output);
556         for (int i = 0; i < output_count; i++) {
557                 tdm_error error = TDM_ERROR_NONE;
558                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
559                 ASSERT_FALSE(NULL == output);
560                 ASSERT_TRUE(TDM_ERROR_NONE == error);
561                 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, NULL));
562         }
563 }
564
565 TEST_F(TDMOutput, OutputSetDPMSSuccessful)
566 {
567         SKIP_FLAG(has_output);
568         bool checked = false;
569         for (int i = 0; i < output_count; i++) {
570                 tdm_error error = TDM_ERROR_NONE;
571                 tdm_output_conn_status status;
572                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
573                 ASSERT_FALSE(NULL == output);
574                 ASSERT_TRUE(TDM_ERROR_NONE == error);
575                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
576                 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
577                         continue;
578                 checked = true;
579                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
580                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_STANDBY));
581                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_SUSPEND));
582                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
583         }
584         if (false == checked) {
585                 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
586         }
587 }
588
589 TEST_F(TDMOutput, OutputAddChangeHandlerSuccessful)
590 {
591         SKIP_FLAG(has_output);
592         bool checked = false;
593         for (int i = 0; i < output_count; i++) {
594                 tdm_error error = TDM_ERROR_NONE;
595                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
596                 ASSERT_FALSE(NULL == output);
597                 ASSERT_TRUE(TDM_ERROR_NONE == error);
598                 tdm_output_conn_status status;
599                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
600                 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
601                         continue;
602                 checked = true;
603                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
604                                                                                                                                         tdm_output_change_handler_test_func,
605                                                                                                                                         (void *) -101));
606                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
607                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
608                 ASSERT_GT(handle_call, 0);
609         }
610         if (false == checked) {
611                 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
612         }
613 }
614
615 TEST_F(TDMOutput, OutputAddChangeHandlerSuccessfulFewFuncs)
616 {
617         SKIP_FLAG(has_output);
618         bool checked = false;
619         for (int i = 0; i < output_count; i++) {
620                 tdm_error error = TDM_ERROR_NONE;
621                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
622                 ASSERT_FALSE(NULL == output);
623                 ASSERT_TRUE(TDM_ERROR_NONE == error);
624                 tdm_output_conn_status status;
625                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
626                 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
627                         continue;
628                 checked = true;
629                 for (intptr_t k = 0; k < 20; k++) {
630                         ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
631                                                                                                                                                 tdm_output_change_handler_test_func,
632                                                                                                                                                 (void *) (-101-k)));
633                 }
634                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
635                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
636                 ASSERT_GT(handle_call, 20);
637         }
638         if (false == checked) {
639                 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
640         }
641 }
642
643
644 TEST_F(TDMOutput, OutputAddChangeHandlerFailAllNull)
645 {
646         SKIP_FLAG(has_output);
647         ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_add_change_handler(NULL, NULL, NULL));
648 }
649
650 TEST_F(TDMOutput, OutputAddChangeHandlerFailOnlyOutput)
651 {
652         SKIP_FLAG(has_output);
653         for (int i = 0; i < output_count; i++) {
654                 tdm_error error = TDM_ERROR_NONE;
655                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
656                 ASSERT_FALSE(NULL == output);
657                 ASSERT_TRUE(TDM_ERROR_NONE == error);
658                 ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_add_change_handler(output, NULL, NULL));
659         }
660 }
661
662 TEST_F(TDMOutput, OutputAddChangeHandlerFailWrongOutput)
663 {
664         SKIP_FLAG(has_output);
665         ASSERT_EXIT({tdm_output *output = (tdm_output *) 0xBEAF;
666                                  tdm_output_add_change_handler(output,
667                                                                                            tdm_output_change_handler_test_func,
668                                                                                            (void *) -101);
669                                  exit(0);}, ::testing::ExitedWithCode(0), "");
670 }
671
672 TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessful)
673 {
674         SKIP_FLAG(has_output);
675         bool checked = false;
676         for (int i = 0; i < output_count; i++) {
677                 tdm_error error = TDM_ERROR_NONE;
678                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
679                 ASSERT_FALSE(NULL == output);
680                 ASSERT_TRUE(TDM_ERROR_NONE == error);
681                 tdm_output_conn_status status;
682                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
683                 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
684                         continue;
685                 checked = true;
686                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
687                                                                                                                                         tdm_output_change_handler_test_func,
688                                                                                                                                         (void *) -101));
689                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
690                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
691                 ASSERT_GT(handle_call, 0);
692                 handle_call = 0;
693                 tdm_output_remove_change_handler(output, tdm_output_change_handler_test_func, (void *) -101);
694                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
695                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
696                 ASSERT_EQ(handle_call, 0);
697         }
698         if (false == checked) {
699                 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
700         }
701 }
702
703 void *UtOutputRemoveChangeHandlerSuccessfulThread(void *ptr)
704 {
705         TDMOutputCommitThread *FTDMOutput = (TDMOutputCommitThread *)ptr;
706
707         bool checked = false;
708         for (int i = 0; i < FTDMOutput->output_count; i++) {
709                 tdm_error error = TDM_ERROR_NONE;
710                 tdm_output * output = tdm_display_get_output(FTDMOutput->dpy, i, &error);
711                 if (NULL == output || TDM_ERROR_NONE != error)
712                         return (void *)1;
713                 tdm_output_conn_status status;
714                 error = tdm_output_get_conn_status(output, &status);
715                 if (TDM_ERROR_NONE != error)
716                         return (void *)2;
717                 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
718                         continue;
719                 checked = true;
720                 error = tdm_output_add_change_handler(output,
721                                                                                                 FTDMOutput->tdm_output_change_handler_test_func,
722                                                                                                 (void *) -101);
723                 if (TDM_ERROR_NONE != error)
724                         return (void *)3;
725                 error = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON);
726                 if (TDM_ERROR_NONE != error)
727                         return (void *)4;
728                 error = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF);
729                 if (TDM_ERROR_NONE != error)
730                         return (void *)5;
731                 FTDMOutput->UtHandleEvent(FTDMOutput->handle_call, 1);
732                 if (FTDMOutput->handle_call <= 0)
733                         return (void *)6;
734                 FTDMOutput->handle_call = 0;
735                 tdm_output_remove_change_handler(output, FTDMOutput->tdm_output_change_handler_test_func, (void *) -101);
736                 error = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON);
737                 if (TDM_ERROR_NONE != error)
738                         return (void *)7;
739                 error = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF);
740                 if (TDM_ERROR_NONE != error)
741                         return (void *)8;
742                 FTDMOutput->UtHandleEvent(FTDMOutput->handle_call, 1);
743                 if (FTDMOutput->handle_call != 0)
744                         return (void *)9;
745         }
746         if (false == checked) {
747                 return (void *)10;
748         }
749
750         return nullptr;
751 }
752
753 TEST_F(TDMOutputCommitThread, OutputRemoveChangeHandlerSuccessfulThread)
754 {
755         SKIP_FLAG(has_output);
756         pthread_t thread = 0;
757         int *status = nullptr;
758
759         ASSERT_FALSE(pthread_create(&thread, NULL, UtOutputRemoveChangeHandlerSuccessfulThread, this));
760
761         ASSERT_FALSE(pthread_join(thread, (void **)&status));
762
763         ASSERT_EQ(nullptr, status);
764 }
765
766 TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessfulFewFuncs)
767 {
768         SKIP_FLAG(has_output);
769         bool checked = false;
770         for (int i = 0; i < output_count; i++) {
771                 tdm_error error = TDM_ERROR_NONE;
772                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
773                 ASSERT_FALSE(NULL == output);
774                 ASSERT_TRUE(TDM_ERROR_NONE == error);
775                 tdm_output_conn_status status;
776                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
777                 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
778                         continue;
779                 checked = true;
780                 for (intptr_t k = 0; k < 20; k++) {
781                         ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
782                                                                                                                                                 tdm_output_change_handler_test_func,
783                                                                                                                                                 (void *) (-101-k)));
784                 }
785                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
786                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
787                 ASSERT_GT(handle_call, 20);
788                 handle_call = 0;
789                 for (intptr_t k = 0; k < 20; k++) {
790                         tdm_output_remove_change_handler(output, tdm_output_change_handler_test_func, (void *) (-101-k));
791                 }
792                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
793                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
794                 ASSERT_EQ(handle_call, 0);
795         }
796         if (false == checked) {
797                 FAIL() << "All outputs are disconnected. Testcase skipped" << std::endl;
798         }
799 }
800
801 TEST_F(TDMOutput, OutputRemoveChangeHandlerFailAllNull)
802 {
803         SKIP_FLAG(has_output);
804         ASSERT_EXIT({tdm_output_remove_change_handler(NULL, NULL, NULL);
805                                  exit(0);}, ::testing::ExitedWithCode(0), "");
806 }
807
808 TEST_F(TDMOutput, OutputRemoveChangeHandlerFailOnlyOutput)
809 {
810         SKIP_FLAG(has_output);
811         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
812                                          tdm_error error = TDM_ERROR_NONE;
813                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
814                                          if (NULL == output) exit(1);
815                                          if (TDM_ERROR_NONE != error) exit(1);
816                                          tdm_output_remove_change_handler(output, NULL, NULL);
817                                  } exit(0);}, ::testing::ExitedWithCode(0), "");
818 }
819
820 TEST_F(TDMOutput, OutputRemoveChangeHandlerFailWrongOutput)
821 {
822         SKIP_FLAG(has_output);
823         ASSERT_EXIT({tdm_output *output = (tdm_output *) 0xBEAF;
824                                  tdm_output_remove_change_handler(output,
825                                                                                            tdm_output_change_handler_test_func,
826                                                                                            (void *) -101);
827                                  exit(0);}, ::testing::ExitedWithCode(0), "");
828 }
829
830 TEST_F(TDMOutput, OutputGetOutputTypeSuccessful)
831 {
832         SKIP_FLAG(has_output);
833         for (int i = 0; i < output_count; i++) {
834                 tdm_error error = TDM_ERROR_NONE;
835                 tdm_output_type type = (tdm_output_type) -42;
836                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
837                 ASSERT_FALSE(NULL == output);
838                 ASSERT_TRUE(TDM_ERROR_NONE == error);
839                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_output_type(output, &type));
840                 ASSERT_NE(type, -42);
841         }
842 }
843
844 TEST_F(TDMOutput, OutputGetOutputTypeFailNullAll)
845 {
846         SKIP_FLAG(has_output);
847         ASSERT_EXIT({if (tdm_output_get_output_type(NULL, NULL) == TDM_ERROR_NONE) exit(1);
848                                  exit(0);}, ::testing::ExitedWithCode(0), "");
849 }
850
851 TEST_F(TDMOutput, OutputGetOutputTypeFailOnlyOutput)
852 {
853         SKIP_FLAG(has_output);
854         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
855                                          tdm_error error = TDM_ERROR_NONE;
856                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
857                                          if (NULL == output) exit(1);
858                                          if (TDM_ERROR_NONE != error) exit(1);
859                                          if (tdm_output_get_output_type(output, NULL) == TDM_ERROR_NONE) exit(1);
860                                 }
861                                 exit(0);}, ::testing::ExitedWithCode(0), "");
862 }
863
864 TEST_F(TDMOutput, OutputGetLayerCountSuccessful)
865 {
866         SKIP_FLAG(has_output);
867         for (int i = 0; i < output_count; i++) {
868                 tdm_error error = TDM_ERROR_NONE;
869                 int count = -42;
870                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
871                 ASSERT_FALSE(NULL == output);
872                 ASSERT_TRUE(TDM_ERROR_NONE == error);
873                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_layer_count(output, &count));
874                 ASSERT_NE(count, -42);
875         }
876 }
877
878 int is_hwc_ennable(tdm_output * output)
879 {
880         tdm_output_capability capabilities = (tdm_output_capability)0;
881         tdm_output_get_capabilities(output, &capabilities);
882         return capabilities & TDM_OUTPUT_CAPABILITY_HWC;
883 }
884
885 TEST_F(TDMOutputHWC, OutputGetLayerCountFailHWC)
886 {
887         SKIP_FLAG(has_output);
888         for (int i = 0; i < output_count; i++) {
889                 tdm_error error = TDM_ERROR_NONE;
890                 int count = -42;
891                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
892                 ASSERT_FALSE(NULL == output);
893                 ASSERT_TRUE(TDM_ERROR_NONE == error);
894                 if (is_hwc_ennable(output))
895                         ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_get_layer_count(output, &count));
896         }
897 }
898
899 TEST_F(TDMOutputHWC, OutputGetLayerFailHWC)
900 {
901         SKIP_FLAG(has_output);
902
903         for (int i = 0; i < output_count; i++) {
904                 tdm_error error = TDM_ERROR_NONE;
905                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
906                 ASSERT_FALSE(NULL == output);
907                 ASSERT_TRUE(TDM_ERROR_NONE == error);
908                 if (is_hwc_ennable(output)) {
909                         ASSERT_TRUE(nullptr == tdm_output_get_layer(output, 0, &error));
910                         ASSERT_TRUE(TDM_ERROR_NONE != error);
911                 }
912         }
913 }
914
915 TEST_F(TDMOutput, OutputGetLayerCountFailNullAll)
916 {
917         SKIP_FLAG(has_output);
918         ASSERT_EXIT({if (tdm_output_get_layer_count(NULL, NULL) == TDM_ERROR_NONE) exit(1);
919                                  exit(0);}, ::testing::ExitedWithCode(0), "");
920 }
921
922 TEST_F(TDMOutput, OutputGetLayerCountFailOnlyOutput)
923 {
924         SKIP_FLAG(has_output);
925         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
926                                          tdm_error error = TDM_ERROR_NONE;
927                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
928                                          if (NULL == output) exit(1);
929                                          if (TDM_ERROR_NONE != error) exit(1);
930                                          if (TDM_ERROR_NONE == tdm_output_get_layer_count(output, NULL)) exit(1);
931                                 }
932                                 exit(0);}, ::testing::ExitedWithCode(0), "");
933 }
934
935 TEST_F(TDMOutput, OutputGetAvailablePropertiesSuccessful)
936 {
937         SKIP_FLAG(has_output);
938         for (int i = 0; i < output_count; i++) {
939                 tdm_error error = TDM_ERROR_NONE;
940                 int count = -42;
941                 const tdm_prop *tdm_prop_array = (const tdm_prop *) 0xBEAF;
942                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
943                 ASSERT_FALSE(NULL == output);
944                 ASSERT_TRUE(TDM_ERROR_NONE == error);
945                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_properties(output,
946                                                                                                                                                   &tdm_prop_array,
947                                                                                                                                                   &count));
948                 ASSERT_NE(count, -42);
949                 ASSERT_NE(tdm_prop_array, 0xBEAF);
950         }
951 }
952
953 TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullAll)
954 {
955         SKIP_FLAG(has_output);
956         ASSERT_EXIT({if (tdm_output_get_available_properties(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
957                                  exit(0);}, ::testing::ExitedWithCode(0), "");
958 }
959
960 TEST_F(TDMOutput, OutputGetAvailablePropertiesFailOnlyOutput)
961 {
962         SKIP_FLAG(has_output);
963         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
964                                          tdm_error error = TDM_ERROR_NONE;
965                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
966                                          if (NULL == output) exit(1);
967                                          if (TDM_ERROR_NONE != error) exit(1);
968                                          if (TDM_ERROR_NONE == tdm_output_get_available_properties(output, NULL, NULL)) exit(1);
969                                 }
970                                 exit(0);}, ::testing::ExitedWithCode(0), "");
971 }
972
973 TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullCount)
974 {
975         SKIP_FLAG(has_output);
976         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
977                                          tdm_error error = TDM_ERROR_NONE;
978                                          const tdm_prop *tdm_prop_array = NULL;
979                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
980                                          if (NULL == output) exit(1);
981                                          if (TDM_ERROR_NONE != error) exit(1);
982                                          if (TDM_ERROR_NONE == tdm_output_get_available_properties(output,
983                                                                                                                                                            &tdm_prop_array,
984                                                                                                                                                            NULL)) exit(1);
985                                 }
986                                 exit(0);}, ::testing::ExitedWithCode(0), "");
987 }
988
989 TEST_F(TDMOutput, OutputGetAvailablePropertiesFailNullProperty)
990 {
991         SKIP_FLAG(has_output);
992         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
993                                          tdm_error error = TDM_ERROR_NONE;
994                                          int count = -42;
995                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
996                                          if (NULL == output) exit(1);
997                                          if (TDM_ERROR_NONE != error) exit(1);
998                                          if (TDM_ERROR_NONE == tdm_output_get_available_properties(output,
999                                                                                                                                                            NULL,
1000                                                                                                                                                            &count)) exit(1);
1001                                 }
1002                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1003 }
1004
1005 TEST_F(TDMOutput, OutputGetAvailableModesSuccessful)
1006 {
1007         SKIP_FLAG(has_output);
1008         for (int i = 0; i < output_count; i++) {
1009                 tdm_error error = TDM_ERROR_NONE;
1010                 int count = -42;
1011                 const tdm_output_mode *modes_array = (const tdm_output_mode *) 0xBEAF;
1012                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1013                 ASSERT_FALSE(NULL == output);
1014                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1015                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_modes(output,
1016                                                                                                                                          &modes_array,
1017                                                                                                                                          &count));
1018                 ASSERT_NE(count, -42);
1019                 ASSERT_NE(modes_array, 0xBEAF);
1020         }
1021 }
1022
1023 TEST_F(TDMOutput, OutputGetAvailableModesFailNullAll)
1024 {
1025         SKIP_FLAG(has_output);
1026         ASSERT_EXIT({if (tdm_output_get_available_modes(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
1027                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1028 }
1029
1030 TEST_F(TDMOutput, OutputGetAvailableModesFailOnlyOutput)
1031 {
1032         SKIP_FLAG(has_output);
1033         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1034                                          tdm_error error = TDM_ERROR_NONE;
1035                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1036                                          if (NULL == output) exit(1);
1037                                          if (TDM_ERROR_NONE != error) exit(1);
1038                                          if (TDM_ERROR_NONE == tdm_output_get_available_modes(output, NULL, NULL)) exit(1);
1039                                 }
1040                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1041 }
1042
1043 TEST_F(TDMOutput, OutputGetAvailableModesFailNullCount)
1044 {
1045         SKIP_FLAG(has_output);
1046         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1047                                          tdm_error error = TDM_ERROR_NONE;
1048                                          const tdm_output_mode *modes_array = NULL;
1049                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1050                                          if (NULL == output) exit(1);
1051                                          if (TDM_ERROR_NONE != error) exit(1);
1052                                          if (TDM_ERROR_NONE == tdm_output_get_available_modes(output,
1053                                                                                                                                                   &modes_array,
1054                                                                                                                                                   NULL)) exit(1);
1055                                 }
1056                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1057 }
1058
1059 TEST_F(TDMOutput, OutputGetAvailableModesFailNullModes)
1060 {
1061         SKIP_FLAG(has_output);
1062         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1063                                          tdm_error error = TDM_ERROR_NONE;
1064                                          int count = -42;
1065                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1066                                          if (NULL == output) exit(1);
1067                                          if (TDM_ERROR_NONE != error) exit(1);
1068                                          if (TDM_ERROR_NONE == tdm_output_get_available_modes(output,
1069                                                                                                                                                   NULL,
1070                                                                                                                                                   &count)) exit(1);
1071                                 }
1072                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1073 }
1074
1075 TEST_F(TDMOutput, OutputGetAvailableSizeSuccessful)
1076 {
1077         SKIP_FLAG(has_output);
1078         for (int i = 0; i < output_count; i++) {
1079                 tdm_error error = TDM_ERROR_NONE;
1080                 int min_w = -42, min_h = -42, max_w = -42, max_h = -42, preferred_align = -42;
1081                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1082                 ASSERT_FALSE(NULL == output);
1083                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1084                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_available_size(output, &min_w, &min_h,
1085                                                                                                                                         &max_w, &max_h, &preferred_align));
1086                 ASSERT_NE(min_w, -42);
1087                 ASSERT_NE(min_h, -42);
1088                 ASSERT_NE(max_w, -42);
1089                 ASSERT_NE(max_h, -42);
1090                 ASSERT_NE(preferred_align, -42);
1091         }
1092 }
1093
1094 TEST_F(TDMOutput, OutputGetAvailableSizeFailNullAll)
1095 {
1096         SKIP_FLAG(has_output);
1097         ASSERT_EXIT({if (tdm_output_get_available_size(NULL, NULL, NULL,
1098                                                                                                    NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
1099                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1100 }
1101
1102 TEST_F(TDMOutput, OutputGetAvailableSizeSuccessfulOnlyOutput)
1103 {
1104         SKIP_FLAG(has_output);
1105         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1106                                          tdm_error error = TDM_ERROR_NONE;
1107                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1108                                          if (NULL == output) exit(1);
1109                                          if (TDM_ERROR_NONE != error) exit(1);
1110                                          if (tdm_output_get_available_size(output, NULL, NULL,
1111                                                                                                                 NULL, NULL, NULL) != TDM_ERROR_NONE) exit(1);
1112                                 }
1113                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1114 }
1115
1116 /*TODO: this test has to be fixed in the backends by increase the ABI version upper than 1.5*/
1117 TEST_F(TDMOutput, DISABLED_OutputGetCursorAvailableSizeSuccessful)
1118 {
1119         SKIP_FLAG(has_output);
1120         for (int i = 0; i < output_count; i++) {
1121                 tdm_error error = TDM_ERROR_NONE;
1122                 int min_w = -42, min_h = -42, max_w = -42, max_h = -42, preferred_align = -42;
1123                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1124                 ASSERT_FALSE(NULL == output);
1125                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1126                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_cursor_available_size(output, &min_w, &min_h,
1127                                                                                                                                                    &max_w, &max_h, &preferred_align));
1128                 ASSERT_NE(min_w, -42);
1129                 ASSERT_NE(min_h, -42);
1130                 ASSERT_NE(max_w, -42);
1131                 ASSERT_NE(max_h, -42);
1132                 ASSERT_NE(preferred_align, -42);
1133         }
1134 }
1135
1136 TEST_F(TDMOutput, OutputGetCursorAvailableSizeFailNullAll)
1137 {
1138         SKIP_FLAG(has_output);
1139         ASSERT_EXIT({if (tdm_output_get_cursor_available_size(NULL, NULL, NULL,
1140                                                                                                                   NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
1141                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1142 }
1143
1144 /*TODO: this test has to be fixed in the backends by increase the ABI version upper than 1.5*/
1145 TEST_F(TDMOutput, DISABLED_OutputGetCursorAvailableSizeSuccessfulOnlyOutput)
1146 {
1147         SKIP_FLAG(has_output);
1148         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1149                                          tdm_error error = TDM_ERROR_NONE;
1150                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1151                                          if (NULL == output) exit(1);
1152                                          if (TDM_ERROR_NONE != error) exit(1);
1153                                          if (tdm_output_get_cursor_available_size(output, NULL, NULL,
1154                                                                                                                           NULL, NULL, NULL) != TDM_ERROR_NONE) exit(1);
1155                                 }
1156                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1157 }
1158
1159 TEST_F(TDMOutput, OutputGetPhysicalSizeSuccessful)
1160 {
1161         SKIP_FLAG(has_output);
1162         for (int i = 0; i < output_count; i++) {
1163                 tdm_error error = TDM_ERROR_NONE;
1164                 unsigned int mmWidth = UINT_MAX, mmHeight = UINT_MAX;
1165                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1166                 ASSERT_FALSE(NULL == output);
1167                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1168                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_physical_size(output, &mmWidth, &mmHeight));
1169                 ASSERT_NE(mmWidth, UINT_MAX);
1170                 ASSERT_NE(mmHeight, UINT_MAX);
1171         }
1172 }
1173
1174 TEST_F(TDMOutput, OutputGetPhysicalSizeFailNullAll)
1175 {
1176         SKIP_FLAG(has_output);
1177         ASSERT_EXIT({if (tdm_output_get_physical_size(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
1178                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1179 }
1180
1181 TEST_F(TDMOutput, OutputGetPhysicalSuccessfulOnlyOutput)
1182 {
1183         SKIP_FLAG(has_output);
1184         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1185                                          tdm_error error = TDM_ERROR_NONE;
1186                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1187                                          if (NULL == output) exit(1);
1188                                          if (TDM_ERROR_NONE != error) exit(1);
1189                                          if (tdm_output_get_physical_size(output, NULL, NULL) != TDM_ERROR_NONE) exit(1);
1190                                 }
1191                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1192 }
1193
1194 TEST_F(TDMOutput, OutputGetSubpixelSuccessful)
1195 {
1196         SKIP_FLAG(has_output);
1197         for (int i = 0; i < output_count; i++) {
1198                 tdm_error error = TDM_ERROR_NONE;
1199                 unsigned int subpixel = UINT_MAX;
1200                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1201                 ASSERT_FALSE(NULL == output);
1202                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1203                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_subpixel(output, &subpixel));
1204                 ASSERT_NE(subpixel, UINT_MAX);
1205         }
1206 }
1207
1208 TEST_F(TDMOutput, OutputGetSubpixelFailNullAll)
1209 {
1210         SKIP_FLAG(has_output);
1211         ASSERT_EXIT({if (tdm_output_get_subpixel(NULL, NULL) == TDM_ERROR_NONE) exit(1);
1212                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1213 }
1214
1215 TEST_F(TDMOutput, OutputGetSubpixelFailOnlyOutput)
1216 {
1217         SKIP_FLAG(has_output);
1218         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1219                                          tdm_error error = TDM_ERROR_NONE;
1220                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1221                                          if (NULL == output) exit(1);
1222                                          if (TDM_ERROR_NONE != error) exit(1);
1223                                          if (tdm_output_get_subpixel(output, NULL) == TDM_ERROR_NONE) exit(1);
1224                                 }
1225                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1226 }
1227
1228 TEST_F(TDMOutput, OutputGetPipeSuccessful)
1229 {
1230         SKIP_FLAG(has_output);
1231         for (int i = 0; i < output_count; i++) {
1232                 tdm_error error = TDM_ERROR_NONE;
1233                 unsigned int pipe = UINT_MAX;
1234                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1235                 ASSERT_FALSE(NULL == output);
1236                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1237                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_pipe(output, &pipe));
1238                 ASSERT_NE(pipe, UINT_MAX);
1239         }
1240 }
1241
1242 TEST_F(TDMOutput, OutputGetPipeFailNullAll)
1243 {
1244         SKIP_FLAG(has_output);
1245         ASSERT_EXIT({if (tdm_output_get_pipe(NULL, NULL) == TDM_ERROR_NONE) exit(1);
1246                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1247 }
1248
1249 TEST_F(TDMOutput, OutputGetPipeFailOnlyOutput)
1250 {
1251         SKIP_FLAG(has_output);
1252         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1253                                          tdm_error error = TDM_ERROR_NONE;
1254                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1255                                          if (NULL == output) exit(1);
1256                                          if (TDM_ERROR_NONE != error) exit(1);
1257                                          if (tdm_output_get_pipe(output, NULL) == TDM_ERROR_NONE) exit(1);
1258                                 }
1259                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1260 }
1261
1262 TEST_F(TDMOutput, OutputGetPrimaryIndexSuccessful)
1263 {
1264         SKIP_FLAG(has_output);
1265         for (int i = 0; i < output_count; i++) {
1266                 tdm_error error = TDM_ERROR_NONE;
1267                 int primary_index = INT_MAX;
1268                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1269                 ASSERT_FALSE(NULL == output);
1270                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1271                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_primary_index(output, &primary_index));
1272                 ASSERT_NE(primary_index, INT_MAX);
1273         }
1274 }
1275
1276 TEST_F(TDMOutput, OutputGetPrimaryIndexFailNullAll)
1277 {
1278         SKIP_FLAG(has_output);
1279         ASSERT_EXIT({if (tdm_output_get_primary_index(NULL, NULL) == TDM_ERROR_NONE) exit(1);
1280                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1281 }
1282
1283 TEST_F(TDMOutput, OutputGetPrimaryIndexFailOnlyOutput)
1284 {
1285         SKIP_FLAG(has_output);
1286         ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
1287                                          tdm_error error = TDM_ERROR_NONE;
1288                                          tdm_output * output = tdm_display_get_output(dpy, i, &error);
1289                                          if (NULL == output) exit(1);
1290                                          if (TDM_ERROR_NONE != error) exit(1);
1291                                          if (tdm_output_get_primary_index(output, NULL) == TDM_ERROR_NONE) exit(1);
1292                                 }
1293                                 exit(0);}, ::testing::ExitedWithCode(0), "");
1294 }
1295
1296 TEST_F(TDMOutput, OutputSetPropertySuccessful)
1297 {
1298         SKIP_FLAG(has_output);
1299         for (int i = 0; i < output_count; i++) {
1300                 tdm_error error = TDM_ERROR_NONE;
1301                 tdm_value value = {.u32 = 0};
1302                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1303                 ASSERT_FALSE(NULL == output);
1304                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1305                 error = tdm_output_set_property(output, UINT_MAX, value);
1306                 ASSERT_TRUE(error == TDM_ERROR_NOT_IMPLEMENTED || error == TDM_ERROR_OPERATION_FAILED);
1307         }
1308 }
1309
1310 TEST_F(TDMOutput, OutputSetPropertyFailNullAll)
1311 {
1312         SKIP_FLAG(has_output);
1313         ASSERT_EXIT({tdm_error error = TDM_ERROR_NONE;
1314                                  tdm_value value = {.u32 = 0};
1315                                  error = tdm_output_set_property(NULL, 0, value);
1316                                  if (error == TDM_ERROR_NONE || error == TDM_ERROR_NOT_IMPLEMENTED ||
1317                                         error == TDM_ERROR_OPERATION_FAILED) exit(1);
1318                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1319 }
1320
1321 TEST_F(TDMOutput, OutputGetPropertySuccessful)
1322 {
1323         SKIP_FLAG(has_output);
1324         for (int i = 0; i < output_count; i++) {
1325                 tdm_error error = TDM_ERROR_NONE;
1326                 tdm_value value = {.u32 = 0};
1327                 tdm_output * output = tdm_display_get_output(dpy, i, &error);
1328                 ASSERT_FALSE(NULL == output);
1329                 ASSERT_TRUE(TDM_ERROR_NONE == error);
1330                 error = tdm_output_get_property(output, UINT_MAX, &value);
1331                 ASSERT_TRUE(error == TDM_ERROR_NOT_IMPLEMENTED || error == TDM_ERROR_NONE);
1332         }
1333 }
1334
1335 TEST_F(TDMOutput, OutputGetPropertyFailNullAll)
1336 {
1337         SKIP_FLAG(has_output);
1338         ASSERT_EXIT({tdm_error error = TDM_ERROR_NONE;
1339                                  error = tdm_output_get_property(NULL, 0, NULL);
1340                                  if (error == TDM_ERROR_NONE || error == TDM_ERROR_NOT_IMPLEMENTED ||
1341                                          error == TDM_ERROR_OPERATION_FAILED) exit(1);
1342                                  exit(0);}, ::testing::ExitedWithCode(0), "");
1343 }
1344
1345 TEST_F(TDMOutputCommit, OutputCommitFailNullAll)
1346 {
1347         SKIP_FLAG(has_output);
1348
1349         ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_commit(NULL, 0, NULL, NULL));
1350 }
1351
1352 TEST_F(TDMOutputCommit, OutputCommit)
1353 {
1354         SKIP_FLAG(has_output);
1355
1356         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1357
1358         for (int i = 0; i < conn_output_count; i++)
1359                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, NULL));
1360
1361         UtHandleCommitEvent();
1362
1363         ASSERT_EQ(conn_output_count, utOutputCommitHandlerCounter);
1364 }
1365
1366 TEST_F(TDMOutputCommitThread, OutputCommit)
1367 {
1368         SKIP_FLAG(has_output);
1369
1370         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1371
1372         for (int i = 0; i < conn_output_count; i++)
1373                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, NULL));
1374
1375         UtHandleCommitEvent();
1376
1377         ASSERT_EQ(conn_output_count, utOutputCommitHandlerCounter);
1378 }
1379
1380 TEST_F(TDMOutputCommitPerVblankEnabled, OutputCommitFailLayerCommit)
1381 {
1382         SKIP_FLAG(has_output);
1383
1384         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1385
1386         for (size_t i = 0; i < layers_array.size(); ++i) {
1387                 for (tdm_layer *layer : layers_array[i]) {
1388                         tdm_layer_commit(layer, NULL, NULL);
1389                 }
1390         }
1391
1392         for (int i = 0; i < conn_output_count; i++)
1393                 ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, NULL));
1394 }
1395
1396 TEST_F(TDMOutputCommitPerVblankEnabled, OutputCommitFailCommitPerVblankEnabled)
1397 {
1398         SKIP_FLAG(has_output);
1399
1400         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1401
1402         for (int i = 0; i < conn_output_count; i++)
1403                 ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, NULL));
1404 }
1405
1406 TEST_F(TDMOutputCommit, OutputCommitFailDpmsOff)
1407 {
1408         SKIP_FLAG(has_output);
1409
1410         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1411
1412         for (int i = 0; i < conn_output_count; i++) {
1413                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(connected_output_array[i], TDM_OUTPUT_DPMS_OFF));
1414
1415                 ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, NULL));
1416         }
1417 }
1418
1419 TEST_F(TDMOutputCommit, OutputWaitVBlankFailNullAll)
1420 {
1421         SKIP_FLAG(has_output);
1422
1423         ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_wait_vblank(nullptr, 1, 0, nullptr, nullptr));
1424 }
1425
1426 TEST_F(TDMOutputCommit, OutputWaitVBlankFailDpmsOff)
1427 {
1428         SKIP_FLAG(has_output);
1429
1430         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1431
1432         for (int i = 0; i < conn_output_count; i++) {
1433                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(connected_output_array[i], TDM_OUTPUT_DPMS_OFF));
1434
1435                 for (int i = 0; i < conn_output_count; i++)
1436                         ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_wait_vblank(connected_output_array[i], 1, 0, UtOutputVblankHandler, nullptr));
1437         }
1438 }
1439
1440 TEST_F(TDMOutputCommit, OutputWaitVBlank)
1441 {
1442         SKIP_FLAG(has_output);
1443
1444         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1445
1446         for (int i = 0; i < conn_output_count; i++)
1447                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, nullptr));
1448
1449         UtHandleCommitEvent();
1450
1451         ASSERT_EQ(conn_output_count, utOutputCommitHandlerCounter);
1452
1453         for (int i = 0; i < conn_output_count; i++)
1454                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_wait_vblank(connected_output_array[i], 1, 0, UtOutputVblankHandler, nullptr));
1455
1456         UtHandleVblankEvent();
1457
1458         ASSERT_EQ(conn_output_count, utOutputVblankHandlerCounter);
1459 }
1460
1461 TEST_F(TDMOutputCommitThread, OutputWaitVBlank)
1462 {
1463         SKIP_FLAG(has_output);
1464
1465         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1466
1467         for (int i = 0; i < conn_output_count; i++)
1468                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, NULL));
1469
1470         UtHandleCommitEvent();
1471
1472         ASSERT_EQ(conn_output_count, utOutputCommitHandlerCounter);
1473
1474         for (int i = 0; i < conn_output_count; i++)
1475                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_wait_vblank(connected_output_array[i], 1, 0, UtOutputVblankHandler, NULL));
1476
1477         UtHandleVblankEvent();
1478
1479         ASSERT_EQ(conn_output_count, utOutputVblankHandlerCounter);
1480 }
1481
1482 TEST_F(TDMOutputCommit, OutputRemoveVblankHandlerFailNullAll)
1483 {
1484         SKIP_FLAG(has_output);
1485
1486         ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_remove_vblank_handler(nullptr, nullptr, nullptr));
1487 }
1488
1489 TEST_F(TDMOutputCommitThread, OutputRemoveVblankHandlerSuccess)
1490 {
1491         SKIP_FLAG(has_output);
1492
1493         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1494
1495         for (int i = 0; i < conn_output_count; i++)
1496                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, NULL));
1497
1498         UtHandleCommitEvent();
1499
1500         ASSERT_EQ(conn_output_count, utOutputCommitHandlerCounter);
1501
1502         for (int i = 0; i < conn_output_count; i++)
1503                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_wait_vblank(connected_output_array[i], 2, 0, UtOutputVblankHandler, NULL));
1504
1505         for (int i = 0; i < conn_output_count; i++) {
1506                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_remove_vblank_handler(connected_output_array[i], UtOutputVblankHandler, NULL));
1507         }
1508
1509         UtHandleVblankEvent();
1510
1511         ASSERT_EQ(0, utOutputVblankHandlerCounter);
1512 }
1513
1514 TEST_F(TDMOutputCommit, OutputRemoveCommitHandlerFailNullAll)
1515 {
1516         SKIP_FLAG(has_output);
1517
1518         ASSERT_TRUE(TDM_ERROR_NONE != tdm_output_remove_commit_handler(nullptr, nullptr, nullptr));
1519 }
1520
1521 TEST_F(TDMOutputCommitThread, OutputRemoveCommitHandlerSuccess)
1522 {
1523         SKIP_FLAG(has_output);
1524
1525         ASSERT_NO_FATAL_FAILURE(UtPrepareToCommit());
1526
1527         for (int i = 0; i < conn_output_count; i++)
1528                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_commit(connected_output_array[i], 0, UtOutputCommitHandler, NULL));
1529
1530         for (int i = 0; i < conn_output_count; i++) {
1531                 ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_remove_commit_handler(connected_output_array[i], UtOutputCommitHandler, NULL));
1532         }
1533
1534         UtHandleCommitEvent();
1535 }