MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/fx/wled.cpp:12–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "fl/stl/shared_ptr.h"
11
12FL_TEST_FILE(FL_FILEPATH) {
13
14using namespace fl;
15
16FL_TEST_CASE("WLEDClient construction") {
17 auto mock = fl::make_shared<MockFastLED>(50);
18 WLEDClient client(mock);
19
20 FL_SUBCASE("Initial state is off with max brightness") {
21 FL_CHECK(client.getOn() == false);
22 FL_CHECK(client.getBrightness() == 255);
23 }
24
25 FL_SUBCASE("LED count is accessible") {
26 FL_CHECK(client.getNumLEDs() == 50);
27 }
28}
29
30FL_TEST_CASE("WLEDClient brightness control") {
31 auto mock = fl::make_shared<MockFastLED>(50);
32 WLEDClient client(mock);
33
34 FL_SUBCASE("Setting brightness when off does not affect controller") {
35 client.setBrightness(128);
36 FL_CHECK(client.getBrightness() == 128);
37 // Controller should still have default brightness (not changed)
38 FL_CHECK(mock->getBrightness() == 255);
39 }
40
41 FL_SUBCASE("Setting brightness when on applies to controller") {
42 client.setOn(true);
43 client.setBrightness(128);
44 FL_CHECK(client.getBrightness() == 128);
45 FL_CHECK(mock->getBrightness() == 128);
46 }
47
48 FL_SUBCASE("Brightness is preserved when turning off and on") {
49 client.setBrightness(100);
50 client.setOn(true);
51 FL_CHECK(mock->getBrightness() == 100);
52
53 client.setOn(false);
54 FL_CHECK(client.getBrightness() == 100); // Internal brightness preserved
55 FL_CHECK(mock->getBrightness() == 0); // Controller brightness is 0
56
57 client.setOn(true);
58 FL_CHECK(mock->getBrightness() == 100); // Restored to internal brightness
59 }
60}
61
62FL_TEST_CASE("WLEDClient on/off control") {
63 auto mock = fl::make_shared<MockFastLED>(50);
64 WLEDClient client(mock);
65
66 FL_SUBCASE("Turning on applies current brightness") {
67 client.setBrightness(150);
68 client.setOn(true);
69 FL_CHECK(client.getOn() == true);

Callers

nothing calls this directly

Calls 15

setOnMethod · 0.80
getClearCallCountMethod · 0.80
getShowCallCountMethod · 0.80
getLastCorrectionMethod · 0.80
getLastTemperatureMethod · 0.80
CRGBClass · 0.50
getOnMethod · 0.45
getBrightnessMethod · 0.45
getNumLEDsMethod · 0.45
setBrightnessMethod · 0.45
clearMethod · 0.45
getLEDsMethod · 0.45

Tested by

no test coverage detected