Files
WiFiManager/test/test_wifimanager/tests/test_advanced_options.cpp
T
2026-09-01 10:59:25 +10:00

135 lines
4.5 KiB
C++

#include <unity.h>
#include <Arduino.h>
#include <WiFiManager.h>
// 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);
wm.setSaveConnect(true);
wm.setSaveConnect(false);
wm.setRestorePersistent(true);
wm.setRestorePersistent(false);
wm.setConnectRetries(1);
wm.setConnectRetries(3);
wm.setConnectRetries(5);
wm.setSaveConnectTimeout(0);
wm.setSaveConnectTimeout(10);
wm.setSaveConnectTimeout(30);
wm.setEnableConfigPortal(true);
wm.setEnableConfigPortal(false);
wm.setDisableConfigPortal(true);
wm.setDisableConfigPortal(false);
wm.portalSetBehaviorConnectOnSave(true);
wm.portalSetBehaviorConnectOnSave(false);
wm.portalSetBehaviorExitAllowed(true);
wm.portalSetBehaviorExitAllowed(false);
wm.portalSetBehaviorConnectTimeoutSeconds(15);
wm.portalSetBehaviorPortalTimeoutSeconds(20);
wm.portalSetBehaviorAutoReconnect(true);
wm.portalSetBehaviorAutoReconnect(false);
wm.portalSetBehaviorApClientCheck(true);
wm.portalSetBehaviorApClientCheck(false);
wm.portalSetBehaviorWebClientCheck(true);
wm.portalSetBehaviorWebClientCheck(false);
wm.preloadWiFi("TestSSID", "TestPassword");
// All setters executed without crash
TEST_ASSERT_TRUE_MESSAGE(true, "Connection behavior options executed without crash");
Serial.println("[TEST] Connection behavior options test completed successfully");
}
// Test UI display options
void test_ui_display_options() {
Serial.println("[TEST] Testing UI display options...");
WiFiManager wm;
// Test display toggles
wm.portalSetFieldPasswordPlaceholderMode(PortalPasswordPlaceholderMode::Actual);
wm.portalSetFieldPasswordPlaceholderMode(PortalPasswordPlaceholderMode::Masked);
wm.portalSetFieldPasswordPlaceholderMode(PortalPasswordPlaceholderMode::Hidden);
wm.setScanDispPerc(true);
wm.setScanDispPerc(false);
wm.portalSetActionEraseVisible(true);
wm.portalSetActionEraseVisible(false);
wm.portalSetActionRestartVisible(true);
wm.portalSetActionRestartVisible(false);
wm.portalSetActionExitVisible(true);
wm.portalSetActionExitVisible(false);
wm.portalSetActionCloseCaptiveVisible(true);
wm.portalSetActionCloseCaptiveVisible(false);
wm.portalSetPageUpdateVisible(true);
wm.portalSetPageUpdateVisible(false);
wm.portalSetPageSetupVisible(true);
wm.portalSetPageSetupVisible(false);
wm.portalSetLayoutParamsLocation(PortalParamsLocation::WiFiPage);
wm.portalSetLayoutParamsLocation(PortalParamsLocation::SetupPage);
wm.portalSetActionBackVisible(true);
wm.portalSetActionBackVisible(false);
// All setters executed without crash
TEST_ASSERT_TRUE_MESSAGE(true, "UI display options executed without crash");
Serial.println("[TEST] UI display options test completed successfully");
}
// Test custom HTML/UI customization
void test_ui_customization() {
Serial.println("[TEST] Testing UI customization...");
WiFiManager wm;
// Minimal customization uses the complete static portal configuration.
WiFiManagerPortalConfig portal;
portal.title = WiFiManagerPortalText::ram("MyDevice");
TEST_ASSERT_TRUE(wm.setPortalConfig(portal));
// All setters executed without crash
TEST_ASSERT_TRUE_MESSAGE(true, "UI customization options executed without crash");
Serial.println("[TEST] UI customization test completed successfully");
}
void test_debug_soft_ap_config() {
Serial.println("[TEST] Testing debugSoftAPConfig()...");
WiFiManager wm;
wm.setConfigPortalTimeout(5);
wm.startConfigPortal("TestAP");
// Call process() to simulate real usage
wm.process();
delay(100);
// Debug output should not crash
wm.debugSoftAPConfig();
wm.stopConfigPortal();
Serial.println("[TEST] debugSoftAPConfig() test completed successfully");
}
void test_debug_platform_info() {
Serial.println("[TEST] Testing debugPlatformInfo()...");
WiFiManager wm;
// Debug output should not crash
wm.debugPlatformInfo();
TEST_ASSERT_TRUE_MESSAGE(true, "debugPlatformInfo() executed without crash");
Serial.println("[TEST] debugPlatformInfo() test completed successfully");
}