| 32 | #include "fl/fx/frame.h" |
| 33 | |
| 34 | FL_TEST_FILE(FL_FILEPATH) { |
| 35 | |
| 36 | // --------------------------------------------------------------------------- |
| 37 | // TestIO — same pattern as tests/fl/remote/remote.cpp |
| 38 | // --------------------------------------------------------------------------- |
| 39 | |
| 40 | struct TestIO { |
| 41 | fl::vector<fl::json> requests; |
| 42 | fl::vector<fl::json> responses; |
| 43 | size_t requestIndex = 0; |
| 44 | |
| 45 | fl::optional<fl::json> pullRequest() { |
| 46 | if (requestIndex >= requests.size()) { |
| 47 | return fl::nullopt; |
| 48 | } |
| 49 | return requests[requestIndex++]; |
| 50 | } |
| 51 | |
| 52 | void pushResponse(const fl::json& response) { |
| 53 | responses.push_back(response); |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | // --------------------------------------------------------------------------- |
| 58 | // Constants & helpers |
| 59 | // --------------------------------------------------------------------------- |
| 60 | |
| 61 | static const char* DEFAULT_PAYLOAD_PATH = ".build/decode_payload.json"; |
| 62 | |
| 63 | static const char* getPayloadPath() { |
| 64 | const char* env = ::getenv("FASTLED_DECODE_PAYLOAD"); |
| 65 | if (env && env[0]) { |
| 66 | return env; |
| 67 | } |
| 68 | return DEFAULT_PAYLOAD_PATH; |
| 69 | } |
| 70 | |
| 71 | static fl::string readFileToString(const char* path) { |
| 72 | fl::FILE* f = fl::fopen(path, "rb"); |
| 73 | if (!f) { |
| 74 | return fl::string(); |
| 75 | } |
| 76 | fl::fseek(f, 0, fl::io::seek_end); |
| 77 | long len = fl::ftell(f); |
| 78 | fl::fseek(f, 0, fl::io::seek_set); |
| 79 | if (len <= 0) { |
| 80 | fl::fclose(f); |
| 81 | return fl::string(); |
| 82 | } |
| 83 | fl::vector<char> buf(len); |
| 84 | size_t read = fl::fread(buf.data(), 1, len, f); |
| 85 | fl::fclose(f); |
| 86 | return fl::string(buf.data(), read); |
| 87 | } |
| 88 | |
| 89 | // --------------------------------------------------------------------------- |
| 90 | // Codec validation helpers |
| 91 | // --------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected