}
static void
+_tc_tdm_test_server_cb_output_mode_change(tdm_output *output, unsigned int index, void *user_data)
+{
+ const tdm_output_mode *modes, *mode;
+ int count = 0;
+ tdm_error ret;
+
+ ret = tdm_output_get_available_modes(output, &modes, &count);
+ TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+ TDM_UT_RETURN_IF_FAIL((int)index < count);
+
+ mode = &modes[index];
+
+ ret = tdm_output_set_mode(output, mode);
+ TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ ret = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON);
+ TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ ret = tdm_output_commit(output, 0, NULL, NULL);
+ TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+static void
+_tc_tdm_output_cb_destroy_handler(tdm_output *output, void *user_data)
+{
+ tdm_error ret;
+
+ tdm_output_remove_mode_change_request_handler(output, _tc_tdm_test_server_cb_output_mode_change, NULL);
+ tdm_output_remove_destroy_handler(output, _tc_tdm_output_cb_destroy_handler, NULL);
+
+ ret = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF);
+ TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+static void
+_tc_tdm_output_cb_create_handler(tdm_display *dpy, tdm_output *output, void *user_data)
+{
+ tdm_error ret = TDM_ERROR_NONE;
+
+ ret = tdm_output_add_mode_change_request_handler(output, _tc_tdm_test_server_cb_output_mode_change, NULL);
+ TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ ret = tdm_output_add_destroy_handler(output, _tc_tdm_output_cb_destroy_handler, NULL);
+ TDM_UT_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+static void
_tc_tdm_server_run(int *pipe_parent, int *pipe_child)
{
tdm_display *dpy = NULL;
struct pollfd fds[2];
int tdm_fd, err;
int output_count = 0;
+ int virtual_conf;
dpy = tdm_display_init(&ret);
TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
TDM_UT_GOTO_IF_FAIL(tc_tdm_output_prepare(dpy, output, true) == true, failed);
}
+ virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
+ if (virtual_conf) {
+ ret = tdm_display_add_output_create_handler(dpy, _tc_tdm_output_cb_create_handler, NULL);
+ TDM_UT_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, failed);
+ }
+
TDM_UT_GOTO_IF_FAIL(_tc_tdm_pipe_write_msg(pipe_parent[1], -1, TDM_UT_PIPE_MSG_SERVER_READY) == true, done);
TDM_INFO("*** server ready ***");
ASSERT_NE(output, NULL);
}
-TEST_F(TDMVirtualOutput, Connect)
+static void
+_tc_voutput_output_handler_cb(tdm_client_output *output, tdm_output_change_type type,
+ tdm_value value, void *user_data)
+{
+ bool *done = (bool *)user_data;
+ tdm_output_conn_status status;
+
+ if (type == TDM_OUTPUT_CHANGE_CONNECTION) {
+ status = (tdm_output_conn_status)value.u32;
+
+ if (status == TDM_OUTPUT_CONN_STATUS_CONNECTED)
+ if (done) *done = true;
+ }
+}
+
+static void
+_tc_voutput_output_handler_cb2(tdm_client_output *output, tdm_output_change_type type,
+ tdm_value value, void *user_data)
+{
+ bool *done = (bool *)user_data;
+ tdm_output_conn_status status;
+
+ if (type == TDM_OUTPUT_CHANGE_CONNECTION) {
+ status = (tdm_output_conn_status)value.u32;
+
+ if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
+ if (done) *done = true;
+ }
+}
+
+static void
+_tc_voutput_output_handler_cb3(tdm_client_output *output, tdm_output_change_type type,
+ tdm_value value, void *user_data)
+{
+ bool *done = (bool *)user_data;
+ tdm_output_conn_status status;
+
+ if (type == TDM_OUTPUT_CHANGE_CONNECTION) {
+ status = (tdm_output_conn_status)value.u32;
+
+ if (status == TDM_OUTPUT_CONN_STATUS_MODE_SETTED)
+ if (done) *done = true;
+ }
+}
+
+TEST_F(TDMVirtualOutput, ConnectDisconnect)
{
tdm_error ret;
+ tdm_client_output *output;
unsigned int mmWidth = 300, mmHeight = 150;
tdm_client_output_mode modes[this->MODE_COUNT];
int count = this->MODE_COUNT;
int virtual_conf;
+ bool done = false;
+ bool done2 = false;
if (this->voutput == NULL) {
virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
return;
}
+ output = tdm_client_voutput_get_client_output(this->voutput, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb, &done);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+ ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
ASSERT_EQ(ret, TDM_ERROR_NONE);
ret = tdm_client_voutput_connect(this->voutput);
ASSERT_EQ(ret, TDM_ERROR_NONE);
- tdm_client_handle_events_timeout(this->client, 0);
-}
-
-TEST_F(TDMVirtualOutput, Disconnect)
-{
- tdm_error ret;
- int virtual_conf;
-
- if (this->voutput == NULL) {
- virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
- ASSERT_EQ(virtual_conf, 0);
- return;
- }
-
-// TDM_UT_WAIT("check & press");
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
ret = tdm_client_voutput_disconnect(this->voutput);
ASSERT_EQ(ret, TDM_ERROR_NONE);
- tdm_client_handle_events_timeout(this->client, 0);
-}
+ while (!done2)
+ ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
+ tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb, &done);
+ tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
+}
TEST_F(TDMVirtualOutput, SetMode)
{
tdm_error ret;
+ tdm_client_output *output;
unsigned int mmWidth = 300, mmHeight = 150;
tdm_client_output_mode modes[this->MODE_COUNT];
int count = this->MODE_COUNT;
int virtual_conf;
+ bool done = false;
+ bool done2 = false;
+ bool done3 = false;
if (this->voutput == NULL) {
virtual_conf = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_VIRTUAL_OUTPUT, 0);
return;
}
+ output = tdm_client_voutput_get_client_output(this->voutput, &ret);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ASSERT_NE(output, NULL);
+
+ ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb, &done);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+ ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb3, &done3);
+ ASSERT_EQ(ret, TDM_ERROR_NONE);
+
ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
ASSERT_EQ(ret, TDM_ERROR_NONE);
ret = tdm_client_voutput_connect(this->voutput);
ASSERT_EQ(ret, TDM_ERROR_NONE);
- tdm_client_handle_events_timeout(this->client, 100);
+ while (!done)
+ ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
ASSERT_EQ(tdm_client_voutput_set_mode(this->voutput, count - 1), TDM_ERROR_NONE);
- tdm_client_handle_events_timeout(this->client, 100);
+ while (!done3)
+ ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
ret = tdm_client_voutput_disconnect(this->voutput);
ASSERT_EQ(ret, TDM_ERROR_NONE);
- tdm_client_handle_events_timeout(this->client, 0);
+ while (!done2)
+ ASSERT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
+
+ tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb, &done);
+ tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
+ tdm_client_output_remove_change_handler(output, _tc_voutput_output_handler_cb3, &done3);
}
TEST_F(TDMVirtualOutput, SetModeNullObject)
ret = tdm_client_voutput_connect(this->voutput);
ASSERT_EQ(ret, TDM_ERROR_NONE);
- tdm_client_handle_events_timeout(this->client, 100);
+ tdm_client_handle_events_timeout(this->client, 50);
ASSERT_EQ(tdm_client_voutput_set_mode(NULL, 0), TDM_ERROR_INVALID_PARAMETER);
ret = tdm_client_voutput_connect(this->voutput);
ASSERT_EQ(ret, TDM_ERROR_NONE);
- tdm_client_handle_events_timeout(this->client, 100);
+ tdm_client_handle_events_timeout(this->client, 50);
ASSERT_EQ(tdm_client_voutput_set_mode(this->voutput, -1), TDM_ERROR_INVALID_PARAMETER);