| 21 | #include "fl/stl/thread.h" |
| 22 | |
| 23 | FL_TEST_FILE(FL_FILEPATH) { |
| 24 | |
| 25 | using namespace fl; |
| 26 | using namespace fl::detail; |
| 27 | |
| 28 | namespace { |
| 29 | |
| 30 | /// @brief Helper to create default timing config for WS2812 |
| 31 | ChipsetTimingConfig getWS2812Timing() { |
| 32 | return ChipsetTimingConfig(350, 800, 450, 50, "WS2812B"); |
| 33 | } |
| 34 | |
| 35 | /// @brief Reset mock state between tests |
| 36 | void resetMockState() { |
| 37 | auto& mock = I2sLcdCamPeripheralMock::instance(); |
| 38 | mock.reset(); |
| 39 | mock.setTransmitDelay(0); // Instant completion for unit tests |
| 40 | } |
| 41 | |
| 42 | /// @brief Create mock peripheral as shared_ptr |
| 43 | fl::shared_ptr<II2sLcdCamPeripheral> createMockPeripheral() { |
| 44 | // Wrap the singleton mock in a shared_ptr |
| 45 | // The wrapper delegates to the singleton without owning it |
| 46 | class MockWrapper : public II2sLcdCamPeripheral { |
| 47 | public: |
| 48 | bool initialize(const I2sLcdCamConfig& config) override { |
| 49 | return I2sLcdCamPeripheralMock::instance().initialize(config); |
| 50 | } |
| 51 | void deinitialize() override { |
| 52 | I2sLcdCamPeripheralMock::instance().deinitialize(); |
| 53 | } |
| 54 | bool isInitialized() const override { |
| 55 | return I2sLcdCamPeripheralMock::instance().isInitialized(); |
| 56 | } |
| 57 | uint16_t* allocateBuffer(size_t size_bytes) override { |
| 58 | return I2sLcdCamPeripheralMock::instance().allocateBuffer(size_bytes); |
| 59 | } |
| 60 | void freeBuffer(uint16_t* buffer) override { |
| 61 | I2sLcdCamPeripheralMock::instance().freeBuffer(buffer); |
| 62 | } |
| 63 | bool transmit(const uint16_t* buffer, size_t size_bytes) override { |
| 64 | return I2sLcdCamPeripheralMock::instance().transmit(buffer, size_bytes); |
| 65 | } |
| 66 | bool waitTransmitDone(uint32_t timeout_ms) override { |
| 67 | return I2sLcdCamPeripheralMock::instance().waitTransmitDone(timeout_ms); |
| 68 | } |
| 69 | bool isBusy() const override { |
| 70 | return I2sLcdCamPeripheralMock::instance().isBusy(); |
| 71 | } |
| 72 | bool registerTransmitCallback(void* callback, void* user_ctx) override { |
| 73 | return I2sLcdCamPeripheralMock::instance().registerTransmitCallback(callback, user_ctx); |
| 74 | } |
| 75 | const I2sLcdCamConfig& getConfig() const override { |
| 76 | return I2sLcdCamPeripheralMock::instance().getConfig(); |
| 77 | } |
| 78 | uint64_t getMicroseconds() override { |
| 79 | return I2sLcdCamPeripheralMock::instance().getMicroseconds(); |
| 80 | } |
nothing calls this directly
no test coverage detected