883ac5c0640a12d23fe1ad9f9121eb1c44d73d21
[platform/core/uifw/libtdm.git] / haltests / src / tc_tdm_client.cpp
1 /**************************************************************************
2  *
3  * Copyright 2017 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  * Contact: Sergey Sizonov <s.sizonov@samsung.com>
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sub license, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice (including the
19  * next paragraph) shall be included in all copies or substantial portions
20  * of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29  *
30 **************************************************************************/
31
32 #include <unistd.h>
33 #include <fcntl.h>
34 #include <sys/signalfd.h>
35 #include <poll.h>
36 #include <sys/prctl.h>
37
38 #include "tc_tdm.h"
39 #include "tdm_client.h"
40
41 /* LCOV_EXCL_START */
42
43 enum {
44         TDM_UT_PIPE_MSG_NONE,
45         TDM_UT_PIPE_MSG_REPLY,
46         TDM_UT_PIPE_MSG_SERVER_READY,
47         TDM_UT_PIPE_MSG_SERVER_FAILED,
48         TDM_UT_PIPE_MSG_DPMS_ON,
49         TDM_UT_PIPE_MSG_DPMS_OFF,
50         TDM_UT_PIPE_MSG_TERMINATE_SERVER,
51 };
52
53 #define TDM_UT_WAIT(fmt, ...) \
54         do { \
55                 char ch; \
56                 do { \
57                         printf(fmt" [n]):next ", ##__VA_ARGS__); \
58                         ch = tc_tdm_getchar(); \
59                 } while(ch != 'n'); \
60         } while (0)
61
62 static int _tc_tdm_pipe_read_msg(int fd);
63 static bool _tc_tdm_pipe_write_msg(int fd, int reply_fd, int msg);
64 static pid_t _tc_tdm_client_server_fork(int *pipe_to_parent, int *pipe_to_child);
65
66 class TDMClient : public TDMEnv
67 {
68 public:
69         static pid_t server_pid;
70
71         /* 0: read, 1: write */
72         static int pipe_parent[2];
73         static int pipe_child[2];
74
75         tdm_client *client;
76         tdm_client_output *output;
77         tdm_client_vblank *vblank;
78         tdm_client_voutput *voutput;
79
80         double vrefresh_interval, start, end;
81
82         TDMClient();
83
84         void SetUp(void);
85         void TearDown(void);
86         bool PrepareClient(void);
87         bool PrepareOutput(void);
88         bool PrepareVblank(void);
89
90         static void TearDownTestCase(void);
91         static void ServerFork(void);
92         static void ServerKill(void);
93 };
94
95 pid_t TDMClient::server_pid = -1;
96 int TDMClient::pipe_parent[2] = {-1, -1};
97 int TDMClient::pipe_child[2] = {-1, -1};
98
99 void TDMClient::TearDownTestCase(void)
100 {
101         ServerKill();
102 }
103
104 void TDMClient::ServerFork(void)
105 {
106         if (server_pid > 0)
107                 return;
108
109         server_pid = _tc_tdm_client_server_fork(pipe_parent, pipe_child);
110         ASSERT_GT(server_pid, 0);
111 }
112
113 void TDMClient::ServerKill(void)
114 {
115         if (pipe_child[0] >= 0)
116                 close(pipe_child[0]);
117         if (pipe_child[1] >= 0) {
118                 if (server_pid > 0) {
119                         bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
120                         if (ret) {
121                                 if (waitpid(server_pid, NULL, 0) == server_pid)
122                                         TDM_INFO("*** server terminated ***");
123                                 else
124                                         TDM_ERR("*** failed to terminate server ***");
125                         } else {
126                                 if (kill(server_pid, 9) < 0)
127                                         TDM_ERR("*** failed to kill server ***");
128                         }
129                 }
130                 close(pipe_child[1]);
131         }
132
133         if (pipe_parent[0] >= 0)
134                 close(pipe_parent[0]);
135         if (pipe_parent[1] >= 0)
136                 close(pipe_parent[1]);
137
138         server_pid = -1;
139         pipe_parent[0] = pipe_parent[1] = -1;
140         pipe_child[0] = pipe_child[1] = -1;
141 }
142
143 TDMClient::TDMClient()
144 {
145         client = NULL;
146         output = NULL;
147         vblank = NULL;
148         vrefresh_interval = start = end = 0.0;
149 }
150
151 void TDMClient::SetUp(void)
152 {
153         TDMEnv::SetUp();
154
155         if (server_pid == -1)
156                 ServerFork();
157 }
158
159 void TDMClient::TearDown(void)
160 {
161         if (vblank)
162                 tdm_client_vblank_destroy(vblank);
163         if (client)
164                 tdm_client_destroy(client);
165
166         TDMEnv::TearDown();
167 }
168
169 bool TDMClient::PrepareClient(void)
170 {
171         tdm_error ret;
172         client = tdm_client_create(&ret);
173         TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
174         TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
175
176         return true;
177 }
178
179 bool TDMClient::PrepareOutput(void)
180 {
181         tdm_error ret;
182
183         TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
184
185         output = tdm_client_get_output(client, NULL, &ret);
186         TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
187         TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
188
189         return true;
190 }
191
192 bool TDMClient::PrepareVblank(void)
193 {
194         tdm_error ret;
195         unsigned int refresh;
196
197         TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
198
199         vblank = tdm_client_output_create_vblank(output, &ret);
200         TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
201         TDM_UT_RETURN_FALSE_IF_FAIL(vblank != NULL);
202
203         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_client_output_get_refresh_rate(output, &refresh) == TDM_ERROR_NONE);
204         TDM_UT_RETURN_FALSE_IF_FAIL(refresh > 0);
205
206         vrefresh_interval = 1.0 / (double)refresh;
207         TDM_UT_RETURN_FALSE_IF_FAIL(vrefresh_interval > 0);
208
209         return true;
210 }
211
212 char
213 tc_tdm_getchar(void)
214 {
215         int c = getchar();
216         int ch = c;
217
218         if (ch == '\n' || ch == '\r')
219                 ch = 'y';
220         else if (ch < 'a')
221                 ch += ('a' - 'A');
222
223         while (c != '\n' && c != EOF)
224                 c = getchar();
225
226         return ch;
227 }
228
229 static int
230 _tc_tdm_pipe_read_msg(int fd)
231 {
232         ssize_t len;
233         int msg;
234
235         do {
236                 len = read(fd, &msg, sizeof msg);
237         } while (len < 0 && errno == EINTR);
238
239         if (len <= 0)
240                 msg = TDM_UT_PIPE_MSG_NONE;
241
242         return msg;
243 }
244
245 static bool
246 _tc_tdm_pipe_write_msg(int fd, int reply_fd, int msg)
247 {
248         ssize_t len = write(fd, &msg, sizeof msg);
249         TDM_UT_RETURN_FALSE_IF_FAIL(len == sizeof msg);
250
251         if (reply_fd >= 0) {
252                 int reply = _tc_tdm_pipe_read_msg(reply_fd);
253                 TDM_UT_RETURN_FALSE_IF_FAIL(reply == TDM_UT_PIPE_MSG_REPLY);
254         }
255
256         return true;
257 }
258
259 static bool
260 _tc_tdm_server_set_output_dpms(tdm_display *dpy, int msg)
261 {
262         tdm_error ret;
263         tdm_output *output;
264         tdm_output_dpms dpms;
265
266         output = tdm_display_find_output(dpy, "primary", &ret);
267         TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
268         TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
269
270         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
271
272         switch (msg) {
273         case TDM_UT_PIPE_MSG_DPMS_ON:
274                 if (dpms != TDM_OUTPUT_DPMS_ON)
275                         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
276                 break;
277         case TDM_UT_PIPE_MSG_DPMS_OFF:
278                 if (dpms != TDM_OUTPUT_DPMS_OFF)
279                         TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
280                 break;
281         default:
282                 break;
283         }
284
285         return true;
286 }
287
288 static void
289 _tc_tdm_server_run(int *pipe_parent, int *pipe_child)
290 {
291         tdm_display *dpy = NULL;
292         tdm_error ret;
293         struct pollfd fds[2];
294         int tdm_fd, err;
295         int output_count = 0;
296
297         dpy = tdm_display_init(&ret);
298         TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
299         TDM_UT_GOTO_IF_FAIL(dpy != NULL, failed);
300
301         TDM_UT_GOTO_IF_FAIL(tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE, failed);
302
303         for (int o = 0; o < output_count; o++) {
304                 tdm_output *output = tdm_display_get_output(dpy, o, &ret);
305                 TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
306                 TDM_UT_GOTO_IF_FAIL(output != NULL, failed);
307
308                 if (!tc_tdm_output_is_connected(output))
309                         continue;
310
311                 TDM_UT_GOTO_IF_FAIL(tc_tdm_output_prepare(dpy, output, true) == true, failed);
312         }
313
314         TDM_UT_GOTO_IF_FAIL(_tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_READY) == true, done);
315
316         TDM_INFO("*** server ready ***");
317
318         ret = tdm_display_get_fd(dpy, &tdm_fd);
319         TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, done);
320
321         fds[0].events = POLLIN;
322         fds[0].fd = tdm_fd;
323         fds[0].revents = 0;
324
325         fds[1].events = POLLIN;
326         fds[1].fd = pipe_child[0];
327         fds[1].revents = 0;
328
329         while (1) {
330                 /* make sure all events are flushed to clients before falling in sleep */
331                 tdm_display_flush(dpy);
332
333                 err = poll(fds, 2, -1);
334                 if (err < 0) {
335                         if (errno == EINTR || errno == EAGAIN) {
336                                 continue;
337                         } else {
338                                 TDM_ERR("server-process: poll failed: %m\n");
339                                 goto done;
340                         }
341                 }
342
343                 if (fds[0].revents & POLLIN)
344                         ret = tc_tdm_display_handle_events(dpy);
345
346                 if (fds[1].revents & POLLIN) {
347                         int msg = _tc_tdm_pipe_read_msg(pipe_child[0]);
348                         _tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_REPLY);
349
350                         switch (msg) {
351                         case TDM_UT_PIPE_MSG_DPMS_ON:
352                         case TDM_UT_PIPE_MSG_DPMS_OFF:
353                                 _tc_tdm_server_set_output_dpms(dpy, msg);
354                                 break;
355                         case TDM_UT_PIPE_MSG_TERMINATE_SERVER:
356                                 goto done;
357                         default:
358                                 break;
359                         }
360                 }
361         }
362
363 done:
364         if (dpy)
365                 tdm_display_deinit(dpy);
366         return;
367
368 failed:
369         TDM_UT_GOTO_IF_FAIL(_tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_FAILED) == true, done);
370         TDM_INFO("*** server failed ***");
371
372         if (dpy)
373                 tdm_display_deinit(dpy);
374         return;
375
376 }
377
378 static void _tc_tdm_client_sig_handler(int sig)
379 {
380         TDM_UT_ERR("got signal: %d", sig);
381         kill(TDMClient::server_pid, 9);
382         abort();
383 }
384
385 static pid_t
386 _tc_tdm_client_server_fork(int *pipe_parent, int *pipe_child)
387 {
388         pid_t pid;
389         int msg;
390
391         TDM_UT_GOTO_IF_FAIL(pipe(pipe_parent) == 0, failed);
392         TDM_UT_GOTO_IF_FAIL(pipe(pipe_child) == 0, failed);
393
394         signal(SIGCHLD, SIG_IGN);
395         signal(SIGSEGV, _tc_tdm_client_sig_handler);
396
397         prctl(PR_SET_PDEATHSIG, SIGHUP);
398
399         pid = fork();
400         TDM_UT_GOTO_IF_FAIL(pid >= 0, failed);
401
402         if (pid == 0) {
403                 _tc_tdm_server_run(pipe_parent, pipe_child);
404                 close(pipe_child[0]);
405                 close(pipe_child[1]);
406                 close(pipe_parent[0]);
407                 close(pipe_parent[1]);
408
409 #ifdef TIZEN_TEST_GCOV
410                 __gcov_flush();
411 #endif
412
413                 exit(0);
414         }
415
416         msg = _tc_tdm_pipe_read_msg(pipe_parent[0]);
417         TDM_UT_GOTO_IF_FAIL(msg == TDM_UT_PIPE_MSG_SERVER_READY, failed);
418
419         TDM_INFO("*** server fork done ***");
420
421         return pid;
422
423 failed:
424         return -1;
425 }
426
427 TEST_P(TDMClient, ClientCreate)
428 {
429         tdm_error ret;
430
431         client = tdm_client_create(&ret);
432         ASSERT_EQ(ret, TDM_ERROR_NONE);
433         ASSERT_NE(client, NULL);
434 }
435
436 TEST_P(TDMClient, ClientCreateNullOther)
437 {
438         client = tdm_client_create(NULL);
439         ASSERT_NE(client, NULL);
440 }
441
442 TEST_P(TDMClient, ClientDestroy)
443 {
444         tdm_error ret;
445
446         client = tdm_client_create(&ret);
447         ASSERT_EQ(ret, TDM_ERROR_NONE);
448         ASSERT_NE(client, NULL);
449
450         tdm_client_destroy(client);
451         client = NULL;
452 }
453
454 TEST_P(TDMClient, ClientNullObject)
455 {
456         tdm_client_destroy(NULL);
457 }
458
459 /* tdm_client_get_fd */
460 TEST_P(TDMClient, ClientGetFd)
461 {
462         int fd = TDM_UT_INVALID_VALUE;
463
464         ASSERT_EQ(PrepareClient(), true);
465
466         ASSERT_EQ(tdm_client_get_fd(client, &fd), TDM_ERROR_NONE);
467         ASSERT_GE(fd, 0);
468 }
469
470 TEST_P(TDMClient, ClientGetFdNullObject)
471 {
472         int fd = TDM_UT_INVALID_VALUE;
473         ASSERT_EQ(tdm_client_get_fd(NULL, &fd), TDM_ERROR_INVALID_PARAMETER);
474         ASSERT_EQ(fd, TDM_UT_INVALID_VALUE);
475 }
476
477 TEST_P(TDMClient, ClientGetFdNullOther)
478 {
479         ASSERT_EQ(PrepareClient(), true);
480
481         ASSERT_EQ(tdm_client_get_fd(client, NULL), TDM_ERROR_INVALID_PARAMETER);
482 }
483
484 static void
485 _tc_tdm_client_vblank_cb(unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data)
486 {
487         bool *done = (bool *)user_data;
488         if (done)
489                 *done = true;
490 }
491
492 /* tdm_client_handle_events_timeout */
493 TEST_P(TDMClient, ClientHandleEvent)
494 {
495         bool done = false;
496
497         ASSERT_EQ(PrepareClient(), true);
498
499         ASSERT_EQ(tdm_client_wait_vblank(client, NULL, 1, 1, 0, _tc_tdm_client_vblank_cb, &done), TDM_ERROR_NONE);
500         ASSERT_EQ(done, false);
501
502         while (!done)
503                 ASSERT_EQ(tdm_client_handle_events(client), TDM_ERROR_NONE);
504 }
505
506 TEST_P(TDMClient, ClientHandleEventNullObject)
507 {
508         ASSERT_EQ(tdm_client_handle_events(NULL), TDM_ERROR_INVALID_PARAMETER);
509 }
510
511 /* tdm_client_wait_vblank, deprecated */
512 TEST_P(TDMClient, ClientWaitVblank)
513 {
514         bool done = false;
515
516         ASSERT_EQ(PrepareClient(), true);
517
518         ASSERT_EQ(tdm_client_wait_vblank(client, NULL, 1, 1, 0, _tc_tdm_client_vblank_cb, &done), TDM_ERROR_NONE);
519         ASSERT_EQ(done, false);
520
521         while (!done)
522                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
523 }
524
525 /* tdm_client_get_output */
526 TEST_P(TDMClient, ClientGetOutput)
527 {
528         tdm_error ret;
529
530         ASSERT_EQ(PrepareClient(), true);
531
532         output = tdm_client_get_output(client, NULL, &ret);
533         ASSERT_EQ(ret, TDM_ERROR_NONE);
534         ASSERT_NE(output, NULL);
535 }
536
537 TEST_P(TDMClient, ClientGetOutputPrimary)
538 {
539         tdm_error ret;
540
541         ASSERT_EQ(PrepareClient(), true);
542
543         output = tdm_client_get_output(client, (char*)"primary", &ret);
544         ASSERT_EQ(ret, TDM_ERROR_NONE);
545         ASSERT_NE(output, NULL);
546 }
547
548 TEST_P(TDMClient, ClientGetOutputDefault)
549 {
550         tdm_error ret;
551
552         ASSERT_EQ(PrepareClient(), true);
553
554         output = tdm_client_get_output(client, (char*)"default", &ret);
555         ASSERT_EQ(ret, TDM_ERROR_NONE);
556         ASSERT_NE(output, NULL);
557 }
558
559 TEST_P(TDMClient, ClientGetOutputInvalidName)
560 {
561         tdm_error ret;
562
563         ASSERT_EQ(PrepareClient(), true);
564
565         output = tdm_client_get_output(client, (char*)"invalid", &ret);
566         ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
567         ASSERT_EQ(output, NULL);
568 }
569
570 TEST_P(TDMClient, ClientGetOutputNullObject)
571 {
572         tdm_error ret;
573
574         output = tdm_client_get_output(NULL, NULL, &ret);
575         ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
576         ASSERT_EQ(output, NULL);
577 }
578
579 TEST_P(TDMClient, ClientGetOutputNullOther)
580 {
581         ASSERT_EQ(PrepareClient(), true);
582
583         output = tdm_client_get_output(client, NULL, NULL);
584         ASSERT_NE(output, NULL);
585 }
586
587 static void
588 _tc_tdm_client_output_change_dpms_cb(tdm_client_output *output,
589                                                                          tdm_output_change_type type,
590                                                                          tdm_value value,
591                                                                          void *user_data)
592 {
593         bool *done = (bool *)user_data;
594
595         switch (type) {
596         case TDM_OUTPUT_CHANGE_DPMS:
597                 if (done)
598                         *done = true;
599                 break;
600         default:
601                 break;
602         }
603 }
604
605 /* tdm_client_output_add_change_handler */
606 TEST_P(TDMClient, ClientOutputAddChangeHandler)
607 {
608         bool done = false;
609         tdm_output_dpms dpms;
610
611         ASSERT_EQ(PrepareClient(), true);
612         ASSERT_EQ(PrepareOutput(), true);
613
614         ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, &done), TDM_ERROR_NONE);
615         ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
616
617         while (!done)
618                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
619
620         ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
621         ASSERT_EQ(dpms, TDM_OUTPUT_DPMS_OFF);
622
623         ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
624         while (dpms != TDM_OUTPUT_DPMS_ON) {
625                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
626                 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
627         }
628 }
629
630 TEST_P(TDMClient, ClientOutputAddChangeHandlerTwice)
631 {
632         ASSERT_EQ(PrepareClient(), true);
633         ASSERT_EQ(PrepareOutput(), true);
634
635         ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_NONE);
636         ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_BAD_REQUEST);
637 }
638
639 TEST_P(TDMClient, ClientOutputAddChangeHandlerNullObject)
640 {
641         ASSERT_EQ(tdm_client_output_add_change_handler(NULL, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
642 }
643
644 TEST_P(TDMClient, ClientOutputAddChangeHandlerNullOther)
645 {
646         ASSERT_EQ(PrepareClient(), true);
647         ASSERT_EQ(PrepareOutput(), true);
648
649         ASSERT_EQ(tdm_client_output_add_change_handler(output, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
650 }
651
652 /* tdm_client_output_remove_change_handler */
653 TEST_P(TDMClient, ClientOutputRemoveChangeHandler)
654 {
655         ASSERT_EQ(PrepareClient(), true);
656         ASSERT_EQ(PrepareOutput(), true);
657
658         ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_NONE);
659         tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL);
660 }
661
662 TEST_P(TDMClient, ClientOutputRemoveChangeHandlerDifferentData)
663 {
664         bool done = (bool)TDM_UT_INVALID_VALUE;
665
666         ASSERT_EQ(PrepareClient(), true);
667         ASSERT_EQ(PrepareOutput(), true);
668
669         ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, &done), TDM_ERROR_NONE);
670         tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL);
671 }
672
673 static void
674 _tc_tdm_client_output_change_dpms_cb2(tdm_client_output *output,
675                                                                           tdm_output_change_type type,
676                                                                           tdm_value value,
677                                                                           void *user_data)
678 {
679         switch (type) {
680         case TDM_OUTPUT_CHANGE_DPMS:
681                 tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb2, user_data);
682                 break;
683         default:
684                 break;
685         }
686 }
687
688 TEST_P(TDMClient, ClientOutputRemoveChangeHandlerInHandler)
689 {
690         tdm_output_dpms dpms = TDM_OUTPUT_DPMS_ON;
691
692         ASSERT_EQ(PrepareClient(), true);
693         ASSERT_EQ(PrepareOutput(), true);
694
695         ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb2, NULL), TDM_ERROR_NONE);
696         ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
697         ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
698         while (dpms != TDM_OUTPUT_DPMS_OFF) {
699                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
700                 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
701         }
702
703         ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
704         while (dpms != TDM_OUTPUT_DPMS_ON)
705                 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
706 }
707
708 TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullObject)
709 {
710         tdm_client_output_remove_change_handler(NULL, _tc_tdm_client_output_change_dpms_cb, NULL);
711 }
712
713 TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullOther)
714 {
715         ASSERT_EQ(PrepareClient(), true);
716         ASSERT_EQ(PrepareOutput(), true);
717
718         tdm_client_output_remove_change_handler(output, NULL, NULL);
719 }
720
721 /* tdm_client_output_get_refresh_rate */
722 TEST_P(TDMClient, ClientOutputGetRefreshRate)
723 {
724         unsigned int refresh = 0;
725
726         ASSERT_EQ(PrepareClient(), true);
727         ASSERT_EQ(PrepareOutput(), true);
728
729         ASSERT_EQ(tdm_client_output_get_refresh_rate(output, &refresh), TDM_ERROR_NONE);
730         ASSERT_GT(refresh, 0);
731 }
732
733 TEST_P(TDMClient, ClientOutputGetRefreshRateNullObject)
734 {
735         unsigned int refresh = (unsigned int)TDM_UT_INVALID_VALUE;
736
737         ASSERT_EQ(tdm_client_output_get_refresh_rate(NULL, &refresh), TDM_ERROR_INVALID_PARAMETER);
738         ASSERT_EQ(refresh, (unsigned int)TDM_UT_INVALID_VALUE);
739 }
740
741 TEST_P(TDMClient, ClientOutputGetRefreshRateNullOther)
742 {
743         ASSERT_EQ(PrepareClient(), true);
744         ASSERT_EQ(PrepareOutput(), true);
745
746         ASSERT_EQ(tdm_client_output_get_refresh_rate(output, NULL), TDM_ERROR_INVALID_PARAMETER);
747 }
748
749 /* tdm_client_output_get_refresh_rate */
750 TEST_P(TDMClient, ClientOutputGetConnStatus)
751 {
752         tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
753
754         ASSERT_EQ(PrepareClient(), true);
755         ASSERT_EQ(PrepareOutput(), true);
756
757         ASSERT_EQ(tdm_client_output_get_conn_status(output, &status), TDM_ERROR_NONE);
758         ASSERT_NE(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
759 }
760
761 TEST_P(TDMClient, ClientOutputGetConnStatusNullObject)
762 {
763         tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
764
765         ASSERT_EQ(tdm_client_output_get_conn_status(NULL, &status), TDM_ERROR_INVALID_PARAMETER);
766         ASSERT_EQ(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
767 }
768
769 TEST_P(TDMClient, ClientOutputGetConnStatusNullOther)
770 {
771         ASSERT_EQ(PrepareClient(), true);
772         ASSERT_EQ(PrepareOutput(), true);
773
774         ASSERT_EQ(tdm_client_output_get_conn_status(output, NULL), TDM_ERROR_INVALID_PARAMETER);
775 }
776
777 /* tdm_client_output_get_dpms */
778 TEST_P(TDMClient, ClientOutputGetDpms)
779 {
780         tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
781
782         ASSERT_EQ(PrepareClient(), true);
783         ASSERT_EQ(PrepareOutput(), true);
784
785         ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
786         ASSERT_NE(dpms, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
787 }
788
789 TEST_P(TDMClient, ClientOutputGetDpmsNullObject)
790 {
791         tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
792
793         ASSERT_EQ(tdm_client_output_get_dpms(NULL, &dpms), TDM_ERROR_INVALID_PARAMETER);
794         ASSERT_EQ(dpms, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
795 }
796
797 TEST_P(TDMClient, ClientOutputGetDpmsNullOther)
798 {
799         ASSERT_EQ(PrepareClient(), true);
800         ASSERT_EQ(PrepareOutput(), true);
801
802         ASSERT_EQ(tdm_client_output_get_dpms(output, NULL), TDM_ERROR_INVALID_PARAMETER);
803 }
804
805 TEST_P(TDMClient, ClientOutputGetAvailableModes)
806 {
807         tdm_client_output_mode *modes;
808         int i, count = 0;
809
810         ASSERT_EQ(PrepareClient(), true);
811         ASSERT_EQ(PrepareOutput(), true);
812
813         ASSERT_EQ(tdm_client_output_get_available_modes(output, &modes, &count), TDM_ERROR_NONE);
814         ASSERT_GT(count, 0);
815
816         for (i = 0; i < count; i++) {
817                 tdm_client_output_mode *mode = (tdm_client_output_mode *)&modes[i];
818                 ASSERT_GT(mode->hdisplay, 0);
819                 ASSERT_GT(mode->vdisplay, 0);
820                 ASSERT_GT(mode->vrefresh, 0);
821         }
822 }
823
824 TEST_P(TDMClient, ClientOutputGetAvailableModesNullObject)
825 {
826         tdm_client_output_mode *modes;
827         int count = TDM_UT_INVALID_VALUE;
828
829         ASSERT_EQ(PrepareClient(), true);
830         ASSERT_EQ(PrepareOutput(), true);
831
832         ASSERT_EQ(tdm_client_output_get_available_modes(NULL, &modes, &count), TDM_ERROR_INVALID_PARAMETER);
833         ASSERT_EQ(count, TDM_UT_INVALID_VALUE);
834 }
835
836 TEST_P(TDMClient, ClientOutputGetAvailableModesNullOther)
837 {
838         ASSERT_EQ(PrepareClient(), true);
839         ASSERT_EQ(PrepareOutput(), true);
840
841         ASSERT_EQ(tdm_client_output_get_available_modes(output, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
842 }
843
844 /* tdm_client_output_create_vblank */
845 TEST_P(TDMClient, ClientOutputCreateVblank)
846 {
847         tdm_error ret;
848
849         ASSERT_EQ(PrepareClient(), true);
850         ASSERT_EQ(PrepareOutput(), true);
851
852         vblank = tdm_client_output_create_vblank(output, &ret);
853         ASSERT_EQ(ret, TDM_ERROR_NONE);
854         ASSERT_NE(vblank, NULL);
855 }
856
857 TEST_P(TDMClient, ClientOutputCreateVblankNullObject)
858 {
859         tdm_error ret;
860
861         vblank = tdm_client_output_create_vblank(NULL, &ret);
862         ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
863         ASSERT_EQ(vblank, NULL);
864 }
865
866 TEST_P(TDMClient, ClientOutputCreateVblankNullOther)
867 {
868         ASSERT_EQ(PrepareClient(), true);
869         ASSERT_EQ(PrepareOutput(), true);
870
871         vblank = tdm_client_output_create_vblank(output, NULL);
872         ASSERT_NE(vblank, NULL);
873 }
874
875 /* tdm_client_vblank_destroy */
876 TEST_P(TDMClient, ClientVblankDestroy)
877 {
878         tdm_error ret;
879
880         ASSERT_EQ(PrepareClient(), true);
881         ASSERT_EQ(PrepareOutput(), true);
882
883         vblank = tdm_client_output_create_vblank(output, &ret);
884         ASSERT_EQ(ret, TDM_ERROR_NONE);
885         ASSERT_NE(vblank, NULL);
886
887         tdm_client_vblank_destroy(vblank);
888         vblank = NULL;
889 }
890
891 TEST_P(TDMClient, ClientVblankDestroyNullObject)
892 {
893         tdm_client_vblank_destroy(NULL);
894 }
895
896 /* tdm_client_vblank_set_name */
897 TEST_P(TDMClient, ClientVblankSetName)
898 {
899         ASSERT_EQ(PrepareClient(), true);
900         ASSERT_EQ(PrepareOutput(), true);
901         ASSERT_EQ(PrepareVblank(), true);
902
903         ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
904 }
905
906 TEST_P(TDMClient, ClientVblankSetNameTwice)
907 {
908         ASSERT_EQ(PrepareClient(), true);
909         ASSERT_EQ(PrepareOutput(), true);
910         ASSERT_EQ(PrepareVblank(), true);
911
912         ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
913         ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
914 }
915
916 TEST_P(TDMClient, ClientVblankSetNameNullObject)
917 {
918         ASSERT_EQ(tdm_client_vblank_set_name(NULL, TDM_UT_VBLANK_NAME), TDM_ERROR_INVALID_PARAMETER);
919 }
920
921 /* tdm_client_vblank_set_sync */
922 TEST_P(TDMClient, ClientVblankSetSync)
923 {
924         ASSERT_EQ(PrepareClient(), true);
925         ASSERT_EQ(PrepareOutput(), true);
926         ASSERT_EQ(PrepareVblank(), true);
927
928         ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
929 }
930
931 TEST_P(TDMClient, ClientVblankSetSyncTwice)
932 {
933         ASSERT_EQ(PrepareClient(), true);
934         ASSERT_EQ(PrepareOutput(), true);
935         ASSERT_EQ(PrepareVblank(), true);
936
937         ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
938         ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
939 }
940
941 TEST_P(TDMClient, ClientVblankSetSyncNullObject)
942 {
943         ASSERT_EQ(tdm_client_vblank_set_sync(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
944 }
945
946 /* tdm_client_vblank_set_fps */
947 TEST_P(TDMClient, ClientVblankSetFps)
948 {
949         ASSERT_EQ(PrepareClient(), true);
950         ASSERT_EQ(PrepareOutput(), true);
951         ASSERT_EQ(PrepareVblank(), true);
952
953         ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
954 }
955
956 TEST_P(TDMClient, ClientVblankSetFpsTwice)
957 {
958         ASSERT_EQ(PrepareClient(), true);
959         ASSERT_EQ(PrepareOutput(), true);
960         ASSERT_EQ(PrepareVblank(), true);
961
962         ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
963         ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
964 }
965
966 TEST_P(TDMClient, ClientVblankSetFpsNullObject)
967 {
968         ASSERT_EQ(tdm_client_vblank_set_fps(NULL, 30), TDM_ERROR_INVALID_PARAMETER);
969 }
970
971 /* tdm_client_vblank_set_offset */
972 TEST_P(TDMClient, ClientVblankSetOffset)
973 {
974         ASSERT_EQ(PrepareClient(), true);
975         ASSERT_EQ(PrepareOutput(), true);
976         ASSERT_EQ(PrepareVblank(), true);
977
978         ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
979 }
980
981 TEST_P(TDMClient, ClientVblankSetOffsetTwice)
982 {
983         ASSERT_EQ(PrepareClient(), true);
984         ASSERT_EQ(PrepareOutput(), true);
985         ASSERT_EQ(PrepareVblank(), true);
986
987         ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
988         ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
989 }
990
991 TEST_P(TDMClient, ClientVblankSetOffsetNullObject)
992 {
993         ASSERT_EQ(tdm_client_vblank_set_offset(NULL, 10), TDM_ERROR_INVALID_PARAMETER);
994 }
995
996 /* tdm_client_vblank_set_enable_fake */
997 TEST_P(TDMClient, ClientVblankSetEnableFake)
998 {
999         ASSERT_EQ(PrepareClient(), true);
1000         ASSERT_EQ(PrepareOutput(), true);
1001         ASSERT_EQ(PrepareVblank(), true);
1002
1003         ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
1004 }
1005
1006 TEST_P(TDMClient, ClientVblankSetEnableFakeTwice)
1007 {
1008         ASSERT_EQ(PrepareClient(), true);
1009         ASSERT_EQ(PrepareOutput(), true);
1010         ASSERT_EQ(PrepareVblank(), true);
1011
1012         ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
1013         ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
1014 }
1015
1016 TEST_P(TDMClient, ClientVblankSetEnableFakeNullObject)
1017 {
1018         ASSERT_EQ(tdm_client_vblank_set_enable_fake(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
1019 }
1020
1021 static void
1022 _tc_tdm_client_vblank_cb2(tdm_client_vblank *vblank,
1023                                                   tdm_error error,
1024                                                   unsigned int sequence,
1025                                                   unsigned int tv_sec,
1026                                                   unsigned int tv_usec,
1027                                                   void *user_data)
1028 {
1029         bool *done = (bool *)user_data;
1030         if (done)
1031                 *done = true;
1032 }
1033
1034 /* tdm_client_vblank_wait */
1035 TEST_P(TDMClient, ClientVblankWait)
1036 {
1037         bool done;
1038
1039         ASSERT_EQ(PrepareClient(), true);
1040         ASSERT_EQ(PrepareOutput(), true);
1041         ASSERT_EQ(PrepareVblank(), true);
1042
1043         done = false;
1044         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1045
1046         start = tdm_helper_get_time();
1047         while (!done)
1048                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1049         end = tdm_helper_get_time();
1050
1051         /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1052         ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
1053 }
1054
1055 TEST_P(TDMClient, ClientVblankWaitFewTime)
1056 {
1057         bool done1, done2, done3;
1058
1059         ASSERT_EQ(PrepareClient(), true);
1060         ASSERT_EQ(PrepareOutput(), true);
1061         ASSERT_EQ(PrepareVblank(), true);
1062
1063         done1 = done2 = done3 = false;
1064         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done1), TDM_ERROR_NONE);
1065         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done2), TDM_ERROR_NONE);
1066         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done3), TDM_ERROR_NONE);
1067
1068         start = tdm_helper_get_time();
1069         while (!done1 || !done2 || !done3)
1070                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1071         end = tdm_helper_get_time();
1072
1073         /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1074         ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
1075
1076 }
1077
1078 TEST_P(TDMClient, ClientVblankWaitInterval0)
1079 {
1080         ASSERT_EQ(PrepareClient(), true);
1081         ASSERT_EQ(PrepareOutput(), true);
1082         ASSERT_EQ(PrepareVblank(), true);
1083
1084         ASSERT_EQ(tdm_client_vblank_wait(vblank, 0, _tc_tdm_client_vblank_cb2, NULL), TDM_ERROR_INVALID_PARAMETER);
1085 }
1086
1087 TEST_P(TDMClient, ClientVblankWaitInterval)
1088 {
1089         bool done;
1090
1091         ASSERT_EQ(PrepareClient(), true);
1092         ASSERT_EQ(PrepareOutput(), true);
1093         ASSERT_EQ(PrepareVblank(), true);
1094
1095         /* start from 1 */
1096         for (int t = 1; t < 10; t++) {
1097                 done = false;
1098                 ASSERT_EQ(tdm_client_vblank_wait(vblank, t, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1099
1100                 start = tdm_helper_get_time();
1101                 while (!done)
1102                         ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1103                 end = tdm_helper_get_time();
1104
1105                 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1106                 ASSERT_GT((end - start), (vrefresh_interval * (t - 1)));
1107                 ASSERT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
1108         }
1109 }
1110
1111 static void
1112 _tc_tdm_client_vblank_cb3(tdm_client_vblank *vblank,
1113                                                   tdm_error error,
1114                                                   unsigned int sequence,
1115                                                   unsigned int tv_sec,
1116                                                   unsigned int tv_usec,
1117                                                   void *user_data)
1118 {
1119         unsigned int *cur_seq = (unsigned int *)user_data;
1120         if (cur_seq)
1121                 *cur_seq = sequence;
1122 }
1123
1124 TEST_P(TDMClient, ClientVblankWaitSeq)
1125 {
1126         ASSERT_EQ(PrepareClient(), true);
1127         ASSERT_EQ(PrepareOutput(), true);
1128         ASSERT_EQ(PrepareVblank(), true);
1129
1130         for (int t = 0; t < 10; t++) {
1131                 unsigned int cur_seq = 0, temp = 0;
1132
1133                 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_NONE);
1134                 while (cur_seq == 0)
1135                         ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1136
1137                 start = tdm_helper_get_time();
1138                 ASSERT_EQ(tdm_client_vblank_wait_seq(vblank, cur_seq + 1, _tc_tdm_client_vblank_cb3, &temp), TDM_ERROR_NONE);
1139                 while (temp == 0)
1140                         ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1141                 end = tdm_helper_get_time();
1142
1143                 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1144                 ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
1145         }
1146 }
1147
1148 TEST_P(TDMClient, ClientVblankWaitSeqInterval)
1149 {
1150         ASSERT_EQ(PrepareClient(), true);
1151         ASSERT_EQ(PrepareOutput(), true);
1152         ASSERT_EQ(PrepareVblank(), true);
1153
1154         /* start from 1 */
1155         for (int t = 1; t < 10; t++) {
1156                 unsigned int cur_seq = 0, temp = 0;
1157
1158                 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_NONE);
1159                 while (cur_seq == 0)
1160                         ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1161
1162                 start = tdm_helper_get_time();
1163                 ASSERT_EQ(tdm_client_vblank_wait_seq(vblank, cur_seq + t, _tc_tdm_client_vblank_cb3, &temp), TDM_ERROR_NONE);
1164                 while (temp == 0)
1165                         ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1166                 end = tdm_helper_get_time();
1167
1168                 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1169                 ASSERT_GT((end - start), (vrefresh_interval * (t - 1)));
1170                 ASSERT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
1171         }
1172 }
1173
1174 TEST_P(TDMClient, ClientVblankWaitSetOffset)
1175 {
1176         bool done;
1177
1178         ASSERT_EQ(PrepareClient(), true);
1179         ASSERT_EQ(PrepareOutput(), true);
1180         ASSERT_EQ(PrepareVblank(), true);
1181
1182         ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 100), TDM_ERROR_NONE);
1183
1184         done = false;
1185         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1186
1187         start = tdm_helper_get_time();
1188         while (!done)
1189                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1190         end = tdm_helper_get_time();
1191
1192         /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1193         ASSERT_GT((end - start), (0.1));
1194         ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval + 0.1));
1195 }
1196
1197 TEST_P(TDMClient, ClientVblankWaitSetFps)
1198 {
1199         bool done;
1200         double interval;
1201         unsigned int fps = 10;
1202
1203         ASSERT_EQ(PrepareClient(), true);
1204         ASSERT_EQ(PrepareOutput(), true);
1205         ASSERT_EQ(PrepareVblank(), true);
1206
1207         ASSERT_EQ(tdm_client_vblank_set_fps(vblank, fps), TDM_ERROR_NONE);
1208         interval = 1.0 / (double)fps;
1209
1210         done = false;
1211         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1212
1213         start = tdm_helper_get_time();
1214         while (!done)
1215                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1216         end = tdm_helper_get_time();
1217
1218         /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1219         ASSERT_GT((end - start), (interval - vrefresh_interval));
1220         ASSERT_LT((end - start), (interval + vrefresh_interval));
1221 }
1222
1223 #if 0
1224
1225 TEST_P(TDMVblank, VblankWaitEnableDisableGlobalFps)
1226 {
1227         TDM_UT_SKIP_FLAG(has_outputs);
1228
1229         unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
1230         double vrefresh_interval;
1231         unsigned int cur_seq[3];
1232         unsigned int global_fps = 5;
1233         double start, end, interval;
1234
1235         ASSERT_EQ(TestPrepareOutput(), true);
1236         ASSERT_EQ(TestCreateVblanks3(), true);
1237         ASSERT_EQ(vblank_count, 3);
1238
1239         ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
1240         ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
1241         vrefresh_interval = 1.0 / (double)fps;
1242
1243         for (int v = 0; v < 3; v++)
1244                 ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 10 * (v + 1)), TDM_ERROR_NONE);
1245
1246         /* enable test */
1247         tdm_vblank_enable_global_fps(1, global_fps);
1248         interval = 1.0 / (double)global_fps;
1249
1250         for (int v = 0; v < 3; v++) {
1251                 cur_seq[v] = 0;
1252                 ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
1253         }
1254
1255         start = tdm_helper_get_time();
1256         while (cur_seq[0] == 0)
1257                 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1258         end = tdm_helper_get_time();
1259
1260         ASSERT_NE(cur_seq[1], 0);
1261         ASSERT_NE(cur_seq[2], 0);
1262
1263         /* "+- vrefresh_interval" consider the delay of socket communication between kernel and platform */
1264         ASSERT_GT((end - start), (interval - vrefresh_interval));
1265         ASSERT_LT((end - start), (interval + vrefresh_interval));
1266
1267         /* disable test */
1268         tdm_vblank_enable_global_fps(0, 0);
1269
1270         for (int v = 0; v < 3; v++) {
1271                 cur_seq[v] = 0;
1272                 ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
1273         }
1274
1275         while (cur_seq[0] == 0)
1276                 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1277         ASSERT_EQ(cur_seq[1], 0);
1278         ASSERT_EQ(cur_seq[2], 0);
1279
1280         while (cur_seq[1] == 0)
1281                 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1282         ASSERT_EQ(cur_seq[2], 0);
1283 }
1284
1285 TEST_P(TDMVblank, VblankWaitIgnoreGlobalFps)
1286 {
1287         TDM_UT_SKIP_FLAG(has_outputs);
1288
1289         unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
1290         unsigned int cur_seq[3];
1291         unsigned int global_fps = 5;
1292         double start, end, interval;
1293
1294         ASSERT_EQ(TestPrepareOutput(), true);
1295         ASSERT_EQ(TestCreateVblanks3(), true);
1296         ASSERT_EQ(vblank_count, 3);
1297
1298         ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
1299         ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
1300         interval = 1.0 / (double)fps;
1301
1302         /* 2nd vblank will ignore the global fps. */
1303         ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[1], 1), TDM_ERROR_NONE);
1304
1305         tdm_vblank_enable_global_fps(1, global_fps);
1306
1307         for (int v = 0; v < 3; v++) {
1308                 cur_seq[v] = 0;
1309                 ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
1310         }
1311
1312         start = tdm_helper_get_time();
1313         while (cur_seq[1] == 0)
1314                 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1315         end = tdm_helper_get_time();
1316
1317         ASSERT_EQ(cur_seq[0], 0);
1318         ASSERT_EQ(cur_seq[2], 0);
1319
1320         /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1321         ASSERT_LT((end - start), (interval + interval));
1322
1323         while (cur_seq[0] == 0)
1324                 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1325         ASSERT_NE(cur_seq[2], 0);
1326 }
1327
1328 #endif
1329
1330 TEST_P(TDMClient, ClientVblankWaitNullObject)
1331 {
1332         unsigned int cur_seq = 0;
1333
1334         ASSERT_EQ(tdm_client_vblank_wait(NULL, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_INVALID_PARAMETER);
1335 }
1336
1337 TEST_P(TDMClient, ClientVblankWaitNullOther)
1338 {
1339         ASSERT_EQ(PrepareClient(), true);
1340         ASSERT_EQ(PrepareOutput(), true);
1341         ASSERT_EQ(PrepareVblank(), true);
1342
1343         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
1344 }
1345
1346 TEST_P(TDMClient, ClientVblankWaitDpmsOff)
1347 {
1348         tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
1349
1350         ASSERT_EQ(PrepareClient(), true);
1351         ASSERT_EQ(PrepareOutput(), true);
1352         ASSERT_EQ(PrepareVblank(), true);
1353
1354         ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
1355         while (dpms != TDM_OUTPUT_DPMS_OFF)
1356                 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
1357         ASSERT_EQ(dpms, TDM_OUTPUT_DPMS_OFF);
1358
1359         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, NULL), TDM_ERROR_DPMS_OFF);
1360
1361         ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
1362         while (dpms != TDM_OUTPUT_DPMS_ON)
1363                 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
1364 }
1365
1366 TEST_P(TDMClient, ClientVblankWaitSetEnableFakeDpmsOff)
1367 {
1368         tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
1369         bool done;
1370
1371         ASSERT_EQ(PrepareClient(), true);
1372         ASSERT_EQ(PrepareOutput(), true);
1373         ASSERT_EQ(PrepareVblank(), true);
1374
1375         ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
1376         while (dpms != TDM_OUTPUT_DPMS_OFF)
1377                 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
1378
1379         ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
1380
1381         done = false;
1382         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1383
1384         while (!done)
1385                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1386
1387         ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
1388         while (dpms != TDM_OUTPUT_DPMS_ON)
1389                 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
1390 }
1391
1392 /* tdm_client_vblank_wait */
1393 TEST_P(TDMClient, ClientVblankIsWaiting)
1394 {
1395         bool done;
1396         unsigned int waiting;
1397
1398         ASSERT_EQ(PrepareClient(), true);
1399         ASSERT_EQ(PrepareOutput(), true);
1400         ASSERT_EQ(PrepareVblank(), true);
1401
1402         done = false;
1403         ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1404
1405         waiting = tdm_client_vblank_is_waiting(vblank);
1406         ASSERT_EQ(waiting, 1);
1407
1408         start = tdm_helper_get_time();
1409         while (!done)
1410                 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1411         end = tdm_helper_get_time();
1412
1413         /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1414         ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
1415
1416         waiting = tdm_client_vblank_is_waiting(vblank);
1417         ASSERT_EQ(waiting, 0);
1418 }
1419
1420 /* tdm_client_vblank_wait */
1421 TEST_P(TDMClient, ClientVblankIsWaitingNullObject)
1422 {
1423         unsigned int waiting = tdm_client_vblank_is_waiting(NULL);
1424         ASSERT_EQ(waiting, 0);
1425 }
1426
1427 TEST_P(TDMClient, ClientCreateVOutput)
1428 {
1429         tdm_error ret;
1430         const char name[TDM_NAME_LEN] = "Virtual Output";
1431
1432         ASSERT_EQ(PrepareClient(), true);
1433         
1434         voutput = tdm_client_create_voutput(client, name, &ret);
1435         ASSERT_EQ(ret, TDM_ERROR_NONE);
1436         ASSERT_NE(voutput, NULL);
1437
1438         tdm_client_voutput_destroy(voutput);
1439 }
1440
1441 class TDMVirtualOutput : public ::testing::Test
1442 {
1443 public:
1444         TDMVirtualOutput() {};
1445         ~TDMVirtualOutput() {};
1446
1447         static void SetUpTestCase();
1448         static void TearDownTestCase();
1449         static bool PrepareVOutput(void);
1450
1451 protected:
1452         static tdm_client *client;
1453         static tdm_client_voutput *voutput;
1454         const int MODE_COUNT = 2;
1455
1456 private:
1457         static pid_t server_pid;
1458
1459         /* 0: read, 1: write */
1460         static int pipe_parent[2];
1461         static int pipe_child[2];
1462
1463         static void ServerFork(void);
1464         static void ServerKill(void);
1465 };
1466
1467 pid_t TDMVirtualOutput::server_pid = -1;
1468 int TDMVirtualOutput::pipe_parent[2] = {-1, -1};
1469 int TDMVirtualOutput::pipe_child[2] = {-1, -1};
1470 tdm_client* TDMVirtualOutput::client = nullptr;
1471 tdm_client_voutput* TDMVirtualOutput::voutput = nullptr;
1472
1473 void TDMVirtualOutput::ServerKill(void)
1474 {
1475         if (pipe_child[0] >= 0)
1476                 close(pipe_child[0]);
1477         if (pipe_child[1] >= 0) {
1478                 if (server_pid > 0) {
1479                         bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
1480                         if (ret) {
1481                                 if (waitpid(server_pid, NULL, 0) == server_pid)
1482                                         TDM_INFO("*** server terminated ***");
1483                                 else
1484                                         TDM_ERR("*** failed to terminate server ***");
1485                         } else {
1486                                 if (kill(server_pid, 9) < 0)
1487                                         TDM_ERR("*** failed to kill server ***");
1488                         }
1489                 }
1490                 close(pipe_child[1]);
1491         }
1492
1493         if (pipe_parent[0] >= 0)
1494                 close(pipe_parent[0]);
1495         if (pipe_parent[1] >= 0)
1496                 close(pipe_parent[1]);
1497
1498         server_pid = -1;
1499         pipe_parent[0] = pipe_parent[1] = -1;
1500         pipe_child[0] = pipe_child[1] = -1;
1501 }
1502
1503 void TDMVirtualOutput::ServerFork(void)
1504 {
1505         if (server_pid > 0)
1506                 return;
1507
1508         server_pid = _tc_tdm_client_server_fork(pipe_parent, pipe_child);
1509         ASSERT_GT(server_pid, 0);
1510 }
1511
1512 void TDMVirtualOutput::SetUpTestCase(void)
1513 {
1514         setenv("XDG_RUNTIME_DIR", "/run", 1);
1515         setenv("TBM_DISPLAY_SERVER", "1", 1);
1516
1517         if (server_pid == -1)
1518                 ServerFork();
1519
1520         ASSERT_EQ(PrepareVOutput(), true);
1521 }
1522
1523 void TDMVirtualOutput::TearDownTestCase(void)
1524 {
1525 //      TDM_UT_WAIT("check & press");
1526
1527         if (voutput)
1528                 tdm_client_voutput_destroy(voutput);
1529
1530         if (client)
1531                 tdm_client_destroy(client);
1532
1533         ServerKill();
1534
1535         unsetenv("XDG_RUNTIME_DIR");
1536         unsetenv("TBM_DISPLAY_SERVER");
1537 }
1538
1539 bool TDMVirtualOutput::PrepareVOutput(void)
1540 {
1541         tdm_error ret;
1542         const char name[TDM_NAME_LEN] = "Virtual Output";
1543
1544         client = tdm_client_create(&ret);
1545         TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
1546         TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
1547
1548
1549         voutput = tdm_client_create_voutput(client, name, &ret);
1550         TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
1551         TDM_UT_RETURN_FALSE_IF_FAIL(voutput != NULL);
1552
1553 //      TDM_UT_WAIT("check & press");
1554
1555         return true;
1556 }
1557
1558 static void
1559 _tc_tdm_client_virutual_make_available_mode(tdm_client_output_mode *modes, int count)
1560 {
1561         int i;
1562
1563         for (i = 0; i < count; i++) {
1564                 modes[i].clock = 25200;
1565                 modes[i].hdisplay = 640;
1566                 modes[i].hsync_start = 656;
1567                 modes[i].hsync_end = 752;
1568                 modes[i].htotal = 800;
1569                 modes[i].hskew = 0;
1570                 modes[i].vdisplay = 480;
1571                 modes[i].vsync_start = 490;
1572                 modes[i].vsync_end = 492;
1573                 modes[i].vtotal = 525;
1574                 modes[i].vscan = 0;
1575                 modes[i].vrefresh = 30;
1576                 modes[i].flags = 0;
1577                 modes[i].type = 0;
1578                 snprintf(modes[i].name, TDM_NAME_LEN, "%dx%d_%d", modes[i].hdisplay, modes[i].vdisplay, i);
1579         }
1580 }
1581
1582 TEST_F(TDMVirtualOutput, SetAvailableModes)
1583 {
1584         tdm_error ret;
1585         tdm_client_output_mode modes[this->MODE_COUNT];
1586         int count = this->MODE_COUNT;
1587
1588         _tc_tdm_client_virutual_make_available_mode(modes, count);
1589
1590         ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
1591         ASSERT_EQ(ret, TDM_ERROR_NONE);
1592 }
1593
1594 TEST_F(TDMVirtualOutput, FailTestSetAvailableModes)
1595 {
1596         tdm_error ret;
1597         tdm_client_output_mode modes[this->MODE_COUNT];
1598         int count = this->MODE_COUNT;
1599
1600         ret = tdm_client_voutput_set_available_modes(NULL, modes, count);
1601         ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
1602
1603         ret = tdm_client_voutput_set_available_modes(this->voutput, NULL, count);
1604         ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
1605 }
1606
1607 TEST_F(TDMVirtualOutput, SetPhysicalSize)
1608 {
1609         tdm_error ret;
1610         unsigned int mmWidth = 1234, mmHeight = 1234;
1611
1612         ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
1613         ASSERT_EQ(ret, TDM_ERROR_NONE);
1614 }
1615
1616 TEST_F(TDMVirtualOutput, FailTestSetPhysicalSize)
1617 {
1618         tdm_error ret;
1619         unsigned int invalid_mmWidth = 0, invalid_mmHeight = 0;
1620
1621         ret = tdm_client_voutput_set_physical_size(this->voutput, invalid_mmWidth, invalid_mmHeight);
1622         ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
1623 }
1624
1625 static void
1626 _tc_tdm_client_voutput_commit_handler(tdm_client_voutput *voutput, tbm_surface_h buffer, void *user_data)
1627 {
1628         int *flag;
1629         flag = (int *)user_data;
1630         *flag = 1;
1631 }
1632
1633 TEST_F(TDMVirtualOutput, AddCommitHandler)
1634 {
1635         tdm_error ret;
1636         int flag_callback_called = 0;
1637
1638         ret = tdm_client_voutput_add_commit_handler(this->voutput,
1639                                                                                                 _tc_tdm_client_voutput_commit_handler,
1640                                                                                                 &flag_callback_called);
1641         ASSERT_EQ(ret, TDM_ERROR_NONE);
1642 //      ASSERT_EQ(flag_callback_called, 1);
1643
1644         tdm_client_voutput_remove_commit_handler(this->voutput,
1645                                                                                          _tc_tdm_client_voutput_commit_handler,
1646                                                                                          &flag_callback_called);
1647 }
1648
1649 TEST_F(TDMVirtualOutput, CommitDone)
1650 {
1651         tdm_error ret;
1652
1653         ret = tdm_client_voutput_commit_done(this->voutput);
1654         ASSERT_EQ(ret, TDM_ERROR_NONE);
1655 }
1656
1657 TEST_F(TDMVirtualOutput, GetClientOutput)
1658 {
1659         tdm_error ret;
1660         tdm_client_output *output;
1661
1662         output = tdm_client_voutput_get_client_output(this->voutput, &ret);
1663         ASSERT_EQ(ret, TDM_ERROR_NONE);
1664         ASSERT_NE(output, NULL);
1665 }
1666
1667 TEST_F(TDMVirtualOutput, Connect)
1668 {
1669         tdm_error ret;
1670         tdm_client_output *output;
1671         unsigned int mmWidth = 300, mmHeight = 150;
1672         tdm_client_output_mode modes[this->MODE_COUNT];
1673         int count = this->MODE_COUNT;
1674
1675         output = tdm_client_voutput_get_client_output(this->voutput, &ret);
1676         ASSERT_EQ(ret, TDM_ERROR_NONE);
1677         ASSERT_NE(output, NULL);
1678
1679         ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
1680         ASSERT_EQ(ret, TDM_ERROR_NONE);
1681
1682         _tc_tdm_client_virutual_make_available_mode(modes, count);
1683         ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
1684         ASSERT_EQ(ret, TDM_ERROR_NONE);
1685
1686         ret = tdm_client_output_connect(output);
1687         ASSERT_EQ(ret, TDM_ERROR_NONE);
1688
1689         tdm_client_handle_events_timeout(this->client, 0);
1690 }
1691
1692 TEST_F(TDMVirtualOutput, Disconnect)
1693 {
1694         tdm_error ret;
1695         tdm_client_output *output;
1696
1697 //      TDM_UT_WAIT("check & press");
1698
1699         output = tdm_client_voutput_get_client_output(this->voutput, &ret);
1700         ASSERT_EQ(ret, TDM_ERROR_NONE);
1701         ASSERT_NE(output, NULL);
1702
1703         ret = tdm_client_output_disconnect(output);
1704         ASSERT_EQ(ret, TDM_ERROR_NONE);
1705
1706         tdm_client_handle_events_timeout(this->client, 0);
1707 }
1708
1709 #if 0
1710 TEST_F(TDMVirtualOutput, FailTestGetClientOutput)
1711 {
1712         tdm_error ret;
1713 }
1714
1715 TEST_F(TDMVirtualOutput, SetBufferQueue)
1716 {
1717         tdm_error ret;
1718 }
1719
1720 TEST_F(TDMVirtualOutput, FailTestSetBufferQueue)
1721 {
1722         tdm_error ret;
1723 }
1724
1725 #endif
1726
1727 #ifdef TDM_UT_TEST_WITH_PARAMS
1728 INSTANTIATE_TEST_CASE_P(TDMClientParams,
1729                                                 TDMClient,
1730                                                 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
1731 #else
1732 INSTANTIATE_TEST_CASE_P(TDMClientParams,
1733                                                 TDMClient,
1734                                                 Values(TDM_DEFAULT_MODULE));
1735 #endif
1736
1737 /* LCOV_EXCL_END */