mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-20 01:41:28 +10:00
WiFiManager: stabilize root rendering and reduce page reallocations.
Keep root template state request-scoped so dynamic placeholders stay consistent during chunked renders, add reserve() coverage for non-streamed pages, and add compile/test coverage for the new root render lifecycle.
This commit is contained in:
@@ -30,6 +30,8 @@ TestCase tests[] = {
|
||||
TEST_ENTRY(test_config_portal_multiple_start_stop),
|
||||
TEST_ENTRY(test_config_portal_already_active),
|
||||
TEST_ENTRY(test_get_config_portal_ssid),
|
||||
TEST_ENTRY(test_root_render_menu_state_transitions),
|
||||
TEST_ENTRY(test_root_render_snapshot_consistency),
|
||||
|
||||
// Non-blocking tests
|
||||
TEST_ENTRY(test_nonblocking_process),
|
||||
|
||||
@@ -40,6 +40,8 @@ void test_stop_web_portal();
|
||||
void test_config_portal_multiple_start_stop();
|
||||
void test_config_portal_already_active();
|
||||
void test_get_config_portal_ssid();
|
||||
void test_root_render_menu_state_transitions();
|
||||
void test_root_render_snapshot_consistency();
|
||||
|
||||
// Non-blocking tests
|
||||
void test_nonblocking_process();
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include <unity.h>
|
||||
#include <Arduino.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <WiFiManagerHandlers.h>
|
||||
|
||||
void test_root_render_menu_state_transitions() {
|
||||
Serial.println("[TEST] Testing root menu state transitions...");
|
||||
|
||||
WiFiManager wm;
|
||||
WiFiManagerHandlers handlers(&wm);
|
||||
|
||||
String menuBefore;
|
||||
handlers.getMenuOut(&menuBefore);
|
||||
TEST_ASSERT_EQUAL(-1, menuBefore.indexOf("/close"));
|
||||
|
||||
wm.setConfigPortalTimeout(5);
|
||||
wm.startConfigPortal("RootStateAP");
|
||||
wm.process();
|
||||
delay(100);
|
||||
|
||||
String menuActive;
|
||||
handlers.getMenuOut(&menuActive);
|
||||
TEST_ASSERT_NOT_EQUAL(-1, menuActive.indexOf("/close"));
|
||||
|
||||
wm.stopConfigPortal();
|
||||
delay(100);
|
||||
|
||||
String menuAfter;
|
||||
handlers.getMenuOut(&menuAfter);
|
||||
TEST_ASSERT_EQUAL(-1, menuAfter.indexOf("/close"));
|
||||
|
||||
Serial.println("[TEST] Root menu state transitions test completed successfully");
|
||||
}
|
||||
|
||||
void test_root_render_snapshot_consistency() {
|
||||
Serial.println("[TEST] Testing root render snapshot consistency...");
|
||||
|
||||
WiFiManager wm;
|
||||
WiFiManagerHandlers handlers(&wm);
|
||||
|
||||
wm.setConfigPortalTimeout(5);
|
||||
wm.startConfigPortal("RootSnapshotAP");
|
||||
wm.process();
|
||||
delay(100);
|
||||
|
||||
String menuSnapshot1;
|
||||
String statusSnapshot1;
|
||||
handlers.getMenuOut(&menuSnapshot1);
|
||||
handlers.reportStatus(statusSnapshot1);
|
||||
|
||||
String menuSnapshot2;
|
||||
String statusSnapshot2;
|
||||
handlers.getMenuOut(&menuSnapshot2);
|
||||
handlers.reportStatus(statusSnapshot2);
|
||||
|
||||
TEST_ASSERT_GREATER_THAN(0, menuSnapshot1.length());
|
||||
TEST_ASSERT_GREATER_THAN(0, statusSnapshot1.length());
|
||||
TEST_ASSERT_EQUAL_STRING(menuSnapshot1.c_str(), menuSnapshot2.c_str());
|
||||
TEST_ASSERT_EQUAL_STRING(statusSnapshot1.c_str(), statusSnapshot2.c_str());
|
||||
|
||||
wm.stopConfigPortal();
|
||||
|
||||
Serial.println("[TEST] Root render snapshot consistency test completed successfully");
|
||||
}
|
||||
Reference in New Issue
Block a user