mirror of https://github.com/nymea/nymea.git
add a test
parent
f48a1d185b
commit
4fc0ef01fa
|
|
@ -4,8 +4,8 @@
|
|||
{
|
||||
"name": "color temperature",
|
||||
"type": "int",
|
||||
"minValue": "any",
|
||||
"maxValue": "any"
|
||||
"minimumValue": "any",
|
||||
"maximumValue": "any"
|
||||
},
|
||||
{
|
||||
"name": "color",
|
||||
|
|
|
|||
|
|
@ -487,15 +487,31 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
|
|||
valid = false;
|
||||
continue;
|
||||
}
|
||||
if (stateMap.contains("minimumValue") && stateMap.value("minimumValue") != stateType.minValue()) {
|
||||
qCWarning(dcDeviceManager) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateMap.value("name").toString() << "has not matching minimum value" << stateMap.value("minimumValue") << "!=" << stateType.minValue();
|
||||
valid = false;
|
||||
continue;
|
||||
if (stateMap.contains("minimumValue")) {
|
||||
if (stateMap.value("minimumValue").toString() == "any") {
|
||||
if (stateType.minValue().isNull()) {
|
||||
qCWarning(dcDeviceManager) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateMap.value("name").toString() << "has no minimum value defined.";
|
||||
valid = false;
|
||||
continue;
|
||||
}
|
||||
} else if (stateMap.value("minimumValue") != stateType.minValue()) {
|
||||
qCWarning(dcDeviceManager) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateMap.value("name").toString() << "has not matching minimum value:" << stateMap.value("minimumValue") << "!=" << stateType.minValue();
|
||||
valid = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (stateMap.contains("maximumValue") && stateMap.value("maximumValue") != stateType.maxValue()) {
|
||||
qCWarning(dcDeviceManager) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateMap.value("name").toString() << "has not matching allowed value" << stateMap.value("maximumValue") << "!=" << stateType.maxValue();
|
||||
valid = false;
|
||||
continue;
|
||||
if (stateMap.contains("maximumValue")) {
|
||||
if (stateMap.value("maximumValue").toString() == "any") {
|
||||
if (stateType.maxValue().isNull()) {
|
||||
qCWarning(dcDeviceManager) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateMap.value("name").toString() << "has no maximum value defined.";
|
||||
valid = false;
|
||||
continue;
|
||||
}
|
||||
} else if (stateMap.value("maximumValue") != stateType.maxValue()) {
|
||||
qCWarning(dcDeviceManager) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateMap.value("name").toString() << "has not matching maximum value:" << stateMap.value("maximumValue") << "!=" << stateType.minValue();
|
||||
valid = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (stateMap.contains("allowedValues") && stateMap.value("allowedValues") != stateType.possibleValues()) {
|
||||
qCWarning(dcDeviceManager) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateMap.value("name").toString() << "has not matching allowed values" << stateMap.value("allowedValues") << "!=" << stateType.possibleValues();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS += \
|
||||
# mock \
|
||||
mock \
|
||||
# elro \
|
||||
# intertechno \
|
||||
# networkdetector \
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
"idName": "mock",
|
||||
"name": "Mock Device",
|
||||
"deviceIcon": "Tune",
|
||||
"interfaces": ["gateway", "light", "mediacontroller"],
|
||||
"basicTags": [
|
||||
"Device",
|
||||
"Actuator",
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ private slots:
|
|||
void getSupportedDevices_data();
|
||||
void getSupportedDevices();
|
||||
|
||||
void verifyInterfaces();
|
||||
|
||||
void addConfiguredDevice_data();
|
||||
void addConfiguredDevice();
|
||||
|
||||
|
|
@ -223,6 +225,27 @@ void TestDevices::getSupportedDevices()
|
|||
QCOMPARE(supportedDevices.count() >= resultCount, true);
|
||||
}
|
||||
|
||||
void TestDevices::verifyInterfaces()
|
||||
{
|
||||
QVariantMap params;
|
||||
params.insert("vendorId", guhVendorId);
|
||||
QVariant result = injectAndWait("Devices.GetSupportedDevices", params);
|
||||
QVariantList supportedDevices = result.toMap().value("params").toMap().value("deviceClasses").toList();
|
||||
|
||||
QVariantMap mockDevice;
|
||||
foreach (const QVariant &deviceClass, supportedDevices) {
|
||||
if (deviceClass.toMap().value("id") == mockDeviceClassId) {
|
||||
mockDevice = deviceClass.toMap();
|
||||
}
|
||||
}
|
||||
QVERIFY(!mockDevice.isEmpty());
|
||||
|
||||
QVariantList interfaces = mockDevice.value("interfaces").toList();
|
||||
// Must contain gateway, but must not contain anything else as device manager should filter it away
|
||||
QCOMPARE(interfaces.count() == 1, true);
|
||||
QVERIFY(interfaces.contains("gateway"));
|
||||
}
|
||||
|
||||
void TestDevices::addConfiguredDevice_data()
|
||||
{
|
||||
QTest::addColumn<DeviceClassId>("deviceClassId");
|
||||
|
|
|
|||
Loading…
Reference in New Issue