Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
test_CanBusManager.cpp File Reference

Unit tests for the CanBusManager class. More...

#include "CanBusManager.hpp"
#include "MockMCP2515Controller.hpp"
#include <QSignalSpy>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

Go to the source code of this file.

Data Structures

class  CanBusManagerTest
 Class to test the integration between the CanBusManager and the MCP2515 controller. More...
 

Functions

 TEST_F (CanBusManagerTest, SpeedSignalEmitsCorrectly)
 Ensures that the speed signal is emitted with the correct value.
 
 TEST_F (CanBusManagerTest, RpmSignalEmitsCorrectly)
 Ensures that the RPM signal emits the correct value.
 
 TEST_F (CanBusManagerTest, InitializeFailsWhenControllerFails)
 Ensures that initialize() fails when the controller fails to initialize.
 
 TEST_F (CanBusManagerTest, InitializeSucceedsWhenControllerSucceeds)
 Ensures that initialize() succeeds when the controller initializes successfully.
 
 TEST_F (CanBusManagerTest, DestructorCallsStopReading)
 Verifies that stopReading() is triggered in the destructor.
 

Detailed Description

Unit tests for the CanBusManager class.

Version
0.1
Date
2025-01-30
Author
Félix LE BIHAN (@Fle-bihh)
Ricardo Melo (@reomelo)
Tiago Pereira (@t-pereira06)
Michel Batista (@MicchelFAB)

This file contains unit tests for the CanBusManager class, using Google Test and Google Mock frameworks.

Definition in file test_CanBusManager.cpp.

Function Documentation

◆ TEST_F() [1/5]

TEST_F ( CanBusManagerTest ,
DestructorCallsStopReading  )

Verifies that stopReading() is triggered in the destructor.

Test
Ensures that stopReading() is called when CanBusManager is destroyed.

This test initializes CanBusManager, then deletes it and confirms that stopReading() was called exactly once.

Note
This test indirectly verifies proper cleanup behavior in the destructor.
See also
CanBusManager::~CanBusManager

Definition at line 152 of file test_CanBusManager.cpp.

◆ TEST_F() [2/5]

TEST_F ( CanBusManagerTest ,
InitializeFailsWhenControllerFails  )

Ensures that initialize() fails when the controller fails to initialize.

Test
Tests CanBusManager::initialize() when init() fails.

This test sets up a mock expectation that init() will return false, verifying that initialize() correctly fails in this case.

See also
CanBusManager::initialize

Definition at line 115 of file test_CanBusManager.cpp.

◆ TEST_F() [3/5]

TEST_F ( CanBusManagerTest ,
InitializeSucceedsWhenControllerSucceeds  )

Ensures that initialize() succeeds when the controller initializes successfully.

Test
Tests CanBusManager::initialize() when init() succeeds.

This test sets up a mock expectation that init() will return true, verifying that initialize() correctly returns true.

See also
CanBusManager::initialize

Definition at line 132 of file test_CanBusManager.cpp.

◆ TEST_F() [4/5]

TEST_F ( CanBusManagerTest ,
RpmSignalEmitsCorrectly  )

Ensures that the RPM signal emits the correct value.

Test
Tests if the rpmUpdated signal is emitted correctly.

Similar to SpeedSignalEmitsCorrectly, this test verifies that rpmUpdated emits the expected RPM value.

See also
CanBusManager::rpmUpdated

Definition at line 95 of file test_CanBusManager.cpp.

Here is the call graph for this function:

◆ TEST_F() [5/5]

TEST_F ( CanBusManagerTest ,
SpeedSignalEmitsCorrectly  )

Ensures that the speed signal is emitted with the correct value.

Test
Tests if the speedUpdated signal is emitted correctly.

This test uses QSignalSpy to verify that speedUpdated emits the expected speed value when the mock controller triggers the signal.

See also
CanBusManager::speedUpdated

Definition at line 76 of file test_CanBusManager.cpp.

Here is the call graph for this function: