)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig)
-ADD_SUBDIRECTORY(test)
ADD_SUBDIRECTORY(tool)
+IF(BUILD_GTESTS)
+ ADD_SUBDIRECTORY(tests)
+ENDIF(BUILD_GTESTS)
+
IF(UNIX)
ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
%if 0%{?gcov:1}
%package gcov
-Summary: Network Wi-Fi manager library(gcov)
-Group: Network/Testing
+Summary: Network Wi-Fi manager library(gcov)
+Group: Network/Testing
+BuildRequires: pkgconfig(gmock)
+BuildRequires: lcov
+BuildRequires: tar
+
%description gcov
gcov objects for coverage test
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
-DLIB_INSTALL_DIR=%{_libdir} -DINCLUDE_INSTALL_DIR=%{_includedir} \
- -DBIN_DIR=%{_bindir} \
- -DLIB_PATH=%{_lib} \
- .
+ -DBIN_DIR=%{_bindir} -DLIB_PATH=%{_lib} \
+ -DBUILD_GTESTS=%{?gcov:1}%{!?gcov:0} \
+ .
make %{?_smp_mflags}
-
-%if 0%{?gcov:1}
-mkdir -p gcov-obj
-find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
-%endif
-
%install
%make_install
%if 0%{?gcov:1}
-mkdir -p %{buildroot}%{_datadir}/gcov/obj
-install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
+find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T -
+install -d -m 755 %{buildroot}%{_datadir}/gcov/obj
+tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj
+
+%check
+tests/gtest-wifi-manager
+lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
+genhtml %{name}.info -o out --legend --show-details
%endif
%post -p /sbin/ldconfig
+++ /dev/null
-PROJECT(wifi_manager_test C)
-
-SET(fw_test "${fw_name}-test")
-
-SET(dependents "capi-base-common glib-2.0")
-SET(pc_dependents "capi-base-common")
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED ${dependents})
-FOREACH(flag ${${fw_test}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-
-aux_source_directory(. sources)
-FOREACH(src ${sources})
- GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
- MESSAGE("${src_name}")
- ADD_EXECUTABLE(${src_name} ${src})
- TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
-ENDFOREACH()
-
-INSTALL(TARGETS wifi_manager_test RUNTIME DESTINATION bin/)
+++ /dev/null
-/*
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/un.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include <assert.h>
-#include <wifi-manager.h>
-#include <wifi-manager-extension.h>
-#include <tizen_error.h>
-
-
-#define LOG_RED "\033[0;31m"
-#define LOG_GREEN "\033[0;32m"
-#define LOG_BROWN "\033[0;33m"
-#define LOG_BLUE "\033[0;34m"
-#define LOG_END "\033[0;m"
-
-#define MAC_ADDR_LEN 17
-
-wifi_manager_h wifi = NULL;
-wifi_manager_h wifi2 = NULL;
-
-gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
-int test_wifi_manager_foreach_bssid_scan(void);
-int test_wifi_manager_foreach_netlink_scan(void);
-
-static const char *__test_convert_error_to_string(wifi_manager_error_e err_type)
-{
- switch (err_type) {
- case WIFI_MANAGER_ERROR_NONE:
- return "NONE";
- case WIFI_MANAGER_ERROR_INVALID_PARAMETER:
- return "INVALID_PARAMETER";
- case WIFI_MANAGER_ERROR_OUT_OF_MEMORY:
- return "OUT_OF_MEMORY";
- case WIFI_MANAGER_ERROR_INVALID_OPERATION:
- return "INVALID_OPERATION";
- case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
- return "ADDRESS_FAMILY_NOT_SUPPORTED";
- case WIFI_MANAGER_ERROR_OPERATION_FAILED:
- return "OPERATION_FAILED";
- case WIFI_MANAGER_ERROR_NO_CONNECTION:
- return "NO_CONNECTION";
- case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS:
- return "NOW_IN_PROGRESS";
- case WIFI_MANAGER_ERROR_ALREADY_EXISTS:
- return "ALREADY_EXISTS";
- case WIFI_MANAGER_ERROR_OPERATION_ABORTED:
- return "OPERATION_ABORTED";
- case WIFI_MANAGER_ERROR_DHCP_FAILED:
- return "DHCP_FAILED";
- case WIFI_MANAGER_ERROR_INVALID_KEY:
- return "INVALID_KEY";
- case WIFI_MANAGER_ERROR_NO_REPLY:
- return "NO_REPLY";
- case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED:
- return "SECURITY_RESTRICTED";
- case WIFI_MANAGER_ERROR_ALREADY_INITIALIZED:
- return "ALREADY_INITIALIZED";
- case WIFI_MANAGER_ERROR_OUT_OF_RANGE:
- return "OUT_OF_RANGE";
- case WIFI_MANAGER_ERROR_CONNECT_FAILED:
- return "CONNECT_FAILED";
- case WIFI_MANAGER_ERROR_LOGIN_FAILED:
- return "LOGIN_FAILED";
- case WIFI_MANAGER_ERROR_AUTHENTICATION_FAILED:
- return "AUTH_FAILED";
- case WIFI_MANAGER_ERROR_PIN_MISSING:
- return "PIN_MISSING";
- case WIFI_MANAGER_ERROR_WPS_OVERLAP:
- return "WPS_OVERLAP";
- case WIFI_MANAGER_ERROR_WPS_TIMEOUT:
- return "WPS_TIMEOUT";
- case WIFI_MANAGER_ERROR_WPS_WEP_PROHIBITED:
- return "WPS_WEP_PROHIBITED";
- case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
- return "PERMISSION_DENIED";
- case WIFI_MANAGER_ERROR_OFFLINE:
- return "OFFLINE";
- case WIFI_MANAGER_ERROR_INVALID_GATEWAY:
- return "INVALID_GATEWAY";
- case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
- return "NOT_SUPPORTED";
- case WIFI_MANAGER_ERROR_NOT_INITIALIZED:
- return "NOT_INITIALIZED";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *__test_convert_connection_mode_to_string(wifi_manager_connection_mode_e mode)
-{
- switch (mode) {
- case WIFI_MANAGER_CONNECTION_MODE_80211_B:
- return "802.11b";
- case WIFI_MANAGER_CONNECTION_MODE_80211_G:
- return "802.11g";
- case WIFI_MANAGER_CONNECTION_MODE_80211_N:
- return "802.11n";
- case WIFI_MANAGER_CONNECTION_MODE_80211_A:
- return "802.11a";
- case WIFI_MANAGER_CONNECTION_MODE_80211_AC:
- return "802.11ac";
- case WIFI_MANAGER_CONNECTION_MODE_UNKNOWN:
- return "Uknown";
- default:
- return "Uknown";
- }
-}
-
-static void __test_device_state_callback(wifi_manager_device_state_e state, void* user_data)
-{
- printf("[%s] Device state changed callback", (char *)user_data);
-
- if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED)
- printf(", state : Activated\n");
- else
- printf(", state : Deactivated\n");
-}
-
-static void __test_scan_changed_callback(wifi_manager_scan_state_e state, void* user_data)
-{
- printf("Scan changed, scan state : %d\n", state);
-}
-
-static void __test_bg_scan_completed_callback(wifi_manager_error_e error_code, void* user_data)
-{
- printf("[%s] Background Scan Completed, error code : %s\n",
- (char *)user_data, __test_convert_error_to_string(error_code));
-}
-
-static void __test_ip_conflict_callback(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
-{
- if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED)
- printf("[%s] Ip conflict detected : %s\n", (char *)user_data, mac);
- else if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
- printf("Ip conflict removed\n");
- else
- printf("Ip conflict state unknown\n");
-}
-
-static void __test_scan_request_callback(wifi_manager_error_e error_code, void* user_data)
-{
- if (user_data != NULL)
- printf("user_data : %s\n", (char *)user_data);
-
- printf("Scan Completed from scan request, error code : %s\n",
- __test_convert_error_to_string(error_code));
-}
-
-static void __test_bssid_scan_request_callback(wifi_manager_error_e error_code, void *user_data)
-{
- printf("BSSID Scan Completed, error code : %s\n",
- __test_convert_error_to_string(error_code));
-
- if (error_code == WIFI_MANAGER_ERROR_NONE)
- test_wifi_manager_foreach_bssid_scan();
-}
-
-static void __test_netlink_scan_request_callback(wifi_manager_error_e error_code, void *user_data)
-{
- printf("Netlink Scan Completed, error code : %s\n",
- __test_convert_error_to_string(error_code));
-
- if (error_code == WIFI_MANAGER_ERROR_NONE)
- test_wifi_manager_foreach_netlink_scan();
-}
-
-static void __test_connection_state_callback(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void* user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
-
- printf("[%s] Connection state changed callback", (char *)user_data);
-
- switch (state) {
- case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
- printf(", state : Connected");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
- printf(", state : Association");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
- printf(", state : Configuration");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
- printf(", state : Disconnected");
- break;
- default:
- printf(", state : Unknown");
- }
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf(", Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- else {
- printf(", AP name : %s\n", ap_name);
- g_free(ap_name);
- }
-}
-
-static void __test_activated_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi Activation Succeeded\n");
- else
- printf("Wi-Fi Activation Failed! error : %s\n", __test_convert_error_to_string(result));
-}
-
-static void __test_deactivated_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi Deactivation Succeeded\n");
- else
- printf("Wi-Fi Deactivation Failed! error : %s\n", __test_convert_error_to_string(result));
-}
-
-static void __test_connected_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi Connection Succeeded\n");
- else
- printf("Wi-Fi Connection Failed! error : %s\n", __test_convert_error_to_string(result));
-}
-
-static void __test_disconnected_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi Disconnection Succeeded\n");
- else
- printf("Wi-Fi Disconnection Failed! error : %s\n", __test_convert_error_to_string(result));
-}
-
-static void __test_rssi_level_callback(wifi_manager_rssi_level_e rssi_level, void* user_data)
-{
- printf("[%s] RSSI level changed callback, level = %d\n", (char *)user_data, rssi_level);
-}
-
-static void __test_tdls_discover_callback(wifi_manager_tdls_discovery_state_e state, char *peer_mac_add, void *user_data)
-{
- printf("[%s] TDLS discover callback", (char *)user_data);
-
- printf(", Peer Mac Address [%s], state :%d\n", peer_mac_add, state);
- if (state == WIFI_MANAGER_TDLS_DISCOVERY_STATE_ONGOING)
- printf(", Discovery is ongoing");
- else
- printf(", Discovery is finished");
-}
-
-static void __test_get_wifi_module_state_callback(wifi_manager_module_state_e state, void *user_data)
-{
- printf("Wi-Fi Module State Changed callback : %d", state);
-
- if (state == WIFI_MANAGER_MODULE_STATE_ATTACHED)
- printf(", Wi-Fi Module Attached\n");
- else
- printf(", Wi-Fi Module Detached\n");
-}
-
-static void __test_tdls_state_callback(wifi_manager_tdls_state_e state, char *peer_mac_add, void *user_data)
-{
- printf("[%s] TDLS state changed callback", (char *)user_data);
-
- if (state == WIFI_MANAGER_TDLS_STATE_CONNECTED)
- printf(", state : TDLS Connected, Peer Mac Address [%s]\n", peer_mac_add);
- else
- printf(", state : TDLS Disconnected, Peer Mac Address [%s]\n", peer_mac_add);
-}
-
-static const char* __test_print_state(wifi_manager_connection_state_e state)
-{
- switch (state) {
- case WIFI_MANAGER_CONNECTION_STATE_FAILURE:
- return "Failure";
- case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
- return "Disconnected";
- case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
- return "Association";
- case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
- return "Connected";
- case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
- return "Configuration";
- }
-
- return "Unknown";
-}
-
-static bool __test_compare_ap_name(const char *ap_name, const char *ap_name_part)
-{
- int ap_name_len = strlen(ap_name);
- int ap_name_part_len = strlen(ap_name_part);
-
- if (strncmp(ap_name, ap_name_part,
- ap_name_len > ap_name_part_len ? ap_name_len : ap_name_part_len) == 0)
- return true;
- else
- return false;
-}
-
-static bool __test_found_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- wifi_manager_connection_state_e state;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- rv = wifi_manager_ap_get_connection_state(ap, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get State [%s]\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- printf("AP name : %s, state : %s\n", ap_name, __test_print_state(state));
- g_free(ap_name);
-
- return true;
-}
-
-struct _ap_data {
- char ap_name[33];
- bool is_found;
-};
-
-static bool __test_found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- struct _ap_data *data = (struct _ap_data*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, data->ap_name)) {
- bool required = false;
- data->is_found = true;
-
- if (wifi_manager_ap_is_passphrase_required(ap, &required) == WIFI_MANAGER_ERROR_NONE)
- printf("Passphrase required : %s\n", required ? "TRUE" : "FALSE");
- else
- printf("Fail to get Passphrase required\n");
-
- if (required) {
- char passphrase[100];
- printf("Input passphrase for %s : ", ap_name);
- rv = scanf(" %99s", passphrase);
-
- rv = wifi_manager_ap_set_passphrase(ap, passphrase);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
- }
-
- rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to connection request [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_connect_wps_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- int user_sel;
- char pin[32] = {0,};
-
- printf("%s - Input WPS method (1:PBC, 2:PIN) :\n", ap_name);
- rv = scanf(" %9d", &user_sel);
-
- switch (user_sel) {
- case 1:
- rv = wifi_manager_connect_by_wps_pbc(wifi, ap, __test_connected_callback, NULL);
- break;
- case 2:
- printf("Input PIN code :\n");
- rv = scanf("%31s", pin);
- rv = wifi_manager_connect_by_wps_pin(wifi, ap, pin, __test_connected_callback, NULL);
- break;
- default:
- printf("Invalid input!\n");
- g_free(ap_name);
- return false;
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to connection request [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_disconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- rv = wifi_manager_disconnect(wifi, ap, __test_disconnected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to disconnection reqeust %s : [%s]\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to disconnection request %s\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_forget_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- rv = wifi_manager_forget_ap(wifi, ap);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to forget [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to forget [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static void __test_forget_ap_finished_cb(wifi_manager_error_e result, void *user_data)
-{
- printf("Forget AP callback %s, error: [%s]\n",
- (result == WIFI_MANAGER_ERROR_NONE) ? "succeeded" : "failed",
- __test_convert_error_to_string(result));
-}
-
-static bool __test_found_forget_ap_async_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- rv = wifi_manager_forget_ap_async(wifi, ap,
- __test_forget_ap_finished_cb, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to forget [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to forget [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_eap_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- char *ap_name = NULL;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- wifi_manager_security_type_e type;
-
- if (wifi_manager_ap_get_security_type(ap, &type) == WIFI_MANAGER_ERROR_NONE)
- printf("Security type : %d\n", type);
- else
- printf("Fail to get Security type\n");
-
- if (type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
- g_free(ap_name);
- return false;
- }
-
- char input_str1[100];
- printf("Input user name for %s : ", ap_name);
- rv = scanf(" %99s", input_str1);
-
- char input_str2[100];
- printf("Input password for %s : ", ap_name);
- rv = scanf("%99s", input_str2);
-
- rv = wifi_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- char *inputed_name = NULL;
- bool is_pass_set;
- rv = wifi_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
-
- int input_int;
- printf("Input EAP type:\n");
- printf("0 -> WIFI_MANAGER_EAP_TYPE_PEAP\n");
- printf("1 -> WIFI_MANAGER_EAP_TYPE_TLS\n");
- printf("2 -> WIFI_MANAGER_EAP_TYPE_TTLS\n");
- printf("3 -> WIFI_MANAGER_EAP_TYPE_SIM\n");
- printf("4 -> WIFI_MANAGER_EAP_TYPE_AKA\n");
- printf("5 -> WIFI_MANAGER_EAP_TYPE_AKA_PRIME\n");
- printf("6 -> WIFI_MANAGER_EAP_TYPE_FAST\n");
- printf("7 -> WIFI_MANAGER_EAP_TYPE_PWD\n");
- rv = scanf("%d", &input_int);
-
- rv = wifi_manager_ap_set_eap_type(ap, input_int);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap type : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- g_free(inputed_name);
- return false;
- }
-
- if (input_int == 0 || input_int == 1 || input_int == 2) {
- printf("Input certificate file:\n");
- rv = scanf("%99s", input_str1);
-
- rv = wifi_manager_ap_set_eap_ca_cert_file(ap, input_str1);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap certificatefile : %s\n",
- __test_convert_error_to_string(rv));
- g_free(ap_name);
- g_free(inputed_name);
- return false;
- }
- }
-
- printf("Input EAP authentication type:\n");
- printf("0 -> WIFI_MANAGER_EAP_AUTH_TYPE_NONE\n");
- printf("1 -> WIFI_MANAGER_EAP_AUTH_TYPE_PAP\n");
- printf("2 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP\n");
- printf("3 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2\n");
- printf("4 -> WIFI_MANAGER_EAP_AUTH_TYPE_GTC\n");
- printf("5 -> WIFI_MANAGER_EAP_AUTH_TYPE_MD5\n");
- rv = scanf("%d", &input_int);
-
- rv = wifi_manager_ap_set_eap_auth_type(ap, input_int);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap auth type : %s\n",
- __test_convert_error_to_string(rv));
- g_free(ap_name);
- g_free(inputed_name);
- return false;
- }
-
- rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to connection request [%s]\n", ap_name);
-
- g_free(ap_name);
- g_free(inputed_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_set_autoconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0, enable;
- char *ap_name = NULL;
- bool autoconnect = false;
- char *ap_name_part = (char *)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[Wi-Fi] Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- printf("[Wi-Fi] Input command number (enable[1], disable[0]) : ");
- rv = scanf(" %9d", &enable);
- if (rv <= 0) {
- g_free(ap_name);
- return false;
- }
-
- if (enable != 0)
- autoconnect = true;
-
- rv = wifi_manager_ap_set_auto_connect(ap, autoconnect);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to set [%s]\n", ap_name);
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
-
- return true;
-}
-
-static bool __test_found_get_autoconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv = 0;
- bool autoconnect = false;
- char *ap_name = NULL;
- char *ap_name_part = (char *)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[Wi-Fi] Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- rv = wifi_manager_ap_get_auto_connect(ap, &autoconnect);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to get : [%s]\n", autoconnect ? "TRUE" : "FALSE");
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
-
- return true;
-}
-
-static bool test_get_user_int(const char *msg, int *num)
-{
- if (msg == NULL || num == NULL)
- return false;
-
- int rv;
- char buf[32] = {0,};
- printf("%s\n", msg);
- rv = read(0, buf, 32);
-
- if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
- return false;
-
- *num = atoi(buf);
- return true;
-}
-
-static bool test_get_user_string(const char *msg, char *buf, int buf_size)
-{
- if (msg == NULL || buf == NULL || buf_size < 2)
- return false;
-
- int rv;
- printf("%s\n", msg);
- memset(buf, 0, buf_size);
- rv = read(0, buf, buf_size - 1);
-
- if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
- buf[0] = '\0';
- return false;
- }
-
- buf[rv-1] = '\0';
- return true;
-}
-
-static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv;
- char *ap_name;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- wifi_manager_ip_config_type_e type;
- int method;
- int address_type;
- int dns_type;
- int prefix_len;
-
- printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n");
- rv = scanf(" %9d", &method);
- if (rv <= 0) {
- g_free(ap_name);
- return false;
- }
-
- rv = test_get_user_int("Input Address type to get"
- "(0:IPV4, 1:IPV6):", &address_type);
-
- if (rv == false || (address_type != 0 && address_type != 1)) {
- printf("Invalid input!!\n");
- g_free(ap_name);
- return false;
- }
-
- switch (method) {
- case 1:
- type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
- break;
- case 2:
- type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
- break;
- case 3:
- type = WIFI_MANAGER_IP_CONFIG_TYPE_AUTO;
- break;
- default:
- printf("Invalid input!\n");
- g_free(ap_name);
- return false;
- }
-
- rv = wifi_manager_ap_set_ip_config_type(ap, address_type, type);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set ip method type[%s]\n", __test_convert_error_to_string(rv));
-
- if (type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC) {
- char ip_addr[40];
-
- 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_ap_set_ip_address(ap, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_ip_address(ap, address_type, ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set ip address[%s]\n",
- __test_convert_error_to_string(rv));
- }
-
- 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_ap_set_subnet_mask(ap, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_subnet_mask(ap, address_type, ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set subnet mask[%s]\n",
- __test_convert_error_to_string(rv));
- }
-
- printf("Input new prefix length (x:skip) :\n");
- rv = scanf("%d", &prefix_len);
- if (rv > 0) {
- if (prefix_len == 'x')
- rv = WIFI_MANAGER_ERROR_NONE;
- else
- rv = wifi_manager_ap_set_prefix_length(ap, address_type, prefix_len);
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set subnet mask[%s]\n",
- __test_convert_error_to_string(rv));
- }
-
- 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_ap_set_gateway_address(ap, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_gateway_address(ap, address_type, ip_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set gateway address[%s]\n",
- __test_convert_error_to_string(rv));
- }
-
- rv = test_get_user_int("Input DNS config type (0:STATIC, 1:DYNAMIC)"
- "- (Enter for skip) : ", &dns_type);
- if (rv == false) {
- printf("Invalid input!!\n");
- g_free(ap_name);
- return false;
- }
- switch (dns_type) {
- case 0:
- rv = wifi_manager_ap_set_dns_config_type(ap,
- 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_ap_set_dns_address(ap,
- 1, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_dns_address(ap,
- 1, address_type, ip_addr);
- break;
- }
- }
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- g_free(ap_name);
- return false;
- }
-
- 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_ap_set_dns_address(ap,
- 2, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_dns_address(ap,
- 2, address_type, ip_addr);
- break;
- }
- }
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- g_free(ap_name);
- return false;
- }
- }
- break;
- case 1:
- rv = wifi_manager_ap_set_dns_config_type(ap,
- address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- g_free(ap_name);
- return false;
- }
- break;
- }
- }
-
- rv = wifi_manager_update_ap(wifi, ap);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to update ap info[%s]\n",
- __test_convert_error_to_string(rv));
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_found_change_proxy_method_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv, address_type;
- char *ap_name;
- char *ap_name_part = (char*)user_data;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- wifi_manager_proxy_type_e type;
- char proxy_addr[65];
- int method;
-
- printf("Input new method type (1:direct, 2:manual, 3:auto) :\n");
- rv = scanf(" %9d", &method);
- if (rv <= 0) {
- g_free(ap_name);
- return false;
- }
-
- rv = test_get_user_int("Input Address type to get"
- "(0:IPV4, 1:IPV6):", &address_type);
-
- if (rv == false || (address_type != 0 && address_type != 1)) {
- printf("Invalid input!!\n");
- g_free(ap_name);
- return false;
- }
-
- switch (method) {
- case 1:
- type = WIFI_MANAGER_PROXY_TYPE_DIRECT;
- break;
- case 2:
- type = WIFI_MANAGER_PROXY_TYPE_MANUAL;
- break;
- case 3:
- type = WIFI_MANAGER_PROXY_TYPE_AUTO;
- break;
- default:
- printf("Invalid input!\n");
- g_free(ap_name);
- return false;
- }
-
- rv = wifi_manager_ap_set_proxy_type(ap, type);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set proxy method type[%s]\n", __test_convert_error_to_string(rv));
-
- printf("Input new proxy address (x:skip, 0:clear) :\n");
- rv = scanf("%64s", proxy_addr);
-
- if (rv > 0) {
- switch (proxy_addr[0]) {
- case 'x':
- rv = WIFI_MANAGER_ERROR_NONE;
- break;
- case '0':
- rv = wifi_manager_ap_set_proxy_address(ap, address_type, NULL);
- break;
- default:
- rv = wifi_manager_ap_set_proxy_address(ap, address_type, proxy_addr);
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to set proxy address[%s]\n", __test_convert_error_to_string(rv));
- }
-
- rv = wifi_manager_update_ap(wifi, ap);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to update ap info[%s]\n",
- __test_convert_error_to_string(rv));
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool __test_ipv6_address_callback(char *ipv6_address, void *user_data)
-{
- printf("IPv6 address: %s\n", ipv6_address);
- return true;
-}
-
-static int __test_convert_byte_to_txt(const unsigned char *src, char **dst, int src_len)
-{
- int dst_length = 0;
- int i = 0;
- char *buf = NULL;
-
- if (src_len <= 0) {
- printf("Invalid source length\n");
- return -1;
- }
-
- *dst = (char *)malloc((2*src_len)+1);
- if (!(*dst)) {
- printf("failed to allocate memory to buffer\n");
- return -1;
- }
-
- buf = (*dst);
-
- for (i = 0; i < src_len; i++) {
- snprintf(buf, 3, "%02x", src[i]);
- buf += 2;
- dst_length += 2;
- }
-
- return dst_length;
-}
-
-static bool __test_vendor_specific_callback(unsigned char *vsie_bytes, int vsie_len, void *user_data)
-{
- if (!vsie_bytes)
- return false;
-
- char *vsie = NULL;
- int buf_len = __test_convert_byte_to_txt(vsie_bytes, &vsie, vsie_len);
- if (buf_len > 0)
- printf("vsie_len: %d, vsie: %s\n", vsie_len, vsie);
-
- if (vsie)
- free(vsie);
-
- return true;
-}
-
-static bool __test_found_bssid_list_callback(const char *bssid, int rssi, int freq, void *user_data)
-{
- printf("-> BSSID : %s, RSSI : %d, Frequency : %d\n", bssid, rssi, freq);
- return true;
-}
-
-static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user_data)
-{
- int rv, address_type = 0;
- char *ap_name;
- char *str_value;
- int int_value;
- wifi_manager_connection_state_e conn_state;
- wifi_manager_ip_config_type_e ip_type;
- wifi_manager_proxy_type_e proxy_type;
- wifi_manager_security_type_e sec_type;
- wifi_manager_encryption_type_e enc_type;
- wifi_manager_eap_type_e eap_type;
- wifi_manager_eap_auth_type_e eap_auth_type;
- wifi_manager_dns_config_type_e dns_type;
- bool bool_value;
- char *ap_name_part = (char*)user_data;
- wifi_manager_disconnect_reason_e disconnect_reason;
- wifi_manager_assoc_status_code_e status_code;
- wifi_manager_rssi_level_e rssi_level;
- bool is_hidden;
- wifi_manager_connection_mode_e mode;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
-
- printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
- if (__test_compare_ap_name(ap_name, ap_name_part)) {
- /* Basic info */
- printf("ESSID : %s\n", ap_name);
-
- if (wifi_manager_ap_get_bssid(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("BSSID : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get BSSID\n");
-
- if (wifi_manager_foreach_found_bssid(ap, __test_found_bssid_list_callback, NULL) != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get BSSID list data\n");
-
- if (wifi_manager_ap_get_rssi(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("RSSI : %d\n", int_value);
- else
- printf("Fail to get RSSI\n");
-
- if (wifi_manager_ap_get_rssi_level(ap, &rssi_level) == WIFI_MANAGER_ERROR_NONE)
- printf("RSSI level : %d\n", rssi_level);
- else
- printf("Fail to get RSSI level\n");
-
- if (wifi_manager_ap_get_connection_mode(ap, &mode) == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi operation mode: %d\n", mode);
- else
- printf("Fail to get operation mode\n");
-
- if (wifi_manager_ap_get_frequency(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Frequency : %d\n", int_value);
- else
- printf("Fail to get Frequency\n");
-
- if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_callback, NULL)
- != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get vsie\n");
-
- if (wifi_manager_ap_get_max_speed(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Max speed : %d\n", int_value);
- else
- printf("Fail to get Max speed\n");
-
- if (wifi_manager_ap_is_favorite(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Favorite : %s\n", bool_value ? "TRUE" : "FALSE");
- else
- printf("Fail to get Favorite\n");
-
- if (wifi_manager_ap_is_hidden(ap, &is_hidden) == WIFI_MANAGER_ERROR_NONE)
- printf("Hidden Status : %s\n", is_hidden ? "TRUE" : "FALSE");
- else
- printf("Fail to get hidden status\n");
-
- if (wifi_manager_ap_get_disconnect_reason(ap, &disconnect_reason)
- == WIFI_MANAGER_ERROR_NONE)
- printf("Disconnect reason : %d\n", disconnect_reason);
- else
- printf("Fail to get disconnect reason\n");
-
- if (wifi_manager_ap_get_assoc_status_code(ap, &status_code)
- == WIFI_MANAGER_ERROR_NONE)
- printf("Association Status Code : %d\n", status_code);
- else
- printf("Fail to get association status code\n");
-
- if (wifi_manager_ap_get_error_state(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("error state of AP : %s\n", __test_convert_error_to_string(int_value));
- else
- printf("Fail to get error state of AP\n");
-
- /* Network info */
- if (wifi_manager_ap_get_connection_state(ap, &conn_state) == WIFI_MANAGER_ERROR_NONE)
- printf("Connection State : %d\n", conn_state);
- else
- printf("Fail to get Connection State\n");
-
- rv = test_get_user_int("Input Address type to get"
- "(0:IPV4, 1:IPV6):", &address_type);
-
- if (rv == false || (address_type != 0 && address_type != 1)) {
- printf("Invalid input!!\n");
- g_free(ap_name);
- return false;
- }
-
- if (wifi_manager_ap_get_ip_config_type(ap, address_type, &ip_type) == WIFI_MANAGER_ERROR_NONE)
- printf("IP config type : %d\n", ip_type);
- else
- printf("Fail to get IP config type\n");
-
- if (wifi_manager_ap_get_ip_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("IP : %s\n", str_value);
- g_free(str_value);
- } else {
- printf("Fail to get IP : %s\n", str_value);
- g_free(str_value);
- }
-
- if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
- if (wifi_manager_ap_foreach_ipv6_address(ap, __test_ipv6_address_callback, NULL)
- != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get multiple IPv6 address\n");
- }
-
- if (wifi_manager_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("Subnet mask : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get Subnet mask\n");
-
- if (wifi_manager_ap_get_prefix_length(ap, address_type, &int_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Prefix length : %d\n", int_value);
- else
- printf("Fail to get Subnet mask\n");
-
- if (wifi_manager_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("Gateway : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get Gateway\n");
-
- if (address_type == 0) {
- if (wifi_manager_ap_get_dhcp_server_address(ap, address_type, &str_value) ==
- WIFI_MANAGER_ERROR_NONE) {
- printf("DHCP Server : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get DHCP Server\n");
- if (wifi_manager_ap_get_dhcp_lease_duration(ap, address_type, &int_value) ==
- WIFI_MANAGER_ERROR_NONE) {
- printf("DHCP Lease duration : %d\n", int_value);
- } else
- printf("Fail to get DHCP lease duration\n");
- }
-
- if (wifi_manager_ap_get_proxy_type(ap, &proxy_type) == WIFI_MANAGER_ERROR_NONE)
- printf("Proxy type : %d\n", proxy_type);
- else
- printf("Fail to get Proxy type\n");
-
- if (wifi_manager_ap_get_proxy_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("Proxy : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get Proxy\n");
-
- if (wifi_manager_ap_get_dns_config_type(ap, address_type, &dns_type) == WIFI_MANAGER_ERROR_NONE) {
- if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC)
- printf("DNS config type : STATIC\n");
- else if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC)
- printf("DNS config type : DYNAMIC\n");
- else
- printf("DNS config type : %d\n", dns_type);
- } else
- printf("Fail to get DNS config type\n");
-
- if (wifi_manager_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("DNS1 : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get DNS1\n");
-
- if (wifi_manager_ap_get_dns_address(ap, 2, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("DNS2 : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get DNS2\n");
-
- /* Security info */
- if (wifi_manager_ap_get_security_type(ap, &sec_type) == WIFI_MANAGER_ERROR_NONE)
- printf("Security type : %d\n", sec_type);
- else
- printf("Fail to get Security type\n");
-
- if (wifi_manager_ap_get_encryption_type(ap, &enc_type) == WIFI_MANAGER_ERROR_NONE)
- printf("Encryption type : %d\n", enc_type);
- else
- printf("Fail to get Encryption type\n");
-
- if (wifi_manager_ap_is_passphrase_required(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Passphrase required : %s\n", bool_value ? "TRUE" : "FALSE");
- else
- printf("Fail to get Passphrase required\n");
-
- if (wifi_manager_ap_is_wps_supported(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
- printf("WPS supported : %s\n", bool_value ? "TRUE" : "FALSE");
- else
- printf("Fail to get WPS supported\n");
-
- if (wifi_manager_ap_is_passpoint(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
- printf("Passpoint enabled : %s\n", bool_value ? "TRUE" : "FALSE");
- else
- printf("Fail to get passpoint state\n");
-
- if (wifi_manager_ap_get_countrycode(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- if (str_value) {
- printf("Country Code : %s\n", str_value);
- free(str_value);
- } else
- printf("Country code is NULL\n");
- } else
- printf("Fail to get Country code\n");
-
- if (sec_type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
- g_free(ap_name);
- return false;
- }
-
- /* EAP info */
- if (wifi_manager_ap_get_eap_type(ap, &eap_type) == WIFI_MANAGER_ERROR_NONE)
- printf("EAP type : %d\n", eap_type);
- else
- printf("Fail to get EAP type\n");
-
- if (wifi_manager_ap_get_eap_auth_type(ap, &eap_auth_type) == WIFI_MANAGER_ERROR_NONE)
- printf("EAP auth type : %d\n", eap_auth_type);
- else
- printf("Fail to get EAP auth type\n");
-
- if (wifi_manager_ap_get_eap_passphrase(ap, &str_value, &bool_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("EAP user name : %s\n", str_value);
- printf("EAP is password setted : %s\n", bool_value ? "TRUE" : "FALSE");
- g_free(str_value);
- } else
- printf("Fail to get EAP passphrase(user name/password)\n");
-
- if (wifi_manager_ap_get_eap_ca_cert_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("EAP ca cert file : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get EAP ca cert file\n");
-
- if (wifi_manager_ap_get_eap_client_cert_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("EAP client cert file : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get EAP client cert file\n");
-
- if (wifi_manager_ap_get_eap_private_key_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
- printf("EAP private key file : %s\n", str_value);
- g_free(str_value);
- } else
- printf("Fail to get EAP private key file\n");
-
- g_free(ap_name);
- return false;
- }
-
- g_free(ap_name);
- return true;
-}
-
-static bool _test_config_list_cb(const wifi_manager_config_h config, void *user_data)
-{
- gchar *name = NULL;
- wifi_manager_security_type_e security_type;
-
- wifi_manager_config_get_name(config, &name);
- wifi_manager_config_get_security_type(config, &security_type);
-
- printf("Name[%s] ", name);
- printf("Security type[%d] ", security_type);
- if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
- wifi_manager_eap_type_e eap_type;
- wifi_manager_eap_auth_type_e eap_auth_type;
- wifi_manager_config_get_eap_type(config, &eap_type);
- printf("Eap type[%d] ", eap_type);
- wifi_manager_config_get_eap_auth_type(config, &eap_auth_type);
- printf("Eap auth type[%d]", eap_auth_type);
- }
- printf("\n");
-
- g_free(name);
-
- return true;
-}
-
-struct _wifi_conf {
- char name[33];
- int type;
-};
-static bool _test_config_list_cb_for_remove(const wifi_manager_config_h config, void *user_data)
-{
-
- struct _wifi_conf *c = (struct _wifi_conf *)user_data;
- gchar *name = NULL;
- wifi_manager_security_type_e security_type;
-
- wifi_manager_config_get_name(config, &name);
- wifi_manager_config_get_security_type(config, &security_type);
-
- if (__test_compare_ap_name(name, c->name) && security_type == c->type) {
- int rv = wifi_manager_config_remove(wifi, config);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to remove configurations [%s]\n", __test_convert_error_to_string(rv));
- else
- printf("Success to remove configuration [%s]\n", name);
- g_free(name);
- return false;
- }
-
- g_free(name);
-
- return true;
-}
-
-static bool __test_found_specific_ap_callback(wifi_manager_ap_h ap, void *user_data)
-{
- printf("Found specific ap Completed\n");
-
- int rv;
- char *ap_name = NULL;
- wifi_manager_security_type_e security_type = WIFI_MANAGER_SECURITY_TYPE_NONE;
-
- rv = wifi_manager_ap_get_essid(ap, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
- return false;
- }
- printf("[AP name] : %s\n", ap_name);
-
- rv = wifi_manager_ap_get_security_type(ap, &security_type);
- if (rv == WIFI_MANAGER_ERROR_NONE)
- printf("[Security type] : %d\n", security_type);
- else {
- printf("Fail to get Security type\n");
- g_free(ap_name);
- return false;
- }
-
- switch (security_type) {
- case WIFI_MANAGER_SECURITY_TYPE_WEP:
- case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
- case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
- case WIFI_MANAGER_SECURITY_TYPE_SAE:
- {
- char passphrase[100];
- printf("Input passphrase for %s : ", ap_name);
- rv = scanf(" %99s", passphrase);
-
- rv = wifi_manager_ap_set_passphrase(ap, passphrase);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
- }
- break;
- case WIFI_MANAGER_SECURITY_TYPE_EAP:
- {
- char input_str1[100];
- printf("Input user name for %s : ", ap_name);
- rv = scanf(" %99s", input_str1);
-
- char input_str2[100];
- printf("Input password for %s : ", ap_name);
- rv = scanf("%99s", input_str2);
-
- rv = wifi_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- char *inputed_name = NULL;
- bool is_pass_set;
- rv = wifi_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- return false;
- }
-
- printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
- g_free(inputed_name);
- }
- break;
- case WIFI_MANAGER_SECURITY_TYPE_NONE:
- case WIFI_MANAGER_SECURITY_TYPE_OWE:
- default:
- break;
- }
-
- rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
- else
- printf("Success to connection request [%s]\n", ap_name);
-
- g_free(ap_name);
- return true;
-}
-
-static void __test_scan_specific_ap_callback(wifi_manager_error_e error_code, void* user_data)
-{
- int rv;
-
- printf("Specific scan Completed from scan request, error code : %s\n",
- __test_convert_error_to_string(error_code));
-
- if (error_code != WIFI_MANAGER_ERROR_NONE)
- return;
-
- rv = wifi_manager_foreach_found_specific_ap(wifi, __test_found_specific_ap_callback, user_data);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get specific AP(can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return;
- }
-}
-
-static void __test_multi_scan_callback(wifi_manager_error_e error_code, void* user_data)
-{
- printf("Multi scan Completed, error code : %s\n",
- __test_convert_error_to_string(error_code));
-}
-
-int test_wifi_manager_init(void)
-{
- int rv = wifi_manager_initialize(&wifi);
-
- if (rv == WIFI_MANAGER_ERROR_NONE) {
- wifi_manager_set_device_state_changed_cb(wifi, __test_device_state_callback, "1");
- wifi_manager_set_scan_state_changed_cb(wifi, __test_scan_changed_callback, "1");
- wifi_manager_set_background_scan_cb(wifi, __test_bg_scan_completed_callback, "1");
- wifi_manager_set_ip_conflict_cb(wifi, __test_ip_conflict_callback, "1");
- wifi_manager_set_connection_state_changed_cb(wifi, __test_connection_state_callback, "1");
- wifi_manager_set_rssi_level_changed_cb(wifi, __test_rssi_level_callback, "1");
- wifi_manager_tdls_set_state_changed_cb(wifi, __test_tdls_state_callback, "1");
- wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "1");
- wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "1");
-
- } else {
- printf("[1] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- rv = wifi_manager_initialize(&wifi2);
-
- if (rv == WIFI_MANAGER_ERROR_NONE) {
- wifi_manager_set_device_state_changed_cb(wifi2, __test_device_state_callback, "2");
- wifi_manager_set_background_scan_cb(wifi2, __test_bg_scan_completed_callback, "2");
- wifi_manager_set_connection_state_changed_cb(wifi2, __test_connection_state_callback, "2");
- wifi_manager_set_rssi_level_changed_cb(wifi2, __test_rssi_level_callback, "2");
- wifi_manager_tdls_set_state_changed_cb(wifi2, __test_tdls_state_callback, "2");
- wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "2");
- wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "2");
- } else {
- printf("[2] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Wifi init succeeded\n");
- return 1;
-}
-
-int test_wifi_manager_deinit(void)
-{
- int rv = wifi_manager_deinitialize(wifi);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[1] Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- rv = wifi_manager_deinitialize(wifi2);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[2] Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Wifi deinit succeeded\n");
- return 1;
-}
-
-int test_wifi_manager_activate(void)
-{
- int rv = 0;
-
- rv = wifi_manager_activate(wifi, __test_activated_callback, NULL);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to activate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to activate Wi-Fi device\n");
-
- return 1;
-}
-
-int test_wifi_manager_deactivate(void)
-{
- int rv = 0;
-
- rv = wifi_manager_deactivate(wifi, __test_deactivated_callback, NULL);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to deactivate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to deactivate Wi-Fi device\n");
-
- return 1;
-}
-
-int test_wifi_manager_is_activated(void)
-{
- int rv = 0;
- bool state = false;
-
- rv = wifi_manager_is_activated(wifi, &state);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get Wi-Fi device state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to get Wi-Fi device state : %s\n", (state) ? "TRUE" : "FALSE");
-
- return 1;
-}
-
-int test_wifi_manager_get_connection_state(void)
-{
- int rv = 0;
- wifi_manager_connection_state_e connection_state;
-
- rv = wifi_manager_get_connection_state(wifi, &connection_state);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get connection state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to get connection state : ");
- switch (connection_state) {
- case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
- printf("Association\n");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
- printf("Connected\n");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
- printf("Configuration\n");
- break;
- case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
- printf("Disconnected\n");
- break;
- default:
- printf("Unknown\n");
- }
-
- return 1;
-}
-
-int test_wifi_manager_get_mac_address(void)
-{
- int rv = 0;
- char *mac_addr = NULL;
-
- rv = wifi_manager_get_mac_address(wifi, &mac_addr);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get MAC address [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("MAC address : %s\n", mac_addr);
- free(mac_addr);
-
- return 1;
-}
-
-int test_wifi_manager_get_interface_name(void)
-{
- int rv = 0;
- char *if_name = NULL;
-
- rv = wifi_manager_get_network_interface_name(wifi, &if_name);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get Interface name [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Interface name : %s\n", if_name);
- free(if_name);
-
- return 1;
-}
-
-int test_wifi_manager_scan(void)
-{
- int rv = 0;
-
- rv = wifi_manager_scan(wifi, __test_scan_request_callback, NULL);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Scan request succeeded\n");
-
- return 1;
-}
-
-int test_wifi_manager_get_connected_ap(void)
-{
- int rv = 0;
- char *ap_name = NULL;
- wifi_manager_ap_h ap_h;
-
- rv = wifi_manager_get_connected_ap(wifi, &ap_h);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
- wifi_manager_ap_destroy(ap_h);
- return -1;
- }
-
- printf("Connected AP : %s\n", ap_name);
- g_free(ap_name);
- wifi_manager_ap_destroy(ap_h);
-
- return 1;
-}
-
-int test_wifi_manager_foreach_found_ap(void)
-{
- int rv = 0;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_ap_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP list [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Get AP list finished\n");
-
- return 1;
-}
-
-int test_wifi_manager_connect(void)
-{
- int rv = 0;
- struct _ap_data data;
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to connect : ");
- rv = scanf(" %32[^\n]s", data.ap_name);
- data.is_found = false;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_ap_callback, (void*)&data);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- if (!data.is_found) {
- printf("%s is not found\n", data.ap_name);
- return -1;
- }
- printf("Connection step finished\n");
- return 1;
-}
-
-int test_wifi_manager_set_ip_conflict_detect_enable()
-{
- int rv = 0;
- int choice;
- bool state = false;
-
- printf("Input '1'(enable)/'0'(disable) for ip conflict detection : ");
- rv = scanf(" %d", &choice);
- if (choice == 1)
- state = true;
- else if (choice == 0)
- state = false;
- else
- return -1;
-
- rv = wifi_manager_set_ip_conflict_detect_enable(wifi, state);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set ip conflict detection state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Successfully set the ip conflict detection !\n");
- return 1;
-}
-
-int test_wifi_manager_ip_conflict_detect_is_enabled()
-{
- int rv = 0;
- bool state = false;
-
- rv = wifi_manager_ip_conflict_detect_is_enabled(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get ip conflict detection state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("IP conflict detection is %s\n", state ? "enabled" : "disabled");
- printf("Successfully get the ip conflict detection !\n");
- return 1;
-}
-
-int test_wifi_manager_get_ip_conflict_state()
-{
- int rv = 0;
- wifi_manager_ip_conflict_state_e state;
-
- rv = wifi_manager_get_ip_conflict_state(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get ip conflict state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- switch (state) {
- case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED:
- printf("IP Conflict present\n");
- break;
- case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED:
- printf("IP Conflict absent\n");
- break;
- case WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN:
- printf("IP Conflict state is unknown\n");
- break;
- default:
- printf("Unhandled state\n");
- break;
- }
-
- printf("Successfully get the ip conflict state!\n");
- return 1;
-}
-
-int test_wifi_manager_get_ip_conflict_period()
-{
- int rv = 0;
- unsigned int initial_time;
-
- rv = wifi_manager_get_ip_conflict_period(wifi, &initial_time);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get ip conflict time period [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Initial time = %u seconds!\n", initial_time);
- printf("Successfully get the ip conflict detect period!\n");
- return 1;
-}
-
-int test_wifi_manager_set_ip_conflict_period()
-{
- int rv = 0;
- int initial_interval;
-
- printf("Enter initial interval for ARP ping\n");
- rv = scanf(" %d", &initial_interval);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_set_ip_conflict_period(wifi, initial_interval);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set ip conflict detection period [%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Successfully set the ip conflict detect period!\n");
- return 1;
-}
-
-int test_wifi_manager_connect_specific_ap(void)
-{
- int rv;
- char ap_name[33];
-
- printf("Input a part of specific AP name to connect : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_scan_specific_ap(wifi, ap_name, __test_scan_specific_ap_callback, NULL);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Scan specific AP request succeeded\n");
- return 1;
-}
-
-int test_wifi_manager_disconnect(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to disconnect : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_disconnect_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to disconnect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Disconnection step finished\n");
- return 1;
-}
-
-int test_wifi_manager_connect_wps(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to connect by wps : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_wps_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Connection step finished\n");
- return 1;
-}
-
-int test_wifi_manager_forget_ap(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to forget : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to forget (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Forget AP finished\n");
-
- return 1;
-}
-
-int test_wifi_manager_connect_eap_ap(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to connect : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_eap_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Connection step finished\n");
- return 1;
-}
-
-int test_wifi_manager_set_ip_method(void)
-{
- int rv;
- char ap_name[33];
- bool state;
-
- rv = wifi_manager_is_activated(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
- return -1;
-
- printf("Input a part of AP name to change IP method : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_change_ip_method_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("IP method changing finished\n");
- return 1;
-}
-
-int test_wifi_manager_set_proxy_method(void)
-{
- int rv;
- char ap_name[33];
- bool state;
-
- rv = wifi_manager_is_activated(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
- return -1;
-
- printf("Input a part of AP name to change Proxy method : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_change_proxy_method_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Proxy method changing finished\n");
- return 1;
-}
-
-int test_wifi_manager_get_ap_info(void)
-{
- int rv;
- char ap_name[33];
- bool state;
-
- rv = wifi_manager_is_activated(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
- return -1;
-
- printf("Input a part of AP name to get detailed info : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_print_ap_info_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get AP info (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("AP info printing finished\n");
- return 1;
-}
-
-int test_wifi_manager_config_load_configuration(void)
-{
- int rv;
-
- rv = wifi_manager_config_foreach_configuration(wifi, _test_config_list_cb, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- return 1;
-}
-
-int test_wifi_manager_config_save(void)
-{
- int rv;
- char name[33] = { 0, };
- char passphrase[100] = { 0, };
- int type = 0;
- char proxy[100] = { 0, };
- int hidden = 0;
- int address_type = 0;
- char ip_addr[40] = { 0, };
- int prefix_len;
- wifi_manager_config_h config;
- int ip_update = 0;
-
- printf("Input AP configuration\n");
- printf("Name : ");
- rv = scanf(" %32[^\n]s", name);
- if (rv <= 0)
- return -1;
-
- printf("Passphrase : ");
- rv = scanf(" %99s", passphrase);
- if (rv <= 0)
- return -1;
-
- printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4)) : ");
- rv = scanf("%d", &type);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_config_create(wifi, name, passphrase, type, &config);
- 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;
- }
- }
-
- if (address_type == 0) {
- 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;
- }
- }
- } else {
- printf("Input new prefix length (x:skip) :\n");
- rv = scanf("%d", &prefix_len);
- if (rv > 0) {
- if (prefix_len == 'x')
- rv = WIFI_MANAGER_ERROR_NONE;
- else
- rv = wifi_manager_config_set_prefix_length(config, address_type, prefix_len);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set prefix length[%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);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_int("Hidden(1:Hidden) - (Enter for skip): ", &hidden)) {
- if (hidden == 1)
- rv = wifi_manager_config_set_hidden_ap_property(config, TRUE);
- else
- rv = wifi_manager_config_set_hidden_ap_property(config, FALSE);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
- char anonymous[100] = { 0, };
- char ca_cert[100] = { 0, };
- char private_key[100] = { 0, };
- char private_key_password[100] = { 0, };
- char client_cert[100] = { 0, };
- char eap_identity[100] = { 0, };
- int eap_type;
- int eap_auth_type;
- char subject_match[100] = { 0, };
-
- if (test_get_user_string("EAP Anonymous Identity - (Enter for skip): ", anonymous, 99)) {
- rv = wifi_manager_config_set_eap_anonymous_identity(config, anonymous);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_string("EAP ca cert file - (Enter for skip): ", ca_cert, 99)) {
- rv = wifi_manager_config_set_eap_ca_cert_file(config, ca_cert);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_string("EAP private key - (Enter for skip): ", private_key, 99) &&
- test_get_user_string("EAP client cert file - (Enter for skip): ", client_cert, 99)) {
- rv = wifi_manager_config_set_eap_client_cert_file(config, private_key, client_cert);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_string("EAP identity - (Enter for skip): ", eap_identity, 99)) {
- rv = wifi_manager_config_set_eap_identity(config, eap_identity);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_int("EAP type (PEAP(0), TLS(1), TTLS(2), SIM(3), AKA(4)) - (Enter for skip): ", &eap_type)) {
- rv = wifi_manager_config_set_eap_type(config, eap_type);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- if (eap_type == 1) {
- if (test_get_user_string("EAP private key file - ", private_key, 99) &&
- test_get_user_string("EAP private-key password - ", private_key_password, 99)) {
- rv = wifi_manager_config_set_eap_private_key_info(config, private_key, private_key_password);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
- }
- }
-
- if (test_get_user_int("EAP auth type (None(0), PAP(1), MSCHAP(2), MSCHAPv2(3), GTC(4), MD5(5)) - (Enter for skip): ", &eap_auth_type)) {
- rv = wifi_manager_config_set_eap_auth_type(config, eap_auth_type);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
-
- if (test_get_user_string("EAP subject match - (Enter for skip): ", subject_match, 99)) {
- rv = wifi_manager_config_set_eap_subject_match(config, subject_match);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
- }
- }
-
- rv = wifi_manager_config_save(wifi, config);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- rv = wifi_manager_config_destroy(config);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- return -1;
-
- return 1;
-}
-
-int test_wifi_manager_config_remove(void)
-{
- int rv;
- struct _wifi_conf c;
-
- printf("Input AP configuration\n");
- printf("Name : ");
- rv = scanf(" %32[^\n]s", c.name);
- if (rv <= 0)
- return -1;
-
- printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
- rv = scanf(" %d", &c.type);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_config_foreach_configuration(wifi, _test_config_list_cb_for_remove, &c);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get configurations [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_tdls_discover()
-{
- int rv = 0;
-
- char peer_mac[MAC_ADDR_LEN + 1];
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
-
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
-
- rv = wifi_manager_tdls_start_discovery(wifi, peer_mac);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_tdls_discover() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-}
-
-int test_wifi_manager_tdls_connect()
-{
- int rv = 0;
-
- char peer_mac[MAC_ADDR_LEN + 1];
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
-
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
-
- rv = wifi_manager_tdls_connect(wifi, peer_mac);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_tdls_connect() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-
-}
-
-int test_wifi_manager_tdls_get_connected_peer(void)
-{
- int rv = 0;
- char *mac_addr = NULL;
-
- rv = wifi_manager_tdls_get_connected_peer(wifi, &mac_addr);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("wifi_manager_tdls_get_connected_peer() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Peer Mac address is [%s]\n", mac_addr);
- g_free(mac_addr);
- return 1;
-}
-
-int test_wifi_manager_tdls_disconnect(void)
-{
- int rv = 0;
-
- char peer_mac[MAC_ADDR_LEN + 1];
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
-
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
-
- rv = wifi_manager_tdls_disconnect(wifi, peer_mac);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_tdls_disconnect() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-}
-int test_wifi_manager_tdls_enable_channel_switch(void)
-{
- int rv = 0;
- char peer_mac[MAC_ADDR_LEN + 1];
- int freq;
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
- printf("Enter Peer Frequency:\n");
- rv = scanf("%9d", &freq);
- if (rv <= 0) {
- printf("Invalid input!\n");
- return -1;
- }
- rv = wifi_manager_tdls_enable_channel_switching(wifi, peer_mac, freq);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_manager_tdls_channel_switch() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-}
-int test_wifi_manager_tdls_disable_channel_switch(void)
-{
- int rv = 0;
- char peer_mac[MAC_ADDR_LEN + 1];
- printf("Enter Mac_address: ");
- if (scanf(" %17s", peer_mac) < 1)
- return -1;
- if (strlen(peer_mac) < MAC_ADDR_LEN) {
- printf("Wrong Mac_address\n");
- return -1;
- }
- rv = wifi_manager_tdls_disable_channel_switching(wifi, peer_mac);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("test_wifi_manager_tdls_cancle_channel_switch() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- return 1;
-}
-int test_wifi_manager_get_module_state(void)
-{
- int rv = 0;
- wifi_manager_module_state_e module_state;
-
- rv = wifi_manager_get_module_state(wifi, &module_state);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get wifi module state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Success to get WiFI Module state : ");
- switch (module_state) {
- case WIFI_MANAGER_MODULE_STATE_ATTACHED:
- printf("Wi-Fi Module Attached \n");
- break;
- case WIFI_MANAGER_MODULE_STATE_DETACHED:
- printf("Wi-Fi Module Detached\n");
- break;
- default:
- printf("Unknown\n");
- }
-
- return 1;
-}
-
-
-int test_wifi_manager_connect_hidden_ap(void)
-{
- int rv = 0;
- char ap_name[33];
- char passphrase[65];
- bool state = false;
- int sec_type;
-
- rv = wifi_manager_is_activated(wifi, &state);
- if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
- return -1;
-
- printf("Input hidden AP name to connect : ");
- rv = scanf(" %32[^\n]s", ap_name);
- printf("Input Security Type :\n");
- printf("0 -> WIFI_SECURITY_TYPE_NONE\n");
- printf("1 -> WIFI_SECURITY_TYPE_WEP\n");
- printf("2 -> WIFI_SECURITY_TYPE_WPA_PSK/WIFI_SECURITY_TYPE_WPA2_PSK\n");
-
- rv = scanf(" %d", &sec_type);
- if (sec_type == 1 || sec_type == 2) {
- printf("Input hidden AP passphrase : ");
- rv = scanf("%64s", passphrase);
- }
-
- rv = wifi_manager_connect_hidden_ap(wifi, ap_name, sec_type, passphrase,
- __test_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to connect to hidden AP [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Hidden Connection step finished\n");
- return 1;
-}
-
-static void __test_wifi_manager_wps_pbc_connected_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi WPS PBC Connection Succeeded\n");
- else
- printf("Wi-Fi WPS PBC Connection Failed! error : %s\n",
- __test_convert_error_to_string(result));
-}
-
-static void __test_wifi_manager_wps_pin_connected_callback(wifi_manager_error_e result, void* user_data)
-{
- if (result == WIFI_MANAGER_ERROR_NONE)
- printf("Wi-Fi WPS PIN Connection Succeeded\n");
- else
- printf("Wi-Fi WPS PIN Connection Failed! error : %s\n",
- __test_convert_error_to_string(result));
-}
-
-int test_wifi_manager_connect_wps_pbc_without_ssid(void)
-{
- int rv;
- rv = wifi_manager_connect_by_wps_pbc_without_ssid(wifi, __test_wifi_manager_wps_pbc_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to WPS connection request : %s\n", __test_convert_error_to_string(rv));
- else
- printf("Success to WPS connection request \n");
- return 1;
-}
-
-int test_wifi_manager_connect_wps_pin_without_ssid(void)
-{
- int rv;
- char pin[9];
-
- printf("Input pin to wps pin connect : ");
-
- rv = scanf(" %8s", pin);
- if (rv <= 0)
- return -1;
-
- if ((strlen(pin) != 4) &&
- (strlen(pin) != 8)) {
- printf("Wrong pin number (4 or 8)\n");
- return -1;
- }
-
- rv = wifi_manager_connect_by_wps_pin_without_ssid(wifi, pin, __test_wifi_manager_wps_pin_connected_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to WPS connection request : %s\n", __test_convert_error_to_string(rv));
- else
- printf("Success to WPS connection request \n");
- return 1;
-}
-
-int test_wifi_manager_cancel_wps(void)
-{
- int rv;
- rv = wifi_manager_cancel_wps(wifi);
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to WPS cancel request : %s\n", __test_convert_error_to_string(rv));
- else
- printf("Success to WPS cancel request \n");
- return 1;
-}
-
-int test_wifi_manager_get_wps_generated_pin(void)
-{
- int rv = 0;
- char *wps_pin = NULL;
-
- rv = wifi_manager_get_wps_generated_pin(wifi, &wps_pin);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("wifi_manager_get_wps_generated_pin() is failed [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Generaged pin number is [%s]\n", wps_pin);
- g_free(wps_pin);
- return 1;
-}
-
-int test_wifi_manager_forget_ap_async(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("Input a part of AP name to forget : ");
- rv = scanf(" %32[^\n]s", ap_name);
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_async_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to forget (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Forget AP async finished\n");
-
- return 1;
-}
-
-int test_wifi_manager_set_autoscan_state(void)
-{
- int autoscan = 0;
- int rv = 0;
-
- printf("Input enable/disable for autoscan (0:enable, 1:disable) :\n");
- rv = scanf(" %9d", &autoscan);
-
- if (rv <= 0) {
- printf("Invalid input!\n");
- return -1;
- }
-
- switch (autoscan) {
- case 0:
- rv = wifi_manager_set_autoscan(wifi, true);
- break;
-
- case 1:
- rv = wifi_manager_set_autoscan(wifi, false);
- break;
-
- default:
- printf("Invalid input!\n");
- return -1;
- }
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("failed to set autoscan [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_set_autoscan_mode(void)
-{
- int mode = 0;
- int rv = 0;
-
- printf("Input autoscan mode (0:exponential, 1:periodic) :\n");
- rv = scanf(" %9d", &mode);
-
- if (rv <= 0) {
- printf("Invalid input!\n");
- return -1;
- }
-
- rv = wifi_manager_set_autoscan_mode(wifi, mode);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("failed to set autoscan mode [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_get_autoscan_state(void)
-{
- int rv = 0;
- bool autoscan = FALSE;
-
- rv = wifi_manager_get_autoscan(wifi, &autoscan);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get auto scan state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Auto scan state (0:enable, 1:disable) : %d\n", autoscan);
- return 1;
-}
-
-int test_wifi_manager_get_autoscan_mode(void)
-{
- int rv = 0;
- wifi_manager_autoscan_mode_e autoscan_mode;
-
- rv = wifi_manager_get_autoscan_mode(wifi, &autoscan_mode);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get auto scan mode [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Auto Scan Mode (0:exponential, 1:periodic) : %d\n", autoscan_mode);
- return 1;
-}
-
-static bool __test_get_bssid_scan_list(wifi_manager_ap_h ap, void *user_data)
-{
- char *bssid;
- char *essid;
- int rssi;
-
- if (wifi_manager_ap_get_bssid(ap, &bssid) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get bssid for ap\n");
- return false;
- }
-
- if (wifi_manager_ap_get_essid(ap, &essid) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get essid for ap\n");
- g_free(bssid);
- return false;
- }
-
- if (wifi_manager_ap_get_rssi(ap, &rssi) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get rssi for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- printf("bssid : %s, essid : %s, rssi : %d\n",
- bssid, essid, rssi);
-
- g_free(bssid);
- g_free(essid);
- return true;
-}
-
-int test_wifi_manager_foreach_bssid_scan(void)
-{
- int rv;
-
- rv = wifi_manager_foreach_found_bssid_ap(wifi,
- __test_get_bssid_scan_list, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get wps scan list [%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_bssid_scan(void)
-{
- int rv = 0;
- rv = wifi_manager_bssid_scan(wifi, __test_bssid_scan_request_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to request bssid scan [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("BSSID Scan request succeeded\n");
- return 1;
-}
-
-static bool __test_get_netlink_scan_list(wifi_manager_ap_h ap, void *user_data)
-{
- char *bssid = NULL;
- char *essid = NULL;
- int freq;
- int rssi;
- wifi_manager_security_type_e sec_type;
- wifi_manager_encryption_type_e enc_type;
-
- if (wifi_manager_ap_get_bssid(ap, &bssid) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get bssid for ap\n");
- g_free(bssid);
- return false;
- }
-
-
- if (wifi_manager_ap_get_essid(ap, &essid) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get essid for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- if (wifi_manager_ap_get_frequency(ap, &freq) != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get Frequency\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- if (wifi_manager_ap_get_rssi(ap, &rssi) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get rssi for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- if (wifi_manager_ap_get_security_type(ap, &sec_type) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get security type for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- if (wifi_manager_ap_get_encryption_type(ap, &enc_type) != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get encryption type for ap\n");
- g_free(bssid);
- g_free(essid);
- return false;
- }
-
- printf("%s, %d, %d, %s\n", bssid, freq, rssi, essid);
- printf("Security type : ");
- switch (sec_type) {
- case WIFI_MANAGER_SECURITY_TYPE_NONE:
- printf("NONE, ");
- break;
- case WIFI_MANAGER_SECURITY_TYPE_WEP:
- printf("WEP, ");
- break;
- case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
- printf("WPAPSK, ");
- break;
- case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
- printf("WPA2PSK, ");
- break;
- case WIFI_MANAGER_SECURITY_TYPE_EAP:
- printf("EAP, ");
- break;
- default:
- break;
- }
- printf("Encryption type : ");
- switch (enc_type) {
- case WIFI_MANAGER_ENCRYPTION_TYPE_NONE:
- printf("NONE\n");
- break;
- case WIFI_MANAGER_ENCRYPTION_TYPE_WEP:
- printf("WEP\n");
- break;
- case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP:
- printf("TKIP\n");
- break;
- case WIFI_MANAGER_ENCRYPTION_TYPE_AES:
- printf("CCMP\n");
- break;
- case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED:
- printf("Mixed\n");
- break;
- default:
- break;
- }
-
- if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_callback, NULL) != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to get vsie\n");
-
- g_free(bssid);
- g_free(essid);
- return true;
-}
-
-int test_wifi_manager_foreach_netlink_scan(void)
-{
- int rv;
-
- rv = wifi_manager_foreach_found_netlink_scan_ap(wifi,
- __test_get_netlink_scan_list, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get netlink scan list [%s]\n",
- __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_netlink_scan(void)
-{
- int rv = 0, scan_type = -1, add_vsie = -1;
- int ret = 1;
- char ssid[32+1];
- char vsie[255];
- wifi_manager_netlink_scan_h netlink_scan = NULL;
-
- rv = wifi_manager_netlink_scan_create(wifi, &netlink_scan);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to create netlink scan handle [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Netlink Scan handle created [%p]\n", netlink_scan);
-
- rv = test_get_user_int("Input netlink scan type"
- "(0:Normal, 1:Specific AP):", &scan_type);
- if (rv == false || (scan_type != 0 && scan_type != 1)) {
- printf("Invalid input!!\n");
- ret = -1;
- goto out;
- }
-
- if (scan_type == 1) {
- int i, num;
- rv = test_get_user_int("Input number of ssid:", &num);
- if (rv == false || num <= 0) {
- printf("Invalid input!!\n");
- ret = -1;
- goto out;
- }
-
- for (i = 0; i < num; i++) {
- printf("Input ssid:\n");
- rv = scanf(" %32[^\n]s", ssid);
-
- rv = wifi_manager_netlink_scan_set_ssid(netlink_scan, ssid);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
- ret = -1;
- goto out;
- }
- }
- }
-
- rv = test_get_user_int("Add vsie option"
- "(0:No, 1:Yes):", &add_vsie);
- if (rv == false || (add_vsie != 0 && add_vsie != 1)) {
- printf("Invalid input!!\n");
- ret = -1;
- goto out;
- }
-
- if (add_vsie) {
- printf("Input vsie:\n");
- rv = scanf(" %250s", vsie);
-
- rv = wifi_manager_netlink_scan_set_vsie(netlink_scan, vsie);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set vsie [%s]", __test_convert_error_to_string(rv));
- ret = -1;
- goto out;
- }
- }
-
- rv = wifi_manager_netlink_scan(wifi, netlink_scan, __test_netlink_scan_request_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to request netlink scan [%s]\n", __test_convert_error_to_string(rv));
- ret = -1;
- goto out;
- }
-
- printf("netlink Scan request succeeded\n");
-
-out:
- rv = wifi_manager_netlink_scan_destroy(wifi, netlink_scan);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to destroy netlink scan handle [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return ret;
-}
-
-int test_wifi_manager_get_scan_state(void)
-{
- int rv = 0;
- wifi_manager_scan_state_e scan_state = -1;
-
- rv = wifi_manager_get_scan_state(wifi, &scan_state);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get scan state [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Scan state [%d]\n", scan_state);
-
- return 1;
-}
-
-int test_wifi_manager_add_vsie(void)
-{
- int rv = 0;
- char *vsie = NULL;
- unsigned int frame_id;
-
- printf("Input frame_id:\n");
- if (scanf(" %2u", &frame_id) < 1)
- return -1;
-
- printf("Input vsie:\n");
- if (scanf(" %100ms", &vsie) < 1)
- return -1;
-
- if (strlen(vsie) == 0)
- printf("invalid vsie !!\n");
- else
- printf("vsie: [%s]\n", vsie);
-
- if ((strlen(vsie) > 0)) {
- rv = wifi_manager_add_vsie(wifi, frame_id, vsie);
- printf("wifi_manager_add_vsie() ret=[%d]\n", rv);
-
- g_free(vsie);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to add vsie [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- }
-
- return 1;
-}
-
-int test_wifi_manager_get_vsie(void)
-{
- int rv = 0;
- char *vsie = NULL;
- unsigned int frame_id;
-
- printf("Input frame_id:\n");
- if (scanf(" %2u", &frame_id) < 1)
- return -1;
-
- rv = wifi_manager_get_vsie(wifi, frame_id, &vsie);
- printf("Received vsie [%s]\n", vsie ? vsie : "NULL");
-
- g_free(vsie);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to get vsie [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- return 1;
-}
-
-int test_wifi_manager_remove_vsie(void)
-{
- int rv = 0;
- char *vsie = NULL;
- unsigned int frame_id;
-
- printf("Input frame_id:\n");
- if (scanf(" %2u", &frame_id) < 1)
- return -1;
-
- printf("Input vsie:\n");
- if (scanf(" %100ms", &vsie) < 1)
- return -1;
-
- if (strlen(vsie) == 0)
- printf("invalid vsie !!\n");
- else
- printf("vsie: [%s]\n", vsie);
-
- if ((strlen(vsie) > 0)) {
- rv = wifi_manager_remove_vsie(wifi, frame_id, vsie);
- printf("wifi_manager_remove_vsie() ret=[%d]\n", rv);
-
- g_free(vsie);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to remove vsie [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
- }
-
- return 1;
-}
-
-int test_wifi_manager_specific_ap_start_multi_scan(void)
-{
- int rv = 0, scan_type, num = 0;
- char ssid[32 + 1];
- int freq;
- int i = 0;
- wifi_manager_specific_scan_h specific_scan = NULL;
-
- rv = wifi_manager_specific_scan_create(wifi, &specific_scan);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to create specific scan handle [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Specific Scan handle created [%p]\n", specific_scan);
-
- rv = test_get_user_int("Input multi scan type"
- "(0:SSID, 1:Freq, 2: SSID & Freq):", &scan_type);
-
- if (rv == false || (scan_type != 0 && scan_type != 1 && scan_type != 2)) {
- printf("Invalid input!!\n");
- return false;
- }
-
- if (scan_type == 0 || scan_type == 1) {
- rv = test_get_user_int("No. of specific ssid/freq for multi scan",
- &num);
- if (rv == false || (num <= 0) || (num > 4)) {
- printf("Invalid input!!\n");
- return false;
- }
-
- if (scan_type == 0) { /** multi ssid scan */
- for (i = 0; i < num; i++) {
- printf("Input ssid[%d]:\n", i);
- rv = scanf(" %32[^\n]s", ssid);
-
- rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- }
- } else { /** multi frequency scan */
- for (i = 0; i < num; i++) {
- printf("Input freq[%d]:\n", i);
- rv = scanf(" %d", &freq);
- rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set freq [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- }
- }
- } else { /** SSID & frequency mixed scan */
- rv = test_get_user_int("No. of ssid&freq for dual parameter multi scan",
- &num);
- if (rv == false || (num <= 0) || (num > 4)) {
- printf("Invalid input!!\n");
- return false;
- }
-
- for (i = 0; i < num; i++) {
- printf("Input ssid:\n");
- rv = scanf(" %32[^\n]s", ssid);
-
- rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Input freq:\n");
- rv = scanf(" %d", &freq);
-
- rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to set freq [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- }
- }
-
- rv = wifi_manager_specific_ap_start_multi_scan(wifi, specific_scan,
- __test_multi_scan_callback, NULL);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to start multi scan[%s]", __test_convert_error_to_string(rv));
- return -1;
- }
- printf("Specific Multi Scan requested\n");
-
- rv = wifi_manager_specific_scan_destroy(wifi, specific_scan);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Failed to destroy specific scan handle [%s]", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("Specific Scan handle destroyed\n");
-
- return 1;
-}
-
-int test_wifi_manager_flush_bss(void)
-{
- int rv;
-
- rv = wifi_manager_flush_bss(wifi);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to flush bss rv = %d\n", rv);
- return -1;
- }
-
- printf("Request to flush bss\n");
- return 1;
-}
-
-int test_wifi_manager_set_auto_connect(void)
-{
- int rv;
- int mode;
-
- printf("Auto connect mode (1:enable, 0:disable) : ");
- rv = scanf(" %d", &mode);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_set_auto_connect(wifi, mode);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set auto connect mode, rv = %d\n", rv);
- }
-
- printf("Request to set auto connect mode\n");
- return 1;
-}
-
-int test_wifi_manager_get_auto_connect(void)
-{
- int rv;
- int mode;
-
- rv = wifi_manager_get_auto_connect(wifi, &mode);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get auto connect mode, rv = %d\n", rv);
- return 1;
- }
-
- printf("Request to get auto connect mode = %d (1:enable, 0:disable)\n", mode);
- return 1;
-}
-
-int test_wifi_manager_set_ap_auto_connect(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("[Wi-Fi] Input a part of AP name to set : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_set_autoconnect_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[Wi-Fi] Fail to set up (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("[Wi-Fi] Set up finished\n");
- return 1;
-}
-
-int test_wifi_manager_get_ap_auto_connect(void)
-{
- int rv = 0;
- char ap_name[33];
- bool state = false;
-
- wifi_manager_is_activated(wifi, &state);
- if (state == false)
- return -1;
-
- printf("[Wi-Fi] Input a part of AP name to get : ");
- rv = scanf(" %32[^\n]s", ap_name);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_foreach_found_ap(wifi, __test_found_get_autoconnect_ap_callback, ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("[Wi-Fi] Fail to get up (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- printf("[Wi-Fi] Get up finished\n");
- return 1;
-}
-
-int test_wifi_manager_set_passpoint_enable(void)
-{
- int rv;
- int enable;
-
- printf("Enter passpoint on/off(0:off, 1:on) : \n");
- rv = scanf(" %d", &enable);
- if (rv <= 0)
- return -1;
-
- rv = wifi_manager_set_passpoint(wifi, enable);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to set passpoint, rv = %d\n", rv);
- }
-
- printf("Request to set passpoint\n");
- return 1;
-}
-
-int test_wifi_manager_get_passpoint_state(void)
-{
- int rv;
- int enabled;
-
- rv = wifi_manager_get_passpoint(wifi, &enabled);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get passpoint state, rv = %d\n", rv);
- return 1;
- }
-
- printf("current passpoint sate(0:off, 1:on) = [%d]\n", enabled);
- return 1;
-}
-
-int test_wifi_manager_get_5ghz_band_supported(void)
-{
- int rv;
- bool supported;
-
- rv = wifi_manager_is_5ghz_band_supported(wifi, &supported);
-
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get 5ghz supported, rv = %d\n", rv);
- return 1;
- }
-
- printf("Is 5Ghz supported = [%s]\n", supported ? "yes" : "no");
- return 1;
-}
-
-int test_wifi_manager_get_connection_mode(void)
-{
- int rv, int_value;
- wifi_manager_connection_mode_e mode;
- char *ap_name = NULL;
- wifi_manager_ap_h ap_h;
-
- rv = wifi_manager_get_connected_ap(wifi, &ap_h);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
- return -1;
- }
-
- rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
- wifi_manager_ap_destroy(ap_h);
- return -1;
- }
-
- rv = wifi_manager_ap_get_max_speed(ap_h, &int_value);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get max speed[%s]\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- wifi_manager_ap_destroy(ap_h);
- return -1;
- }
-
- rv = wifi_manager_get_connection_mode(wifi, &mode);
- if (rv != WIFI_MANAGER_ERROR_NONE) {
- printf("Fail to get connection mode[%s]\n", __test_convert_error_to_string(rv));
- g_free(ap_name);
- wifi_manager_ap_destroy(ap_h);
- return -1;
- }
-
- printf("Connected AP : %s\n", ap_name);
- printf("Connection mode : %s\n", __test_convert_connection_mode_to_string(mode));
- printf("Link speed : %d\n", int_value);
- g_free(ap_name);
- wifi_manager_ap_destroy(ap_h);
- return 1;
-}
-
-int main(int argc, char **argv)
-{
- GMainLoop *mainloop;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
-#endif
- mainloop = g_main_loop_new(NULL, FALSE);
-
- GIOChannel *channel = g_io_channel_unix_new(0);
- g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
-
- printf("Test Thread created...\n");
-
- g_main_loop_run(mainloop);
-
- return 0;
-}
-
-gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
-{
- int rv;
- char a[10];
-
- printf("Event received from stdin\n");
-
- rv = read(0, a, 10);
-
- if (rv <= 0 || a[0] == '0') {
- rv = wifi_manager_deinitialize(wifi);
-
- if (rv != WIFI_MANAGER_ERROR_NONE)
- printf("Fail to deinitialize.\n");
-
- exit(1);
- }
-
- if (a[0] == '\n' || a[0] == '\r') {
-/* Public API */
- printf("\n\n Network Connection API Test App\n\n");
- printf("Options..\n");
- printf(LOG_BLUE "[Public APIs]\n" LOG_END);
- printf(LOG_GREEN "1 - Wi-Fi init and set callbacks\n" LOG_END);
- printf("2 - Wi-Fi deinit(unset callbacks automatically)\n");
- printf(LOG_GREEN "3 - Activate Wi-Fi device\n" LOG_END);
- printf("4 - Deactivate Wi-Fi device\n");
- printf("5 - Is Wi-Fi activated?\n");
- printf("6 - Get connection state\n");
- printf("7 - Get MAC address\n");
- printf("8 - Get Wi-Fi interface name\n");
- printf(LOG_GREEN "9 - Scan request\n" LOG_END);
- printf("a - Get Connected AP\n");
- printf("b - Get AP list\n");
- printf(LOG_GREEN "c - Connect\n" LOG_END);
- printf("d - Disconnect\n");
- printf("e - Connect by wps pbc\n");
- printf("f - Forget an AP\n");
- printf("g - Set & connect EAP\n");
- printf("h - Set IP method type\n");
- printf("i - Set Proxy method type\n");
- printf("j - Get Ap info\n");
- printf("k - Connect Specific AP\n");
- printf("l - Load configuration\n");
- printf("m - Save configuration\n");
- printf("n - Remove configuration\n");
- printf("o - TDLS Discover\n");
- printf("p - TDLS Connect\n");
- printf("q - TDLS Connected peer\n");
- printf("r - TDLS Disconnect\n");
- printf("s - Connect Hidden AP\n");
- printf("t - Connect WPS PBC without SSID\n");
- printf("u - Connect WPS PIN without SSID\n");
- printf("v - Cancel WPS Request\n");
- printf("w - Get wifi scanning state\n");
- printf("x - Enable TDLS Channel Switch Request\n");
- printf("y - Disable TDLS Channel Switch Request\n");
- printf("z - Get Wi-Fi Module State\n");
- printf("A - BSSID Scan (Wi-Fi Position System Scan)\n");
- printf("B - Multi Scan (Multi Frequency & Multi SSID)\n");
- printf("C - Add VSIE\n");
- printf("D - Get VSIE\n");
- printf("E - Remove VSIE\n");
- printf("F - Set IP conflict detection mode\n");
- printf("G - Get IP conflict detection mode\n");
- printf("H - Get IP conflict state\n");
- printf("I - Get generated PIN number\n");
- printf("J - Forget an AP(async)\n");
-/* Extension APIs */
- printf(LOG_BLUE "[Extension API]\n" LOG_END);
- printf("K - Set Enable or Disable Auto Scan\n");
- printf("L - Set Mode of Auto Scan\n");
- printf("M - Get Enable or Disable Auto Scan\n");
- printf("N - Get Mode of Auto Scan\n");
- printf("O - Flush BSS\n");
- printf("P - Set enable or disable auto connect\n");
- printf("Q - Get enable or disable auto connect\n");
- printf("R - Set enable or disable of Wi-Fi profile auto-connect\n");
- printf("S - Get enable or disable of Wi-Fi profile auto-connect\n");
- printf("T - Set the IP conflict detection period\n");
- printf("U - Get the IP conflict detection period\n");
- printf("V - Netlink Scan Normal/Specific-AP\n");
- printf("W - Get passpoint state\n");
- printf("X - Set passpoint on/off\n");
- printf("Y - Get Access Point Hardware Mode\n");
- printf("Z - Get 5Ghz supported\n");
- printf(LOG_RED "0 - Exit \n" LOG_END);
-
- printf("ENTER - Show options menu.......\n");
- }
-
- switch (a[0]) {
-/* Public API */
- case '1':
- rv = test_wifi_manager_init();
- break;
- case '2':
- rv = test_wifi_manager_deinit();
- break;
- case '3':
- rv = test_wifi_manager_activate();
- break;
- case '4':
- rv = test_wifi_manager_deactivate();
- break;
- case '5':
- rv = test_wifi_manager_is_activated();
- break;
- case '6':
- rv = test_wifi_manager_get_connection_state();
- break;
- case '7':
- rv = test_wifi_manager_get_mac_address();
- break;
- case '8':
- rv = test_wifi_manager_get_interface_name();
- break;
- case '9':
- rv = test_wifi_manager_scan();
- break;
- case 'a':
- rv = test_wifi_manager_get_connected_ap();
- break;
- case 'b':
- rv = test_wifi_manager_foreach_found_ap();
- break;
- case 'c':
- rv = test_wifi_manager_connect();
- break;
- case 'd':
- rv = test_wifi_manager_disconnect();
- break;
- case 'e':
- rv = test_wifi_manager_connect_wps();
- break;
- case 'f':
- rv = test_wifi_manager_forget_ap();
- break;
- case 'g':
- rv = test_wifi_manager_connect_eap_ap();
- break;
- case 'h':
- rv = test_wifi_manager_set_ip_method();
- break;
- case 'i':
- rv = test_wifi_manager_set_proxy_method();
- break;
- case 'j':
- rv = test_wifi_manager_get_ap_info();
- break;
- case 'k':
- rv = test_wifi_manager_connect_specific_ap();
- break;
- case 'l':
- rv = test_wifi_manager_config_load_configuration();
- break;
- case 'm':
- rv = test_wifi_manager_config_save();
- break;
- case 'n':
- rv = test_wifi_manager_config_remove();
- break;
- case 'o':
- rv = test_wifi_manager_tdls_discover();
- break;
- case 'p':
- rv = test_wifi_manager_tdls_connect();
- break;
- case 'q':
- rv = test_wifi_manager_tdls_get_connected_peer();
- break;
- case 'r':
- rv = test_wifi_manager_tdls_disconnect();
- break;
- case 's':
- rv = test_wifi_manager_connect_hidden_ap();
- break;
- case 't':
- rv = test_wifi_manager_connect_wps_pbc_without_ssid();
- break;
- case 'u':
- rv = test_wifi_manager_connect_wps_pin_without_ssid();
- break;
- case 'v':
- rv = test_wifi_manager_cancel_wps();
- break;
- case 'w':
- rv = test_wifi_manager_get_scan_state();
- break;
- case 'x':
- rv = test_wifi_manager_tdls_enable_channel_switch();
- break;
- case 'y':
- rv = test_wifi_manager_tdls_disable_channel_switch();
- break;
- case 'z':
- rv = test_wifi_manager_get_module_state();
- break;
- case 'A':
- rv = test_wifi_manager_bssid_scan();
- break;
- case 'B':
- rv = test_wifi_manager_specific_ap_start_multi_scan();
- break;
- case 'C':
- rv = test_wifi_manager_add_vsie();
- break;
- case 'D':
- rv = test_wifi_manager_get_vsie();
- break;
- case 'E':
- rv = test_wifi_manager_remove_vsie();
- break;
- case 'F':
- rv = test_wifi_manager_set_ip_conflict_detect_enable();
- break;
- case 'G':
- rv = test_wifi_manager_ip_conflict_detect_is_enabled();
- break;
- case 'H':
- rv = test_wifi_manager_get_ip_conflict_state();
- break;
- case 'I':
- rv = test_wifi_manager_get_wps_generated_pin();
- break;
- case 'J':
- rv = test_wifi_manager_forget_ap_async();
- break;
-
-/* Extension APIs */
- case 'K':
- rv = test_wifi_manager_set_autoscan_state();
- break;
- case 'L':
- rv = test_wifi_manager_set_autoscan_mode();
- break;
- case 'M':
- rv = test_wifi_manager_get_autoscan_state();
- break;
- case 'N':
- rv = test_wifi_manager_get_autoscan_mode();
- break;
- case 'O':
- rv = test_wifi_manager_flush_bss();
- break;
- case 'P':
- rv = test_wifi_manager_set_auto_connect();
- break;
- case 'Q':
- rv = test_wifi_manager_get_auto_connect();
- break;
- case 'R':
- rv = test_wifi_manager_set_ap_auto_connect();
- break;
- case 'S':
- rv = test_wifi_manager_get_ap_auto_connect();
- break;
- case 'T':
- rv = test_wifi_manager_set_ip_conflict_period();
- break;
- case 'U':
- rv = test_wifi_manager_get_ip_conflict_period();
- break;
- case 'V':
- rv = test_wifi_manager_netlink_scan();
- break;
- case 'W':
- rv = test_wifi_manager_get_passpoint_state();
- break;
- case 'X':
- rv = test_wifi_manager_set_passpoint_enable();
- break;
- case 'Y':
- rv = test_wifi_manager_get_connection_mode();
- break;
- case 'Z':
- rv = test_wifi_manager_get_5ghz_band_supported();
- break;
- default:
- break;
- }
-
- if (rv == 1)
- printf("Operation succeeded!\n");
- else
- printf("Operation failed!\n");
-
- return TRUE;
-}
--- /dev/null
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+SET(GTEST "gtest-wifi-manager")
+
+pkg_check_modules(gtest_pkgs REQUIRED gmock glib-2.0)
+INCLUDE_DIRECTORIES(${gtest_pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${gtest_pkgs_LIBRARY_DIRS})
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-lto")
+
+FILE(GLOB GTEST_SRCS *.cpp mocks/*.c ${CMAKE_SOURCE_DIR}/src/*.c)
+ADD_EXECUTABLE(${GTEST} ${GTEST_SRCS})
+TARGET_LINK_LIBRARIES(${GTEST} ${gtest_pkgs_LIBRARIES} ${${fw_name}_LIBRARIES})
+SET_TARGET_PROPERTIES(${GTEST} PROPERTIES COMPILE_FLAGS "-fPIE" LINK_FLAGS "-Wl,\
+--wrap=system_info_get_platform_bool,\
+--wrap=g_try_malloc0,\
+--wrap=g_bus_get_sync,\
+--wrap=g_cancellable_new,\
+--wrap=g_dbus_connection_call_sync,\
+--wrap=g_dbus_connection_call,\
+--wrap=g_dbus_connection_call_finish,\
+--wrap=g_dbus_connection_signal_subscribe,\
+--wrap=g_dbus_connection_signal_unsubscribe,\
+--wrap=vconf_get_int,\
+--wrap=vconf_get_bool,\
+--wrap=vconf_get_str")
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "gtest-wifi-manager-util.h"
+#include "wifi-manager.h"
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+static int g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+
+class UtcWifiManagerActivation : public ::testing::Test {
+protected:
+ wifi_manager_h handle;
+ WifiManagerTestUtil testUtil;
+
+ UtcWifiManagerActivation() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ mock_set_gdbus_powered(true);
+ mock_set_gdbus_devicePolicy(false);
+ wifi_manager_initialize(&handle);
+ }
+
+ void TearDown() override
+ {
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_powered(false);
+ mock_set_gdbus_devicePolicy(true);
+ }
+};
+
+
+static void utc_wifi_manager_activated_cb(wifi_manager_error_e result, void *user_data)
+{
+ g_nCallbackRet = result;
+}
+
+static void utc_wifi_manager_deactivated_cb(wifi_manager_error_e result, void *user_data)
+{
+ g_nCallbackRet = result;
+}
+
+TEST_F(UtcWifiManagerActivation, ActivateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_activate(handle, utc_wifi_manager_activated_cb, nullptr));
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerActivation, ActivateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_activate(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, ActivateN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deinitialize(handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_INITIALIZED, wifi_manager_activate(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, ActivateN3)
+{
+ mock_set_gdbus_devicePolicy(true);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_activate(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, ActivateN4)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_activate(handle, utc_wifi_manager_activated_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_SECURITY_RESTRICTED);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_SECURITY_RESTRICTED, g_nCallbackRet);
+}
+
+#if 0 //This will enable after fix in wifi-manager code
+TEST_F(UtcWifiManagerActivation, ActivateN5)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_activate(handle, utc_wifi_manager_activated_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerActivation, ActivateN6)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_activate(handle, utc_wifi_manager_activated_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_ALREADY_EXISTS);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_ALREADY_EXISTS, g_nCallbackRet);
+}
+#endif
+
+TEST_F(UtcWifiManagerActivation, Activate_with_wifi_pickerN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_activate_with_wifi_picker_tested(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, Activate_with_wifi_pickerP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_activate_with_wifi_picker_tested(handle, utc_wifi_manager_activated_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, Activate_with_wifi_pickerN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deinitialize(handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_INITIALIZED, wifi_manager_activate_with_wifi_picker_tested(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, Activate_with_wifi_pickerN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_activate_with_wifi_picker_tested(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, Activate_with_wifi_pickerN4)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_activate_with_wifi_picker_tested(handle, utc_wifi_manager_activated_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_SECURITY_RESTRICTED);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_SECURITY_RESTRICTED, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerActivation, DeactivateP1)
+{
+ mock_set_gdbus_tech_state("wlan0", TRUE, FALSE);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deactivate(handle, utc_wifi_manager_deactivated_cb, nullptr));
+ mock_set_gdbus_tech_state("wlan0", FALSE, FALSE);
+}
+
+TEST_F(UtcWifiManagerActivation, DeactivateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_deactivate(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, DeactivateN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_ALREADY_EXISTS, wifi_manager_deactivate(handle, utc_wifi_manager_deactivated_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerActivation, DeactivateN3)
+{
+ mock_set_gdbus_tech_state("wlan0", TRUE, FALSE);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deactivate(handle, utc_wifi_manager_deactivated_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_SECURITY_RESTRICTED);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_SECURITY_RESTRICTED, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerActivation, DeactivateN4)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deinitialize(handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_INITIALIZED, wifi_manager_deactivate(handle, nullptr, nullptr));
+}
+
+
+#if 0 //This will enable after fix in wifi-manager code
+TEST_F(UtcWifiManagerActivation, DeactivateN4)
+{
+ mock_set_gdbus_tech_state("wlan0", TRUE, FALSE);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deactivate(handle, utc_wifi_manager_deactivated_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, g_nCallbackRet);
+}
+#endif
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "gtest-wifi-manager-util.h"
+#include "wifi-manager.h"
+#include <wifi-manager-extension.h>
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+static int g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+
+class UtcWifiManagerAp : public ::testing::Test {
+ protected:
+ wifi_manager_h handle;
+ WifiManagerTestUtil testUtil;
+
+ UtcWifiManagerAp() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ wifi_manager_initialize(&handle);
+ mock_set_gdbus_tech_state("wlan0", true, false);
+ }
+
+ void TearDown() override
+ {
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+ }
+};
+
+
+bool callback(unsigned char *vsie, int length, void *user_data)
+{
+ return true;
+}
+
+bool vsie_cb (unsigned char *vsie, int length, void *user_data)
+{
+ return true;
+}
+
+bool found_bssid_cb(const char *bssid, int rssi, int freq, void *user_data)
+{
+ return true;
+}
+
+bool ipv6_cb(char *ipv6_address, void *user_data)
+{
+ return true;
+}
+
+wifi_manager_ap_h _ap;
+
+wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+
+wifi_manager_ip_config_type_e type;
+
+const char essid = '1';
+
+TEST_F(UtcWifiManagerAp, ApCreateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_create(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApCreateN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_create(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApCreateN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_create(handle, &essid, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApCreateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_create(handle, &essid, &_ap));
+}
+
+TEST_F(UtcWifiManagerAp, ApHiddenCreateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_hidden_create(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApHiddenCreateN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_hidden_create(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApHiddenCreateN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_hidden_create(handle, &essid, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApHiddenCreateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_hidden_create(handle, &essid, &_ap));
+}
+
+TEST_F(UtcWifiManagerAp, ApDestroyN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_destroy(nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApCloneN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_clone(nullptr, _ap));
+}
+
+TEST_F(UtcWifiManagerAp, ApCloneN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_clone(nullptr, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerAp, ApRefreshP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_refresh(_ap));
+}
+*/
+
+TEST_F(UtcWifiManagerAp, ApRefreshN1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_ap_refresh(_ap));
+}
+
+TEST_F(UtcWifiManagerAp, ApRefreshN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_refresh(nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApRefreshN3)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_ap_refresh(_ap));
+}
+
+TEST_F(UtcWifiManagerAp, ApRefreshN4)
+{
+ mock_set_gdbus_error_msg(ERROR_NULL);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_refresh(_ap));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEssidN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_essid(_ap, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_essid(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetRawSsidN1)
+{
+ int *len = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_raw_ssid(_ap, nullptr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_raw_ssid(nullptr, nullptr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_raw_ssid(_ap, nullptr, len));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetBssidN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_bssid(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetRssiN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_rssi(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetRssiLevelN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_rssi_level(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetFrequencyN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_frequency(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApForeachVsieN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_foreach_vsie(_ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApForeachVsieP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_foreach_vsie(_ap, vsie_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetMaxSpeedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_max_speed(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApIsFavoriteN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_is_favorite(_ap, nullptr));
+}
+
+
+TEST_F(UtcWifiManagerAp, ApIsPasspointN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_is_passpoint(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetConnectionStateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_connection_state(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetIpConfigTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_ip_config_type(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetIpConfigTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_ip_config_type(nullptr, addr, type));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetIpConfigTypeP1)
+{
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_ip_config_type_e type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_ip_config_type(_ap, addr, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_ip_config_type(_ap, addr, &type));
+ addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_ip_config_type(_ap, addr, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_ip_config_type(_ap, addr, &type));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetIpAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_ip_address(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetIpAddressN2)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ char *ip_address;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NO_CONNECTION, wifi_manager_ap_get_ip_address(_ap, addr, &ip_address));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetIpAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_ip_address(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetIpAddressP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ char ip = '1';
+ char *ip_addr = &ip;
+ const char *ip_address = &ip;
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_ip_address(_ap, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_ip_address(_ap, addr, ip_address));
+ EXPECT_EQ(-30277630, wifi_manager_ap_get_ip_address(_ap, addr, &ip_addr));
+ addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_ip_address(_ap, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_ip_address(_ap, addr, &ip_addr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_ip_address(_ap, addr, ip_address));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetSubnetMaskN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_subnet_mask(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetSubnetMaskN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_subnet_mask(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetSubnetMaskP1)
+{
+ const char mask = '1';
+ char *subnet;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_subnet_mask(_ap, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_subnet_mask(_ap, addr, &subnet));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_subnet_mask(_ap, addr, &mask));
+ addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_subnet_mask(_ap, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_subnet_mask(_ap, addr, &subnet));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetPrefixLengthN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_prefix_length(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetPrefixLengthN1)
+{
+ int prefix_len = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_prefix_length(nullptr, addr, prefix_len));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetPrefixLengthP1)
+{
+ int prefix_len = 1;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_prefix_length(_ap, addr, prefix_len));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_prefix_length(_ap, addr, &prefix_len));
+ addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_prefix_length(_ap, addr, prefix_len));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_prefix_length(_ap, addr, &prefix_len));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetGatewayAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_gateway_address(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetGatewayAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_gateway_address(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetGatewayAddressP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ const char g_addr = '1';
+ char g_ad = '1';
+ char *ad = &g_ad;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_gateway_address(_ap, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_gateway_address(_ap, addr, &ad));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_gateway_address(_ap, addr, &g_addr));
+ addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_gateway_address(_ap, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_gateway_address(_ap, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_gateway_address(_ap, addr, &g_addr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDhcpServerAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_dhcp_server_address(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDhcpServerAddressP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ char dhcp = '1';
+ char *dp = &dhcp;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_dhcp_server_address(_ap, addr, &dp));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDhcpServerAddressN2)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ char dhcp = '1';
+ char *dp = &dhcp;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_SUPPORTED, wifi_manager_ap_get_dhcp_server_address(_ap, addr, &dp));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDhcpLeaseDurationN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_dhcp_lease_duration(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDhcpLeaseDurationP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ int dhcp = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_dhcp_lease_duration(_ap, addr, &dhcp));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDhcpLeaseDurationN2)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ int dhcp = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_SUPPORTED, wifi_manager_ap_get_dhcp_lease_duration(_ap, addr, &dhcp));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetProxyAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_proxy_address(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetProxyAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_proxy_address(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetProxyAddressP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ const char add = '1';
+ char ad = '1';
+ char *a = &ad;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_proxy_address(_ap, addr, &add));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_proxy_address(_ap, addr, &a));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetProxyTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_proxy_type(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetProxyTypeN1)
+{
+ wifi_manager_proxy_type_e type = WIFI_MANAGER_PROXY_TYPE_DIRECT;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_proxy_type(nullptr, type));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDnsConfigTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_dns_config_type(_ap, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetDnsConfigTypeN1)
+{
+ wifi_manager_dns_config_type_e type = WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_dns_config_type(nullptr, addr, type));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetDnsConfigTypeP1)
+{
+ wifi_manager_dns_config_type_e type = WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_dns_config_type(_ap, addr, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_dns_config_type(_ap, addr, &type));
+ addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_dns_config_type(_ap, addr, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_dns_config_type(_ap, addr, &type));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDnsAddressN1)
+{
+ int order = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_dns_address(_ap, order, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetDnsAddressN1)
+{
+ int order = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_dns_address(_ap, order, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetDnsAddressP1)
+{
+ int order = 1;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_address_family_e addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV4;
+ const char ad = '1';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_dns_address(_ap, order, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_dns_address(_ap, order, addr, &ad));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_dns_address(_ap, order, addr, nullptr));
+ addr = WIFI_MANAGER_ADDRESS_FAMILY_IPV6;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_dns_address(_ap, order, addr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_dns_address(_ap, order, addr,&ad));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_dns_address(_ap, order, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetDnsAddressN2)
+{
+ int order = 0;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_dns_address(_ap, order, addr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetCountryCodeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_countrycode(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ForeachFoundBssidN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_bssid(_ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ForeachFoundBssidP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_foreach_found_bssid(_ap, found_bssid_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetSecurityTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_security_type(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetSecurityTypeN1)
+{
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_security_type(nullptr, type));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetSecurityTypeP1)
+{
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_NONE;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_security_type(_ap, &type));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEncryptionTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_encryption_type(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEncryptionTypeN1)
+{
+ wifi_manager_encryption_type_e type = WIFI_MANAGER_ENCRYPTION_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_encryption_type(nullptr, type));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEncryptionTypeP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_encryption_type_e type = WIFI_MANAGER_ENCRYPTION_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_encryption_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_encryption_type(_ap, &type));
+}
+
+TEST_F(UtcWifiManagerAp, ApIsPassphraseRequiredN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_is_passphrase_required(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApIsPassphraseRequiredP1)
+{
+ bool required = true;
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_WEP;
+ const char pass = '1';
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_ap_is_passphrase_required(_ap, &required));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_ap_set_passphrase(_ap, &pass));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_is_passphrase_required(_ap, &required));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_passphrase(_ap, &pass));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetPassphraseN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_passphrase(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApIsWpsSupportedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_is_wps_supported(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApIsWpsSupportedP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ bool support = true;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_is_wps_supported(_ap, &support));
+}
+
+TEST_F(UtcWifiManagerAp, ApIsHiddenN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_is_hidden(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApIsHiddenP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ bool hidden = true;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_is_hidden(_ap, &hidden));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapPassphraseN1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_passphrase(nullptr, nullptr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_passphrase(_ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapPassphraseP1)
+{
+ const char username = '1';
+ const char pass = '1';
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_set_eap_passphrase(_ap, &username, &pass));
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_eap_passphrase(_ap, &username, &pass));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapPassphraseN1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_eap_passphrase(nullptr, nullptr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_eap_passphrase(_ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapPassphraseP1)
+{
+ char usr = '1';
+ char *username = &usr;
+ bool is_set = true;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_get_eap_passphrase(_ap, &username, &is_set));
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_eap_passphrase(_ap, &username, &is_set));
+
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapAnonymousIdentityN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_anonymous_identity(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapAnonymousIdentityP1)
+{
+ const char name = '1';
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_set_eap_anonymous_identity(_ap, &name));
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_eap_anonymous_identity(_ap, &name));
+}
+
+
+TEST_F(UtcWifiManagerAp, ApGetEapAnonymousIdentityN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_eap_anonymous_identity(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapAnonymousIdentityP1)
+{
+ char name = '1';
+ char *identity = &name;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_get_eap_anonymous_identity(_ap, &identity));
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_eap_anonymous_identity(_ap, &identity));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapCertFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_eap_ca_cert_file(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapCertFileP1)
+{
+ char name = '1';
+ char *file = &name;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_get_eap_ca_cert_file(_ap, &file));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_eap_ca_cert_file(_ap, &file));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapCertFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_ca_cert_file(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapCertFileP1)
+{
+ const char file = '1';
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_set_eap_ca_cert_file(_ap, &file));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_eap_ca_cert_file(_ap, &file));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapClientCertFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_eap_client_cert_file(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapClientCertFileP1)
+{
+ char name = '1';
+ char *file = &name;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_get_eap_client_cert_file(_ap, &file));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_eap_client_cert_file(_ap, &file));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapClientCertFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_client_cert_file(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapClientCertFileP1)
+{
+ const char file = '1';
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_set_eap_client_cert_file(_ap, &file));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_eap_client_cert_file(_ap, &file));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapPrivateKeyFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_eap_private_key_file(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapPrivateKeyFileP1)
+{
+ char name = '1';
+ char *file = &name;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_get_eap_private_key_file(_ap, &file));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_eap_private_key_file(_ap, &file));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapPrivateKeyInfoN1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_private_key_info(nullptr, nullptr, nullptr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_private_key_info(_ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapPrivateKeyInfoP1)
+{
+ const char file = '1';
+ const char pass = '1';
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_set_eap_private_key_info(_ap, &file, &pass));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_eap_private_key_info(_ap, &file, &pass));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_eap_type(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapTypeN1)
+{
+ wifi_manager_eap_type_e type = WIFI_MANAGER_EAP_TYPE_PEAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_type(nullptr, type));
+}
+
+
+TEST_F(UtcWifiManagerAp, ApSetEapTypeP1)
+{
+ wifi_manager_eap_type_e eap_type = WIFI_MANAGER_EAP_TYPE_PEAP;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_set_eap_type(_ap, eap_type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_get_eap_type(_ap, &eap_type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_eap_type(_ap, eap_type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_eap_type(_ap, &eap_type));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetEapAuthTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_eap_auth_type(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapAuthTypeN1)
+{
+ wifi_manager_eap_auth_type_e type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_eap_auth_type(nullptr, type));
+}
+
+TEST_F(UtcWifiManagerAp, ApSetEapAuthTypeP1)
+{
+ wifi_manager_eap_auth_type_e auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ wifi_manager_security_type_e type = WIFI_MANAGER_SECURITY_TYPE_EAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_set_eap_auth_type(_ap, auth_type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_ap_get_eap_auth_type(_ap, &auth_type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_security_type(_ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_eap_auth_type(_ap, auth_type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_eap_auth_type(_ap, &auth_type));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDisconnectReasonN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_disconnect_reason(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetDisconnectReasonP1)
+{
+ wifi_manager_disconnect_reason_e dc_reason = WIFI_REASON_UNSPECIFIED;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_disconnect_reason(_ap, &dc_reason));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetAssocStatusCodeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_assoc_status_code(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetAssocStatusCodeP1)
+{
+ wifi_manager_assoc_status_code_e status_code = WLAN_STATUS_SUCCESS;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_assoc_status_code(_ap, &status_code));
+}
+
+TEST_F(UtcWifiManagerAp, ApForeachIpv6AddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_foreach_ipv6_address(_ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApForeachIpv6AddressP1)
+{
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_foreach_ipv6_address(_ap, ipv6_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetErrorStateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_error_state(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetErrorStateP1)
+{
+ wifi_manager_error_e error_state = WIFI_MANAGER_ERROR_NONE;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_error_state(_ap, &error_state));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetConnectionModeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_connection_mode(_ap, nullptr));
+}
+
+TEST_F(UtcWifiManagerAp, ApGetConnectionModeN2)
+{
+ wifi_manager_connection_mode_e mode = WIFI_MANAGER_CONNECTION_MODE_80211_B;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_ap_get_connection_mode(_ap, &mode));
+}
+
+/*
+ * TEST_F(UtcWifiManagerAp, ApGetConnectionModeP1)
+{
+ wifi_manager_connection_mode_e mode = WIFI_MANAGER_CONNECTION_MODE_80211_B;
+ wifi_manager_get_connected_ap(handle, &_ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_connection_mode(_ap, &mode));
+}
+*/
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "gtest-wifi-manager-util.h"
+#include "wifi-manager.h"
+#include <wifi-manager-extension.h>
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+static int g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+
+class UtcWifiManagerConflict : public ::testing::Test {
+ protected:
+ wifi_manager_h handle;
+ WifiManagerTestUtil testUtil;
+
+ UtcWifiManagerConflict() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ wifi_manager_initialize(&handle);
+ mock_set_gdbus_tech_state("wlan0", true, false);
+ }
+
+ void TearDown() override
+ {
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+ }
+};
+
+void ip_conflict_cb (char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
+{
+}
+
+void rssi_level_changed_cb (wifi_manager_rssi_level_e rssi_level, void *user_data)
+{
+}
+
+void module_state_changed_cb (wifi_manager_module_state_e wifi_module_state, void *user_data)
+{
+}
+
+wifi_manager_module_state_e state;
+
+TEST_F(UtcWifiManagerConflict, SetConflictN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_ip_conflict_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, SetConflictN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_ip_conflict_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, SetConflictP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_ip_conflict_cb(handle, &ip_conflict_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, UnsetConflictN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_ip_conflict_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, UnsetConflictP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_ip_conflict_cb(handle));
+}
+
+TEST_F(UtcWifiManagerConflict, SetConflictDetectP1)
+{
+ bool detect = true;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_ip_conflict_detect_enable(handle, detect));
+}
+
+TEST_F(UtcWifiManagerConflict, SetConflictDetectN1)
+{
+ bool detect = true;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_ip_conflict_detect_enable(nullptr, detect));
+}
+
+TEST_F(UtcWifiManagerConflict, ConflictIsEnabledN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ip_conflict_detect_is_enabled(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, ConflictIsEnabledN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ip_conflict_detect_is_enabled(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, ConflictIsEnabledP1)
+{
+ bool state = true;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ip_conflict_detect_is_enabled(handle, &state));
+}
+
+TEST_F(UtcWifiManagerConflict, SetConflictPeriodN1)
+{
+ unsigned int time = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_ip_conflict_period(nullptr, time));
+}
+
+TEST_F(UtcWifiManagerConflict, SetConflictPeriodP1)
+{
+ unsigned int time = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_ip_conflict_period(handle, time));
+}
+
+TEST_F(UtcWifiManagerConflict, GetConflictPeriodN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_ip_conflict_period(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, GetConflictPeriodN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_ip_conflict_period(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, GetConflictPeriodP1)
+{
+ unsigned int time;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_ip_conflict_period(handle, &time));
+}
+
+TEST_F(UtcWifiManagerConflict, GetConflictStateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_ip_conflict_state(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, GetConflictStateN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_ip_conflict_state(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, GetConflictStateP1)
+{
+ wifi_manager_ip_conflict_state_e state;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_ip_conflict_state(handle, &state));
+}
+
+TEST_F(UtcWifiManagerConflict, RssiLevelChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_rssi_level_changed_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, RssiLevelChangedN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_rssi_level_changed_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, RssiLevelChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_rssi_level_changed_cb(handle, &rssi_level_changed_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, UnsetRssiLevelChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_rssi_level_changed_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, UnsetRssiLevelChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_rssi_level_changed_cb(handle));
+}
+
+TEST_F(UtcWifiManagerConflict, ModuleStateChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_module_state_changed_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, ModuleStateChangedN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_module_state_changed_cb(nullptr, &module_state_changed_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, ModuleStateChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_module_state_changed_cb(handle, &module_state_changed_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, UnsetModuleStateChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_module_state_changed_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, UnsetModuleStateChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_module_state_changed_cb(handle));
+}
+
+TEST_F(UtcWifiManagerConflict, GetModuleStateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_module_state(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, GetModuleStateN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_module_state(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConflict, GetModuleStateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_module_state(handle, &state));
+}
+
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "gtest-wifi-manager-util.h"
+#include "wifi-manager.h"
+#include <wifi-manager-extension.h>
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+static int g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+
+class UtcWifiManagerConnection : public ::testing::Test {
+ protected:
+ wifi_manager_h handle;
+ WifiManagerTestUtil testUtil;
+
+ UtcWifiManagerConnection() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ wifi_manager_initialize(&handle);
+ mock_set_gdbus_tech_state("wlan0", true, false);
+ }
+
+ void TearDown() override
+ {
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+ }
+};
+
+wifi_manager_security_type_e sec_type = WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK;
+
+wifi_manager_ap_h ap;
+
+wifi_manager_connection_state_e conn_state;
+
+void __cb(wifi_manager_error_e result, void* user_data)
+{
+ g_nCallbackRet = result;
+}
+
+void manager_connected_cb (wifi_manager_error_e error_code, void *user_data)
+{
+ g_nCallbackRet = error_code;
+}
+
+void manager_disconnected_cb (wifi_manager_error_e error_code, void *user_data)
+{
+ g_nCallbackRet = error_code;
+}
+
+void manager_forget_ap_finished_cb (wifi_manager_error_e error_code, void *user_data)
+{
+ g_nCallbackRet = error_code;
+}
+
+void conn_state_changed_cb (wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void *user_data)
+{
+}
+
+void device_state_changed_cb (wifi_manager_device_state_e state, void *user_data)
+{
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectHiddenN1)
+{
+ const char essid = 'a';
+ const char passphrase = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_hidden_ap(nullptr, &essid, sec_type, &passphrase, manager_connected_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectHiddenN2)
+{
+ const char essid = 'a';
+ const char passphrase = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_hidden_ap(handle, &essid, sec_type, &passphrase, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectHiddenN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_hidden_ap(handle, nullptr, sec_type, nullptr, manager_connected_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectHiddenN4)
+{
+ const char essid = 'a';
+ const char passphrase = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_connect_hidden_ap(handle, &essid, sec_type, &passphrase, manager_connected_cb, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, ConnectHiddenP1)
+{
+ const char essid = 'a';
+ const char passphrase = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_connect_hidden_ap(handle, &essid, sec_type, &passphrase, manager_connected_cb, nullptr));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, GetConnectedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_connected_ap(nullptr, &ap));
+}
+
+TEST_F(UtcWifiManagerConnection, GetConnectedN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_connected_ap(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetConnectedP1)
+{
+ wifi_manager_ap_h g_wifi_ap;
+ char *ap_name = NULL;
+ char *ssid = NULL;
+ int ssid_len;
+ bool favor;
+ wifi_manager_connection_state_e state;
+ wifi_manager_rssi_level_e rssi_level;
+ wifi_manager_proxy_type_e type;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_clone(&g_wifi_ap, ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_essid(ap, &ap_name));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_raw_ssid(ap, &ssid, &ssid_len));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_bssid(ap, &ssid));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_rssi(ap, &ssid_len));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_rssi_level(ap, &rssi_level));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_frequency(ap, &ssid_len));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_max_speed(ap, &ssid_len));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_is_favorite(ap, &favor));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_is_passpoint(ap, &favor));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_connection_state(ap, &state));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_proxy_type(ap, &type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_proxy_type(ap, type));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_countrycode(ap, &ssid));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_destroy(ap));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect(nullptr, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect(handle, &ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_connect(handle, ap, manager_connected_cb, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, ConnectP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_connect(handle, ap, manager_connected_cb, nullptr));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, DisconnectN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_disconnect(nullptr, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, DisconnectN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_disconnect(handle, &ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, DisconnectP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_disconnect(handle, ap, manager_disconnected_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectByPbcN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pbc(nullptr, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectByPbcN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pbc(handle, &ap, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectByPbcP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ int rv = wifi_manager_connect_by_wps_pbc(handle, ap, manager_connected_cb, nullptr);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, rv);
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectByPinN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pin(nullptr, nullptr, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectByPinN2)
+{
+ const char pin = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pin(handle, &ap, &pin, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectByPinN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pin(handle, &ap, nullptr, manager_connected_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectByPinP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ const char pin = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_connect_by_wps_pin(handle, ap, &pin, manager_connected_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ForgetApN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_forget_ap(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ForgetApN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_forget_ap(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ForgetApN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_forget_ap(handle, ap));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, ForgetApP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_forget_ap(handle, ap));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, UpdateApN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_update_ap(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, UpdateApN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_update_ap(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, UpdateApN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_SECURITY_RESTRICTED, wifi_manager_update_ap(handle, ap));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, UpdateApP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_SECURITY_RESTRICTED, wifi_manager_update_ap(handle, ap));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, ForgetApAsyncN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_forget_ap_async(nullptr, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ForgetApAsyncN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_forget_ap_async(handle, nullptr, nullptr,nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ForgetApAsyncP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_forget_ap_async(handle, ap, manager_forget_ap_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetConnStateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_connection_state(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetConnStateN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_connection_state(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetConnStateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connection_state(handle, &conn_state));
+}
+
+TEST_F(UtcWifiManagerConnection, UnsetDeviceStateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_device_state_changed_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, UnsetDeviceStateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_device_state_changed_cb(handle));
+}
+
+TEST_F(UtcWifiManagerConnection, DevStateChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_device_state_changed_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, DevStateChangedN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_device_state_changed_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, DevStateChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_device_state_changed_cb(handle, &device_state_changed_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnStateChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_connection_state_changed_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnStateChangedN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_connection_state_changed_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnStateChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_connection_state_changed_cb(handle, &conn_state_changed_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, UnsetConnStateChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_connection_state_changed_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, UnsetConnStateChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_connection_state_changed_cb(handle));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectWpsPbcN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pbc_without_ssid(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectWpsPbcN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pbc_without_ssid(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectWpsPbcN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOW_IN_PROGRESS, wifi_manager_connect_by_wps_pbc_without_ssid(handle, &manager_connected_cb, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, ConnectWpsPbcP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_connect_by_wps_pbc_without_ssid(handle, &manager_connected_cb, nullptr));
+}
+*/
+
+
+TEST_F(UtcWifiManagerConnection, ConnectWpsPinN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pin_without_ssid(nullptr, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectWpsPinN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pin_without_ssid(handle, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectWpsPinN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pin_without_ssid(handle, nullptr, &manager_connected_cb, nullptr));
+ const char pin[255] = "123";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_connect_by_wps_pin_without_ssid(handle, pin, &manager_connected_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ConnectWpsPinN4)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ const char pin[255] = "1234";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOW_IN_PROGRESS, wifi_manager_connect_by_wps_pin_without_ssid(handle, pin, &manager_connected_cb, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, ConnectWpsPinP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ const char pin[255] = "1234";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOW_IN_PROGRESS, wifi_manager_connect_by_wps_pin_without_ssid(handle, pin, &manager_connected_cb, nullptr));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, CancelWpsN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_cancel_wps(nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, CancelWpsN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_cancel_wps(handle));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, CancelWpsP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_cancel_wps(handle));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, GetWpsPinN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_wps_generated_pin(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetWpsPinN2)
+{
+ char *pin;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_get_wps_generated_pin(handle, &pin));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, GetWpsPinP1)
+{
+ char *pin;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_get_wps_generated_pin(handle, &pin));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, SetPasspointN1)
+{
+ int passpoint = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_passpoint(nullptr, passpoint));
+}
+
+TEST_F(UtcWifiManagerConnection, SetPasspointP1)
+{
+ int passpoint = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_passpoint(handle, passpoint));
+}
+
+TEST_F(UtcWifiManagerConnection, GetPasspointN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_passpoint(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetPasspointN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_passpoint(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetPasspointN3)
+{
+ int passpoint;
+ EXPECT_EQ(-999, wifi_manager_get_passpoint(handle, &passpoint));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, GetPasspointP1)
+{
+ int passpoint;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_passpoint(handle, &passpoint));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, GetAutoConnectN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_auto_connect(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetAutoConnectN2)
+{
+ int connect_mode = 1;
+ EXPECT_EQ(-999, wifi_manager_get_auto_connect(handle, &connect_mode));
+}
+
+
+/*
+ * TEST_F(UtcWifiManagerConnection, GetAutoConnectP1)
+{
+ int connect_mode = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_auto_connect(handle, &connect_mode));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, SetAutoConnectP1)
+{
+ int connect_mode = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_auto_connect(handle, connect_mode));
+}
+
+TEST_F(UtcWifiManagerConnection, ApSetAutoConnectN1)
+{
+ bool autoconnect = TRUE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_set_auto_connect(nullptr, autoconnect));
+}
+
+TEST_F(UtcWifiManagerConnection, ApSetAutoConnectP1)
+{
+ bool autoconnect = TRUE;
+ wifi_manager_get_connected_ap(handle, &ap);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_set_auto_connect(ap, autoconnect));
+}
+
+TEST_F(UtcWifiManagerConnection, ApGetAutoConnectN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_auto_connect(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, ApGetAutoConnectN2)
+{
+ bool autoconnect = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connected_ap(handle, &ap));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_ap_get_auto_connect(&ap, &autoconnect));
+}
+
+/*
+ * TEST_F(UtcWifiManagerConnection, ApGetAutoConnectP1)
+{
+ bool autoconnect = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_ap_get_auto_connect(&ap, &autoconnect));
+}
+*/
+
+TEST_F(UtcWifiManagerConnection, GetConnectionModeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_connection_mode(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetConnectionModeN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_connection_mode(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerConnection, GetConnectionModeP1)
+{
+ wifi_manager_connection_mode_e mode;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_connection_mode(handle, &mode));
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "gtest-wifi-manager-util.h"
+#include "wifi-manager.h"
+#include "wifi-manager-extension.h"
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+static int g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+
+class UtcWifiManagerDpp : public ::testing::Test {
+protected:
+ wifi_manager_h handle;
+ WifiManagerTestUtil testUtil;
+ const char *name;
+ const char *passphrase;
+ wifi_manager_security_type_e security_type;
+ wifi_manager_config_h origin;
+ wifi_manager_config_h clone;
+
+ UtcWifiManagerDpp() : handle(nullptr), name("dummy"), passphrase("dummy"),
+ security_type(WIFI_MANAGER_SECURITY_TYPE_NONE), origin(nullptr), clone(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ wifi_manager_initialize(&handle);
+ mock_set_gdbus_tech_state("wlan0", true, false);
+ }
+
+ void TearDown() override
+ {
+ wifi_manager_config_destroy(origin);
+ wifi_manager_config_destroy(clone);
+
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+ }
+};
+
+
+wifi_manager_address_family_e address_family;
+
+int order = 1;
+
+TEST_F(UtcWifiManagerDpp, ConfigCreateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_create(nullptr, nullptr, nullptr, security_type, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigCreateN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_create(handle, nullptr, nullptr, security_type, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigCreateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigDestroyN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_destroy(nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigDestroyP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_save(handle, origin));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigCloneN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_clone(origin, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigCloneP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_clone(origin, &clone));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSaveN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_save(nullptr, origin));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSaveP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_save(handle, origin));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigRemoveN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_remove(nullptr, origin));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigRemoveP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_remove(handle, origin));
+}
+
+static bool __tests_foreach_config_cb(const wifi_manager_config_h config, void *user_data)
+{
+ return TRUE;
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigForeachConfigurationN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_foreach_configuration(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigForeachConfigurationN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_foreach_configuration(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigForeachConfigurationP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_foreach_configuration(handle, __tests_foreach_config_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigForeachConfigurationAllN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_foreach_configuration_in_all_interfaces(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigForeachConfigurationAllN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_foreach_configuration_in_all_interfaces(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigForeachConfigurationAllP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_foreach_configuration_in_all_interfaces(handle, __tests_foreach_config_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetNameN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_name(origin, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetNameP1)
+{
+ char *new_name = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_name(origin, &new_name));
+ free(new_name);
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetSecurityTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_security_type(origin, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetSecurityTypeP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_security_type(origin, &security_type));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetProxyAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_proxy_address(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetProxyAddressP1)
+{
+ const char *proxy_addr = "dummy";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_proxy_address(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, proxy_addr));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, wifi_manager_config_set_proxy_address(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV6, proxy_addr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetProxyAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_proxy_address(origin, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetProxyAddressP1)
+{
+ wifi_manager_address_family_e addr_family;
+ char *proxy_addr = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_proxy_address(origin, &addr_family, &proxy_addr));
+ free(proxy_addr);
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetHiddenApN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_hidden_ap_property(nullptr, true));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetHiddenApP1)
+{
+ bool hidden = true;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_hidden_ap_property(origin, hidden));
+}
+
+
+TEST_F(UtcWifiManagerDpp, ConfigGetHiddenApN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_hidden_ap_property(origin, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetHiddenApP1)
+{
+ bool hidden = true;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_hidden_ap_property(origin, &hidden));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetIpConfigTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_ip_config_type(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetIpConfigTypeP1)
+{
+ wifi_manager_ip_config_type_e type;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_ip_config_type(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &type));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetIpConfigTypeN1)
+{
+ wifi_manager_ip_config_type_e type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_ip_config_type(nullptr, address_family, type));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetIpConfigTypeP1)
+{
+ wifi_manager_ip_config_type_e type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_ip_config_type(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, type));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetIpAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_ip_address(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetIpAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_ip_address(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetIpAddressP1)
+{
+ const char *ip_addr = "192.168.0.1";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_ip_address(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, ip_addr));
+ char *ip_address = nullptr;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_ip_address(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_address));
+ free(ip_address);
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetSubnetMaskN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_subnet_mask(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetSubnetMaskN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_subnet_mask(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetSubnetMaskP1)
+{
+ const char *subnet = "255.255.255.0";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_subnet_mask(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, subnet));
+ char *sub_mask = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_subnet_mask(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &sub_mask));
+ free(sub_mask);
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetPrefixLenN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_prefix_length(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetPrefixLenP1)
+{
+ int prefix_len = 24;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_prefix_length(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &prefix_len));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetPrefixLenN1)
+{
+ int prefix_len = 24;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_prefix_length(nullptr, address_family, prefix_len));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetPrefixLenP1)
+{
+ int prefix_len = 24;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_prefix_length(origin, WIFI_MANAGER_ADDRESS_FAMILY_IPV6, prefix_len));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetGatewayAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_gateway_address(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetGatewayAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_gateway_address(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetGatewayAddressP1)
+{
+ const char *gw_addr = "192.168.0.1";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_gateway_address(origin, address_family, gw_addr));
+ char *gw_address = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_gateway_address(origin, address_family, &gw_address));
+ free(gw_address);
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetDnsConfigTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_dns_config_type(origin, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetDnsConfigTypeP1)
+{
+ wifi_manager_dns_config_type_e type;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_dns_config_type(origin, address_family, &type));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetDnsConfigTypeN1)
+{
+ wifi_manager_dns_config_type_e type = WIFI_MANAGER_DNS_CONFIG_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_dns_config_type(nullptr, address_family, type));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetDnsConfigTypeP1)
+{
+ wifi_manager_dns_config_type_e type = WIFI_MANAGER_DNS_CONFIG_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_dns_config_type(nullptr, address_family, type));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetDnsAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_dns_address(origin, order, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetDnsAddressN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_dns_address(origin, order, address_family, nullptr));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigSetDnsAddressP1)
+{
+ int order = 1;
+ const char *dns_addr = "192.168.0.1";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_dns_address(origin, order, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, dns_addr));
+ char *dns_address = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_dns_address(origin, order, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &dns_address));
+}
+
+TEST_F(UtcWifiManagerDpp, ConfigGetEapAnonymousIdentityN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_anonymous_identity(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigGetEapAnonymousIdentityP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_anonymous_identity(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigSetEapAnonymousIdentityN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_anonymous_identity(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigSetEapAnonymousIdentityP1)
+{
+ const char * identity = "";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, name, passphrase, security_type, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_eap_anonymous_identity(origin, identity));
+}
+*/
+
+TEST_F(UtcWifiManagerDpp, ConfigGetEapCaCertFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_ca_cert_file(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigGetEapCaCertFileP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_ca_cert_file(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigSetEapCaCertFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_ca_cert_file(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigSetEapCaCertFileP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_ca_cert_file(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigGetEapClientCertFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_client_cert_file(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigGetEapClientCertFileP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_client_cert_file(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigSetEapClientCertFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_client_cert_file(origin, nullptr, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigSetEapClientCertFileP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_client_cert_file(origin, nullptr, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigGetEapPrivateKeyFileN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_private_key_file(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigGetEapPrivateKeyFileP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_private_key_file(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigSetEapPrivateKeyInfoN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_private_key_info(origin, nullptr, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigSetEapPrivateKeyInfoP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_private_key_info(origin, nullptr, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigGetEapIdentityN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_identity(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigGetEapIdentityP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_identity(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigSetEapIdentityN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_identity(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigSetEapIdentityP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_identity(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigGetEapTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_type(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigGetEapTypeP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_type(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigSetEapTypeN1)
+{
+ wifi_manager_eap_type_e eap_type = WIFI_MANAGER_EAP_TYPE_PEAP;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_type(nullptr, eap_type));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigSetEapTypeP1)
+ {
+ wifi_manager_eap_type_e eap_type;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_type(nullptr, eap_type));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigGetEapAuthTypeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_auth_type(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigGetEapAuthTypeP1)
+ {
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_auth_type(origin, nullptr));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigSetEapAuthTypeN1)
+{
+ wifi_manager_eap_auth_type_e eap_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_auth_type(nullptr, eap_auth_type));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigSetEapAuthTypeP1)
+ {
+ wifi_manager_eap_auth_type_e eap_auth_type;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_auth_type(nullptr, eap_auth_type));
+ }
+ */
+
+TEST_F(UtcWifiManagerDpp, ConfigGetEapSubjectMatchN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_subject_match(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigGetEapSubjectMatchP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_eap_subject_match(origin, nullptr));
+}
+*/
+
+TEST_F(UtcWifiManagerDpp, ConfigSetEapSubjectMatchN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_subject_match(origin, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerDpp, ConfigSetEapSubjectMatchP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_eap_subject_match(origin, nullptr));
+}
+*/
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "wifi-manager.h"
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+class UtcWifiManagerInfo : public ::testing::Test {
+ protected:
+ wifi_manager_h handle;
+ UtcWifiManagerInfo() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ wifi_manager_initialize(&handle);
+ mock_set_gdbus_tech_state("wlan0", true, false);
+ //wifi_manager_activate(handle, nullptr, nullptr);
+ }
+
+ void TearDown() override
+ {
+ //wifi_manager_deactivate(handle, nullptr, nullptr);
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ }
+};
+
+
+/*
+ * static void utc_wifi_manager_activated_cb(wifi_manager_error_e result, void *user_data)
+{
+}
+
+static void utc_wifi_manager_deactivated_cb(wifi_manager_error_e result, void *user_data)
+{
+}
+*/
+
+TEST_F(UtcWifiManagerInfo, IsActivateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_is_activated(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, IsActivateN2)
+{
+ bool activated;
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_is_activated(handle, &activated));
+}
+
+TEST_F(UtcWifiManagerInfo, IsActivateN3)
+{
+ bool activated;
+ mock_set_gdbus_error_msg(ERROR_ALREADY_EXISTS);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_is_activated(handle, &activated));
+}
+
+TEST_F(UtcWifiManagerInfo, IsActivateN4)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_is_activated(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, IsActivateN5)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deinitialize(handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_INITIALIZED, wifi_manager_is_activated(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, IsActivateP1)
+{
+ bool activated;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_is_activated(handle, &activated));
+}
+
+TEST_F(UtcWifiManagerInfo, GetMACAddrP1)
+{
+ char *mac_address = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_mac_address(handle, &mac_address));
+}
+
+TEST_F(UtcWifiManagerInfo, GetMACAddrN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_mac_address(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, GetMACAddrN2)
+{
+ char *mac_address = NULL;
+ mock_set_vconf_result(false);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_get_mac_address(handle, &mac_address));
+}
+
+TEST_F(UtcWifiManagerInfo, GetMACAddrN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_mac_address(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, GetMACAddrN4)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deinitialize(handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_INITIALIZED, wifi_manager_get_mac_address(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, GetNetworkIntfNameN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_network_interface_name(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, GetNetworkIntfNameN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deinitialize(handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_INITIALIZED, wifi_manager_get_network_interface_name(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, GetNetworkIntfNameN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_network_interface_name(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, GetNetworkIntfNameP1)
+{
+ char* intf_name = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_network_interface_name(handle, &intf_name));
+}
+
+TEST_F(UtcWifiManagerInfo, Is5GhzSupportedP1)
+{
+ bool supported;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_is_5ghz_band_supported(handle, &supported));
+}
+
+TEST_F(UtcWifiManagerInfo, Is5GhzSupportedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_is_5ghz_band_supported(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, Is5GhzSupportedN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_is_5ghz_band_supported(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerInfo, Is5GhzSupportedN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deinitialize(handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_INITIALIZED, wifi_manager_is_5ghz_band_supported(handle, nullptr));
+}
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include "wifi-manager.h"
+#include "wifi-manager-extension.h"
+
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+}
+
+class UtcWifiManagerInit : public ::testing::Test {
+protected:
+ wifi_manager_h handle;
+ UtcWifiManagerInit() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ }
+
+ void TearDown() override
+ {
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ }
+};
+
+TEST_F(UtcWifiManagerInit, InitializeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_initialize(nullptr));
+}
+
+TEST_F(UtcWifiManagerInit, InitializeN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_initialize(&handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_ALREADY_INITIALIZED, wifi_manager_initialize(&handle));
+}
+
+TEST_F(UtcWifiManagerInit, InitializeN3)
+{
+ mock_set_memory_result(false);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OUT_OF_MEMORY, wifi_manager_initialize(&handle));
+}
+
+TEST_F(UtcWifiManagerInit, InitializeP)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_initialize(&handle));
+}
+
+TEST_F(UtcWifiManagerInit, DeinitializeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_deinitialize(nullptr));
+}
+
+TEST_F(UtcWifiManagerInit, DeinitializeN2)
+{
+ int garbage_memory;
+ handle = (wifi_manager_h) &garbage_memory;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NOT_INITIALIZED, wifi_manager_deinitialize(handle));
+}
+
+TEST_F(UtcWifiManagerInit, DeinitializeP)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_initialize(&handle));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_deinitialize(handle));
+}
+
+TEST_F(UtcWifiManagerInit, Initialize_with_ifnameN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_initialize_with_interface_name(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerInit, Initialize_with_ifnameN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_initialize_with_interface_name(&handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerInit, Initialize_with_ifnameN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_initialize_with_interface_name(&handle, "wlan0"));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_ALREADY_INITIALIZED, wifi_manager_initialize_with_interface_name(&handle, "wlan0"));
+}
+
+TEST_F(UtcWifiManagerInit, Initialize_with_ifnameN4)
+{
+ mock_set_memory_result(false);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OUT_OF_MEMORY, wifi_manager_initialize_with_interface_name(&handle, "wlan0"));
+}
+
+TEST_F(UtcWifiManagerInit, Initialize_with_ifnameP)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_initialize_with_interface_name(&handle, "wlan0"));
+}
+
+TEST_F(UtcWifiManagerInit, InitializeCsN1)
+{
+ int tid = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_initialize_cs(tid, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerInit, InitializeCsP)
+{
+ int tid = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_initialize_cs(tid, nullptr));
+}
+*/
+
+/*
+ * TEST_F(UtcWifiManagerInit, DeInitializeCsN1)
+{
+ int tid = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_deinitialize_cs(tid, nullptr));
+}
+*/
+
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "gtest-wifi-manager-util.h"
+#include "wifi-manager.h"
+#include <wifi-manager-extension.h>
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+static int g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+
+class UtcWifiManagerScan : public ::testing::Test {
+ protected:
+ wifi_manager_h handle;
+ WifiManagerTestUtil testUtil;
+
+ UtcWifiManagerScan() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ wifi_manager_initialize(&handle);
+ mock_set_gdbus_tech_state("wlan0", true, false);
+ }
+
+ void TearDown() override
+ {
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+ }
+};
+
+wifi_manager_autoscan_mode_e mode;
+
+wifi_manager_netlink_scan_h netlink_scan;
+
+wifi_manager_specific_scan_h specific_scan = NULL;
+
+void scan_finished_cb (wifi_manager_error_e error_code, void *user_data)
+{
+ g_nCallbackRet = error_code;
+}
+
+void scan_state_cb(wifi_manager_scan_state_e state, void *user_data)
+{
+}
+
+void set_background_scan_cb (wifi_manager_error_e error_code, void *user_data)
+{
+ g_nCallbackRet = error_code;
+}
+
+void bssid_scan_finished_cb(wifi_manager_error_e error_code, void *user_data)
+{
+ g_nCallbackRet = error_code;
+}
+
+bool interface_cb(char *ifname, void *user_data)
+{
+ return true;
+}
+
+static bool found_ap_cb(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_manager_connection_state_e state;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ return false;
+ }
+
+ rv = wifi_manager_ap_get_connection_state(ap, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+
+ return true;
+}
+
+TEST_F(UtcWifiManagerScan, GetScanStateP1)
+{
+ wifi_manager_scan_state_e scan_state;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_scan_state(handle, &scan_state));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanStateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_scan_state(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanStateN2)
+{
+ wifi_manager_scan_state_e scan_state;
+ mock_set_gdbus_result(false);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_get_scan_state(handle, &scan_state));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanStateN4)
+{
+ wifi_manager_scan_state_e scan_state;
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_get_scan_state(handle, &scan_state));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanStateN5)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_scan_state(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan(handle, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_scan(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanN2)
+{
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_scan(handle, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanN3)
+{
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_scan(handle, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetScanN4)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan(handle, scan_finished_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerScan, GetScanN5)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan(handle, scan_finished_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_NOW_IN_PROGRESS);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerScan, GetScanN6)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan(handle, scan_finished_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_FAIL_DEVICE_BUSY);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerScan, GetScanN7)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_scan(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetSpecificP1)
+{
+ const char essid = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan_specific_ap(handle, &essid, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetSpecificN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_scan_specific_ap(handle, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetSpecificN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_scan_specific_ap(nullptr, nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetSpecificN3)
+{
+ const char essid = 'a';
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_OPERATION, wifi_manager_scan_specific_ap(handle, &essid, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetSpecificN4)
+{
+ const char essid = 'a';
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_scan_specific_ap(handle, &essid, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetSpecificN5)
+{
+ const char essid = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan_specific_ap(handle, &essid, scan_finished_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerScan, GetSpecificN6)
+{
+ const char essid = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan_specific_ap(handle, &essid, scan_finished_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_NOW_IN_PROGRESS);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerScan, GetSpecificN7)
+{
+ const char essid = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan_specific_ap(handle, &essid, scan_finished_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_FAIL_DEVICE_BUSY);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerScan, ForeachAvailIN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_available_interface(nullptr, nullptr, nullptr));
+}
+
+ TEST_F(UtcWifiManagerScan, ForeachAvailIN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_available_interface(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachAvailIP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_foreach_available_interface(handle, interface_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundApN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_ap(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundApN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_ap(handle, nullptr, nullptr));
+}
+
+#if 0 //enable once fix in wifi_manager code
+TEST_F(UtcWifiManagerScan, ForeachFoundApN3)
+{
+ mock_set_gdbus_error_msg(ERROR_NULL);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_foreach_found_ap(handle, found_ap_cb, nullptr));
+}
+#endif
+
+TEST_F(UtcWifiManagerScan, ForeachFoundApP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_foreach_found_ap(handle, found_ap_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundAllN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_ap_in_all_interfaces(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetFrequencyN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_get_frequency(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetFrequencyN1)
+{
+ int frequency = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_config_set_frequency(nullptr, frequency));
+}
+
+/*
+ * TEST_F(UtcWifiManagerScan, SetFrequencyP1)
+{
+ wifi_manager_config_h origin;
+ const char name = '1';
+ const char passphrase = '1';
+ int frequency = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_create(handle, &name, &passphrase, WIFI_MANAGER_SECURITY_TYPE_NONE, &origin));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_set_frequency(origin, frequency));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_config_get_frequency(origin, &frequency));
+}
+*/
+
+TEST_F(UtcWifiManagerScan, ForeachFoundAllN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_ap_in_all_interfaces(handle, nullptr, nullptr));
+}
+
+#if 0 //enable once fix in wifi_manager code
+TEST_F(UtcWifiManagerScan, ForeachFoundAllN3)
+{
+ mock_set_gdbus_error_msg(ERROR_NULL);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_foreach_found_ap_in_all_interfaces(handle, found_ap_cb, nullptr));
+}
+#endif
+
+TEST_F(UtcWifiManagerScan, ForeachFoundAllP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_foreach_found_ap_in_all_interfaces(handle, found_ap_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundSpecificN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_specific_ap(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundSpecificN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_specific_ap(handle, nullptr, nullptr));
+}
+
+#if 0 //enable once fix in wifi_manager code
+TEST_F(UtcWifiManagerScan, ForeachFoundSpecificN3)
+{
+ mock_set_gdbus_error_msg(ERROR_NULL);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_foreach_found_specific_ap(handle, found_ap_cb, nullptr));
+}
+#endif
+
+TEST_F(UtcWifiManagerScan, ForeachFoundSpecificP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_foreach_found_specific_ap(handle, found_ap_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundBssidN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_bssid_ap(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundBssidN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_bssid_ap(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundBssidP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_foreach_found_bssid_ap(handle, found_ap_cb, nullptr));
+}
+
+
+#if 0 //enable once fix in wifi_manager code
+TEST_F(UtcWifiManagerScan, ForeachFoundBssidN3)
+{
+ mock_set_gdbus_error_msg(ERROR_NULL);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_foreach_found_bssid_ap(handle, found_ap_cb, nullptr));
+}
+#endif
+
+TEST_F(UtcWifiManagerScan, ForeachFoundNetlinkN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_netlink_scan_ap(nullptr, nullptr, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerScan, ForeachFoundNetlinkP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_foreach_found_netlink_scan_ap(handle, found_ap_cb, nullptr));
+}
+*/
+
+TEST_F(UtcWifiManagerScan, ForeachFoundNetlinkN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_foreach_found_netlink_scan_ap(handle, found_ap_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ForeachFoundNetlinkN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_foreach_found_netlink_scan_ap(handle, nullptr, nullptr));
+}
+
+#if 0 //enable once fix in wifi_manager code
+TEST_F(UtcWifiManagerScan, ForeachFoundNetlinkN3)
+{
+ mock_set_gdbus_error_msg(ERROR_NULL);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_foreach_found_netlink_scan_ap(handle, found_ap_cb, nullptr));
+}
+#endif
+
+TEST_F(UtcWifiManagerScan, NetlinkScanN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_netlink_scan(nullptr, netlink_scan, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_netlink_scan(handle, netlink_scan, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanN3)
+{
+ EXPECT_EQ(-38, wifi_manager_netlink_scan(handle, netlink_scan, scan_finished_cb, nullptr));
+}
+
+/*
+ * TEST_F(UtcWifiManagerScan, NetlinkScanP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_netlink_scan(handle, netlink_scan, scan_finished_cb, nullptr));
+}
+*/
+
+TEST_F(UtcWifiManagerScan, ScanSpecificApN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_scan_specific_ap(handle, nullptr, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ScanSpecificApN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_scan_specific_ap(handle, nullptr, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ScanSpecificApN3)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan_specific_ap(handle, "TEMP_AP1", scan_finished_cb, nullptr));
+ mock_set_gdbus_error_msg(ERROR_SECURITY_RESTRICTED);
+ testUtil.runMainLoop();
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, g_nCallbackRet);
+}
+
+TEST_F(UtcWifiManagerScan, ScanSpecificApN4)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_scan_specific_ap(nullptr, nullptr, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ScanSpecificApP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_scan_specific_ap(handle, "TEMP_AP1", scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetBackgroundScanCbN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_background_scan_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetBackgroundScanCbN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_background_scan_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetBackgroundScanCbP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_background_scan_cb(handle, scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, UnSetBackgroundScanCbN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_background_scan_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, UnSetBackgroundScanCbP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_background_scan_cb(handle));
+}
+
+TEST_F(UtcWifiManagerScan, SetScanStateChangedCbN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_scan_state_changed_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetScanStateChangedCbN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_scan_state_changed_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetScanStateChangedCbP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_scan_state_changed_cb(handle, scan_state_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, UnSetScanStateChangedCbP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_scan_state_changed_cb(handle));
+}
+
+TEST_F(UtcWifiManagerScan, UnSetScanStateChangedCbN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_scan_state_changed_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetAutoScanP1)
+{
+ mock_set_gdbus_error_msg(ERROR_NONE);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_autoscan(handle, true));
+}
+
+TEST_F(UtcWifiManagerScan, SetAutoScanN1)
+{
+ mock_set_gdbus_error_msg(ERROR_PERMISSION_DENIED);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_PERMISSION_DENIED, wifi_manager_set_autoscan(handle, true));
+}
+
+TEST_F(UtcWifiManagerScan, SetAutoScanN2)
+{
+ mock_set_gdbus_error_msg(ERROR_FAIL_DEVICE_BUSY);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_OPERATION_FAILED, wifi_manager_set_autoscan(handle, true));
+}
+
+TEST_F(UtcWifiManagerScan, SetBkgScanN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_background_scan_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetBkgScanN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_background_scan_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetBkgScanP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_background_scan_cb(handle, set_background_scan_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, UnsetBkgScanN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_background_scan_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, UnsetBkgScanP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_background_scan_cb(handle));
+}
+
+TEST_F(UtcWifiManagerScan, ScanStateChangeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_scan_state_changed_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ScanStateChangeN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_scan_state_changed_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, ScanStateChangeP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_scan_state_changed_cb(handle, scan_state_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, UnsetScanStateChangeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_unset_scan_state_changed_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, UnsetScanStateChangeP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_unset_scan_state_changed_cb(handle));
+}
+
+TEST_F(UtcWifiManagerScan, SetAutoScanModeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_autoscan_mode(nullptr, mode));
+}
+
+TEST_F(UtcWifiManagerScan, GetAutoScanN1)
+{
+ bool autoscan = TRUE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_autoscan(nullptr, &autoscan));
+}
+
+TEST_F(UtcWifiManagerScan, GetAutoScanN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_autoscan(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetAutoScanP1)
+{
+ bool autoscan = FALSE;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_autoscan(handle, &autoscan));
+}
+
+TEST_F(UtcWifiManagerScan, GetAutoScanModeN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_autoscan_mode(nullptr, &mode));
+}
+
+TEST_F(UtcWifiManagerScan, GetAutoScanModeN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_autoscan_mode(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, GetAutoScanModeP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_autoscan_mode(handle, &mode));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_autoscan_mode(handle, mode));
+}
+
+TEST_F(UtcWifiManagerScan, BssidScanN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_bssid_scan(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, BssidScanN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_bssid_scan(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, BssidScanP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_bssid_scan(handle, bssid_scan_finished_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, FlushBssN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_flush_bss(nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, FlushBssP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_flush_bss(handle));
+}
+
+TEST_F(UtcWifiManagerScan, SetBssidN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_bssid(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetBssidN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_set_bssid(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SetBssidP1)
+{
+ char bssid = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_set_bssid(handle, &bssid));
+}
+
+
+TEST_F(UtcWifiManagerScan, NetlinkScanCreateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_netlink_scan_create(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanCreateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_netlink_scan_create(handle, &netlink_scan));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanDestroyN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_netlink_scan_destroy(nullptr, netlink_scan));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanDestroyP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_netlink_scan_create(handle, &netlink_scan));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_netlink_scan_destroy(handle, netlink_scan));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanSetSsidN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_netlink_scan_set_ssid(netlink_scan, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanSetSsidP1)
+{
+ const char essid = 'a';
+ wifi_manager_netlink_scan_create(handle, &netlink_scan);
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_netlink_scan_set_ssid(netlink_scan, &essid));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanSetVsieN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_netlink_scan_set_vsie(netlink_scan, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanSetVsieP1)
+{
+ const char* essid = "ddcdefghijklm";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_netlink_scan_set_vsie(netlink_scan, essid));
+}
+
+TEST_F(UtcWifiManagerScan, NetlinkScanSetVsieN2)
+{
+ const char* essid = "abcdefghijklm";
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_netlink_scan_set_vsie(netlink_scan, essid));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanCreateN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_specific_scan_create(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanCreateP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_specific_scan_create(handle, &specific_scan));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanDestroyN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_specific_scan_destroy(nullptr, specific_scan));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanDestroyP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_specific_scan_create(handle, &specific_scan));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_specific_scan_destroy(handle, specific_scan));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanGetMaxSsidN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_specific_scan_get_max_ssids(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanGetMaxSsidN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_specific_scan_get_max_ssids(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanGetMaxSsidP1)
+{
+ int max_scan_ssids = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_specific_scan_get_max_ssids(handle, &max_scan_ssids));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanSetSsidN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_specific_scan_set_ssid(specific_scan, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanSetSsidP1)
+{
+ const char essid = 'a';
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_specific_scan_create(handle, &specific_scan));
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_specific_scan_set_ssid(specific_scan, &essid));
+}
+
+TEST_F(UtcWifiManagerScan, SpecificScanSetFreqP1)
+{
+ int freq = 1;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_specific_scan_set_freq(specific_scan, freq));
+}
+
+TEST_F(UtcWifiManagerScan, StartMultiScanN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_specific_ap_start_multi_scan(nullptr, specific_scan, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, StartMultiScanN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_specific_ap_start_multi_scan(handle, specific_scan, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerScan, StartMultiScanP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_specific_ap_start_multi_scan(handle, specific_scan, scan_finished_cb, nullptr));
+}
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "gtest-wifi-manager-util.h"
+#include "wifi-manager.h"
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+static int g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+
+class UtcWifiManagerTdls : public ::testing::Test {
+protected:
+ wifi_manager_h handle;
+ WifiManagerTestUtil testUtil;
+
+ UtcWifiManagerTdls() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ mock_set_gdbus_tech_state("wlan0", true, false);
+ wifi_manager_initialize(&handle);
+ }
+
+ void TearDown() override
+ {
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+ }
+};
+
+static void __tdls_discovered_cb(wifi_manager_tdls_discovery_state_e state,
+ char *peer_mac_addr, void *user_data)
+{
+}
+
+static void __tdls_state_changed_cb(wifi_manager_tdls_state_e state,
+ char *peer_mac_addr, void *user_data)
+{
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsSetDiscoveredN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_set_discovered_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsSetDiscoveredN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_set_discovered_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsSetDiscoveredP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_set_discovered_cb(handle, __tdls_discovered_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsUnsetDiscoveredN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_unset_discovered_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsUnsetDiscoveredP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE,wifi_manager_tdls_unset_discovered_cb(handle));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsStartDiscoveryN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_start_discovery(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsStartDiscoveryN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_start_discovery(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsStartDiscoveryP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_start_discovery(handle, "11:22:33:44:55:66"));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsConnectN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_connect(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsConnectN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_connect(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsConnectP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_connect(handle, "11:22:33:44:55:66"));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsDisconnectN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_disconnect(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsDisconnectN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_disconnect(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsDisconnectP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_disconnect(handle, "11:22:33:44:55:66"));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsGetConnectedPeerN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_get_connected_peer(nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsGetConnectedPeerN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_get_connected_peer(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsGetConnectedPeerP1)
+{
+ char *peer = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_get_connected_peer(handle, &peer));
+ free(peer);
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsSetStateChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_set_state_changed_cb(nullptr, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsSetStateChangedN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_set_state_changed_cb(handle, nullptr, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsSetStateChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_set_state_changed_cb(handle, __tdls_state_changed_cb, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsUnsetStateChangedN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_unset_state_changed_cb(nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsUnsetStateChangedP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_unset_state_changed_cb(handle));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsEnableChannelSwitchingN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_enable_channel_switching(nullptr, nullptr, 1));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsEnableChannelSwitchingN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_enable_channel_switching(handle, nullptr, 1));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsEnableChannelSwitchingP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_enable_channel_switching(handle, "11:22:33:44:55:66", 2412));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsDisableChannelSwitchingN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_disable_channel_switching(nullptr,nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsDisableChannelSwitchingN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_tdls_disable_channel_switching(handle, nullptr));
+}
+
+TEST_F(UtcWifiManagerTdls, TdlsDisableChannelSwitchingP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_tdls_disable_channel_switching(handle, "11:22:33:44:55:66"));
+}
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "gtest-wifi-manager-util.h"
+
+#include <glib.h>
+#include<stdio.h>
+#include <glib-object.h>
+extern "C" {
+#include "mocks/mock_gdbus.h"
+};
+
+WifiManagerTestUtil::WifiManagerTestUtil(void) : testType(WIFIMANAGER_TEST_UTIL_MAX), mainLoop(NULL), timeoutId(0)
+{
+}
+
+WifiManagerTestUtil::~WifiManagerTestUtil(void)
+{
+}
+
+void WifiManagerTestUtil::setTestType(int type)
+{
+ testType = type;
+}
+
+int WifiManagerTestUtil::getTestType(void)
+{
+ return testType;
+}
+
+void WifiManagerTestUtil::runMainLoop(void)
+{
+ mainLoop = g_main_loop_new(NULL, false);
+ timeoutId = g_timeout_add(10, WifiManagerTestUtil::timeoutCallback, this);
+ g_main_loop_run(mainLoop);
+}
+
+void WifiManagerTestUtil::stopMainLoop(void)
+{
+ if (mainLoop)
+ g_main_loop_quit(mainLoop);
+
+ if (timeoutId)
+ g_source_remove(timeoutId);
+}
+
+gboolean WifiManagerTestUtil::timeoutCallback(gpointer user_data)
+{
+ WifiManagerTestUtil *util = (WifiManagerTestUtil *)user_data;
+ //int type = util->getTestType();
+ mock_invoke_gdbus_async_callback();
+ util->stopMainLoop();
+
+ return FALSE;
+}
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+#include <glib.h>
+#define WIFIMANAGER_TEST_UTIL_MAX 10
+
+class WifiManagerTestUtil
+{
+public:
+ WifiManagerTestUtil(void);
+ ~WifiManagerTestUtil();
+
+ void runMainLoop(void);
+ void setTestType(int type);
+ int getTestType(void);
+
+private:
+ int testType;
+ GMainLoop *mainLoop;
+ guint timeoutId;
+
+ void stopMainLoop(void);
+
+ static gboolean timeoutCallback(gpointer user_data);
+};
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include<stdio.h>
+#include <gtest/gtest.h>
+
+#include "gtest-wifi-manager-util.h"
+#include "wifi-manager.h"
+#include <wifi-manager-extension.h>
+extern "C" {
+#include "mocks/mock_system_info.h"
+#include "mocks/mock_memory.h"
+#include "mocks/mock_gdbus.h"
+#include "mocks/mock_vconf.h"
+}
+
+static int g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+
+class UtcWifiManagerVsie : public ::testing::Test {
+protected:
+ wifi_manager_h handle;
+ WifiManagerTestUtil testUtil;
+
+ UtcWifiManagerVsie() : handle(nullptr)
+ {
+ }
+
+ void SetUp() override
+ {
+ mock_set_system_info_result(true);
+ mock_set_memory_result(true);
+ mock_set_gdbus_result(true);
+ mock_set_vconf_result(true);
+ wifi_manager_initialize(&handle);
+ mock_set_gdbus_tech_state("wlan0", true, false);
+ }
+
+ void TearDown() override
+ {
+ wifi_manager_deinitialize(handle);
+ mock_set_system_info_result(false);
+ mock_set_memory_result(false);
+ mock_set_gdbus_result(false);
+ mock_set_vconf_result(false);
+ mock_set_gdbus_tech_state("wlan0", false, false);
+ g_nCallbackRet = WIFI_MANAGER_ERROR_NONE;
+ }
+};
+
+TEST_F(UtcWifiManagerVsie, AddVsieN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_add_vsie(nullptr, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, nullptr));
+}
+
+TEST_F(UtcWifiManagerVsie, AddVsieN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_add_vsie(handle, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, nullptr));
+}
+
+
+TEST_F(UtcWifiManagerVsie, AddVsieP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_add_vsie(handle, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, "dummy_vsie"));
+}
+
+
+TEST_F(UtcWifiManagerVsie, GetVsieN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_vsie(nullptr, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, nullptr));
+}
+
+TEST_F(UtcWifiManagerVsie, GetVsieN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_get_vsie(handle, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, nullptr));
+}
+
+
+TEST_F(UtcWifiManagerVsie, GetVsieP1)
+{
+ char *vsie_str = NULL;
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_get_vsie(handle, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, &vsie_str));
+ free(vsie_str);
+}
+
+
+TEST_F(UtcWifiManagerVsie, RemoveVsieN1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_remove_vsie(nullptr, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, nullptr));
+}
+
+TEST_F(UtcWifiManagerVsie, RemoveVsieN2)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_INVALID_PARAMETER, wifi_manager_remove_vsie(handle, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, nullptr));
+}
+
+
+TEST_F(UtcWifiManagerVsie, RemoveVsieP1)
+{
+ EXPECT_EQ(WIFI_MANAGER_ERROR_NONE, wifi_manager_remove_vsie(handle, WIFI_MANAGER_VSIE_FRAME_PROBE_REQ, "dummy_vsie"));
+}
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gtest/gtest.h>
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * TODO: Add logic to methodcall and it's mock reply.
+ * TODO: Add logic to emit mock signals.
+ */
+
+#include<stdio.h>
+#include "mock_gdbus.h"
+
+#include <stdbool.h>
+#include <gio/gio.h>
+
+static bool mock_gdbus_result;
+static bool mock_gdbus_devicePolicy;
+static bool mock_gdbus_powered;
+#define MOCK_TECH_COUNT_MAX 2
+#define MOCK_SERVICES_COUNT_MAX 2
+#define ERROR_DOMAIN 5
+#define ERROR_CODE 10
+
+typedef struct {
+ GAsyncReadyCallback callback;
+ gpointer user_data;
+ const char *method_name;
+} gdbus_async_callback_info_s;
+
+#if 0
+typedef struct {
+ GDBusSignalCallback callback;
+ gpointer user_data;
+} gdbus_signal_callback_info_s;
+
+
+static const char *gdbus_signal_list[WIFI_MOCK_GDBUS_SIGNAL_MAX] = {
+ [WIFI_MOCK_GDBUS_SIGNAL_STATE_CHANGED_PROPERTIES] = "StateChangedPropertie",
+ [WIFI_MOCK_GDBUS_SIGNAL_PROPERTY_CHANGED] = "PropertyChanged",
+ [WIFI_MOCK_GDBUS_SIGNAL_SCAN_CHANGED] = "ScanChanged",
+ [WIFI_MOCK_GDBUS_SIGNAL_SCAN_DONE] = "ScanDone",
+};
+
+static gdbus_signal_callback_info_s gdbus_signal_callbacks[WIFI_MOCK_GDBUS_SIGNAL_MAX] = {
+ {NULL, NULL}, {NULL, NULL}, {NULL, NULL}, {NULL, NULL} }; // {NULL, NULL},
+ // {NULL, NULL}, {NULL, NULL}, {NULL, NULL}, {NULL, NULL} };
+
+#endif
+static gdbus_async_callback_info_s gdbus_async_callback = {NULL, NULL};
+
+typedef struct {
+ const char *ifname;
+ const char *mac_address;
+ gboolean powered;
+ gboolean connected;
+} mock_gdbus_tech_s;
+
+typedef struct {
+ const char *EncryptionMode;
+ const char *State;
+ const char *Name;
+ const char *Interface;
+ const char *BssId;
+} mock_gdbus_services_s;
+
+char *err_msg[ERROR_MAX] = {"", "PermissionDenied", "AccessDenied", "AlreadyExists", "InProgress", "Device or resource busy", "NULL" };
+static int err_no;
+
+mock_gdbus_tech_s mock_tech[MOCK_TECH_COUNT_MAX] = {
+ {"wlan0", "11:22:33:44:55:66", 0, 0},
+ {"wlan1", "66:55:44:33:22:11", 0, 0}
+};
+
+mock_gdbus_services_s mock_services[MOCK_SERVICES_COUNT_MAX] = {
+ {"wep", "ready", "TEMP_AP1", "wlan0", "11:22:33:44:55:66"},
+ {"aes", "ready", "TEMP_AP2", "wlan0", "11:22:33:44:55:66"}
+};
+
+void mock_set_gdbus_tech_state(const char *ifname, bool powered, bool connected)
+{
+ for (int i = 0; i < MOCK_TECH_COUNT_MAX; i++) {
+ if (g_strcmp0(mock_tech[i].ifname, ifname) != 0)
+ continue;
+
+ mock_tech[i].powered = powered;
+ mock_tech[i].connected = connected;
+ break;
+ }
+}
+
+void mock_set_gdbus_error_msg(int error)
+{
+ err_no = error;
+}
+
+static GVariant * __get_mock_variant_get_technologies(void)
+{
+ GVariant *return_parameter;
+ GVariantBuilder *builder_technologies = g_variant_builder_new(G_VARIANT_TYPE("a(oa{sv})"));;
+ GVariantBuilder *builder_technology = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ GVariantBuilder *deviceList = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ const gchar *object_path = "/net/connman/technology/wifi";
+
+ // TODO: fill technology data
+ g_variant_builder_add(builder_technology, "{sv}", "Name", g_variant_new_string("WiFi"));
+ g_variant_builder_add(builder_technology, "{sv}", "Type", g_variant_new_string("wifi"));
+ g_variant_builder_add(builder_technology, "{sv}", "Tethering", g_variant_new_boolean(FALSE));
+ g_variant_builder_add(builder_technology, "{sv}", "Powered", g_variant_new_boolean(TRUE));
+ g_variant_builder_add(builder_technology, "{sv}", "Connected", g_variant_new_boolean(FALSE));
+
+ for (int i = 0; i < MOCK_TECH_COUNT_MAX; i++) {
+
+ g_variant_builder_add(deviceList, "{sv}", "Ifname", g_variant_new_string(mock_tech[i].ifname));
+ g_variant_builder_add(deviceList, "{sv}", "Powered", g_variant_new_boolean(mock_tech[i].powered));
+ g_variant_builder_add(deviceList, "{sv}", "Connected", g_variant_new_boolean(mock_tech[i].connected));
+ g_variant_builder_add(deviceList, "{sv}", "MAC.Address", g_variant_new_string(mock_tech[i].mac_address));
+ }
+
+ g_variant_builder_add(builder_technology, "{sv}", "Device.List", g_variant_builder_end(deviceList));
+
+ g_variant_builder_add(builder_technologies, "(oa{sv})", object_path, builder_technology);
+
+ return_parameter = g_variant_new("(a(oa{sv}))", builder_technologies);
+
+
+ g_variant_builder_unref(deviceList);
+ g_variant_builder_unref(builder_technology);
+ g_variant_builder_unref(builder_technologies);
+
+ return return_parameter;
+}
+
+static GVariant * __get_mock_variant_get_DevicePolicyGetWifi(void)
+{
+ GVariant *value;
+ if (mock_gdbus_devicePolicy)
+ value = g_variant_new("(i)", 0);
+ else
+ value = g_variant_new("(i)", 1);
+
+ return value;
+}
+
+static GVariant * __get_mock_variant_int(void)
+{
+ return g_variant_new("(i)", 0);
+}
+
+static GVariant * __get_mock_variant_uint(void)
+{
+ return g_variant_new("(u)", 1);
+}
+
+static GVariant * __get_mock_variant_bool(void)
+{
+ return g_variant_new("(b)", TRUE);
+}
+
+static GVariant * __get_mock_variant_get_scanstate(void)
+{
+ GVariant *value;
+ GVariantBuilder *scanstate = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ //g_variant_builder_add(scanstate, "{sv}", g_variant_new_string(mock_tech[0].ifname), g_variant_new_boolean(FALSE));
+ g_variant_builder_add(scanstate, "{sv}", "wlan0", g_variant_new_boolean(FALSE));
+ value = g_variant_new("(a{sv})", scanstate);
+ return value;
+}
+
+static GVariant * __get_mock_variant_get_services(void)
+{
+ GVariant *return_parameter;
+ GVariantBuilder *builder_services = g_variant_builder_new(G_VARIANT_TYPE("a(oa{sv})"));;
+ int i = 0;
+ for (i = 0; i < MOCK_SERVICES_COUNT_MAX; i++) {
+ GVariantBuilder *builder_service = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ GVariantBuilder *builder_eth = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ const gchar *object_path = "/net/connman/service/wifi_112233445566_496e6672612d36412d33_managed_psk";
+
+ // TODO: fill service data
+ g_variant_builder_add(builder_service, "{sv}", "EncryptionMode", g_variant_new_string(mock_services[i].EncryptionMode));
+ g_variant_builder_add(builder_service, "{sv}", "BSSID", g_variant_new_string(mock_services[i].BssId));
+ g_variant_builder_add(builder_service, "{sv}", "State", g_variant_new_string(mock_services[i].State));
+ g_variant_builder_add(builder_service, "{sv}", "Name", g_variant_new_string(mock_services[i].Name));
+
+ g_variant_builder_add(builder_eth, "{sv}", "Interface", g_variant_new_string(mock_services[i].Interface));
+
+ g_variant_builder_add(builder_service, "{sv}", "Ethernet", g_variant_builder_end(builder_eth));
+ g_variant_builder_add(builder_services, "(oa{sv})", object_path, builder_service);
+ g_variant_builder_unref(builder_service);
+ g_variant_builder_unref(builder_eth);
+ }
+ return_parameter = g_variant_new("(a(oa{sv}))", builder_services);
+
+ //g_variant_builder_unref(builder_service);
+ g_variant_builder_unref(builder_services);
+
+ return return_parameter;
+}
+
+static GVariant * __get_mock_variant_get_properties(void)
+{
+ return NULL;
+}
+
+static GVariant * __get_mock_variant_get_interfaces(void)
+{
+ const gchar *interface_name = "wlan0";
+ GVariantBuilder *builder_interfaces = g_variant_builder_new(G_VARIANT_TYPE("as"));
+
+ g_variant_builder_add(builder_interfaces, "s", interface_name);
+
+ return g_variant_new("(as)", builder_interfaces);
+}
+
+static GVariant * __get_mock_variant_string(void)
+{
+ return g_variant_new("(s)", "dummy");
+}
+
+void mock_set_gdbus_result(bool value)
+{
+ mock_gdbus_result = value;
+}
+
+void mock_set_gdbus_devicePolicy(bool value)
+{
+ mock_gdbus_devicePolicy = value;
+}
+
+void mock_set_gdbus_powered(bool value)
+{
+ mock_gdbus_powered = value;
+}
+
+GCancellable *__wrap_g_cancellable_new(void)
+{
+ if (mock_gdbus_result == false)
+ return NULL;
+
+ return (GCancellable *)g_object_new(G_TYPE_CANCELLABLE, NULL);
+}
+
+GDBusConnection *__wrap_g_bus_get_sync(GBusType bus_type, GCancellable *cancellable, GError **error)
+{
+ if (mock_gdbus_result == false)
+ return NULL;
+
+ return (GDBusConnection *)g_object_new(G_TYPE_DBUS_CONNECTION, NULL);
+}
+
+typedef GVariant * (*g_dbus_reply_fn)(void);
+
+typedef struct {
+ const char *method_name;
+ g_dbus_reply_fn fn;
+} method_call_reply_s;
+
+method_call_reply_s g_dbus_reply[] = {
+ {"GetTechnologies", __get_mock_variant_get_technologies},
+ {"GetServices", __get_mock_variant_get_services},
+ {"GetProperties", __get_mock_variant_get_properties},
+ {"GetInterfaces", __get_mock_variant_get_interfaces},
+ {"DevicePolicyGetWifi", __get_mock_variant_get_DevicePolicyGetWifi},
+ {"GetScanState", __get_mock_variant_get_scanstate},
+ {"IpConflictSetEnable", __get_mock_variant_int},
+ {"SetIpConflictPeriod", __get_mock_variant_int},
+ {"GetIpConflictPeriod", __get_mock_variant_uint},
+ {"GetIpConflictState", __get_mock_variant_uint},
+ {"SetProperty", __get_mock_variant_int},
+ {"GetAutoscan", __get_mock_variant_bool},
+ {"GetAutoscanmode", __get_mock_variant_uint},
+ {"FlushBss", __get_mock_variant_int},
+ {"CheckGetPrivilege", __get_mock_variant_int},
+ {"GetMaxScanSsid", __get_mock_variant_get_scanstate},
+ {"Get5GhzSupported", __get_mock_variant_get_scanstate},
+ {"ResumeBgscan", __get_mock_variant_string},
+ {"PauseBgscan", __get_mock_variant_string},
+ {"AddVsie", __get_mock_variant_string},
+ {"GetVsie", __get_mock_variant_string},
+ {"RemoveVsie", __get_mock_variant_string},
+ {"TdlsDiscover", __get_mock_variant_int},
+ {"TdlsConnect", __get_mock_variant_int},
+ {"TdlsDisconnect", __get_mock_variant_int},
+ {"TdlsConnectedPeer", __get_mock_variant_string},
+ {"SetBgscan", __get_mock_variant_int},
+ {"SaveConfiguration", __get_mock_variant_int},
+ {"SaveEapConfiguration", __get_mock_variant_int},
+ {"TdlsChannelSwitch", __get_mock_variant_int},
+ {"TdlsCancelChannelSwitch", __get_mock_variant_int},
+ {"LoadConfiguration", __get_mock_variant_get_scanstate},
+ {"GetConfigIds", __get_mock_variant_get_interfaces},
+ {NULL, NULL}
+};
+
+GVariant *__wrap_g_dbus_connection_call_sync(GDBusConnection *connection,
+ const gchar *bus_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ const GVariantType *reply_type,
+ GDBusCallFlags flags,
+ gint timeout_msec,
+ GCancellable *cancellable,
+ GError **error)
+{
+ if (mock_gdbus_result == false)
+ return NULL;
+
+ if (err_no) {
+ g_set_error(error, ERROR_DOMAIN, ERROR_CODE, "error message %s", err_msg[err_no]);
+ err_no = ERROR_NONE;
+ return NULL;
+ }
+
+ for (int i = 0; g_dbus_reply[i].method_name; i++)
+ if (!g_strcmp0(g_dbus_reply[i].method_name, method_name))
+ return g_dbus_reply[i].fn();
+
+ return NULL;
+}
+
+void __wrap_g_dbus_connection_call(GDBusConnection *connection,
+ const gchar *bus_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ const GVariantType *reply_type,
+ GDBusCallFlags flags,
+ gint timeout_msec,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ if (mock_gdbus_result == false)
+ return;
+
+ gdbus_async_callback.callback = callback;
+ gdbus_async_callback.user_data = user_data;
+ gdbus_async_callback.method_name = method_name;
+
+ return;
+}
+
+GVariant * __wrap_g_dbus_connection_call_finish(GDBusConnection *connection,
+ GAsyncResult *res,
+ GError **error)
+{
+ GVariant *params = NULL;
+ const char *method_name = gdbus_async_callback.method_name;
+ if (mock_gdbus_result == false)
+ return NULL;
+ if ((strcmp(method_name, "LoadDriver") == 0) || (strcmp(method_name, "RemoveDriver") == 0)) {
+ if (!g_strcmp0("", err_msg[err_no]))
+ error = NULL;
+ else
+ g_set_error(error, ERROR_DOMAIN, ERROR_CODE, "error message %s", err_msg[err_no]);
+ params = g_variant_new("(u)", 0);
+ } else if (strcmp(method_name, "ScanDevice") == 0) {
+ g_set_error(error, ERROR_DOMAIN, ERROR_CODE, "error message %s", err_msg[err_no]);
+ params = g_variant_new("(u)", 0);
+ } else if (strcmp(method_name, "SpecificScan") == 0) {
+ g_set_error(error, ERROR_DOMAIN, ERROR_CODE, "error message %s", err_msg[err_no]);
+ params = g_variant_new("(u)", 0);
+ }
+
+ gdbus_async_callback.callback = NULL;
+ gdbus_async_callback.user_data = NULL;
+ gdbus_async_callback.method_name = NULL;
+ err_no = ERROR_NONE;
+
+ return params;
+}
+
+void mock_invoke_gdbus_async_callback(void)
+{
+ if (!gdbus_async_callback.callback)
+ return;
+ gdbus_async_callback.callback(NULL, NULL, gdbus_async_callback.user_data);
+}
+
+#if 0
+void mock_emit_gdbus_signal(int signo)
+{
+ if (signo < WIFI_MOCK_GDBUS_SIGNAL_STATE_CHANGED_PROPERTIES|| signo >= WIFI_MOCK_GDBUS_SIGNAL_MAX)
+ return;
+
+ if (!gdbus_signal_callbacks[signo].callback)
+ return;
+
+ GVariant *params = NULL;
+ return;
+ switch (signo) {
+ case TETHERING_MOCK_GDBUS_SIGNAL_NET_CLOSED:
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_WIFI_TETHER_ON:
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_WIFI_TETHER_OFF:
+ params = g_variant_new("(s)", "There is no connection for a while");
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_USB_TETHER_ON:
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_USB_TETHER_OFF:
+ params = g_variant_new("(s)", "Interface is not available");
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_BT_TETHER_ON:
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_BT_TETHER_OFF:
+ params = g_variant_new("(s)", "There is no connection for a while");
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_NO_DATA_TIMEOUT:
+ case TETHERING_MOCK_GDBUS_SIGNAL_LOW_BATTERY_MODE:
+ case TETHERING_MOCK_GDBUS_SIGNAL_FLIGHT_MODE:
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_SECURITY_TYPE_CHANGED:
+ params = g_variant_new("(s)", "wpa2-psk");
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_SSID_VISIBILITY_CHANGED:
+ params = g_variant_new("(s)", "ssid_visible");
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_PASSPHRASE_CHANGED:
+ break;
+ case TETHERING_MOCK_GDBUS_SIGNAL_DHCP_STATUS:
+ params = g_variant_new("(susssu)", "DhcpConnected", 1,
+ "192.168.43.24", "ab:cd:ef:ab:cd:ef",
+ "client", 1592460260);
+ break;
+ default:
+ break;
+ }
+ gdbus_signal_callbacks[signo].callback(NULL, NULL,
+ NULL, NULL, gdbus_signal_list[signo],
+ params, gdbus_signal_callbacks[signo].user_data);
+}
+#endif
+
+guint __wrap_g_dbus_connection_signal_subscribe(GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *interface_name,
+ const gchar *member,
+ const gchar *object_path,
+ const gchar *arg0,
+ GDBusSignalFlags flags,
+ GDBusSignalCallback callback,
+ gpointer user_data,
+ GDestroyNotify user_data_free_func)
+{
+ if (mock_gdbus_result == false)
+ return 0;
+
+ return 1;
+#if 0
+ if(!member)
+ return 0;
+ for (int i = WIFI_MOCK_GDBUS_SIGNAL_STATE_CHANGED_PROPERTIES; i < WIFI_MOCK_GDBUS_SIGNAL_MAX; i++) {
+ if (strcmp(gdbus_signal_list[i], member) == 0) {
+ gdbus_signal_callbacks[i].callback = callback;
+ gdbus_signal_callbacks[i].user_data = user_data;
+ return i;
+ }
+ }
+ return 0;
+#endif
+}
+
+void __wrap_g_dbus_connection_signal_unsubscribe(GDBusConnection *connection,
+ guint subscription_id)
+{
+ if (mock_gdbus_result == false)
+ return;
+#if 0
+ if (subscription_id >= WIFI_MOCK_GDBUS_SIGNAL_STATE_CHANGED_PROPERTIES
+ && subscription_id < WIFI_MOCK_GDBUS_SIGNAL_MAX) {
+ gdbus_signal_callbacks[subscription_id].callback = NULL;
+ gdbus_signal_callbacks[subscription_id].user_data = NULL;
+ }
+
+ return;
+#endif
+}
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#pragma once
+
+#include <stdbool.h>
+
+enum {
+ ERROR_NONE = 0,
+ ERROR_SECURITY_RESTRICTED,
+ ERROR_PERMISSION_DENIED,
+ ERROR_ALREADY_EXISTS,
+ ERROR_NOW_IN_PROGRESS,
+ ERROR_FAIL_DEVICE_BUSY,
+ ERROR_NULL,
+ ERROR_MAX
+};
+
+enum {
+ WIFI_MOCK_GDBUS_SIGNAL_STATE_CHANGED_PROPERTIES = 0 ,
+ WIFI_MOCK_GDBUS_SIGNAL_PROPERTY_CHANGED,
+ WIFI_MOCK_GDBUS_SIGNAL_SCAN_CHANGED,
+ WIFI_MOCK_GDBUS_SIGNAL_SCAN_DONE,
+ WIFI_MOCK_GDBUS_SIGNAL_MAX
+};
+
+void mock_set_gdbus_result(bool value);
+void mock_set_gdbus_devicePolicy(bool value);
+void mock_set_gdbus_powered(bool value);
+void mock_set_gdbus_tech_state(const char *ifname, bool powered, bool connected);
+void mock_invoke_gdbus_async_callback(void);
+void mock_set_gdbus_error_msg(int error);
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mock_memory.h"
+
+#include <glib.h>
+#include <stdbool.h>
+
+static bool mock_memory_result;
+
+extern gpointer __real_g_try_malloc0(gsize n_bytes);
+
+void mock_set_memory_result(bool result)
+{
+ mock_memory_result = result;
+}
+
+void *__wrap_g_try_malloc0(size_t size)
+{
+ if (mock_memory_result == false)
+ return NULL;
+
+ return __real_g_try_malloc0(size);
+}
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+
+void mock_set_memory_result(bool result);
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "mock_system_info.h"
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <system_info.h>
+
+static bool mock_sysinfo_result = false;
+
+void mock_set_system_info_result(bool value)
+{
+ mock_sysinfo_result = value;
+}
+
+int __wrap_system_info_get_platform_bool(const char *key, bool *value)
+{
+ if (mock_sysinfo_result == false)
+ return -1;
+
+ *value = mock_sysinfo_result;
+ return SYSTEM_INFO_ERROR_NONE;
+}
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#pragma once
+
+#include <stdbool.h>
+
+void mock_set_system_info_result(bool value);
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "mock_vconf.h"
+
+#include <vconf.h>
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+
+static bool mock_vconf_result;
+static int mock_hotspot_mode = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
+static bool mock_flight_mode = 0;
+
+void mock_set_vconf_result(bool result)
+{
+ mock_vconf_result = result;
+}
+
+void mock_set_vonf_hospot_mode(int hotspot_mode)
+{
+ mock_hotspot_mode = hotspot_mode;
+}
+
+void mock_set_vonf_flight_mode(int flight_mode)
+{
+ mock_flight_mode = flight_mode;
+}
+
+int __wrap_vconf_get_int(const char *key, int *intval)
+{
+ if (!mock_vconf_result)
+ return -1;
+
+ if (!strcmp(VCONFKEY_MOBILE_HOTSPOT_MODE, key))
+ *intval = mock_hotspot_mode;
+ else
+ *intval = 0;
+
+ return 0;
+}
+
+int __wrap_vconf_get_bool(const char *key, bool *boolval)
+{
+ if (!mock_vconf_result)
+ return -1;
+
+ if (!strcmp(VCONFKEY_TELEPHONY_FLIGHT_MODE, key))
+ *boolval = mock_flight_mode;
+ else
+ *boolval = false;
+
+ return 0;
+}
+
+char *__wrap_vconf_get_str(const char *key)
+{
+ if (!mock_vconf_result)
+ return NULL;
+ if (!strcmp(VCONFKEY_WIFI_BSSID_ADDRESS, key))
+ return strdup("11:22:33:44:55:66");
+
+ return NULL;
+}
--- /dev/null
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#pragma once
+
+#include <stdbool.h>
+
+void mock_set_vconf_result(bool result);
+void mock_set_vonf_hospot_mode(int hotspot_mode);
+void mock_set_vonf_flight_mode(int flight_mode);
ADD_EXECUTABLE(wifi_connect_tool ${wifi_connect_tool_src})
TARGET_LINK_LIBRARIES(wifi_connect_tool ${fw_name})
+SET(wifi_manager_test_src
+ wifi_manager_test.c
+)
+
+ADD_EXECUTABLE(wifi_manager_test ${wifi_manager_test_src})
+TARGET_LINK_LIBRARIES(wifi_manager_test ${fw_name})
+
INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR})
INSTALL(TARGETS wifi_connect_tool RUNTIME DESTINATION ${BIN_DIR})
+INSTALL(TARGETS wifi_manager_test RUNTIME DESTINATION ${BIN_DIR})
--- /dev/null
+/*
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <assert.h>
+#include <wifi-manager.h>
+#include <wifi-manager-extension.h>
+#include <tizen_error.h>
+
+
+#define LOG_RED "\033[0;31m"
+#define LOG_GREEN "\033[0;32m"
+#define LOG_BROWN "\033[0;33m"
+#define LOG_BLUE "\033[0;34m"
+#define LOG_END "\033[0;m"
+
+#define MAC_ADDR_LEN 17
+
+wifi_manager_h wifi = NULL;
+wifi_manager_h wifi2 = NULL;
+
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
+int test_wifi_manager_foreach_bssid_scan(void);
+int test_wifi_manager_foreach_netlink_scan(void);
+
+static const char *__test_convert_error_to_string(wifi_manager_error_e err_type)
+{
+ switch (err_type) {
+ case WIFI_MANAGER_ERROR_NONE:
+ return "NONE";
+ case WIFI_MANAGER_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_MANAGER_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_MANAGER_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_MANAGER_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_MANAGER_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_MANAGER_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_MANAGER_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_MANAGER_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_MANAGER_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_MANAGER_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_MANAGER_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_MANAGER_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ case WIFI_MANAGER_ERROR_ALREADY_INITIALIZED:
+ return "ALREADY_INITIALIZED";
+ case WIFI_MANAGER_ERROR_OUT_OF_RANGE:
+ return "OUT_OF_RANGE";
+ case WIFI_MANAGER_ERROR_CONNECT_FAILED:
+ return "CONNECT_FAILED";
+ case WIFI_MANAGER_ERROR_LOGIN_FAILED:
+ return "LOGIN_FAILED";
+ case WIFI_MANAGER_ERROR_AUTHENTICATION_FAILED:
+ return "AUTH_FAILED";
+ case WIFI_MANAGER_ERROR_PIN_MISSING:
+ return "PIN_MISSING";
+ case WIFI_MANAGER_ERROR_WPS_OVERLAP:
+ return "WPS_OVERLAP";
+ case WIFI_MANAGER_ERROR_WPS_TIMEOUT:
+ return "WPS_TIMEOUT";
+ case WIFI_MANAGER_ERROR_WPS_WEP_PROHIBITED:
+ return "WPS_WEP_PROHIBITED";
+ case WIFI_MANAGER_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case WIFI_MANAGER_ERROR_OFFLINE:
+ return "OFFLINE";
+ case WIFI_MANAGER_ERROR_INVALID_GATEWAY:
+ return "INVALID_GATEWAY";
+ case WIFI_MANAGER_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPORTED";
+ case WIFI_MANAGER_ERROR_NOT_INITIALIZED:
+ return "NOT_INITIALIZED";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *__test_convert_connection_mode_to_string(wifi_manager_connection_mode_e mode)
+{
+ switch (mode) {
+ case WIFI_MANAGER_CONNECTION_MODE_80211_B:
+ return "802.11b";
+ case WIFI_MANAGER_CONNECTION_MODE_80211_G:
+ return "802.11g";
+ case WIFI_MANAGER_CONNECTION_MODE_80211_N:
+ return "802.11n";
+ case WIFI_MANAGER_CONNECTION_MODE_80211_A:
+ return "802.11a";
+ case WIFI_MANAGER_CONNECTION_MODE_80211_AC:
+ return "802.11ac";
+ case WIFI_MANAGER_CONNECTION_MODE_UNKNOWN:
+ return "Uknown";
+ default:
+ return "Uknown";
+ }
+}
+
+static void __test_device_state_callback(wifi_manager_device_state_e state, void* user_data)
+{
+ printf("[%s] Device state changed callback", (char *)user_data);
+
+ if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED)
+ printf(", state : Activated\n");
+ else
+ printf(", state : Deactivated\n");
+}
+
+static void __test_scan_changed_callback(wifi_manager_scan_state_e state, void* user_data)
+{
+ printf("Scan changed, scan state : %d\n", state);
+}
+
+static void __test_bg_scan_completed_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ printf("[%s] Background Scan Completed, error code : %s\n",
+ (char *)user_data, __test_convert_error_to_string(error_code));
+}
+
+static void __test_ip_conflict_callback(char *mac, wifi_manager_ip_conflict_state_e state, void *user_data)
+{
+ if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED)
+ printf("[%s] Ip conflict detected : %s\n", (char *)user_data, mac);
+ else if (state == WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED)
+ printf("Ip conflict removed\n");
+ else
+ printf("Ip conflict state unknown\n");
+}
+
+static void __test_scan_request_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ if (user_data != NULL)
+ printf("user_data : %s\n", (char *)user_data);
+
+ printf("Scan Completed from scan request, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+}
+
+static void __test_bssid_scan_request_callback(wifi_manager_error_e error_code, void *user_data)
+{
+ printf("BSSID Scan Completed, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+
+ if (error_code == WIFI_MANAGER_ERROR_NONE)
+ test_wifi_manager_foreach_bssid_scan();
+}
+
+static void __test_netlink_scan_request_callback(wifi_manager_error_e error_code, void *user_data)
+{
+ printf("Netlink Scan Completed, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+
+ if (error_code == WIFI_MANAGER_ERROR_NONE)
+ test_wifi_manager_foreach_netlink_scan();
+}
+
+static void __test_connection_state_callback(wifi_manager_connection_state_e state, wifi_manager_ap_h ap, void* user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+
+ printf("[%s] Connection state changed callback", (char *)user_data);
+
+ switch (state) {
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ printf(", state : Connected");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ printf(", state : Association");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ printf(", state : Configuration");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ printf(", state : Disconnected");
+ break;
+ default:
+ printf(", state : Unknown");
+ }
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf(", Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ else {
+ printf(", AP name : %s\n", ap_name);
+ g_free(ap_name);
+ }
+}
+
+static void __test_activated_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Activation Succeeded\n");
+ else
+ printf("Wi-Fi Activation Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_deactivated_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Deactivation Succeeded\n");
+ else
+ printf("Wi-Fi Deactivation Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_connected_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Connection Succeeded\n");
+ else
+ printf("Wi-Fi Connection Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_disconnected_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi Disconnection Succeeded\n");
+ else
+ printf("Wi-Fi Disconnection Failed! error : %s\n", __test_convert_error_to_string(result));
+}
+
+static void __test_rssi_level_callback(wifi_manager_rssi_level_e rssi_level, void* user_data)
+{
+ printf("[%s] RSSI level changed callback, level = %d\n", (char *)user_data, rssi_level);
+}
+
+static void __test_tdls_discover_callback(wifi_manager_tdls_discovery_state_e state, char *peer_mac_add, void *user_data)
+{
+ printf("[%s] TDLS discover callback", (char *)user_data);
+
+ printf(", Peer Mac Address [%s], state :%d\n", peer_mac_add, state);
+ if (state == WIFI_MANAGER_TDLS_DISCOVERY_STATE_ONGOING)
+ printf(", Discovery is ongoing");
+ else
+ printf(", Discovery is finished");
+}
+
+static void __test_get_wifi_module_state_callback(wifi_manager_module_state_e state, void *user_data)
+{
+ printf("Wi-Fi Module State Changed callback : %d", state);
+
+ if (state == WIFI_MANAGER_MODULE_STATE_ATTACHED)
+ printf(", Wi-Fi Module Attached\n");
+ else
+ printf(", Wi-Fi Module Detached\n");
+}
+
+static void __test_tdls_state_callback(wifi_manager_tdls_state_e state, char *peer_mac_add, void *user_data)
+{
+ printf("[%s] TDLS state changed callback", (char *)user_data);
+
+ if (state == WIFI_MANAGER_TDLS_STATE_CONNECTED)
+ printf(", state : TDLS Connected, Peer Mac Address [%s]\n", peer_mac_add);
+ else
+ printf(", state : TDLS Disconnected, Peer Mac Address [%s]\n", peer_mac_add);
+}
+
+static const char* __test_print_state(wifi_manager_connection_state_e state)
+{
+ switch (state) {
+ case WIFI_MANAGER_CONNECTION_STATE_FAILURE:
+ return "Failure";
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ return "Disconnected";
+ case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ return "Association";
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ return "Connected";
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ return "Configuration";
+ }
+
+ return "Unknown";
+}
+
+static bool __test_compare_ap_name(const char *ap_name, const char *ap_name_part)
+{
+ int ap_name_len = strlen(ap_name);
+ int ap_name_part_len = strlen(ap_name_part);
+
+ if (strncmp(ap_name, ap_name_part,
+ ap_name_len > ap_name_part_len ? ap_name_len : ap_name_part_len) == 0)
+ return true;
+ else
+ return false;
+}
+
+static bool __test_found_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_manager_connection_state_e state;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ rv = wifi_manager_ap_get_connection_state(ap, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get State [%s]\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("AP name : %s, state : %s\n", ap_name, __test_print_state(state));
+ g_free(ap_name);
+
+ return true;
+}
+
+struct _ap_data {
+ char ap_name[33];
+ bool is_found;
+};
+
+static bool __test_found_connect_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ struct _ap_data *data = (struct _ap_data*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, data->ap_name)) {
+ bool required = false;
+ data->is_found = true;
+
+ if (wifi_manager_ap_is_passphrase_required(ap, &required) == WIFI_MANAGER_ERROR_NONE)
+ printf("Passphrase required : %s\n", required ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
+
+ if (required) {
+ char passphrase[100];
+ printf("Input passphrase for %s : ", ap_name);
+ rv = scanf(" %99s", passphrase);
+
+ rv = wifi_manager_ap_set_passphrase(ap, passphrase);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+ }
+
+ rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_connect_wps_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ int user_sel;
+ char pin[32] = {0,};
+
+ printf("%s - Input WPS method (1:PBC, 2:PIN) :\n", ap_name);
+ rv = scanf(" %9d", &user_sel);
+
+ switch (user_sel) {
+ case 1:
+ rv = wifi_manager_connect_by_wps_pbc(wifi, ap, __test_connected_callback, NULL);
+ break;
+ case 2:
+ printf("Input PIN code :\n");
+ rv = scanf("%31s", pin);
+ rv = wifi_manager_connect_by_wps_pin(wifi, ap, pin, __test_connected_callback, NULL);
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_disconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_disconnect(wifi, ap, __test_disconnected_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to disconnection reqeust %s : [%s]\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to disconnection request %s\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_forget_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_forget_ap(wifi, ap);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to forget [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to forget [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static void __test_forget_ap_finished_cb(wifi_manager_error_e result, void *user_data)
+{
+ printf("Forget AP callback %s, error: [%s]\n",
+ (result == WIFI_MANAGER_ERROR_NONE) ? "succeeded" : "failed",
+ __test_convert_error_to_string(result));
+}
+
+static bool __test_found_forget_ap_async_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_forget_ap_async(wifi, ap,
+ __test_forget_ap_finished_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to forget [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to forget [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_eap_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_manager_security_type_e type;
+
+ if (wifi_manager_ap_get_security_type(ap, &type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Security type : %d\n", type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ g_free(ap_name);
+ return false;
+ }
+
+ char input_str1[100];
+ printf("Input user name for %s : ", ap_name);
+ rv = scanf(" %99s", input_str1);
+
+ char input_str2[100];
+ printf("Input password for %s : ", ap_name);
+ rv = scanf("%99s", input_str2);
+
+ rv = wifi_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ char *inputed_name = NULL;
+ bool is_pass_set;
+ rv = wifi_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
+
+ int input_int;
+ printf("Input EAP type:\n");
+ printf("0 -> WIFI_MANAGER_EAP_TYPE_PEAP\n");
+ printf("1 -> WIFI_MANAGER_EAP_TYPE_TLS\n");
+ printf("2 -> WIFI_MANAGER_EAP_TYPE_TTLS\n");
+ printf("3 -> WIFI_MANAGER_EAP_TYPE_SIM\n");
+ printf("4 -> WIFI_MANAGER_EAP_TYPE_AKA\n");
+ printf("5 -> WIFI_MANAGER_EAP_TYPE_AKA_PRIME\n");
+ printf("6 -> WIFI_MANAGER_EAP_TYPE_FAST\n");
+ printf("7 -> WIFI_MANAGER_EAP_TYPE_PWD\n");
+ rv = scanf("%d", &input_int);
+
+ rv = wifi_manager_ap_set_eap_type(ap, input_int);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap type : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ g_free(inputed_name);
+ return false;
+ }
+
+ if (input_int == 0 || input_int == 1 || input_int == 2) {
+ printf("Input certificate file:\n");
+ rv = scanf("%99s", input_str1);
+
+ rv = wifi_manager_ap_set_eap_ca_cert_file(ap, input_str1);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap certificatefile : %s\n",
+ __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ g_free(inputed_name);
+ return false;
+ }
+ }
+
+ printf("Input EAP authentication type:\n");
+ printf("0 -> WIFI_MANAGER_EAP_AUTH_TYPE_NONE\n");
+ printf("1 -> WIFI_MANAGER_EAP_AUTH_TYPE_PAP\n");
+ printf("2 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP\n");
+ printf("3 -> WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2\n");
+ printf("4 -> WIFI_MANAGER_EAP_AUTH_TYPE_GTC\n");
+ printf("5 -> WIFI_MANAGER_EAP_AUTH_TYPE_MD5\n");
+ rv = scanf("%d", &input_int);
+
+ rv = wifi_manager_ap_set_eap_auth_type(ap, input_int);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap auth type : %s\n",
+ __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ g_free(inputed_name);
+ return false;
+ }
+
+ rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ g_free(inputed_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_set_autoconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0, enable;
+ char *ap_name = NULL;
+ bool autoconnect = false;
+ char *ap_name_part = (char *)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[Wi-Fi] Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ printf("[Wi-Fi] Input command number (enable[1], disable[0]) : ");
+ rv = scanf(" %9d", &enable);
+ if (rv <= 0) {
+ g_free(ap_name);
+ return false;
+ }
+
+ if (enable != 0)
+ autoconnect = true;
+
+ rv = wifi_manager_ap_set_auto_connect(ap, autoconnect);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to set [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+
+ return true;
+}
+
+static bool __test_found_get_autoconnect_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv = 0;
+ bool autoconnect = false;
+ char *ap_name = NULL;
+ char *ap_name_part = (char *)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[Wi-Fi] Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ rv = wifi_manager_ap_get_auto_connect(ap, &autoconnect);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to get : [%s]\n", autoconnect ? "TRUE" : "FALSE");
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+
+ return true;
+}
+
+static bool test_get_user_int(const char *msg, int *num)
+{
+ if (msg == NULL || num == NULL)
+ return false;
+
+ int rv;
+ char buf[32] = {0,};
+ printf("%s\n", msg);
+ rv = read(0, buf, 32);
+
+ if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
+ return false;
+
+ *num = atoi(buf);
+ return true;
+}
+
+static bool test_get_user_string(const char *msg, char *buf, int buf_size)
+{
+ if (msg == NULL || buf == NULL || buf_size < 2)
+ return false;
+
+ int rv;
+ printf("%s\n", msg);
+ memset(buf, 0, buf_size);
+ rv = read(0, buf, buf_size - 1);
+
+ if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
+ buf[0] = '\0';
+ return false;
+ }
+
+ buf[rv-1] = '\0';
+ return true;
+}
+
+static bool __test_found_change_ip_method_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv;
+ char *ap_name;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_manager_ip_config_type_e type;
+ int method;
+ int address_type;
+ int dns_type;
+ int prefix_len;
+
+ printf("Input new method type (1:dhcp, 2:manual, 3:auto) :\n");
+ rv = scanf(" %9d", &method);
+ if (rv <= 0) {
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ switch (method) {
+ case 1:
+ type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+ case 2:
+ type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
+ break;
+ case 3:
+ type = WIFI_MANAGER_IP_CONFIG_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_manager_ap_set_ip_config_type(ap, address_type, type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set ip method type[%s]\n", __test_convert_error_to_string(rv));
+
+ if (type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC) {
+ char ip_addr[40];
+
+ 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_ap_set_ip_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_ip_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set ip address[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+
+ 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_ap_set_subnet_mask(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_subnet_mask(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set subnet mask[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+
+ printf("Input new prefix length (x:skip) :\n");
+ rv = scanf("%d", &prefix_len);
+ if (rv > 0) {
+ if (prefix_len == 'x')
+ rv = WIFI_MANAGER_ERROR_NONE;
+ else
+ rv = wifi_manager_ap_set_prefix_length(ap, address_type, prefix_len);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set subnet mask[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+
+ 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_ap_set_gateway_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_gateway_address(ap, address_type, ip_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set gateway address[%s]\n",
+ __test_convert_error_to_string(rv));
+ }
+
+ rv = test_get_user_int("Input DNS config type (0:STATIC, 1:DYNAMIC)"
+ "- (Enter for skip) : ", &dns_type);
+ if (rv == false) {
+ printf("Invalid input!!\n");
+ g_free(ap_name);
+ return false;
+ }
+ switch (dns_type) {
+ case 0:
+ rv = wifi_manager_ap_set_dns_config_type(ap,
+ 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_ap_set_dns_address(ap,
+ 1, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_dns_address(ap,
+ 1, address_type, ip_addr);
+ break;
+ }
+ }
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ g_free(ap_name);
+ return false;
+ }
+
+ 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_ap_set_dns_address(ap,
+ 2, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_dns_address(ap,
+ 2, address_type, ip_addr);
+ break;
+ }
+ }
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ g_free(ap_name);
+ return false;
+ }
+ }
+ break;
+ case 1:
+ rv = wifi_manager_ap_set_dns_config_type(ap,
+ address_type, WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ g_free(ap_name);
+ return false;
+ }
+ break;
+ }
+ }
+
+ rv = wifi_manager_update_ap(wifi, ap);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to update ap info[%s]\n",
+ __test_convert_error_to_string(rv));
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_found_change_proxy_method_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv, address_type;
+ char *ap_name;
+ char *ap_name_part = (char*)user_data;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ wifi_manager_proxy_type_e type;
+ char proxy_addr[65];
+ int method;
+
+ printf("Input new method type (1:direct, 2:manual, 3:auto) :\n");
+ rv = scanf(" %9d", &method);
+ if (rv <= 0) {
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ switch (method) {
+ case 1:
+ type = WIFI_MANAGER_PROXY_TYPE_DIRECT;
+ break;
+ case 2:
+ type = WIFI_MANAGER_PROXY_TYPE_MANUAL;
+ break;
+ case 3:
+ type = WIFI_MANAGER_PROXY_TYPE_AUTO;
+ break;
+ default:
+ printf("Invalid input!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ rv = wifi_manager_ap_set_proxy_type(ap, type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set proxy method type[%s]\n", __test_convert_error_to_string(rv));
+
+ printf("Input new proxy address (x:skip, 0:clear) :\n");
+ rv = scanf("%64s", proxy_addr);
+
+ if (rv > 0) {
+ switch (proxy_addr[0]) {
+ case 'x':
+ rv = WIFI_MANAGER_ERROR_NONE;
+ break;
+ case '0':
+ rv = wifi_manager_ap_set_proxy_address(ap, address_type, NULL);
+ break;
+ default:
+ rv = wifi_manager_ap_set_proxy_address(ap, address_type, proxy_addr);
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to set proxy address[%s]\n", __test_convert_error_to_string(rv));
+ }
+
+ rv = wifi_manager_update_ap(wifi, ap);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to update ap info[%s]\n",
+ __test_convert_error_to_string(rv));
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool __test_ipv6_address_callback(char *ipv6_address, void *user_data)
+{
+ printf("IPv6 address: %s\n", ipv6_address);
+ return true;
+}
+
+static int __test_convert_byte_to_txt(const unsigned char *src, char **dst, int src_len)
+{
+ int dst_length = 0;
+ int i = 0;
+ char *buf = NULL;
+
+ if (src_len <= 0) {
+ printf("Invalid source length\n");
+ return -1;
+ }
+
+ *dst = (char *)malloc((2*src_len)+1);
+ if (!(*dst)) {
+ printf("failed to allocate memory to buffer\n");
+ return -1;
+ }
+
+ buf = (*dst);
+
+ for (i = 0; i < src_len; i++) {
+ snprintf(buf, 3, "%02x", src[i]);
+ buf += 2;
+ dst_length += 2;
+ }
+
+ return dst_length;
+}
+
+static bool __test_vendor_specific_callback(unsigned char *vsie_bytes, int vsie_len, void *user_data)
+{
+ if (!vsie_bytes)
+ return false;
+
+ char *vsie = NULL;
+ int buf_len = __test_convert_byte_to_txt(vsie_bytes, &vsie, vsie_len);
+ if (buf_len > 0)
+ printf("vsie_len: %d, vsie: %s\n", vsie_len, vsie);
+
+ if (vsie)
+ free(vsie);
+
+ return true;
+}
+
+static bool __test_found_bssid_list_callback(const char *bssid, int rssi, int freq, void *user_data)
+{
+ printf("-> BSSID : %s, RSSI : %d, Frequency : %d\n", bssid, rssi, freq);
+ return true;
+}
+
+static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ int rv, address_type = 0;
+ char *ap_name;
+ char *str_value;
+ int int_value;
+ wifi_manager_connection_state_e conn_state;
+ wifi_manager_ip_config_type_e ip_type;
+ wifi_manager_proxy_type_e proxy_type;
+ wifi_manager_security_type_e sec_type;
+ wifi_manager_encryption_type_e enc_type;
+ wifi_manager_eap_type_e eap_type;
+ wifi_manager_eap_auth_type_e eap_auth_type;
+ wifi_manager_dns_config_type_e dns_type;
+ bool bool_value;
+ char *ap_name_part = (char*)user_data;
+ wifi_manager_disconnect_reason_e disconnect_reason;
+ wifi_manager_assoc_status_code_e status_code;
+ wifi_manager_rssi_level_e rssi_level;
+ bool is_hidden;
+ wifi_manager_connection_mode_e mode;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+
+ printf("ap_name %s, user input name %s\n", ap_name, ap_name_part);
+ if (__test_compare_ap_name(ap_name, ap_name_part)) {
+ /* Basic info */
+ printf("ESSID : %s\n", ap_name);
+
+ if (wifi_manager_ap_get_bssid(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("BSSID : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get BSSID\n");
+
+ if (wifi_manager_foreach_found_bssid(ap, __test_found_bssid_list_callback, NULL) != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get BSSID list data\n");
+
+ if (wifi_manager_ap_get_rssi(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("RSSI : %d\n", int_value);
+ else
+ printf("Fail to get RSSI\n");
+
+ if (wifi_manager_ap_get_rssi_level(ap, &rssi_level) == WIFI_MANAGER_ERROR_NONE)
+ printf("RSSI level : %d\n", rssi_level);
+ else
+ printf("Fail to get RSSI level\n");
+
+ if (wifi_manager_ap_get_connection_mode(ap, &mode) == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi operation mode: %d\n", mode);
+ else
+ printf("Fail to get operation mode\n");
+
+ if (wifi_manager_ap_get_frequency(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Frequency : %d\n", int_value);
+ else
+ printf("Fail to get Frequency\n");
+
+ if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_callback, NULL)
+ != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get vsie\n");
+
+ if (wifi_manager_ap_get_max_speed(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Max speed : %d\n", int_value);
+ else
+ printf("Fail to get Max speed\n");
+
+ if (wifi_manager_ap_is_favorite(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Favorite : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Favorite\n");
+
+ if (wifi_manager_ap_is_hidden(ap, &is_hidden) == WIFI_MANAGER_ERROR_NONE)
+ printf("Hidden Status : %s\n", is_hidden ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get hidden status\n");
+
+ if (wifi_manager_ap_get_disconnect_reason(ap, &disconnect_reason)
+ == WIFI_MANAGER_ERROR_NONE)
+ printf("Disconnect reason : %d\n", disconnect_reason);
+ else
+ printf("Fail to get disconnect reason\n");
+
+ if (wifi_manager_ap_get_assoc_status_code(ap, &status_code)
+ == WIFI_MANAGER_ERROR_NONE)
+ printf("Association Status Code : %d\n", status_code);
+ else
+ printf("Fail to get association status code\n");
+
+ if (wifi_manager_ap_get_error_state(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("error state of AP : %s\n", __test_convert_error_to_string(int_value));
+ else
+ printf("Fail to get error state of AP\n");
+
+ /* Network info */
+ if (wifi_manager_ap_get_connection_state(ap, &conn_state) == WIFI_MANAGER_ERROR_NONE)
+ printf("Connection State : %d\n", conn_state);
+ else
+ printf("Fail to get Connection State\n");
+
+ rv = test_get_user_int("Input Address type to get"
+ "(0:IPV4, 1:IPV6):", &address_type);
+
+ if (rv == false || (address_type != 0 && address_type != 1)) {
+ printf("Invalid input!!\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_ip_config_type(ap, address_type, &ip_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("IP config type : %d\n", ip_type);
+ else
+ printf("Fail to get IP config type\n");
+
+ if (wifi_manager_ap_get_ip_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("IP : %s\n", str_value);
+ g_free(str_value);
+ } else {
+ printf("Fail to get IP : %s\n", str_value);
+ g_free(str_value);
+ }
+
+ if (address_type == WIFI_MANAGER_ADDRESS_FAMILY_IPV6) {
+ if (wifi_manager_ap_foreach_ipv6_address(ap, __test_ipv6_address_callback, NULL)
+ != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get multiple IPv6 address\n");
+ }
+
+ if (wifi_manager_ap_get_subnet_mask(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Subnet mask : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Subnet mask\n");
+
+ if (wifi_manager_ap_get_prefix_length(ap, address_type, &int_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Prefix length : %d\n", int_value);
+ else
+ printf("Fail to get Subnet mask\n");
+
+ if (wifi_manager_ap_get_gateway_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Gateway : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Gateway\n");
+
+ if (address_type == 0) {
+ if (wifi_manager_ap_get_dhcp_server_address(ap, address_type, &str_value) ==
+ WIFI_MANAGER_ERROR_NONE) {
+ printf("DHCP Server : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DHCP Server\n");
+ if (wifi_manager_ap_get_dhcp_lease_duration(ap, address_type, &int_value) ==
+ WIFI_MANAGER_ERROR_NONE) {
+ printf("DHCP Lease duration : %d\n", int_value);
+ } else
+ printf("Fail to get DHCP lease duration\n");
+ }
+
+ if (wifi_manager_ap_get_proxy_type(ap, &proxy_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Proxy type : %d\n", proxy_type);
+ else
+ printf("Fail to get Proxy type\n");
+
+ if (wifi_manager_ap_get_proxy_address(ap, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("Proxy : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get Proxy\n");
+
+ if (wifi_manager_ap_get_dns_config_type(ap, address_type, &dns_type) == WIFI_MANAGER_ERROR_NONE) {
+ if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC)
+ printf("DNS config type : STATIC\n");
+ else if (dns_type == WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC)
+ printf("DNS config type : DYNAMIC\n");
+ else
+ printf("DNS config type : %d\n", dns_type);
+ } else
+ printf("Fail to get DNS config type\n");
+
+ if (wifi_manager_ap_get_dns_address(ap, 1, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("DNS1 : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DNS1\n");
+
+ if (wifi_manager_ap_get_dns_address(ap, 2, address_type, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("DNS2 : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get DNS2\n");
+
+ /* Security info */
+ if (wifi_manager_ap_get_security_type(ap, &sec_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Security type : %d\n", sec_type);
+ else
+ printf("Fail to get Security type\n");
+
+ if (wifi_manager_ap_get_encryption_type(ap, &enc_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("Encryption type : %d\n", enc_type);
+ else
+ printf("Fail to get Encryption type\n");
+
+ if (wifi_manager_ap_is_passphrase_required(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Passphrase required : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get Passphrase required\n");
+
+ if (wifi_manager_ap_is_wps_supported(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("WPS supported : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get WPS supported\n");
+
+ if (wifi_manager_ap_is_passpoint(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE)
+ printf("Passpoint enabled : %s\n", bool_value ? "TRUE" : "FALSE");
+ else
+ printf("Fail to get passpoint state\n");
+
+ if (wifi_manager_ap_get_countrycode(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ if (str_value) {
+ printf("Country Code : %s\n", str_value);
+ free(str_value);
+ } else
+ printf("Country code is NULL\n");
+ } else
+ printf("Fail to get Country code\n");
+
+ if (sec_type != WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ g_free(ap_name);
+ return false;
+ }
+
+ /* EAP info */
+ if (wifi_manager_ap_get_eap_type(ap, &eap_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("EAP type : %d\n", eap_type);
+ else
+ printf("Fail to get EAP type\n");
+
+ if (wifi_manager_ap_get_eap_auth_type(ap, &eap_auth_type) == WIFI_MANAGER_ERROR_NONE)
+ printf("EAP auth type : %d\n", eap_auth_type);
+ else
+ printf("Fail to get EAP auth type\n");
+
+ if (wifi_manager_ap_get_eap_passphrase(ap, &str_value, &bool_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("EAP user name : %s\n", str_value);
+ printf("EAP is password setted : %s\n", bool_value ? "TRUE" : "FALSE");
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP passphrase(user name/password)\n");
+
+ if (wifi_manager_ap_get_eap_ca_cert_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("EAP ca cert file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP ca cert file\n");
+
+ if (wifi_manager_ap_get_eap_client_cert_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("EAP client cert file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP client cert file\n");
+
+ if (wifi_manager_ap_get_eap_private_key_file(ap, &str_value) == WIFI_MANAGER_ERROR_NONE) {
+ printf("EAP private key file : %s\n", str_value);
+ g_free(str_value);
+ } else
+ printf("Fail to get EAP private key file\n");
+
+ g_free(ap_name);
+ return false;
+ }
+
+ g_free(ap_name);
+ return true;
+}
+
+static bool _test_config_list_cb(const wifi_manager_config_h config, void *user_data)
+{
+ gchar *name = NULL;
+ wifi_manager_security_type_e security_type;
+
+ wifi_manager_config_get_name(config, &name);
+ wifi_manager_config_get_security_type(config, &security_type);
+
+ printf("Name[%s] ", name);
+ printf("Security type[%d] ", security_type);
+ if (security_type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ wifi_manager_eap_type_e eap_type;
+ wifi_manager_eap_auth_type_e eap_auth_type;
+ wifi_manager_config_get_eap_type(config, &eap_type);
+ printf("Eap type[%d] ", eap_type);
+ wifi_manager_config_get_eap_auth_type(config, &eap_auth_type);
+ printf("Eap auth type[%d]", eap_auth_type);
+ }
+ printf("\n");
+
+ g_free(name);
+
+ return true;
+}
+
+struct _wifi_conf {
+ char name[33];
+ int type;
+};
+static bool _test_config_list_cb_for_remove(const wifi_manager_config_h config, void *user_data)
+{
+
+ struct _wifi_conf *c = (struct _wifi_conf *)user_data;
+ gchar *name = NULL;
+ wifi_manager_security_type_e security_type;
+
+ wifi_manager_config_get_name(config, &name);
+ wifi_manager_config_get_security_type(config, &security_type);
+
+ if (__test_compare_ap_name(name, c->name) && security_type == c->type) {
+ int rv = wifi_manager_config_remove(wifi, config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to remove configurations [%s]\n", __test_convert_error_to_string(rv));
+ else
+ printf("Success to remove configuration [%s]\n", name);
+ g_free(name);
+ return false;
+ }
+
+ g_free(name);
+
+ return true;
+}
+
+static bool __test_found_specific_ap_callback(wifi_manager_ap_h ap, void *user_data)
+{
+ printf("Found specific ap Completed\n");
+
+ int rv;
+ char *ap_name = NULL;
+ wifi_manager_security_type_e security_type = WIFI_MANAGER_SECURITY_TYPE_NONE;
+
+ rv = wifi_manager_ap_get_essid(ap, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP name [%s]\n", __test_convert_error_to_string(rv));
+ return false;
+ }
+ printf("[AP name] : %s\n", ap_name);
+
+ rv = wifi_manager_ap_get_security_type(ap, &security_type);
+ if (rv == WIFI_MANAGER_ERROR_NONE)
+ printf("[Security type] : %d\n", security_type);
+ else {
+ printf("Fail to get Security type\n");
+ g_free(ap_name);
+ return false;
+ }
+
+ switch (security_type) {
+ case WIFI_MANAGER_SECURITY_TYPE_WEP:
+ case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+ case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+ case WIFI_MANAGER_SECURITY_TYPE_SAE:
+ {
+ char passphrase[100];
+ printf("Input passphrase for %s : ", ap_name);
+ rv = scanf(" %99s", passphrase);
+
+ rv = wifi_manager_ap_set_passphrase(ap, passphrase);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+ }
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_EAP:
+ {
+ char input_str1[100];
+ printf("Input user name for %s : ", ap_name);
+ rv = scanf(" %99s", input_str1);
+
+ char input_str2[100];
+ printf("Input password for %s : ", ap_name);
+ rv = scanf("%99s", input_str2);
+
+ rv = wifi_manager_ap_set_eap_passphrase(ap, input_str1, input_str2);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ char *inputed_name = NULL;
+ bool is_pass_set;
+ rv = wifi_manager_ap_get_eap_passphrase(ap, &inputed_name, &is_pass_set);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get eap passphrase : %s\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ return false;
+ }
+
+ printf("name : %s, is password set : %s\n", inputed_name, is_pass_set ? "TRUE" : "FALSE");
+ g_free(inputed_name);
+ }
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_NONE:
+ case WIFI_MANAGER_SECURITY_TYPE_OWE:
+ default:
+ break;
+ }
+
+ rv = wifi_manager_connect(wifi, ap, __test_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to connection request [%s] : %s\n", ap_name, __test_convert_error_to_string(rv));
+ else
+ printf("Success to connection request [%s]\n", ap_name);
+
+ g_free(ap_name);
+ return true;
+}
+
+static void __test_scan_specific_ap_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ int rv;
+
+ printf("Specific scan Completed from scan request, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+
+ if (error_code != WIFI_MANAGER_ERROR_NONE)
+ return;
+
+ rv = wifi_manager_foreach_found_specific_ap(wifi, __test_found_specific_ap_callback, user_data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get specific AP(can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return;
+ }
+}
+
+static void __test_multi_scan_callback(wifi_manager_error_e error_code, void* user_data)
+{
+ printf("Multi scan Completed, error code : %s\n",
+ __test_convert_error_to_string(error_code));
+}
+
+int test_wifi_manager_init(void)
+{
+ int rv = wifi_manager_initialize(&wifi);
+
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(wifi, __test_device_state_callback, "1");
+ wifi_manager_set_scan_state_changed_cb(wifi, __test_scan_changed_callback, "1");
+ wifi_manager_set_background_scan_cb(wifi, __test_bg_scan_completed_callback, "1");
+ wifi_manager_set_ip_conflict_cb(wifi, __test_ip_conflict_callback, "1");
+ wifi_manager_set_connection_state_changed_cb(wifi, __test_connection_state_callback, "1");
+ wifi_manager_set_rssi_level_changed_cb(wifi, __test_rssi_level_callback, "1");
+ wifi_manager_tdls_set_state_changed_cb(wifi, __test_tdls_state_callback, "1");
+ wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "1");
+ wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "1");
+
+ } else {
+ printf("[1] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_initialize(&wifi2);
+
+ if (rv == WIFI_MANAGER_ERROR_NONE) {
+ wifi_manager_set_device_state_changed_cb(wifi2, __test_device_state_callback, "2");
+ wifi_manager_set_background_scan_cb(wifi2, __test_bg_scan_completed_callback, "2");
+ wifi_manager_set_connection_state_changed_cb(wifi2, __test_connection_state_callback, "2");
+ wifi_manager_set_rssi_level_changed_cb(wifi2, __test_rssi_level_callback, "2");
+ wifi_manager_tdls_set_state_changed_cb(wifi2, __test_tdls_state_callback, "2");
+ wifi_manager_tdls_set_discovered_cb(wifi, __test_tdls_discover_callback, "2");
+ wifi_manager_set_module_state_changed_cb(wifi, __test_get_wifi_module_state_callback, "2");
+ } else {
+ printf("[2] Wifi init failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Wifi init succeeded\n");
+ return 1;
+}
+
+int test_wifi_manager_deinit(void)
+{
+ int rv = wifi_manager_deinitialize(wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[1] Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_deinitialize(wifi2);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[2] Wifi deinit failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Wifi deinit succeeded\n");
+ return 1;
+}
+
+int test_wifi_manager_activate(void)
+{
+ int rv = 0;
+
+ rv = wifi_manager_activate(wifi, __test_activated_callback, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to activate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to activate Wi-Fi device\n");
+
+ return 1;
+}
+
+int test_wifi_manager_deactivate(void)
+{
+ int rv = 0;
+
+ rv = wifi_manager_deactivate(wifi, __test_deactivated_callback, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to deactivate Wi-Fi device [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to deactivate Wi-Fi device\n");
+
+ return 1;
+}
+
+int test_wifi_manager_is_activated(void)
+{
+ int rv = 0;
+ bool state = false;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get Wi-Fi device state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to get Wi-Fi device state : %s\n", (state) ? "TRUE" : "FALSE");
+
+ return 1;
+}
+
+int test_wifi_manager_get_connection_state(void)
+{
+ int rv = 0;
+ wifi_manager_connection_state_e connection_state;
+
+ rv = wifi_manager_get_connection_state(wifi, &connection_state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connection state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to get connection state : ");
+ switch (connection_state) {
+ case WIFI_MANAGER_CONNECTION_STATE_ASSOCIATION:
+ printf("Association\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONNECTED:
+ printf("Connected\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_CONFIGURATION:
+ printf("Configuration\n");
+ break;
+ case WIFI_MANAGER_CONNECTION_STATE_DISCONNECTED:
+ printf("Disconnected\n");
+ break;
+ default:
+ printf("Unknown\n");
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_get_mac_address(void)
+{
+ int rv = 0;
+ char *mac_addr = NULL;
+
+ rv = wifi_manager_get_mac_address(wifi, &mac_addr);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get MAC address [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("MAC address : %s\n", mac_addr);
+ free(mac_addr);
+
+ return 1;
+}
+
+int test_wifi_manager_get_interface_name(void)
+{
+ int rv = 0;
+ char *if_name = NULL;
+
+ rv = wifi_manager_get_network_interface_name(wifi, &if_name);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get Interface name [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Interface name : %s\n", if_name);
+ free(if_name);
+
+ return 1;
+}
+
+int test_wifi_manager_scan(void)
+{
+ int rv = 0;
+
+ rv = wifi_manager_scan(wifi, __test_scan_request_callback, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Scan request succeeded\n");
+
+ return 1;
+}
+
+int test_wifi_manager_get_connected_ap(void)
+{
+ int rv = 0;
+ char *ap_name = NULL;
+ wifi_manager_ap_h ap_h;
+
+ rv = wifi_manager_get_connected_ap(wifi, &ap_h);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ printf("Connected AP : %s\n", ap_name);
+ g_free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+
+ return 1;
+}
+
+int test_wifi_manager_foreach_found_ap(void)
+{
+ int rv = 0;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_ap_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP list [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Get AP list finished\n");
+
+ return 1;
+}
+
+int test_wifi_manager_connect(void)
+{
+ int rv = 0;
+ struct _ap_data data;
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf(" %32[^\n]s", data.ap_name);
+ data.is_found = false;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_ap_callback, (void*)&data);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ if (!data.is_found) {
+ printf("%s is not found\n", data.ap_name);
+ return -1;
+ }
+ printf("Connection step finished\n");
+ return 1;
+}
+
+int test_wifi_manager_set_ip_conflict_detect_enable()
+{
+ int rv = 0;
+ int choice;
+ bool state = false;
+
+ printf("Input '1'(enable)/'0'(disable) for ip conflict detection : ");
+ rv = scanf(" %d", &choice);
+ if (choice == 1)
+ state = true;
+ else if (choice == 0)
+ state = false;
+ else
+ return -1;
+
+ rv = wifi_manager_set_ip_conflict_detect_enable(wifi, state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set ip conflict detection state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Successfully set the ip conflict detection !\n");
+ return 1;
+}
+
+int test_wifi_manager_ip_conflict_detect_is_enabled()
+{
+ int rv = 0;
+ bool state = false;
+
+ rv = wifi_manager_ip_conflict_detect_is_enabled(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict detection state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("IP conflict detection is %s\n", state ? "enabled" : "disabled");
+ printf("Successfully get the ip conflict detection !\n");
+ return 1;
+}
+
+int test_wifi_manager_get_ip_conflict_state()
+{
+ int rv = 0;
+ wifi_manager_ip_conflict_state_e state;
+
+ rv = wifi_manager_get_ip_conflict_state(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ switch (state) {
+ case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_DETECTED:
+ printf("IP Conflict present\n");
+ break;
+ case WIFI_MANAGER_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED:
+ printf("IP Conflict absent\n");
+ break;
+ case WIFI_MANAGER_IP_CONFLICT_STATE_UNKNOWN:
+ printf("IP Conflict state is unknown\n");
+ break;
+ default:
+ printf("Unhandled state\n");
+ break;
+ }
+
+ printf("Successfully get the ip conflict state!\n");
+ return 1;
+}
+
+int test_wifi_manager_get_ip_conflict_period()
+{
+ int rv = 0;
+ unsigned int initial_time;
+
+ rv = wifi_manager_get_ip_conflict_period(wifi, &initial_time);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get ip conflict time period [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Initial time = %u seconds!\n", initial_time);
+ printf("Successfully get the ip conflict detect period!\n");
+ return 1;
+}
+
+int test_wifi_manager_set_ip_conflict_period()
+{
+ int rv = 0;
+ int initial_interval;
+
+ printf("Enter initial interval for ARP ping\n");
+ rv = scanf(" %d", &initial_interval);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_ip_conflict_period(wifi, initial_interval);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set ip conflict detection period [%s]\n",
+ __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Successfully set the ip conflict detect period!\n");
+ return 1;
+}
+
+int test_wifi_manager_connect_specific_ap(void)
+{
+ int rv;
+ char ap_name[33];
+
+ printf("Input a part of specific AP name to connect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_scan_specific_ap(wifi, ap_name, __test_scan_specific_ap_callback, NULL);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Scan request failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Scan specific AP request succeeded\n");
+ return 1;
+}
+
+int test_wifi_manager_disconnect(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to disconnect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_disconnect_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to disconnect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Disconnection step finished\n");
+ return 1;
+}
+
+int test_wifi_manager_connect_wps(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect by wps : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_connect_wps_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+int test_wifi_manager_forget_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to forget : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to forget (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Forget AP finished\n");
+
+ return 1;
+}
+
+int test_wifi_manager_connect_eap_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to connect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_eap_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to connect (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Connection step finished\n");
+ return 1;
+}
+
+int test_wifi_manager_set_ip_method(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to change IP method : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_change_ip_method_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("IP method changing finished\n");
+ return 1;
+}
+
+int test_wifi_manager_set_proxy_method(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to change Proxy method : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_change_proxy_method_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to change (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Proxy method changing finished\n");
+ return 1;
+}
+
+int test_wifi_manager_get_ap_info(void)
+{
+ int rv;
+ char ap_name[33];
+ bool state;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input a part of AP name to get detailed info : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_print_ap_info_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get AP info (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("AP info printing finished\n");
+ return 1;
+}
+
+int test_wifi_manager_config_load_configuration(void)
+{
+ int rv;
+
+ rv = wifi_manager_config_foreach_configuration(wifi, _test_config_list_cb, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+int test_wifi_manager_config_save(void)
+{
+ int rv;
+ char name[33] = { 0, };
+ char passphrase[100] = { 0, };
+ int type = 0;
+ char proxy[100] = { 0, };
+ int hidden = 0;
+ int address_type = 0;
+ char ip_addr[40] = { 0, };
+ int prefix_len;
+ wifi_manager_config_h config;
+ int ip_update = 0;
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf(" %32[^\n]s", name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Passphrase : ");
+ rv = scanf(" %99s", passphrase);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4)) : ");
+ rv = scanf("%d", &type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_config_create(wifi, name, passphrase, type, &config);
+ 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;
+ }
+ }
+
+ if (address_type == 0) {
+ 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;
+ }
+ }
+ } else {
+ printf("Input new prefix length (x:skip) :\n");
+ rv = scanf("%d", &prefix_len);
+ if (rv > 0) {
+ if (prefix_len == 'x')
+ rv = WIFI_MANAGER_ERROR_NONE;
+ else
+ rv = wifi_manager_config_set_prefix_length(config, address_type, prefix_len);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set prefix length[%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);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("Hidden(1:Hidden) - (Enter for skip): ", &hidden)) {
+ if (hidden == 1)
+ rv = wifi_manager_config_set_hidden_ap_property(config, TRUE);
+ else
+ rv = wifi_manager_config_set_hidden_ap_property(config, FALSE);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (type == WIFI_MANAGER_SECURITY_TYPE_EAP) {
+ char anonymous[100] = { 0, };
+ char ca_cert[100] = { 0, };
+ char private_key[100] = { 0, };
+ char private_key_password[100] = { 0, };
+ char client_cert[100] = { 0, };
+ char eap_identity[100] = { 0, };
+ int eap_type;
+ int eap_auth_type;
+ char subject_match[100] = { 0, };
+
+ if (test_get_user_string("EAP Anonymous Identity - (Enter for skip): ", anonymous, 99)) {
+ rv = wifi_manager_config_set_eap_anonymous_identity(config, anonymous);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP ca cert file - (Enter for skip): ", ca_cert, 99)) {
+ rv = wifi_manager_config_set_eap_ca_cert_file(config, ca_cert);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP private key - (Enter for skip): ", private_key, 99) &&
+ test_get_user_string("EAP client cert file - (Enter for skip): ", client_cert, 99)) {
+ rv = wifi_manager_config_set_eap_client_cert_file(config, private_key, client_cert);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP identity - (Enter for skip): ", eap_identity, 99)) {
+ rv = wifi_manager_config_set_eap_identity(config, eap_identity);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("EAP type (PEAP(0), TLS(1), TTLS(2), SIM(3), AKA(4)) - (Enter for skip): ", &eap_type)) {
+ rv = wifi_manager_config_set_eap_type(config, eap_type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ if (eap_type == 1) {
+ if (test_get_user_string("EAP private key file - ", private_key, 99) &&
+ test_get_user_string("EAP private-key password - ", private_key_password, 99)) {
+ rv = wifi_manager_config_set_eap_private_key_info(config, private_key, private_key_password);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+ }
+ }
+
+ if (test_get_user_int("EAP auth type (None(0), PAP(1), MSCHAP(2), MSCHAPv2(3), GTC(4), MD5(5)) - (Enter for skip): ", &eap_auth_type)) {
+ rv = wifi_manager_config_set_eap_auth_type(config, eap_auth_type);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("EAP subject match - (Enter for skip): ", subject_match, 99)) {
+ rv = wifi_manager_config_set_eap_subject_match(config, subject_match);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+ }
+ }
+
+ rv = wifi_manager_config_save(wifi, config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ rv = wifi_manager_config_destroy(config);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+int test_wifi_manager_config_remove(void)
+{
+ int rv;
+ struct _wifi_conf c;
+
+ printf("Input AP configuration\n");
+ printf("Name : ");
+ rv = scanf(" %32[^\n]s", c.name);
+ if (rv <= 0)
+ return -1;
+
+ printf("Security type(None(0), WEP(1), WPA-PSK(2), EAP(4) : ");
+ rv = scanf(" %d", &c.type);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_config_foreach_configuration(wifi, _test_config_list_cb_for_remove, &c);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get configurations [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_tdls_discover()
+{
+ int rv = 0;
+
+ char peer_mac[MAC_ADDR_LEN + 1];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+
+ rv = wifi_manager_tdls_start_discovery(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_tdls_discover() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int test_wifi_manager_tdls_connect()
+{
+ int rv = 0;
+
+ char peer_mac[MAC_ADDR_LEN + 1];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+
+ rv = wifi_manager_tdls_connect(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_tdls_connect() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ return 1;
+
+}
+
+int test_wifi_manager_tdls_get_connected_peer(void)
+{
+ int rv = 0;
+ char *mac_addr = NULL;
+
+ rv = wifi_manager_tdls_get_connected_peer(wifi, &mac_addr);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("wifi_manager_tdls_get_connected_peer() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ printf("Peer Mac address is [%s]\n", mac_addr);
+ g_free(mac_addr);
+ return 1;
+}
+
+int test_wifi_manager_tdls_disconnect(void)
+{
+ int rv = 0;
+
+ char peer_mac[MAC_ADDR_LEN + 1];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+
+ rv = wifi_manager_tdls_disconnect(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_tdls_disconnect() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ return 1;
+}
+int test_wifi_manager_tdls_enable_channel_switch(void)
+{
+ int rv = 0;
+ char peer_mac[MAC_ADDR_LEN + 1];
+ int freq;
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+ printf("Enter Peer Frequency:\n");
+ rv = scanf("%9d", &freq);
+ if (rv <= 0) {
+ printf("Invalid input!\n");
+ return -1;
+ }
+ rv = wifi_manager_tdls_enable_channel_switching(wifi, peer_mac, freq);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_manager_tdls_channel_switch() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ return 1;
+}
+int test_wifi_manager_tdls_disable_channel_switch(void)
+{
+ int rv = 0;
+ char peer_mac[MAC_ADDR_LEN + 1];
+ printf("Enter Mac_address: ");
+ if (scanf(" %17s", peer_mac) < 1)
+ return -1;
+ if (strlen(peer_mac) < MAC_ADDR_LEN) {
+ printf("Wrong Mac_address\n");
+ return -1;
+ }
+ rv = wifi_manager_tdls_disable_channel_switching(wifi, peer_mac);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("test_wifi_manager_tdls_cancle_channel_switch() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ return 1;
+}
+int test_wifi_manager_get_module_state(void)
+{
+ int rv = 0;
+ wifi_manager_module_state_e module_state;
+
+ rv = wifi_manager_get_module_state(wifi, &module_state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get wifi module state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Success to get WiFI Module state : ");
+ switch (module_state) {
+ case WIFI_MANAGER_MODULE_STATE_ATTACHED:
+ printf("Wi-Fi Module Attached \n");
+ break;
+ case WIFI_MANAGER_MODULE_STATE_DETACHED:
+ printf("Wi-Fi Module Detached\n");
+ break;
+ default:
+ printf("Unknown\n");
+ }
+
+ return 1;
+}
+
+
+int test_wifi_manager_connect_hidden_ap(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ char passphrase[65];
+ bool state = false;
+ int sec_type;
+
+ rv = wifi_manager_is_activated(wifi, &state);
+ if (rv != WIFI_MANAGER_ERROR_NONE || state == false)
+ return -1;
+
+ printf("Input hidden AP name to connect : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ printf("Input Security Type :\n");
+ printf("0 -> WIFI_SECURITY_TYPE_NONE\n");
+ printf("1 -> WIFI_SECURITY_TYPE_WEP\n");
+ printf("2 -> WIFI_SECURITY_TYPE_WPA_PSK/WIFI_SECURITY_TYPE_WPA2_PSK\n");
+
+ rv = scanf(" %d", &sec_type);
+ if (sec_type == 1 || sec_type == 2) {
+ printf("Input hidden AP passphrase : ");
+ rv = scanf("%64s", passphrase);
+ }
+
+ rv = wifi_manager_connect_hidden_ap(wifi, ap_name, sec_type, passphrase,
+ __test_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to connect to hidden AP [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Hidden Connection step finished\n");
+ return 1;
+}
+
+static void __test_wifi_manager_wps_pbc_connected_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi WPS PBC Connection Succeeded\n");
+ else
+ printf("Wi-Fi WPS PBC Connection Failed! error : %s\n",
+ __test_convert_error_to_string(result));
+}
+
+static void __test_wifi_manager_wps_pin_connected_callback(wifi_manager_error_e result, void* user_data)
+{
+ if (result == WIFI_MANAGER_ERROR_NONE)
+ printf("Wi-Fi WPS PIN Connection Succeeded\n");
+ else
+ printf("Wi-Fi WPS PIN Connection Failed! error : %s\n",
+ __test_convert_error_to_string(result));
+}
+
+int test_wifi_manager_connect_wps_pbc_without_ssid(void)
+{
+ int rv;
+ rv = wifi_manager_connect_by_wps_pbc_without_ssid(wifi, __test_wifi_manager_wps_pbc_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to WPS connection request : %s\n", __test_convert_error_to_string(rv));
+ else
+ printf("Success to WPS connection request \n");
+ return 1;
+}
+
+int test_wifi_manager_connect_wps_pin_without_ssid(void)
+{
+ int rv;
+ char pin[9];
+
+ printf("Input pin to wps pin connect : ");
+
+ rv = scanf(" %8s", pin);
+ if (rv <= 0)
+ return -1;
+
+ if ((strlen(pin) != 4) &&
+ (strlen(pin) != 8)) {
+ printf("Wrong pin number (4 or 8)\n");
+ return -1;
+ }
+
+ rv = wifi_manager_connect_by_wps_pin_without_ssid(wifi, pin, __test_wifi_manager_wps_pin_connected_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to WPS connection request : %s\n", __test_convert_error_to_string(rv));
+ else
+ printf("Success to WPS connection request \n");
+ return 1;
+}
+
+int test_wifi_manager_cancel_wps(void)
+{
+ int rv;
+ rv = wifi_manager_cancel_wps(wifi);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to WPS cancel request : %s\n", __test_convert_error_to_string(rv));
+ else
+ printf("Success to WPS cancel request \n");
+ return 1;
+}
+
+int test_wifi_manager_get_wps_generated_pin(void)
+{
+ int rv = 0;
+ char *wps_pin = NULL;
+
+ rv = wifi_manager_get_wps_generated_pin(wifi, &wps_pin);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("wifi_manager_get_wps_generated_pin() is failed [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ printf("Generaged pin number is [%s]\n", wps_pin);
+ g_free(wps_pin);
+ return 1;
+}
+
+int test_wifi_manager_forget_ap_async(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("Input a part of AP name to forget : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_forget_ap_async_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to forget (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Forget AP async finished\n");
+
+ return 1;
+}
+
+int test_wifi_manager_set_autoscan_state(void)
+{
+ int autoscan = 0;
+ int rv = 0;
+
+ printf("Input enable/disable for autoscan (0:enable, 1:disable) :\n");
+ rv = scanf(" %9d", &autoscan);
+
+ if (rv <= 0) {
+ printf("Invalid input!\n");
+ return -1;
+ }
+
+ switch (autoscan) {
+ case 0:
+ rv = wifi_manager_set_autoscan(wifi, true);
+ break;
+
+ case 1:
+ rv = wifi_manager_set_autoscan(wifi, false);
+ break;
+
+ default:
+ printf("Invalid input!\n");
+ return -1;
+ }
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("failed to set autoscan [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_set_autoscan_mode(void)
+{
+ int mode = 0;
+ int rv = 0;
+
+ printf("Input autoscan mode (0:exponential, 1:periodic) :\n");
+ rv = scanf(" %9d", &mode);
+
+ if (rv <= 0) {
+ printf("Invalid input!\n");
+ return -1;
+ }
+
+ rv = wifi_manager_set_autoscan_mode(wifi, mode);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("failed to set autoscan mode [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_get_autoscan_state(void)
+{
+ int rv = 0;
+ bool autoscan = FALSE;
+
+ rv = wifi_manager_get_autoscan(wifi, &autoscan);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get auto scan state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Auto scan state (0:enable, 1:disable) : %d\n", autoscan);
+ return 1;
+}
+
+int test_wifi_manager_get_autoscan_mode(void)
+{
+ int rv = 0;
+ wifi_manager_autoscan_mode_e autoscan_mode;
+
+ rv = wifi_manager_get_autoscan_mode(wifi, &autoscan_mode);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get auto scan mode [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Auto Scan Mode (0:exponential, 1:periodic) : %d\n", autoscan_mode);
+ return 1;
+}
+
+static bool __test_get_bssid_scan_list(wifi_manager_ap_h ap, void *user_data)
+{
+ char *bssid;
+ char *essid;
+ int rssi;
+
+ if (wifi_manager_ap_get_bssid(ap, &bssid) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get bssid for ap\n");
+ return false;
+ }
+
+ if (wifi_manager_ap_get_essid(ap, &essid) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get essid for ap\n");
+ g_free(bssid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_rssi(ap, &rssi) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get rssi for ap\n");
+ g_free(bssid);
+ g_free(essid);
+ return false;
+ }
+
+ printf("bssid : %s, essid : %s, rssi : %d\n",
+ bssid, essid, rssi);
+
+ g_free(bssid);
+ g_free(essid);
+ return true;
+}
+
+int test_wifi_manager_foreach_bssid_scan(void)
+{
+ int rv;
+
+ rv = wifi_manager_foreach_found_bssid_ap(wifi,
+ __test_get_bssid_scan_list, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get wps scan list [%s]\n",
+ __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_bssid_scan(void)
+{
+ int rv = 0;
+ rv = wifi_manager_bssid_scan(wifi, __test_bssid_scan_request_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to request bssid scan [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("BSSID Scan request succeeded\n");
+ return 1;
+}
+
+static bool __test_get_netlink_scan_list(wifi_manager_ap_h ap, void *user_data)
+{
+ char *bssid = NULL;
+ char *essid = NULL;
+ int freq;
+ int rssi;
+ wifi_manager_security_type_e sec_type;
+ wifi_manager_encryption_type_e enc_type;
+
+ if (wifi_manager_ap_get_bssid(ap, &bssid) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get bssid for ap\n");
+ g_free(bssid);
+ return false;
+ }
+
+
+ if (wifi_manager_ap_get_essid(ap, &essid) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get essid for ap\n");
+ g_free(bssid);
+ g_free(essid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_frequency(ap, &freq) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get Frequency\n");
+ g_free(bssid);
+ g_free(essid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_rssi(ap, &rssi) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get rssi for ap\n");
+ g_free(bssid);
+ g_free(essid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_security_type(ap, &sec_type) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get security type for ap\n");
+ g_free(bssid);
+ g_free(essid);
+ return false;
+ }
+
+ if (wifi_manager_ap_get_encryption_type(ap, &enc_type) != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get encryption type for ap\n");
+ g_free(bssid);
+ g_free(essid);
+ return false;
+ }
+
+ printf("%s, %d, %d, %s\n", bssid, freq, rssi, essid);
+ printf("Security type : ");
+ switch (sec_type) {
+ case WIFI_MANAGER_SECURITY_TYPE_NONE:
+ printf("NONE, ");
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WEP:
+ printf("WEP, ");
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK:
+ printf("WPAPSK, ");
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK:
+ printf("WPA2PSK, ");
+ break;
+ case WIFI_MANAGER_SECURITY_TYPE_EAP:
+ printf("EAP, ");
+ break;
+ default:
+ break;
+ }
+ printf("Encryption type : ");
+ switch (enc_type) {
+ case WIFI_MANAGER_ENCRYPTION_TYPE_NONE:
+ printf("NONE\n");
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_WEP:
+ printf("WEP\n");
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP:
+ printf("TKIP\n");
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_AES:
+ printf("CCMP\n");
+ break;
+ case WIFI_MANAGER_ENCRYPTION_TYPE_TKIP_AES_MIXED:
+ printf("Mixed\n");
+ break;
+ default:
+ break;
+ }
+
+ if (wifi_manager_ap_foreach_vsie(ap, __test_vendor_specific_callback, NULL) != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to get vsie\n");
+
+ g_free(bssid);
+ g_free(essid);
+ return true;
+}
+
+int test_wifi_manager_foreach_netlink_scan(void)
+{
+ int rv;
+
+ rv = wifi_manager_foreach_found_netlink_scan_ap(wifi,
+ __test_get_netlink_scan_list, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get netlink scan list [%s]\n",
+ __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_netlink_scan(void)
+{
+ int rv = 0, scan_type = -1, add_vsie = -1;
+ int ret = 1;
+ char ssid[32+1];
+ char vsie[255];
+ wifi_manager_netlink_scan_h netlink_scan = NULL;
+
+ rv = wifi_manager_netlink_scan_create(wifi, &netlink_scan);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to create netlink scan handle [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Netlink Scan handle created [%p]\n", netlink_scan);
+
+ rv = test_get_user_int("Input netlink scan type"
+ "(0:Normal, 1:Specific AP):", &scan_type);
+ if (rv == false || (scan_type != 0 && scan_type != 1)) {
+ printf("Invalid input!!\n");
+ ret = -1;
+ goto out;
+ }
+
+ if (scan_type == 1) {
+ int i, num;
+ rv = test_get_user_int("Input number of ssid:", &num);
+ if (rv == false || num <= 0) {
+ printf("Invalid input!!\n");
+ ret = -1;
+ goto out;
+ }
+
+ for (i = 0; i < num; i++) {
+ printf("Input ssid:\n");
+ rv = scanf(" %32[^\n]s", ssid);
+
+ rv = wifi_manager_netlink_scan_set_ssid(netlink_scan, ssid);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
+ ret = -1;
+ goto out;
+ }
+ }
+ }
+
+ rv = test_get_user_int("Add vsie option"
+ "(0:No, 1:Yes):", &add_vsie);
+ if (rv == false || (add_vsie != 0 && add_vsie != 1)) {
+ printf("Invalid input!!\n");
+ ret = -1;
+ goto out;
+ }
+
+ if (add_vsie) {
+ printf("Input vsie:\n");
+ rv = scanf(" %250s", vsie);
+
+ rv = wifi_manager_netlink_scan_set_vsie(netlink_scan, vsie);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set vsie [%s]", __test_convert_error_to_string(rv));
+ ret = -1;
+ goto out;
+ }
+ }
+
+ rv = wifi_manager_netlink_scan(wifi, netlink_scan, __test_netlink_scan_request_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to request netlink scan [%s]\n", __test_convert_error_to_string(rv));
+ ret = -1;
+ goto out;
+ }
+
+ printf("netlink Scan request succeeded\n");
+
+out:
+ rv = wifi_manager_netlink_scan_destroy(wifi, netlink_scan);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to destroy netlink scan handle [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return ret;
+}
+
+int test_wifi_manager_get_scan_state(void)
+{
+ int rv = 0;
+ wifi_manager_scan_state_e scan_state = -1;
+
+ rv = wifi_manager_get_scan_state(wifi, &scan_state);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get scan state [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Scan state [%d]\n", scan_state);
+
+ return 1;
+}
+
+int test_wifi_manager_add_vsie(void)
+{
+ int rv = 0;
+ char *vsie = NULL;
+ unsigned int frame_id;
+
+ printf("Input frame_id:\n");
+ if (scanf(" %2u", &frame_id) < 1)
+ return -1;
+
+ printf("Input vsie:\n");
+ if (scanf(" %100ms", &vsie) < 1)
+ return -1;
+
+ if (strlen(vsie) == 0)
+ printf("invalid vsie !!\n");
+ else
+ printf("vsie: [%s]\n", vsie);
+
+ if ((strlen(vsie) > 0)) {
+ rv = wifi_manager_add_vsie(wifi, frame_id, vsie);
+ printf("wifi_manager_add_vsie() ret=[%d]\n", rv);
+
+ g_free(vsie);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to add vsie [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_get_vsie(void)
+{
+ int rv = 0;
+ char *vsie = NULL;
+ unsigned int frame_id;
+
+ printf("Input frame_id:\n");
+ if (scanf(" %2u", &frame_id) < 1)
+ return -1;
+
+ rv = wifi_manager_get_vsie(wifi, frame_id, &vsie);
+ printf("Received vsie [%s]\n", vsie ? vsie : "NULL");
+
+ g_free(vsie);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to get vsie [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_remove_vsie(void)
+{
+ int rv = 0;
+ char *vsie = NULL;
+ unsigned int frame_id;
+
+ printf("Input frame_id:\n");
+ if (scanf(" %2u", &frame_id) < 1)
+ return -1;
+
+ printf("Input vsie:\n");
+ if (scanf(" %100ms", &vsie) < 1)
+ return -1;
+
+ if (strlen(vsie) == 0)
+ printf("invalid vsie !!\n");
+ else
+ printf("vsie: [%s]\n", vsie);
+
+ if ((strlen(vsie) > 0)) {
+ rv = wifi_manager_remove_vsie(wifi, frame_id, vsie);
+ printf("wifi_manager_remove_vsie() ret=[%d]\n", rv);
+
+ g_free(vsie);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to remove vsie [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+int test_wifi_manager_specific_ap_start_multi_scan(void)
+{
+ int rv = 0, scan_type, num = 0;
+ char ssid[32 + 1];
+ int freq;
+ int i = 0;
+ wifi_manager_specific_scan_h specific_scan = NULL;
+
+ rv = wifi_manager_specific_scan_create(wifi, &specific_scan);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to create specific scan handle [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Specific Scan handle created [%p]\n", specific_scan);
+
+ rv = test_get_user_int("Input multi scan type"
+ "(0:SSID, 1:Freq, 2: SSID & Freq):", &scan_type);
+
+ if (rv == false || (scan_type != 0 && scan_type != 1 && scan_type != 2)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ if (scan_type == 0 || scan_type == 1) {
+ rv = test_get_user_int("No. of specific ssid/freq for multi scan",
+ &num);
+ if (rv == false || (num <= 0) || (num > 4)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ if (scan_type == 0) { /** multi ssid scan */
+ for (i = 0; i < num; i++) {
+ printf("Input ssid[%d]:\n", i);
+ rv = scanf(" %32[^\n]s", ssid);
+
+ rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ }
+ } else { /** multi frequency scan */
+ for (i = 0; i < num; i++) {
+ printf("Input freq[%d]:\n", i);
+ rv = scanf(" %d", &freq);
+ rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set freq [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ }
+ }
+ } else { /** SSID & frequency mixed scan */
+ rv = test_get_user_int("No. of ssid&freq for dual parameter multi scan",
+ &num);
+ if (rv == false || (num <= 0) || (num > 4)) {
+ printf("Invalid input!!\n");
+ return false;
+ }
+
+ for (i = 0; i < num; i++) {
+ printf("Input ssid:\n");
+ rv = scanf(" %32[^\n]s", ssid);
+
+ rv = wifi_manager_specific_scan_set_ssid(specific_scan, ssid);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set ssid [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ printf("Input freq:\n");
+ rv = scanf(" %d", &freq);
+
+ rv = wifi_manager_specific_scan_set_freq(specific_scan, freq);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set freq [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ }
+ }
+
+ rv = wifi_manager_specific_ap_start_multi_scan(wifi, specific_scan,
+ __test_multi_scan_callback, NULL);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to start multi scan[%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+ printf("Specific Multi Scan requested\n");
+
+ rv = wifi_manager_specific_scan_destroy(wifi, specific_scan);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to destroy specific scan handle [%s]", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("Specific Scan handle destroyed\n");
+
+ return 1;
+}
+
+int test_wifi_manager_flush_bss(void)
+{
+ int rv;
+
+ rv = wifi_manager_flush_bss(wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to flush bss rv = %d\n", rv);
+ return -1;
+ }
+
+ printf("Request to flush bss\n");
+ return 1;
+}
+
+int test_wifi_manager_set_auto_connect(void)
+{
+ int rv;
+ int mode;
+
+ printf("Auto connect mode (1:enable, 0:disable) : ");
+ rv = scanf(" %d", &mode);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_auto_connect(wifi, mode);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set auto connect mode, rv = %d\n", rv);
+ }
+
+ printf("Request to set auto connect mode\n");
+ return 1;
+}
+
+int test_wifi_manager_get_auto_connect(void)
+{
+ int rv;
+ int mode;
+
+ rv = wifi_manager_get_auto_connect(wifi, &mode);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get auto connect mode, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("Request to get auto connect mode = %d (1:enable, 0:disable)\n", mode);
+ return 1;
+}
+
+int test_wifi_manager_set_ap_auto_connect(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("[Wi-Fi] Input a part of AP name to set : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_set_autoconnect_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[Wi-Fi] Fail to set up (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("[Wi-Fi] Set up finished\n");
+ return 1;
+}
+
+int test_wifi_manager_get_ap_auto_connect(void)
+{
+ int rv = 0;
+ char ap_name[33];
+ bool state = false;
+
+ wifi_manager_is_activated(wifi, &state);
+ if (state == false)
+ return -1;
+
+ printf("[Wi-Fi] Input a part of AP name to get : ");
+ rv = scanf(" %32[^\n]s", ap_name);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_foreach_found_ap(wifi, __test_found_get_autoconnect_ap_callback, ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("[Wi-Fi] Fail to get up (can't get AP list) [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ printf("[Wi-Fi] Get up finished\n");
+ return 1;
+}
+
+int test_wifi_manager_set_passpoint_enable(void)
+{
+ int rv;
+ int enable;
+
+ printf("Enter passpoint on/off(0:off, 1:on) : \n");
+ rv = scanf(" %d", &enable);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_passpoint(wifi, enable);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to set passpoint, rv = %d\n", rv);
+ }
+
+ printf("Request to set passpoint\n");
+ return 1;
+}
+
+int test_wifi_manager_get_passpoint_state(void)
+{
+ int rv;
+ int enabled;
+
+ rv = wifi_manager_get_passpoint(wifi, &enabled);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get passpoint state, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("current passpoint sate(0:off, 1:on) = [%d]\n", enabled);
+ return 1;
+}
+
+int test_wifi_manager_get_5ghz_band_supported(void)
+{
+ int rv;
+ bool supported;
+
+ rv = wifi_manager_is_5ghz_band_supported(wifi, &supported);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get 5ghz supported, rv = %d\n", rv);
+ return 1;
+ }
+
+ printf("Is 5Ghz supported = [%s]\n", supported ? "yes" : "no");
+ return 1;
+}
+
+int test_wifi_manager_get_connection_mode(void)
+{
+ int rv, int_value;
+ wifi_manager_connection_mode_e mode;
+ char *ap_name = NULL;
+ wifi_manager_ap_h ap_h;
+
+ rv = wifi_manager_get_connected_ap(wifi, &ap_h);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connected AP [%s]\n", __test_convert_error_to_string(rv));
+ return -1;
+ }
+
+ rv = wifi_manager_ap_get_essid(ap_h, &ap_name);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get essid [%s]\n", __test_convert_error_to_string(rv));
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ rv = wifi_manager_ap_get_max_speed(ap_h, &int_value);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get max speed[%s]\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ rv = wifi_manager_get_connection_mode(wifi, &mode);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get connection mode[%s]\n", __test_convert_error_to_string(rv));
+ g_free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+ return -1;
+ }
+
+ printf("Connected AP : %s\n", ap_name);
+ printf("Connection mode : %s\n", __test_convert_connection_mode_to_string(mode));
+ printf("Link speed : %d\n", int_value);
+ g_free(ap_name);
+ wifi_manager_ap_destroy(ap_h);
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ GMainLoop *mainloop;
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ GIOChannel *channel = g_io_channel_unix_new(0);
+ g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
+
+ printf("Test Thread created...\n");
+
+ g_main_loop_run(mainloop);
+
+ return 0;
+}
+
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ int rv;
+ char a[10];
+
+ printf("Event received from stdin\n");
+
+ rv = read(0, a, 10);
+
+ if (rv <= 0 || a[0] == '0') {
+ rv = wifi_manager_deinitialize(wifi);
+
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ printf("Fail to deinitialize.\n");
+
+ exit(1);
+ }
+
+ if (a[0] == '\n' || a[0] == '\r') {
+/* Public API */
+ printf("\n\n Network Connection API Test App\n\n");
+ printf("Options..\n");
+ printf(LOG_BLUE "[Public APIs]\n" LOG_END);
+ printf(LOG_GREEN "1 - Wi-Fi init and set callbacks\n" LOG_END);
+ printf("2 - Wi-Fi deinit(unset callbacks automatically)\n");
+ printf(LOG_GREEN "3 - Activate Wi-Fi device\n" LOG_END);
+ printf("4 - Deactivate Wi-Fi device\n");
+ printf("5 - Is Wi-Fi activated?\n");
+ printf("6 - Get connection state\n");
+ printf("7 - Get MAC address\n");
+ printf("8 - Get Wi-Fi interface name\n");
+ printf(LOG_GREEN "9 - Scan request\n" LOG_END);
+ printf("a - Get Connected AP\n");
+ printf("b - Get AP list\n");
+ printf(LOG_GREEN "c - Connect\n" LOG_END);
+ printf("d - Disconnect\n");
+ printf("e - Connect by wps pbc\n");
+ printf("f - Forget an AP\n");
+ printf("g - Set & connect EAP\n");
+ printf("h - Set IP method type\n");
+ printf("i - Set Proxy method type\n");
+ printf("j - Get Ap info\n");
+ printf("k - Connect Specific AP\n");
+ printf("l - Load configuration\n");
+ printf("m - Save configuration\n");
+ printf("n - Remove configuration\n");
+ printf("o - TDLS Discover\n");
+ printf("p - TDLS Connect\n");
+ printf("q - TDLS Connected peer\n");
+ printf("r - TDLS Disconnect\n");
+ printf("s - Connect Hidden AP\n");
+ printf("t - Connect WPS PBC without SSID\n");
+ printf("u - Connect WPS PIN without SSID\n");
+ printf("v - Cancel WPS Request\n");
+ printf("w - Get wifi scanning state\n");
+ printf("x - Enable TDLS Channel Switch Request\n");
+ printf("y - Disable TDLS Channel Switch Request\n");
+ printf("z - Get Wi-Fi Module State\n");
+ printf("A - BSSID Scan (Wi-Fi Position System Scan)\n");
+ printf("B - Multi Scan (Multi Frequency & Multi SSID)\n");
+ printf("C - Add VSIE\n");
+ printf("D - Get VSIE\n");
+ printf("E - Remove VSIE\n");
+ printf("F - Set IP conflict detection mode\n");
+ printf("G - Get IP conflict detection mode\n");
+ printf("H - Get IP conflict state\n");
+ printf("I - Get generated PIN number\n");
+ printf("J - Forget an AP(async)\n");
+/* Extension APIs */
+ printf(LOG_BLUE "[Extension API]\n" LOG_END);
+ printf("K - Set Enable or Disable Auto Scan\n");
+ printf("L - Set Mode of Auto Scan\n");
+ printf("M - Get Enable or Disable Auto Scan\n");
+ printf("N - Get Mode of Auto Scan\n");
+ printf("O - Flush BSS\n");
+ printf("P - Set enable or disable auto connect\n");
+ printf("Q - Get enable or disable auto connect\n");
+ printf("R - Set enable or disable of Wi-Fi profile auto-connect\n");
+ printf("S - Get enable or disable of Wi-Fi profile auto-connect\n");
+ printf("T - Set the IP conflict detection period\n");
+ printf("U - Get the IP conflict detection period\n");
+ printf("V - Netlink Scan Normal/Specific-AP\n");
+ printf("W - Get passpoint state\n");
+ printf("X - Set passpoint on/off\n");
+ printf("Y - Get Access Point Hardware Mode\n");
+ printf("Z - Get 5Ghz supported\n");
+ printf(LOG_RED "0 - Exit \n" LOG_END);
+
+ printf("ENTER - Show options menu.......\n");
+ }
+
+ switch (a[0]) {
+/* Public API */
+ case '1':
+ rv = test_wifi_manager_init();
+ break;
+ case '2':
+ rv = test_wifi_manager_deinit();
+ break;
+ case '3':
+ rv = test_wifi_manager_activate();
+ break;
+ case '4':
+ rv = test_wifi_manager_deactivate();
+ break;
+ case '5':
+ rv = test_wifi_manager_is_activated();
+ break;
+ case '6':
+ rv = test_wifi_manager_get_connection_state();
+ break;
+ case '7':
+ rv = test_wifi_manager_get_mac_address();
+ break;
+ case '8':
+ rv = test_wifi_manager_get_interface_name();
+ break;
+ case '9':
+ rv = test_wifi_manager_scan();
+ break;
+ case 'a':
+ rv = test_wifi_manager_get_connected_ap();
+ break;
+ case 'b':
+ rv = test_wifi_manager_foreach_found_ap();
+ break;
+ case 'c':
+ rv = test_wifi_manager_connect();
+ break;
+ case 'd':
+ rv = test_wifi_manager_disconnect();
+ break;
+ case 'e':
+ rv = test_wifi_manager_connect_wps();
+ break;
+ case 'f':
+ rv = test_wifi_manager_forget_ap();
+ break;
+ case 'g':
+ rv = test_wifi_manager_connect_eap_ap();
+ break;
+ case 'h':
+ rv = test_wifi_manager_set_ip_method();
+ break;
+ case 'i':
+ rv = test_wifi_manager_set_proxy_method();
+ break;
+ case 'j':
+ rv = test_wifi_manager_get_ap_info();
+ break;
+ case 'k':
+ rv = test_wifi_manager_connect_specific_ap();
+ break;
+ case 'l':
+ rv = test_wifi_manager_config_load_configuration();
+ break;
+ case 'm':
+ rv = test_wifi_manager_config_save();
+ break;
+ case 'n':
+ rv = test_wifi_manager_config_remove();
+ break;
+ case 'o':
+ rv = test_wifi_manager_tdls_discover();
+ break;
+ case 'p':
+ rv = test_wifi_manager_tdls_connect();
+ break;
+ case 'q':
+ rv = test_wifi_manager_tdls_get_connected_peer();
+ break;
+ case 'r':
+ rv = test_wifi_manager_tdls_disconnect();
+ break;
+ case 's':
+ rv = test_wifi_manager_connect_hidden_ap();
+ break;
+ case 't':
+ rv = test_wifi_manager_connect_wps_pbc_without_ssid();
+ break;
+ case 'u':
+ rv = test_wifi_manager_connect_wps_pin_without_ssid();
+ break;
+ case 'v':
+ rv = test_wifi_manager_cancel_wps();
+ break;
+ case 'w':
+ rv = test_wifi_manager_get_scan_state();
+ break;
+ case 'x':
+ rv = test_wifi_manager_tdls_enable_channel_switch();
+ break;
+ case 'y':
+ rv = test_wifi_manager_tdls_disable_channel_switch();
+ break;
+ case 'z':
+ rv = test_wifi_manager_get_module_state();
+ break;
+ case 'A':
+ rv = test_wifi_manager_bssid_scan();
+ break;
+ case 'B':
+ rv = test_wifi_manager_specific_ap_start_multi_scan();
+ break;
+ case 'C':
+ rv = test_wifi_manager_add_vsie();
+ break;
+ case 'D':
+ rv = test_wifi_manager_get_vsie();
+ break;
+ case 'E':
+ rv = test_wifi_manager_remove_vsie();
+ break;
+ case 'F':
+ rv = test_wifi_manager_set_ip_conflict_detect_enable();
+ break;
+ case 'G':
+ rv = test_wifi_manager_ip_conflict_detect_is_enabled();
+ break;
+ case 'H':
+ rv = test_wifi_manager_get_ip_conflict_state();
+ break;
+ case 'I':
+ rv = test_wifi_manager_get_wps_generated_pin();
+ break;
+ case 'J':
+ rv = test_wifi_manager_forget_ap_async();
+ break;
+
+/* Extension APIs */
+ case 'K':
+ rv = test_wifi_manager_set_autoscan_state();
+ break;
+ case 'L':
+ rv = test_wifi_manager_set_autoscan_mode();
+ break;
+ case 'M':
+ rv = test_wifi_manager_get_autoscan_state();
+ break;
+ case 'N':
+ rv = test_wifi_manager_get_autoscan_mode();
+ break;
+ case 'O':
+ rv = test_wifi_manager_flush_bss();
+ break;
+ case 'P':
+ rv = test_wifi_manager_set_auto_connect();
+ break;
+ case 'Q':
+ rv = test_wifi_manager_get_auto_connect();
+ break;
+ case 'R':
+ rv = test_wifi_manager_set_ap_auto_connect();
+ break;
+ case 'S':
+ rv = test_wifi_manager_get_ap_auto_connect();
+ break;
+ case 'T':
+ rv = test_wifi_manager_set_ip_conflict_period();
+ break;
+ case 'U':
+ rv = test_wifi_manager_get_ip_conflict_period();
+ break;
+ case 'V':
+ rv = test_wifi_manager_netlink_scan();
+ break;
+ case 'W':
+ rv = test_wifi_manager_get_passpoint_state();
+ break;
+ case 'X':
+ rv = test_wifi_manager_set_passpoint_enable();
+ break;
+ case 'Y':
+ rv = test_wifi_manager_get_connection_mode();
+ break;
+ case 'Z':
+ rv = test_wifi_manager_get_5ghz_band_supported();
+ break;
+ default:
+ break;
+ }
+
+ if (rv == 1)
+ printf("Operation succeeded!\n");
+ else
+ printf("Operation failed!\n");
+
+ return TRUE;
+}