Files
pictureFrame-firmware/test/mocks/HTTPClient.h
T
football2801 87af8cb030 fix: harden firmware NVS persistence, WDT, and 304 epd_sleep
Three bugs fixed:
- NVS img_id now written before epd_init/draw; new draw_needed flag in NVS
  survives power-loss mid-refresh so next boot re-draws from LittleFS instead
  of showing stale content
- epd_sleep() now only called when display was initialized this cycle,
  preventing a 60 s wait_busy() timeout on every 304 poll
- esp_task_wdt_reset() added to wait_busy() loop so the ~20 s 6-color
  refresh no longer triggers the task watchdog

Also extracts normal_operation into operation.h template and adds
a native PlatformIO test suite (16 tests) covering the full response matrix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 12:09:37 -04:00

48 lines
1.2 KiB
C++

#pragma once
#include "Arduino.h"
#include "LittleFS.h"
#include "WiFiClientSecure.h"
#include <map>
// Global test state for inspecting behavior
extern int g_http_get_code;
extern std::map<std::string, std::string> g_http_response_headers;
extern std::map<std::string, std::string> g_http_request_headers;
extern bool g_http_end_called;
extern std::string g_http_body;
struct MockHTTPClient {
bool _ended = false;
void begin(WiFiClientSecure&, const String& url) {}
void addHeader(const char* name, const String& value) {
g_http_request_headers[name] = value._s;
}
void collectHeaders(const char** headers, int count) {}
int GET() {
_ended = false;
return g_http_get_code;
}
String header(const char* name) {
if (_ended) return String("");
auto it = g_http_response_headers.find(name);
return it != g_http_response_headers.end() ? String(it->second) : String("");
}
size_t writeToStream(File* f) {
if (f && *f) {
f->write((const uint8_t*)g_http_body.data(), g_http_body.size());
}
return g_http_body.size();
}
void end() {
_ended = true;
g_http_end_called = true;
}
};