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

Function FL_TEST_FILE

tests/fl/stl/asio/http/connection.cpp:5–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "test.h"
4
5FL_TEST_FILE(FL_FILEPATH) {
6
7using namespace fl;
8
9FL_TEST_CASE("HttpConnection - Initial state is DISCONNECTED") {
10 HttpConnection conn;
11 FL_CHECK(conn.getState() == ConnectionState::DISCONNECTED);
12 FL_CHECK(conn.isDisconnected());
13 FL_CHECK_FALSE(conn.isConnected());
14 FL_CHECK_FALSE(conn.shouldReconnect());
15}
16
17FL_TEST_CASE("HttpConnection - Connect transitions to CONNECTING") {
18 HttpConnection conn;
19 conn.connect();
20 FL_CHECK(conn.getState() == ConnectionState::CONNECTING);
21}
22
23FL_TEST_CASE("HttpConnection - onConnected transitions to CONNECTED") {
24 HttpConnection conn;
25 conn.connect();
26 conn.onConnected();
27 FL_CHECK(conn.getState() == ConnectionState::CONNECTED);
28 FL_CHECK(conn.isConnected());
29}
30
31FL_TEST_CASE("HttpConnection - Disconnect from CONNECTED") {
32 HttpConnection conn;
33 conn.connect();
34 conn.onConnected();
35 conn.disconnect();
36 FL_CHECK(conn.getState() == ConnectionState::DISCONNECTED);
37}
38
39FL_TEST_CASE("HttpConnection - onDisconnected triggers RECONNECTING") {
40 HttpConnection conn;
41 conn.connect();
42 conn.onConnected();
43 conn.onDisconnected();
44 FL_CHECK(conn.getState() == ConnectionState::RECONNECTING);
45 FL_CHECK(conn.shouldReconnect());
46}
47
48FL_TEST_CASE("HttpConnection - Exponential backoff calculation") {
49 ConnectionConfig config;
50 config.reconnectInitialDelayMs = 1000;
51 config.reconnectMaxDelayMs = 30000;
52 config.reconnectBackoffMultiplier = 2;
53
54 HttpConnection conn(config);
55 conn.connect();
56
57 // Rapid disconnect without successful connection establishes
58 // First disconnect: delay = 1000ms (attempts = 0 → 1)
59 conn.onDisconnected();
60 FL_CHECK(conn.getState() == ConnectionState::RECONNECTING);
61 FL_CHECK(conn.getReconnectAttempts() == 1);
62 FL_CHECK(conn.getReconnectDelayMs() == 1000);

Callers

nothing calls this directly

Calls 15

isDisconnectedMethod · 0.80
shouldReconnectMethod · 0.80
onConnectedMethod · 0.80
onDisconnectedMethod · 0.80
isTimedOutMethod · 0.80
getStateMethod · 0.45
isConnectedMethod · 0.45
connectMethod · 0.45
disconnectMethod · 0.45
getReconnectAttemptsMethod · 0.45
getReconnectDelayMsMethod · 0.45
shouldSendHeartbeatMethod · 0.45

Tested by

no test coverage detected