mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
- Added 42 new tests covering critical functionality: * WiFi connection flow tests (6 tests) * Callback firing verification tests (4 tests) * DNS server lifecycle tests (3 tests) * Error condition tests (7 tests) * Parameter value management tests (5 tests) * WiFi scanning tests (4 tests) * State transition tests (4 tests) * Integration tests (5 tests) * Stress tests (5 tests) - Fixed compilation errors by replacing protected connectWifi() calls with public autoConnect() - Fixed config reset callback test to use resetSettings() instead of erase() - Added delays around resetSettings() calls to prevent ESP8266 WiFi stack crashes - Reduced stress test iterations to avoid excessive output - Improved test stability with better state checking and error handling Total test count: 86 tests (up from 44) All tests passing successfully
94 lines
2.7 KiB
C++
94 lines
2.7 KiB
C++
#include <unity.h>
|
|
#include <Arduino.h>
|
|
#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()...");
|
|
|
|
WiFiManager wm;
|
|
|
|
IPAddress ip(192, 168, 4, 1);
|
|
IPAddress gw(192, 168, 4, 1);
|
|
IPAddress sn(255, 255, 255, 0);
|
|
|
|
// Set AP static IP
|
|
wm.setAPStaticIPConfig(ip, gw, sn);
|
|
|
|
wm.setConfigPortalTimeout(10);
|
|
|
|
// Start portal and verify IP is actually set
|
|
wm.startConfigPortal("TestAP");
|
|
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
|
|
|
// Call process() to simulate real usage
|
|
wm.process();
|
|
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);
|
|
|
|
wm.stopConfigPortal();
|
|
|
|
Serial.println("[TEST] setAPStaticIPConfig() test completed successfully");
|
|
}
|
|
|
|
// Test STA static IP configuration - consolidated
|
|
void test_sta_static_ip_configuration() {
|
|
Serial.println("[TEST] Testing STA static IP configuration...");
|
|
|
|
WiFiManager wm;
|
|
|
|
IPAddress ip(192, 168, 1, 100);
|
|
IPAddress gw(192, 168, 1, 1);
|
|
IPAddress sn(255, 255, 255, 0);
|
|
IPAddress dns(8, 8, 8, 8);
|
|
|
|
// 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, "STA static IP configuration setters executed without crash");
|
|
|
|
Serial.println("[TEST] STA static IP configuration 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...");
|
|
|
|
WiFiManager wm;
|
|
|
|
IPAddress customIP(10, 0, 1, 1);
|
|
IPAddress customGW(10, 0, 1, 1);
|
|
IPAddress customSN(255, 255, 255, 0);
|
|
|
|
wm.setAPStaticIPConfig(customIP, customGW, customSN);
|
|
|
|
wm.setConfigPortalTimeout(10);
|
|
|
|
wm.startConfigPortal("TestAP");
|
|
TEST_ASSERT_TRUE(wm.getConfigPortalActive());
|
|
|
|
// Call process() to simulate real usage
|
|
wm.process();
|
|
delay(200); // Give time for AP to configure
|
|
|
|
IPAddress apIP = WiFi.softAPIP();
|
|
|
|
// AP should have the configured IP
|
|
TEST_ASSERT_EQUAL(customIP, apIP);
|
|
|
|
wm.stopConfigPortal();
|
|
|
|
Serial.println("[TEST] AP static IP application test completed successfully");
|
|
}
|
|
|