From 679e51b027ffafa412ddf1220ecb38bd188e2710 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 17 Oct 2019 12:21:16 +0200 Subject: [PATCH] Fix failing test --- .../devices/devicemanagerimplementation.cpp | 2 ++ plugins/mock/devicepluginmock.cpp | 2 ++ tests/auto/logging/testlogging.cpp | 21 +++++++++++++++++++ tests/testlib/nymeatestbase.h | 2 -- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libnymea-core/devices/devicemanagerimplementation.cpp b/libnymea-core/devices/devicemanagerimplementation.cpp index 2c17cf59..68a7dd1e 100644 --- a/libnymea-core/devices/devicemanagerimplementation.cpp +++ b/libnymea-core/devices/devicemanagerimplementation.cpp @@ -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()); }); diff --git a/plugins/mock/devicepluginmock.cpp b/plugins/mock/devicepluginmock.cpp index d1eb5a08..98f67dbd 100644 --- a/plugins/mock/devicepluginmock.cpp +++ b/plugins/mock/devicepluginmock.cpp @@ -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; } diff --git a/tests/auto/logging/testlogging.cpp b/tests/auto/logging/testlogging.cpp index 20ea147d..033874a5 100644 --- a/tests/auto/logging/testlogging.cpp +++ b/tests/auto/logging/testlogging.cpp @@ -25,6 +25,8 @@ #include "logging/logvaluetool.h" #include "servers/mocktcpserver.h" +#include + 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."); } diff --git a/tests/testlib/nymeatestbase.h b/tests/testlib/nymeatestbase.h index e2bbf373..79f08d68 100644 --- a/tests/testlib/nymeatestbase.h +++ b/tests/testlib/nymeatestbase.h @@ -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)); }