[ITC][wifi-manager][NON-ACR][TSAM11160, fixed 2 failed TCs]
authorShobhit Verma <shobhit.v@samsung.com>
Mon, 19 Dec 2016 06:27:46 +0000 (11:57 +0530)
committerShobhit Verma <shobhit.v@samsung.com>
Mon, 19 Dec 2016 06:27:46 +0000 (11:57 +0530)
Change-Id: I1a15219720c2086a5c15969b7b606b891cb34838
Signed-off-by: Shobhit Verma <shobhit.v@samsung.com>
src/itc/wifi-manager/ITs-wifi-manager-ap.c
src/itc/wifi-manager/ITs-wifi-manager-common.c
src/itc/wifi-manager/ITs-wifi-manager-common.h

index 8a3461c..54ffbc9 100755 (executable)
@@ -1303,8 +1303,10 @@ int ITc_wifi_manager_connect_disconnect_p(void)
        int nRet ;
        
        //Target API Inside calling wifi_manager_connect
-       nRet = wifi_manager_pre_connect();
-       PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, nRet, "wifi_manager_pre_connect", WifiManagerGetError(nRet));
+       if (wifi_manager_pre_connect() != WIFI_MANAGER_ERROR_NONE)
+       {
+               return 1;
+       }
        
        nRet = wifi_manager_get_connected_ap(g_hWifi, &hAP);
        PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, nRet, "wifi_manager_get_connected_ap", WifiManagerGetError(nRet));
index 2c5c495..a30e8af 100755 (executable)
@@ -202,22 +202,24 @@ bool wifi_manager_found_ap_callback(wifi_manager_ap_h ap, void *user_data)
        size_t ap_name_len = strlen(ap_name_part);
        int ret = WIFI_MANAGER_ERROR_NONE;
 
-       if (ap) {
+       if (ap) 
+       {
                ret = wifi_manager_ap_get_essid(ap, &ap_name);
                CHECK_RETURN("wifi_manager_ap_get_essid", ret, WIFI_MANAGER_ERROR_NONE);
 
                FPRINTF("[%s:%d] AP ssid : %s\\n", __FILE__, __LINE__, ap_name);
-               if (!strncmp(ap_name, ap_name_part, ap_name_len)) {
+               if (!strncmp(ap_name, ap_name_part, ap_name_len))
+               {
                        FREE_MEMORY(ap_name);
                        ret = wifi_manager_ap_clone(&g_hWifiAP, ap);
                        CHECK_RETURN("wifi_manager_ap_clone", ret, WIFI_MANAGER_ERROR_NONE);
-                       if (g_hWifiAP) {
+                       if (g_hWifiAP) 
+                       {
                                g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
                                return false;
                        }
                }
        }
-       QUIT_GMAIN_LOOP;
        return true;
 }
 
@@ -343,54 +345,83 @@ int wifi_manager_pre_deactivate(void)
 
 int wifi_manager_pre_connect(void)
 {
-               wifi_manager_connection_state_e connection_state;
-               char ap_name[CONFIG_VALUE_LEN_MAX] = {0,};
-               char ap_passphrase[CONFIG_VALUE_LEN_MAX] = {0,};
-               bool required = false;
-               int ret = WIFI_MANAGER_ERROR_NONE;
-
-               ret = wifi_manager_pre_activate();
-               CHECK_RETURN("wifi_manager_pre_activate", ret, WIFI_MANAGER_ERROR_NONE);
-
-               ret = wifi_manager_get_connection_state(g_hWifi, &connection_state);
-               CHECK_RETURN("wifi_manager_get_connection_state", ret, WIFI_MANAGER_ERROR_NONE);
-
-               if (connection_state == WIFI_MANAGER_CONNECTION_STATE_CONNECTED)
-                       return WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_connection_state_e connection_state;
+       char ap_name[CONFIG_VALUE_LEN_MAX] = {0,};
+       char ap_passphrase[CONFIG_VALUE_LEN_MAX] = {0,};
+       bool required = false;
+       int ret = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_ap_h hAP = NULL;
 
-               if (!wifi_manager_get_value_from_configfile("WIFI_WPSACCESSPOINTNAME", ap_name)) {
-                       FPRINTF("[%s:%d] wifi_manager_get_value_from_configfile(WIFI_WPSACCESSPOINTNAME) failed \\n", __FILE__, __LINE__);
-                       return -1;
-               }
+       ret = wifi_manager_pre_activate();
+       PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_pre_activate", WifiManagerGetError(ret));
 
-               if (!wifi_manager_get_value_from_configfile("WIFI_ACCESSPOINTPIN", ap_passphrase)) {
-                       FPRINTF("[%s:%d] wifi_manager_get_value_from_configfile(WIFI_ACCESSPOINTPIN) failed \\n", __FILE__, __LINE__);
-                       return -1;
-               }
+       ret = wifi_manager_get_connection_state(g_hWifi, &connection_state);
+       PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_get_connection_state", WifiManagerGetError(ret));
 
-               ret = wifi_manager_scan(g_hWifi, wifi_manager_scanned_callback, NULL);
-               PRINT_RETURN("wifi_manager_scan", ret);
+       if (connection_state == WIFI_MANAGER_CONNECTION_STATE_CONNECTED)
+       {
+               FPRINTF("[%s:%d] Connection State is connected.\\n", __FILE__, __LINE__);
+               ret = wifi_manager_get_connected_ap(g_hWifi, &hAP);
+               PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_get_connected_ap", WifiManagerGetError(ret));
+               
+               g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+               g_bWifiManagerCB = false;
+               ret = wifi_manager_disconnect(g_hWifi, hAP, wifi_manager_disconnected_callback, NULL);
+               PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_disconnect", WifiManagerGetError(ret));
                RUN_POLLING_LOOP;
-               CHECK_RETURN(CALLBACK_RETURN, g_nCallbackRet, WIFI_MANAGER_ERROR_NONE);
-
-               ret = wifi_manager_foreach_found_ap(g_hWifi, wifi_manager_found_ap_callback, ap_name);
-               PRINT_RETURN("wifi_manager_foreach_found_ap", ret);
-               CHECK_RETURN(CALLBACK_RETURN, g_nCallbackRet, WIFI_MANAGER_ERROR_NONE);
-
-               ret = wifi_manager_ap_is_passphrase_required(g_hWifiAP, &required);
-               CHECK_RETURN("wifi_manager_ap_is_passphrase_required", ret, WIFI_MANAGER_ERROR_NONE);
-
-               if (required) {
-                       ret = wifi_manager_ap_set_passphrase(g_hWifiAP, ap_passphrase);
-                       CHECK_RETURN("wifi_manager_ap_set_passphrase", ret, WIFI_MANAGER_ERROR_NONE);
+               if (!g_bWifiManagerCB || (g_nCallbackRet != WIFI_MANAGER_ERROR_NONE) )
+               {
+                       FPRINTF("[%s:%d] Callback issue for wifi_manager_disconnect api\\n", __FILE__, __LINE__);
+                       return 1;
                }
+       }
+       
+       if (!wifi_manager_get_value_from_configfile("WIFI_WPSACCESSPOINTNAME", ap_name)) 
+       {
+               FPRINTF("[%s:%d] wifi_manager_get_value_from_configfile(WIFI_WPSACCESSPOINTNAME) failed \\n", __FILE__, __LINE__);
+               return 1;
+       }
 
-               ret = wifi_manager_connect(g_hWifi, g_hWifiAP, wifi_manager_connected_callback, NULL);
-               PRINT_RETURN("wifi_manager_connect", ret);
-               RUN_POLLING_LOOP;
-               CHECK_RETURN(CALLBACK_RETURN, g_nCallbackRet, WIFI_MANAGER_ERROR_NONE);
+       if (!wifi_manager_get_value_from_configfile("WIFI_ACCESSPOINTPIN", ap_passphrase)) 
+       {
+               FPRINTF("[%s:%d] wifi_manager_get_value_from_configfile(WIFI_ACCESSPOINTPIN) failed \\n", __FILE__, __LINE__);
+               return 1;
+       }
 
-               return WIFI_MANAGER_ERROR_NONE;
+       g_bWifiManagerCB = false;
+       ret = wifi_manager_scan(g_hWifi, wifi_manager_scanned_callback, NULL);
+       PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_scan", WifiManagerGetError(ret));
+       RUN_POLLING_LOOP;
+       if (!g_bWifiManagerCB || (g_nCallbackRet != WIFI_MANAGER_ERROR_NONE) )
+       {
+               FPRINTF("[%s:%d] Callback issue for wifi_manager_scan api\\n", __FILE__, __LINE__);
+               return 1;
+       }
+       
+       ret = wifi_manager_foreach_found_ap(g_hWifi, wifi_manager_found_ap_callback, ap_name);
+       PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_foreach_found_ap", WifiManagerGetError(ret));
+       
+       ret = wifi_manager_ap_is_passphrase_required(g_hWifiAP, &required);
+       PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_ap_is_passphrase_required", WifiManagerGetError(ret));
+       
+       if (required) 
+       {
+               ret = wifi_manager_ap_set_passphrase(g_hWifiAP, ap_passphrase);
+               PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_ap_set_passphrase", WifiManagerGetError(ret));
+       }
+
+       g_bWifiManagerCB = false;
+       ret = wifi_manager_connect(g_hWifi, g_hWifiAP, wifi_manager_connected_callback, NULL);
+       PRINT_RESULT(WIFI_MANAGER_ERROR_NONE, ret, "wifi_manager_connect", WifiManagerGetError(ret));
+       RUN_POLLING_LOOP;
+       
+       if (!g_bWifiManagerCB || (g_nCallbackRet != WIFI_MANAGER_ERROR_NONE) )
+       {
+               FPRINTF("[%s:%d] Callback issue for wifi_manager_connect api\\n", __FILE__, __LINE__);
+               return 1;
+       }
+       
+       return WIFI_MANAGER_ERROR_NONE;
 }
 
 
index 2ffe28c..d2982bd 100755 (executable)
@@ -31,7 +31,7 @@
 #define API_NAMESPACE                  "WIFI_MANAGER_ITC"
 #define MICROSECONDS_PER_SECOND        1000000
 #define MINCOUNT                               1
-#define TIMEOUT_CB                             10000
+#define TIMEOUT_CB                             20000
 #define WIFI_CONFIG_LEN                                64
 #define WIFI_AP_NAME                           "AccessPoint"
 #define WIFI_AP_PASSPHRASE                     "Passphrase"