mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
- Group portal state into brand/pages/actions/layout structs; portal* API - Bootstrap JSON: nested brand/context/pages/actions/layout; param kind - Handlers: PROGMEM default CSS when no override/append; dynamic CSS path - PortalAppJS: portal timeout countdown; safe WiFi scan DOM; serialized scan-status polling; fetch error handling; wm:view-changed on redirects - CSS: scan list icon alignment; wm-status for timeout - Tests: remove low-value/no-op tests; trim fragile JS substring checks
133 lines
4.4 KiB
C++
133 lines
4.4 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 retained: title
|
|
wm.portalSetBrandTitle("MyDevice");
|
|
|
|
// 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");
|
|
}
|
|
|