This commit is contained in:
Michael Zanetti 2020-07-27 14:36:44 +02:00
parent 5002fad6d9
commit 399f406d10
6 changed files with 17 additions and 16 deletions

View File

@ -1697,19 +1697,19 @@ void ThingManagerImplementation::onAutoThingDisappeared(const ThingId &thingId)
Thing *thing = m_configuredThings.value(thingId); Thing *thing = m_configuredThings.value(thingId);
if (!thing) { if (!thing) {
qWarning(dcThingManager) << "Received an autoThingDisappeared signal but this thing is unknown:" << thingId; qCWarning(dcThingManager) << "Received an autoThingDisappeared signal but this thing is unknown:" << thingId;
return; return;
} }
ThingClass thingClass = m_supportedThings.value(thing->thingClassId()); ThingClass thingClass = m_supportedThings.value(thing->thingClassId());
if (thingClass.pluginId() != plugin->pluginId()) { if (thingClass.pluginId() != plugin->pluginId()) {
qWarning(dcThingManager) << "Received a autoThingDisappeared signal but emitting plugin does not own the thing"; qCWarning(dcThingManager) << "Received a autoThingDisappeared signal but emitting plugin does not own the thing";
return; return;
} }
if (!thing->autoCreated()) { if (!thing->autoCreated()) {
qWarning(dcThingManager) << "Received an autoThingDisappeared signal but thing creationMethod is not CreateMothodAuto"; qCWarning(dcThingManager) << "Received an autoThingDisappeared signal but thing creationMethod is not CreateMothodAuto";
return; return;
} }

View File

@ -171,11 +171,11 @@ bool StateDescriptor::operator ==(const State &state) const
if ((m_stateTypeId != state.stateTypeId()) || (m_thingId != state.thingId())) { if ((m_stateTypeId != state.stateTypeId()) || (m_thingId != state.thingId())) {
return false; return false;
} }
if (!m_stateValue.canConvert(state.value().type())) { QVariant convertedValue = m_stateValue;
bool res = convertedValue.convert(state.value().type());
if (!res) {
return false; return false;
} }
QVariant convertedValue = m_stateValue;
convertedValue.convert(state.value().type());
switch (m_operatorType) { switch (m_operatorType) {
case Types::ValueOperatorEquals: case Types::ValueOperatorEquals:
return convertedValue == state.value(); return convertedValue == state.value();

View File

@ -98,7 +98,7 @@
"name": "double", "name": "double",
"displayName": "Dummy double state", "displayName": "Dummy double state",
"displayNameEvent": "Dummy double state changed", "displayNameEvent": "Dummy double state changed",
"type": "int", "type": "double",
"minValue": 0, "minValue": 0,
"maxValue": 100, "maxValue": 100,
"defaultValue": 2.7 "defaultValue": 2.7

View File

@ -382,10 +382,10 @@ void TestIntegrations::addThing_data()
QTest::newRow("User, JustAdd, wrong param") << mockThingClassId << invalidThingParams << true << Thing::ThingErrorInvalidParameter; QTest::newRow("User, JustAdd, wrong param") << mockThingClassId << invalidThingParams << true << Thing::ThingErrorInvalidParameter;
thingParams.clear(); thingParams << httpportParam << fakeparam; thingParams.clear(); thingParams << httpportParam << fakeparam;
QTest::newRow("USer, JustAdd, additional invalid param") << mockThingClassId << thingParams << false << Thing::ThingErrorNoError; QTest::newRow("USer, JustAdd, additional invalid param") << mockThingClassId << thingParams << false << Thing::ThingErrorInvalidParameter;
thingParams.clear(); thingParams << httpportParam << fakeparam2; thingParams.clear(); thingParams << httpportParam << fakeparam2;
QTest::newRow("USer, JustAdd, additional param, valid but unused") << mockThingClassId << thingParams << true << Thing::ThingErrorNoError; QTest::newRow("USer, JustAdd, duplicate param") << mockThingClassId << thingParams << true << Thing::ThingErrorInvalidParameter;
} }

View File

@ -265,13 +265,14 @@ void TestRules::setWritableStateValue(const ThingId &thingId, const StateTypeId
QVariantList stateChangedVariants = checkNotifications(stateSpy, "Integrations.StateChanged"); QVariantList stateChangedVariants = checkNotifications(stateSpy, "Integrations.StateChanged");
QVERIFY2(stateChangedVariants.count() == 1, "Did not get Integrations.StateChanged notification."); QVERIFY2(stateChangedVariants.count() == 1, "Did not get Integrations.StateChanged notification.");
qCDebug(dcTests()) << "Notification content:" << qUtf8Printable(QJsonDocument::fromVariant(stateChangedVariants).toJson());
QVariantMap notification = stateChangedVariants.first().toMap().value("params").toMap(); QVariantMap notification = stateChangedVariants.first().toMap().value("params").toMap();
QVERIFY2(notification.contains("thingId"), "Integrations.StateChanged notification does not contain thingId"); QVERIFY2(notification.contains("thingId"), "Integrations.StateChanged notification does not contain thingId");
QVERIFY2(ThingId(notification.value("thingId").toString()) == thingId, "Integrations.StateChanged notification does not contain the correct thingId"); QVERIFY2(ThingId(notification.value("thingId").toString()) == thingId, "Integrations.StateChanged notification does not contain the correct thingId");
QVERIFY2(notification.contains("stateTypeId"), "Integrations.StateChanged notification does not contain stateTypeId"); QVERIFY2(notification.contains("stateTypeId"), "Integrations.StateChanged notification does not contain stateTypeId");
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == stateTypeId, "Integrations.StateChanged notification does not contain the correct stateTypeId"); QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == stateTypeId, "Integrations.StateChanged notification does not contain the correct stateTypeId");
QVERIFY2(notification.contains("value"), "Integrations.StateChanged notification does not contain new state value"); QVERIFY2(notification.contains("value"), "Integrations.StateChanged notification does not contain new state value");
QVERIFY2(notification.value("value") == QVariant(value), "Integrations.StateChanged notification does not contain the new value"); QVERIFY2(notification.value("value") == QVariant(value), QString("Integrations.StateChanged notification does not contain the new value. Got: %1, Expected: %2").arg(notification.value("value").toString()).arg(QVariant(value).toString()).toUtf8());
} }
} }
@ -1990,11 +1991,11 @@ void TestRules::testChildEvaluator_data()
QTest::addColumn<bool>("trigger"); QTest::addColumn<bool>("trigger");
QTest::addColumn<bool>("active"); QTest::addColumn<bool>("active");
QTest::newRow("Unchanged | 2 | 2.5 | String value 1 | #FF0000") << testThingId << ruleMap << 2 << 2.5 << "String value 1" << "#FF0000" << false << false; QTest::newRow("Unchanged | 2 | 2.5 | String value 1 | #FF0000") << testThingId << ruleMap << 2 << 2.5 << "String value 1" << "#ff0000" << false << false;
QTest::newRow("Unchanged | 60 | 2.5 | String value 2 | #FF0000") << testThingId << ruleMap << 60 << 2.5 << "String value 2" << "#FF0000" << false << false; QTest::newRow("Unchanged | 60 | 2.5 | String value 2 | #FF0000") << testThingId << ruleMap << 60 << 2.5 << "String value 2" << "#ff0000" << false << false;
QTest::newRow("Unchanged | 60 | 20.5 | String value 2 | #FF0000") << testThingId << ruleMap << 60 << 20.5 << "String value 2" << "#FF0000" << false << false; QTest::newRow("Unchanged | 60 | 20.5 | String value 2 | #FF0000") << testThingId << ruleMap << 60 << 20.5 << "String value 2" << "#ff0000" << false << false;
QTest::newRow("Active | 60 | 20.5 | String value 2 | #00FF00") << testThingId << ruleMap << 60 << 20.5 << "String value 2" << "#00FF00" << true << true; QTest::newRow("Active | 60 | 20.5 | String value 2 | #00FF00") << testThingId << ruleMap << 60 << 20.5 << "String value 2" << "#00ff00" << true << true;
QTest::newRow("Active | 60 | 20.5 | String value 2 | #00FF00") << testThingId << ruleMap << 60 << 20.5 << "String value 2" << "#00FF00" << true << true; QTest::newRow("Active | 60 | 20.5 | String value 2 | #00FF00") << testThingId << ruleMap << 60 << 20.5 << "String value 2" << "#00ff00" << true << true;
} }
void TestRules::testChildEvaluator() void TestRules::testChildEvaluator()

View File

@ -118,7 +118,7 @@ protected:
// just for debugging // just for debugging
inline void printJson(const QVariant &response) { inline void printJson(const QVariant &response) {
QJsonDocument jsonDoc = QJsonDocument::fromVariant(response); QJsonDocument jsonDoc = QJsonDocument::fromVariant(response);
qDebug() << jsonDoc.toJson(); qCDebug(dcTests()) << jsonDoc.toJson();
} }
void waitForDBSync(); void waitForDBSync();