mirror of https://github.com/nymea/nymea.git
fix tests
parent
c6331465eb
commit
e8053a1df5
|
|
@ -198,17 +198,12 @@ void TestJSONRPC::enableDisableNotifications()
|
||||||
|
|
||||||
void TestJSONRPC::stateChangeEmitsNotifications()
|
void TestJSONRPC::stateChangeEmitsNotifications()
|
||||||
{
|
{
|
||||||
QVariantMap params;
|
QCOMPARE(enableNotifications(), true);
|
||||||
params.insert("enabled", true);
|
|
||||||
QVariant response = injectAndWait("JSONRPC.SetNotificationStatus", params);
|
|
||||||
QCOMPARE(response.toMap().value("params").toMap().value("enabled").toBool(), true);
|
|
||||||
|
|
||||||
// Setup connection to mock client
|
// Setup connection to mock client
|
||||||
QNetworkAccessManager nam;
|
QNetworkAccessManager nam;
|
||||||
|
|
||||||
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
||||||
|
|
||||||
|
|
||||||
// trigger state change in mock device
|
// trigger state change in mock device
|
||||||
int newVal = 1111;
|
int newVal = 1111;
|
||||||
QUuid stateTypeId("80baec19-54de-4948-ac46-31eabfaceb83");
|
QUuid stateTypeId("80baec19-54de-4948-ac46-31eabfaceb83");
|
||||||
|
|
@ -238,10 +233,7 @@ void TestJSONRPC::stateChangeEmitsNotifications()
|
||||||
QCOMPARE(jsonDoc.toVariant().toMap().value("params").toMap().value("event").toMap().value("params").toList().first().toMap().value("value").toInt(), newVal);
|
QCOMPARE(jsonDoc.toVariant().toMap().value("params").toMap().value("event").toMap().value("params").toList().first().toMap().value("value").toInt(), newVal);
|
||||||
|
|
||||||
// Now turn off notifications
|
// Now turn off notifications
|
||||||
params.clear();
|
QCOMPARE(disableNotifications(), true);
|
||||||
params.insert("enabled", false);
|
|
||||||
response = injectAndWait("JSONRPC.SetNotificationStatus", params);
|
|
||||||
QCOMPARE(response.toMap().value("params").toMap().value("enabled").toBool(), false);
|
|
||||||
|
|
||||||
// Fire the a statechange once again
|
// Fire the a statechange once again
|
||||||
clientSpy.clear();
|
clientSpy.clear();
|
||||||
|
|
@ -256,13 +248,12 @@ void TestJSONRPC::stateChangeEmitsNotifications()
|
||||||
QCOMPARE(clientSpy.count(), 0);
|
QCOMPARE(clientSpy.count(), 0);
|
||||||
|
|
||||||
// Now check that the state has indeed changed even though we didn't get a notification
|
// Now check that the state has indeed changed even though we didn't get a notification
|
||||||
params.clear();
|
QVariantMap params;
|
||||||
params.insert("deviceId", m_mockDeviceId);
|
params.insert("deviceId", m_mockDeviceId);
|
||||||
params.insert("stateTypeId", stateTypeId);
|
params.insert("stateTypeId", stateTypeId);
|
||||||
response = injectAndWait("Devices.GetStateValue", params);
|
QVariant response = injectAndWait("Devices.GetStateValue", params);
|
||||||
|
|
||||||
QCOMPARE(response.toMap().value("params").toMap().value("value").toInt(), newVal);
|
QCOMPARE(response.toMap().value("params").toMap().value("value").toInt(), newVal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -282,7 +273,7 @@ void TestJSONRPC::deviceAddedRemovedNotifications()
|
||||||
httpportParam.insert("value", 8765);
|
httpportParam.insert("value", 8765);
|
||||||
deviceParams.append(httpportParam);
|
deviceParams.append(httpportParam);
|
||||||
|
|
||||||
QVariantMap params;
|
QVariantMap params; clientSpy.clear();
|
||||||
params.insert("deviceClassId", mockDeviceClassId);
|
params.insert("deviceClassId", mockDeviceClassId);
|
||||||
params.insert("deviceParams", deviceParams);
|
params.insert("deviceParams", deviceParams);
|
||||||
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params);
|
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||||
|
|
@ -310,7 +301,7 @@ void TestJSONRPC::deviceAddedRemovedNotifications()
|
||||||
verifyDeviceError(response);
|
verifyDeviceError(response);
|
||||||
checkNotification(clientSpy, "Devices.DeviceRemoved");
|
checkNotification(clientSpy, "Devices.DeviceRemoved");
|
||||||
|
|
||||||
//QCOMPARE(disableNotifications(), true);
|
QCOMPARE(disableNotifications(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestJSONRPC::ruleAddedRemovedNotifications()
|
void TestJSONRPC::ruleAddedRemovedNotifications()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue