15#include <QCoreApplication>
20#include <gtest/gtest.h>
30 static QCoreApplication *
app;
37 char *argv[] = {
nullptr};
38 app =
new QCoreApplication(argc, argv);
74 emit controller->speedUpdated(88.8f);
75 QCoreApplication::processEvents();
77 ASSERT_GT(spy.count(), 0) <<
"Signal was not emitted!";
78 QList<QVariant> args = spy.takeFirst();
79 EXPECT_FLOAT_EQ(args.at(0).toFloat(), 88.8f);
94 emit controller->rpmUpdated(4500);
95 QCoreApplication::processEvents();
97 ASSERT_GT(spy.count(), 0) <<
"Signal was not emitted!";
98 QList<QVariant> args = spy.takeFirst();
99 EXPECT_EQ(args.at(0).toInt(), 4500);
111 ASSERT_TRUE(canBusManager->initialize()) <<
"Initialization failed!";
112 ASSERT_NE(canBusManager->getThread(),
nullptr) <<
"Thread not created!";
113 ASSERT_TRUE(canBusManager->getThread()->isRunning()) <<
"Thread did not start!";
125 ASSERT_NE(tmpManager,
nullptr);
127 ASSERT_EQ(tmpManager->
getThread(),
nullptr) <<
"Thread created too soon!";
131 ASSERT_NE(tmpManager->
getThread(),
nullptr) <<
"Thread not created!";
132 ASSERT_TRUE(tmpManager->
getThread()->isRunning()) <<
"Thread did not start!";
136 ASSERT_EQ(tmpManager->
getThread(),
nullptr) <<
"Thread not deleted!";
Definition of the CanBusManager class.
Definition of the MCP2515Controller class.
Class to test the integration between the CanBusManager and the MCP2515 controller.
static QCoreApplication * app
Initialize static member.
static void SetUpTestSuite()
CanBusManager * canBusManager
static void TearDownTestSuite()
IMCP2515Controller * controller
Class that manages the CAN bus communication. QObject.
void rpmUpdated(int newRpm)
Signal emitted when the RPM is updated.
QThread * getThread() const
void speedUpdated(float newSpeed)
Signal emitted when the speed is updated.
bool initialize()
Initializes the CanBusManager.
Interface for the MCP2515 CAN controller. QObject.
Class that controls the MCP2515 CAN controller. IMCP2515Controller.
TEST_F(CanBusManagerTest, ForwardSpeedDataFromMCP2515)
Ensures that the CanBusManager forwards speed data from the MCP2515 controller.