Fix failing test
This commit is contained in:
parent
e049c3b2f5
commit
679e51b027
@ -620,6 +620,7 @@ DevicePairingInfo *DeviceManagerImplementation::confirmPairing(const PairingTran
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qCDebug(dcDeviceManager()) << "Setup complete for device" << info->device();
|
||||||
info->device()->setupCompleted();
|
info->device()->setupCompleted();
|
||||||
|
|
||||||
if (addNewDevice) {
|
if (addNewDevice) {
|
||||||
@ -1239,6 +1240,7 @@ void DeviceManagerImplementation::loadConfiguredDevices()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qCDebug(dcDeviceManager()) << "Setup complete for device" << info->device();
|
||||||
info->device()->setupCompleted();
|
info->device()->setupCompleted();
|
||||||
postSetupDevice(info->device());
|
postSetupDevice(info->device());
|
||||||
});
|
});
|
||||||
|
|||||||
@ -139,6 +139,7 @@ void DevicePluginMock::setupDevice(DeviceSetupInfo *info)
|
|||||||
async = info->device()->paramValue(mockDeviceAutoDeviceAsyncParamTypeId).toBool();
|
async = info->device()->paramValue(mockDeviceAutoDeviceAsyncParamTypeId).toBool();
|
||||||
broken = info->device()->paramValue(mockDeviceAutoDeviceBrokenParamTypeId).toBool();
|
broken = info->device()->paramValue(mockDeviceAutoDeviceBrokenParamTypeId).toBool();
|
||||||
}
|
}
|
||||||
|
qCDebug(dcMockDevice()) << "SetupDevice for" << info->device()->name() << "Async:" << async << "Broken:" << broken;
|
||||||
|
|
||||||
if (!async && broken) {
|
if (!async && broken) {
|
||||||
qCWarning(dcMockDevice) << "This device is intentionally broken.";
|
qCWarning(dcMockDevice) << "This device is intentionally broken.";
|
||||||
@ -176,6 +177,7 @@ void DevicePluginMock::setupDevice(DeviceSetupInfo *info)
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
qCDebug(dcMockDevice()) << "Setup complete" << info->device()->name();
|
||||||
info->finish(Device::DeviceErrorNoError);
|
info->finish(Device::DeviceErrorNoError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,8 @@
|
|||||||
#include "logging/logvaluetool.h"
|
#include "logging/logvaluetool.h"
|
||||||
#include "servers/mocktcpserver.h"
|
#include "servers/mocktcpserver.h"
|
||||||
|
|
||||||
|
#include <qglobal.h>
|
||||||
|
|
||||||
using namespace nymeaserver;
|
using namespace nymeaserver;
|
||||||
|
|
||||||
class TestLogging : public NymeaTestBase
|
class TestLogging : public NymeaTestBase
|
||||||
@ -34,6 +36,8 @@ class TestLogging : public NymeaTestBase
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void initTestCase();
|
||||||
|
|
||||||
void initLogs();
|
void initLogs();
|
||||||
|
|
||||||
void databaseSerializationTest_data();
|
void databaseSerializationTest_data();
|
||||||
@ -62,6 +66,15 @@ private slots:
|
|||||||
void removeDevice();
|
void removeDevice();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void TestLogging::initTestCase()
|
||||||
|
{
|
||||||
|
NymeaTestBase::initTestCase();
|
||||||
|
QLoggingCategory::setFilterRules("*.debug=false\n"
|
||||||
|
"Tests.debug=true\n"
|
||||||
|
"MockDevice.debug=true\n"
|
||||||
|
"DeviceManager.debug=true\n");
|
||||||
|
}
|
||||||
|
|
||||||
void TestLogging::initLogs()
|
void TestLogging::initLogs()
|
||||||
{
|
{
|
||||||
QVariant response = injectAndWait("Logging.GetLogEntries");
|
QVariant response = injectAndWait("Logging.GetLogEntries");
|
||||||
@ -588,6 +601,14 @@ void TestLogging::testHouseKeeping()
|
|||||||
|
|
||||||
restartServer();
|
restartServer();
|
||||||
|
|
||||||
|
// Wait for the mock device to complete the setup
|
||||||
|
do {
|
||||||
|
qApp->processEvents();
|
||||||
|
params.clear();
|
||||||
|
params.insert("deviceId", m_mockDeviceId);
|
||||||
|
response = injectAndWait("Devices.GetConfiguredDevices", params);
|
||||||
|
} while (!response.toMap().value("params").toMap().value("devices").toList().first().toMap().value("setupComplete").toBool());
|
||||||
|
|
||||||
response = injectAndWait("Logging.GetLogEntries", params);
|
response = injectAndWait("Logging.GetLogEntries", params);
|
||||||
QVERIFY2(response.toMap().value("params").toMap().value("logEntries").toList().count() == 0, "Device state change event still in log. Should've been cleaned by housekeeping.");
|
QVERIFY2(response.toMap().value("params").toMap().value("logEntries").toList().count() == 0, "Device state change event still in log. Should've been cleaned by housekeeping.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,6 @@ protected:
|
|||||||
|
|
||||||
inline void verifyError(const QVariant &response, const QString &fieldName, const QString &error)
|
inline void verifyError(const QVariant &response, const QString &fieldName, const QString &error)
|
||||||
{
|
{
|
||||||
qCDebug(dcTests()) << "******* response 2" << response;
|
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromVariant(response);
|
QJsonDocument jsonDoc = QJsonDocument::fromVariant(response);
|
||||||
QVERIFY2(response.toMap().value("status").toString() == QString("success"),
|
QVERIFY2(response.toMap().value("status").toString() == QString("success"),
|
||||||
QString("\nExpected status: \"success\"\nGot: %2\nFull message: %3")
|
QString("\nExpected status: \"success\"\nGot: %2\nFull message: %3")
|
||||||
@ -80,7 +79,6 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void verifyRuleError(const QVariant &response, RuleEngine::RuleError error = RuleEngine::RuleErrorNoError) {
|
inline void verifyRuleError(const QVariant &response, RuleEngine::RuleError error = RuleEngine::RuleErrorNoError) {
|
||||||
qCDebug(dcTests()) << "******* response" << response;
|
|
||||||
verifyError(response, "ruleError", JsonTypes::ruleErrorToString(error));
|
verifyError(response, "ruleError", JsonTypes::ruleErrorToString(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user