20#include <gmock/gmock.h>
21#include <gtest/gtest.h>
24using ::testing::DoAll;
25using ::testing::NiceMock;
26using ::testing::Return;
60 ASSERT_TRUE(spy.isValid());
62 systemManager->updateTime();
64 ASSERT_EQ(spy.count(), 1);
65 QList<QVariant> arguments = spy.takeFirst();
66 EXPECT_FALSE(arguments.at(0).toString().isEmpty());
67 EXPECT_FALSE(arguments.at(1).toString().isEmpty());
68 EXPECT_FALSE(arguments.at(2).toString().isEmpty());
80 QString mockWifiName =
"MyWiFi";
82 EXPECT_CALL(mockInfoProvider, getWifiStatus(_))
83 .WillOnce(DoAll(testing::SetArgReferee<0>(mockWifiName),
84 Return(QString(
"Connected"))
88 ASSERT_TRUE(spy.isValid());
90 systemManager->updateSystemStatus();
92 ASSERT_EQ(spy.count(), 1);
93 QList<QVariant> arguments = spy.takeFirst();
94 EXPECT_EQ(arguments.at(0).toString(),
"Connected");
95 EXPECT_EQ(arguments.at(1).toString(),
"MyWiFi");
107 EXPECT_CALL(mockInfoProvider, getTemperature()).WillOnce(Return(QString(
"42.0°C")));
110 ASSERT_TRUE(spy.isValid());
112 systemManager->updateSystemStatus();
114 ASSERT_EQ(spy.count(), 1);
115 EXPECT_EQ(spy.takeFirst().at(0).toString(),
"42.0°C");
127 EXPECT_CALL(mockBatteryController, getBatteryPercentage()).WillOnce(Return(75.0f));
130 ASSERT_TRUE(spy.isValid());
132 systemManager->updateSystemStatus();
134 ASSERT_EQ(spy.count(), 1);
135 EXPECT_FLOAT_EQ(spy.takeFirst().at(0).toFloat(), 75.0f);
147 EXPECT_CALL(mockInfoProvider, getIpAddress()).WillOnce(Return(QString(
"192.168.1.100")));
150 ASSERT_TRUE(spy.isValid());
152 systemManager->updateSystemStatus();
154 ASSERT_EQ(spy.count(), 1);
155 EXPECT_EQ(spy.takeFirst().at(0).toString(),
"192.168.1.100");
File containing the Mock class of the BatteryController module.
File containing Mock classes to test the SystemInfoProvider module.
Definition of the SystemManager class.
Class to test the integration between the SystemManager and the BatteryController,...
NiceMock< MockBatteryController > mockBatteryController
SystemManager * systemManager
NiceMock< MockSystemInfoProvider > mockInfoProvider
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 ¤tDate, const QString ¤tTime, const QString ¤tDay)
void temperatureUpdated(const QString &temperature)
TEST_F(SystemManagerTest, UpdateTime_EmitsCorrectSignal)
Ensures that the time is correctly updated.