Skip to content

Commit

Permalink
Adds test to verify that speed replies from the listener protocol cor…
Browse files Browse the repository at this point in the history
…rectly

clear the estopActive_ in the throttle client cache.
  • Loading branch information
balazsracz committed Nov 30, 2020
1 parent 4119004 commit bd80aea
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/openlcb/TractionThrottle.cxxtest
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,23 @@ TEST_F(ThrottleClientTest, ListenerCallback)
// send another speed command to verify that E-Stop gets cleared
throttle_.set_speed(v);
EXPECT_FALSE(throttle_.get_emergencystop());

// Go back to estop.
EXPECT_CALL(l, update(-1));
EXPECT_FALSE(throttle_.get_emergencystop());
send_packet(":X195EB330N077102;"); // E-Stop
wait();
Mock::VerifyAndClear(&l);
EXPECT_TRUE(throttle_.get_emergencystop());

// Speed replies will also clear estop.
EXPECT_CALL(l, update(-1));
send_packet(":X195EB330N07710045D0;"); // speed 13 mph
wait();
Mock::VerifyAndClear(&l);
EXPECT_NEAR(13, throttle_.get_speed().mph(), 0.1);
EXPECT_EQ(Velocity::FORWARD, throttle_.get_speed().direction());
EXPECT_FALSE(throttle_.get_emergencystop());
}

} // namespace openlcb

0 comments on commit bd80aea

Please sign in to comment.