1 /**************************************************************************
3 * Copyright 2017 Samsung Electronics co., Ltd. All Rights Reserved.
5 * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
6 * Contact: Andrii Sokolenko <a.sokolenko@samsung.com>
7 * Contact: Roman Marchenko <r.marchenko@samsung.com>
8 * Contact: Sergey Sizonov <s.sizonov@samsung.com>
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:
18 * The above copyright notice and this permission notice (including the
19 * next paragraph) shall be included in all copies or substantial portions
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.
30 **************************************************************************/
34 #include <sys/signalfd.h>
36 #include <sys/prctl.h>
39 #include "tdm_client.h"
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,
53 #define TDM_UT_WAIT(fmt, ...) \
57 printf(fmt" [n]):next ", ##__VA_ARGS__); \
58 ch = tc_tdm_getchar(); \
59 } while (ch != 'n'); \
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);
66 class TDMClient : public TDMEnv
69 static pid_t server_pid;
71 /* 0: read, 1: write */
72 static int pipe_parent[2];
73 static int pipe_child[2];
76 tdm_client_output *output;
77 tdm_client_vblank *vblank;
78 tdm_client_voutput *voutput;
80 double vrefresh_interval, start, end;
86 bool PrepareClient(void);
87 bool PrepareOutput(void);
88 bool PrepareVblank(void);
90 static void TearDownTestCase(void);
91 static void ServerFork(void);
92 static void ServerKill(void);
95 pid_t TDMClient::server_pid = -1;
96 int TDMClient::pipe_parent[2] = {-1, -1};
97 int TDMClient::pipe_child[2] = {-1, -1};
99 void TDMClient::TearDownTestCase(void)
104 void TDMClient::ServerFork(void)
109 server_pid = _tc_tdm_client_server_fork(pipe_parent, pipe_child);
110 ASSERT_GT(server_pid, 0);
113 void TDMClient::ServerKill(void)
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);
121 if (waitpid(server_pid, NULL, 0) == server_pid)
122 TDM_INFO("*** server terminated ***");
124 TDM_ERR("*** failed to terminate server ***");
126 if (kill(server_pid, 9) < 0)
127 TDM_ERR("*** failed to kill server ***");
130 close(pipe_child[1]);
133 if (pipe_parent[0] >= 0)
134 close(pipe_parent[0]);
135 if (pipe_parent[1] >= 0)
136 close(pipe_parent[1]);
139 pipe_parent[0] = pipe_parent[1] = -1;
140 pipe_child[0] = pipe_child[1] = -1;
143 TDMClient::TDMClient()
149 vrefresh_interval = start = end = 0.0;
152 void TDMClient::SetUp(void)
156 if (server_pid == -1)
160 void TDMClient::TearDown(void)
163 tdm_client_vblank_destroy(vblank);
165 tdm_client_destroy(client);
170 bool TDMClient::PrepareClient(void)
173 client = tdm_client_create(&ret);
174 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
175 TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
180 bool TDMClient::PrepareOutput(void)
184 TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
186 output = tdm_client_get_output(client, NULL, &ret);
187 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
188 TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
193 bool TDMClient::PrepareVblank(void)
196 unsigned int refresh;
198 TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
200 vblank = tdm_client_output_create_vblank(output, &ret);
201 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
202 TDM_UT_RETURN_FALSE_IF_FAIL(vblank != NULL);
204 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_client_output_get_refresh_rate(output, &refresh) == TDM_ERROR_NONE);
205 TDM_UT_RETURN_FALSE_IF_FAIL(refresh > 0);
207 vrefresh_interval = 1.0 / (double)refresh;
208 TDM_UT_RETURN_FALSE_IF_FAIL(vrefresh_interval > 0);
219 if (ch == '\n' || ch == '\r')
224 while (c != '\n' && c != EOF)
231 _tc_tdm_pipe_read_msg(int fd)
237 len = read(fd, &msg, sizeof msg);
238 } while (len < 0 && errno == EINTR);
241 msg = TDM_UT_PIPE_MSG_NONE;
247 _tc_tdm_pipe_write_msg(int fd, int reply_fd, int msg)
249 ssize_t len = write(fd, &msg, sizeof msg);
250 TDM_UT_RETURN_FALSE_IF_FAIL(len == sizeof msg);
253 int reply = _tc_tdm_pipe_read_msg(reply_fd);
254 TDM_UT_RETURN_FALSE_IF_FAIL(reply == TDM_UT_PIPE_MSG_REPLY);
261 _tc_tdm_server_set_output_dpms(tdm_display *dpy, int msg)
265 tdm_output_dpms dpms;
267 output = tdm_display_find_output(dpy, "primary", &ret);
268 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
269 TDM_UT_RETURN_FALSE_IF_FAIL(output != NULL);
271 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_dpms(output, &dpms) == TDM_ERROR_NONE);
274 case TDM_UT_PIPE_MSG_DPMS_ON:
275 if (dpms != TDM_OUTPUT_DPMS_ON)
276 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE);
278 case TDM_UT_PIPE_MSG_DPMS_OFF:
279 if (dpms != TDM_OUTPUT_DPMS_OFF)
280 TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF) == TDM_ERROR_NONE);
290 _tc_tdm_test_server_cb_output_mode_change(tdm_output *output, unsigned int index, void *user_data)
292 const tdm_output_mode *modes, *mode;
296 ret = tdm_output_get_available_modes(output, &modes, &count);
297 TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
298 TDM_UT_RETURN_IF_FAIL((int)index < count);
300 mode = &modes[index];
302 ret = tdm_output_set_mode(output, mode);
303 TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
305 ret = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON);
306 TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
308 ret = tdm_output_commit(output, 0, NULL, NULL);
309 TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
313 _tc_tdm_output_cb_destroy_handler(tdm_output *output, void *user_data)
317 tdm_output_remove_mode_change_request_handler(output, _tc_tdm_test_server_cb_output_mode_change, NULL);
318 tdm_output_remove_destroy_handler(output, _tc_tdm_output_cb_destroy_handler, NULL);
320 ret = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF);
321 TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
325 _tc_tdm_output_cb_create_handler(tdm_display *dpy, tdm_output *output, void *user_data)
327 tdm_error ret = TDM_ERROR_NONE;
329 ret = tdm_output_add_mode_change_request_handler(output, _tc_tdm_test_server_cb_output_mode_change, NULL);
330 TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
332 ret = tdm_output_add_destroy_handler(output, _tc_tdm_output_cb_destroy_handler, NULL);
333 TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
337 _tc_tdm_server_run(int *pipe_parent, int *pipe_child)
339 tdm_display *dpy = NULL;
341 struct pollfd fds[2];
343 int output_count = 0;
346 dpy = tdm_display_init(&ret);
347 TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
348 TDM_UT_GOTO_IF_FAIL(dpy != NULL, failed);
350 TDM_UT_GOTO_IF_FAIL(tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE, failed);
352 for (int o = 0; o < output_count; o++) {
353 tdm_output *output = tdm_display_get_output(dpy, o, &ret);
354 TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
355 TDM_UT_GOTO_IF_FAIL(output != NULL, failed);
357 if (!tc_tdm_output_is_connected(output))
360 TDM_UT_GOTO_IF_FAIL(tc_tdm_output_prepare(dpy, output, true) == true, failed);
363 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
365 ret = tdm_display_add_output_create_handler(dpy, _tc_tdm_output_cb_create_handler, NULL);
366 TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
369 TDM_UT_GOTO_IF_FAIL(_tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_READY) == true, done);
371 TDM_INFO("*** server ready ***");
373 ret = tdm_display_get_fd(dpy, &tdm_fd);
374 TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, done);
376 fds[0].events = POLLIN;
380 fds[1].events = POLLIN;
381 fds[1].fd = pipe_child[0];
385 /* make sure all events are flushed to clients before falling in sleep */
386 tdm_display_flush(dpy);
388 err = poll(fds, 2, -1);
390 if (errno == EINTR || errno == EAGAIN) {
393 TDM_ERR("server-process: poll failed: %m\n");
398 if (fds[0].revents & POLLIN)
399 ret = tc_tdm_display_handle_events(dpy);
401 if (fds[1].revents & POLLIN) {
402 int msg = _tc_tdm_pipe_read_msg(pipe_child[0]);
403 _tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_REPLY);
406 case TDM_UT_PIPE_MSG_DPMS_ON:
407 case TDM_UT_PIPE_MSG_DPMS_OFF:
408 _tc_tdm_server_set_output_dpms(dpy, msg);
410 case TDM_UT_PIPE_MSG_TERMINATE_SERVER:
420 tdm_display_deinit(dpy);
424 TDM_UT_GOTO_IF_FAIL(_tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_FAILED) == true, done);
425 TDM_INFO("*** server failed ***");
428 tdm_display_deinit(dpy);
433 static void _tc_tdm_client_sig_handler(int sig)
435 TDM_UT_ERR("got signal: %d", sig);
436 kill(TDMClient::server_pid, 9);
441 _tc_tdm_client_server_fork(int *pipe_parent, int *pipe_child)
446 TDM_UT_GOTO_IF_FAIL(pipe(pipe_parent) == 0, failed);
447 TDM_UT_GOTO_IF_FAIL(pipe(pipe_child) == 0, failed);
449 signal(SIGCHLD, SIG_IGN);
450 signal(SIGSEGV, _tc_tdm_client_sig_handler);
452 prctl(PR_SET_PDEATHSIG, SIGHUP);
455 TDM_UT_GOTO_IF_FAIL(pid >= 0, failed);
458 _tc_tdm_server_run(pipe_parent, pipe_child);
459 close(pipe_child[0]);
460 close(pipe_child[1]);
461 close(pipe_parent[0]);
462 close(pipe_parent[1]);
464 #ifdef TIZEN_TEST_GCOV
471 msg = _tc_tdm_pipe_read_msg(pipe_parent[0]);
472 TDM_UT_GOTO_IF_FAIL(msg == TDM_UT_PIPE_MSG_SERVER_READY, failed);
474 TDM_INFO("*** server fork done ***");
482 TEST_P(TDMClient, ClientCreate)
486 client = tdm_client_create(&ret);
487 ASSERT_EQ(ret, TDM_ERROR_NONE);
488 ASSERT_NE(client, NULL);
491 TEST_P(TDMClient, ClientCreateNullOther)
493 client = tdm_client_create(NULL);
494 ASSERT_NE(client, NULL);
497 TEST_P(TDMClient, ClientDestroy)
501 client = tdm_client_create(&ret);
502 ASSERT_EQ(ret, TDM_ERROR_NONE);
503 ASSERT_NE(client, NULL);
505 tdm_client_destroy(client);
509 TEST_P(TDMClient, ClientNullObject)
511 tdm_client_destroy(NULL);
514 /* tdm_client_get_fd */
515 TEST_P(TDMClient, ClientGetFd)
517 int fd = TDM_UT_INVALID_VALUE;
519 ASSERT_EQ(PrepareClient(), true);
521 ASSERT_EQ(tdm_client_get_fd(client, &fd), TDM_ERROR_NONE);
525 TEST_P(TDMClient, ClientGetFdNullObject)
527 int fd = TDM_UT_INVALID_VALUE;
528 ASSERT_EQ(tdm_client_get_fd(NULL, &fd), TDM_ERROR_INVALID_PARAMETER);
529 ASSERT_EQ(fd, TDM_UT_INVALID_VALUE);
532 TEST_P(TDMClient, ClientGetFdNullOther)
534 ASSERT_EQ(PrepareClient(), true);
536 ASSERT_EQ(tdm_client_get_fd(client, NULL), TDM_ERROR_INVALID_PARAMETER);
540 _tc_tdm_client_vblank_cb(unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data)
542 bool *done = (bool *)user_data;
547 /* tdm_client_handle_events_timeout */
548 TEST_P(TDMClient, ClientHandleEvent)
552 ASSERT_EQ(PrepareClient(), true);
554 ASSERT_EQ(tdm_client_wait_vblank(client, NULL, 1, 1, 0, _tc_tdm_client_vblank_cb, &done), TDM_ERROR_NONE);
555 ASSERT_EQ(done, false);
558 ASSERT_EQ(tdm_client_handle_events(client), TDM_ERROR_NONE);
561 TEST_P(TDMClient, ClientHandleEventNullObject)
563 ASSERT_EQ(tdm_client_handle_events(NULL), TDM_ERROR_INVALID_PARAMETER);
566 /* tdm_client_wait_vblank, deprecated */
567 TEST_P(TDMClient, ClientWaitVblank)
571 ASSERT_EQ(PrepareClient(), true);
573 ASSERT_EQ(tdm_client_wait_vblank(client, NULL, 1, 1, 0, _tc_tdm_client_vblank_cb, &done), TDM_ERROR_NONE);
574 ASSERT_EQ(done, false);
577 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
580 /* tdm_client_get_output */
581 TEST_P(TDMClient, ClientGetOutput)
585 ASSERT_EQ(PrepareClient(), true);
587 output = tdm_client_get_output(client, NULL, &ret);
588 ASSERT_EQ(ret, TDM_ERROR_NONE);
589 ASSERT_NE(output, NULL);
592 TEST_P(TDMClient, ClientGetOutputPrimary)
596 ASSERT_EQ(PrepareClient(), true);
598 output = tdm_client_get_output(client, (char*)"primary", &ret);
599 ASSERT_EQ(ret, TDM_ERROR_NONE);
600 ASSERT_NE(output, NULL);
603 TEST_P(TDMClient, ClientGetOutputDefault)
607 ASSERT_EQ(PrepareClient(), true);
609 output = tdm_client_get_output(client, (char*)"default", &ret);
610 ASSERT_EQ(ret, TDM_ERROR_NONE);
611 ASSERT_NE(output, NULL);
614 TEST_P(TDMClient, ClientGetOutputInvalidName)
618 ASSERT_EQ(PrepareClient(), true);
620 output = tdm_client_get_output(client, (char*)"invalid", &ret);
621 ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
622 ASSERT_EQ(output, NULL);
625 TEST_P(TDMClient, ClientGetOutputNullObject)
629 output = tdm_client_get_output(NULL, NULL, &ret);
630 ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
631 ASSERT_EQ(output, NULL);
634 TEST_P(TDMClient, ClientGetOutputNullOther)
636 ASSERT_EQ(PrepareClient(), true);
638 output = tdm_client_get_output(client, NULL, NULL);
639 ASSERT_NE(output, NULL);
643 _tc_tdm_client_output_change_dpms_cb(tdm_client_output *output,
644 tdm_output_change_type type,
648 bool *done = (bool *)user_data;
651 case TDM_OUTPUT_CHANGE_DPMS:
660 /* tdm_client_output_add_change_handler */
661 TEST_P(TDMClient, ClientOutputAddChangeHandler)
664 tdm_output_dpms dpms;
666 ASSERT_EQ(PrepareClient(), true);
667 ASSERT_EQ(PrepareOutput(), true);
669 ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, &done), TDM_ERROR_NONE);
670 ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
673 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
675 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
676 ASSERT_EQ(dpms, TDM_OUTPUT_DPMS_OFF);
678 ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
679 while (dpms != TDM_OUTPUT_DPMS_ON) {
680 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
681 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
685 TEST_P(TDMClient, ClientOutputAddChangeHandlerTwice)
687 ASSERT_EQ(PrepareClient(), true);
688 ASSERT_EQ(PrepareOutput(), true);
690 ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_NONE);
691 ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_BAD_REQUEST);
694 TEST_P(TDMClient, ClientOutputAddChangeHandlerNullObject)
696 ASSERT_EQ(tdm_client_output_add_change_handler(NULL, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_INVALID_PARAMETER);
699 TEST_P(TDMClient, ClientOutputAddChangeHandlerNullOther)
701 ASSERT_EQ(PrepareClient(), true);
702 ASSERT_EQ(PrepareOutput(), true);
704 ASSERT_EQ(tdm_client_output_add_change_handler(output, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
707 /* tdm_client_output_remove_change_handler */
708 TEST_P(TDMClient, ClientOutputRemoveChangeHandler)
710 ASSERT_EQ(PrepareClient(), true);
711 ASSERT_EQ(PrepareOutput(), true);
713 ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL), TDM_ERROR_NONE);
714 tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL);
717 TEST_P(TDMClient, ClientOutputRemoveChangeHandlerDifferentData)
719 bool done = (bool)TDM_UT_INVALID_VALUE;
721 ASSERT_EQ(PrepareClient(), true);
722 ASSERT_EQ(PrepareOutput(), true);
724 ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb, &done), TDM_ERROR_NONE);
725 tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb, NULL);
729 _tc_tdm_client_output_change_dpms_cb2(tdm_client_output *output,
730 tdm_output_change_type type,
735 case TDM_OUTPUT_CHANGE_DPMS:
736 tdm_client_output_remove_change_handler(output, _tc_tdm_client_output_change_dpms_cb2, user_data);
743 TEST_P(TDMClient, ClientOutputRemoveChangeHandlerInHandler)
745 tdm_output_dpms dpms = TDM_OUTPUT_DPMS_ON;
747 ASSERT_EQ(PrepareClient(), true);
748 ASSERT_EQ(PrepareOutput(), true);
750 ASSERT_EQ(tdm_client_output_add_change_handler(output, _tc_tdm_client_output_change_dpms_cb2, NULL), TDM_ERROR_NONE);
751 ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
752 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
753 while (dpms != TDM_OUTPUT_DPMS_OFF) {
754 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
755 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
758 ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
759 while (dpms != TDM_OUTPUT_DPMS_ON)
760 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
763 TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullObject)
765 tdm_client_output_remove_change_handler(NULL, _tc_tdm_client_output_change_dpms_cb, NULL);
768 TEST_P(TDMClient, ClientOutputRemoveChangeHandlerNullOther)
770 ASSERT_EQ(PrepareClient(), true);
771 ASSERT_EQ(PrepareOutput(), true);
773 tdm_client_output_remove_change_handler(output, NULL, NULL);
776 /* tdm_client_output_get_refresh_rate */
777 TEST_P(TDMClient, ClientOutputGetRefreshRate)
779 unsigned int refresh = 0;
781 ASSERT_EQ(PrepareClient(), true);
782 ASSERT_EQ(PrepareOutput(), true);
784 ASSERT_EQ(tdm_client_output_get_refresh_rate(output, &refresh), TDM_ERROR_NONE);
785 ASSERT_GT(refresh, 0);
788 TEST_P(TDMClient, ClientOutputGetRefreshRateNullObject)
790 unsigned int refresh = (unsigned int)TDM_UT_INVALID_VALUE;
792 ASSERT_EQ(tdm_client_output_get_refresh_rate(NULL, &refresh), TDM_ERROR_INVALID_PARAMETER);
793 ASSERT_EQ(refresh, (unsigned int)TDM_UT_INVALID_VALUE);
796 TEST_P(TDMClient, ClientOutputGetRefreshRateNullOther)
798 ASSERT_EQ(PrepareClient(), true);
799 ASSERT_EQ(PrepareOutput(), true);
801 ASSERT_EQ(tdm_client_output_get_refresh_rate(output, NULL), TDM_ERROR_INVALID_PARAMETER);
804 /* tdm_client_output_get_mode */
805 TEST_P(TDMClient, ClientOutputGetMode)
807 unsigned int width = 0, height = 0;
809 ASSERT_EQ(PrepareClient(), true);
810 ASSERT_EQ(PrepareOutput(), true);
812 ASSERT_EQ(tdm_client_output_get_mode(output, &width, &height), TDM_ERROR_NONE);
814 ASSERT_GT(height, 0);
817 TEST_P(TDMClient, ClientOutputGetModeNullObject)
819 unsigned int width = (unsigned int)TDM_UT_INVALID_VALUE;
820 unsigned int height = (unsigned int)TDM_UT_INVALID_VALUE;
822 ASSERT_EQ(tdm_client_output_get_mode(NULL, &width, &height), TDM_ERROR_INVALID_PARAMETER);
823 ASSERT_EQ(width, (unsigned int)TDM_UT_INVALID_VALUE);
824 ASSERT_EQ(height, (unsigned int)TDM_UT_INVALID_VALUE);
827 TEST_P(TDMClient, ClientOutputGetModeNullOther)
829 ASSERT_EQ(PrepareClient(), true);
830 ASSERT_EQ(PrepareOutput(), true);
832 ASSERT_EQ(tdm_client_output_get_mode(output, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
835 /* tdm_client_output_get_conn_status */
836 TEST_P(TDMClient, ClientOutputGetConnStatus)
838 tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
840 ASSERT_EQ(PrepareClient(), true);
841 ASSERT_EQ(PrepareOutput(), true);
843 ASSERT_EQ(tdm_client_output_get_conn_status(output, &status), TDM_ERROR_NONE);
844 ASSERT_NE(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
847 TEST_P(TDMClient, ClientOutputGetConnStatusNullObject)
849 tdm_output_conn_status status = (tdm_output_conn_status)TDM_UT_INVALID_VALUE;
851 ASSERT_EQ(tdm_client_output_get_conn_status(NULL, &status), TDM_ERROR_INVALID_PARAMETER);
852 ASSERT_EQ(status, (tdm_output_conn_status)TDM_UT_INVALID_VALUE);
855 TEST_P(TDMClient, ClientOutputGetConnStatusNullOther)
857 ASSERT_EQ(PrepareClient(), true);
858 ASSERT_EQ(PrepareOutput(), true);
860 ASSERT_EQ(tdm_client_output_get_conn_status(output, NULL), TDM_ERROR_INVALID_PARAMETER);
863 /* tdm_client_output_get_dpms */
864 TEST_P(TDMClient, ClientOutputGetDpms)
866 tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
868 ASSERT_EQ(PrepareClient(), true);
869 ASSERT_EQ(PrepareOutput(), true);
871 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
872 ASSERT_NE(dpms, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
875 TEST_P(TDMClient, ClientOutputGetDpmsNullObject)
877 tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
879 ASSERT_EQ(tdm_client_output_get_dpms(NULL, &dpms), TDM_ERROR_INVALID_PARAMETER);
880 ASSERT_EQ(dpms, (tdm_output_dpms)TDM_UT_INVALID_VALUE);
883 TEST_P(TDMClient, ClientOutputGetDpmsNullOther)
885 ASSERT_EQ(PrepareClient(), true);
886 ASSERT_EQ(PrepareOutput(), true);
888 ASSERT_EQ(tdm_client_output_get_dpms(output, NULL), TDM_ERROR_INVALID_PARAMETER);
891 /* tdm_client_output_create_vblank */
892 TEST_P(TDMClient, ClientOutputCreateVblank)
896 ASSERT_EQ(PrepareClient(), true);
897 ASSERT_EQ(PrepareOutput(), true);
899 vblank = tdm_client_output_create_vblank(output, &ret);
900 ASSERT_EQ(ret, TDM_ERROR_NONE);
901 ASSERT_NE(vblank, NULL);
904 TEST_P(TDMClient, ClientOutputCreateVblankNullObject)
908 vblank = tdm_client_output_create_vblank(NULL, &ret);
909 ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
910 ASSERT_EQ(vblank, NULL);
913 TEST_P(TDMClient, ClientOutputCreateVblankNullOther)
915 ASSERT_EQ(PrepareClient(), true);
916 ASSERT_EQ(PrepareOutput(), true);
918 vblank = tdm_client_output_create_vblank(output, NULL);
919 ASSERT_NE(vblank, NULL);
922 /* tdm_client_vblank_destroy */
923 TEST_P(TDMClient, ClientVblankDestroy)
927 ASSERT_EQ(PrepareClient(), true);
928 ASSERT_EQ(PrepareOutput(), true);
930 vblank = tdm_client_output_create_vblank(output, &ret);
931 ASSERT_EQ(ret, TDM_ERROR_NONE);
932 ASSERT_NE(vblank, NULL);
934 tdm_client_vblank_destroy(vblank);
938 TEST_P(TDMClient, ClientVblankDestroyNullObject)
940 tdm_client_vblank_destroy(NULL);
943 /* tdm_client_vblank_set_name */
944 TEST_P(TDMClient, ClientVblankSetName)
946 ASSERT_EQ(PrepareClient(), true);
947 ASSERT_EQ(PrepareOutput(), true);
948 ASSERT_EQ(PrepareVblank(), true);
950 ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
953 TEST_P(TDMClient, ClientVblankSetNameTwice)
955 ASSERT_EQ(PrepareClient(), true);
956 ASSERT_EQ(PrepareOutput(), true);
957 ASSERT_EQ(PrepareVblank(), true);
959 ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
960 ASSERT_EQ(tdm_client_vblank_set_name(vblank, TDM_UT_VBLANK_NAME), TDM_ERROR_NONE);
963 TEST_P(TDMClient, ClientVblankSetNameNullObject)
965 ASSERT_EQ(tdm_client_vblank_set_name(NULL, TDM_UT_VBLANK_NAME), TDM_ERROR_INVALID_PARAMETER);
968 /* tdm_client_vblank_set_sync */
969 TEST_P(TDMClient, ClientVblankSetSync)
971 ASSERT_EQ(PrepareClient(), true);
972 ASSERT_EQ(PrepareOutput(), true);
973 ASSERT_EQ(PrepareVblank(), true);
975 ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
978 TEST_P(TDMClient, ClientVblankSetSyncTwice)
980 ASSERT_EQ(PrepareClient(), true);
981 ASSERT_EQ(PrepareOutput(), true);
982 ASSERT_EQ(PrepareVblank(), true);
984 ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
985 ASSERT_EQ(tdm_client_vblank_set_sync(vblank, 1), TDM_ERROR_NONE);
988 TEST_P(TDMClient, ClientVblankSetSyncNullObject)
990 ASSERT_EQ(tdm_client_vblank_set_sync(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
993 /* tdm_client_vblank_set_fps */
994 TEST_P(TDMClient, ClientVblankSetFps)
996 ASSERT_EQ(PrepareClient(), true);
997 ASSERT_EQ(PrepareOutput(), true);
998 ASSERT_EQ(PrepareVblank(), true);
1000 ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
1003 TEST_P(TDMClient, ClientVblankSetFpsTwice)
1005 ASSERT_EQ(PrepareClient(), true);
1006 ASSERT_EQ(PrepareOutput(), true);
1007 ASSERT_EQ(PrepareVblank(), true);
1009 ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
1010 ASSERT_EQ(tdm_client_vblank_set_fps(vblank, 30), TDM_ERROR_NONE);
1013 TEST_P(TDMClient, ClientVblankSetFpsNullObject)
1015 ASSERT_EQ(tdm_client_vblank_set_fps(NULL, 30), TDM_ERROR_INVALID_PARAMETER);
1018 /* tdm_client_vblank_set_offset */
1019 TEST_P(TDMClient, ClientVblankSetOffset)
1021 ASSERT_EQ(PrepareClient(), true);
1022 ASSERT_EQ(PrepareOutput(), true);
1023 ASSERT_EQ(PrepareVblank(), true);
1025 ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
1028 TEST_P(TDMClient, ClientVblankSetOffsetTwice)
1030 ASSERT_EQ(PrepareClient(), true);
1031 ASSERT_EQ(PrepareOutput(), true);
1032 ASSERT_EQ(PrepareVblank(), true);
1034 ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
1035 ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 10), TDM_ERROR_NONE);
1038 TEST_P(TDMClient, ClientVblankSetOffsetNullObject)
1040 ASSERT_EQ(tdm_client_vblank_set_offset(NULL, 10), TDM_ERROR_INVALID_PARAMETER);
1043 /* tdm_client_vblank_set_enable_fake */
1044 TEST_P(TDMClient, ClientVblankSetEnableFake)
1046 ASSERT_EQ(PrepareClient(), true);
1047 ASSERT_EQ(PrepareOutput(), true);
1048 ASSERT_EQ(PrepareVblank(), true);
1050 ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
1053 TEST_P(TDMClient, ClientVblankSetEnableFakeTwice)
1055 ASSERT_EQ(PrepareClient(), true);
1056 ASSERT_EQ(PrepareOutput(), true);
1057 ASSERT_EQ(PrepareVblank(), true);
1059 ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
1060 ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
1063 TEST_P(TDMClient, ClientVblankSetEnableFakeNullObject)
1065 ASSERT_EQ(tdm_client_vblank_set_enable_fake(NULL, 1), TDM_ERROR_INVALID_PARAMETER);
1069 _tc_tdm_client_vblank_cb2(tdm_client_vblank *vblank,
1071 unsigned int sequence,
1072 unsigned int tv_sec,
1073 unsigned int tv_usec,
1076 bool *done = (bool *)user_data;
1081 /* tdm_client_vblank_wait */
1082 TEST_P(TDMClient, ClientVblankWait)
1086 ASSERT_EQ(PrepareClient(), true);
1087 ASSERT_EQ(PrepareOutput(), true);
1088 ASSERT_EQ(PrepareVblank(), true);
1091 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1093 start = tdm_helper_get_time();
1095 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1096 end = tdm_helper_get_time();
1098 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1099 ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
1102 TEST_P(TDMClient, ClientVblankWaitFewTime)
1104 bool done1, done2, done3;
1106 ASSERT_EQ(PrepareClient(), true);
1107 ASSERT_EQ(PrepareOutput(), true);
1108 ASSERT_EQ(PrepareVblank(), true);
1110 done1 = done2 = done3 = false;
1111 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done1), TDM_ERROR_NONE);
1112 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done2), TDM_ERROR_NONE);
1113 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done3), TDM_ERROR_NONE);
1115 start = tdm_helper_get_time();
1116 while (!done1 || !done2 || !done3)
1117 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1118 end = tdm_helper_get_time();
1120 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1121 ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
1125 TEST_P(TDMClient, ClientVblankWaitInterval0)
1127 ASSERT_EQ(PrepareClient(), true);
1128 ASSERT_EQ(PrepareOutput(), true);
1129 ASSERT_EQ(PrepareVblank(), true);
1131 ASSERT_EQ(tdm_client_vblank_wait(vblank, 0, _tc_tdm_client_vblank_cb2, NULL), TDM_ERROR_INVALID_PARAMETER);
1134 TEST_P(TDMClient, ClientVblankWaitInterval)
1138 ASSERT_EQ(PrepareClient(), true);
1139 ASSERT_EQ(PrepareOutput(), true);
1140 ASSERT_EQ(PrepareVblank(), true);
1143 for (int t = 1; t < 10; t++) {
1145 ASSERT_EQ(tdm_client_vblank_wait(vblank, t, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1147 start = tdm_helper_get_time();
1149 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1150 end = tdm_helper_get_time();
1152 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1153 ASSERT_GT((end - start), (vrefresh_interval * (t - 1)));
1154 ASSERT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
1159 _tc_tdm_client_vblank_cb3(tdm_client_vblank *vblank,
1161 unsigned int sequence,
1162 unsigned int tv_sec,
1163 unsigned int tv_usec,
1166 unsigned int *cur_seq = (unsigned int *)user_data;
1168 *cur_seq = sequence;
1171 TEST_P(TDMClient, ClientVblankWaitSeq)
1173 ASSERT_EQ(PrepareClient(), true);
1174 ASSERT_EQ(PrepareOutput(), true);
1175 ASSERT_EQ(PrepareVblank(), true);
1177 for (int t = 0; t < 10; t++) {
1178 unsigned int cur_seq = 0, temp = 0;
1180 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_NONE);
1181 while (cur_seq == 0)
1182 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1184 start = tdm_helper_get_time();
1185 ASSERT_EQ(tdm_client_vblank_wait_seq(vblank, cur_seq + 1, _tc_tdm_client_vblank_cb3, &temp), TDM_ERROR_NONE);
1187 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1188 end = tdm_helper_get_time();
1190 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1191 ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
1195 TEST_P(TDMClient, ClientVblankWaitSeqInterval)
1197 ASSERT_EQ(PrepareClient(), true);
1198 ASSERT_EQ(PrepareOutput(), true);
1199 ASSERT_EQ(PrepareVblank(), true);
1202 for (int t = 1; t < 10; t++) {
1203 unsigned int cur_seq = 0, temp = 0;
1205 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_NONE);
1206 while (cur_seq == 0)
1207 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1209 start = tdm_helper_get_time();
1210 ASSERT_EQ(tdm_client_vblank_wait_seq(vblank, cur_seq + t, _tc_tdm_client_vblank_cb3, &temp), TDM_ERROR_NONE);
1212 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1213 end = tdm_helper_get_time();
1215 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1216 ASSERT_GT((end - start), (vrefresh_interval * (t - 1)));
1217 ASSERT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
1221 TEST_P(TDMClient, ClientVblankWaitSetOffset)
1225 ASSERT_EQ(PrepareClient(), true);
1226 ASSERT_EQ(PrepareOutput(), true);
1227 ASSERT_EQ(PrepareVblank(), true);
1229 ASSERT_EQ(tdm_client_vblank_set_offset(vblank, 100), TDM_ERROR_NONE);
1232 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1234 start = tdm_helper_get_time();
1236 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1237 end = tdm_helper_get_time();
1239 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1240 ASSERT_GT((end - start), (0.1));
1241 ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval + 0.1));
1244 TEST_P(TDMClient, ClientVblankWaitSetFps)
1248 unsigned int fps = 10;
1250 ASSERT_EQ(PrepareClient(), true);
1251 ASSERT_EQ(PrepareOutput(), true);
1252 ASSERT_EQ(PrepareVblank(), true);
1254 ASSERT_EQ(tdm_client_vblank_set_fps(vblank, fps), TDM_ERROR_NONE);
1255 interval = 1.0 / (double)fps;
1258 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1260 start = tdm_helper_get_time();
1262 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1263 end = tdm_helper_get_time();
1265 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1266 ASSERT_GT((end - start), (interval - vrefresh_interval * 2));
1267 ASSERT_LT((end - start), (interval + vrefresh_interval));
1272 TEST_P(TDMVblank, VblankWaitEnableDisableGlobalFps)
1274 TDM_UT_SKIP_FLAG(has_outputs);
1276 unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
1277 double vrefresh_interval;
1278 unsigned int cur_seq[3];
1279 unsigned int global_fps = 5;
1280 double start, end, interval;
1282 ASSERT_EQ(TestPrepareOutput(), true);
1283 ASSERT_EQ(TestCreateVblanks3(), true);
1284 ASSERT_EQ(vblank_count, 3);
1286 ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
1287 ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
1288 vrefresh_interval = 1.0 / (double)fps;
1290 for (int v = 0; v < 3; v++)
1291 ASSERT_EQ(tdm_vblank_set_fixed_fps(vblanks[v], 10 * (v + 1)), TDM_ERROR_NONE);
1294 tdm_vblank_enable_global_fps(1, global_fps);
1295 interval = 1.0 / (double)global_fps;
1297 for (int v = 0; v < 3; v++) {
1299 ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
1302 start = tdm_helper_get_time();
1303 while (cur_seq[0] == 0)
1304 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1305 end = tdm_helper_get_time();
1307 ASSERT_NE(cur_seq[1], 0);
1308 ASSERT_NE(cur_seq[2], 0);
1310 /* "+- vrefresh_interval" consider the delay of socket communication between kernel and platform */
1311 ASSERT_GT((end - start), (interval - vrefresh_interval));
1312 ASSERT_LT((end - start), (interval + vrefresh_interval));
1315 tdm_vblank_enable_global_fps(0, 0);
1317 for (int v = 0; v < 3; v++) {
1319 ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
1322 while (cur_seq[0] == 0)
1323 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1324 ASSERT_EQ(cur_seq[1], 0);
1325 ASSERT_EQ(cur_seq[2], 0);
1327 while (cur_seq[1] == 0)
1328 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1329 ASSERT_EQ(cur_seq[2], 0);
1332 TEST_P(TDMVblank, VblankWaitIgnoreGlobalFps)
1334 TDM_UT_SKIP_FLAG(has_outputs);
1336 unsigned int fps = (unsigned int)TDM_UT_INVALID_VALUE;
1337 unsigned int cur_seq[3];
1338 unsigned int global_fps = 5;
1339 double start, end, interval;
1341 ASSERT_EQ(TestPrepareOutput(), true);
1342 ASSERT_EQ(TestCreateVblanks3(), true);
1343 ASSERT_EQ(vblank_count, 3);
1345 ASSERT_EQ(tdm_vblank_get_fps(vblanks[0], &fps), TDM_ERROR_NONE);
1346 ASSERT_TRUE(fps >= 30 && fps != (unsigned int)TDM_UT_INVALID_VALUE);
1347 interval = 1.0 / (double)fps;
1349 /* 2nd vblank will ignore the global fps. */
1350 ASSERT_EQ(tdm_vblank_ignore_global_fps(vblanks[1], 1), TDM_ERROR_NONE);
1352 tdm_vblank_enable_global_fps(1, global_fps);
1354 for (int v = 0; v < 3; v++) {
1356 ASSERT_EQ(tdm_vblank_wait(vblanks[v], 0, 0, 1, _tc_tdm_vblank_cb, &cur_seq[v]), TDM_ERROR_NONE);
1359 start = tdm_helper_get_time();
1360 while (cur_seq[1] == 0)
1361 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1362 end = tdm_helper_get_time();
1364 ASSERT_EQ(cur_seq[0], 0);
1365 ASSERT_EQ(cur_seq[2], 0);
1367 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1368 ASSERT_LT((end - start), (interval + interval));
1370 while (cur_seq[0] == 0)
1371 ASSERT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE);
1372 ASSERT_NE(cur_seq[2], 0);
1377 TEST_P(TDMClient, ClientVblankWaitNullObject)
1379 unsigned int cur_seq = 0;
1381 ASSERT_EQ(tdm_client_vblank_wait(NULL, 1, _tc_tdm_client_vblank_cb3, &cur_seq), TDM_ERROR_INVALID_PARAMETER);
1384 TEST_P(TDMClient, ClientVblankWaitNullOther)
1386 ASSERT_EQ(PrepareClient(), true);
1387 ASSERT_EQ(PrepareOutput(), true);
1388 ASSERT_EQ(PrepareVblank(), true);
1390 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
1393 TEST_P(TDMClient, ClientVblankWaitDpmsOff)
1395 tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
1397 ASSERT_EQ(PrepareClient(), true);
1398 ASSERT_EQ(PrepareOutput(), true);
1399 ASSERT_EQ(PrepareVblank(), true);
1401 ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
1402 while (dpms != TDM_OUTPUT_DPMS_OFF)
1403 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
1404 ASSERT_EQ(dpms, TDM_OUTPUT_DPMS_OFF);
1406 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, NULL), TDM_ERROR_DPMS_OFF);
1408 ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
1409 while (dpms != TDM_OUTPUT_DPMS_ON)
1410 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
1413 TEST_P(TDMClient, ClientVblankWaitSetEnableFakeDpmsOff)
1415 tdm_output_dpms dpms = (tdm_output_dpms)TDM_UT_INVALID_VALUE;
1418 ASSERT_EQ(PrepareClient(), true);
1419 ASSERT_EQ(PrepareOutput(), true);
1420 ASSERT_EQ(PrepareVblank(), true);
1422 ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_OFF), true);
1423 while (dpms != TDM_OUTPUT_DPMS_OFF)
1424 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
1426 ASSERT_EQ(tdm_client_vblank_set_enable_fake(vblank, 1), TDM_ERROR_NONE);
1429 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1432 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1434 ASSERT_EQ(_tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_DPMS_ON), true);
1435 while (dpms != TDM_OUTPUT_DPMS_ON)
1436 ASSERT_EQ(tdm_client_output_get_dpms(output, &dpms), TDM_ERROR_NONE);
1439 /* tdm_client_vblank_wait */
1440 TEST_P(TDMClient, ClientVblankIsWaiting)
1443 unsigned int waiting;
1445 ASSERT_EQ(PrepareClient(), true);
1446 ASSERT_EQ(PrepareOutput(), true);
1447 ASSERT_EQ(PrepareVblank(), true);
1450 ASSERT_EQ(tdm_client_vblank_wait(vblank, 1, _tc_tdm_client_vblank_cb2, &done), TDM_ERROR_NONE);
1452 waiting = tdm_client_vblank_is_waiting(vblank);
1453 ASSERT_EQ(waiting, 1);
1455 start = tdm_helper_get_time();
1457 ASSERT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
1458 end = tdm_helper_get_time();
1460 /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
1461 ASSERT_LT((end - start), (vrefresh_interval + vrefresh_interval));
1463 waiting = tdm_client_vblank_is_waiting(vblank);
1464 ASSERT_EQ(waiting, 0);
1467 /* tdm_client_vblank_wait */
1468 TEST_P(TDMClient, ClientVblankIsWaitingNullObject)
1470 unsigned int waiting = tdm_client_vblank_is_waiting(NULL);
1471 ASSERT_EQ(waiting, 0);
1474 TEST_P(TDMClient, ClientCreateVOutput)
1477 int virtual_conf = 0;
1478 const char name[TDM_NAME_LEN] = "Virtual Output";
1480 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1481 if (virtual_conf == 0) {
1482 ASSERT_EQ(virtual_conf, 0);
1486 ASSERT_EQ(PrepareClient(), true);
1488 voutput = tdm_client_create_voutput(client, name, &ret);
1489 ASSERT_EQ(ret, TDM_ERROR_NONE);
1490 ASSERT_NE(voutput, NULL);
1492 tdm_client_voutput_destroy(voutput);
1495 class TDMVirtualOutput : public ::testing::Test
1498 TDMVirtualOutput() {};
1499 ~TDMVirtualOutput() {};
1501 static void SetUpTestCase();
1502 static void TearDownTestCase();
1503 static bool PrepareVOutput(void);
1506 static tdm_client *client;
1507 static tdm_client_voutput *voutput;
1508 const int MODE_COUNT = 2;
1511 static pid_t server_pid;
1513 /* 0: read, 1: write */
1514 static int pipe_parent[2];
1515 static int pipe_child[2];
1517 static void ServerFork(void);
1518 static void ServerKill(void);
1521 pid_t TDMVirtualOutput::server_pid = -1;
1522 int TDMVirtualOutput::pipe_parent[2] = {-1, -1};
1523 int TDMVirtualOutput::pipe_child[2] = {-1, -1};
1524 tdm_client* TDMVirtualOutput::client = nullptr;
1525 tdm_client_voutput* TDMVirtualOutput::voutput = nullptr;
1527 void TDMVirtualOutput::ServerKill(void)
1529 if (pipe_child[0] >= 0)
1530 close(pipe_child[0]);
1531 if (pipe_child[1] >= 0) {
1532 if (server_pid > 0) {
1533 bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
1535 if (waitpid(server_pid, NULL, 0) == server_pid)
1536 TDM_INFO("*** server terminated ***");
1538 TDM_ERR("*** failed to terminate server ***");
1540 if (kill(server_pid, 9) < 0)
1541 TDM_ERR("*** failed to kill server ***");
1544 close(pipe_child[1]);
1547 if (pipe_parent[0] >= 0)
1548 close(pipe_parent[0]);
1549 if (pipe_parent[1] >= 0)
1550 close(pipe_parent[1]);
1553 pipe_parent[0] = pipe_parent[1] = -1;
1554 pipe_child[0] = pipe_child[1] = -1;
1557 void TDMVirtualOutput::ServerFork(void)
1562 server_pid = _tc_tdm_client_server_fork(pipe_parent, pipe_child);
1563 ASSERT_GT(server_pid, 0);
1566 void TDMVirtualOutput::SetUpTestCase(void)
1568 setenv("XDG_RUNTIME_DIR", "/run", 1);
1569 setenv("TBM_DISPLAY_SERVER", "1", 1);
1571 if (server_pid == -1)
1574 ASSERT_EQ(PrepareVOutput(), true);
1577 void TDMVirtualOutput::TearDownTestCase(void)
1579 // TDM_UT_WAIT("check & press");
1582 tdm_client_voutput_destroy(voutput);
1585 tdm_client_destroy(client);
1589 unsetenv("XDG_RUNTIME_DIR");
1590 unsetenv("TBM_DISPLAY_SERVER");
1593 bool TDMVirtualOutput::PrepareVOutput(void)
1596 int virtual_conf = 0;
1597 const char name[TDM_NAME_LEN] = "Virtual Output";
1599 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1600 if (virtual_conf == 0) return true;
1602 client = tdm_client_create(&ret);
1603 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
1604 TDM_UT_RETURN_FALSE_IF_FAIL(client != NULL);
1606 voutput = tdm_client_create_voutput(client, name, &ret);
1607 TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
1608 TDM_UT_RETURN_FALSE_IF_FAIL(voutput != NULL);
1610 // TDM_UT_WAIT("check & press");
1616 _tc_tdm_client_virutual_make_available_mode(tdm_client_output_mode *modes, int count)
1620 for (i = 0; i < count; i++) {
1621 modes[i].clock = 25200;
1622 modes[i].hdisplay = 640;
1623 modes[i].hsync_start = 656;
1624 modes[i].hsync_end = 752;
1625 modes[i].htotal = 800;
1627 modes[i].vdisplay = 480;
1628 modes[i].vsync_start = 490;
1629 modes[i].vsync_end = 492;
1630 modes[i].vtotal = 525;
1632 modes[i].vrefresh = 30;
1635 snprintf(modes[i].name, TDM_NAME_LEN, "%dx%d_%d", modes[i].hdisplay, modes[i].vdisplay, i);
1639 TEST_F(TDMVirtualOutput, SetAvailableModes)
1642 tdm_client_output_mode modes[this->MODE_COUNT];
1643 int count = this->MODE_COUNT;
1646 if (this->voutput == NULL) {
1647 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1648 ASSERT_EQ(virtual_conf, 0);
1651 _tc_tdm_client_virutual_make_available_mode(modes, count);
1653 ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
1654 ASSERT_EQ(ret, TDM_ERROR_NONE);
1657 TEST_F(TDMVirtualOutput, FailTestSetAvailableModes)
1660 tdm_client_output_mode modes[this->MODE_COUNT];
1661 int count = this->MODE_COUNT;
1664 if (this->voutput == NULL) {
1665 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1666 ASSERT_EQ(virtual_conf, 0);
1670 ret = tdm_client_voutput_set_available_modes(NULL, modes, count);
1671 ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
1673 ret = tdm_client_voutput_set_available_modes(this->voutput, NULL, count);
1674 ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
1677 TEST_F(TDMVirtualOutput, SetPhysicalSize)
1680 unsigned int mmWidth = 1234, mmHeight = 1234;
1683 if (this->voutput == NULL) {
1684 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1685 ASSERT_EQ(virtual_conf, 0);
1689 ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
1690 ASSERT_EQ(ret, TDM_ERROR_NONE);
1693 TEST_F(TDMVirtualOutput, FailTestSetPhysicalSize)
1696 unsigned int invalid_mmWidth = 0, invalid_mmHeight = 0;
1699 if (this->voutput == NULL) {
1700 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1701 ASSERT_EQ(virtual_conf, 0);
1705 ret = tdm_client_voutput_set_physical_size(this->voutput, invalid_mmWidth, invalid_mmHeight);
1706 ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
1710 _tc_tdm_client_voutput_commit_handler(tdm_client_voutput *voutput, tbm_surface_h buffer, void *user_data)
1713 flag = (int *)user_data;
1717 TEST_F(TDMVirtualOutput, AddCommitHandler)
1720 int flag_callback_called = 0;
1723 if (this->voutput == NULL) {
1724 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1725 ASSERT_EQ(virtual_conf, 0);
1729 ret = tdm_client_voutput_add_commit_handler(this->voutput,
1730 _tc_tdm_client_voutput_commit_handler,
1731 &flag_callback_called);
1732 ASSERT_EQ(ret, TDM_ERROR_NONE);
1733 // ASSERT_EQ(flag_callback_called, 1);
1735 tdm_client_voutput_remove_commit_handler(this->voutput,
1736 _tc_tdm_client_voutput_commit_handler,
1737 &flag_callback_called);
1740 TEST_F(TDMVirtualOutput, CommitDone)
1745 if (this->voutput == NULL) {
1746 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1747 ASSERT_EQ(virtual_conf, 0);
1751 ret = tdm_client_voutput_commit_done(this->voutput);
1752 ASSERT_EQ(ret, TDM_ERROR_NONE);
1755 TEST_F(TDMVirtualOutput, GetClientOutput)
1758 tdm_client_output *output;
1761 if (this->voutput == NULL) {
1762 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1763 ASSERT_EQ(virtual_conf, 0);
1767 output = tdm_client_voutput_get_client_output(this->voutput, &ret);
1768 ASSERT_EQ(ret, TDM_ERROR_NONE);
1769 ASSERT_NE(output, NULL);
1773 _tc_voutput_output_handler_cb(tdm_client_output *output, tdm_output_change_type type,
1774 tdm_value value, void *user_data)
1776 bool *done = (bool *)user_data;
1777 tdm_output_conn_status status;
1779 if (type == TDM_OUTPUT_CHANGE_CONNECTION) {
1780 status = (tdm_output_conn_status)value.u32;
1782 if (status == TDM_OUTPUT_CONN_STATUS_CONNECTED)
1783 if (done) *done = true;
1788 _tc_voutput_output_handler_cb2(tdm_client_output *output, tdm_output_change_type type,
1789 tdm_value value, void *user_data)
1791 bool *done = (bool *)user_data;
1792 tdm_output_conn_status status;
1794 if (type == TDM_OUTPUT_CHANGE_CONNECTION) {
1795 status = (tdm_output_conn_status)value.u32;
1797 if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
1798 if (done) *done = true;
1803 _tc_voutput_output_handler_cb3(tdm_client_output *output, tdm_output_change_type type,
1804 tdm_value value, void *user_data)
1806 bool *done = (bool *)user_data;
1807 tdm_output_conn_status status;
1809 if (type == TDM_OUTPUT_CHANGE_CONNECTION) {
1810 status = (tdm_output_conn_status)value.u32;
1812 if (status == TDM_OUTPUT_CONN_STATUS_MODE_SETTED)
1813 if (done) *done = true;
1817 TEST_F(TDMVirtualOutput, ConnectDisconnect)
1820 tdm_client_output *output;
1821 unsigned int mmWidth = 300, mmHeight = 150;
1822 tdm_client_output_mode modes[this->MODE_COUNT];
1823 int count = this->MODE_COUNT;
1828 if (this->voutput == NULL) {
1829 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1830 ASSERT_EQ(virtual_conf, 0);
1834 output = tdm_client_voutput_get_client_output(this->voutput, &ret);
1835 ASSERT_EQ(ret, TDM_ERROR_NONE);
1836 ASSERT_NE(output, NULL);
1838 ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb, &done);
1839 ASSERT_EQ(ret, TDM_ERROR_NONE);
1841 ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
1842 ASSERT_EQ(ret, TDM_ERROR_NONE);
1844 ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
1845 ASSERT_EQ(ret, TDM_ERROR_NONE);
1847 _tc_tdm_client_virutual_make_available_mode(modes, count);
1848 ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
1849 ASSERT_EQ(ret, TDM_ERROR_NONE);
1851 ret = tdm_client_voutput_connect(this->voutput);
1852 ASSERT_EQ(ret, TDM_ERROR_NONE);
1855 ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
1857 ret = tdm_client_voutput_disconnect(this->voutput);
1858 ASSERT_EQ(ret, TDM_ERROR_NONE);
1861 ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
1863 tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb, &done);
1864 tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
1867 TEST_F(TDMVirtualOutput, SetMode)
1870 tdm_client_output *output;
1871 unsigned int mmWidth = 300, mmHeight = 150;
1872 tdm_client_output_mode modes[this->MODE_COUNT];
1873 int count = this->MODE_COUNT;
1879 if (this->voutput == NULL) {
1880 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1881 ASSERT_EQ(virtual_conf, 0);
1885 output = tdm_client_voutput_get_client_output(this->voutput, &ret);
1886 ASSERT_EQ(ret, TDM_ERROR_NONE);
1887 ASSERT_NE(output, NULL);
1889 ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb, &done);
1890 ASSERT_EQ(ret, TDM_ERROR_NONE);
1891 ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
1892 ASSERT_EQ(ret, TDM_ERROR_NONE);
1893 ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb3, &done3);
1894 ASSERT_EQ(ret, TDM_ERROR_NONE);
1896 ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
1897 ASSERT_EQ(ret, TDM_ERROR_NONE);
1899 _tc_tdm_client_virutual_make_available_mode(modes, count);
1900 ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
1901 ASSERT_EQ(ret, TDM_ERROR_NONE);
1903 ret = tdm_client_voutput_connect(this->voutput);
1904 ASSERT_EQ(ret, TDM_ERROR_NONE);
1907 ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
1909 ASSERT_EQ(tdm_client_voutput_set_mode(this->voutput, count - 1), TDM_ERROR_NONE);
1912 ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
1914 ret = tdm_client_voutput_disconnect(this->voutput);
1915 ASSERT_EQ(ret, TDM_ERROR_NONE);
1918 ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
1920 tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb, &done);
1921 tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
1922 tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb3, &done3);
1925 TEST_F(TDMVirtualOutput, SetModeNullObject)
1928 unsigned int mmWidth = 300, mmHeight = 150;
1929 tdm_client_output_mode modes[this->MODE_COUNT];
1930 int count = this->MODE_COUNT;
1933 if (this->voutput == NULL) {
1934 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1935 ASSERT_EQ(virtual_conf, 0);
1939 ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
1940 ASSERT_EQ(ret, TDM_ERROR_NONE);
1942 _tc_tdm_client_virutual_make_available_mode(modes, count);
1943 ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
1944 ASSERT_EQ(ret, TDM_ERROR_NONE);
1946 ret = tdm_client_voutput_connect(this->voutput);
1947 ASSERT_EQ(ret, TDM_ERROR_NONE);
1949 tdm_client_handle_events_timeout(this->client, 50);
1951 ASSERT_EQ(tdm_client_voutput_set_mode(NULL, 0), TDM_ERROR_INVALID_PARAMETER);
1953 ret = tdm_client_voutput_disconnect(this->voutput);
1954 ASSERT_EQ(ret, TDM_ERROR_NONE);
1956 tdm_client_handle_events_timeout(this->client, 0);
1959 TEST_F(TDMVirtualOutput, SetModeInvalidIndex)
1962 unsigned int mmWidth = 300, mmHeight = 150;
1963 tdm_client_output_mode modes[this->MODE_COUNT];
1964 int count = this->MODE_COUNT;
1967 if (this->voutput == NULL) {
1968 virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
1969 ASSERT_EQ(virtual_conf, 0);
1973 ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
1974 ASSERT_EQ(ret, TDM_ERROR_NONE);
1976 _tc_tdm_client_virutual_make_available_mode(modes, count);
1977 ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
1978 ASSERT_EQ(ret, TDM_ERROR_NONE);
1980 ret = tdm_client_voutput_connect(this->voutput);
1981 ASSERT_EQ(ret, TDM_ERROR_NONE);
1983 tdm_client_handle_events_timeout(this->client, 50);
1985 ASSERT_EQ(tdm_client_voutput_set_mode(this->voutput, -1), TDM_ERROR_INVALID_PARAMETER);
1987 ret = tdm_client_voutput_disconnect(this->voutput);
1988 ASSERT_EQ(ret, TDM_ERROR_NONE);
1990 tdm_client_handle_events_timeout(this->client, 0);
1993 #ifdef TDM_UT_TEST_WITH_PARAMS
1994 INSTANTIATE_TEST_CASE_P(TDMClientParams,
1996 Combine(Bool(), Bool(), Values(TDM_DEFAULT_MODULE)));
1998 INSTANTIATE_TEST_CASE_P(TDMClientParams,
2000 Values(TDM_DEFAULT_MODULE));