state changed notification

pull/135/head
Simon Stürz 2016-03-04 11:46:13 +01:00 committed by Michael Zanetti
parent a225423b73
commit b841fd03d6
1 changed files with 13 additions and 5 deletions

View File

@ -213,7 +213,9 @@ void TestJSONRPC::stateChangeEmitsNotifications()
QNetworkReply *reply = nam.get(request);
reply->deleteLater();
clientSpy.wait();
qDebug() << "Waiting for notifications";
clientSpy.wait(8000);
// Make sure the notification contains all the stuff we expect
QVariantList stateChangedVariants = checkNotifications(clientSpy, "Devices.StateChanged");
@ -221,13 +223,15 @@ void TestJSONRPC::stateChangeEmitsNotifications()
qDebug() << "got" << stateChangedVariants.count() << "Devices.StateChanged notifications";
foreach (const QVariant &stateChangedVariant, stateChangedVariants) {
qDebug() << QJsonDocument::fromVariant(stateChangedVariant).toJson();
if (stateChangedVariant.toMap().value("params").toMap().value("stateTypeId").toUuid() == stateTypeId) {
found = true;
QCOMPARE(stateChangedVariant.toMap().value("params").toMap().value("value").toInt(), newVal);
break;
}
}
if (!found)
qDebug() << QJsonDocument::fromVariant(stateChangedVariants).toJson();
QVERIFY2(found, "Could not find the correct Devices.StateChanged notification");
// Make sure the logg notification contains all the stuff we expect
@ -246,9 +250,10 @@ void TestJSONRPC::stateChangeEmitsNotifications()
break;
}
}
QVERIFY2(found, "Could not find the correct Events.EventTriggered notification");
if (!found)
qDebug() << QJsonDocument::fromVariant(loggEntryAddedVariants).toJson();
QVERIFY2(found, "Could not find the corresponding Logging.LogEntryAdded notification");
// Make sure the notification contains all the stuff we expect
@ -265,7 +270,10 @@ void TestJSONRPC::stateChangeEmitsNotifications()
break;
}
}
QVERIFY2(found, "Could not find the correct Events.EventTriggered notification");
if (!found)
qDebug() << QJsonDocument::fromVariant(eventTriggeredVariants).toJson();
QVERIFY2(found, "Could not find the corresponding Events.EventTriggered notification");
// Now turn off notifications
QCOMPARE(disableNotifications(), true);