Added test-code of config CAPIs to set IP details. 99/186499/7 accepted/tizen/unified/20180907.211654 submit/tizen/20180907.071239
authorNiraj Kumar Goit <niraj.g@samsung.com>
Fri, 10 Aug 2018 03:39:10 +0000 (09:09 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Wed, 5 Sep 2018 11:59:42 +0000 (11:59 +0000)
Added test-code for below config CAPIs to set IP details.
- wifi_manager_config_set_ip_config_type()
- wifi_manager_config_set_ip_address()
- wifi_manager_config_set_subnet_mask()
- wifi_manager_config_set_gateway_address()
- wifi_manager_config_set_dns_config_type()
- wifi_manager_config_set_dns_address()

Change-Id: I6f1515f098d90019d7b805f7ed10975fa5882e4a
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
test/wifi_manager_test.c

index ca2b692..4af7d58 100755 (executable)
@@ -2087,7 +2087,10 @@ int test_wifi_manager_config_save(void)
        int type = 0;
        char proxy[100] = { 0, };
        int hidden = 0;
+       int address_type = 0;
+       char ip_addr[40] = { 0, };
        wifi_manager_config_h config;
+       int ip_update = 0;
 
        printf("Input AP configuration\n");
        printf("Name : ");
@@ -2109,8 +2112,157 @@ int test_wifi_manager_config_save(void)
        if (rv != WIFI_MANAGER_ERROR_NONE)
                return -1;
 
+       rv = test_get_user_int("Update IP details (0:No, 1:Yes):", &ip_update);
+       if (rv == false || (ip_update != 0 && ip_update != 1)) {
+               printf("Invalid input!!\n");
+               return -1;
+       }
+
+       if (ip_update == 1) {
+               rv = test_get_user_int("Input Address type "
+                                                          "(0:IPV4, 1:IPV6):", &address_type);
+
+               if (rv == false || (address_type != 0 && address_type != 1)) {
+                       printf("Invalid input!!\n");
+                       return -1;
+               }
+               rv = wifi_manager_config_set_ip_config_type(config, address_type,
+                                                                       WIFI_MANAGER_IP_CONFIG_TYPE_STATIC);
+               if (rv != WIFI_MANAGER_ERROR_NONE) {
+                       printf("Fail to set ip method type[%s]\n",
+                                  __test_convert_error_to_string(rv));
+                       return -1;
+               }
+
+               printf("Input new ip address (x:skip, 0:clear) :\n");
+               rv = scanf("%39s", ip_addr);
+               if (rv > 0) {
+                       switch (ip_addr[0]) {
+                       case 'x':
+                               rv = WIFI_MANAGER_ERROR_NONE;
+                               break;
+                       case '0':
+                               rv = wifi_manager_config_set_ip_address(config, address_type,
+                                                                                                               NULL);
+                               break;
+                       default:
+                               rv = wifi_manager_config_set_ip_address(config, address_type,
+                                                                                                               ip_addr);
+                       }
+
+                       if (rv != WIFI_MANAGER_ERROR_NONE) {
+                               printf("Fail to set ip address[%s]\n",
+                                          __test_convert_error_to_string(rv));
+                               return -1;
+                       }
+               }
+
+               printf("Input new subnet mask (x:skip, 0:clear) :\n");
+               rv = scanf("%39s", ip_addr);
+               if (rv > 0) {
+                       switch (ip_addr[0]) {
+                       case 'x':
+                               rv = WIFI_MANAGER_ERROR_NONE;
+                               break;
+                       case '0':
+                               rv = wifi_manager_config_set_subnet_mask(config, address_type,
+                                                                                                                NULL);
+                               break;
+                       default:
+                               rv = wifi_manager_config_set_subnet_mask(config, address_type,
+                                                                                                                ip_addr);
+                       }
+
+                       if (rv != WIFI_MANAGER_ERROR_NONE) {
+                               printf("Fail to set subnet mask[%s]\n",
+                                          __test_convert_error_to_string(rv));
+                               return -1;
+                       }
+               }
+
+               printf("Input new gateway address (x:skip, 0:clear) :\n");
+               rv = scanf("%39s", ip_addr);
+               if (rv > 0) {
+                       switch (ip_addr[0]) {
+                       case 'x':
+                               rv = WIFI_MANAGER_ERROR_NONE;
+                               break;
+                       case '0':
+                               rv = wifi_manager_config_set_gateway_address(config,
+                                                                                address_type, NULL);
+                               break;
+                       default:
+                               rv = wifi_manager_config_set_gateway_address(config,
+                                                                                address_type, ip_addr);
+                       }
+
+                       if (rv != WIFI_MANAGER_ERROR_NONE) {
+                               printf("Fail to set gateway address[%s]\n",
+                                          __test_convert_error_to_string(rv));
+                               return -1;
+                       }
+               }
+
+               rv = wifi_manager_config_set_dns_config_type(config,
+                                                        address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC);
+               if (rv == WIFI_MANAGER_ERROR_NONE) {
+                       printf("Input DNS1 address (x: skip, 0: clear) : \n");
+                       if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+                               rv = scanf("%15s", ip_addr);
+                       else
+                               rv = scanf("%39s", ip_addr);
+                       if (rv > 0) {
+                               switch (ip_addr[0]) {
+                               case 'x':
+                                       rv = WIFI_MANAGER_ERROR_NONE;
+                                       break;
+                               case '0':
+                                       rv = wifi_manager_config_set_dns_address(config,
+                                                                                                1, address_type, NULL);
+                                       break;
+                               default:
+                                       rv = wifi_manager_config_set_dns_address(config,
+                                                                                                                        1, address_type,
+                                                                                                                        ip_addr);
+                               }
+                       }
+                       if (rv != WIFI_MANAGER_ERROR_NONE) {
+                               printf("Fail to set DNS1 address[%s]\n",
+                                          __test_convert_error_to_string(rv));
+                               return -1;
+                       }
+
+                       printf("Input DNS2 address (x: skip, 0: clear) : \n");
+                       if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV4)
+                               rv = scanf("%15s", ip_addr);
+                       else
+                               rv = scanf("%39s", ip_addr);
+                       if (rv > 0) {
+                               switch (ip_addr[0]) {
+                               case 'x':
+                                       rv = WIFI_MANAGER_ERROR_NONE;
+                                       break;
+                               case '0':
+                                       rv = wifi_manager_config_set_dns_address(config,
+                                                                                                2, address_type, NULL);
+                                       break;
+                               default:
+                                       rv = wifi_manager_config_set_dns_address(config,
+                                                                                                                        2, address_type,
+                                                                                                                        ip_addr);
+                               }
+                       }
+                       if (rv != WIFI_MANAGER_ERROR_NONE) {
+                               printf("Fail to set DNS2 address[%s]\n",
+                                          __test_convert_error_to_string(rv));
+                               return -1;
+                       }
+               }
+       }
+
        if (test_get_user_string("Proxy(server:port) - (Enter for skip): ", proxy, 99)) {
-               rv = wifi_manager_config_set_proxy_address(config, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, proxy);
+               rv = wifi_manager_config_set_proxy_address(config,
+                                                WIFI_MANAGER_ADDRESS_FAMILY_IPV4, proxy);
                if (rv != WIFI_MANAGER_ERROR_NONE)
                        return -1;
        }