20#include <gmock/gmock.h>
21#include <gtest/gtest.h>
24using ::testing::Return;
79 float expectedSpeed = 150.0F;
80 emit mockMcpController->speedUpdated(expectedSpeed);
82 ASSERT_EQ(speedSpy.count(), 1);
83 ASSERT_EQ(speedSpy.takeFirst().at(0).toFloat(), expectedSpeed);
98 int expectedRpm = 2500;
99 emit mockMcpController->rpmUpdated(expectedRpm);
101 ASSERT_EQ(rpmSpy.count(), 1);
102 ASSERT_EQ(rpmSpy.takeFirst().at(0).toInt(), expectedRpm);
117 .WillOnce(Return(
false));
119 ASSERT_FALSE(manager->initialize());
134 .WillOnce(Return(
true));
136 ASSERT_TRUE(manager->initialize());
154 .WillOnce(Return(
true));
159 ASSERT_TRUE(manager->initialize());
Definition of the CanBusManager class.
File containing Mock classes to test the controller of the MCP2515 module.
Class to test the integration between the CanBusManager and the MCP2515 controller.
IMCP2515Controller * mockMcpController
Mocked MCP2515 controller.
void TearDown() override
Tear down the test environment.
void SetUp() override
Set up the test environment.
CanBusManager * manager
CanBusManager object.
Class that manages the CAN bus communication. QObject.
void rpmUpdated(int newRpm)
Signal emitted when the RPM is updated.
void speedUpdated(float newSpeed)
Signal emitted when the speed is updated.
Interface for the MCP2515 CAN controller. QObject.
Class to emulate the behavior of the MCP2515 controller.
TEST_F(CanBusManagerTest, SpeedSignalEmitsCorrectly)
Ensures that the speed signal is emitted with the correct value.