Skip to content

Commit

Permalink
🚧 Blink leds disconnection only if charging
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Dec 16, 2022
1 parent f6ba849 commit 2d3b6b4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion libs/RobotKit/include/RobotController.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ class RobotController : public interface::RobotController
void startDisconnectionBehavior() final
{
stopActuators();
_behaviorkit.blinkOnCharge();
if (_battery.isCharging()) {
_behaviorkit.blinkOnCharge();
}
}

void startAutonomousActivityMode() final
Expand Down
14 changes: 13 additions & 1 deletion libs/RobotKit/tests/RobotController_test_stateDisconnected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@

#include "./RobotController_test.h"

TEST_F(RobotControllerTest, startDisconnectionBehavior)
TEST_F(RobotControllerTest, startDisconnectionBehaviorCharging)
{
expectedCallsStopActuators();

EXPECT_CALL(battery, isCharging).WillOnce(Return(true));
EXPECT_CALL(mock_ledkit, start(isSameAnimation(&led::animation::blink_on_charge))).Times(1);

rc.startDisconnectionBehavior();
EXPECT_FALSE(rc.isBleConnected());
}

TEST_F(RobotControllerTest, startDisconnectionBehaviorNotCharging)
{
expectedCallsStopActuators();

EXPECT_CALL(battery, isCharging).WillOnce(Return(false));
EXPECT_CALL(mock_ledkit, start(isSameAnimation(&led::animation::blink_on_charge))).Times(0);

rc.startDisconnectionBehavior();
EXPECT_FALSE(rc.isBleConnected());
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ TEST_F(RobotControllerTest, stateFileExchangeEventDisconnectionGuardIsCharging)
// TODO: Specify which BLE service and what is expected if necessary
EXPECT_CALL(mbed_mock_gatt, write(_, _, _, _)).Times(AnyNumber()).InSequence(on_file_exchange_end);

Sequence start_disconnection_behavior;
expectedCallsStopActuators();
EXPECT_CALL(mock_ledkit, start);
EXPECT_CALL(battery, isCharging).InSequence(start_disconnection_behavior).WillOnce(Return(returned_is_charging));
EXPECT_CALL(mock_ledkit, start).InSequence(start_disconnection_behavior);

Sequence start_charging_behavior_sequence;
EXPECT_CALL(battery, level).InSequence(start_charging_behavior_sequence);
Expand Down Expand Up @@ -99,7 +101,10 @@ TEST_F(RobotControllerTest, stateFileExchangeEventDisconnectionGuardIsNotChargin
// TODO: Specify which BLE service and what is expected if necessary
EXPECT_CALL(mbed_mock_gatt, write(_, _, _, _)).Times(AnyNumber()).InSequence(on_file_exchange_end);

Sequence start_disconnection_behavior;
expectedCallsStopActuators();
EXPECT_CALL(battery, isCharging).InSequence(start_disconnection_behavior).WillOnce(Return(returned_is_charging));
EXPECT_CALL(mock_ledkit, start).Times(0).InSequence(start_disconnection_behavior);

Sequence on_idle_sequence;
EXPECT_CALL(timeout, onTimeout).InSequence(on_idle_sequence);
Expand Down

0 comments on commit 2d3b6b4

Please sign in to comment.