Skip to content

Commit

Permalink
✅ (BLEKit): Add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed May 21, 2024
1 parent 980fcc1 commit c24197d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions libs/BLEKit/tests/BLEServiceMonitoring_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,28 @@ TEST_F(BLEServiceMonitoringTest, onDataRequested)

// nothing expected
}

TEST_F(BLEServiceMonitoringTest, onDataRequestedNotSameHandle)
{
data_requested_handle.handle = 0xFFFF;

service_monitoring.onDataRequested(data_requested_handle);

// nothing expected
}

TEST_F(BLEServiceMonitoringTest, setNegotiatedMtu)
{
uint16_t actual_negotiated_mtu {};

auto spy_callback = [&actual_negotiated_mtu](const BLEServiceMonitoring::data_to_send_handle_t &handle) {
actual_negotiated_mtu = std::get<1>(handle)[0];
};

service_monitoring.onDataReadyToSend(spy_callback);

uint16_t expect_negotiated_mtu = 23;
service_monitoring.setNegotiatedMtu(expect_negotiated_mtu);

EXPECT_EQ(actual_negotiated_mtu, expect_negotiated_mtu);
}
9 changes: 9 additions & 0 deletions libs/BLEKit/tests/CoreGap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,12 @@ TEST_F(CoreGapTest, isConnectedDefault)

EXPECT_FALSE(is_connected);
}

TEST_F(CoreGapTest, isConnectedAfterConnection)
{
auto dummy_on_connection_callback = std::function<void()> {};

coregap.onConnectionCallback(dummy_on_connection_callback);

// nothing expected
}
13 changes: 13 additions & 0 deletions libs/BLEKit/tests/CoreGattServerEventHandler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,16 @@ TEST_F(CoreGattServerEventHandlerTest, onDataRequestedParamsHandleDifferent)

gatt_event_handler.onDataRead(params);
}

TEST_F(CoreGattServerEventHandlerTest, onMTUNegotiated)
{
auto expected_mtu = uint16_t {23};

MockFunction<void(uint16_t)> mock_on_mtu_negotiated_callback;

gatt_event_handler.onMTUNegotiated(mock_on_mtu_negotiated_callback.AsStdFunction());

EXPECT_CALL(mock_on_mtu_negotiated_callback, Call(expected_mtu)).Times(1);

gatt_event_handler.onAttMtuChange(0, expected_mtu);
}

0 comments on commit c24197d

Please sign in to comment.