Change demo program
authorJihoon Jung <jh8801.jung@samsung.com>
Thu, 11 Jan 2018 10:15:09 +0000 (19:15 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:40 +0000 (19:38 +0900)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
capi/demo/companion_demo.c

index 2ab3471..6c4361d 100755 (executable)
@@ -8,13 +8,13 @@
 #include <familynet.h>
 
 #define BUFFER_LEN 100
-#define TEST_CASE_MAX 3
+#define TEST_CASE_MAX 5
 
 #define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
 #define TC_PRT(format, args...) PRT(format"\n", ##args)
 
-#define BEGIN() TC_PRT("BEGIN >>>>");
-#define END() TC_PRT("END <<<<");
+#define BEGIN() TC_PRT("BEGIN");
+#define END() TC_PRT("END");
 
 GMainLoop *main_loop = NULL;
 
@@ -106,6 +106,76 @@ int familynet_group_create_test(void)
        return ret;
 }
 
+bool _group_found_cb(familynet_group_type_e type, familynet_group_h group, void *user_data)
+{
+       char *uri_path;
+
+       familynet_group_information_get_uri_path(group, &uri_path);
+
+       TC_PRT("found group type : %d, uri : %s", type, uri_path);
+}
+
+void _group_finish_cb(int result, void *user_data)
+{
+       TC_PRT("find operation finished");
+
+}
+
+int familynet_group_find_test(void)
+{
+       int ret = 0;
+       int input_int = 0;
+
+       BEGIN();
+
+       if (!test_get_user_int("==> Input timeout value (sec)"
+                                                " - (Enter for skip) :", &input_int))
+       {
+               input_int = 5;
+               TC_PRT("default timeout value [%d]", input_int);
+       }
+
+       familynet_group_find(input_int, _group_found_cb, _group_finish_cb, NULL);
+
+       if (ret == 0)
+               TC_PRT("group find successful");
+       else
+               TC_PRT("group find failed, ret [%d]", ret);
+
+       END();
+       return ret;
+}
+
+int familynet_group_get_found_groups_test(void)
+{
+       int ret = 0;
+       int input_int = 0;
+       int count;
+       familynet_group_h *groups;
+
+       BEGIN();
+
+       ret = familynet_group_get_found_groups(&groups ,&count);
+
+       if (ret == 0)
+               TC_PRT("group find successful");
+       else
+               TC_PRT("group find failed, ret [%d]", ret);
+
+       TC_PRT("Found groups device count : ", count);
+
+       for (int i = 0; i < count; i++) {
+               familynet_group_type_e type;
+               char *uri_path;
+               familynet_group_information_get_type(groups[i], &type);
+               familynet_group_information_get_uri_path(groups[i], &uri_path);
+               TC_PRT("%d. type : %d, uri path : %s", i+1, type, uri_path);
+       }
+
+       END();
+       return ret;
+}
+
 int familynet_deinitialize_test(void)
 {
        int ret = 0;
@@ -127,6 +197,8 @@ tc_table_t tc_table[] = {
        /* manager api */
        {"familynet_initialize_test",  1,       familynet_initialize_test},
        {"familynet_group_create_test",  2,     familynet_group_create_test},
+       {"familynet_group_find_test",  3,       familynet_group_find_test},
+       {"familynet_group_get_found_groups_test",  4,   familynet_group_get_found_groups_test},
        {"familynet_deinitialize_test",  TEST_CASE_MAX, familynet_deinitialize_test},
 
        /*-----------*/
@@ -186,7 +258,6 @@ static gboolean key_event_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
        int rv = 0;
 
        memset(buf, 0, sizeof(buf));
-       printf("Event received from stdin\n");
 
        rv = read(0, buf, 100);