Suppose Device trying to connect with a wifi router which does not support IPV6.
[platform/core/api/connection.git] / test / connection_test.c
index 2abebf0..4a63bac 100755 (executable)
@@ -231,6 +231,10 @@ static const char *test_print_error(connection_error_e error)
                return "CONNECTION_ERROR_PERMISSION_DENIED";
        case CONNECTION_ERROR_NOT_SUPPORTED:
                return "CONNECTION_ERROR_NOT_SUPPORTED";
+       case CONNECTION_ERROR_NOT_INITIALIZED:
+               return "CONNECTION_ERROR_NOT_INITIALIZED";
+       case CONNECTION_ERROR_ALREADY_INITIALIZED:
+               return "CONNECTION_ERROR_ALREADY_INITIALIZED";
        default:
                return "CONNECTION_ERROR_UNKNOWN";
        }
@@ -1029,6 +1033,65 @@ int  test_deregister_client(void)
        return 1;
 }
 
+int test_register_client_cs(void)
+{
+       int tid = 0;
+       test_get_user_int("Input a TID in C# API :", &tid);
+
+       int err = connection_create_cs(tid, &connection);
+
+       if (CONNECTION_ERROR_NONE == err) {
+               connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
+               connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
+               connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
+               connection_set_ethernet_cable_state_chaged_cb(connection,
+                                       test_get_ethernet_cable_state_callback, NULL);
+       } else {
+               printf("Client registration failed [%s]\n", test_print_error(err));
+               return -1;
+       }
+
+       printf("Client registration success\n");
+       return 1;
+}
+
+int  test_deregister_client_cs(void)
+{
+       int rv = 0;
+       GSList *list;
+       connection_profile_h profile;
+       int tid = 0;
+
+       test_get_user_int("Input a TID in C# API :", &tid);
+
+       if (connection != NULL)
+               rv = connection_destroy_cs(tid, connection);
+       else {
+               printf("Cannot deregister : Handle is NULL\n");
+               rv = CONNECTION_ERROR_INVALID_OPERATION;
+       }
+
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Client deregistration fail [%s]\n", test_print_error(rv));
+               return -1;
+       }
+
+       if (state_cb_list) {
+               for (list = state_cb_list; list; list = list->next) {
+                       profile = list->data;
+                       connection_profile_destroy(profile);
+               }
+
+               g_slist_free(state_cb_list);
+               state_cb_list = NULL;
+       }
+
+       connection = NULL;
+       printf("Client deregistration success\n");
+
+       return 1;
+}
+
 int test_get_network_state(void)
 {
        int rv = 0;
@@ -2186,8 +2249,15 @@ int test_get_tcpdump_state(void)
 int test_mptcp_enable(void)
 {
        int rv = 0;
-       rv = connection_mptcp_enable(CONNECTION_MPTCP_ENABLE_ALL);
+       bool supported = false;
+       rv = connection_mptcp_is_supported(connection, &supported);
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Failure[%s]\n", test_print_error(rv));
+               return -1;
+       }
+       printf("MPTCP Support: %d\n", supported);
 
+       rv = connection_mptcp_enable(connection, CONNECTION_MPTCP_ENABLE_ALL);
        if (rv != CONNECTION_ERROR_NONE) {
                printf("Failure[%s]\n", test_print_error(rv));
                return -1;
@@ -2198,7 +2268,7 @@ int test_mptcp_enable(void)
 int test_mptcp_disable(void)
 {
        int rv = 0;
-       rv = connection_mptcp_disable();
+       rv = connection_mptcp_disable(connection);
 
        if (rv != CONNECTION_ERROR_NONE) {
                printf("Failure[%s]\n", test_print_error(rv));
@@ -2215,10 +2285,10 @@ int test_mptcp_set_path_manager(void)
 
        switch (input) {
        case 1:
-               rv = connection_mptcp_set_path_manager(CONNECTION_MPTCP_PM_DEFAULT);
+               rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_DEFAULT);
                break;
        case 2:
-               rv = connection_mptcp_set_path_manager(CONNECTION_MPTCP_PM_FULLMESH);
+               rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_FULLMESH);
                break;
        default:
                printf("Invalid input!!\n");
@@ -2238,7 +2308,7 @@ int test_mptcp_get_path_manager(void)
        int rv = 0;
        connection_mptcp_path_manager_e pm;
 
-       rv = connection_mptcp_get_path_manager(&pm);
+       rv = connection_mptcp_get_path_manager(connection, &pm);
        if (rv != CONNECTION_ERROR_NONE) {
                printf("Failure[%s]\n", test_print_error(rv));
                return -1;
@@ -2267,10 +2337,10 @@ int test_mptcp_set_scheduler(void)
 
        switch (input) {
        case 1:
-               rv = connection_mptcp_set_scheduler(CONNECTION_MPTCP_SCHEDULER_DEFAULT);
+               rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_DEFAULT);
                break;
        case 2:
-               rv = connection_mptcp_set_scheduler(CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
+               rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
                break;
        default:
                printf("Invalid input!!\n");
@@ -2290,7 +2360,7 @@ int test_mptcp_get_scheduler(void)
        int rv = 0;
        connection_mptcp_scheduler_e scheduler;
 
-       rv = connection_mptcp_get_scheduler(&scheduler);
+       rv = connection_mptcp_get_scheduler(connection, &scheduler);
        if (rv != CONNECTION_ERROR_NONE) {
                printf("Failure[%s]\n", test_print_error(rv));
                return -1;
@@ -2398,6 +2468,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("N   - Get MPTCP Path Manager (internal)\n");
                printf("O   - Set MPTCP Scheduler (internal)\n");
                printf("P   - Get MPTCP Scheduler (internal)\n");
+               printf(LOG_GREEN "Q   - Create Handle and set callbacks in C# API\n" LOG_END);
+               printf("R   - Destroy Handle(unset callbacks automatically in C# API)\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
                printf("ENTER   - Show options menu.......\n");
        }
@@ -2549,6 +2621,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'P':
                rv = test_mptcp_get_scheduler();
                break;
+       case 'Q':
+               rv = test_register_client_cs();
+               break;
+       case 'R':
+               rv = test_deregister_client_cs();
+               break;
 
        }