#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;
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;
/* 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},
/*-----------*/
int rv = 0;
memset(buf, 0, sizeof(buf));
- printf("Event received from stdin\n");
rv = read(0, buf, 100);