client: add tdm_client_output_get_mode function 99/191399/3
authorJunkyeong Kim <jk0430.kim@samsung.com>
Tue, 16 Oct 2018 12:30:48 +0000 (21:30 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 1 Nov 2018 02:33:42 +0000 (02:33 +0000)
Change-Id: Ie21b4f8f3179624339bf97e5dce7727b36c5d6bb
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
client/tdm_client.c
client/tdm_client.h
haltests/src/tc_tdm_client.cpp

index 972ae00..57f8ce3 100644 (file)
@@ -1061,6 +1061,51 @@ tdm_client_output_get_refresh_rate(tdm_client_output *output, unsigned int *refr
 }
 
 tdm_error
+tdm_client_output_get_mode(tdm_client_output *output, unsigned int *width, unsigned int *height)
+{
+       tdm_private_client_output *private_output;
+       tdm_private_client *private_client;
+
+       TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
+       TDM_RETURN_VAL_IF_FAIL(width != NULL, TDM_ERROR_INVALID_PARAMETER);
+       TDM_RETURN_VAL_IF_FAIL(height != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+       private_output = (tdm_private_client_output*)output;
+       private_client = private_output->private_client;
+
+       pthread_mutex_lock(&private_client->lock);
+
+       if (private_output->watch_output_changes) {
+               *width = private_output->width;
+               *height = private_output->height;
+               pthread_mutex_unlock(&private_client->lock);
+               return TDM_ERROR_NONE;
+       }
+
+       if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+               pthread_mutex_unlock(&private_client->lock);
+               return TDM_ERROR_PROTOCOL_ERROR;
+       }
+
+       wl_proxy_set_queue((struct wl_proxy *)private_output->output, private_client->queue);
+       wl_tdm_output_get_mode(private_output->output);
+       wl_display_roundtrip_queue(private_client->display, private_client->queue);
+       wl_proxy_set_queue((struct wl_proxy *)private_output->output, NULL);
+
+       if (CHECK_WL_PROTOCOL_ERROR(private_client)) {
+               pthread_mutex_unlock(&private_client->lock);
+               return TDM_ERROR_PROTOCOL_ERROR;
+       }
+
+       *width = private_output->width;
+       *height = private_output->height;
+
+       pthread_mutex_unlock(&private_client->lock);
+
+       return TDM_ERROR_NONE;
+}
+
+tdm_error
 tdm_client_output_get_conn_status(tdm_client_output *output, tdm_output_conn_status *status)
 {
        tdm_private_client_output *private_output;
index 17d63cf..f8b2dec 100644 (file)
@@ -219,6 +219,16 @@ tdm_error
 tdm_client_output_get_refresh_rate(tdm_client_output *output, unsigned int *refresh);
 
 /**
+ * @brief Get the width and height of the given client output mode
+ * @param[in] output The client output object
+ * @param[out] width The width of output mode
+ * @param[out] height The height of output mode
+ * @return #TDM_ERROR_NONE if success. Otherwise, error value.
+ */
+tdm_error
+tdm_client_output_get_mode(tdm_client_output *output, unsigned int *width, unsigned int *height);
+
+/**
  * @brief Get the connection status of the given client output
  * @param[in] output The client output object
  * @param[out] status The connection status
index 0d54855..504aaee 100644 (file)
@@ -746,6 +746,37 @@ TEST_P(TDMClient, ClientOutputGetRefreshRateNullOther)
        ASSERT_EQ(tdm_client_output_get_refresh_rate(output, NULL), TDM_ERROR_INVALID_PARAMETER);
 }
 
+/* tdm_client_output_get_mode */
+TEST_P(TDMClient, ClientOutputGetMode)
+{
+       unsigned int width = 0, height = 0;
+
+       ASSERT_EQ(PrepareClient(), true);
+       ASSERT_EQ(PrepareOutput(), true);
+
+       ASSERT_EQ(tdm_client_output_get_mode(output, &width, &height), TDM_ERROR_NONE);
+       ASSERT_GT(width, 0);
+       ASSERT_GT(height, 0);
+}
+
+TEST_P(TDMClient, ClientOutputGetModeNullObject)
+{
+       unsigned int width = (unsigned int)TDM_UT_INVALID_VALUE;
+       unsigned int height = (unsigned int)TDM_UT_INVALID_VALUE;
+
+       ASSERT_EQ(tdm_client_output_get_mode(NULL, &width, &height), TDM_ERROR_INVALID_PARAMETER);
+       ASSERT_EQ(width, (unsigned int)TDM_UT_INVALID_VALUE);
+       ASSERT_EQ(height, (unsigned int)TDM_UT_INVALID_VALUE);
+}
+
+TEST_P(TDMClient, ClientOutputGetModeNullOther)
+{
+       ASSERT_EQ(PrepareClient(), true);
+       ASSERT_EQ(PrepareOutput(), true);
+
+       ASSERT_EQ(tdm_client_output_get_mode(output, NULL, NULL), TDM_ERROR_INVALID_PARAMETER);
+}
+
 /* tdm_client_output_get_conn_status */
 TEST_P(TDMClient, ClientOutputGetConnStatus)
 {