| 10 | #include "fl/stl/span.h" |
| 11 | |
| 12 | FL_TEST_FILE(FL_FILEPATH) { |
| 13 | |
| 14 | |
| 15 | FL_TEST_CASE("Rectangular Buffer") { |
| 16 | fl::RectangularDrawBuffer buffer; |
| 17 | |
| 18 | FL_SUBCASE("Empty buffer has no LEDs") { |
| 19 | FL_CHECK(buffer.getTotalBytes() == 0); |
| 20 | FL_CHECK(buffer.getMaxBytesInStrip() == 0); |
| 21 | } |
| 22 | |
| 23 | FL_SUBCASE("Add one strip of 10 RGB LEDs") { |
| 24 | buffer.queue(fl::DrawItem(1, 10, false)); |
| 25 | |
| 26 | FL_CHECK(buffer.getMaxBytesInStrip() == 30); |
| 27 | FL_CHECK(buffer.getTotalBytes() == 30); |
| 28 | } |
| 29 | |
| 30 | FL_SUBCASE("Add two strips of 10 RGB LEDs") { |
| 31 | buffer.queue(fl::DrawItem(1, 10, false)); |
| 32 | buffer.queue(fl::DrawItem(2, 10, false)); |
| 33 | |
| 34 | FL_CHECK(buffer.getMaxBytesInStrip() == 30); |
| 35 | FL_CHECK(buffer.getTotalBytes() == 60); |
| 36 | } |
| 37 | |
| 38 | FL_SUBCASE("Add one strip of 10 RGBW LEDs") { |
| 39 | buffer.queue(fl::DrawItem(1, 10, true)); |
| 40 | |
| 41 | uint32_t num_bytes = Rgbw::size_as_rgb(10) * 3; |
| 42 | |
| 43 | FL_CHECK(buffer.getMaxBytesInStrip() == num_bytes); |
| 44 | FL_CHECK(buffer.getTotalBytes() == num_bytes); |
| 45 | } |
| 46 | |
| 47 | FL_SUBCASE("Add one strip of 10 RGBW LEDs and one strip of 10 RGB LEDs") { |
| 48 | buffer.queue(fl::DrawItem(1, 10, true)); |
| 49 | buffer.queue(fl::DrawItem(2, 10, false)); |
| 50 | |
| 51 | uint32_t max_size_strip_bytes = Rgbw::size_as_rgb(10) * 3; |
| 52 | |
| 53 | FL_CHECK(buffer.getMaxBytesInStrip() == max_size_strip_bytes); |
| 54 | FL_CHECK(buffer.getTotalBytes() == max_size_strip_bytes * 2); |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | FL_TEST_CASE("Rectangular Buffer queue tests") { |
| 59 | fl::RectangularDrawBuffer buffer; |
| 60 | |
| 61 | FL_SUBCASE("Queueing start and done") { |
| 62 | FL_CHECK(buffer.mQueueState == fl::RectangularDrawBuffer::IDLE); |
| 63 | buffer.onQueuingStart(); |
| 64 | FL_CHECK(buffer.mQueueState == fl::RectangularDrawBuffer::QUEUEING); |
| 65 | buffer.onQueuingDone(); |
| 66 | FL_CHECK(buffer.mQueueState == fl::RectangularDrawBuffer::QUEUE_DONE); |
| 67 | buffer.onQueuingStart(); |
| 68 | FL_CHECK(buffer.mQueueState == fl::RectangularDrawBuffer::QUEUEING); |
| 69 | } |
nothing calls this directly
no test coverage detected