mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
Consolidate and optimize test suite (80 -> 43 tests)
This commit is contained in:
@@ -9,6 +9,7 @@ monitor_speed = 115200
|
||||
test_framework = unity
|
||||
test_build_src = no
|
||||
lib_deps =
|
||||
${platformio.lib_dir}/../lib/WiFiManager
|
||||
bblanchon/ArduinoJson@^6.21.0
|
||||
|
||||
[env:esp32]
|
||||
@@ -19,5 +20,6 @@ monitor_speed = 115200
|
||||
test_framework = unity
|
||||
test_build_src = no
|
||||
lib_deps =
|
||||
${platformio.lib_dir}/../lib/WiFiManager
|
||||
bblanchon/ArduinoJson@^6.21.0
|
||||
|
||||
|
||||
@@ -11,22 +11,9 @@ TestCase tests[] = {
|
||||
TEST_ENTRY(test_disconnect),
|
||||
|
||||
// Configuration tests
|
||||
TEST_ENTRY(test_set_title),
|
||||
TEST_ENTRY(test_set_config_portal_timeout),
|
||||
TEST_ENTRY(test_set_connect_timeout),
|
||||
TEST_ENTRY(test_set_http_port),
|
||||
TEST_ENTRY(test_set_minimum_signal_quality),
|
||||
TEST_ENTRY(test_set_remove_duplicate_aps),
|
||||
TEST_ENTRY(test_set_show_static_fields),
|
||||
TEST_ENTRY(test_set_show_dns_fields),
|
||||
TEST_ENTRY(test_set_config_portal_blocking),
|
||||
TEST_ENTRY(test_set_captive_portal_enable),
|
||||
TEST_ENTRY(test_set_hostname),
|
||||
TEST_ENTRY(test_set_wifi_ap_channel),
|
||||
TEST_ENTRY(test_set_wifi_ap_hidden),
|
||||
TEST_ENTRY(test_set_clean_connect),
|
||||
TEST_ENTRY(test_set_country),
|
||||
TEST_ENTRY(test_set_wifi_auto_reconnect),
|
||||
TEST_ENTRY(test_configuration_setters),
|
||||
TEST_ENTRY(test_set_and_get_hostname),
|
||||
TEST_ENTRY(test_wifi_ap_configuration_setters),
|
||||
TEST_ENTRY(test_get_default_ap_name),
|
||||
TEST_ENTRY(test_get_wifi_status_string),
|
||||
TEST_ENTRY(test_get_mode_string),
|
||||
@@ -34,6 +21,7 @@ TestCase tests[] = {
|
||||
|
||||
// Portal lifecycle tests
|
||||
TEST_ENTRY(test_start_config_portal),
|
||||
TEST_ENTRY(test_start_config_portal_with_password),
|
||||
TEST_ENTRY(test_start_config_portal_auto_name),
|
||||
TEST_ENTRY(test_stop_config_portal),
|
||||
TEST_ENTRY(test_config_portal_infrastructure),
|
||||
@@ -44,19 +32,14 @@ TestCase tests[] = {
|
||||
TEST_ENTRY(test_get_config_portal_ssid),
|
||||
|
||||
// Non-blocking tests
|
||||
TEST_ENTRY(test_nonblocking_mode_setup),
|
||||
TEST_ENTRY(test_nonblocking_process),
|
||||
TEST_ENTRY(test_ap_client_check),
|
||||
TEST_ENTRY(test_web_portal_client_check),
|
||||
TEST_ENTRY(test_client_check_setters),
|
||||
TEST_ENTRY(test_nonblocking_timeout_behavior),
|
||||
|
||||
// Callback tests
|
||||
TEST_ENTRY(test_ap_callback),
|
||||
TEST_ENTRY(test_web_server_callback),
|
||||
TEST_ENTRY(test_config_reset_callback),
|
||||
TEST_ENTRY(test_save_config_callback_registration),
|
||||
TEST_ENTRY(test_save_params_callback_registration),
|
||||
TEST_ENTRY(test_config_portal_timeout_callback_registration),
|
||||
TEST_ENTRY(test_callback_registration),
|
||||
TEST_ENTRY(test_multiple_callbacks),
|
||||
|
||||
// Parameter tests
|
||||
@@ -71,33 +54,13 @@ TestCase tests[] = {
|
||||
|
||||
// Static IP tests
|
||||
TEST_ENTRY(test_set_ap_static_ip_config),
|
||||
TEST_ENTRY(test_set_sta_static_ip_config),
|
||||
TEST_ENTRY(test_set_sta_static_ip_config_with_dns),
|
||||
TEST_ENTRY(test_show_static_fields),
|
||||
TEST_ENTRY(test_show_dns_fields),
|
||||
TEST_ENTRY(test_sta_static_ip_configuration),
|
||||
TEST_ENTRY(test_ap_static_ip_application),
|
||||
|
||||
// Advanced options tests
|
||||
TEST_ENTRY(test_set_break_after_config),
|
||||
TEST_ENTRY(test_set_save_connect),
|
||||
TEST_ENTRY(test_set_restore_persistent),
|
||||
TEST_ENTRY(test_set_show_password),
|
||||
TEST_ENTRY(test_set_scan_disp_perc),
|
||||
TEST_ENTRY(test_set_enable_config_portal),
|
||||
TEST_ENTRY(test_set_disable_config_portal),
|
||||
TEST_ENTRY(test_set_connect_retries),
|
||||
TEST_ENTRY(test_set_save_connect_timeout),
|
||||
TEST_ENTRY(test_set_show_info_erase),
|
||||
TEST_ENTRY(test_set_show_info_update),
|
||||
TEST_ENTRY(test_set_custom_head_element),
|
||||
TEST_ENTRY(test_set_custom_body_header),
|
||||
TEST_ENTRY(test_set_custom_body_footer),
|
||||
TEST_ENTRY(test_set_custom_menu_html),
|
||||
TEST_ENTRY(test_set_menu),
|
||||
TEST_ENTRY(test_set_params_page),
|
||||
TEST_ENTRY(test_set_dark_mode),
|
||||
TEST_ENTRY(test_set_class),
|
||||
TEST_ENTRY(test_preload_wifi),
|
||||
TEST_ENTRY(test_connection_behavior_options),
|
||||
TEST_ENTRY(test_ui_display_options),
|
||||
TEST_ENTRY(test_ui_customization),
|
||||
TEST_ENTRY(test_debug_soft_ap_config),
|
||||
TEST_ENTRY(test_debug_platform_info),
|
||||
};
|
||||
|
||||
@@ -21,22 +21,9 @@ void test_reset_settings();
|
||||
void test_disconnect();
|
||||
|
||||
// Configuration tests
|
||||
void test_set_title();
|
||||
void test_set_config_portal_timeout();
|
||||
void test_set_connect_timeout();
|
||||
void test_set_http_port();
|
||||
void test_set_minimum_signal_quality();
|
||||
void test_set_remove_duplicate_aps();
|
||||
void test_set_show_static_fields();
|
||||
void test_set_show_dns_fields();
|
||||
void test_set_config_portal_blocking();
|
||||
void test_set_captive_portal_enable();
|
||||
void test_set_hostname();
|
||||
void test_set_wifi_ap_channel();
|
||||
void test_set_wifi_ap_hidden();
|
||||
void test_set_clean_connect();
|
||||
void test_set_country();
|
||||
void test_set_wifi_auto_reconnect();
|
||||
void test_configuration_setters();
|
||||
void test_set_and_get_hostname();
|
||||
void test_wifi_ap_configuration_setters();
|
||||
void test_get_default_ap_name();
|
||||
void test_get_wifi_status_string();
|
||||
void test_get_mode_string();
|
||||
@@ -44,6 +31,7 @@ void test_get_rssi_as_quality();
|
||||
|
||||
// Portal lifecycle tests
|
||||
void test_start_config_portal();
|
||||
void test_start_config_portal_with_password();
|
||||
void test_start_config_portal_auto_name();
|
||||
void test_stop_config_portal();
|
||||
void test_config_portal_infrastructure();
|
||||
@@ -54,19 +42,14 @@ void test_config_portal_already_active();
|
||||
void test_get_config_portal_ssid();
|
||||
|
||||
// Non-blocking tests
|
||||
void test_nonblocking_mode_setup();
|
||||
void test_nonblocking_process();
|
||||
void test_ap_client_check();
|
||||
void test_web_portal_client_check();
|
||||
void test_client_check_setters();
|
||||
void test_nonblocking_timeout_behavior();
|
||||
|
||||
// Callback tests
|
||||
void test_ap_callback();
|
||||
void test_web_server_callback();
|
||||
void test_config_reset_callback();
|
||||
void test_save_config_callback_registration();
|
||||
void test_save_params_callback_registration();
|
||||
void test_config_portal_timeout_callback_registration();
|
||||
void test_callback_registration();
|
||||
void test_multiple_callbacks();
|
||||
|
||||
// Parameter tests
|
||||
@@ -81,33 +64,13 @@ void test_parameter_placeholder();
|
||||
|
||||
// Static IP tests
|
||||
void test_set_ap_static_ip_config();
|
||||
void test_set_sta_static_ip_config();
|
||||
void test_set_sta_static_ip_config_with_dns();
|
||||
void test_show_static_fields();
|
||||
void test_show_dns_fields();
|
||||
void test_sta_static_ip_configuration();
|
||||
void test_ap_static_ip_application();
|
||||
|
||||
// Advanced options tests
|
||||
void test_set_break_after_config();
|
||||
void test_set_save_connect();
|
||||
void test_set_restore_persistent();
|
||||
void test_set_show_password();
|
||||
void test_set_scan_disp_perc();
|
||||
void test_set_enable_config_portal();
|
||||
void test_set_disable_config_portal();
|
||||
void test_set_connect_retries();
|
||||
void test_set_save_connect_timeout();
|
||||
void test_set_show_info_erase();
|
||||
void test_set_show_info_update();
|
||||
void test_set_custom_head_element();
|
||||
void test_set_custom_body_header();
|
||||
void test_set_custom_body_footer();
|
||||
void test_set_custom_menu_html();
|
||||
void test_set_menu();
|
||||
void test_set_params_page();
|
||||
void test_set_dark_mode();
|
||||
void test_set_class();
|
||||
void test_preload_wifi();
|
||||
void test_connection_behavior_options();
|
||||
void test_ui_display_options();
|
||||
void test_ui_customization();
|
||||
void test_debug_soft_ap_config();
|
||||
void test_debug_platform_info();
|
||||
|
||||
|
||||
@@ -2,274 +2,96 @@
|
||||
#include <Arduino.h>
|
||||
#include <WiFiManager.h>
|
||||
|
||||
// Test advanced configuration options
|
||||
void test_set_break_after_config() {
|
||||
Serial.println("[TEST] Testing setBreakAfterConfig()...");
|
||||
// Test advanced configuration options - consolidated into logical groups
|
||||
|
||||
// Test connection behavior options
|
||||
void test_connection_behavior_options() {
|
||||
Serial.println("[TEST] Testing connection behavior options...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test connection options
|
||||
wm.setBreakAfterConfig(true);
|
||||
wm.setBreakAfterConfig(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setBreakAfterConfig() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setBreakAfterConfig() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_save_connect() {
|
||||
Serial.println("[TEST] Testing setSaveConnect()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setSaveConnect(true);
|
||||
wm.setSaveConnect(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setSaveConnect() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setSaveConnect() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_restore_persistent() {
|
||||
Serial.println("[TEST] Testing setRestorePersistent()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setRestorePersistent(true);
|
||||
wm.setRestorePersistent(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setRestorePersistent() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setRestorePersistent() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_show_password() {
|
||||
Serial.println("[TEST] Testing setShowPassword()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setShowPassword(true);
|
||||
wm.setShowPassword(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setShowPassword() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setShowPassword() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_scan_disp_perc() {
|
||||
Serial.println("[TEST] Testing setScanDispPerc()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setScanDispPerc(true);
|
||||
wm.setScanDispPerc(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setScanDispPerc() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setScanDispPerc() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_enable_config_portal() {
|
||||
Serial.println("[TEST] Testing setEnableConfigPortal()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setEnableConfigPortal(true);
|
||||
wm.setEnableConfigPortal(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setEnableConfigPortal() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setEnableConfigPortal() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_disable_config_portal() {
|
||||
Serial.println("[TEST] Testing setDisableConfigPortal()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setDisableConfigPortal(true);
|
||||
wm.setDisableConfigPortal(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setDisableConfigPortal() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setDisableConfigPortal() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_connect_retries() {
|
||||
Serial.println("[TEST] Testing setConnectRetries()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setConnectRetries(1);
|
||||
wm.setConnectRetries(3);
|
||||
wm.setConnectRetries(5);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setConnectRetries() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setConnectRetries() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_save_connect_timeout() {
|
||||
Serial.println("[TEST] Testing setSaveConnectTimeout()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setSaveConnectTimeout(0);
|
||||
wm.setSaveConnectTimeout(10);
|
||||
wm.setSaveConnectTimeout(30);
|
||||
wm.setEnableConfigPortal(true);
|
||||
wm.setEnableConfigPortal(false);
|
||||
wm.setDisableConfigPortal(true);
|
||||
wm.setDisableConfigPortal(false);
|
||||
wm.preloadWiFi("TestSSID", "TestPassword");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setSaveConnectTimeout() executed without crash");
|
||||
// All setters executed without crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "Connection behavior options executed without crash");
|
||||
|
||||
Serial.println("[TEST] setSaveConnectTimeout() test completed successfully");
|
||||
Serial.println("[TEST] Connection behavior options test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_show_info_erase() {
|
||||
Serial.println("[TEST] Testing setShowInfoErase()...");
|
||||
// Test UI display options
|
||||
void test_ui_display_options() {
|
||||
Serial.println("[TEST] Testing UI display options...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test display toggles
|
||||
wm.setShowPassword(true);
|
||||
wm.setShowPassword(false);
|
||||
wm.setScanDispPerc(true);
|
||||
wm.setScanDispPerc(false);
|
||||
wm.setShowInfoErase(true);
|
||||
wm.setShowInfoErase(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setShowInfoErase() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setShowInfoErase() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_show_info_update() {
|
||||
Serial.println("[TEST] Testing setShowInfoUpdate()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setShowInfoUpdate(true);
|
||||
wm.setShowInfoUpdate(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setShowInfoUpdate() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setShowInfoUpdate() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_custom_head_element() {
|
||||
Serial.println("[TEST] Testing setCustomHeadElement()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setCustomHeadElement("<style>body { background: red; }</style>");
|
||||
wm.setCustomHeadElement("");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setCustomHeadElement() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setCustomHeadElement() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_custom_body_header() {
|
||||
Serial.println("[TEST] Testing setCustomBodyHeader()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setCustomBodyHeader("<div>Custom Header</div>");
|
||||
wm.setCustomBodyHeader("");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setCustomBodyHeader() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setCustomBodyHeader() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_custom_body_footer() {
|
||||
Serial.println("[TEST] Testing setCustomBodyFooter()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setCustomBodyFooter("<div>Custom Footer</div>");
|
||||
wm.setCustomBodyFooter("");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setCustomBodyFooter() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setCustomBodyFooter() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_custom_menu_html() {
|
||||
Serial.println("[TEST] Testing setCustomMenuHTML()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setCustomMenuHTML("<div>Custom Menu</div>");
|
||||
wm.setCustomMenuHTML("");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setCustomMenuHTML() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setCustomMenuHTML() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_menu() {
|
||||
Serial.println("[TEST] Testing setMenu()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test with array
|
||||
const char* menu[] = {"wifi", "info", "exit"};
|
||||
wm.setMenu(menu, 3);
|
||||
|
||||
// Test with vector
|
||||
std::vector<const char*> menuVec = {"wifi", "info", "param", "exit"};
|
||||
wm.setMenu(menuVec);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setMenu() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setMenu() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_params_page() {
|
||||
Serial.println("[TEST] Testing setParamsPage()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setDarkMode(true);
|
||||
wm.setDarkMode(false);
|
||||
wm.setParamsPage(true);
|
||||
wm.setParamsPage(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setParamsPage() executed without crash");
|
||||
// All setters executed without crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "UI display options executed without crash");
|
||||
|
||||
Serial.println("[TEST] setParamsPage() test completed successfully");
|
||||
Serial.println("[TEST] UI display options test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_dark_mode() {
|
||||
Serial.println("[TEST] Testing setDarkMode()...");
|
||||
// Test custom HTML/UI customization
|
||||
void test_ui_customization() {
|
||||
Serial.println("[TEST] Testing UI customization...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setDarkMode(true);
|
||||
wm.setDarkMode(false);
|
||||
// Test custom HTML elements
|
||||
wm.setCustomHeadElement("<style>body { background: red; }</style>");
|
||||
wm.setCustomHeadElement("");
|
||||
wm.setCustomBodyHeader("<div>Custom Header</div>");
|
||||
wm.setCustomBodyHeader("");
|
||||
wm.setCustomBodyFooter("<div>Custom Footer</div>");
|
||||
wm.setCustomBodyFooter("");
|
||||
wm.setCustomMenuHTML("<div>Custom Menu</div>");
|
||||
wm.setCustomMenuHTML("");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setDarkMode() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setDarkMode() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_class() {
|
||||
Serial.println("[TEST] Testing setClass()...");
|
||||
|
||||
WiFiManager wm;
|
||||
// Test menu configuration
|
||||
const char* menu[] = {"wifi", "info", "exit"};
|
||||
wm.setMenu(menu, 3);
|
||||
std::vector<const char*> menuVec = {"wifi", "info", "param", "exit"};
|
||||
wm.setMenu(menuVec);
|
||||
|
||||
// Test CSS class
|
||||
wm.setClass("invert");
|
||||
wm.setClass("custom-class");
|
||||
wm.setClass("");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setClass() executed without crash");
|
||||
// All setters executed without crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "UI customization options executed without crash");
|
||||
|
||||
Serial.println("[TEST] setClass() test completed successfully");
|
||||
}
|
||||
|
||||
void test_preload_wifi() {
|
||||
Serial.println("[TEST] Testing preloadWiFi()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Preload WiFi credentials (without actually connecting)
|
||||
wm.preloadWiFi("TestSSID", "TestPassword");
|
||||
|
||||
// Should return true/false, just verify no crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "preloadWiFi() executed without crash");
|
||||
|
||||
Serial.println("[TEST] preloadWiFi() test completed successfully");
|
||||
Serial.println("[TEST] UI customization test completed successfully");
|
||||
}
|
||||
|
||||
void test_debug_soft_ap_config() {
|
||||
|
||||
@@ -39,16 +39,19 @@ void test_reset_settings() {
|
||||
Serial.println("[TEST] resetSettings() test completed successfully");
|
||||
}
|
||||
|
||||
// Test disconnect without erasing credentials
|
||||
// Test disconnect - verify it doesn't crash and can be called multiple times
|
||||
void test_disconnect() {
|
||||
Serial.println("[TEST] Testing disconnect()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Disconnect should not crash even if not connected
|
||||
wm.disconnect();
|
||||
bool result1 = wm.disconnect();
|
||||
|
||||
// Disconnect returns true/false, just verify no crash
|
||||
// Can be called multiple times safely
|
||||
bool result2 = wm.disconnect();
|
||||
|
||||
// Verify no crash (results may be true/false depending on WiFi state)
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "disconnect() executed without crash");
|
||||
|
||||
Serial.println("[TEST] disconnect() test completed successfully");
|
||||
|
||||
@@ -97,81 +97,29 @@ void test_web_server_callback() {
|
||||
Serial.println("[TEST] Web server callback test completed successfully");
|
||||
}
|
||||
|
||||
void test_config_reset_callback() {
|
||||
Serial.println("[TEST] Testing config reset callback...");
|
||||
// Test callback registration - verify all callbacks can be registered without crash
|
||||
void test_callback_registration() {
|
||||
Serial.println("[TEST] Testing callback registration...");
|
||||
|
||||
reset_callback_flags();
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Register all callbacks - verify registration doesn't crash
|
||||
wm.setConfigResetCallback(config_reset_callback);
|
||||
|
||||
// Reset settings should trigger callback
|
||||
wm.resetSettings();
|
||||
|
||||
// Note: Callback may or may not fire on resetSettings() depending on implementation
|
||||
// Just verify it doesn't crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setConfigResetCallback() executed without crash");
|
||||
|
||||
Serial.println("[TEST] Config reset callback test completed successfully");
|
||||
}
|
||||
|
||||
void test_save_config_callback_registration() {
|
||||
Serial.println("[TEST] Testing save config callback registration...");
|
||||
|
||||
reset_callback_flags();
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Register callback
|
||||
wm.setSaveConfigCallback(save_config_callback);
|
||||
wm.setPreSaveConfigCallback(pre_save_config_callback);
|
||||
|
||||
// Note: These callbacks fire when WiFi is saved via web portal
|
||||
// We can't easily test the actual firing without HTTP requests,
|
||||
// but we can verify registration doesn't crash
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "Save config callbacks registered without crash");
|
||||
|
||||
Serial.println("[TEST] Save config callback registration test completed successfully");
|
||||
}
|
||||
|
||||
void test_save_params_callback_registration() {
|
||||
Serial.println("[TEST] Testing save params callback registration...");
|
||||
|
||||
reset_callback_flags();
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Register callbacks
|
||||
wm.setSaveParamsCallback(save_params_callback);
|
||||
wm.setPreSaveParamsCallback(pre_save_params_callback);
|
||||
|
||||
// Note: These callbacks fire when parameters are saved via web portal
|
||||
// We can't easily test the actual firing without HTTP requests,
|
||||
// but we can verify registration doesn't crash
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "Save params callbacks registered without crash");
|
||||
|
||||
Serial.println("[TEST] Save params callback registration test completed successfully");
|
||||
}
|
||||
|
||||
void test_config_portal_timeout_callback_registration() {
|
||||
Serial.println("[TEST] Testing config portal timeout callback registration...");
|
||||
|
||||
reset_callback_flags();
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Register callback
|
||||
wm.setConfigPortalTimeoutCallback(config_portal_timeout_callback);
|
||||
|
||||
// Note: This callback fires when config portal times out
|
||||
// We can't easily test the actual firing without waiting for timeout,
|
||||
// but we can verify registration doesn't crash
|
||||
// Call resetSettings to verify callback registration doesn't interfere
|
||||
wm.resetSettings();
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "Config portal timeout callback registered without crash");
|
||||
// Verify registration doesn't crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "All callbacks registered without crash");
|
||||
|
||||
Serial.println("[TEST] Config portal timeout callback registration test completed successfully");
|
||||
Serial.println("[TEST] Callback registration test completed successfully");
|
||||
}
|
||||
|
||||
void test_multiple_callbacks() {
|
||||
|
||||
@@ -3,229 +3,105 @@
|
||||
#include <WiFiManager.h>
|
||||
|
||||
// Test configuration API methods
|
||||
void test_set_title() {
|
||||
Serial.println("[TEST] Testing setTitle()...");
|
||||
|
||||
WiFiManager wm;
|
||||
String testTitle = "TestTitle";
|
||||
|
||||
wm.setTitle(testTitle);
|
||||
|
||||
// Note: getTitle() doesn't exist, so we just verify no crash
|
||||
// The title is used internally when rendering pages
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setTitle() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setTitle() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_config_portal_timeout() {
|
||||
Serial.println("[TEST] Testing setConfigPortalTimeout()...");
|
||||
// Consolidated setter tests - verify setters don't crash and can be called multiple times
|
||||
void test_configuration_setters() {
|
||||
Serial.println("[TEST] Testing configuration setters...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test various timeout values
|
||||
// Test timeout setters
|
||||
wm.setConfigPortalTimeout(0);
|
||||
wm.setConfigPortalTimeout(30);
|
||||
wm.setConfigPortalTimeout(300);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setConfigPortalTimeout() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setConfigPortalTimeout() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_connect_timeout() {
|
||||
Serial.println("[TEST] Testing setConnectTimeout()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setConnectTimeout(0);
|
||||
wm.setConnectTimeout(20);
|
||||
wm.setConnectTimeout(60);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setConnectTimeout() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setConnectTimeout() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_http_port() {
|
||||
Serial.println("[TEST] Testing setHttpPort()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test default port
|
||||
// Test HTTP port
|
||||
wm.setHttpPort(80);
|
||||
|
||||
// Test custom port
|
||||
wm.setHttpPort(8080);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setHttpPort() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setHttpPort() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_minimum_signal_quality() {
|
||||
Serial.println("[TEST] Testing setMinimumSignalQuality()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test WiFi quality and filtering
|
||||
wm.setMinimumSignalQuality(-1); // Disable filter
|
||||
wm.setMinimumSignalQuality(0);
|
||||
wm.setMinimumSignalQuality(50);
|
||||
wm.setMinimumSignalQuality(100);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setMinimumSignalQuality() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setMinimumSignalQuality() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_remove_duplicate_aps() {
|
||||
Serial.println("[TEST] Testing setRemoveDuplicateAPs()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setRemoveDuplicateAPs(true);
|
||||
wm.setRemoveDuplicateAPs(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setRemoveDuplicateAPs() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setRemoveDuplicateAPs() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_show_static_fields() {
|
||||
Serial.println("[TEST] Testing setShowStaticFields()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test display options
|
||||
wm.setShowStaticFields(true);
|
||||
wm.setShowStaticFields(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setShowStaticFields() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setShowStaticFields() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_show_dns_fields() {
|
||||
Serial.println("[TEST] Testing setShowDnsFields()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setShowDnsFields(true);
|
||||
wm.setShowDnsFields(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setShowDnsFields() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setShowDnsFields() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_config_portal_blocking() {
|
||||
Serial.println("[TEST] Testing setConfigPortalBlocking()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test portal behavior
|
||||
wm.setConfigPortalBlocking(true);
|
||||
wm.setConfigPortalBlocking(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setConfigPortalBlocking() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setConfigPortalBlocking() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_captive_portal_enable() {
|
||||
Serial.println("[TEST] Testing setCaptivePortalEnable()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setCaptivePortalEnable(true);
|
||||
wm.setCaptivePortalEnable(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setCaptivePortalEnable() executed without crash");
|
||||
// Test custom title (no getter available, but we can verify it doesn't crash)
|
||||
wm.setTitle("TestTitle");
|
||||
|
||||
Serial.println("[TEST] setCaptivePortalEnable() test completed successfully");
|
||||
// All setters executed without crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "All configuration setters executed without crash");
|
||||
|
||||
Serial.println("[TEST] Configuration setters test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_hostname() {
|
||||
Serial.println("[TEST] Testing setHostname()...");
|
||||
// Test hostname setter/getter - can verify behavior
|
||||
void test_set_and_get_hostname() {
|
||||
Serial.println("[TEST] Testing setHostname() and getWiFiHostname()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test with char*
|
||||
wm.setHostname("test-hostname");
|
||||
String hostname1 = wm.getWiFiHostname();
|
||||
// Verify hostname was set (may be empty initially, but getter doesn't crash)
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setHostname(char*) and getWiFiHostname() executed");
|
||||
|
||||
// Test with String
|
||||
wm.setHostname(String("test-hostname-2"));
|
||||
String hostname2 = wm.getWiFiHostname();
|
||||
// Verify getter works
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setHostname(String) and getWiFiHostname() executed");
|
||||
|
||||
// Test getting hostname
|
||||
String hostname = wm.getWiFiHostname();
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setHostname() and getWiFiHostname() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setHostname() test completed successfully");
|
||||
Serial.println("[TEST] setHostname() and getWiFiHostname() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_wifi_ap_channel() {
|
||||
Serial.println("[TEST] Testing setWiFiAPChannel()...");
|
||||
// Test WiFi AP configuration setters - consolidated
|
||||
void test_wifi_ap_configuration_setters() {
|
||||
Serial.println("[TEST] Testing WiFi AP configuration setters...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test AP channel
|
||||
wm.setWiFiAPChannel(0); // Auto
|
||||
wm.setWiFiAPChannel(1);
|
||||
wm.setWiFiAPChannel(11);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setWiFiAPChannel() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setWiFiAPChannel() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_wifi_ap_hidden() {
|
||||
Serial.println("[TEST] Testing setWiFiAPHidden()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test AP hidden
|
||||
wm.setWiFiAPHidden(true);
|
||||
wm.setWiFiAPHidden(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setWiFiAPHidden() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setWiFiAPHidden() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_clean_connect() {
|
||||
Serial.println("[TEST] Testing setCleanConnect()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setCleanConnect(true);
|
||||
wm.setCleanConnect(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setCleanConnect() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setCleanConnect() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_country() {
|
||||
Serial.println("[TEST] Testing setCountry()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test country code
|
||||
wm.setCountry("US");
|
||||
wm.setCountry("CN");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setCountry() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setCountry() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_wifi_auto_reconnect() {
|
||||
Serial.println("[TEST] Testing setWiFiAutoReconnect()...");
|
||||
|
||||
WiFiManager wm;
|
||||
// Test clean connect
|
||||
wm.setCleanConnect(true);
|
||||
wm.setCleanConnect(false);
|
||||
|
||||
// Test auto reconnect
|
||||
wm.setWiFiAutoReconnect(true);
|
||||
wm.setWiFiAutoReconnect(false);
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setWiFiAutoReconnect() executed without crash");
|
||||
// All setters executed without crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "All WiFi AP configuration setters executed without crash");
|
||||
|
||||
Serial.println("[TEST] setWiFiAutoReconnect() test completed successfully");
|
||||
Serial.println("[TEST] WiFi AP configuration setters test completed successfully");
|
||||
}
|
||||
|
||||
void test_get_default_ap_name() {
|
||||
|
||||
@@ -2,57 +2,33 @@
|
||||
#include <Arduino.h>
|
||||
#include <WiFiManager.h>
|
||||
|
||||
// Test non-blocking configuration portal
|
||||
void test_nonblocking_mode_setup() {
|
||||
Serial.println("[TEST] Testing non-blocking mode setup...");
|
||||
// Test non-blocking configuration portal - verify process() doesn't block
|
||||
void test_nonblocking_process() {
|
||||
Serial.println("[TEST] Testing non-blocking process() calls...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Enable non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal
|
||||
wm.startConfigPortal("TestAP");
|
||||
|
||||
// Verify portal is active
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
// Process should not block
|
||||
unsigned long start = millis();
|
||||
wm.process();
|
||||
unsigned long elapsed = millis() - start;
|
||||
|
||||
// Should return quickly (< 200ms)
|
||||
TEST_ASSERT_LESS_THAN(200, elapsed);
|
||||
|
||||
wm.stopConfigPortal();
|
||||
|
||||
Serial.println("[TEST] Non-blocking mode setup test completed successfully");
|
||||
}
|
||||
|
||||
void test_nonblocking_process() {
|
||||
Serial.println("[TEST] Testing non-blocking process() calls...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
wm.startConfigPortal("TestAP");
|
||||
|
||||
// Call process multiple times - should not block
|
||||
for (int i = 0; i < 10; i++) {
|
||||
unsigned long start = millis();
|
||||
wm.process();
|
||||
unsigned long elapsed = millis() - start;
|
||||
|
||||
// Each call should be fast
|
||||
// Each call should be fast (< 100ms) - verifies non-blocking behavior
|
||||
TEST_ASSERT_LESS_THAN(100, elapsed);
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
// Portal should still be active
|
||||
// Portal should still be active after multiple process() calls
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
wm.stopConfigPortal();
|
||||
@@ -60,56 +36,37 @@ void test_nonblocking_process() {
|
||||
Serial.println("[TEST] Non-blocking process() test completed successfully");
|
||||
}
|
||||
|
||||
void test_ap_client_check() {
|
||||
Serial.println("[TEST] Testing setAPClientCheck()...");
|
||||
// Test client check setters - verify they don't interfere with portal operation
|
||||
void test_client_check_setters() {
|
||||
Serial.println("[TEST] Testing client check setters...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test enabling client check
|
||||
// Test AP client check
|
||||
wm.setAPClientCheck(true);
|
||||
|
||||
// Test disabling client check
|
||||
wm.setAPClientCheck(false);
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
// Start portal and verify it works with client check settings
|
||||
wm.startConfigPortal("TestAP");
|
||||
|
||||
delay(100);
|
||||
|
||||
// Should not crash and portal should be active
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
delay(100);
|
||||
wm.stopConfigPortal();
|
||||
|
||||
Serial.println("[TEST] setAPClientCheck() test completed successfully");
|
||||
}
|
||||
|
||||
void test_web_portal_client_check() {
|
||||
Serial.println("[TEST] Testing setWebPortalClientCheck()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test enabling client check
|
||||
// Test web portal client check
|
||||
wm.setWebPortalClientCheck(true);
|
||||
|
||||
// Test disabling client check
|
||||
wm.setWebPortalClientCheck(false);
|
||||
|
||||
// Start web portal
|
||||
// Start web portal and verify it works
|
||||
wm.setConfigPortalTimeout(5);
|
||||
wm.startWebPortal();
|
||||
|
||||
// Should not crash
|
||||
TEST_ASSERT_TRUE(wm.getWebPortalActive());
|
||||
|
||||
wm.stopWebPortal();
|
||||
|
||||
Serial.println("[TEST] setWebPortalClientCheck() test completed successfully");
|
||||
Serial.println("[TEST] Client check setters test completed successfully");
|
||||
}
|
||||
|
||||
void test_nonblocking_timeout_behavior() {
|
||||
|
||||
@@ -10,25 +10,13 @@ void test_start_config_portal() {
|
||||
|
||||
// Use non-blocking mode so we can control when to stop
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10); // Longer timeout
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal with SSID only
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
// So we check getConfigPortalActive() instead of the return value
|
||||
wm.startConfigPortal("TestAP");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
delay(100); // Give it time to initialize
|
||||
|
||||
wm.stopConfigPortal();
|
||||
TEST_ASSERT_FALSE(wm.getConfigPortalActive());
|
||||
delay(100);
|
||||
|
||||
// Start portal with SSID and password
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal("TestAP2", "password123");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
delay(100);
|
||||
|
||||
wm.stopConfigPortal();
|
||||
@@ -37,6 +25,27 @@ void test_start_config_portal() {
|
||||
Serial.println("[TEST] startConfigPortal() test completed successfully");
|
||||
}
|
||||
|
||||
void test_start_config_portal_with_password() {
|
||||
Serial.println("[TEST] Testing startConfigPortal() with password...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start portal with SSID and password
|
||||
wm.startConfigPortal("TestAP2", "password123");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
delay(100);
|
||||
|
||||
wm.stopConfigPortal();
|
||||
TEST_ASSERT_FALSE(wm.getConfigPortalActive());
|
||||
|
||||
Serial.println("[TEST] startConfigPortal() with password test completed successfully");
|
||||
}
|
||||
|
||||
void test_start_config_portal_auto_name() {
|
||||
Serial.println("[TEST] Testing startConfigPortal() with auto-generated name...");
|
||||
|
||||
@@ -234,21 +243,17 @@ void test_get_config_portal_ssid() {
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Start with known SSID
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
wm.startConfigPortal("MyTestAP");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
delay(100);
|
||||
|
||||
// Verify SSID matches what we set
|
||||
String ssid = wm.getConfigPortalSSID();
|
||||
TEST_ASSERT_EQUAL_STRING("MyTestAP", ssid.c_str());
|
||||
|
||||
wm.stopConfigPortal();
|
||||
|
||||
// After stop, should return empty or default
|
||||
String ssid2 = wm.getConfigPortalSSID();
|
||||
// Note: Behavior may vary, just verify it doesn't crash
|
||||
|
||||
Serial.println("[TEST] getConfigPortalSSID() test completed successfully");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <WiFiManager.h>
|
||||
|
||||
// Test static IP configuration
|
||||
// Test AP static IP configuration - verifies IP is actually applied
|
||||
void test_set_ap_static_ip_config() {
|
||||
Serial.println("[TEST] Testing setAPStaticIPConfig()...");
|
||||
|
||||
@@ -15,20 +16,17 @@ void test_set_ap_static_ip_config() {
|
||||
// Set AP static IP
|
||||
wm.setAPStaticIPConfig(ip, gw, sn);
|
||||
|
||||
// Verify no crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setAPStaticIPConfig() executed without crash");
|
||||
|
||||
// Start portal and verify IP is set
|
||||
// Use non-blocking mode
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(10);
|
||||
|
||||
// Note: In non-blocking mode, startConfigPortal() returns false even when successful
|
||||
// Start portal and verify IP is actually set
|
||||
wm.startConfigPortal("TestAP");
|
||||
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
||||
|
||||
delay(200); // Give time for IP to be configured
|
||||
|
||||
// Verify AP IP matches what we configured
|
||||
IPAddress apIP = WiFi.softAPIP();
|
||||
TEST_ASSERT_EQUAL(ip, apIP);
|
||||
|
||||
@@ -37,26 +35,9 @@ void test_set_ap_static_ip_config() {
|
||||
Serial.println("[TEST] setAPStaticIPConfig() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_sta_static_ip_config() {
|
||||
Serial.println("[TEST] Testing setSTAStaticIPConfig()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
IPAddress ip(192, 168, 1, 100);
|
||||
IPAddress gw(192, 168, 1, 1);
|
||||
IPAddress sn(255, 255, 255, 0);
|
||||
|
||||
// Set STA static IP
|
||||
wm.setSTAStaticIPConfig(ip, gw, sn);
|
||||
|
||||
// Verify no crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setSTAStaticIPConfig() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setSTAStaticIPConfig() test completed successfully");
|
||||
}
|
||||
|
||||
void test_set_sta_static_ip_config_with_dns() {
|
||||
Serial.println("[TEST] Testing setSTAStaticIPConfig() with DNS...");
|
||||
// Test STA static IP configuration - consolidated
|
||||
void test_sta_static_ip_configuration() {
|
||||
Serial.println("[TEST] Testing STA static IP configuration...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
@@ -65,48 +46,20 @@ void test_set_sta_static_ip_config_with_dns() {
|
||||
IPAddress sn(255, 255, 255, 0);
|
||||
IPAddress dns(8, 8, 8, 8);
|
||||
|
||||
// Set STA static IP with DNS
|
||||
// Test setSTAStaticIPConfig without DNS
|
||||
wm.setSTAStaticIPConfig(ip, gw, sn);
|
||||
|
||||
// Test setSTAStaticIPConfig with DNS
|
||||
wm.setSTAStaticIPConfig(ip, gw, sn, dns);
|
||||
|
||||
// Verify no crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setSTAStaticIPConfig() with DNS executed without crash");
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "STA static IP configuration setters executed without crash");
|
||||
|
||||
Serial.println("[TEST] setSTAStaticIPConfig() with DNS test completed successfully");
|
||||
Serial.println("[TEST] STA static IP configuration test completed successfully");
|
||||
}
|
||||
|
||||
void test_show_static_fields() {
|
||||
Serial.println("[TEST] Testing setShowStaticFields()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test enabling static fields
|
||||
wm.setShowStaticFields(true);
|
||||
|
||||
// Test disabling static fields
|
||||
wm.setShowStaticFields(false);
|
||||
|
||||
// Verify no crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setShowStaticFields() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setShowStaticFields() test completed successfully");
|
||||
}
|
||||
|
||||
void test_show_dns_fields() {
|
||||
Serial.println("[TEST] Testing setShowDnsFields()...");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
// Test enabling DNS fields
|
||||
wm.setShowDnsFields(true);
|
||||
|
||||
// Test disabling DNS fields
|
||||
wm.setShowDnsFields(false);
|
||||
|
||||
// Verify no crash
|
||||
TEST_ASSERT_TRUE_MESSAGE(true, "setShowDnsFields() executed without crash");
|
||||
|
||||
Serial.println("[TEST] setShowDnsFields() test completed successfully");
|
||||
}
|
||||
// Note: test_show_static_fields and test_show_dns_fields removed -
|
||||
// already covered in test_configuration_setters() in test_configuration.cpp
|
||||
|
||||
void test_ap_static_ip_application() {
|
||||
Serial.println("[TEST] Testing AP static IP application...");
|
||||
|
||||
Reference in New Issue
Block a user