[UTC][d2d-conv-manager][Non-ACR][Add conv_service_e array and checking loop]
authorHongkuk, Son <hongkuk.son@samsung.com>
Fri, 17 Jun 2016 08:56:09 +0000 (17:56 +0900)
committerHongkuk, Son <hongkuk.son@samsung.com>
Fri, 17 Jun 2016 08:57:42 +0000 (17:57 +0900)
Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: Iaa24c4bcb633787e72ff2959f83c1f1173a84ca8

src/utc/d2d-conv-manager/utc-d2d-conv-manager_service.c

index 8f06656..ab8e58c 100755 (executable)
 #include <system_info.h>
 #include <d2d_conv_manager.h>
 
+#define ARRAY_SIZE(name) (sizeof(name) / sizeof(name[0]))
+
 static bool g_feature;
 static GMainLoop *g_mainloop = NULL;
 
+conv_service_e service_types[] = {
+//     CONV_SERVICE_NONE,                                              /**< Undefined service */
+       CONV_SERVICE_APP_TO_APP_COMMUNICATION,  /**< App-to-app communication service */
+       CONV_SERVICE_REMOTE_APP_CONTROL,                /**< Remote app-control service */
+//     CONV_SERVICE_REMOTE_INTERACTION,                /**< Remote Interaction service */
+};
+
 static void test_service_connected_cb(conv_service_h service_handle, conv_error_e error, conv_payload_h result, void* user_data)
 {
        return ;
@@ -627,29 +636,31 @@ int utc_d2d_conv_manager_conv_service_get_connection_state_n2(void)
  */
 int utc_d2d_conv_manager_conv_service_get_type_p(void)
 {
+       int i;
        int ret = CONV_ERROR_NONE;
        conv_service_h handle;
-       conv_service_e value = CONV_SERVICE_APP_TO_APP_COMMUNICATION;
-       conv_service_e value_2;
+       conv_service_e value;
 
        if (g_feature == false) {
-               ret = conv_service_get_type(handle, &value_2);
+               ret = conv_service_get_type(handle, &value);
                assert_eq(ret, CONV_ERROR_NOT_SUPPORTED);
 
                return 0;
        }
 
-       ret = conv_service_create(&handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+       for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+               ret = conv_service_create(&handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_type(handle, value);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_set_type(handle, service_types[i]);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_get_type(handle, &value_2);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_get_type(handle, &value);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_destroy(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_destroy(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
+       }
 
        return 0;
 }
@@ -663,29 +674,31 @@ int utc_d2d_conv_manager_conv_service_get_type_p(void)
  */
 int utc_d2d_conv_manager_conv_service_get_type_n1(void)
 {
+       int i;
        int ret = CONV_ERROR_NONE;
        conv_service_h handle;
-       conv_service_e value = CONV_SERVICE_APP_TO_APP_COMMUNICATION;
-       conv_service_e value_2;
+       conv_service_e value;
 
        if (g_feature == false) {
-               ret = conv_service_get_type(NULL, &value_2);
+               ret = conv_service_get_type(NULL, &value);
                assert_eq(ret, CONV_ERROR_NOT_SUPPORTED);
 
                return 0;
        }
 
-       ret = conv_service_create(&handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+       for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+               ret = conv_service_create(&handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_type(handle, value);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_set_type(handle, service_types[i]);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_get_type(NULL, &value_2);
-       assert_eq(ret, CONV_ERROR_INVALID_PARAMETER);
+               ret = conv_service_get_type(NULL, &value);
+               assert_eq(ret, CONV_ERROR_INVALID_PARAMETER);
 
-       ret = conv_service_destroy(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_destroy(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
+       }
 
        return 0;
 }
@@ -699,9 +712,9 @@ int utc_d2d_conv_manager_conv_service_get_type_n1(void)
  */
 int utc_d2d_conv_manager_conv_service_get_type_n2(void)
 {
+       int i;
        int ret = CONV_ERROR_NONE;
        conv_service_h handle;
-       conv_service_e value = CONV_SERVICE_APP_TO_APP_COMMUNICATION;
 
        if (g_feature == false) {
                ret = conv_service_get_type(handle, NULL);
@@ -710,17 +723,19 @@ int utc_d2d_conv_manager_conv_service_get_type_n2(void)
                return 0;
        }
 
-       ret = conv_service_create(&handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+       for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+               ret = conv_service_create(&handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_type(handle, value);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_set_type(handle, service_types[i]);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_get_type(handle, NULL);
-       assert_eq(ret, CONV_ERROR_INVALID_PARAMETER);
+               ret = conv_service_get_type(handle, NULL);
+               assert_eq(ret, CONV_ERROR_INVALID_PARAMETER);
 
-       ret = conv_service_destroy(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_destroy(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
+       }
 
        return 0;
 }
@@ -734,25 +749,29 @@ int utc_d2d_conv_manager_conv_service_get_type_n2(void)
  */
 int utc_d2d_conv_manager_conv_service_set_type_p(void)
 {
+       int i;
        int ret = CONV_ERROR_NONE;
        conv_service_h handle;
-       conv_service_e value = CONV_SERVICE_APP_TO_APP_COMMUNICATION;
 
        if (g_feature == false) {
-               ret = conv_service_set_type(handle, value);
-               assert_eq(ret, CONV_ERROR_NOT_SUPPORTED);
+               for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+                       ret = conv_service_set_type(handle, service_types[i]);
+                       assert_eq(ret, CONV_ERROR_NOT_SUPPORTED);
+               }
 
                return 0;
        }
 
-       ret = conv_service_create(&handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+       for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+               ret = conv_service_create(&handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_type(handle, value);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_set_type(handle, service_types[i]);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_destroy(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_destroy(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
+       }
 
        return 0;
 }
@@ -766,25 +785,29 @@ int utc_d2d_conv_manager_conv_service_set_type_p(void)
  */
 int utc_d2d_conv_manager_conv_service_set_type_n1(void)
 {
+       int i;
        int ret = CONV_ERROR_NONE;
        conv_service_h handle;
-       conv_service_e value = CONV_SERVICE_APP_TO_APP_COMMUNICATION;
 
        if (g_feature == false) {
-               ret = conv_service_set_type(NULL, value);
-               assert_eq(ret, CONV_ERROR_NOT_SUPPORTED);
+               for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+                       ret = conv_service_set_type(NULL, service_types[i]);
+                       assert_eq(ret, CONV_ERROR_NOT_SUPPORTED);
+               }
 
                return 0;
        }
 
-       ret = conv_service_create(&handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+       for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+               ret = conv_service_create(&handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_type(NULL, value);
-       assert_eq(ret, CONV_ERROR_INVALID_PARAMETER);
+               ret = conv_service_set_type(NULL, service_types[i]);
+               assert_eq(ret, CONV_ERROR_INVALID_PARAMETER);
 
-       ret = conv_service_destroy(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_destroy(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
+       }
 
        return 0;
 }
@@ -1076,10 +1099,10 @@ int utc_d2d_conv_manager_conv_service_stop_n(void)
  */
 int utc_d2d_conv_manager_conv_service_set_listener_cb_p(void)
 {
+       int i;
        int ret = CONV_ERROR_NONE;
        conv_service_h handle;
        void *user_data = NULL;
-       conv_service_e value = CONV_SERVICE_APP_TO_APP_COMMUNICATION;
 
        if (g_feature == false) {
                ret = conv_service_set_listener_cb(handle, test_service_listener_cb, user_data);
@@ -1088,20 +1111,22 @@ int utc_d2d_conv_manager_conv_service_set_listener_cb_p(void)
                return 0;
        }
 
-       ret = conv_service_create(&handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+       for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+               ret = conv_service_create(&handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_type(handle, value);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_set_type(handle, service_types[i]);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_listener_cb(handle, test_service_listener_cb, user_data);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_set_listener_cb(handle, test_service_listener_cb, user_data);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_unset_listener_cb(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_unset_listener_cb(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_destroy(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_destroy(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
+       }
 
        return 0;
 }
@@ -1179,10 +1204,10 @@ int utc_d2d_conv_manager_conv_service_set_listener_cb_n2(void)
  */
 int utc_d2d_conv_manager_conv_service_unset_listener_cb_p(void)
 {
+       int i;
        int ret = CONV_ERROR_NONE;
        conv_service_h handle;
        void *user_data = NULL;
-       conv_service_e value = CONV_SERVICE_APP_TO_APP_COMMUNICATION;
 
        if (g_feature == false) {
                ret = conv_service_unset_listener_cb(handle);
@@ -1191,20 +1216,22 @@ int utc_d2d_conv_manager_conv_service_unset_listener_cb_p(void)
                return 0;
        }
 
-       ret = conv_service_create(&handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+       for (i = 0; i < ARRAY_SIZE(service_types); i++) {
+               ret = conv_service_create(&handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_type(handle, value);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_set_type(handle, service_types[i]);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_set_listener_cb(handle, test_service_listener_cb, user_data);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_set_listener_cb(handle, test_service_listener_cb, user_data);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_unset_listener_cb(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_unset_listener_cb(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
 
-       ret = conv_service_destroy(handle);
-       assert_eq(ret, CONV_ERROR_NONE);
+               ret = conv_service_destroy(handle);
+               assert_eq(ret, CONV_ERROR_NONE);
+       }
 
        return 0;
 }