Fix failing test

pull/211/head
Michael Zanetti 2019-10-17 12:21:16 +02:00
parent e049c3b2f5
commit 679e51b027
4 changed files with 25 additions and 2 deletions

View File

@ -620,6 +620,7 @@ DevicePairingInfo *DeviceManagerImplementation::confirmPairing(const PairingTran
return;
}
qCDebug(dcDeviceManager()) << "Setup complete for device" << info->device();
info->device()->setupCompleted();
if (addNewDevice) {
@ -1239,6 +1240,7 @@ void DeviceManagerImplementation::loadConfiguredDevices()
return;
}
qCDebug(dcDeviceManager()) << "Setup complete for device" << info->device();
info->device()->setupCompleted();
postSetupDevice(info->device());
});

View File

@ -139,6 +139,7 @@ void DevicePluginMock::setupDevice(DeviceSetupInfo *info)
async = info->device()->paramValue(mockDeviceAutoDeviceAsyncParamTypeId).toBool();
broken = info->device()->paramValue(mockDeviceAutoDeviceBrokenParamTypeId).toBool();
}
qCDebug(dcMockDevice()) << "SetupDevice for" << info->device()->name() << "Async:" << async << "Broken:" << broken;
if (!async && broken) {
qCWarning(dcMockDevice) << "This device is intentionally broken.";
@ -176,6 +177,7 @@ void DevicePluginMock::setupDevice(DeviceSetupInfo *info)
});
return;
}
qCDebug(dcMockDevice()) << "Setup complete" << info->device()->name();
info->finish(Device::DeviceErrorNoError);
return;
}

View File

@ -25,6 +25,8 @@
#include "logging/logvaluetool.h"
#include "servers/mocktcpserver.h"
#include <qglobal.h>
using namespace nymeaserver;
class TestLogging : public NymeaTestBase
@ -34,6 +36,8 @@ class TestLogging : public NymeaTestBase
private:
private slots:
void initTestCase();
void initLogs();
void databaseSerializationTest_data();
@ -62,6 +66,15 @@ private slots:
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()
{
QVariant response = injectAndWait("Logging.GetLogEntries");
@ -588,6 +601,14 @@ void TestLogging::testHouseKeeping()
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);
QVERIFY2(response.toMap().value("params").toMap().value("logEntries").toList().count() == 0, "Device state change event still in log. Should've been cleaned by housekeeping.");
}

View File

@ -64,7 +64,6 @@ protected:
inline void verifyError(const QVariant &response, const QString &fieldName, const QString &error)
{
qCDebug(dcTests()) << "******* response 2" << response;
QJsonDocument jsonDoc = QJsonDocument::fromVariant(response);
QVERIFY2(response.toMap().value("status").toString() == QString("success"),
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) {
qCDebug(dcTests()) << "******* response" << response;
verifyError(response, "ruleError", JsonTypes::ruleErrorToString(error));
}