Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
test_int_SystemManager.cpp
Go to the documentation of this file.
1
14
15#include <QCoreApplication>
16#include <QSignalSpy>
17#include "BatteryController.hpp"
20#include "SystemManager.hpp"
21#include <gtest/gtest.h>
22
28class SystemManagerTest : public ::testing::Test
29{
30protected:
31 static QCoreApplication *app;
36
37 static void SetUpTestSuite()
38 {
39 int argc = 0;
40 char *argv[] = {nullptr};
41 app = new QCoreApplication(argc, argv);
42 }
43
44 static void TearDownTestSuite() { delete app; }
45
55
56 void TearDown() override
57 {
58 delete systemManager;
59 delete batteryController;
60 delete systemInfoProvider;
62 }
63};
64
66QCoreApplication *SystemManagerTest::app = nullptr;
67
76TEST_F(SystemManagerTest, UpdateTimeSignal)
77{
78 QSignalSpy spy(systemManager, &SystemManager::timeUpdated);
79
80 systemManager->initialize();
81 QCoreApplication::processEvents();
82
83 ASSERT_GT(spy.count(), 0);
84 QList<QVariant> args = spy.takeFirst();
85 EXPECT_FALSE(args.isEmpty());
86}
87
95TEST_F(SystemManagerTest, UpdateWifiStatusSignal)
96{
97 QSignalSpy spy(systemManager, &SystemManager::wifiStatusUpdated);
98
99 systemManager->initialize();
100 QCoreApplication::processEvents();
101
102 ASSERT_GT(spy.count(), 0);
103 QList<QVariant> args = spy.takeFirst();
104 EXPECT_FALSE(args.isEmpty());
105}
106
114TEST_F(SystemManagerTest, UpdateTemperatureSignal)
115{
116 QSignalSpy spy(systemManager, &SystemManager::temperatureUpdated);
117
118 systemManager->initialize();
119 QCoreApplication::processEvents();
120
121 ASSERT_GT(spy.count(), 0);
122 QList<QVariant> args = spy.takeFirst();
123 EXPECT_FALSE(args.isEmpty());
124}
125
133TEST_F(SystemManagerTest, UpdateBatteryPercentageSignal)
134{
135 QSignalSpy spy(systemManager, &SystemManager::batteryPercentageUpdated);
136
137 systemManager->initialize();
138 QCoreApplication::processEvents();
139
140 ASSERT_GT(spy.count(), 0);
141 QList<QVariant> args = spy.takeFirst();
142 EXPECT_GE(args.at(0).toFloat(), 0.0f);
143 EXPECT_LE(args.at(0).toFloat(), 100.0f);
144}
145
153TEST_F(SystemManagerTest, UpdateIpAddressSignal)
154{
155 QSignalSpy spy(systemManager, &SystemManager::ipAddressUpdated);
156
157 systemManager->initialize();
158 QCoreApplication::processEvents();
159
160 ASSERT_GT(spy.count(), 0);
161 QList<QVariant> args = spy.takeFirst();
162 EXPECT_FALSE(args.isEmpty());
163}
164
171TEST_F(SystemManagerTest, ShutdownSystemManager)
172{
173 systemManager->initialize();
174 systemManager->shutdown();
175
176 EXPECT_EQ(systemManager->getTimeTimer().isActive(), false);
177 EXPECT_EQ(systemManager->getStatusTimer().isActive(), false);
178}
Definition of the BatteryController class.
Definition of the SystemCommandExecutor class.
Definition of the SystemInfoProvider class.
Definition of the SystemManager class.
Class that manages the battery of the vehicle.
Interface for managing the battery of the vehicle.
Interface for executing system commands and reading files.
Interface for providing system information to the display manager.
Class that executes system commands and reads files.
Class that provides system information to the display manager.
Class to test the integration between the SystemManager and the BatteryController,...
ISystemInfoProvider * systemInfoProvider
static QCoreApplication * app
Initialize static member.
ISystemCommandExecutor * systemCommandExecutor
IBatteryController * batteryController
Class that manages the system time, status, and battery. QObject.
void ipAddressUpdated(const QString &ipAddress)
void batteryPercentageUpdated(float batteryPercentage)
void wifiStatusUpdated(const QString &status, const QString &wifiName)
void timeUpdated(const QString &currentDate, const QString &currentTime, const QString &currentDay)
void temperatureUpdated(const QString &temperature)
TEST_F(SystemManagerTest, UpdateTimeSignal)
Ensures that the SystemManager initializes successfully.