add a test
This commit is contained in:
parent
f48a1d185b
commit
4fc0ef01fa
@ -4,8 +4,8 @@
|
|||||||
{
|
{
|
||||||
"name": "color temperature",
|
"name": "color temperature",
|
||||||
"type": "int",
|
"type": "int",
|
||||||
"minValue": "any",
|
"minimumValue": "any",
|
||||||
"maxValue": "any"
|
"maximumValue": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "color",
|
"name": "color",
|
||||||
|
|||||||
@ -487,15 +487,31 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
|
|||||||
valid = false;
|
valid = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (stateMap.contains("minimumValue") && stateMap.value("minimumValue") != stateType.minValue()) {
|
if (stateMap.contains("minimumValue")) {
|
||||||
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();
|
if (stateMap.value("minimumValue").toString() == "any") {
|
||||||
valid = false;
|
if (stateType.minValue().isNull()) {
|
||||||
continue;
|
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()) {
|
if (stateMap.contains("maximumValue")) {
|
||||||
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();
|
if (stateMap.value("maximumValue").toString() == "any") {
|
||||||
valid = false;
|
if (stateType.maxValue().isNull()) {
|
||||||
continue;
|
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()) {
|
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();
|
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
|
TEMPLATE = subdirs
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
# mock \
|
mock \
|
||||||
# elro \
|
# elro \
|
||||||
# intertechno \
|
# intertechno \
|
||||||
# networkdetector \
|
# networkdetector \
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
"idName": "mock",
|
"idName": "mock",
|
||||||
"name": "Mock Device",
|
"name": "Mock Device",
|
||||||
"deviceIcon": "Tune",
|
"deviceIcon": "Tune",
|
||||||
|
"interfaces": ["gateway", "light", "mediacontroller"],
|
||||||
"basicTags": [
|
"basicTags": [
|
||||||
"Device",
|
"Device",
|
||||||
"Actuator",
|
"Actuator",
|
||||||
|
|||||||
@ -51,6 +51,8 @@ private slots:
|
|||||||
void getSupportedDevices_data();
|
void getSupportedDevices_data();
|
||||||
void getSupportedDevices();
|
void getSupportedDevices();
|
||||||
|
|
||||||
|
void verifyInterfaces();
|
||||||
|
|
||||||
void addConfiguredDevice_data();
|
void addConfiguredDevice_data();
|
||||||
void addConfiguredDevice();
|
void addConfiguredDevice();
|
||||||
|
|
||||||
@ -223,6 +225,27 @@ void TestDevices::getSupportedDevices()
|
|||||||
QCOMPARE(supportedDevices.count() >= resultCount, true);
|
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()
|
void TestDevices::addConfiguredDevice_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<DeviceClassId>("deviceClassId");
|
QTest::addColumn<DeviceClassId>("deviceClassId");
|
||||||
|
|||||||
Reference in New Issue
Block a user