virtual: client get voutput's output by tdm_client_get_output
[platform/core/uifw/libtdm.git] / haltests / src / tc_tdm_client.cpp
index 1909ff0..01668cb 100644 (file)
@@ -1483,6 +1483,8 @@ void TDMVirtualOutput::SetUpTestCase(void)
 
 void TDMVirtualOutput::TearDownTestCase(void)
 {
+//     TDM_UT_WAIT("check & press");
+
        if (voutput)
                tdm_client_voutput_destroy(voutput);
 
@@ -1514,30 +1516,37 @@ bool TDMVirtualOutput::PrepareVOutput(void)
        return true;
 }
 
+static void
+_tc_tdm_client_virutual_make_available_mode(tdm_client_output_mode *modes, int count)
+{
+       int i;
+
+       for (i = 0; i < count; i++) {
+               modes[i].clock = 25200;
+               modes[i].hdisplay = 640;
+               modes[i].hsync_start = 656;
+               modes[i].hsync_end = 752;
+               modes[i].htotal = 800;
+               modes[i].hskew = 0;
+               modes[i].vdisplay = 480;
+               modes[i].vsync_start = 490;
+               modes[i].vsync_end = 492;
+               modes[i].vtotal = 525;
+               modes[i].vscan = 0;
+               modes[i].vrefresh = 30;
+               modes[i].flags = 0;
+               modes[i].type = 0;
+               snprintf(modes[i].name, TDM_NAME_LEN, "%dx%d_%d", modes[i].hdisplay, modes[i].vdisplay, i);
+       }
+}
+
 TEST_F(TDMVirtualOutput, SetAvailableModes)
 {
        tdm_error ret;
        tdm_client_output_mode modes[this->MODE_COUNT];
-       int i, count = this->MODE_COUNT;
-
-       for (i = 0; i < count; i++)
-       {
-               modes[i].clock = 1;
-               modes[i].hdisplay = 2;
-               modes[i].hsync_start = 3;
-               modes[i].hsync_end = 4;
-               modes[i].htotal = 5;
-               modes[i].hskew = 6;
-               modes[i].vdisplay = 7;
-               modes[i].vsync_start = 8;
-               modes[i].vsync_end = 9;
-               modes[i].vtotal = 10;
-               modes[i].vscan = 11;
-               modes[i].vrefresh = 12;
-               modes[i].flags = 13;
-               modes[i].type = 14;
-               snprintf(modes[i].name, TDM_NAME_LEN, "TestModeSetting %d", i);
-       }
+       int count = this->MODE_COUNT;
+
+       _tc_tdm_client_virutual_make_available_mode(modes, count);
 
        ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
        ASSERT_EQ(ret, TDM_ERROR_NONE);
@@ -1559,8 +1568,8 @@ TEST_F(TDMVirtualOutput, FailTestSetAvailableModes)
 TEST_F(TDMVirtualOutput, SetPhysicalSize)
 {
        tdm_error ret;
-       int mmWidth = 1234, mmHeight = 1234;
-       
+       unsigned int mmWidth = 1234, mmHeight = 1234;
+
        ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
        ASSERT_EQ(ret, TDM_ERROR_NONE);
 }
@@ -1568,12 +1577,44 @@ TEST_F(TDMVirtualOutput, SetPhysicalSize)
 TEST_F(TDMVirtualOutput, FailTestSetPhysicalSize)
 {
        tdm_error ret;
-       int invalid_mmWidth = -1, invalid_mmHeight = -1;
-       
+       unsigned int invalid_mmWidth = 0, invalid_mmHeight = 0;
+
        ret = tdm_client_voutput_set_physical_size(this->voutput, invalid_mmWidth, invalid_mmHeight);
        ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER);
 }
 
+static void
+_tc_tdm_client_voutput_commit_handler(tdm_client_voutput *voutput, tbm_surface_h buffer, void *user_data)
+{
+       int *flag;
+       flag = (int *)user_data;
+       *flag = 1;
+}
+
+TEST_F(TDMVirtualOutput, AddCommitHandler)
+{
+       tdm_error ret;
+       int flag_callback_called = 0;
+
+       ret = tdm_client_voutput_add_commit_handler(this->voutput,
+                                                                                               _tc_tdm_client_voutput_commit_handler,
+                                                                                               &flag_callback_called);
+       ASSERT_EQ(ret, TDM_ERROR_NONE);
+//     ASSERT_EQ(flag_callback_called, 1);
+
+       tdm_client_voutput_remove_commit_handler(this->voutput,
+                                                                                        _tc_tdm_client_voutput_commit_handler,
+                                                                                        &flag_callback_called);
+}
+
+TEST_F(TDMVirtualOutput, CommitDone)
+{
+       tdm_error ret;
+
+       ret = tdm_client_voutput_commit_done(this->voutput);
+       ASSERT_EQ(ret, TDM_ERROR_NONE);
+}
+
 TEST_F(TDMVirtualOutput, GetClientOutput)
 {
        tdm_error ret;
@@ -1588,11 +1629,21 @@ TEST_F(TDMVirtualOutput, Connect)
 {
        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;
 
        output = tdm_client_voutput_get_client_output(this->voutput, &ret);
        ASSERT_EQ(ret, TDM_ERROR_NONE);
        ASSERT_NE(output, NULL);
 
+       ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
+       ASSERT_EQ(ret, TDM_ERROR_NONE);
+
+       _tc_tdm_client_virutual_make_available_mode(modes, count);
+       ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
+       ASSERT_EQ(ret, TDM_ERROR_NONE);
+
        ret = tdm_client_output_connect(output);
        ASSERT_EQ(ret, TDM_ERROR_NONE);
 
@@ -1604,6 +1655,8 @@ TEST_F(TDMVirtualOutput, Disconnect)
        tdm_error ret;
        tdm_client_output *output;
 
+//     TDM_UT_WAIT("check & press");
+
        output = tdm_client_voutput_get_client_output(this->voutput, &ret);
        ASSERT_EQ(ret, TDM_ERROR_NONE);
        ASSERT_NE(output, NULL);