Improve the PIC to detect duplicate UUIDs, give metter messages. Clean up mock plugin.
This commit is contained in:
parent
947e6bdc71
commit
51f5538772
@ -849,18 +849,23 @@ void DeviceManagerImplementation::loadPlugins()
|
||||
|
||||
// Check plugin API version compatibility
|
||||
QLibrary lib(fi.absoluteFilePath());
|
||||
QString *version = reinterpret_cast<QString*>(lib.resolve("libnymea_api_version"));
|
||||
if (!version) {
|
||||
QFunctionPointer versionFunc = lib.resolve("libnymea_api_version");
|
||||
if (!versionFunc) {
|
||||
qCWarning(dcDeviceManager()).nospace() << "Unable to resolve version in plugin " << entry << ". Not loading plugin.";
|
||||
loader.unload();
|
||||
lib.unload();
|
||||
continue;
|
||||
|
||||
}
|
||||
QString version = reinterpret_cast<QString(*)()>(versionFunc)();
|
||||
// QString *version = reinterpret_cast<QString*>(lib.resolve("libnymea_api_version"));
|
||||
// if (!version) {
|
||||
// }
|
||||
lib.unload();
|
||||
QStringList parts = version->split('.');
|
||||
QStringList parts = version.split('.');
|
||||
QStringList coreParts = QString(LIBNYMEA_API_VERSION).split('.');
|
||||
if (parts.length() != 3 || parts.at(0).toInt() != coreParts.at(0).toInt() || parts.at(1).toInt() > coreParts.at(1).toInt()) {
|
||||
qCWarning(dcDeviceManager()).nospace() << "Libnymea API mismatch for " << entry << ". Core API: " << LIBNYMEA_API_VERSION << ", Plugin API: " << *version;
|
||||
qCWarning(dcDeviceManager()).nospace() << "Libnymea API mismatch for " << entry << ". Core API: " << LIBNYMEA_API_VERSION << ", Plugin API: " << version;
|
||||
loader.unload();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QMetaObject>
|
||||
#include <QMetaEnum>
|
||||
|
||||
@ -84,37 +85,43 @@ DeviceClasses PluginMetadata::deviceClasses() const
|
||||
|
||||
void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
{
|
||||
bool hasError = false;
|
||||
|
||||
// General plugin info
|
||||
QStringList pluginMandatoryJsonProperties = QStringList() << "id" << "name" << "displayName" << "vendors";
|
||||
QStringList pluginJsonProperties = QStringList() << "id" << "name" << "displayName" << "vendors" << "paramTypes" << "builtIn";
|
||||
QPair<QStringList, QStringList> verificationResult = verifyFields(pluginJsonProperties, pluginMandatoryJsonProperties, jsonObject);
|
||||
if (!verificationResult.first.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping plugin because of missing fields:" << verificationResult.first.join(", ") << endl << jsonObject;
|
||||
qCWarning(dcDevice()) << "Plugin has missing fields:" << verificationResult.first.join(", ") << endl << jsonObject;
|
||||
hasError = true;
|
||||
// Not gonna continue parsing as we rely on mandatory fields being available
|
||||
return;
|
||||
}
|
||||
if (!verificationResult.second.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping plugin because of unknown fields:" << verificationResult.second.join(", ") << endl << jsonObject;
|
||||
return;
|
||||
qCWarning(dcDevice()) << "Plugin has unknown fields:" << verificationResult.second.join(", ") << endl << qUtf8Printable(QJsonDocument::fromVariant(jsonObject.toVariantMap()).toJson(QJsonDocument::Indented));
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
m_pluginId = jsonObject.value("id").toString();
|
||||
m_pluginName = jsonObject.value("name").toString();
|
||||
m_pluginDisplayName = jsonObject.value("displayName").toString();
|
||||
|
||||
// Mandatory fields available... All the rest will be skipped if not valid, but it won't invalidate the entire meta data
|
||||
m_isValid = true;
|
||||
if (!verifyDuplicateUuid(m_pluginId)) {
|
||||
qCWarning(dcDevice()) << "Plugin" << m_pluginName << "has duplicate UUID:" << m_pluginId.toString();
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
// parse plugin configuration params
|
||||
if (jsonObject.contains("paramTypes")) {
|
||||
QPair<bool, QList<ParamType> > paramVerification = parseParamTypes(jsonObject.value("paramTypes").toArray());
|
||||
if (paramVerification.first) {
|
||||
m_pluginSettings = paramVerification.second;
|
||||
} else {
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Load vendors
|
||||
foreach (const QJsonValue &vendorJson, jsonObject.value("vendors").toArray()) {
|
||||
bool broken = false;
|
||||
QJsonObject vendorObject = vendorJson.toObject();
|
||||
|
||||
QStringList vendorMandatoryJsonProperties = QStringList() << "id" << "name" << "displayName" << "deviceClasses";
|
||||
@ -124,20 +131,25 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
|
||||
// Check mandatory fields
|
||||
if (!verificationResult.first.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping vendor because of missing fields:" << verificationResult.first.join(", ") << endl << vendorObject;
|
||||
broken = true;
|
||||
qCWarning(dcDevice()) << "Vendor has missing fields:" << verificationResult.first.join(", ") << endl << vendorObject;
|
||||
hasError = true;
|
||||
// Not continuing parsing vendor as we rely on mandatory fields being around.
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if there are any unknown fields
|
||||
if (!verificationResult.second.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping vendor because of unknown fields:" << verificationResult.second.join(", ") << endl << vendorObject;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << pluginName() << "Vendor has unknown fields:" << verificationResult.second.join(", ") << endl << qUtf8Printable(QJsonDocument::fromVariant(vendorObject.toVariantMap()).toJson(QJsonDocument::Indented));
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
VendorId vendorId = VendorId(vendorObject.value("id").toString());
|
||||
Vendor vendor(vendorId, vendorObject.value("name").toString());
|
||||
QString vendorName = vendorObject.value("name").toString();
|
||||
if (!verifyDuplicateUuid(vendorId)) {
|
||||
qCWarning(dcDevice()) << "Vendor" << vendorName << "has duplicate UUID:" << vendorId.toString();
|
||||
hasError = true;
|
||||
}
|
||||
Vendor vendor(vendorId, vendorName);
|
||||
vendor.setDisplayName(vendorObject.value("displayName").toString());
|
||||
m_vendors.append(vendor);
|
||||
|
||||
@ -154,20 +166,27 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
|
||||
// Check mandatory fields
|
||||
if (!verificationResult.first.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping device class because of missing fields:" << verificationResult.first.join(", ") << endl << deviceClassObject;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << "Device class has missing fields:" << verificationResult.first.join(", ") << endl << deviceClassObject;
|
||||
hasError = true;
|
||||
// Stop parsing this deviceClass as we rely on mandatory fields being around.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if there are any unknown fields
|
||||
if (!verificationResult.second.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping device class because of unknown fields:" << verificationResult.second.join(", ") << endl << deviceClassObject;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << "Device class has unknown fields:" << verificationResult.second.join(", ") << endl << qUtf8Printable(QJsonDocument::fromVariant(deviceClassObject.toVariantMap()).toJson(QJsonDocument::Indented));
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
DeviceClass deviceClass(pluginId(), vendorId, deviceClassObject.value("id").toString());
|
||||
deviceClass.setName(deviceClassObject.value("name").toString());
|
||||
DeviceClassId deviceClassId = deviceClassObject.value("id").toString();
|
||||
QString deviceClassName = deviceClassObject.value("name").toString();
|
||||
if (!verifyDuplicateUuid(deviceClassId)) {
|
||||
qCWarning(dcDevice()) << "Device class" << deviceClassName << "has duplicate UUID:" << deviceClassName;
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
DeviceClass deviceClass(pluginId(), vendorId, deviceClassId);
|
||||
deviceClass.setName(deviceClassName);
|
||||
deviceClass.setDisplayName(deviceClassObject.value("displayName").toString());
|
||||
|
||||
// Read create methods
|
||||
@ -184,9 +203,8 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
} else if (createMethodValue.toString().toLower() == "user") {
|
||||
createMethods |= DeviceClass::CreateMethodUser;
|
||||
} else {
|
||||
qCWarning(dcDevice()) << "Unknown createMehtod" << createMethodValue.toString() << "in deviceClass "
|
||||
<< deviceClass.name() << ". Falling back to CreateMethodUser.";
|
||||
createMethods |= DeviceClass::CreateMethodUser;
|
||||
qCWarning(dcDevice()) << "Unknown createMehtod" << createMethodValue.toString() << "in deviceClass " << deviceClass.name() << ".";
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,8 +213,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
// Read params
|
||||
QPair<bool, QList<ParamType> > paramTypesVerification = parseParamTypes(deviceClassObject.value("paramTypes").toArray());
|
||||
if (!paramTypesVerification.first) {
|
||||
broken = true;
|
||||
break;
|
||||
hasError = true;
|
||||
} else {
|
||||
deviceClass.setParamTypes(paramTypesVerification.second);
|
||||
}
|
||||
@ -204,8 +221,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
// Read settings
|
||||
QPair<bool, QList<ParamType> > settingsTypesVerification = parseParamTypes(deviceClassObject.value("settingsTypes").toArray());
|
||||
if (!settingsTypesVerification.first) {
|
||||
broken = true;
|
||||
break;
|
||||
hasError = true;
|
||||
} else {
|
||||
deviceClass.setSettingsTypes(settingsTypesVerification.second);
|
||||
}
|
||||
@ -213,8 +229,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
// Read discover params
|
||||
QPair<bool, QList<ParamType> > discoveryParamVerification = parseParamTypes(deviceClassObject.value("discoveryParamTypes").toArray());
|
||||
if (!discoveryParamVerification.first) {
|
||||
broken = true;
|
||||
break;
|
||||
hasError = true;
|
||||
} else {
|
||||
deviceClass.setDiscoveryParamTypes(discoveryParamVerification.second);
|
||||
}
|
||||
@ -232,9 +247,8 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
} else if (setupMethodString.toLower() == "justadd") {
|
||||
setupMethod = DeviceClass::SetupMethodJustAdd;
|
||||
} else {
|
||||
qCWarning(dcDevice()) << "Unknown setupMehtod" << setupMethod << "in deviceClass"
|
||||
<< deviceClass.name() << ". Falling back to SetupMethodJustAdd.";
|
||||
setupMethod = DeviceClass::SetupMethodJustAdd;
|
||||
qCWarning(dcDevice()) << "Unknown setupMethod" << setupMethod << "in deviceClass" << deviceClass.name() << ".";
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
deviceClass.setSetupMethod(setupMethod);
|
||||
@ -256,44 +270,48 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
|
||||
// Check mandatory fields
|
||||
if (!verificationResult.first.isEmpty()) {
|
||||
qCWarning(dcDevice()) << "Skipping device class" << deviceClass.name() << "because of missing" << verificationResult.first.join(", ") << "in stateType" << st;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << "Device class stateType" << deviceClass.name() << "has missing properties" << verificationResult.first.join(", ") << "in stateType" << st;
|
||||
hasError = true;
|
||||
// Not processing further as mandatory fields are expected to be here
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if there are any unknown fields
|
||||
if (!verificationResult.second.isEmpty()) {
|
||||
qCWarning(dcDevice()) << "Skipping device class" << deviceClass.name() << "because of unknown properties" << verificationResult.second.join(", ") << "in stateType" << st;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << "Device class stateType" << deviceClass.name() << "has unknown properties" << verificationResult.second.join(", ") << "in stateType" << st;
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
// If this is a writable stateType, there must be also the displayNameAction property
|
||||
if (st.contains("writable") && st.value("writable").toBool()) {
|
||||
writableState = true;
|
||||
if (!st.contains("displayNameAction")) {
|
||||
qCWarning(dcDevice()) << "Skipping device class" << deviceClass.name() << ". The state is writable, but does not define the displayNameAction property" << st;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << "Device class" << deviceClass.name() << " has writable state but does not define the displayNameAction property" << st;
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant::Type t = QVariant::nameToType(st.value("type").toString().toLatin1().data());
|
||||
if (t == QVariant::Invalid) {
|
||||
qCWarning(dcDevice()) << "Invalid StateType type:" << st.value("type").toString();
|
||||
broken = true;
|
||||
break;
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
StateType stateType(st.value("id").toString());
|
||||
stateType.setName(st.value("name").toString());
|
||||
StateTypeId stateTypeId = st.value("id").toString();
|
||||
QString stateTypeName = st.value("name").toString();
|
||||
if (!verifyDuplicateUuid(stateTypeId)) {
|
||||
qCWarning(dcDevice()) << "StateType" << stateTypeName << "has duplicate UUID" << stateTypeId.toString();
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
StateType stateType(stateTypeId);
|
||||
stateType.setName(stateTypeName);
|
||||
stateType.setDisplayName(st.value("displayName").toString());
|
||||
stateType.setIndex(index++);
|
||||
stateType.setType(t);
|
||||
QPair<bool, Types::Unit> unitVerification = loadAndVerifyUnit(st.value("unit").toString());
|
||||
if (!unitVerification.first) {
|
||||
broken = true;
|
||||
break;
|
||||
hasError = true;
|
||||
} else {
|
||||
stateType.setUnit(unitVerification.second);
|
||||
}
|
||||
@ -315,7 +333,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
if (!stateType.possibleValues().contains(stateType.defaultValue())) {
|
||||
qCWarning(dcDevice()) << QString("\"%1\" plugin:").arg(pluginName()).toLatin1().data() << QString("The given default value \"%1\" is not in the possible values of the stateType \"%2\".")
|
||||
.arg(stateType.defaultValue().toString()).arg(stateType.name()).toLatin1().data();
|
||||
broken = true;
|
||||
hasError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -325,7 +343,7 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
}
|
||||
stateTypes.append(stateType);
|
||||
|
||||
// Events for state changed
|
||||
// Events for state changed (Not checking for duplicate UUID, this is expected to be the same as the state!)
|
||||
EventType eventType(EventTypeId(stateType.id().toString()));
|
||||
eventType.setName(st.value("name").toString());
|
||||
eventType.setDisplayName(st.value("displayNameEvent").toString());
|
||||
@ -360,26 +378,31 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
|
||||
// Check mandatory fields
|
||||
if (!verificationResult.first.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping device class" << deviceClass.name() << "because of missing" << verificationResult.first.join(", ") << "in action type:" << endl << at;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << "Device class" << deviceClass.name() << " has missing fields" << verificationResult.first.join(", ") << "in action type:" << endl << at;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if there are any unknown fields
|
||||
if (!verificationResult.second.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping device class" << deviceClass.name() << "because of unknown fields:" << verificationResult.second.join(", ") << "in action type:" << endl << at;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << pluginName() << "Device class" << deviceClass.name() << "has unknown fields:" << verificationResult.second.join(", ") << "in action type:" << endl << at;
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
ActionType actionType(at.value("id").toString());
|
||||
actionType.setName(at.value("name").toString());
|
||||
ActionTypeId actionTypeId = ActionTypeId(at.value("id").toString());
|
||||
QString actionTypeName = at.value("name").toString();
|
||||
if (!verifyDuplicateUuid(actionTypeId)) {
|
||||
qCWarning(dcDevice()) << "Action Type" << actionTypeName << "has duplicate UUID:" << actionTypeId.toString();
|
||||
hasError = true;
|
||||
}
|
||||
ActionType actionType(actionTypeId);
|
||||
actionType.setName(actionTypeName);
|
||||
actionType.setDisplayName(at.value("displayName").toString());
|
||||
actionType.setIndex(index++);
|
||||
|
||||
QPair<bool, QList<ParamType> > paramVerification = parseParamTypes(at.value("paramTypes").toArray());
|
||||
if (!paramVerification.first) {
|
||||
broken = true;
|
||||
hasError = true;
|
||||
break;
|
||||
} else {
|
||||
actionType.setParamTypes(paramVerification.second);
|
||||
@ -398,27 +421,31 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
|
||||
// Check mandatory fields
|
||||
if (!verificationResult.first.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping device class" << deviceClass.name() << "because of missing" << verificationResult.first.join(", ") << "in event type:" << endl << et;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << "Device class" << deviceClass.name() << "has missing fields" << verificationResult.first.join(", ") << "in event type:" << endl << et;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if there are any unknown fields
|
||||
if (!verificationResult.second.isEmpty()) {
|
||||
qCWarning(dcDevice()) << pluginName() << "Skipping device class" << deviceClass.name() << "because of unknown fields:" << verificationResult.second.join(", ") << "in event type:" << endl << et;
|
||||
broken = true;
|
||||
break;
|
||||
qCWarning(dcDevice()) << "Device class" << deviceClass.name() << "has unknown fields:" << verificationResult.second.join(", ") << "in event type:" << endl << et;
|
||||
hasError = true;
|
||||
}
|
||||
|
||||
EventType eventType(et.value("id").toString());
|
||||
eventType.setName(et.value("name").toString());
|
||||
EventTypeId eventTypeId = EventTypeId(et.value("id").toString());
|
||||
QString eventTypeName = et.value("name").toString();
|
||||
if (!verifyDuplicateUuid(eventTypeId)) {
|
||||
qCWarning(dcDevice()) << "Event type" << eventTypeName << "has duplicate UUID:" << eventTypeId.toString();
|
||||
hasError = true;
|
||||
}
|
||||
EventType eventType(eventTypeId);
|
||||
eventType.setName(eventTypeName);
|
||||
eventType.setDisplayName(et.value("displayName").toString());
|
||||
eventType.setIndex(index++);
|
||||
|
||||
QPair<bool, QList<ParamType> > paramVerification = parseParamTypes(et.value("paramTypes").toArray());
|
||||
if (!paramVerification.first) {
|
||||
broken = true;
|
||||
break;
|
||||
hasError = true;
|
||||
} else {
|
||||
eventType.setParamTypes(paramVerification.second);
|
||||
}
|
||||
@ -435,29 +462,28 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
ActionTypes actionTypes(deviceClass.actionTypes());
|
||||
EventTypes eventTypes(deviceClass.eventTypes());
|
||||
|
||||
bool valid = true;
|
||||
foreach (const StateType &ifaceStateType, iface.stateTypes()) {
|
||||
StateType stateType = stateTypes.findByName(ifaceStateType.name());
|
||||
if (stateType.id().isNull()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement state" << ifaceStateType.name();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
if (ifaceStateType.type() != stateType.type()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching type" << stateType.type() << "!=" << ifaceStateType.type();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
if (ifaceStateType.minValue().isValid() && !ifaceStateType.minValue().isNull()) {
|
||||
if (ifaceStateType.minValue().toString() == "any") {
|
||||
if (stateType.minValue().isNull()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has no minimum value defined.";
|
||||
valid = false;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
} else if (ifaceStateType.minValue() != stateType.minValue()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching minimum value:" << ifaceStateType.minValue() << "!=" << stateType.minValue();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -465,18 +491,18 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
if (ifaceStateType.maxValue().toString() == "any") {
|
||||
if (stateType.maxValue().isNull()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has no maximum value defined.";
|
||||
valid = false;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
} else if (ifaceStateType.maxValue() != stateType.maxValue()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching maximum value:" << ifaceStateType.maxValue() << "!=" << stateType.minValue();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!ifaceStateType.possibleValues().isEmpty() && ifaceStateType.possibleValues() != stateType.possibleValues()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but state" << stateType.name() << "has not matching allowed values" << ifaceStateType.possibleValues() << "!=" << stateType.possibleValues();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -485,17 +511,17 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
ActionType actionType = actionTypes.findByName(ifaceActionType.name());
|
||||
if (actionType.id().isNull()) {
|
||||
qCWarning(dcDevice) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement action" << ifaceActionType.name();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
}
|
||||
foreach (const ParamType &ifaceActionParamType, ifaceActionType.paramTypes()) {
|
||||
ParamType paramType = actionType.paramTypes().findByName(ifaceActionParamType.name());
|
||||
if (!paramType.isValid()) {
|
||||
qCWarning(dcDevice) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement action param" << ifaceActionType.name() << ":" << ifaceActionParamType.name();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
} else {
|
||||
if (paramType.type() != ifaceActionParamType.type()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but param" << paramType.name() << "is of wrong type:" << QVariant::typeToName(paramType.type()) << "expected:" << QVariant::typeToName(ifaceActionParamType.type());
|
||||
valid = false;
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -505,36 +531,35 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
|
||||
EventType eventType = eventTypes.findByName(ifaceEventType.name());
|
||||
if (!eventType.isValid()) {
|
||||
qCWarning(dcDevice) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement event" << ifaceEventType.name();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
}
|
||||
foreach (const ParamType &ifaceEventParamType, ifaceEventType.paramTypes()) {
|
||||
ParamType paramType = eventType.paramTypes().findByName(ifaceEventParamType.name());
|
||||
if (!paramType.isValid()) {
|
||||
qCWarning(dcDevice) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but doesn't implement event param" << ifaceEventType.name() << ":" << ifaceEventParamType.name();
|
||||
valid = false;
|
||||
hasError = true;
|
||||
} else {
|
||||
if (paramType.type() != ifaceEventParamType.type()) {
|
||||
qCWarning(dcDevice()) << "DeviceClass" << deviceClass.name() << "claims to implement interface" << value.toString() << "but param" << paramType.name() << "is of wrong type:" << QVariant::typeToName(paramType.type()) << "expected:" << QVariant::typeToName(ifaceEventParamType.type());
|
||||
valid = false;
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
interfaces.append(DeviceUtils::generateInterfaceParentList(value.toString()));
|
||||
}
|
||||
interfaces.append(DeviceUtils::generateInterfaceParentList(value.toString()));
|
||||
}
|
||||
interfaces.removeDuplicates();
|
||||
deviceClass.setInterfaces(interfaces);
|
||||
|
||||
if (!broken) {
|
||||
m_deviceClasses.append(deviceClass);
|
||||
} else {
|
||||
qCWarning(dcDevice()) << "Skipping device class" << deviceClass.name();
|
||||
}
|
||||
m_deviceClasses.append(deviceClass);
|
||||
}
|
||||
}
|
||||
if (!hasError) {
|
||||
m_isValid = true;
|
||||
} else {
|
||||
qCWarning(dcDevice()) << "Device metadata has errors.";
|
||||
}
|
||||
}
|
||||
|
||||
QPair<bool, Types::Unit> PluginMetadata::loadAndVerifyUnit(const QString &unitString)
|
||||
@ -615,7 +640,13 @@ QPair<bool, ParamTypes> PluginMetadata::parseParamTypes(const QJsonArray &array)
|
||||
return QPair<bool, QList<ParamType> >(false, QList<ParamType>());
|
||||
}
|
||||
|
||||
ParamType paramType(ParamTypeId(pt.value("id").toString()), pt.value("name").toString(), t, pt.value("defaultValue").toVariant());
|
||||
ParamTypeId paramTypeId = ParamTypeId(pt.value("id").toString());
|
||||
QString paramName = pt.value("name").toString();
|
||||
if (!verifyDuplicateUuid(paramTypeId)) {
|
||||
qCWarning(dcDevice()) << "Param" << paramName << "has duplicate UUID:" << paramTypeId.toString();
|
||||
return QPair<bool, QList<ParamType> >(false, QList<ParamType>());
|
||||
}
|
||||
ParamType paramType(paramTypeId, paramName, t, pt.value("defaultValue").toVariant());
|
||||
paramType.setDisplayName(pt.value("displayName").toString());
|
||||
|
||||
|
||||
@ -685,3 +716,12 @@ QPair<bool, Types::InputType> PluginMetadata::loadAndVerifyInputType(const QStri
|
||||
|
||||
return QPair<bool, Types::InputType>(true, (Types::InputType)enumValue);
|
||||
}
|
||||
|
||||
bool PluginMetadata::verifyDuplicateUuid(const QUuid &uuid)
|
||||
{
|
||||
if (m_allUuids.contains(uuid)) {
|
||||
return false;
|
||||
}
|
||||
m_allUuids.append(uuid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -52,6 +52,8 @@ private:
|
||||
QPair<bool, Types::Unit> loadAndVerifyUnit(const QString &unitString);
|
||||
QPair<bool, Types::InputType> loadAndVerifyInputType(const QString &inputType);
|
||||
|
||||
bool verifyDuplicateUuid(const QUuid &uuid);
|
||||
|
||||
private:
|
||||
bool m_isValid = false;
|
||||
bool m_isBuiltIn = false;
|
||||
@ -61,6 +63,8 @@ private:
|
||||
ParamTypes m_pluginSettings;
|
||||
Vendors m_vendors;
|
||||
DeviceClasses m_deviceClasses;
|
||||
|
||||
QList<QUuid> m_allUuids;
|
||||
};
|
||||
|
||||
#endif // PLUGINMETADATA_H
|
||||
|
||||
@ -224,13 +224,13 @@ Device::DeviceError DevicePluginMock::executeAction(Device *device, const Action
|
||||
return Device::DeviceErrorDeviceNotFound;
|
||||
|
||||
if (device->deviceClassId() == mockDeviceClassId) {
|
||||
if (action.actionTypeId() == mockMockAsyncActionTypeId || action.actionTypeId() == mockMockAsyncFailingActionTypeId) {
|
||||
if (action.actionTypeId() == mockAsyncActionTypeId || action.actionTypeId() == mockAsyncFailingActionTypeId) {
|
||||
m_asyncActions.append(qMakePair<Action, Device*>(action, device));
|
||||
QTimer::singleShot(1000, this, SLOT(emitActionExecuted()));
|
||||
return Device::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() == mockMockFailingActionTypeId)
|
||||
if (action.actionTypeId() == mockFailingActionTypeId)
|
||||
return Device::DeviceErrorSetupFailed;
|
||||
|
||||
if (action.actionTypeId() == mockPowerActionTypeId) {
|
||||
@ -514,10 +514,10 @@ void DevicePluginMock::emitDeviceSetupFinished()
|
||||
void DevicePluginMock::emitActionExecuted()
|
||||
{
|
||||
QPair<Action, Device*> action = m_asyncActions.takeFirst();
|
||||
if (action.first.actionTypeId() == mockMockAsyncActionTypeId) {
|
||||
if (action.first.actionTypeId() == mockAsyncActionTypeId) {
|
||||
m_daemons.value(action.second)->actionExecuted(action.first.actionTypeId());
|
||||
emit actionExecutionFinished(action.first.id(), Device::DeviceErrorNoError);
|
||||
} else if (action.first.actionTypeId() == mockMockAsyncFailingActionTypeId) {
|
||||
} else if (action.first.actionTypeId() == mockAsyncFailingActionTypeId) {
|
||||
emit actionExecutionFinished(action.first.id(), Device::DeviceErrorSetupFailed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
"id": "753f0d32-0468-4d08-82ed-1964aab03298",
|
||||
"name": "mock",
|
||||
"displayName": "Mock Device",
|
||||
"interfaces": ["system", "light", "gateway", "battery"],
|
||||
"interfaces": ["system", "light", "battery"],
|
||||
"createMethods": ["user", "discovery"],
|
||||
"discoveryParamTypes": [
|
||||
{
|
||||
@ -135,17 +135,17 @@
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b",
|
||||
"name": "mockEvent1",
|
||||
"name": "event1",
|
||||
"displayName": "Mock Event 1"
|
||||
},
|
||||
{
|
||||
"id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf",
|
||||
"name": "mockEvent2",
|
||||
"name": "event2",
|
||||
"displayName": "Mock Event 2",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "0550e16d-60b9-4ba5-83f4-4d3cee656121",
|
||||
"name": "mockParamInt",
|
||||
"name": "intParam",
|
||||
"displayName": "mockParamInt",
|
||||
"type": "int",
|
||||
"defaultValue": 10
|
||||
@ -161,13 +161,13 @@
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "a2d3a256-a551-4712-a65b-ecd5a436a1cb",
|
||||
"name": "mockActionParam1",
|
||||
"name": "param1",
|
||||
"displayName": "mockActionParam1",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"id": "304a4899-18be-4e3b-94f4-d03be52f3233",
|
||||
"name": "mockActionParam2",
|
||||
"name": "param2",
|
||||
"displayName": "mockActionParam2",
|
||||
"type": "bool"
|
||||
}
|
||||
@ -180,17 +180,17 @@
|
||||
},
|
||||
{
|
||||
"id": "fbae06d3-7666-483e-a39e-ec50fe89054e",
|
||||
"name": "mockAsync",
|
||||
"name": "async",
|
||||
"displayName": "Mock Action 3 (async)"
|
||||
},
|
||||
{
|
||||
"id": "df3cf33d-26d5-4577-9132-9823bd33fad0",
|
||||
"name": "mockFailing",
|
||||
"name": "failing",
|
||||
"displayName": "Mock Action 4 (broken)"
|
||||
},
|
||||
{
|
||||
"id": "bfe89a1d-3497-4121-8318-e77c37537219",
|
||||
"name": "mockAsyncFailing",
|
||||
"name": "asyncFailing",
|
||||
"displayName": "Mock Action 5 (async, broken)"
|
||||
}
|
||||
]
|
||||
@ -203,13 +203,13 @@
|
||||
"createMethods": ["auto"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "d4f06047-125e-4479-9810-b54c189917f5",
|
||||
"id": "bfeb0613-dab6-408c-aa27-c362c921d0d1",
|
||||
"name": "httpport",
|
||||
"displayName": "http port",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"id": "f2977061-4dd0-4ef5-85aa-3b7134743be3",
|
||||
"id": "a5c4315f-0624-4971-87c1-4bbfbfdbd16e",
|
||||
"name": "async",
|
||||
"displayName": "async",
|
||||
"type": "bool",
|
||||
@ -217,7 +217,7 @@
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"id": "ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4",
|
||||
"id": "66179395-ef7a-4013-9fc6-2084104eea09",
|
||||
"name": "broken",
|
||||
"displayName": "broken",
|
||||
"type": "bool",
|
||||
@ -226,7 +226,7 @@
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "80baec19-54de-4948-ac46-31eabfaceb83",
|
||||
"id": "74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c",
|
||||
"name": "int",
|
||||
"displayName": "Dummy int state",
|
||||
"displayNameEvent": "Dummy int state changed",
|
||||
@ -234,7 +234,7 @@
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"id": "9dd6a97c-dfd1-43dc-acbd-367932742310",
|
||||
"id": "978b0ba5-d008-41bd-b63d-a3bd23cb6469",
|
||||
"name": "boolValue",
|
||||
"displayName": "Dummy bool state",
|
||||
"displayNameEvent": "Dummy bool state changed",
|
||||
@ -245,18 +245,18 @@
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b",
|
||||
"id": "00f81fca-26f1-4a84-aa2b-4c6a3d953ec6",
|
||||
"name": "event1",
|
||||
"displayName": "Mock Event 1"
|
||||
},
|
||||
{
|
||||
"id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf",
|
||||
"id": "6e27922d-aa9d-44d1-b9b4-9faf31b6bd97",
|
||||
"name": "event2",
|
||||
"displayName": "Mock Event 2",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "0550e16d-60b9-4ba5-83f4-4d3cee656121",
|
||||
"name": "mockParamInt",
|
||||
"id": "12ed5a15-96b4-4381-9d9c-a24875283d4f",
|
||||
"name": "intParam",
|
||||
"displayName": "mockParamInt",
|
||||
"type": "int",
|
||||
"defaultValue": 10
|
||||
@ -266,18 +266,18 @@
|
||||
],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "dea0f4e1-65e3-4981-8eaa-2701c53a9185",
|
||||
"id": "e6a22f52-1818-46a7-9d15-5ca08b0612c",
|
||||
"name": "withParams",
|
||||
"displayName": "Mock Action 1 (with params)",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "a2d3a256-a551-4712-a65b-ecd5a436a1cb",
|
||||
"id": "b8126ba6-3a54-45a3-be4d-63feb0ddb77b",
|
||||
"name": "mockActionParam1",
|
||||
"displayName": "mockActionParam1",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"id": "304a4899-18be-4e3b-94f4-d03be52f3233",
|
||||
"id": "df41ba71-e43b-4854-91d1-b19d8066d4f9",
|
||||
"name": "mockActionParam2",
|
||||
"displayName": "mockActionParam2",
|
||||
"type": "bool"
|
||||
@ -285,22 +285,22 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "defd3ed6-1a0d-400b-8879-a0202cf39935",
|
||||
"id": "ef518d53-50e2-4ca5-a4b1-e9a8b9309d44",
|
||||
"name": "mockActionNoParms",
|
||||
"displayName": "Mock Action 2 (without params)"
|
||||
},
|
||||
{
|
||||
"id": "fbae06d3-7666-483e-a39e-ec50fe89054e",
|
||||
"id": "5f27a9f2-59cd-4a15-98bd-6ed6e10bc6ed",
|
||||
"name": "mockActionAsync",
|
||||
"displayName": "Mock Action 3 (async)"
|
||||
},
|
||||
{
|
||||
"id": "df3cf33d-26d5-4577-9132-9823bd33fad0",
|
||||
"id": "58a61de4-472c-4775-8fe8-583a9c83fcf1",
|
||||
"name": "mockActionBroken",
|
||||
"displayName": "Mock Action 4 (broken)"
|
||||
},
|
||||
{
|
||||
"id": "bfe89a1d-3497-4121-8318-e77c37537219",
|
||||
"id": "17ad52dd-ef2f-4947-9b73-5bf6e172a9d0",
|
||||
"name": "mockActionAsyncBroken",
|
||||
"displayName": "Mock Action 5 (async, broken)"
|
||||
}
|
||||
@ -317,7 +317,7 @@
|
||||
"paramTypes": [ ],
|
||||
"discoveryParamTypes": [
|
||||
{
|
||||
"id": "d222adb4-2f9c-4c3f-8655-76400d0fb6ce",
|
||||
"id": "c40dbc59-4bba-4871-9b8e-bbd8d5d9193b",
|
||||
"name": "resultCount",
|
||||
"displayName": "resultCount",
|
||||
"type": "int",
|
||||
@ -406,7 +406,7 @@
|
||||
"pairingInfo": "Please enter the secret which normaly will be displayed on the device. For the mockdevice the pin is 243681.",
|
||||
"discoveryParamTypes": [
|
||||
{
|
||||
"id": "d222adb4-2f9c-4c3f-8655-76400d0fb6ce",
|
||||
"id": "35f6e4ba-28ad-4152-a58d-ec2600667bcf",
|
||||
"name": "resultCount",
|
||||
"displayName": "resultCount",
|
||||
"type": "int",
|
||||
@ -427,7 +427,7 @@
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "20dc7c22-c50e-42db-837c-2bbced939f8e",
|
||||
"id": "3e161294-8a0d-4384-9676-6959e08cc2fa",
|
||||
"name": "color",
|
||||
"displayName": "color",
|
||||
"displayNameEvent": "color changed",
|
||||
@ -437,7 +437,7 @@
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"id": "72981c04-267a-4ba0-a59e-9921d2f3af9c",
|
||||
"id": "527f0687-0b28-4c26-852c-25b8f83e4797",
|
||||
"name": "percentage",
|
||||
"displayName": "percentage",
|
||||
"displayNameEvent": "percentage changed",
|
||||
@ -450,7 +450,7 @@
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"id": "05f63f9c-f61e-4dcf-ad55-3f13fde2765b",
|
||||
"id": "b463c5ae-4d55-402f-8480-a5cdb485c143",
|
||||
"name": "allowedValues",
|
||||
"displayName": "allowed values",
|
||||
"displayNameEvent": "allowed values changed",
|
||||
@ -466,7 +466,7 @@
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"id": "53cd7c55-49b7-441b-b970-9048f20f0e2c",
|
||||
"id": "17635624-7c19-4bae-8429-2f7aa5d2f843",
|
||||
"name": "double",
|
||||
"displayName": "double value",
|
||||
"displayNameEvent": "double value changed",
|
||||
@ -478,7 +478,7 @@
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"id": "e680f7a4-b39e-46da-be41-fa3170fe3768",
|
||||
"id": "7ffe514f-7999-4998-8350-0e73e222a8c4",
|
||||
"name": "bool",
|
||||
"displayName": "bool value",
|
||||
"displayNameEvent": "bool value changed",
|
||||
@ -490,7 +490,7 @@
|
||||
],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "54646e7c-bc54-4895-81a2-590d72d120f9",
|
||||
"id": "854a0a4a-803f-4b7f-9dce-b07794f9011b",
|
||||
"name": "timeout",
|
||||
"displayName": "Timeout action"
|
||||
}
|
||||
@ -524,7 +524,7 @@
|
||||
"paramTypes": [],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "d24ede5f-4064-4898-bb84-cfb533b1fbc0",
|
||||
"id": "80ba1449-b485-47d4-a067-6bf306e2a568",
|
||||
"name": "boolValue",
|
||||
"displayName": "bool value",
|
||||
"displayNameEvent": "bool value changed",
|
||||
|
||||
@ -38,18 +38,18 @@ extern EventTypeId mockBatteryCriticalEventTypeId;
|
||||
extern ParamTypeId mockBatteryCriticalEventBatteryCriticalParamTypeId;
|
||||
extern EventTypeId mockPowerEventTypeId;
|
||||
extern ParamTypeId mockPowerEventPowerParamTypeId;
|
||||
extern EventTypeId mockMockEvent1EventTypeId;
|
||||
extern EventTypeId mockMockEvent2EventTypeId;
|
||||
extern ParamTypeId mockMockEvent2EventMockParamIntParamTypeId;
|
||||
extern EventTypeId mockEvent1EventTypeId;
|
||||
extern EventTypeId mockEvent2EventTypeId;
|
||||
extern ParamTypeId mockEvent2EventIntParamParamTypeId;
|
||||
extern ActionTypeId mockPowerActionTypeId;
|
||||
extern ParamTypeId mockPowerActionPowerParamTypeId;
|
||||
extern ActionTypeId mockWithParamsActionTypeId;
|
||||
extern ParamTypeId mockWithParamsActionMockActionParam1ParamTypeId;
|
||||
extern ParamTypeId mockWithParamsActionMockActionParam2ParamTypeId;
|
||||
extern ParamTypeId mockWithParamsActionParam1ParamTypeId;
|
||||
extern ParamTypeId mockWithParamsActionParam2ParamTypeId;
|
||||
extern ActionTypeId mockWithoutParamsActionTypeId;
|
||||
extern ActionTypeId mockMockAsyncActionTypeId;
|
||||
extern ActionTypeId mockMockFailingActionTypeId;
|
||||
extern ActionTypeId mockMockAsyncFailingActionTypeId;
|
||||
extern ActionTypeId mockAsyncActionTypeId;
|
||||
extern ActionTypeId mockFailingActionTypeId;
|
||||
extern ActionTypeId mockAsyncFailingActionTypeId;
|
||||
extern DeviceClassId mockDeviceAutoDeviceClassId;
|
||||
extern ParamTypeId mockDeviceAutoDeviceHttpportParamTypeId;
|
||||
extern ParamTypeId mockDeviceAutoDeviceAsyncParamTypeId;
|
||||
@ -62,7 +62,7 @@ extern EventTypeId mockDeviceAutoBoolValueEventTypeId;
|
||||
extern ParamTypeId mockDeviceAutoBoolValueEventBoolValueParamTypeId;
|
||||
extern EventTypeId mockDeviceAutoEvent1EventTypeId;
|
||||
extern EventTypeId mockDeviceAutoEvent2EventTypeId;
|
||||
extern ParamTypeId mockDeviceAutoEvent2EventMockParamIntParamTypeId;
|
||||
extern ParamTypeId mockDeviceAutoEvent2EventIntParamParamTypeId;
|
||||
extern ActionTypeId mockDeviceAutoWithParamsActionTypeId;
|
||||
extern ParamTypeId mockDeviceAutoWithParamsActionMockActionParam1ParamTypeId;
|
||||
extern ParamTypeId mockDeviceAutoWithParamsActionMockActionParam2ParamTypeId;
|
||||
|
||||
@ -39,7 +39,10 @@
|
||||
HttpDaemon::HttpDaemon(Device *device, DevicePlugin *parent):
|
||||
QTcpServer(parent), disabled(false), m_plugin(parent), m_device(device)
|
||||
{
|
||||
listen(QHostAddress::Any, device->paramValue(mockDeviceHttpportParamTypeId).toInt());
|
||||
QHash<DeviceClassId, ParamTypeId> portMap;
|
||||
portMap.insert(mockDeviceClassId, mockDeviceHttpportParamTypeId);
|
||||
portMap.insert(mockDeviceAutoDeviceClassId, mockDeviceAutoDeviceHttpportParamTypeId);
|
||||
listen(QHostAddress::Any, device->paramValue(portMap.value(device->deviceClassId())).toInt());
|
||||
}
|
||||
|
||||
HttpDaemon::~HttpDaemon()
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#include <QLoggingCategory>
|
||||
#include <QObject>
|
||||
|
||||
extern "C" const QString libnymea_api_version = QString("2.1.0");
|
||||
extern "C" const QString libnymea_api_version() { return QString("2.1.0");}
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcMockDevice)
|
||||
Q_LOGGING_CATEGORY(dcMockDevice, "MockDevice")
|
||||
@ -42,40 +42,40 @@ EventTypeId mockBatteryCriticalEventTypeId = EventTypeId("{580bc611-1a55-41f3-99
|
||||
ParamTypeId mockBatteryCriticalEventBatteryCriticalParamTypeId = ParamTypeId("{580bc611-1a55-41f3-996f-8d3ccf543db3}");
|
||||
EventTypeId mockPowerEventTypeId = EventTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
|
||||
ParamTypeId mockPowerEventPowerParamTypeId = ParamTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
|
||||
EventTypeId mockMockEvent1EventTypeId = EventTypeId("{45bf3752-0fc6-46b9-89fd-ffd878b5b22b}");
|
||||
EventTypeId mockMockEvent2EventTypeId = EventTypeId("{863d5920-b1cf-4eb9-88bd-8f7b8583b1cf}");
|
||||
ParamTypeId mockMockEvent2EventMockParamIntParamTypeId = ParamTypeId("{0550e16d-60b9-4ba5-83f4-4d3cee656121}");
|
||||
EventTypeId mockEvent1EventTypeId = EventTypeId("{45bf3752-0fc6-46b9-89fd-ffd878b5b22b}");
|
||||
EventTypeId mockEvent2EventTypeId = EventTypeId("{863d5920-b1cf-4eb9-88bd-8f7b8583b1cf}");
|
||||
ParamTypeId mockEvent2EventIntParamParamTypeId = ParamTypeId("{0550e16d-60b9-4ba5-83f4-4d3cee656121}");
|
||||
ActionTypeId mockPowerActionTypeId = ActionTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
|
||||
ParamTypeId mockPowerActionPowerParamTypeId = ParamTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}");
|
||||
ActionTypeId mockWithParamsActionTypeId = ActionTypeId("{dea0f4e1-65e3-4981-8eaa-2701c53a9185}");
|
||||
ParamTypeId mockWithParamsActionMockActionParam1ParamTypeId = ParamTypeId("{a2d3a256-a551-4712-a65b-ecd5a436a1cb}");
|
||||
ParamTypeId mockWithParamsActionMockActionParam2ParamTypeId = ParamTypeId("{304a4899-18be-4e3b-94f4-d03be52f3233}");
|
||||
ParamTypeId mockWithParamsActionParam1ParamTypeId = ParamTypeId("{a2d3a256-a551-4712-a65b-ecd5a436a1cb}");
|
||||
ParamTypeId mockWithParamsActionParam2ParamTypeId = ParamTypeId("{304a4899-18be-4e3b-94f4-d03be52f3233}");
|
||||
ActionTypeId mockWithoutParamsActionTypeId = ActionTypeId("{defd3ed6-1a0d-400b-8879-a0202cf39935}");
|
||||
ActionTypeId mockMockAsyncActionTypeId = ActionTypeId("{fbae06d3-7666-483e-a39e-ec50fe89054e}");
|
||||
ActionTypeId mockMockFailingActionTypeId = ActionTypeId("{df3cf33d-26d5-4577-9132-9823bd33fad0}");
|
||||
ActionTypeId mockMockAsyncFailingActionTypeId = ActionTypeId("{bfe89a1d-3497-4121-8318-e77c37537219}");
|
||||
ActionTypeId mockAsyncActionTypeId = ActionTypeId("{fbae06d3-7666-483e-a39e-ec50fe89054e}");
|
||||
ActionTypeId mockFailingActionTypeId = ActionTypeId("{df3cf33d-26d5-4577-9132-9823bd33fad0}");
|
||||
ActionTypeId mockAsyncFailingActionTypeId = ActionTypeId("{bfe89a1d-3497-4121-8318-e77c37537219}");
|
||||
DeviceClassId mockDeviceAutoDeviceClassId = DeviceClassId("{ab4257b3-7548-47ee-9bd4-7dc3004fd197}");
|
||||
ParamTypeId mockDeviceAutoDeviceHttpportParamTypeId = ParamTypeId("{d4f06047-125e-4479-9810-b54c189917f5}");
|
||||
ParamTypeId mockDeviceAutoDeviceAsyncParamTypeId = ParamTypeId("{f2977061-4dd0-4ef5-85aa-3b7134743be3}");
|
||||
ParamTypeId mockDeviceAutoDeviceBrokenParamTypeId = ParamTypeId("{ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4}");
|
||||
StateTypeId mockDeviceAutoIntStateTypeId = StateTypeId("{80baec19-54de-4948-ac46-31eabfaceb83}");
|
||||
StateTypeId mockDeviceAutoBoolValueStateTypeId = StateTypeId("{9dd6a97c-dfd1-43dc-acbd-367932742310}");
|
||||
EventTypeId mockDeviceAutoIntEventTypeId = EventTypeId("{80baec19-54de-4948-ac46-31eabfaceb83}");
|
||||
ParamTypeId mockDeviceAutoIntEventIntParamTypeId = ParamTypeId("{80baec19-54de-4948-ac46-31eabfaceb83}");
|
||||
EventTypeId mockDeviceAutoBoolValueEventTypeId = EventTypeId("{9dd6a97c-dfd1-43dc-acbd-367932742310}");
|
||||
ParamTypeId mockDeviceAutoBoolValueEventBoolValueParamTypeId = ParamTypeId("{9dd6a97c-dfd1-43dc-acbd-367932742310}");
|
||||
EventTypeId mockDeviceAutoEvent1EventTypeId = EventTypeId("{45bf3752-0fc6-46b9-89fd-ffd878b5b22b}");
|
||||
EventTypeId mockDeviceAutoEvent2EventTypeId = EventTypeId("{863d5920-b1cf-4eb9-88bd-8f7b8583b1cf}");
|
||||
ParamTypeId mockDeviceAutoEvent2EventMockParamIntParamTypeId = ParamTypeId("{0550e16d-60b9-4ba5-83f4-4d3cee656121}");
|
||||
ActionTypeId mockDeviceAutoWithParamsActionTypeId = ActionTypeId("{dea0f4e1-65e3-4981-8eaa-2701c53a9185}");
|
||||
ParamTypeId mockDeviceAutoWithParamsActionMockActionParam1ParamTypeId = ParamTypeId("{a2d3a256-a551-4712-a65b-ecd5a436a1cb}");
|
||||
ParamTypeId mockDeviceAutoWithParamsActionMockActionParam2ParamTypeId = ParamTypeId("{304a4899-18be-4e3b-94f4-d03be52f3233}");
|
||||
ActionTypeId mockDeviceAutoMockActionNoParmsActionTypeId = ActionTypeId("{defd3ed6-1a0d-400b-8879-a0202cf39935}");
|
||||
ActionTypeId mockDeviceAutoMockActionAsyncActionTypeId = ActionTypeId("{fbae06d3-7666-483e-a39e-ec50fe89054e}");
|
||||
ActionTypeId mockDeviceAutoMockActionBrokenActionTypeId = ActionTypeId("{df3cf33d-26d5-4577-9132-9823bd33fad0}");
|
||||
ActionTypeId mockDeviceAutoMockActionAsyncBrokenActionTypeId = ActionTypeId("{bfe89a1d-3497-4121-8318-e77c37537219}");
|
||||
ParamTypeId mockDeviceAutoDeviceHttpportParamTypeId = ParamTypeId("{bfeb0613-dab6-408c-aa27-c362c921d0d1}");
|
||||
ParamTypeId mockDeviceAutoDeviceAsyncParamTypeId = ParamTypeId("{a5c4315f-0624-4971-87c1-4bbfbfdbd16e}");
|
||||
ParamTypeId mockDeviceAutoDeviceBrokenParamTypeId = ParamTypeId("{66179395-ef7a-4013-9fc6-2084104eea09}");
|
||||
StateTypeId mockDeviceAutoIntStateTypeId = StateTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}");
|
||||
StateTypeId mockDeviceAutoBoolValueStateTypeId = StateTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}");
|
||||
EventTypeId mockDeviceAutoIntEventTypeId = EventTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}");
|
||||
ParamTypeId mockDeviceAutoIntEventIntParamTypeId = ParamTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}");
|
||||
EventTypeId mockDeviceAutoBoolValueEventTypeId = EventTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}");
|
||||
ParamTypeId mockDeviceAutoBoolValueEventBoolValueParamTypeId = ParamTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}");
|
||||
EventTypeId mockDeviceAutoEvent1EventTypeId = EventTypeId("{00f81fca-26f1-4a84-aa2b-4c6a3d953ec6}");
|
||||
EventTypeId mockDeviceAutoEvent2EventTypeId = EventTypeId("{6e27922d-aa9d-44d1-b9b4-9faf31b6bd97}");
|
||||
ParamTypeId mockDeviceAutoEvent2EventIntParamParamTypeId = ParamTypeId("{12ed5a15-96b4-4381-9d9c-a24875283d4f}");
|
||||
ActionTypeId mockDeviceAutoWithParamsActionTypeId = ActionTypeId("{00000000-0000-0000-0000-000000000000}");
|
||||
ParamTypeId mockDeviceAutoWithParamsActionMockActionParam1ParamTypeId = ParamTypeId("{b8126ba6-3a54-45a3-be4d-63feb0ddb77b}");
|
||||
ParamTypeId mockDeviceAutoWithParamsActionMockActionParam2ParamTypeId = ParamTypeId("{df41ba71-e43b-4854-91d1-b19d8066d4f9}");
|
||||
ActionTypeId mockDeviceAutoMockActionNoParmsActionTypeId = ActionTypeId("{ef518d53-50e2-4ca5-a4b1-e9a8b9309d44}");
|
||||
ActionTypeId mockDeviceAutoMockActionAsyncActionTypeId = ActionTypeId("{5f27a9f2-59cd-4a15-98bd-6ed6e10bc6ed}");
|
||||
ActionTypeId mockDeviceAutoMockActionBrokenActionTypeId = ActionTypeId("{58a61de4-472c-4775-8fe8-583a9c83fcf1}");
|
||||
ActionTypeId mockDeviceAutoMockActionAsyncBrokenActionTypeId = ActionTypeId("{17ad52dd-ef2f-4947-9b73-5bf6e172a9d0}");
|
||||
DeviceClassId mockPushButtonDeviceClassId = DeviceClassId("{9e03144c-e436-4eea-82d9-ccb33ef778db}");
|
||||
ParamTypeId mockPushButtonDiscoveryResultCountParamTypeId = ParamTypeId("{d222adb4-2f9c-4c3f-8655-76400d0fb6ce}");
|
||||
ParamTypeId mockPushButtonDiscoveryResultCountParamTypeId = ParamTypeId("{c40dbc59-4bba-4871-9b8e-bbd8d5d9193b}");
|
||||
StateTypeId mockPushButtonColorStateTypeId = StateTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
|
||||
StateTypeId mockPushButtonPercentageStateTypeId = StateTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
|
||||
StateTypeId mockPushButtonAllowedValuesStateTypeId = StateTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
|
||||
@ -104,33 +104,33 @@ ParamTypeId mockPushButtonBoolActionBoolParamTypeId = ParamTypeId("{e680f7a4-b39
|
||||
ActionTypeId mockPushButtonTimeoutActionTypeId = ActionTypeId("{54646e7c-bc54-4895-81a2-590d72d120f9}");
|
||||
DeviceClassId mockDisplayPinDeviceClassId = DeviceClassId("{296f1fd4-e893-46b2-8a42-50d1bceb8730}");
|
||||
ParamTypeId mockDisplayPinDevicePinParamTypeId = ParamTypeId("{da820e07-22dc-4173-9c07-2f49a4e265f9}");
|
||||
ParamTypeId mockDisplayPinDiscoveryResultCountParamTypeId = ParamTypeId("{d222adb4-2f9c-4c3f-8655-76400d0fb6ce}");
|
||||
StateTypeId mockDisplayPinColorStateTypeId = StateTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
|
||||
StateTypeId mockDisplayPinPercentageStateTypeId = StateTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
|
||||
StateTypeId mockDisplayPinAllowedValuesStateTypeId = StateTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
|
||||
StateTypeId mockDisplayPinDoubleStateTypeId = StateTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
|
||||
StateTypeId mockDisplayPinBoolStateTypeId = StateTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
|
||||
EventTypeId mockDisplayPinColorEventTypeId = EventTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
|
||||
ParamTypeId mockDisplayPinColorEventColorParamTypeId = ParamTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
|
||||
EventTypeId mockDisplayPinPercentageEventTypeId = EventTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
|
||||
ParamTypeId mockDisplayPinPercentageEventPercentageParamTypeId = ParamTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
|
||||
EventTypeId mockDisplayPinAllowedValuesEventTypeId = EventTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
|
||||
ParamTypeId mockDisplayPinAllowedValuesEventAllowedValuesParamTypeId = ParamTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
|
||||
EventTypeId mockDisplayPinDoubleEventTypeId = EventTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
|
||||
ParamTypeId mockDisplayPinDoubleEventDoubleParamTypeId = ParamTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
|
||||
EventTypeId mockDisplayPinBoolEventTypeId = EventTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
|
||||
ParamTypeId mockDisplayPinBoolEventBoolParamTypeId = ParamTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
|
||||
ActionTypeId mockDisplayPinColorActionTypeId = ActionTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
|
||||
ParamTypeId mockDisplayPinColorActionColorParamTypeId = ParamTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}");
|
||||
ActionTypeId mockDisplayPinPercentageActionTypeId = ActionTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
|
||||
ParamTypeId mockDisplayPinPercentageActionPercentageParamTypeId = ParamTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}");
|
||||
ActionTypeId mockDisplayPinAllowedValuesActionTypeId = ActionTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
|
||||
ParamTypeId mockDisplayPinAllowedValuesActionAllowedValuesParamTypeId = ParamTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}");
|
||||
ActionTypeId mockDisplayPinDoubleActionTypeId = ActionTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
|
||||
ParamTypeId mockDisplayPinDoubleActionDoubleParamTypeId = ParamTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}");
|
||||
ActionTypeId mockDisplayPinBoolActionTypeId = ActionTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
|
||||
ParamTypeId mockDisplayPinBoolActionBoolParamTypeId = ParamTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}");
|
||||
ActionTypeId mockDisplayPinTimeoutActionTypeId = ActionTypeId("{54646e7c-bc54-4895-81a2-590d72d120f9}");
|
||||
ParamTypeId mockDisplayPinDiscoveryResultCountParamTypeId = ParamTypeId("{35f6e4ba-28ad-4152-a58d-ec2600667bcf}");
|
||||
StateTypeId mockDisplayPinColorStateTypeId = StateTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
|
||||
StateTypeId mockDisplayPinPercentageStateTypeId = StateTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
|
||||
StateTypeId mockDisplayPinAllowedValuesStateTypeId = StateTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
|
||||
StateTypeId mockDisplayPinDoubleStateTypeId = StateTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
|
||||
StateTypeId mockDisplayPinBoolStateTypeId = StateTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
|
||||
EventTypeId mockDisplayPinColorEventTypeId = EventTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
|
||||
ParamTypeId mockDisplayPinColorEventColorParamTypeId = ParamTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
|
||||
EventTypeId mockDisplayPinPercentageEventTypeId = EventTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
|
||||
ParamTypeId mockDisplayPinPercentageEventPercentageParamTypeId = ParamTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
|
||||
EventTypeId mockDisplayPinAllowedValuesEventTypeId = EventTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
|
||||
ParamTypeId mockDisplayPinAllowedValuesEventAllowedValuesParamTypeId = ParamTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
|
||||
EventTypeId mockDisplayPinDoubleEventTypeId = EventTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
|
||||
ParamTypeId mockDisplayPinDoubleEventDoubleParamTypeId = ParamTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
|
||||
EventTypeId mockDisplayPinBoolEventTypeId = EventTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
|
||||
ParamTypeId mockDisplayPinBoolEventBoolParamTypeId = ParamTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
|
||||
ActionTypeId mockDisplayPinColorActionTypeId = ActionTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
|
||||
ParamTypeId mockDisplayPinColorActionColorParamTypeId = ParamTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}");
|
||||
ActionTypeId mockDisplayPinPercentageActionTypeId = ActionTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
|
||||
ParamTypeId mockDisplayPinPercentageActionPercentageParamTypeId = ParamTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}");
|
||||
ActionTypeId mockDisplayPinAllowedValuesActionTypeId = ActionTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
|
||||
ParamTypeId mockDisplayPinAllowedValuesActionAllowedValuesParamTypeId = ParamTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}");
|
||||
ActionTypeId mockDisplayPinDoubleActionTypeId = ActionTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
|
||||
ParamTypeId mockDisplayPinDoubleActionDoubleParamTypeId = ParamTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}");
|
||||
ActionTypeId mockDisplayPinBoolActionTypeId = ActionTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
|
||||
ParamTypeId mockDisplayPinBoolActionBoolParamTypeId = ParamTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}");
|
||||
ActionTypeId mockDisplayPinTimeoutActionTypeId = ActionTypeId("{854a0a4a-803f-4b7f-9dce-b07794f9011b}");
|
||||
DeviceClassId mockParentDeviceClassId = DeviceClassId("{a71fbde9-9a38-4bf8-beab-c8aade2608ba}");
|
||||
StateTypeId mockParentBoolValueStateTypeId = StateTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
EventTypeId mockParentBoolValueEventTypeId = EventTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
@ -138,11 +138,11 @@ ParamTypeId mockParentBoolValueEventBoolValueParamTypeId = ParamTypeId("{d24ede5
|
||||
ActionTypeId mockParentBoolValueActionTypeId = ActionTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
ParamTypeId mockParentBoolValueActionBoolValueParamTypeId = ParamTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
DeviceClassId mockChildDeviceClassId = DeviceClassId("{40893c9f-bc47-40c1-8bf7-b390c7c1b4fc}");
|
||||
StateTypeId mockChildBoolValueStateTypeId = StateTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
EventTypeId mockChildBoolValueEventTypeId = EventTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
ParamTypeId mockChildBoolValueEventBoolValueParamTypeId = ParamTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
ActionTypeId mockChildBoolValueActionTypeId = ActionTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
ParamTypeId mockChildBoolValueActionBoolValueParamTypeId = ParamTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}");
|
||||
StateTypeId mockChildBoolValueStateTypeId = StateTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
|
||||
EventTypeId mockChildBoolValueEventTypeId = EventTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
|
||||
ParamTypeId mockChildBoolValueEventBoolValueParamTypeId = ParamTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
|
||||
ActionTypeId mockChildBoolValueActionTypeId = ActionTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
|
||||
ParamTypeId mockChildBoolValueActionBoolValueParamTypeId = ParamTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}");
|
||||
DeviceClassId mockInputTypeDeviceClassId = DeviceClassId("{515ffdf1-55e5-498d-9abc-4e2fe768f3a9}");
|
||||
ParamTypeId mockInputTypeDeviceTextLineParamTypeId = ParamTypeId("{e6acf0c7-4b8e-4296-ac62-855d20deb816}");
|
||||
ParamTypeId mockInputTypeDeviceTextAreaParamTypeId = ParamTypeId("{716f0994-bc01-42b0-b64d-59236f7320d2}");
|
||||
@ -274,10 +274,10 @@ const QString translations[] {
|
||||
//: The name of the EventType ({f7d2063d-959e-46ac-8568-8b99722d3b22}) of DeviceClass mockInputType
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Double changed"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: boolValue, ID: {9dd6a97c-dfd1-43dc-acbd-367932742310})
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: boolValue, ID: {978b0ba5-d008-41bd-b63d-a3bd23cb6469})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state"),
|
||||
|
||||
//: The name of the StateType ({9dd6a97c-dfd1-43dc-acbd-367932742310}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the StateType ({978b0ba5-d008-41bd-b63d-a3bd23cb6469}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, EventType: bool, ID: {9dd6a97c-dfd1-43dc-acbd-367932742310})
|
||||
@ -286,7 +286,7 @@ const QString translations[] {
|
||||
//: The name of the StateType ({9dd6a97c-dfd1-43dc-acbd-367932742310}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state"),
|
||||
|
||||
//: The name of the EventType ({9dd6a97c-dfd1-43dc-acbd-367932742310}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the EventType ({978b0ba5-d008-41bd-b63d-a3bd23cb6469}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy bool state changed"),
|
||||
|
||||
//: The name of the EventType ({9dd6a97c-dfd1-43dc-acbd-367932742310}) of DeviceClass mock
|
||||
@ -301,10 +301,10 @@ const QString translations[] {
|
||||
//: The name of the EventType ({7cac53ee-7048-4dc9-b000-7b585390f34c}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy double state changed"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: int, ID: {80baec19-54de-4948-ac46-31eabfaceb83})
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: int, ID: {74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state"),
|
||||
|
||||
//: The name of the StateType ({80baec19-54de-4948-ac46-31eabfaceb83}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the StateType ({74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, EventType: int, ID: {80baec19-54de-4948-ac46-31eabfaceb83})
|
||||
@ -313,7 +313,7 @@ const QString translations[] {
|
||||
//: The name of the StateType ({80baec19-54de-4948-ac46-31eabfaceb83}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state"),
|
||||
|
||||
//: The name of the EventType ({80baec19-54de-4948-ac46-31eabfaceb83}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the EventType ({74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Dummy int state changed"),
|
||||
|
||||
//: The name of the EventType ({80baec19-54de-4948-ac46-31eabfaceb83}) of DeviceClass mock
|
||||
@ -340,31 +340,31 @@ const QString translations[] {
|
||||
//: The name of the ParamType (DeviceClass: mockInputType, Type: device, ID: {a8494faf-3a0f-4cf3-84b7-4b39148a838d})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mail address"),
|
||||
|
||||
//: The name of the ActionType ({dea0f4e1-65e3-4981-8eaa-2701c53a9185}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the ActionType ({00000000-0000-0000-0000-000000000000}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 1 (with params)"),
|
||||
|
||||
//: The name of the ActionType ({dea0f4e1-65e3-4981-8eaa-2701c53a9185}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 1 (with params)"),
|
||||
|
||||
//: The name of the ActionType ({defd3ed6-1a0d-400b-8879-a0202cf39935}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the ActionType ({ef518d53-50e2-4ca5-a4b1-e9a8b9309d44}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 2 (without params)"),
|
||||
|
||||
//: The name of the ActionType ({defd3ed6-1a0d-400b-8879-a0202cf39935}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 2 (without params)"),
|
||||
|
||||
//: The name of the ActionType ({fbae06d3-7666-483e-a39e-ec50fe89054e}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the ActionType ({5f27a9f2-59cd-4a15-98bd-6ed6e10bc6ed}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 3 (async)"),
|
||||
|
||||
//: The name of the ActionType ({fbae06d3-7666-483e-a39e-ec50fe89054e}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 3 (async)"),
|
||||
|
||||
//: The name of the ActionType ({df3cf33d-26d5-4577-9132-9823bd33fad0}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the ActionType ({58a61de4-472c-4775-8fe8-583a9c83fcf1}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 4 (broken)"),
|
||||
|
||||
//: The name of the ActionType ({df3cf33d-26d5-4577-9132-9823bd33fad0}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 4 (broken)"),
|
||||
|
||||
//: The name of the ActionType ({bfe89a1d-3497-4121-8318-e77c37537219}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the ActionType ({17ad52dd-ef2f-4947-9b73-5bf6e172a9d0}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Action 5 (async, broken)"),
|
||||
|
||||
//: The name of the ActionType ({bfe89a1d-3497-4121-8318-e77c37537219}) of DeviceClass mock
|
||||
@ -394,13 +394,13 @@ const QString translations[] {
|
||||
//: The name of the plugin mockDevice ({727a4a9a-c187-446f-aadf-f1b2220607d1})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Devices"),
|
||||
|
||||
//: The name of the EventType ({45bf3752-0fc6-46b9-89fd-ffd878b5b22b}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the EventType ({00f81fca-26f1-4a84-aa2b-4c6a3d953ec6}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Event 1"),
|
||||
|
||||
//: The name of the EventType ({45bf3752-0fc6-46b9-89fd-ffd878b5b22b}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Event 1"),
|
||||
|
||||
//: The name of the EventType ({863d5920-b1cf-4eb9-88bd-8f7b8583b1cf}) of DeviceClass mockDeviceAuto
|
||||
//: The name of the EventType ({6e27922d-aa9d-44d1-b9b4-9faf31b6bd97}) of DeviceClass mockDeviceAuto
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Mock Event 2"),
|
||||
|
||||
//: The name of the EventType ({863d5920-b1cf-4eb9-88bd-8f7b8583b1cf}) of DeviceClass mock
|
||||
@ -454,37 +454,37 @@ const QString translations[] {
|
||||
//: The name of the ActionType ({79238998-eaab-4d71-b406-5d78f1749751}) of DeviceClass mockInputType
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set Writable UInt (min/max)"),
|
||||
|
||||
//: The name of the ActionType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockDisplayPin
|
||||
//: The name of the ActionType ({b463c5ae-4d55-402f-8480-a5cdb485c143}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set allowed values"),
|
||||
|
||||
//: The name of the ActionType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set allowed values"),
|
||||
|
||||
//: The name of the ActionType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockChild
|
||||
//: The name of the ActionType ({80ba1449-b485-47d4-a067-6bf306e2a568}) of DeviceClass mockChild
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set bool value"),
|
||||
|
||||
//: The name of the ActionType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockParent
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set bool value"),
|
||||
|
||||
//: The name of the ActionType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockDisplayPin
|
||||
//: The name of the ActionType ({7ffe514f-7999-4998-8350-0e73e222a8c4}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set bool value"),
|
||||
|
||||
//: The name of the ActionType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set bool value"),
|
||||
|
||||
//: The name of the ActionType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockDisplayPin
|
||||
//: The name of the ActionType ({3e161294-8a0d-4384-9676-6959e08cc2fa}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set color"),
|
||||
|
||||
//: The name of the ActionType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set color"),
|
||||
|
||||
//: The name of the ActionType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockDisplayPin
|
||||
//: The name of the ActionType ({17635624-7c19-4bae-8429-2f7aa5d2f843}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set double value"),
|
||||
|
||||
//: The name of the ActionType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set double value"),
|
||||
|
||||
//: The name of the ActionType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockDisplayPin
|
||||
//: The name of the ActionType ({527f0687-0b28-4c26-852c-25b8f83e4797}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Set percentage"),
|
||||
|
||||
//: The name of the ActionType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockPushButton
|
||||
@ -517,7 +517,7 @@ const QString translations[] {
|
||||
//: The name of the EventType ({8250c71e-59bc-41ab-b576-99fcfc34e8d1}) of DeviceClass mockInputType
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Time changed"),
|
||||
|
||||
//: The name of the ActionType ({54646e7c-bc54-4895-81a2-590d72d120f9}) of DeviceClass mockDisplayPin
|
||||
//: The name of the ActionType ({854a0a4a-803f-4b7f-9dce-b07794f9011b}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Timeout action"),
|
||||
|
||||
//: The name of the ActionType ({54646e7c-bc54-4895-81a2-590d72d120f9}) of DeviceClass mockPushButton
|
||||
@ -712,13 +712,13 @@ const QString translations[] {
|
||||
//: The name of the EventType ({563e9c4c-5198-400a-9f6c-358f4752af58}) of DeviceClass mockInputType
|
||||
QT_TRANSLATE_NOOP("mockDevice", "Writable UInt changed"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: allowedValues, ID: {05f63f9c-f61e-4dcf-ad55-3f13fde2765b})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: allowedValues, ID: {b463c5ae-4d55-402f-8480-a5cdb485c143})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: allowedValues, ID: {05f63f9c-f61e-4dcf-ad55-3f13fde2765b})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: allowedValues, ID: {b463c5ae-4d55-402f-8480-a5cdb485c143})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
|
||||
|
||||
//: The name of the StateType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockDisplayPin
|
||||
//: The name of the StateType ({b463c5ae-4d55-402f-8480-a5cdb485c143}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: allowedValues, ID: {05f63f9c-f61e-4dcf-ad55-3f13fde2765b})
|
||||
@ -730,13 +730,13 @@ const QString translations[] {
|
||||
//: The name of the StateType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "allowed values"),
|
||||
|
||||
//: The name of the EventType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockDisplayPin
|
||||
//: The name of the EventType ({b463c5ae-4d55-402f-8480-a5cdb485c143}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "allowed values changed"),
|
||||
|
||||
//: The name of the EventType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "allowed values changed"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {f2977061-4dd0-4ef5-85aa-3b7134743be3})
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {a5c4315f-0624-4971-87c1-4bbfbfdbd16e})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "async"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, Type: device, ID: {f2977061-4dd0-4ef5-85aa-3b7134743be3})
|
||||
@ -760,13 +760,13 @@ const QString translations[] {
|
||||
//: The name of the StateType ({580bc611-1a55-41f3-996f-8d3ccf543db3}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "battery level critical"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockChild, ActionType: boolValue, ID: {d24ede5f-4064-4898-bb84-cfb533b1fbc0})
|
||||
//: The name of the ParamType (DeviceClass: mockChild, ActionType: boolValue, ID: {80ba1449-b485-47d4-a067-6bf306e2a568})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockChild, EventType: boolValue, ID: {d24ede5f-4064-4898-bb84-cfb533b1fbc0})
|
||||
//: The name of the ParamType (DeviceClass: mockChild, EventType: boolValue, ID: {80ba1449-b485-47d4-a067-6bf306e2a568})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
|
||||
|
||||
//: The name of the StateType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockChild
|
||||
//: The name of the StateType ({80ba1449-b485-47d4-a067-6bf306e2a568}) of DeviceClass mockChild
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockParent, ActionType: boolValue, ID: {d24ede5f-4064-4898-bb84-cfb533b1fbc0})
|
||||
@ -778,13 +778,13 @@ const QString translations[] {
|
||||
//: The name of the StateType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockParent
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: bool, ID: {e680f7a4-b39e-46da-be41-fa3170fe3768})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: bool, ID: {7ffe514f-7999-4998-8350-0e73e222a8c4})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: bool, ID: {e680f7a4-b39e-46da-be41-fa3170fe3768})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: bool, ID: {7ffe514f-7999-4998-8350-0e73e222a8c4})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
|
||||
|
||||
//: The name of the StateType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockDisplayPin
|
||||
//: The name of the StateType ({7ffe514f-7999-4998-8350-0e73e222a8c4}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: bool, ID: {e680f7a4-b39e-46da-be41-fa3170fe3768})
|
||||
@ -796,31 +796,31 @@ const QString translations[] {
|
||||
//: The name of the StateType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value"),
|
||||
|
||||
//: The name of the EventType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockChild
|
||||
//: The name of the EventType ({80ba1449-b485-47d4-a067-6bf306e2a568}) of DeviceClass mockChild
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value changed"),
|
||||
|
||||
//: The name of the EventType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of DeviceClass mockParent
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value changed"),
|
||||
|
||||
//: The name of the EventType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockDisplayPin
|
||||
//: The name of the EventType ({7ffe514f-7999-4998-8350-0e73e222a8c4}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value changed"),
|
||||
|
||||
//: The name of the EventType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "bool value changed"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4})
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {66179395-ef7a-4013-9fc6-2084104eea09})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "broken"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, Type: device, ID: {ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "broken"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: color, ID: {20dc7c22-c50e-42db-837c-2bbced939f8e})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: color, ID: {3e161294-8a0d-4384-9676-6959e08cc2fa})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "color"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: color, ID: {20dc7c22-c50e-42db-837c-2bbced939f8e})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: color, ID: {3e161294-8a0d-4384-9676-6959e08cc2fa})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "color"),
|
||||
|
||||
//: The name of the StateType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockDisplayPin
|
||||
//: The name of the StateType ({3e161294-8a0d-4384-9676-6959e08cc2fa}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "color"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: color, ID: {20dc7c22-c50e-42db-837c-2bbced939f8e})
|
||||
@ -832,7 +832,7 @@ const QString translations[] {
|
||||
//: The name of the StateType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "color"),
|
||||
|
||||
//: The name of the EventType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockDisplayPin
|
||||
//: The name of the EventType ({3e161294-8a0d-4384-9676-6959e08cc2fa}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "color changed"),
|
||||
|
||||
//: The name of the EventType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of DeviceClass mockPushButton
|
||||
@ -844,13 +844,13 @@ const QString translations[] {
|
||||
//: The name of the ParamType (DeviceClass: mockDevice, Type: plugin, ID: {e1f72121-a426-45e2-b475-8262b5cdf103})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "configParamInt"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: double, ID: {53cd7c55-49b7-441b-b970-9048f20f0e2c})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: double, ID: {17635624-7c19-4bae-8429-2f7aa5d2f843})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "double value"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: double, ID: {53cd7c55-49b7-441b-b970-9048f20f0e2c})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: double, ID: {17635624-7c19-4bae-8429-2f7aa5d2f843})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "double value"),
|
||||
|
||||
//: The name of the StateType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockDisplayPin
|
||||
//: The name of the StateType ({17635624-7c19-4bae-8429-2f7aa5d2f843}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "double value"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: double, ID: {53cd7c55-49b7-441b-b970-9048f20f0e2c})
|
||||
@ -862,46 +862,46 @@ const QString translations[] {
|
||||
//: The name of the StateType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "double value"),
|
||||
|
||||
//: The name of the EventType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockDisplayPin
|
||||
//: The name of the EventType ({17635624-7c19-4bae-8429-2f7aa5d2f843}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "double value changed"),
|
||||
|
||||
//: The name of the EventType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "double value changed"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {d4f06047-125e-4479-9810-b54c189917f5})
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, Type: device, ID: {bfeb0613-dab6-408c-aa27-c362c921d0d1})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "http port"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, Type: device, ID: {d4f06047-125e-4479-9810-b54c189917f5})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "http port"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, ActionType: withParams, ID: {a2d3a256-a551-4712-a65b-ecd5a436a1cb})
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, ActionType: withParams, ID: {b8126ba6-3a54-45a3-be4d-63feb0ddb77b})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "mockActionParam1"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, ActionType: withParams, ID: {a2d3a256-a551-4712-a65b-ecd5a436a1cb})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "mockActionParam1"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, ActionType: withParams, ID: {304a4899-18be-4e3b-94f4-d03be52f3233})
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, ActionType: withParams, ID: {df41ba71-e43b-4854-91d1-b19d8066d4f9})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "mockActionParam2"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, ActionType: withParams, ID: {304a4899-18be-4e3b-94f4-d03be52f3233})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "mockActionParam2"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: event2, ID: {0550e16d-60b9-4ba5-83f4-4d3cee656121})
|
||||
//: The name of the ParamType (DeviceClass: mockDeviceAuto, EventType: event2, ID: {12ed5a15-96b4-4381-9d9c-a24875283d4f})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "mockParamInt"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, EventType: mockEvent2, ID: {0550e16d-60b9-4ba5-83f4-4d3cee656121})
|
||||
//: The name of the ParamType (DeviceClass: mock, EventType: event2, ID: {0550e16d-60b9-4ba5-83f4-4d3cee656121})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "mockParamInt"),
|
||||
|
||||
//: The name of the vendor ({2062d64d-3232-433c-88bc-0d33c0ba2ba6})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "nymea"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: percentage, ID: {72981c04-267a-4ba0-a59e-9921d2f3af9c})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, ActionType: percentage, ID: {527f0687-0b28-4c26-852c-25b8f83e4797})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: percentage, ID: {72981c04-267a-4ba0-a59e-9921d2f3af9c})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, EventType: percentage, ID: {527f0687-0b28-4c26-852c-25b8f83e4797})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
|
||||
|
||||
//: The name of the StateType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockDisplayPin
|
||||
//: The name of the StateType ({527f0687-0b28-4c26-852c-25b8f83e4797}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockPushButton, ActionType: percentage, ID: {72981c04-267a-4ba0-a59e-9921d2f3af9c})
|
||||
@ -913,7 +913,7 @@ const QString translations[] {
|
||||
//: The name of the StateType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockPushButton
|
||||
QT_TRANSLATE_NOOP("mockDevice", "percentage"),
|
||||
|
||||
//: The name of the EventType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockDisplayPin
|
||||
//: The name of the EventType ({527f0687-0b28-4c26-852c-25b8f83e4797}) of DeviceClass mockDisplayPin
|
||||
QT_TRANSLATE_NOOP("mockDevice", "percentage changed"),
|
||||
|
||||
//: The name of the EventType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of DeviceClass mockPushButton
|
||||
@ -934,10 +934,10 @@ const QString translations[] {
|
||||
//: The name of the EventType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of DeviceClass mock
|
||||
QT_TRANSLATE_NOOP("mockDevice", "powered changed"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, Type: discovery, ID: {d222adb4-2f9c-4c3f-8655-76400d0fb6ce})
|
||||
//: The name of the ParamType (DeviceClass: mockDisplayPin, Type: discovery, ID: {35f6e4ba-28ad-4152-a58d-ec2600667bcf})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "resultCount"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mockPushButton, Type: discovery, ID: {d222adb4-2f9c-4c3f-8655-76400d0fb6ce})
|
||||
//: The name of the ParamType (DeviceClass: mockPushButton, Type: discovery, ID: {c40dbc59-4bba-4871-9b8e-bbd8d5d9193b})
|
||||
QT_TRANSLATE_NOOP("mockDevice", "resultCount"),
|
||||
|
||||
//: The name of the ParamType (DeviceClass: mock, Type: discovery, ID: {d222adb4-2f9c-4c3f-8655-76400d0fb6ce})
|
||||
|
||||
@ -45,21 +45,21 @@ void TestActions::executeAction_data()
|
||||
|
||||
QVariantList params;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 5);
|
||||
params.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
params.append(param2);
|
||||
|
||||
QTest::newRow("valid action") << m_mockDeviceId << mockActionIdWithParams << params << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << mockActionIdWithParams << params << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("valid action") << m_mockDeviceId << mockWithParamsActionTypeId << params << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << mockWithParamsActionTypeId << params << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("invalid actionTypeId") << m_mockDeviceId << ActionTypeId::createActionTypeId() << params << Device::DeviceErrorActionTypeNotFound;
|
||||
QTest::newRow("missing params") << m_mockDeviceId << mockActionIdWithParams << QVariantList() << Device::DeviceErrorMissingParameter;
|
||||
QTest::newRow("async action") << m_mockDeviceId << mockActionIdAsync << QVariantList() << Device::DeviceErrorNoError;
|
||||
QTest::newRow("broken action") << m_mockDeviceId << mockActionIdFailing << QVariantList() << Device::DeviceErrorSetupFailed;
|
||||
QTest::newRow("async broken action") << m_mockDeviceId << mockActionIdAsyncFailing << QVariantList() << Device::DeviceErrorSetupFailed;
|
||||
QTest::newRow("missing params") << m_mockDeviceId << mockWithParamsActionTypeId << QVariantList() << Device::DeviceErrorMissingParameter;
|
||||
QTest::newRow("async action") << m_mockDeviceId << mockAsyncActionTypeId << QVariantList() << Device::DeviceErrorNoError;
|
||||
QTest::newRow("broken action") << m_mockDeviceId << mockFailingActionTypeId << QVariantList() << Device::DeviceErrorSetupFailed;
|
||||
QTest::newRow("async broken action") << m_mockDeviceId << mockAsyncFailingActionTypeId << QVariantList() << Device::DeviceErrorSetupFailed;
|
||||
}
|
||||
|
||||
void TestActions::executeAction()
|
||||
@ -119,7 +119,7 @@ void TestActions::getActionType_data()
|
||||
QTest::addColumn<ActionTypeId>("actionTypeId");
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QTest::newRow("valid actiontypeid") << mockActionIdWithParams << Device::DeviceErrorNoError;
|
||||
QTest::newRow("valid actiontypeid") << mockWithParamsActionTypeId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid actiontypeid") << ActionTypeId::createActionTypeId() << Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ void TestDevices::setPluginConfig()
|
||||
|
||||
QVariantList configuration;
|
||||
QVariantMap configParam;
|
||||
configParam.insert("paramTypeId", configParamIntParamTypeId);
|
||||
configParam.insert("paramTypeId", mockDevicePluginConfigParamIntParamTypeId);
|
||||
configParam.insert("value", value);
|
||||
configuration.append(configParam);
|
||||
params.insert("configuration", configuration);
|
||||
@ -174,7 +174,7 @@ void TestDevices::setPluginConfig()
|
||||
response = injectAndWait("Devices.GetPluginConfiguration", params);
|
||||
verifyDeviceError(response);
|
||||
qDebug() << value << response.toMap().value("params").toMap().value("configuration").toList().first();
|
||||
QVERIFY2(ParamTypeId(response.toMap().value("params").toMap().value("configuration").toList().first().toMap().value("paramTypeId").toString()) == configParamIntParamTypeId, "Value not set correctly");
|
||||
QVERIFY2(ParamTypeId(response.toMap().value("params").toMap().value("configuration").toList().first().toMap().value("paramTypeId").toString()) == mockDevicePluginConfigParamIntParamTypeId, "Value not set correctly");
|
||||
QVERIFY2(response.toMap().value("params").toMap().value("configuration").toList().first().toMap().value("value") == value, "Value not set correctly");
|
||||
}
|
||||
}
|
||||
@ -255,13 +255,13 @@ void TestDevices::addConfiguredDevice_data()
|
||||
QTest::addColumn<Device::DeviceError>("deviceError");
|
||||
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId.toString());
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId.toString());
|
||||
httpportParam.insert("value", m_mockDevice1Port - 1);
|
||||
QVariantMap asyncParam;
|
||||
asyncParam.insert("paramTypeId", asyncParamTypeId);
|
||||
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
|
||||
asyncParam.insert("value", true);
|
||||
QVariantMap brokenParam;
|
||||
brokenParam.insert("paramTypeId", brokenParamTypeId);
|
||||
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
|
||||
brokenParam.insert("value", true);
|
||||
|
||||
QVariantList deviceParams;
|
||||
@ -330,15 +330,15 @@ void TestDevices::storedDevices()
|
||||
params.insert("name", "Test stored Device");
|
||||
QVariantList deviceParams;
|
||||
QVariantMap asyncParam;
|
||||
asyncParam.insert("paramTypeId", asyncParamTypeId);
|
||||
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
|
||||
asyncParam.insert("value", false);
|
||||
deviceParams.append(asyncParam);
|
||||
QVariantMap brokenParam;
|
||||
brokenParam.insert("paramTypeId", brokenParamTypeId);
|
||||
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
|
||||
brokenParam.insert("value", false);
|
||||
deviceParams.append(brokenParam);
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", 8889);
|
||||
deviceParams.append(httpportParam);
|
||||
params.insert("deviceParams", deviceParams);
|
||||
@ -380,7 +380,7 @@ void TestDevices::discoverDevices_data()
|
||||
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 1);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
@ -445,7 +445,7 @@ void TestDevices::addPushButtonDevices()
|
||||
// Discover device
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockPushButtonDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 1);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
@ -511,7 +511,7 @@ void TestDevices::addDisplayPinDevices()
|
||||
// Discover device
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockDisplayPinDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 1);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
@ -636,7 +636,7 @@ void TestDevices::getActionTypes_data()
|
||||
QTest::addColumn<QList<ActionTypeId> >("actionTypeTestData");
|
||||
|
||||
QTest::newRow("valid deviceclass") << mockDeviceClassId
|
||||
<< (QList<ActionTypeId>() << mockActionIdAsync << mockActionIdAsyncFailing << mockActionIdFailing << mockActionIdNoParams << mockActionIdPower << mockActionIdWithParams);
|
||||
<< (QList<ActionTypeId>() << mockAsyncActionTypeId << mockAsyncFailingActionTypeId << mockFailingActionTypeId << mockWithoutParamsActionTypeId << mockPowerActionTypeId << mockWithoutParamsActionTypeId);
|
||||
QTest::newRow("invalid deviceclass") << DeviceClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << QList<ActionTypeId>();
|
||||
}
|
||||
|
||||
@ -709,7 +709,7 @@ void TestDevices::getStateTypes()
|
||||
QVariantList stateTypes = response.toMap().value("params").toMap().value("stateTypes").toList();
|
||||
QCOMPARE(stateTypes.count(), resultCount);
|
||||
if (resultCount > 0) {
|
||||
QCOMPARE(stateTypes.first().toMap().value("id").toString(), mockIntStateId.toString());
|
||||
QCOMPARE(stateTypes.first().toMap().value("id").toString(), mockIntStateTypeId.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -718,8 +718,8 @@ void TestDevices::getStateType_data()
|
||||
QTest::addColumn<StateTypeId>("stateTypeId");
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QTest::newRow("valid int state") << mockIntStateId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("valid bool state") << mockBoolStateId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("valid int state") << mockIntStateTypeId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("valid bool state") << mockBoolStateTypeId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid stateTypeId") << StateTypeId::createStateTypeId() << Device::DeviceErrorStateTypeNotFound;
|
||||
}
|
||||
|
||||
@ -750,8 +750,8 @@ void TestDevices::getStateValue_data()
|
||||
QTest::addColumn<StateTypeId>("stateTypeId");
|
||||
QTest::addColumn<Device::DeviceError>("statusCode");
|
||||
|
||||
QTest::newRow("valid deviceId") << m_mockDeviceId << mockIntStateId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid deviceId") << DeviceId("094f8024-5caa-48c1-ab6a-de486a92088f") << mockIntStateId << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("valid deviceId") << m_mockDeviceId << mockIntStateTypeId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid deviceId") << DeviceId("094f8024-5caa-48c1-ab6a-de486a92088f") << mockIntStateTypeId << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("invalid statetypeId") << m_mockDeviceId << StateTypeId("120514f1-343e-4621-9bff-dac616169df9") << Device::DeviceErrorStateTypeNotFound;
|
||||
}
|
||||
|
||||
@ -816,7 +816,7 @@ void TestDevices::editDevices()
|
||||
// add device
|
||||
QVariantList deviceParams;
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", 8889);
|
||||
deviceParams.append(httpportParam);
|
||||
|
||||
@ -874,7 +874,7 @@ void TestDevices::testDeviceSettings()
|
||||
// add device
|
||||
QVariantList deviceParams;
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", 8889);
|
||||
deviceParams.append(httpportParam);
|
||||
|
||||
@ -899,7 +899,7 @@ void TestDevices::testDeviceSettings()
|
||||
QVariantList settings = device.value("settings").toList();
|
||||
QCOMPARE(settings.count(), 1);
|
||||
|
||||
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSetting1ParamTypeId.toString());
|
||||
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSettingsSetting1ParamTypeId.toString());
|
||||
QVERIFY2(settings.first().toMap().value("value").toInt() == 5, "Setting 1 default value not matching");
|
||||
|
||||
// change a setting
|
||||
@ -907,7 +907,7 @@ void TestDevices::testDeviceSettings()
|
||||
params.insert("deviceId", deviceId);
|
||||
settings.clear();
|
||||
QVariantMap setting;
|
||||
setting.insert("paramTypeId", mockSetting1ParamTypeId);
|
||||
setting.insert("paramTypeId", mockSettingsSetting1ParamTypeId);
|
||||
setting.insert("value", 7);
|
||||
settings.append(setting);
|
||||
params.insert("settings", settings);
|
||||
@ -926,7 +926,7 @@ void TestDevices::testDeviceSettings()
|
||||
settings = device.value("settings").toList();
|
||||
QCOMPARE(settings.count(), 1);
|
||||
|
||||
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSetting1ParamTypeId.toString());
|
||||
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSettingsSetting1ParamTypeId.toString());
|
||||
QVERIFY2(settings.first().toMap().value("value").toInt() == 7, "Setting 1 changed value not matching");
|
||||
|
||||
restartServer();
|
||||
@ -944,7 +944,7 @@ void TestDevices::testDeviceSettings()
|
||||
settings = device.value("settings").toList();
|
||||
QCOMPARE(settings.count(), 1);
|
||||
|
||||
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSetting1ParamTypeId.toString());
|
||||
QCOMPARE(settings.first().toMap().value("paramTypeId").toString(), mockSettingsSetting1ParamTypeId.toString());
|
||||
QVERIFY2(settings.first().toMap().value("value").toInt() == 7, "Setting 1 changed value not persisting restart");
|
||||
|
||||
}
|
||||
@ -953,19 +953,19 @@ void TestDevices::reconfigureDevices_data()
|
||||
{
|
||||
QVariantList asyncChangeDeviceParams;
|
||||
QVariantMap asyncParamDifferent;
|
||||
asyncParamDifferent.insert("paramTypeId", asyncParamTypeId);
|
||||
asyncParamDifferent.insert("paramTypeId", mockDeviceAsyncParamTypeId);
|
||||
asyncParamDifferent.insert("value", true);
|
||||
asyncChangeDeviceParams.append(asyncParamDifferent);
|
||||
|
||||
QVariantList httpportChangeDeviceParams;
|
||||
QVariantMap httpportParamDifferent;
|
||||
httpportParamDifferent.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParamDifferent.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParamDifferent.insert("value", 8893); // if change -> change also newPort in reconfigureDevices()
|
||||
httpportChangeDeviceParams.append(httpportParamDifferent);
|
||||
|
||||
QVariantList brokenChangedDeviceParams;
|
||||
QVariantMap brokenParamDifferent;
|
||||
brokenParamDifferent.insert("paramTypeId", brokenParamTypeId);
|
||||
brokenParamDifferent.insert("paramTypeId", mockDeviceBrokenParamTypeId);
|
||||
brokenParamDifferent.insert("value", true);
|
||||
brokenChangedDeviceParams.append(brokenParamDifferent);
|
||||
|
||||
@ -1000,15 +1000,15 @@ void TestDevices::reconfigureDevices()
|
||||
params.insert("name", "Device to edit");
|
||||
QVariantList deviceParams;
|
||||
QVariantMap asyncParam;
|
||||
asyncParam.insert("paramTypeId", asyncParamTypeId);
|
||||
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
|
||||
asyncParam.insert("value", false);
|
||||
deviceParams.append(asyncParam);
|
||||
QVariantMap brokenParam;
|
||||
brokenParam.insert("paramTypeId", brokenParamTypeId);
|
||||
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
|
||||
brokenParam.insert("value", broken);
|
||||
deviceParams.append(brokenParam);
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", 8892);
|
||||
deviceParams.append(httpportParam);
|
||||
params.insert("deviceParams", deviceParams);
|
||||
@ -1123,7 +1123,7 @@ void TestDevices::reconfigureByDiscovery_data()
|
||||
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 2);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
@ -1228,7 +1228,7 @@ void TestDevices::reconfigureByDiscovery()
|
||||
|
||||
// Note: this shows that by discovery a not editable param (name) can be changed!
|
||||
foreach (QVariant param, deviceMap.value("params").toList()) {
|
||||
if (param.toMap().value("paramTypeId") == httpportParamTypeId) {
|
||||
if (param.toMap().value("paramTypeId") == mockDeviceHttpportParamTypeId) {
|
||||
QCOMPARE(param.toMap().value("value").toInt(), 55556);
|
||||
}
|
||||
}
|
||||
@ -1261,7 +1261,7 @@ void TestDevices::reconfigureByDiscoveryAndPair()
|
||||
{
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockDisplayPinDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 1);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
@ -1363,27 +1363,28 @@ void TestDevices::reconfigureAutodevice()
|
||||
qCDebug(dcTests()) << "Reconfigure auto device";
|
||||
|
||||
// Get the autodevice
|
||||
QList<Device *> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId);
|
||||
QList<Device *> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoDeviceClassId);
|
||||
QVERIFY2(devices.count() > 0, "There needs to be at least one auto-created Mock Device for this test");
|
||||
|
||||
// Get current auto device infos
|
||||
Device *currentDevice = devices.first();
|
||||
DeviceId deviceId = currentDevice->id();
|
||||
int currentPort = currentDevice->paramValue(httpportParamTypeId).toInt();
|
||||
int currentPort = currentDevice->paramValue(mockDeviceAutoDeviceHttpportParamTypeId).toInt();
|
||||
|
||||
// Trigger reconfigure signal in mock device
|
||||
QNetworkAccessManager *nam = new QNetworkAccessManager(this);
|
||||
QSignalSpy spy(nam, SIGNAL(finished(QNetworkReply*)));
|
||||
QSignalSpy spy(nam, &QNetworkAccessManager::finished);
|
||||
QNetworkReply *reply = nam->get(QNetworkRequest(QUrl(QString("http://localhost:%1/reconfigureautodevice").arg(currentPort))));
|
||||
spy.wait();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
qCDebug(dcTests()) << "Reconfigure reply:" << reply->error() << reply->readAll();
|
||||
reply->deleteLater();
|
||||
|
||||
Device *device = NymeaCore::instance()->deviceManager()->findConfiguredDevice(deviceId);
|
||||
QVERIFY(device);
|
||||
int newPort = device->paramValue(httpportParamTypeId).toInt();
|
||||
int newPort = device->paramValue(mockDeviceAutoDeviceHttpportParamTypeId).toInt();
|
||||
// Note: reconfigure autodevice increases the http port by 1
|
||||
QVERIFY(newPort == currentPort + 1);
|
||||
QCOMPARE(newPort, currentPort + 1);
|
||||
}
|
||||
|
||||
|
||||
@ -1436,7 +1437,7 @@ void TestDevices::removeAutoDevice()
|
||||
Device *device = devices.first();
|
||||
|
||||
// trigger disappear signal in mock device
|
||||
int port = device->paramValue(httpportParamTypeId).toInt();
|
||||
int port = device->paramValue(mockDeviceAutoDeviceHttpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/disappear").arg(port)));
|
||||
QNetworkReply *reply = nam->get(request);
|
||||
spy.wait();
|
||||
@ -1446,7 +1447,7 @@ void TestDevices::removeAutoDevice()
|
||||
|
||||
// Ok, now do the same with an autocreated one. It should go away
|
||||
|
||||
devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId);
|
||||
devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoDeviceClassId);
|
||||
QVERIFY2(devices.count() > 0, "There needs to be at least one auto-created Mock Device for this test");
|
||||
device = devices.first();
|
||||
|
||||
@ -1454,7 +1455,7 @@ void TestDevices::removeAutoDevice()
|
||||
|
||||
// trigger disappear signal in mock device
|
||||
spy.clear();
|
||||
port = device->paramValue(httpportParamTypeId).toInt();
|
||||
port = device->paramValue(mockDeviceAutoDeviceHttpportParamTypeId).toInt();
|
||||
request.setUrl(QUrl(QString("http://localhost:%1/disappear").arg(port)));
|
||||
reply = nam->get(request);
|
||||
|
||||
@ -1462,7 +1463,7 @@ void TestDevices::removeAutoDevice()
|
||||
QCOMPARE(spy.count(), 1);
|
||||
reply->deleteLater();
|
||||
|
||||
QVERIFY2(NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId).count() == 0, "Mock device has not disappeared even though it should have.");
|
||||
QVERIFY2(NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoDeviceClassId).count() == 0, "Mock device has not disappeared even though it should have.");
|
||||
}
|
||||
|
||||
#include "testdevices.moc"
|
||||
|
||||
@ -50,8 +50,8 @@ void TestEvents::triggerEvent()
|
||||
QNetworkAccessManager nam;
|
||||
|
||||
// trigger event in mock device
|
||||
int port = device->paramValue(httpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1Id.toString())));
|
||||
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1EventTypeId.toString())));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
|
||||
@ -62,7 +62,7 @@ void TestEvents::triggerEvent()
|
||||
Event event = spy.at(i).at(0).value<Event>();
|
||||
if (event.deviceId() == device->id()) {
|
||||
// Make sure the event contains all the stuff we expect
|
||||
QCOMPARE(event.eventTypeId(), mockEvent1Id);
|
||||
QCOMPARE(event.eventTypeId(), mockEvent1EventTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,8 +79,8 @@ void TestEvents::triggerStateChangeEvent()
|
||||
QNetworkAccessManager nam;
|
||||
|
||||
// trigger state changed event in mock device
|
||||
int port = device->paramValue(httpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockIntStateId.toString()).arg(11)));
|
||||
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockIntStateTypeId.toString()).arg(11)));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
|
||||
@ -91,8 +91,8 @@ void TestEvents::triggerStateChangeEvent()
|
||||
Event event = spy.at(i).at(0).value<Event>();
|
||||
if (event.deviceId() == device->id()) {
|
||||
// Make sure the event contains all the stuff we expect
|
||||
QCOMPARE(event.eventTypeId().toString(), mockIntStateId.toString());
|
||||
QCOMPARE(event.param(ParamTypeId(mockIntStateId.toString())).value().toInt(), 11);
|
||||
QCOMPARE(event.eventTypeId().toString(), mockIntStateTypeId.toString());
|
||||
QCOMPARE(event.param(ParamTypeId(mockIntStateTypeId.toString())).value().toInt(), 11);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ void TestEvents::getEventType_data()
|
||||
QTest::addColumn<EventTypeId>("eventTypeId");
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QTest::newRow("valid eventypeid") << mockEvent1Id << Device::DeviceErrorNoError;
|
||||
QTest::newRow("valid eventypeid") << mockEvent1EventTypeId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid eventypeid") << EventTypeId::createEventTypeId() << Device::DeviceErrorEventTypeNotFound;
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ void TestJSONRPC::testHandshakeLocale()
|
||||
QVariantMap supportedDevices = injectAndWait("Devices.GetSupportedDevices").toMap();
|
||||
bool found = false;
|
||||
foreach (const QVariant &dcMap, supportedDevices.value("params").toMap().value("deviceClasses").toList()) {
|
||||
if (dcMap.toMap().value("id").toUuid() == mockDeviceAutoClassId) {
|
||||
if (dcMap.toMap().value("id").toUuid() == mockDeviceAutoDeviceClassId) {
|
||||
QCOMPARE(dcMap.toMap().value("displayName").toString(), QString("Mock Device (Auto created)"));
|
||||
found = true;
|
||||
}
|
||||
@ -200,7 +200,7 @@ void TestJSONRPC::testHandshakeLocale()
|
||||
supportedDevices = injectAndWait("Devices.GetSupportedDevices").toMap();
|
||||
found = false;
|
||||
foreach (const QVariant &dcMap, supportedDevices.value("params").toMap().value("deviceClasses").toList()) {
|
||||
if (dcMap.toMap().value("id").toUuid() == mockDeviceAutoClassId) {
|
||||
if (dcMap.toMap().value("id").toUuid() == mockDeviceAutoDeviceClassId) {
|
||||
QCOMPARE(dcMap.toMap().value("displayName").toString(), QString("Mock Gerät (Automatisch erzeugt)"));
|
||||
found = true;
|
||||
}
|
||||
@ -650,7 +650,7 @@ void TestJSONRPC::deviceAddedRemovedNotifications()
|
||||
// add device and wait for notification
|
||||
QVariantList deviceParams;
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", 8765);
|
||||
deviceParams.append(httpportParam);
|
||||
|
||||
@ -697,7 +697,7 @@ void TestJSONRPC::ruleAddedRemovedNotifications()
|
||||
// Add rule and wait for notification
|
||||
// StateDescriptor
|
||||
QVariantMap stateDescriptor;
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateId);
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
|
||||
stateDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorLess));
|
||||
stateDescriptor.insert("value", "20");
|
||||
@ -707,13 +707,13 @@ void TestJSONRPC::ruleAddedRemovedNotifications()
|
||||
|
||||
// RuleAction
|
||||
QVariantMap actionNoParams;
|
||||
actionNoParams.insert("actionTypeId", mockActionIdNoParams);
|
||||
actionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
actionNoParams.insert("deviceId", m_mockDeviceId);
|
||||
actionNoParams.insert("ruleActionParams", QVariantList());
|
||||
|
||||
// EventDescriptor
|
||||
QVariantMap eventDescriptor;
|
||||
eventDescriptor.insert("eventTypeId", mockEvent1Id);
|
||||
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
eventDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
eventDescriptor.insert("paramDescriptors", QVariantList());
|
||||
|
||||
@ -761,7 +761,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
|
||||
// Add rule and wait for notification
|
||||
// StateDescriptor
|
||||
QVariantMap stateDescriptor;
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateId);
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
|
||||
stateDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
stateDescriptor.insert("value", "20");
|
||||
@ -771,7 +771,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
|
||||
|
||||
// RuleAction
|
||||
QVariantMap actionNoParams;
|
||||
actionNoParams.insert("actionTypeId", mockActionIdNoParams);
|
||||
actionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
actionNoParams.insert("deviceId", m_mockDeviceId);
|
||||
actionNoParams.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -804,7 +804,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
|
||||
|
||||
// state state to 20
|
||||
qDebug() << "setting mock int state to 20";
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateId.toString()).arg(20)));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateTypeId.toString()).arg(20)));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
|
||||
|
||||
@ -819,7 +819,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
|
||||
|
||||
// set the rule inactive
|
||||
qDebug() << "setting mock int state to 42";
|
||||
QNetworkRequest request2(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateId.toString()).arg(42)));
|
||||
QNetworkRequest request2(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateTypeId.toString()).arg(42)));
|
||||
QNetworkReply *reply2 = nam.get(request2);
|
||||
if (spy.count() == 0) spy.wait();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
@ -861,7 +861,7 @@ void TestJSONRPC::deviceChangedNotifications()
|
||||
// add device and wait for notification
|
||||
QVariantList deviceParams;
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", 23234);
|
||||
deviceParams.append(httpportParam);
|
||||
|
||||
@ -888,7 +888,7 @@ void TestJSONRPC::deviceChangedNotifications()
|
||||
// now reconfigure the device and check the deviceChanged notification
|
||||
QVariantList newDeviceParams;
|
||||
QVariantMap newHttpportParam;
|
||||
newHttpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
newHttpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
newHttpportParam.insert("value", 45473);
|
||||
newDeviceParams.append(newHttpportParam);
|
||||
|
||||
@ -1039,7 +1039,7 @@ void TestJSONRPC::pluginConfigChangeEmitsNotification()
|
||||
params.insert("pluginId", mockPluginId);
|
||||
QVariantList pluginParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", configParamIntParamTypeId);
|
||||
param1.insert("paramTypeId", mockDevicePluginConfigParamIntParamTypeId);
|
||||
param1.insert("value", 42);
|
||||
pluginParams.append(param1);
|
||||
params.insert("configuration", pluginParams);
|
||||
|
||||
@ -213,8 +213,8 @@ void TestLogging::eventLogs()
|
||||
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
||||
|
||||
// trigger event in mock device
|
||||
int port = device->paramValue(httpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1Id.toString())));
|
||||
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1EventTypeId.toString())));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
|
||||
// Lets wait for the notification
|
||||
@ -233,7 +233,7 @@ void TestLogging::eventLogs()
|
||||
if (logEntry.value("deviceId").toString() == device->id().toString()) {
|
||||
found = true;
|
||||
// Make sure the notification contains all the stuff we expect
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockEvent1Id.toString());
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockEvent1EventTypeId.toString());
|
||||
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents));
|
||||
QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));
|
||||
@ -250,7 +250,7 @@ void TestLogging::eventLogs()
|
||||
params.insert("deviceIds", QVariantList() << device->id());
|
||||
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents));
|
||||
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
params.insert("typeIds", QVariantList() << mockEvent1Id);
|
||||
params.insert("typeIds", QVariantList() << mockEvent1EventTypeId);
|
||||
|
||||
QVariant response = injectAndWait("Logging.GetLogEntries", params);
|
||||
verifyLoggingError(response);
|
||||
@ -268,16 +268,16 @@ void TestLogging::actionLog()
|
||||
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 7);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("actionTypeId", mockActionIdWithParams);
|
||||
params.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
params.insert("params", actionParams);
|
||||
|
||||
@ -304,7 +304,7 @@ void TestLogging::actionLog()
|
||||
if (logEntry.value("deviceId").toString() == m_mockDeviceId.toString()) {
|
||||
found = true;
|
||||
// Make sure the notification contains all the stuff we expect
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockActionIdWithParams.toString());
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockWithParamsActionTypeId.toString());
|
||||
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
|
||||
QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));
|
||||
@ -318,7 +318,7 @@ void TestLogging::actionLog()
|
||||
|
||||
// EXECUTE without params
|
||||
params.clear(); clientSpy.clear();
|
||||
params.insert("actionTypeId", mockActionIdNoParams);
|
||||
params.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
response = injectAndWait("Actions.ExecuteAction", params);
|
||||
verifyDeviceError(response);
|
||||
@ -345,7 +345,7 @@ void TestLogging::actionLog()
|
||||
|
||||
// EXECUTE broken action
|
||||
params.clear(); clientSpy.clear();
|
||||
params.insert("actionTypeId", mockActionIdFailing);
|
||||
params.insert("actionTypeId", mockFailingActionTypeId);
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
response = injectAndWait("Actions.ExecuteAction", params);
|
||||
verifyDeviceError(response, Device::DeviceErrorSetupFailed);
|
||||
@ -363,7 +363,7 @@ void TestLogging::actionLog()
|
||||
if (logEntry.value("deviceId").toString() == m_mockDeviceId.toString()) {
|
||||
found = true;
|
||||
// Make sure the notification contains all the stuff we expect
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockActionIdFailing.toString());
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockFailingActionTypeId.toString());
|
||||
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
|
||||
QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelAlert));
|
||||
@ -396,7 +396,7 @@ void TestLogging::actionLog()
|
||||
params.insert("deviceIds", QVariantList() << m_mockDeviceId);
|
||||
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
|
||||
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
params.insert("typeIds", QVariantList() << mockActionIdNoParams);
|
||||
params.insert("typeIds", QVariantList() << mockWithoutParamsActionTypeId);
|
||||
|
||||
response = injectAndWait("Logging.GetLogEntries", params);
|
||||
verifyLoggingError(response);
|
||||
@ -408,7 +408,7 @@ void TestLogging::actionLog()
|
||||
params.insert("deviceIds", QVariantList() << m_mockDeviceId);
|
||||
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
|
||||
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
params.insert("typeIds", QVariantList() << mockActionIdNoParams << mockActionIdWithParams << mockActionIdFailing);
|
||||
params.insert("typeIds", QVariantList() << mockWithoutParamsActionTypeId << mockWithParamsActionTypeId << mockFailingActionTypeId);
|
||||
|
||||
response = injectAndWait("Logging.GetLogEntries", params);
|
||||
verifyLoggingError(response);
|
||||
@ -465,7 +465,7 @@ void TestLogging::testDoubleValues()
|
||||
// Discover device
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockDisplayPinDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 1);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
@ -505,12 +505,12 @@ void TestLogging::testDoubleValues()
|
||||
// Set the double state value and sniff for LogEntryAdded notification
|
||||
double value = 23.80;
|
||||
QVariantMap actionParam;
|
||||
actionParam.insert("paramTypeId", doubleStateParamTypeId.toString());
|
||||
actionParam.insert("paramTypeId", mockDisplayPinDoubleActionDoubleParamTypeId.toString());
|
||||
actionParam.insert("value", value);
|
||||
|
||||
params.clear(); response.clear();
|
||||
params.insert("deviceId", deviceId);
|
||||
params.insert("actionTypeId", doubleStateParamTypeId.toString());
|
||||
params.insert("actionTypeId", mockDisplayPinDoubleActionTypeId.toString());
|
||||
params.insert("params", QVariantList() << actionParam);
|
||||
|
||||
response = injectAndWait("Actions.ExecuteAction", params);
|
||||
@ -523,8 +523,8 @@ void TestLogging::testDoubleValues()
|
||||
foreach (const QVariant &logNotificationVariant, logNotificationsList) {
|
||||
QVariantMap logNotification = logNotificationVariant.toMap().value("params").toMap().value("logEntry").toMap();
|
||||
|
||||
if (logNotification.value("typeId").toString() == doubleStateParamTypeId.toString()) {
|
||||
if (logNotification.value("typeId").toString() == doubleStateParamTypeId.toString()) {
|
||||
if (logNotification.value("typeId").toString() == mockDisplayPinDoubleActionDoubleParamTypeId.toString()) {
|
||||
if (logNotification.value("typeId").toString() == mockDisplayPinDoubleActionDoubleParamTypeId.toString()) {
|
||||
|
||||
// If state source
|
||||
if (logNotification.value("source").toString() == JsonTypes::loggingSourceToString(Logging::LoggingSourceStates)) {
|
||||
@ -558,7 +558,7 @@ void TestLogging::testHouseKeeping()
|
||||
params.insert("name", "TestDeviceToBeRemoved");
|
||||
QVariantList deviceParams;
|
||||
QVariantMap httpParam;
|
||||
httpParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpParam.insert("value", 6667);
|
||||
deviceParams.append(httpParam);
|
||||
params.insert("deviceParams", deviceParams);
|
||||
@ -569,7 +569,7 @@ void TestLogging::testHouseKeeping()
|
||||
// Trigger something that creates a logging entry
|
||||
QNetworkAccessManager nam;
|
||||
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(6667).arg(mockIntStateId.toString()).arg(4321)));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(6667).arg(mockIntStateTypeId.toString()).arg(4321)));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
|
||||
spy.wait();
|
||||
@ -598,16 +598,16 @@ void TestLogging::testLimits()
|
||||
for (int i = 0; i < 50; i++) {
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", i);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("actionTypeId", mockActionIdWithParams);
|
||||
params.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
params.insert("params", actionParams);
|
||||
|
||||
|
||||
@ -139,11 +139,11 @@ void TestRestDeviceClasses::getActionTypes_data()
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QTest::newRow("all ActionTypes") << mockDeviceClassId.toString() << QString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("ActionType async") << mockDeviceClassId.toString() << mockActionIdAsync.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("ActionType no params") << mockDeviceClassId.toString() << mockActionIdNoParams.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("ActionType failing") << mockDeviceClassId.toString() << mockActionIdFailing.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("ActionType with params") << mockDeviceClassId.toString() << mockActionIdWithParams.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockActionIdNoParams.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
|
||||
QTest::newRow("ActionType async") << mockDeviceClassId.toString() << mockAsyncActionTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("ActionType no params") << mockDeviceClassId.toString() << mockWithoutParamsActionTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("ActionType failing") << mockDeviceClassId.toString() << mockFailingActionTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("ActionType with params") << mockDeviceClassId.toString() << mockWithParamsActionTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockWithoutParamsActionTypeId.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
|
||||
QTest::newRow("invalid ActionTypeId") << mockDeviceClassId.toString() << ActionTypeId::createActionTypeId().toString() << 404 << Device::DeviceErrorActionTypeNotFound;
|
||||
QTest::newRow("invalid ActionTypeId format") << mockDeviceClassId.toString() << "uuid" << 400 << Device::DeviceErrorActionTypeNotFound;
|
||||
QTest::newRow("invalid DeviceClassId format") << "uuid" << "uuid" << 400 << Device::DeviceErrorDeviceClassNotFound;
|
||||
@ -180,9 +180,9 @@ void TestRestDeviceClasses::getStateTypes_data()
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QTest::newRow("all ActionTypes") << mockDeviceClassId.toString() << QString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("StateType bool") << mockDeviceClassId.toString() << mockBoolStateId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("StateType int") << mockDeviceClassId.toString() << mockIntStateId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockBoolStateId.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
|
||||
QTest::newRow("StateType bool") << mockDeviceClassId.toString() << mockBoolStateTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("StateType int") << mockDeviceClassId.toString() << mockIntStateTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockBoolStateTypeId.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
|
||||
QTest::newRow("invalid StateTypeId") << mockDeviceClassId.toString() << StateTypeId::createStateTypeId().toString() << 404 << Device::DeviceErrorStateTypeNotFound;
|
||||
QTest::newRow("invalid StateTypeId format") << mockDeviceClassId.toString() << "uuid" << 400 << Device::DeviceErrorStateTypeNotFound;
|
||||
QTest::newRow("invalid DeviceClassId format") << "uuid" << "uuid" << 400 << Device::DeviceErrorDeviceClassNotFound;
|
||||
@ -218,9 +218,9 @@ void TestRestDeviceClasses::getEventTypes_data()
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QTest::newRow("all ActionTypes") << mockDeviceClassId.toString() << QString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("EventType 1") << mockDeviceClassId.toString() << mockEvent1Id.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("EventType 2") << mockDeviceClassId.toString() << mockEvent2Id.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockEvent2Id.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
|
||||
QTest::newRow("EventType 1") << mockDeviceClassId.toString() << mockEvent1EventTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("EventType 2") << mockDeviceClassId.toString() << mockEvent2EventTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid DeviceClassId") << DeviceClassId::createDeviceClassId().toString() << mockEvent2EventTypeId.toString() << 404 << Device::DeviceErrorDeviceClassNotFound;
|
||||
QTest::newRow("invalid EventTypeId") << mockDeviceClassId.toString() << EventTypeId::createEventTypeId().toString() << 404 << Device::DeviceErrorEventTypeNotFound;
|
||||
QTest::newRow("invalid EventTypeId format") << mockDeviceClassId.toString() << "uuid" << 400 << Device::DeviceErrorEventTypeNotFound;
|
||||
QTest::newRow("invalid DeviceClassId format") << "uuid" << "uuid" << 400 << Device::DeviceErrorDeviceClassNotFound;
|
||||
@ -257,11 +257,11 @@ void TestRestDeviceClasses::discoverDevices_data()
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 1);
|
||||
|
||||
QVariantMap invalidResultCountParam;
|
||||
invalidResultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
invalidResultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
|
||||
invalidResultCountParam.insert("value", 10);
|
||||
|
||||
QVariantList discoveryParams;
|
||||
|
||||
@ -104,19 +104,19 @@ void TestRestDevices::addConfiguredDevice_data()
|
||||
QTest::addColumn<int>("expectedStatusCode");
|
||||
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", m_mockDevice1Port - 1);
|
||||
QVariantMap asyncParam;
|
||||
asyncParam.insert("paramTypeId", asyncParamTypeId);
|
||||
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
|
||||
asyncParam.insert("value", true);
|
||||
QVariantMap notAsyncParam;
|
||||
notAsyncParam.insert("paramTypeId", asyncParamTypeId);
|
||||
notAsyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
|
||||
notAsyncParam.insert("value", false);
|
||||
QVariantMap notBrokenParam;
|
||||
notBrokenParam.insert("paramTypeId", brokenParamTypeId);
|
||||
notBrokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
|
||||
notBrokenParam.insert("value", false);
|
||||
QVariantMap brokenParam;
|
||||
brokenParam.insert("paramTypeId", brokenParamTypeId);
|
||||
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
|
||||
brokenParam.insert("value", true);
|
||||
|
||||
QVariantList deviceParams;
|
||||
@ -198,7 +198,7 @@ void TestRestDevices::addPushButtonDevices()
|
||||
// Discover device
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockPushButtonDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 1);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
@ -279,7 +279,7 @@ void TestRestDevices::addDisplayPinDevices()
|
||||
// Discover device
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockDisplayPinDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 1);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
@ -419,21 +419,21 @@ void TestRestDevices::executeAction_data()
|
||||
|
||||
QVariantList params;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 5);
|
||||
params.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
params.append(param2);
|
||||
|
||||
QTest::newRow("valid action") << m_mockDeviceId << mockActionIdWithParams << params << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << mockActionIdWithParams << params << 404 << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("valid action") << m_mockDeviceId << mockWithParamsActionTypeId << params << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << mockWithParamsActionTypeId << params << 404 << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("invalid actionTypeId") << m_mockDeviceId << ActionTypeId::createActionTypeId() << params << 404 << Device::DeviceErrorActionTypeNotFound;
|
||||
QTest::newRow("missing params") << m_mockDeviceId << mockActionIdWithParams << QVariantList() << 500 << Device::DeviceErrorMissingParameter;
|
||||
QTest::newRow("async action") << m_mockDeviceId << mockActionIdAsync << QVariantList() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("broken action") << m_mockDeviceId << mockActionIdFailing << QVariantList() << 500 << Device::DeviceErrorSetupFailed;
|
||||
QTest::newRow("async broken action") << m_mockDeviceId << mockActionIdAsyncFailing << QVariantList() << 500 << Device::DeviceErrorSetupFailed;
|
||||
QTest::newRow("missing params") << m_mockDeviceId << mockWithParamsActionTypeId << QVariantList() << 500 << Device::DeviceErrorMissingParameter;
|
||||
QTest::newRow("async action") << m_mockDeviceId << mockAsyncActionTypeId << QVariantList() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("broken action") << m_mockDeviceId << mockFailingActionTypeId << QVariantList() << 500 << Device::DeviceErrorSetupFailed;
|
||||
QTest::newRow("async broken action") << m_mockDeviceId << mockAsyncFailingActionTypeId << QVariantList() << 500 << Device::DeviceErrorSetupFailed;
|
||||
}
|
||||
|
||||
void TestRestDevices::executeAction()
|
||||
@ -501,9 +501,9 @@ void TestRestDevices::getStateValue_data()
|
||||
QTest::addColumn<int>("expectedStatusCode");
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QTest::newRow("existing state") << device->id().toString() << mockIntStateId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("existing state") << device->id().toString() << mockIntStateTypeId.toString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("all states") << device->id().toString() << QString() << 200 << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid device") << DeviceId::createDeviceId().toString() << mockIntStateId.toString() << 404 << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("invalid device") << DeviceId::createDeviceId().toString() << mockIntStateTypeId.toString() << 404 << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("invalid device id format") << "uuid" << StateTypeId::createStateTypeId().toString() << 400 << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("invalid statetype") << device->id().toString() << StateTypeId::createStateTypeId().toString() << 404 << Device::DeviceErrorStateTypeNotFound;
|
||||
QTest::newRow("invalid statetype format") << device->id().toString() << "uuid" << 400 << Device::DeviceErrorStateTypeNotFound;
|
||||
@ -548,7 +548,7 @@ void TestRestDevices::editDevices()
|
||||
|
||||
QVariantList deviceParams;
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", m_mockDevice1Port - 2);
|
||||
deviceParams.append(httpportParam);
|
||||
|
||||
@ -587,19 +587,19 @@ void TestRestDevices::reconfigureDevices_data()
|
||||
{
|
||||
QVariantList asyncChangeDeviceParams;
|
||||
QVariantMap asyncParamDifferent;
|
||||
asyncParamDifferent.insert("paramTypeId", asyncParamTypeId);
|
||||
asyncParamDifferent.insert("paramTypeId", mockDeviceAsyncParamTypeId);
|
||||
asyncParamDifferent.insert("value", true);
|
||||
asyncChangeDeviceParams.append(asyncParamDifferent);
|
||||
|
||||
QVariantList httpportChangeDeviceParams;
|
||||
QVariantMap httpportParamDifferent;
|
||||
httpportParamDifferent.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParamDifferent.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParamDifferent.insert("value", 8895); // if change -> change also newPort in reconfigureDevices()
|
||||
httpportChangeDeviceParams.append(httpportParamDifferent);
|
||||
|
||||
QVariantList brokenChangedDeviceParams;
|
||||
QVariantMap brokenParamDifferent;
|
||||
brokenParamDifferent.insert("paramTypeId", brokenParamTypeId);
|
||||
brokenParamDifferent.insert("paramTypeId", mockDeviceBrokenParamTypeId);
|
||||
brokenParamDifferent.insert("value", true);
|
||||
brokenChangedDeviceParams.append(brokenParamDifferent);
|
||||
|
||||
@ -635,15 +635,15 @@ void TestRestDevices::reconfigureDevices()
|
||||
params.insert("name", "Edit mock device");
|
||||
QVariantList deviceParams;
|
||||
QVariantMap asyncParam;
|
||||
asyncParam.insert("paramTypeId", asyncParamTypeId);
|
||||
asyncParam.insert("paramTypeId", mockDeviceAsyncParamTypeId);
|
||||
asyncParam.insert("value", false);
|
||||
deviceParams.append(asyncParam);
|
||||
QVariantMap brokenParam;
|
||||
brokenParam.insert("paramTypeId", brokenParamTypeId);
|
||||
brokenParam.insert("paramTypeId", mockDeviceBrokenParamTypeId);
|
||||
brokenParam.insert("value", broken);
|
||||
deviceParams.append(brokenParam);
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("paramTypeId", httpportParamTypeId);
|
||||
httpportParam.insert("paramTypeId", mockDeviceHttpportParamTypeId);
|
||||
httpportParam.insert("value", 8896);
|
||||
deviceParams.append(httpportParam);
|
||||
params.insert("deviceParams", deviceParams);
|
||||
@ -695,7 +695,7 @@ void TestRestDevices::reconfigureByDiscovery_data()
|
||||
|
||||
QVariantList discoveryParams;
|
||||
QVariantMap resultCountParam;
|
||||
resultCountParam.insert("paramTypeId", resultCountParamTypeId);
|
||||
resultCountParam.insert("paramTypeId", mockDiscoveryResultCountParamTypeId);
|
||||
resultCountParam.insert("value", 2);
|
||||
discoveryParams.append(resultCountParam);
|
||||
|
||||
|
||||
@ -150,8 +150,8 @@ void TestRestLogging::eventLogs()
|
||||
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
||||
|
||||
// trigger event in mock device
|
||||
int port = device->paramValue(httpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1Id.toString())));
|
||||
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(port).arg(mockEvent1EventTypeId.toString())));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
clientSpy.wait();
|
||||
|
||||
@ -169,7 +169,7 @@ void TestRestLogging::eventLogs()
|
||||
if (logEntry.value("deviceId").toString() == device->id().toString()) {
|
||||
found = true;
|
||||
// Make sure the notification contains all the stuff we expect
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockEvent1Id.toString());
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockEvent1EventTypeId.toString());
|
||||
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents));
|
||||
QCOMPARE(logEntry.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));
|
||||
@ -186,7 +186,7 @@ void TestRestLogging::eventLogs()
|
||||
params.insert("deviceIds", QVariantList() << device->id());
|
||||
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceEvents));
|
||||
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
params.insert("typeIds", QVariantList() << mockEvent1Id);
|
||||
params.insert("typeIds", QVariantList() << mockEvent1EventTypeId);
|
||||
|
||||
QVariant response = injectAndWait("Logging.GetLogEntries", params);
|
||||
verifyLoggingError(response);
|
||||
@ -202,16 +202,16 @@ void TestRestLogging::actionLog()
|
||||
{
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 7);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("actionTypeId", mockActionIdWithParams);
|
||||
params.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
params.insert("params", actionParams);
|
||||
|
||||
@ -232,7 +232,7 @@ void TestRestLogging::actionLog()
|
||||
QVariantMap logEntry = notification.toMap().value("params").toMap().value("logEntry").toMap();
|
||||
|
||||
// Make sure the notification contains all the stuff we expect
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockActionIdWithParams.toString());
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockWithParamsActionTypeId.toString());
|
||||
QCOMPARE(logEntry.value("deviceId").toString(), m_mockDeviceId.toString());
|
||||
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
|
||||
@ -240,7 +240,7 @@ void TestRestLogging::actionLog()
|
||||
|
||||
// EXECUTE without params
|
||||
params.clear(); clientSpy.clear();
|
||||
params.insert("actionTypeId", mockActionIdNoParams);
|
||||
params.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
response = injectAndWait("Actions.ExecuteAction", params);
|
||||
verifyDeviceError(response);
|
||||
@ -269,7 +269,7 @@ void TestRestLogging::actionLog()
|
||||
|
||||
// EXECUTE broken action
|
||||
params.clear(); clientSpy.clear();
|
||||
params.insert("actionTypeId", mockActionIdFailing);
|
||||
params.insert("actionTypeId", mockFailingActionTypeId);
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
response = injectAndWait("Actions.ExecuteAction", params);
|
||||
verifyDeviceError(response, Device::DeviceErrorSetupFailed);
|
||||
@ -281,7 +281,7 @@ void TestRestLogging::actionLog()
|
||||
logEntry = notification.toMap().value("params").toMap().value("logEntry").toMap();
|
||||
|
||||
// Make sure the notification contains all the stuff we expect
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockActionIdFailing.toString());
|
||||
QCOMPARE(logEntry.value("typeId").toString(), mockFailingActionTypeId.toString());
|
||||
QCOMPARE(logEntry.value("deviceId").toString(), m_mockDeviceId.toString());
|
||||
QCOMPARE(logEntry.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
QCOMPARE(logEntry.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
|
||||
@ -310,7 +310,7 @@ void TestRestLogging::actionLog()
|
||||
params.insert("deviceIds", QVariantList() << m_mockDeviceId);
|
||||
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
|
||||
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
params.insert("typeIds", QVariantList() << mockActionIdNoParams);
|
||||
params.insert("typeIds", QVariantList() << mockWithoutParamsActionTypeId);
|
||||
|
||||
query.clear();
|
||||
query.addQueryItem("filter", QJsonDocument::fromVariant(params).toJson(QJsonDocument::Compact));
|
||||
@ -324,7 +324,7 @@ void TestRestLogging::actionLog()
|
||||
params.insert("deviceIds", QVariantList() << m_mockDeviceId);
|
||||
params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceActions));
|
||||
params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeTrigger));
|
||||
params.insert("typeIds", QVariantList() << mockActionIdNoParams << mockActionIdWithParams << mockActionIdFailing);
|
||||
params.insert("typeIds", QVariantList() << mockWithoutParamsActionTypeId << mockWithParamsActionTypeId << mockFailingActionTypeId);
|
||||
|
||||
query.clear();
|
||||
query.addQueryItem("filter", QJsonDocument::fromVariant(params).toJson(QJsonDocument::Compact));
|
||||
|
||||
@ -89,7 +89,7 @@ void TestRestRules::cleanupMockHistory()
|
||||
{
|
||||
QNetworkAccessManager nam;
|
||||
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/clearactionhistory").arg(m_mockDevice1Port).arg(mockEvent1Id.toString())));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/clearactionhistory").arg(m_mockDevice1Port).arg(mockEvent1EventTypeId.toString())));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
spy.wait();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
@ -149,7 +149,7 @@ void TestRestRules::triggerMockEvent()
|
||||
// trigger event in mock device
|
||||
QNetworkAccessManager nam;
|
||||
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
|
||||
QNetworkRequest request = QNetworkRequest(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1Id.toString())));
|
||||
QNetworkRequest request = QNetworkRequest(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1EventTypeId.toString())));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
spy.wait();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
@ -162,7 +162,7 @@ QVariant TestRestRules::validIntStateBasedRule(const QString &name, const bool &
|
||||
|
||||
// StateDescriptor
|
||||
QVariantMap stateDescriptor;
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateId);
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
|
||||
stateDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorLess));
|
||||
stateDescriptor.insert("value", 25);
|
||||
@ -174,14 +174,14 @@ QVariant TestRestRules::validIntStateBasedRule(const QString &name, const bool &
|
||||
|
||||
// RuleAction
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdWithParams);
|
||||
action.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 5);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
@ -189,7 +189,7 @@ QVariant TestRestRules::validIntStateBasedRule(const QString &name, const bool &
|
||||
|
||||
// RuleExitAction
|
||||
QVariantMap exitAction;
|
||||
exitAction.insert("actionTypeId", mockActionIdNoParams);
|
||||
exitAction.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
exitAction.insert("deviceId", m_mockDeviceId);
|
||||
exitAction.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -340,7 +340,7 @@ void TestRestRules::addRemoveRules_data()
|
||||
{
|
||||
// RuleAction
|
||||
QVariantMap validActionNoParams;
|
||||
validActionNoParams.insert("actionTypeId", mockActionIdNoParams);
|
||||
validActionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
validActionNoParams.insert("deviceId", m_mockDeviceId);
|
||||
validActionNoParams.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -351,7 +351,7 @@ void TestRestRules::addRemoveRules_data()
|
||||
|
||||
// RuleExitAction
|
||||
QVariantMap validExitActionNoParams;
|
||||
validExitActionNoParams.insert("actionTypeId", mockActionIdNoParams);
|
||||
validExitActionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
validExitActionNoParams.insert("deviceId", m_mockDeviceId);
|
||||
validExitActionNoParams.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -362,7 +362,7 @@ void TestRestRules::addRemoveRules_data()
|
||||
|
||||
// StateDescriptor
|
||||
QVariantMap stateDescriptor;
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateId);
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
|
||||
stateDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorLess));
|
||||
stateDescriptor.insert("value", 20);
|
||||
@ -378,23 +378,23 @@ void TestRestRules::addRemoveRules_data()
|
||||
|
||||
// EventDescriptor
|
||||
QVariantMap validEventDescriptor1;
|
||||
validEventDescriptor1.insert("eventTypeId", mockEvent1Id);
|
||||
validEventDescriptor1.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
validEventDescriptor1.insert("deviceId", m_mockDeviceId);
|
||||
validEventDescriptor1.insert("paramDescriptors", QVariantList());
|
||||
|
||||
QVariantMap validEventDescriptor2;
|
||||
validEventDescriptor2.insert("eventTypeId", mockEvent2Id);
|
||||
validEventDescriptor2.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
validEventDescriptor2.insert("deviceId", m_mockDeviceId);
|
||||
QVariantList params;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockParamIntParamTypeId);
|
||||
param1.insert("paramTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
param1.insert("value", 3);
|
||||
param1.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
params.append(param1);
|
||||
validEventDescriptor2.insert("paramDescriptors", params);
|
||||
|
||||
QVariantMap validEventDescriptor3;
|
||||
validEventDescriptor3.insert("eventTypeId", mockEvent2Id);
|
||||
validEventDescriptor3.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
validEventDescriptor3.insert("deviceId", m_mockDeviceId);
|
||||
validEventDescriptor3.insert("paramDescriptors", QVariantList());
|
||||
|
||||
@ -404,48 +404,48 @@ void TestRestRules::addRemoveRules_data()
|
||||
eventDescriptorList.append(validEventDescriptor2);
|
||||
|
||||
QVariantMap invalidEventDescriptor;
|
||||
invalidEventDescriptor.insert("eventTypeId", mockEvent1Id);
|
||||
invalidEventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
invalidEventDescriptor.insert("deviceId", DeviceId());
|
||||
invalidEventDescriptor.insert("paramDescriptors", QVariantList());
|
||||
|
||||
// RuleAction event based
|
||||
QVariantMap validActionEventBased;
|
||||
validActionEventBased.insert("actionTypeId", mockActionIdWithParams);
|
||||
validActionEventBased.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
validActionEventBased.insert("deviceId", m_mockDeviceId);
|
||||
QVariantMap validActionEventBasedParam1;
|
||||
validActionEventBasedParam1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
validActionEventBasedParam1.insert("eventTypeId", mockEvent2Id);
|
||||
validActionEventBasedParam1.insert("eventParamTypeId", mockParamIntParamTypeId);
|
||||
validActionEventBasedParam1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
validActionEventBasedParam1.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
validActionEventBasedParam1.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
QVariantMap validActionEventBasedParam2;
|
||||
validActionEventBasedParam2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
validActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
validActionEventBasedParam2.insert("value", false);
|
||||
validActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1 << validActionEventBasedParam2);
|
||||
|
||||
QVariantMap invalidActionEventBased;
|
||||
invalidActionEventBased.insert("actionTypeId", mockActionIdNoParams);
|
||||
invalidActionEventBased.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
invalidActionEventBased.insert("deviceId", m_mockDeviceId);
|
||||
validActionEventBasedParam1.insert("value", 10);
|
||||
invalidActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1);
|
||||
|
||||
QVariantMap invalidActionEventBased2;
|
||||
invalidActionEventBased2.insert("actionTypeId", mockActionIdWithParams);
|
||||
invalidActionEventBased2.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
invalidActionEventBased2.insert("deviceId", m_mockDeviceId);
|
||||
QVariantMap invalidActionEventBasedParam2;
|
||||
invalidActionEventBasedParam2.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
invalidActionEventBasedParam2.insert("eventTypeId", mockEvent1Id);
|
||||
invalidActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
invalidActionEventBasedParam2.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
invalidActionEventBasedParam2.insert("eventParamTypeId", ParamTypeId::createParamTypeId());
|
||||
QVariantMap invalidActionEventBasedParam3;
|
||||
invalidActionEventBasedParam3.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
invalidActionEventBasedParam3.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
invalidActionEventBasedParam3.insert("value", 2);
|
||||
invalidActionEventBased2.insert("ruleActionParams", QVariantList() << invalidActionEventBasedParam2 << invalidActionEventBasedParam3);
|
||||
|
||||
QVariantMap invalidActionEventBased3;
|
||||
invalidActionEventBased3.insert("actionTypeId", mockActionIdWithParams);
|
||||
invalidActionEventBased3.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
invalidActionEventBased3.insert("deviceId", m_mockDeviceId);
|
||||
QVariantMap invalidActionEventBasedParam4;
|
||||
invalidActionEventBasedParam4.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
invalidActionEventBasedParam4.insert("eventTypeId", mockEvent1Id);
|
||||
invalidActionEventBasedParam4.insert("eventParamTypeId", mockParamIntParamTypeId);
|
||||
invalidActionEventBasedParam4.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
invalidActionEventBasedParam4.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
invalidActionEventBasedParam4.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
invalidActionEventBased3.insert("ruleActionParams", QVariantList() << invalidActionEventBasedParam4);
|
||||
|
||||
QTest::addColumn<bool>("enabled");
|
||||
@ -574,7 +574,7 @@ void TestRestRules::editRules_data()
|
||||
{
|
||||
// RuleAction
|
||||
QVariantMap validActionNoParams;
|
||||
validActionNoParams.insert("actionTypeId", mockActionIdNoParams);
|
||||
validActionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
validActionNoParams.insert("deviceId", m_mockDeviceId);
|
||||
validActionNoParams.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -585,7 +585,7 @@ void TestRestRules::editRules_data()
|
||||
|
||||
// RuleExitAction
|
||||
QVariantMap validExitActionNoParams;
|
||||
validExitActionNoParams.insert("actionTypeId", mockActionIdNoParams);
|
||||
validExitActionNoParams.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
validExitActionNoParams.insert("deviceId", m_mockDeviceId);
|
||||
validExitActionNoParams.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -596,7 +596,7 @@ void TestRestRules::editRules_data()
|
||||
|
||||
// StateDescriptor
|
||||
QVariantMap stateDescriptor;
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateId);
|
||||
stateDescriptor.insert("stateTypeId", mockIntStateTypeId);
|
||||
stateDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptor.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorLess));
|
||||
stateDescriptor.insert("value", 20);
|
||||
@ -612,23 +612,23 @@ void TestRestRules::editRules_data()
|
||||
|
||||
// EventDescriptor
|
||||
QVariantMap validEventDescriptor1;
|
||||
validEventDescriptor1.insert("eventTypeId", mockEvent1Id);
|
||||
validEventDescriptor1.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
validEventDescriptor1.insert("deviceId", m_mockDeviceId);
|
||||
validEventDescriptor1.insert("paramDescriptors", QVariantList());
|
||||
|
||||
QVariantMap validEventDescriptor2;
|
||||
validEventDescriptor2.insert("eventTypeId", mockEvent2Id);
|
||||
validEventDescriptor2.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
validEventDescriptor2.insert("deviceId", m_mockDeviceId);
|
||||
QVariantList params;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockParamIntParamTypeId);
|
||||
param1.insert("paramTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
param1.insert("value", 3);
|
||||
param1.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
params.append(param1);
|
||||
validEventDescriptor2.insert("paramDescriptors", params);
|
||||
|
||||
QVariantMap validEventDescriptor3;
|
||||
validEventDescriptor3.insert("eventTypeId", mockEvent2Id);
|
||||
validEventDescriptor3.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
validEventDescriptor3.insert("deviceId", m_mockDeviceId);
|
||||
validEventDescriptor3.insert("paramDescriptors", QVariantList());
|
||||
|
||||
@ -638,48 +638,48 @@ void TestRestRules::editRules_data()
|
||||
eventDescriptorList.append(validEventDescriptor2);
|
||||
|
||||
QVariantMap invalidEventDescriptor;
|
||||
invalidEventDescriptor.insert("eventTypeId", mockEvent1Id);
|
||||
invalidEventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
invalidEventDescriptor.insert("deviceId", DeviceId());
|
||||
invalidEventDescriptor.insert("paramDescriptors", QVariantList());
|
||||
|
||||
// RuleAction event based
|
||||
QVariantMap validActionEventBased;
|
||||
validActionEventBased.insert("actionTypeId", mockActionIdWithParams);
|
||||
validActionEventBased.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
validActionEventBased.insert("deviceId", m_mockDeviceId);
|
||||
QVariantMap validActionEventBasedParam1;
|
||||
validActionEventBasedParam1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
validActionEventBasedParam1.insert("eventTypeId", mockEvent2Id);
|
||||
validActionEventBasedParam1.insert("eventParamTypeId", mockParamIntParamTypeId);
|
||||
validActionEventBasedParam1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
validActionEventBasedParam1.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
validActionEventBasedParam1.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
QVariantMap validActionEventBasedParam2;
|
||||
validActionEventBasedParam2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
validActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
validActionEventBasedParam2.insert("value", false);
|
||||
validActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1 << validActionEventBasedParam2);
|
||||
|
||||
QVariantMap invalidActionEventBased;
|
||||
invalidActionEventBased.insert("actionTypeId", mockActionIdNoParams);
|
||||
invalidActionEventBased.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
invalidActionEventBased.insert("deviceId", m_mockDeviceId);
|
||||
validActionEventBasedParam1.insert("value", 10);
|
||||
invalidActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1);
|
||||
|
||||
QVariantMap invalidActionEventBased2;
|
||||
invalidActionEventBased2.insert("actionTypeId", mockActionIdWithParams);
|
||||
invalidActionEventBased2.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
invalidActionEventBased2.insert("deviceId", m_mockDeviceId);
|
||||
QVariantMap invalidActionEventBasedParam2;
|
||||
invalidActionEventBasedParam2.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
invalidActionEventBasedParam2.insert("eventTypeId", mockEvent1Id);
|
||||
invalidActionEventBasedParam2.insert("eventParamTypeId", mockEvent1Id);
|
||||
invalidActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
invalidActionEventBasedParam2.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
invalidActionEventBasedParam2.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
QVariantMap invalidActionEventBasedParam3;
|
||||
invalidActionEventBasedParam3.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
invalidActionEventBasedParam3.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
invalidActionEventBasedParam3.insert("value", 2);
|
||||
invalidActionEventBased2.insert("ruleActionParams", QVariantList() << invalidActionEventBasedParam2 << invalidActionEventBasedParam3);
|
||||
|
||||
QVariantMap invalidActionEventBased3;
|
||||
invalidActionEventBased3.insert("actionTypeId", mockActionIdWithParams);
|
||||
invalidActionEventBased3.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
invalidActionEventBased3.insert("deviceId", m_mockDeviceId);
|
||||
QVariantMap invalidActionEventBasedParam4;
|
||||
invalidActionEventBasedParam4.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
invalidActionEventBasedParam4.insert("eventTypeId", mockEvent1Id);
|
||||
invalidActionEventBasedParam4.insert("eventParamTypeId", mockEvent1Id);
|
||||
invalidActionEventBasedParam4.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
invalidActionEventBasedParam4.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
invalidActionEventBasedParam4.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
invalidActionEventBased3.insert("ruleActionParams", QVariantList() << invalidActionEventBasedParam4);
|
||||
|
||||
QTest::addColumn<bool>("enabled");
|
||||
@ -728,15 +728,15 @@ void TestRestRules::editRules()
|
||||
// Add the rule we want to edit
|
||||
QVariantList eventParamDescriptors;
|
||||
QVariantMap eventDescriptor1;
|
||||
eventDescriptor1.insert("eventTypeId", mockEvent1Id);
|
||||
eventDescriptor1.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
eventDescriptor1.insert("deviceId", m_mockDeviceId);
|
||||
eventDescriptor1.insert("paramDescriptors", QVariantList());
|
||||
QVariantMap eventDescriptor2;
|
||||
eventDescriptor2.insert("eventTypeId", mockEvent2Id);
|
||||
eventDescriptor2.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
eventDescriptor2.insert("deviceId", m_mockDeviceId);
|
||||
eventDescriptor2.insert("paramDescriptors", QVariantList());
|
||||
QVariantMap eventParam1;
|
||||
eventParam1.insert("paramTypeId", mockParamIntParamTypeId);
|
||||
eventParam1.insert("paramTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
eventParam1.insert("value", 3);
|
||||
eventParam1.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
eventParamDescriptors.append(eventParam1);
|
||||
@ -750,12 +750,12 @@ void TestRestRules::editRules()
|
||||
QVariantMap stateDescriptor1;
|
||||
stateDescriptor1.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptor1.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
stateDescriptor1.insert("stateTypeId", mockIntStateId);
|
||||
stateDescriptor1.insert("stateTypeId", mockIntStateTypeId);
|
||||
stateDescriptor1.insert("value", 1);
|
||||
QVariantMap stateDescriptor2;
|
||||
stateDescriptor2.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptor2.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
stateDescriptor2.insert("stateTypeId", mockBoolStateId);
|
||||
stateDescriptor2.insert("stateTypeId", mockBoolStateTypeId);
|
||||
stateDescriptor2.insert("value", true);
|
||||
QVariantMap stateEvaluator1;
|
||||
stateEvaluator1.insert("stateDescriptor", stateDescriptor1);
|
||||
@ -770,39 +770,39 @@ void TestRestRules::editRules()
|
||||
stateEvaluator0.insert("operator", JsonTypes::stateOperatorToString(Types::StateOperatorAnd));
|
||||
|
||||
QVariantMap action1;
|
||||
action1.insert("actionTypeId", mockActionIdNoParams);
|
||||
action1.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action1.insert("deviceId", m_mockDeviceId);
|
||||
action1.insert("ruleActionParams", QVariantList());
|
||||
QVariantMap action2;
|
||||
action2.insert("actionTypeId", mockActionIdWithParams);
|
||||
action2.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
action2.insert("deviceId", m_mockDeviceId);
|
||||
QVariantList action2Params;
|
||||
QVariantMap action2Param1;
|
||||
action2Param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
action2Param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
action2Param1.insert("value", 5);
|
||||
action2Params.append(action2Param1);
|
||||
QVariantMap action2Param2;
|
||||
action2Param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
action2Param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
action2Param2.insert("value", true);
|
||||
action2Params.append(action2Param2);
|
||||
action2.insert("ruleActionParams", action2Params);
|
||||
|
||||
// RuleAction event based
|
||||
QVariantMap validActionEventBased;
|
||||
validActionEventBased.insert("actionTypeId", mockActionIdWithParams);
|
||||
validActionEventBased.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
validActionEventBased.insert("deviceId", m_mockDeviceId);
|
||||
QVariantMap validActionEventBasedParam1;
|
||||
validActionEventBasedParam1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
validActionEventBasedParam1.insert("eventTypeId", mockEvent2Id);
|
||||
validActionEventBasedParam1.insert("eventParamTypeId", mockEvent2Id);
|
||||
validActionEventBasedParam1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
validActionEventBasedParam1.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
validActionEventBasedParam1.insert("eventParamTypeId", mockEvent2EventIntParamParamTypeId);
|
||||
QVariantMap validActionEventBasedParam2;
|
||||
validActionEventBasedParam2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
validActionEventBasedParam2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
validActionEventBasedParam2.insert("value", false);
|
||||
validActionEventBased.insert("ruleActionParams", QVariantList() << validActionEventBasedParam1 << validActionEventBasedParam2);
|
||||
|
||||
QVariantList validEventDescriptors3;
|
||||
QVariantMap validEventDescriptor3;
|
||||
validEventDescriptor3.insert("eventTypeId", mockEvent2Id);
|
||||
validEventDescriptor3.insert("eventTypeId", mockEvent2EventTypeId);
|
||||
validEventDescriptor3.insert("deviceId", m_mockDeviceId);
|
||||
validEventDescriptor3.insert("paramDescriptors", QVariantList());
|
||||
validEventDescriptors3.append(validEventDescriptor3);
|
||||
@ -885,7 +885,7 @@ void TestRestRules::enableDisableRule()
|
||||
QVariantMap addRuleParams;
|
||||
QVariantList events;
|
||||
QVariantMap event1;
|
||||
event1.insert("eventTypeId", mockEvent1Id);
|
||||
event1.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
event1.insert("deviceId", m_mockDeviceId);
|
||||
events.append(event1);
|
||||
addRuleParams.insert("eventDescriptors", events);
|
||||
@ -893,7 +893,7 @@ void TestRestRules::enableDisableRule()
|
||||
|
||||
QVariantList actions;
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
actions.append(action);
|
||||
addRuleParams.insert("actions", actions);
|
||||
@ -912,7 +912,7 @@ void TestRestRules::enableDisableRule()
|
||||
|
||||
// Trigger an event
|
||||
triggerMockEvent();
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
|
||||
cleanupMockHistory();
|
||||
|
||||
@ -934,7 +934,7 @@ void TestRestRules::enableDisableRule()
|
||||
|
||||
// trigger event in mock device
|
||||
triggerMockEvent();
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
|
||||
cleanupRules();
|
||||
}
|
||||
@ -977,7 +977,7 @@ void TestRestRules::executeRuleActions()
|
||||
QCOMPARE(JsonTypes::ruleErrorToString(ruleError), response.toMap().value("error").toString());
|
||||
|
||||
if (ruleError == RuleEngine::RuleErrorNoError) {
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
} else {
|
||||
verifyRuleNotExecuted();
|
||||
}
|
||||
@ -991,7 +991,7 @@ void TestRestRules::executeRuleActions()
|
||||
QCOMPARE(JsonTypes::ruleErrorToString(ruleError), response.toMap().value("error").toString());
|
||||
|
||||
if (ruleError == RuleEngine::RuleErrorNoError) {
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
} else {
|
||||
verifyRuleNotExecuted();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -56,8 +56,8 @@ void TestStates::getStateValue_data()
|
||||
QTest::addColumn<StateTypeId>("stateTypeId");
|
||||
QTest::addColumn<Device::DeviceError>("error");
|
||||
|
||||
QTest::newRow("existing state") << device->id() << mockIntStateId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid device") << DeviceId::createDeviceId() << mockIntStateId << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("existing state") << device->id() << mockIntStateTypeId << Device::DeviceErrorNoError;
|
||||
QTest::newRow("invalid device") << DeviceId::createDeviceId() << mockIntStateTypeId << Device::DeviceErrorDeviceNotFound;
|
||||
QTest::newRow("invalid statetype") << device->id() << StateTypeId::createStateTypeId() << Device::DeviceErrorStateTypeNotFound;
|
||||
}
|
||||
|
||||
@ -80,26 +80,26 @@ void TestStates::save_load_states()
|
||||
{
|
||||
DeviceClass mockDeviceClass = NymeaCore::instance()->deviceManager()->findDeviceClass(mockDeviceClassId);
|
||||
|
||||
QVERIFY2(mockDeviceClass.getStateType(mockIntStateId).cached(), "Mock int state is not cached (required to be true for this test)");
|
||||
QVERIFY2(!mockDeviceClass.getStateType(mockBoolStateId).cached(), "Mock bool state is cached (required to be false for this test)");
|
||||
QVERIFY2(mockDeviceClass.getStateType(mockIntStateTypeId).cached(), "Mock int state is not cached (required to be true for this test)");
|
||||
QVERIFY2(!mockDeviceClass.getStateType(mockBoolStateTypeId).cached(), "Mock bool state is cached (required to be false for this test)");
|
||||
|
||||
Device* device = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).first();
|
||||
int port = device->paramValue(httpportParamTypeId).toInt();
|
||||
int port = device->paramValue(mockDeviceHttpportParamTypeId).toInt();
|
||||
QNetworkAccessManager nam;
|
||||
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
|
||||
|
||||
|
||||
// First set the state values to something that is *not* the default
|
||||
int newIntValue = mockDeviceClass.getStateType(mockIntStateId).defaultValue().toInt() + 1;
|
||||
bool newBoolValue = !mockDeviceClass.getStateType(mockBoolStateId).defaultValue().toBool();
|
||||
int newIntValue = mockDeviceClass.getStateType(mockIntStateTypeId).defaultValue().toInt() + 1;
|
||||
bool newBoolValue = !mockDeviceClass.getStateType(mockBoolStateTypeId).defaultValue().toBool();
|
||||
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockIntStateId.toString()).arg(newIntValue)));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockIntStateTypeId.toString()).arg(newIntValue)));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
spy.wait();
|
||||
|
||||
spy.clear();
|
||||
request = QNetworkRequest(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockBoolStateId.toString()).arg(newBoolValue)));
|
||||
request = QNetworkRequest(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(mockBoolStateTypeId.toString()).arg(newBoolValue)));
|
||||
reply = nam.get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
spy.wait();
|
||||
@ -108,11 +108,11 @@ void TestStates::save_load_states()
|
||||
QVariantMap params;
|
||||
params.insert("deviceId", device->id());
|
||||
|
||||
params["stateTypeId"] = mockIntStateId;
|
||||
params["stateTypeId"] = mockIntStateTypeId;
|
||||
QVariant response = injectAndWait("Devices.GetStateValue", params);
|
||||
QCOMPARE(response.toMap().value("params").toMap().value("value").toInt(), newIntValue);
|
||||
|
||||
params["stateTypeId"] = mockBoolStateId;
|
||||
params["stateTypeId"] = mockBoolStateTypeId;
|
||||
response = injectAndWait("Devices.GetStateValue", params);
|
||||
QCOMPARE(response.toMap().value("params").toMap().value("value").toBool(), newBoolValue);
|
||||
|
||||
@ -120,14 +120,14 @@ void TestStates::save_load_states()
|
||||
restartServer();
|
||||
|
||||
// And check if the cached int state has successfully been restored
|
||||
params["stateTypeId"] = mockIntStateId;
|
||||
params["stateTypeId"] = mockIntStateTypeId;
|
||||
response = injectAndWait("Devices.GetStateValue", params);
|
||||
QCOMPARE(response.toMap().value("params").toMap().value("value").toInt(), newIntValue);
|
||||
|
||||
// and that the non-cached bool state is back to its default
|
||||
params["stateTypeId"] = mockBoolStateId;
|
||||
params["stateTypeId"] = mockBoolStateTypeId;
|
||||
response = injectAndWait("Devices.GetStateValue", params);
|
||||
QCOMPARE(response.toMap().value("params").toMap().value("value").toBool(), mockDeviceClass.getStateType(mockBoolStateId).defaultValue().toBool());
|
||||
QCOMPARE(response.toMap().value("params").toMap().value("value").toBool(), mockDeviceClass.getStateType(mockBoolStateTypeId).defaultValue().toBool());
|
||||
}
|
||||
|
||||
#include "teststates.moc"
|
||||
|
||||
@ -201,7 +201,7 @@ void TestTimeManager::loadSaveTimeDescriptor()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap ruleMap; QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -355,7 +355,7 @@ void TestTimeManager::addTimeDescriptor()
|
||||
|
||||
// ADD the rule
|
||||
QVariantMap ruleMap; QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
ruleMap.insert("name", "TimeBased rule");
|
||||
@ -395,21 +395,21 @@ void TestTimeManager::testCalendarDateTime()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
// Exit action (with params)
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 12);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
exitAction.insert("actionTypeId", mockActionIdWithParams);
|
||||
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
exitAction.insert("deviceId", m_mockDeviceId);
|
||||
exitAction.insert("ruleActionParams", actionParams);
|
||||
|
||||
@ -435,14 +435,14 @@ void TestTimeManager::testCalendarDateTime()
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 30));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs((duration + 1) * 60));
|
||||
@ -471,17 +471,17 @@ void TestTimeManager::testCalendarItemHourly()
|
||||
|
||||
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap repeatingOptionHourly;
|
||||
repeatingOptionHourly.insert("mode", "RepeatingModeHourly");
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
exitAction.insert("actionTypeId", mockActionIdWithParams);
|
||||
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 7);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
exitAction.insert("deviceId", m_mockDeviceId);
|
||||
@ -507,7 +507,7 @@ void TestTimeManager::testCalendarItemHourly()
|
||||
if (duration == 60) {
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
// Should be active since adding
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
} else {
|
||||
// check the next 24 hours in 8h steps
|
||||
for (int i = 0; i < 24; i+=8) {
|
||||
@ -516,14 +516,14 @@ void TestTimeManager::testCalendarItemHourly()
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 5)));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 7)));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 10)));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(currentDateTime.date(), QTime(future.time().hour(), 11)));
|
||||
@ -564,17 +564,17 @@ void TestTimeManager::testCalendarItemDaily()
|
||||
initTimeManager();
|
||||
|
||||
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
exitAction.insert("actionTypeId", mockActionIdWithParams);
|
||||
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 12);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
exitAction.insert("deviceId", m_mockDeviceId);
|
||||
@ -597,7 +597,7 @@ void TestTimeManager::testCalendarItemDaily()
|
||||
if (time == "08:00") {
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
// Should be active since adding
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
} else {
|
||||
// check the next 7 days
|
||||
for (int i = 0; i < 7; i++) {
|
||||
@ -606,14 +606,14 @@ void TestTimeManager::testCalendarItemDaily()
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
|
||||
@ -663,21 +663,21 @@ void TestTimeManager::testCalendarItemWeekly()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
// Exit action (with params)
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 12);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
exitAction.insert("actionTypeId", mockActionIdWithParams);
|
||||
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
exitAction.insert("deviceId", m_mockDeviceId);
|
||||
exitAction.insert("ruleActionParams", actionParams);
|
||||
|
||||
@ -707,7 +707,7 @@ void TestTimeManager::testCalendarItemWeekly()
|
||||
if (repeatingOption.isEmpty()) {
|
||||
NymeaCore::instance()->timeManager()->setTime(future);
|
||||
// Should be active since adding
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
} else {
|
||||
if (!overlapping) {
|
||||
// check the next 7 days (because not overlapping the week)
|
||||
@ -722,14 +722,14 @@ void TestTimeManager::testCalendarItemWeekly()
|
||||
// should trigger today
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(6* 60));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(11 * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(future.addSecs(12 * 60));
|
||||
@ -762,7 +762,7 @@ void TestTimeManager::testCalendarItemWeekly()
|
||||
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
|
||||
// still active
|
||||
@ -775,7 +775,7 @@ void TestTimeManager::testCalendarItemWeekly()
|
||||
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(2).addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -818,21 +818,21 @@ void TestTimeManager::testCalendarItemMonthly()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
// Exit action (with params)
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 12);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
exitAction.insert("actionTypeId", mockActionIdWithParams);
|
||||
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
exitAction.insert("deviceId", m_mockDeviceId);
|
||||
exitAction.insert("ruleActionParams", actionParams);
|
||||
|
||||
@ -871,14 +871,14 @@ void TestTimeManager::testCalendarItemMonthly()
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(6* 60));
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(11 * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(12 * 60));
|
||||
@ -906,7 +906,7 @@ void TestTimeManager::testCalendarItemMonthly()
|
||||
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
|
||||
// still active
|
||||
@ -915,7 +915,7 @@ void TestTimeManager::testCalendarItemMonthly()
|
||||
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(startDate.addDays(3).addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
}
|
||||
|
||||
cleanupMockHistory();
|
||||
@ -946,21 +946,21 @@ void TestTimeManager::testCalendarYearlyDateTime()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
// Exit action (with params)
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 12);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
exitAction.insert("actionTypeId", mockActionIdWithParams);
|
||||
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
exitAction.insert("deviceId", m_mockDeviceId);
|
||||
exitAction.insert("ruleActionParams", actionParams);
|
||||
|
||||
@ -991,7 +991,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
@ -999,7 +999,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
cleanupMockHistory();
|
||||
// inactive unchanged
|
||||
@ -1015,7 +1015,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
|
||||
verifyRuleNotExecuted();
|
||||
// active
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
cleanupMockHistory();
|
||||
// active unchanged
|
||||
@ -1023,7 +1023,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
|
||||
verifyRuleNotExecuted();
|
||||
// inactive
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(duration * 60));
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
|
||||
// inactive unchanged
|
||||
@ -1049,7 +1049,7 @@ void TestTimeManager::testCalendarItemStates_data()
|
||||
|
||||
// Action
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1057,14 +1057,14 @@ void TestTimeManager::testCalendarItemStates_data()
|
||||
QVariantMap exitAction;
|
||||
QVariantList actionParams;
|
||||
QVariantMap param1;
|
||||
param1.insert("paramTypeId", mockActionParam1ParamTypeId);
|
||||
param1.insert("paramTypeId", mockWithParamsActionParam1ParamTypeId);
|
||||
param1.insert("value", 12);
|
||||
actionParams.append(param1);
|
||||
QVariantMap param2;
|
||||
param2.insert("paramTypeId", mockActionParam2ParamTypeId);
|
||||
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
|
||||
param2.insert("value", true);
|
||||
actionParams.append(param2);
|
||||
exitAction.insert("actionTypeId", mockActionIdWithParams);
|
||||
exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
|
||||
exitAction.insert("deviceId", m_mockDeviceId);
|
||||
exitAction.insert("ruleActionParams", actionParams);
|
||||
|
||||
@ -1073,12 +1073,12 @@ void TestTimeManager::testCalendarItemStates_data()
|
||||
QVariantMap stateDescriptorInt;
|
||||
stateDescriptorInt.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptorInt.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorGreaterOrEqual));
|
||||
stateDescriptorInt.insert("stateTypeId", mockIntStateId);
|
||||
stateDescriptorInt.insert("stateTypeId", mockIntStateTypeId);
|
||||
stateDescriptorInt.insert("value", 65);
|
||||
QVariantMap stateDescriptorBool;
|
||||
stateDescriptorBool.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptorBool.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
stateDescriptorBool.insert("stateTypeId", mockBoolStateId);
|
||||
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
|
||||
stateDescriptorBool.insert("value", true);
|
||||
QVariantMap stateEvaluatorInt;
|
||||
stateEvaluatorInt.insert("stateDescriptor", stateDescriptorInt);
|
||||
@ -1141,13 +1141,13 @@ void TestTimeManager::testCalendarItemStates()
|
||||
|
||||
// Actions
|
||||
if (trigger && active) {
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
}
|
||||
|
||||
// Exit actions
|
||||
if (trigger && !active) {
|
||||
verifyRuleExecuted(mockActionIdWithParams);
|
||||
verifyRuleExecuted(mockWithParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
}
|
||||
|
||||
@ -1164,12 +1164,12 @@ void TestTimeManager::testCalendarItemEvent_data()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
QVariantMap eventDescriptor;
|
||||
eventDescriptor.insert("eventTypeId", mockEvent1Id);
|
||||
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
eventDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
|
||||
// The rule
|
||||
@ -1214,7 +1214,7 @@ void TestTimeManager::testCalendarItemEvent()
|
||||
triggerMockEvent1();
|
||||
|
||||
if (trigger) {
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
} else {
|
||||
verifyRuleNotExecuted();
|
||||
}
|
||||
@ -1228,20 +1228,20 @@ void TestTimeManager::testCalendarItemStatesEvent_data()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
// Event descriptor
|
||||
QVariantMap eventDescriptor;
|
||||
eventDescriptor.insert("eventTypeId", mockEvent1Id);
|
||||
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
eventDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
|
||||
// State evaluator
|
||||
QVariantMap stateDescriptorBool;
|
||||
stateDescriptorBool.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptorBool.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
stateDescriptorBool.insert("stateTypeId", mockBoolStateId);
|
||||
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
|
||||
stateDescriptorBool.insert("value", true);
|
||||
|
||||
QVariantMap stateEvaluator;
|
||||
@ -1287,7 +1287,7 @@ void TestTimeManager::testCalendarItemStatesEvent()
|
||||
triggerMockEvent1();
|
||||
|
||||
if (trigger) {
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
} else {
|
||||
verifyRuleNotExecuted();
|
||||
@ -1302,7 +1302,7 @@ void TestTimeManager::testCalendarItemCrossesMidnight()
|
||||
|
||||
// Action
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1370,12 +1370,12 @@ void TestTimeManager::testEventBasedWithCalendarItemCrossingMidnight()
|
||||
|
||||
// Event descriptor
|
||||
QVariantMap eventDescriptor;
|
||||
eventDescriptor.insert("eventTypeId", mockEvent1Id);
|
||||
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
|
||||
eventDescriptor.insert("deviceId", m_mockDeviceId);
|
||||
|
||||
// Action
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1407,17 +1407,17 @@ void TestTimeManager::testEventBasedWithCalendarItemCrossingMidnight()
|
||||
cleanupMockHistory();
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(23, 00)));
|
||||
triggerMockEvent1();
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
|
||||
cleanupMockHistory();
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(23, 50)));
|
||||
triggerMockEvent1();
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
|
||||
cleanupMockHistory();
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(00, 00)));
|
||||
triggerMockEvent1();
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
|
||||
cleanupMockHistory();
|
||||
NymeaCore::instance()->timeManager()->setTime(QDateTime(QDate::currentDate(), QTime(01, 00)));
|
||||
@ -1442,7 +1442,7 @@ void TestTimeManager::testEventItemDateTime()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap ruleMap; QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1463,7 +1463,7 @@ void TestTimeManager::testEventItemDateTime()
|
||||
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
|
||||
// not triggering
|
||||
@ -1499,7 +1499,7 @@ void TestTimeManager::testEventItemHourly()
|
||||
|
||||
// Action
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1529,7 +1529,7 @@ void TestTimeManager::testEventItemHourly()
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
@ -1568,7 +1568,7 @@ void TestTimeManager::testEventItemDaily()
|
||||
|
||||
// Action
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1599,7 +1599,7 @@ void TestTimeManager::testEventItemDaily()
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
@ -1641,7 +1641,7 @@ void TestTimeManager::testEventItemWeekly()
|
||||
|
||||
// Action
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1675,7 +1675,7 @@ void TestTimeManager::testEventItemWeekly()
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
@ -1723,7 +1723,7 @@ void TestTimeManager::testEventItemMonthly()
|
||||
|
||||
// Action
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1757,7 +1757,7 @@ void TestTimeManager::testEventItemMonthly()
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(60));
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
NymeaCore::instance()->timeManager()->setTime(beforeEventDateTime.addSecs(120));
|
||||
@ -1802,7 +1802,7 @@ void TestTimeManager::testEventItemYearly()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap ruleMap; QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1823,7 +1823,7 @@ void TestTimeManager::testEventItemYearly()
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(60));
|
||||
@ -1837,7 +1837,7 @@ void TestTimeManager::testEventItemYearly()
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(nextYear);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
NymeaCore::instance()->timeManager()->setTime(nextYear.addSecs(60));
|
||||
@ -1861,7 +1861,7 @@ void TestTimeManager::testEventItemStates_data()
|
||||
|
||||
// Action (without params)
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1875,7 +1875,7 @@ void TestTimeManager::testEventItemStates_data()
|
||||
QVariantMap stateDescriptorBool;
|
||||
stateDescriptorBool.insert("deviceId", m_mockDeviceId);
|
||||
stateDescriptorBool.insert("operator", JsonTypes::valueOperatorToString(Types::ValueOperatorEquals));
|
||||
stateDescriptorBool.insert("stateTypeId", mockBoolStateId);
|
||||
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
|
||||
stateDescriptorBool.insert("value", true);
|
||||
|
||||
QVariantMap stateEvaluator;
|
||||
@ -1925,7 +1925,7 @@ void TestTimeManager::testEventItemStates()
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
|
||||
if (trigger) {
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
} else {
|
||||
verifyRuleNotExecuted();
|
||||
@ -1944,7 +1944,7 @@ void TestTimeManager::testEnableDisableTimeRule()
|
||||
|
||||
// Action
|
||||
QVariantMap action;
|
||||
action.insert("actionTypeId", mockActionIdNoParams);
|
||||
action.insert("actionTypeId", mockWithoutParamsActionTypeId);
|
||||
action.insert("deviceId", m_mockDeviceId);
|
||||
action.insert("ruleActionParams", QVariantList());
|
||||
|
||||
@ -1964,7 +1964,7 @@ void TestTimeManager::testEnableDisableTimeRule()
|
||||
verifyRuleNotExecuted();
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
// not triggering
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(1));
|
||||
@ -1991,7 +1991,7 @@ void TestTimeManager::testEnableDisableTimeRule()
|
||||
// trigger
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime.addSecs(-1));
|
||||
NymeaCore::instance()->timeManager()->setTime(dateTime);
|
||||
verifyRuleExecuted(mockActionIdNoParams);
|
||||
verifyRuleExecuted(mockWithoutParamsActionTypeId);
|
||||
cleanupMockHistory();
|
||||
|
||||
// REMOVE rule
|
||||
@ -2070,7 +2070,7 @@ void TestTimeManager::setIntState(const int &value)
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
params.insert("stateTypeId", mockIntStateId);
|
||||
params.insert("stateTypeId", mockIntStateTypeId);
|
||||
QVariant response = injectAndWait("Devices.GetStateValue", params);
|
||||
verifyDeviceError(response);
|
||||
|
||||
@ -2082,7 +2082,7 @@ void TestTimeManager::setIntState(const int &value)
|
||||
QSignalSpy stateSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
||||
|
||||
spy.clear();
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateId.toString()).arg(value)));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockIntStateTypeId.toString()).arg(value)));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
spy.wait();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
@ -2098,7 +2098,7 @@ void TestTimeManager::setIntState(const int &value)
|
||||
QVERIFY2(notification.contains("deviceId"), "Devices.StateChanged notification does not contain deviceId");
|
||||
QVERIFY2(DeviceId(notification.value("deviceId").toString()) == m_mockDeviceId, "Devices.StateChanged notification does not contain the correct deviceId");
|
||||
QVERIFY2(notification.contains("stateTypeId"), "Devices.StateChanged notification does not contain stateTypeId");
|
||||
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockIntStateId, "Devices.StateChanged notification does not contain the correct stateTypeId");
|
||||
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockIntStateTypeId, "Devices.StateChanged notification does not contain the correct stateTypeId");
|
||||
QVERIFY2(notification.contains("value"), "Devices.StateChanged notification does not contain new state value");
|
||||
QVERIFY2(notification.value("value").toInt() == value, "Devices.StateChanged notification does not contain the new value");
|
||||
}
|
||||
@ -2111,7 +2111,7 @@ void TestTimeManager::setBoolState(const bool &value)
|
||||
// Get the current state value to check if we have to wait for state changed notfication
|
||||
QVariantMap params;
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
params.insert("stateTypeId", mockBoolStateId);
|
||||
params.insert("stateTypeId", mockBoolStateTypeId);
|
||||
QVariant response = injectAndWait("Devices.GetStateValue", params);
|
||||
verifyDeviceError(response);
|
||||
|
||||
@ -2122,7 +2122,7 @@ void TestTimeManager::setBoolState(const bool &value)
|
||||
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*)));
|
||||
QSignalSpy stateSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
||||
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockBoolStateId.toString()).arg(value)));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockDevice1Port).arg(mockBoolStateTypeId.toString()).arg(value)));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
spy.wait();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
@ -2138,7 +2138,7 @@ void TestTimeManager::setBoolState(const bool &value)
|
||||
QVERIFY2(notification.contains("deviceId"), "Devices.StateChanged notification does not contain deviceId");
|
||||
QVERIFY2(DeviceId(notification.value("deviceId").toString()) == m_mockDeviceId, "Devices.StateChanged notification does not contain the correct deviceId");
|
||||
QVERIFY2(notification.contains("stateTypeId"), "Devices.StateChanged notification does not contain stateTypeId");
|
||||
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockBoolStateId, "Devices.StateChanged notification does not contain the correct stateTypeId");
|
||||
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockBoolStateTypeId, "Devices.StateChanged notification does not contain the correct stateTypeId");
|
||||
QVERIFY2(notification.contains("value"), "Devices.StateChanged notification does not contain new state value");
|
||||
QVERIFY2(notification.value("value").toBool() == value, "Devices.StateChanged notification does not contain the new value");
|
||||
}
|
||||
@ -2153,7 +2153,7 @@ void TestTimeManager::triggerMockEvent1()
|
||||
|
||||
QSignalSpy eventSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
||||
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1Id.toString())));
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockDevice1Port).arg(mockEvent1EventTypeId.toString())));
|
||||
QNetworkReply *reply = nam.get(request);
|
||||
spy.wait();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
@ -2168,7 +2168,7 @@ void TestTimeManager::triggerMockEvent1()
|
||||
QVERIFY2(eventMap.contains("deviceId"), "Events.EventTriggered notification does not contain deviceId");
|
||||
QVERIFY2(DeviceId(eventMap.value("deviceId").toString()) == m_mockDeviceId, "Events.EventTriggered notification does not contain the correct deviceId");
|
||||
QVERIFY2(eventMap.contains("eventTypeId"), "Events.EventTriggered notification does not contain eventTypeId");
|
||||
QVERIFY2(EventTypeId(eventMap.value("eventTypeId").toString()) == mockEvent1Id, "Events.EventTriggered notification does not contain the correct eventTypeId");
|
||||
QVERIFY2(EventTypeId(eventMap.value("eventTypeId").toString()) == mockEvent1EventTypeId, "Events.EventTriggered notification does not contain the correct eventTypeId");
|
||||
}
|
||||
|
||||
QVariantMap TestTimeManager::createTimeEventItem(const QString &time, const QVariantMap &repeatingOption) const
|
||||
|
||||
@ -28,65 +28,7 @@ using namespace nymeaserver;
|
||||
|
||||
Q_LOGGING_CATEGORY(dcTests, "Tests")
|
||||
|
||||
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
||||
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
||||
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
|
||||
DeviceClassId mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
|
||||
DeviceClassId mockPushButtonDeviceClassId = DeviceClassId("9e03144c-e436-4eea-82d9-ccb33ef778db");
|
||||
DeviceClassId mockDisplayPinDeviceClassId = DeviceClassId("296f1fd4-e893-46b2-8a42-50d1bceb8730");
|
||||
DeviceClassId mockParentDeviceClassId = DeviceClassId("a71fbde9-9a38-4bf8-beab-c8aade2608ba");
|
||||
DeviceClassId mockChildDeviceClassId = DeviceClassId("40893c9f-bc47-40c1-8bf7-b390c7c1b4fc");
|
||||
DeviceClassId mockDeviceDiscoveryClassId = DeviceClassId("1bbaf751-36b7-4d3d-b05a-58dab2a3be8c");
|
||||
DeviceClassId mockDeviceAsyncSetupClassId = DeviceClassId("c08a8b27-8200-413d-b96b-4cff78b864d9");
|
||||
DeviceClassId mockDeviceBrokenClassId = DeviceClassId("ba5fb404-c9ce-4db4-8cd4-f48c61c24b13");
|
||||
DeviceClassId mockDeviceBrokenAsyncSetupClassId = DeviceClassId("bd5b78c5-53c9-4417-8eac-8ab2bce97bd0");
|
||||
EventTypeId mockEvent1Id = EventTypeId("45bf3752-0fc6-46b9-89fd-ffd878b5b22b");
|
||||
EventTypeId mockEvent2Id = EventTypeId("863d5920-b1cf-4eb9-88bd-8f7b8583b1cf");
|
||||
StateTypeId mockIntStateId = StateTypeId("80baec19-54de-4948-ac46-31eabfaceb83");
|
||||
StateTypeId mockBoolStateId = StateTypeId("9dd6a97c-dfd1-43dc-acbd-367932742310");
|
||||
StateTypeId mockDoubleStateId = StateTypeId("7cac53ee-7048-4dc9-b000-7b585390f34c");
|
||||
StateTypeId mockBatteryCriticalStateId = StateTypeId("580bc611-1a55-41f3-996f-8d3ccf543db3");
|
||||
StateTypeId mockPowerStateTypeId = StateTypeId("064aed0d-da4c-49d4-b236-60f97e98ff84");
|
||||
ActionTypeId mockActionIdPower = ActionTypeId("064aed0d-da4c-49d4-b236-60f97e98ff84");
|
||||
ActionTypeId mockActionIdWithParams = ActionTypeId("dea0f4e1-65e3-4981-8eaa-2701c53a9185");
|
||||
ActionTypeId mockActionIdNoParams = ActionTypeId("defd3ed6-1a0d-400b-8879-a0202cf39935");
|
||||
ActionTypeId mockActionIdAsync = ActionTypeId("fbae06d3-7666-483e-a39e-ec50fe89054e");
|
||||
ActionTypeId mockActionIdFailing = ActionTypeId("df3cf33d-26d5-4577-9132-9823bd33fad0");
|
||||
ActionTypeId mockActionIdAsyncFailing = ActionTypeId("bfe89a1d-3497-4121-8318-e77c37537219");
|
||||
|
||||
ParamTypeId configParamIntParamTypeId = ParamTypeId("e1f72121-a426-45e2-b475-8262b5cdf103");
|
||||
ParamTypeId configParamBoolParamTypeId = ParamTypeId("c75723b6-ea4f-4982-9751-6c5e39c88145");
|
||||
ParamTypeId httpportParamTypeId = ParamTypeId("d4f06047-125e-4479-9810-b54c189917f5");
|
||||
ParamTypeId asyncParamTypeId = ParamTypeId("f2977061-4dd0-4ef5-85aa-3b7134743be3");
|
||||
ParamTypeId brokenParamTypeId = ParamTypeId("ae8f8901-f2c1-42a5-8111-6d2fc8e4c1e4");
|
||||
ParamTypeId resultCountParamTypeId = ParamTypeId("d222adb4-2f9c-4c3f-8655-76400d0fb6ce");
|
||||
ParamTypeId mockActionParam1ParamTypeId = ParamTypeId("a2d3a256-a551-4712-a65b-ecd5a436a1cb");
|
||||
ParamTypeId mockActionParam2ParamTypeId = ParamTypeId("304a4899-18be-4e3b-94f4-d03be52f3233");
|
||||
ParamTypeId mockParamIntParamTypeId = ParamTypeId("0550e16d-60b9-4ba5-83f4-4d3cee656121");
|
||||
ParamTypeId colorStateParamTypeId = ParamTypeId("20dc7c22-c50e-42db-837c-2bbced939f8e");
|
||||
ParamTypeId percentageStateParamTypeId = ParamTypeId("72981c04-267a-4ba0-a59e-9921d2f3af9c");
|
||||
ParamTypeId allowedValuesStateParamTypeId = ParamTypeId("05f63f9c-f61e-4dcf-ad55-3f13fde2765b");
|
||||
ParamTypeId doubleStateParamTypeId = ParamTypeId("53cd7c55-49b7-441b-b970-9048f20f0e2c");
|
||||
ParamTypeId boolStateParamTypeId = ParamTypeId("e680f7a4-b39e-46da-be41-fa3170fe3768");
|
||||
ParamTypeId pinParamTypeId = ParamTypeId("da820e07-22dc-4173-9c07-2f49a4e265f9");
|
||||
ParamTypeId boolValueStateParamTypeId = ParamTypeId("d24ede5f-4064-4898-bb84-cfb533b1fbc0");
|
||||
ParamTypeId parentUuidParamTypeId = ParamTypeId("104b5288-404e-42d3-bf38-e40682e75681");
|
||||
ParamTypeId textLineParamTypeId = ParamTypeId("e6acf0c7-4b8e-4296-ac62-855d20deb816");
|
||||
ParamTypeId textAreaParamTypeId = ParamTypeId("716f0994-bc01-42b0-b64d-59236f7320d2");
|
||||
ParamTypeId passwordParamTypeId = ParamTypeId("e5c0d14b-c9f1-4aca-a56e-85bfa6977150");
|
||||
ParamTypeId searchParamTypeId = ParamTypeId("22add8c9-ee4f-43ad-8931-58e999313ac3");
|
||||
ParamTypeId mailParamTypeId = ParamTypeId("a8494faf-3a0f-4cf3-84b7-4b39148a838d");
|
||||
ParamTypeId ip4ParamTypeId = ParamTypeId("9e5f86a0-4bb3-4892-bff8-3fc4032af6e2");
|
||||
ParamTypeId ip6ParamTypeId = ParamTypeId("43bf3832-dd48-4090-a836-656e8b60216e");
|
||||
ParamTypeId urlParamTypeId = ParamTypeId("fa67229f-fcef-496f-b671-59a4b48f3ab5");
|
||||
ParamTypeId macParamTypeId = ParamTypeId("e93db587-7919-48f3-8c88-1651de63c765");
|
||||
ParamTypeId mockSetting1ParamTypeId = ParamTypeId("367f7ba4-5039-47be-abd8-59cc8eaf4b9a");
|
||||
|
||||
|
||||
// Parent device
|
||||
EventTypeId mockParentChildEventId = EventTypeId("d24ede5f-4064-4898-bb84-cfb533b1fbc0");
|
||||
ActionTypeId mockParentChildActionId = ActionTypeId("d24ede5f-4064-4898-bb84-cfb533b1fbc0");
|
||||
StateTypeId mockParentChildStateId = StateTypeId("d24ede5f-4064-4898-bb84-cfb533b1fbc0");
|
||||
#include "../plugins/mock/plugininfo.h"
|
||||
|
||||
NymeaTestBase::NymeaTestBase(QObject *parent) :
|
||||
QObject(parent),
|
||||
@ -120,7 +62,7 @@ void NymeaTestBase::initTestCase()
|
||||
NymeaSettings nymeadSettings(NymeaSettings::SettingsRoleGlobal);
|
||||
nymeadSettings.clear();
|
||||
|
||||
QLoggingCategory::setFilterRules("*.debug=false\nTests.debug=true");
|
||||
QLoggingCategory::setFilterRules("*.debug=false\nTests.debug=true\nMockDevice.debug=true");
|
||||
|
||||
// Start the server
|
||||
NymeaCore::instance()->init();
|
||||
@ -150,7 +92,7 @@ void NymeaTestBase::initTestCase()
|
||||
|
||||
response = injectAndWait("Devices.GetConfiguredDevices", {});
|
||||
foreach (const QVariant &device, response.toMap().value("params").toMap().value("devices").toList()) {
|
||||
if (device.toMap().value("deviceClassId").toUuid() == mockDeviceAutoClassId) {
|
||||
if (device.toMap().value("deviceClassId").toUuid() == mockDeviceAutoDeviceClassId) {
|
||||
m_mockDeviceAutoId = DeviceId(device.toMap().value("id").toString());
|
||||
}
|
||||
}
|
||||
@ -458,11 +400,11 @@ void NymeaTestBase::createMockDevice()
|
||||
{
|
||||
QVariantMap params;
|
||||
params.insert("name", "Test Mock Device");
|
||||
params.insert("deviceClassId", "{753f0d32-0468-4d08-82ed-1964aab03298}");
|
||||
params.insert("deviceClassId", mockDeviceClassId.toString());
|
||||
|
||||
QVariantList deviceParams;
|
||||
QVariantMap httpPortParam;
|
||||
httpPortParam.insert("paramTypeId", httpportParamTypeId.toString());
|
||||
httpPortParam.insert("paramTypeId", mockDeviceHttpportParamTypeId.toString());
|
||||
httpPortParam.insert("value", m_mockDevice1Port);
|
||||
deviceParams.append(httpPortParam);
|
||||
params.insert("deviceParams", deviceParams);
|
||||
|
||||
@ -31,64 +31,7 @@
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcTests)
|
||||
|
||||
extern DeviceClassId mockDeviceClassId;
|
||||
extern DeviceClassId mockDeviceAutoClassId;
|
||||
extern DeviceClassId mockPushButtonDeviceClassId;
|
||||
extern DeviceClassId mockDisplayPinDeviceClassId;
|
||||
extern DeviceClassId mockParentDeviceClassId;
|
||||
extern DeviceClassId mockChildDeviceClassId;
|
||||
extern DeviceClassId mockDeviceDiscoveryClassId;
|
||||
extern DeviceClassId mockDeviceAsyncSetupClassId;
|
||||
extern DeviceClassId mockDeviceBrokenClassId;
|
||||
extern DeviceClassId mockDeviceBrokenAsyncSetupClassId;
|
||||
extern ActionTypeId mockActionIdPower;
|
||||
extern ActionTypeId mockActionIdWithParams;
|
||||
extern ActionTypeId mockActionIdNoParams;
|
||||
extern ActionTypeId mockActionIdAsync;
|
||||
extern ActionTypeId mockActionIdFailing;
|
||||
extern ActionTypeId mockActionIdAsyncFailing;
|
||||
extern EventTypeId mockEvent1Id;
|
||||
extern EventTypeId mockEvent2Id;
|
||||
extern StateTypeId mockIntStateId;
|
||||
extern StateTypeId mockDoubleStateId;
|
||||
extern StateTypeId mockBatteryCriticalStateId;
|
||||
extern StateTypeId mockBoolStateId;
|
||||
extern StateTypeId mockPowerStateTypeId;
|
||||
|
||||
// ParamTypes from mock devices
|
||||
extern ParamTypeId configParamIntParamTypeId;
|
||||
extern ParamTypeId configParamBoolParamTypeId;
|
||||
extern ParamTypeId httpportParamTypeId;
|
||||
extern ParamTypeId asyncParamTypeId;
|
||||
extern ParamTypeId brokenParamTypeId;
|
||||
extern ParamTypeId resultCountParamTypeId;
|
||||
extern ParamTypeId mockActionParam1ParamTypeId;
|
||||
extern ParamTypeId mockActionParam2ParamTypeId;
|
||||
extern ParamTypeId mockParamIntParamTypeId;
|
||||
extern ParamTypeId colorStateParamTypeId;
|
||||
extern ParamTypeId percentageStateParamTypeId;
|
||||
extern ParamTypeId allowedValuesStateParamTypeId;
|
||||
extern ParamTypeId doubleStateParamTypeId;
|
||||
extern ParamTypeId boolStateParamTypeId;
|
||||
extern ParamTypeId pinParamTypeId;
|
||||
extern ParamTypeId boolValueStateParamTypeId;
|
||||
extern ParamTypeId parentUuidParamTypeId;
|
||||
extern ParamTypeId textLineParamTypeId;
|
||||
extern ParamTypeId textAreaParamTypeId;
|
||||
extern ParamTypeId passwordParamTypeId;
|
||||
extern ParamTypeId searchParamTypeId;
|
||||
extern ParamTypeId mailParamTypeId;
|
||||
extern ParamTypeId ip4ParamTypeId;
|
||||
extern ParamTypeId ip6ParamTypeId;
|
||||
extern ParamTypeId urlParamTypeId;
|
||||
extern ParamTypeId macParamTypeId;
|
||||
extern ParamTypeId mockSetting1ParamTypeId;
|
||||
|
||||
// Parent / Child device
|
||||
extern EventTypeId mockParentChildEventId;
|
||||
extern ActionTypeId mockParentChildActionId;
|
||||
extern StateTypeId mockParentChildStateId;
|
||||
|
||||
#include "../plugins/mock/extern-plugininfo.h"
|
||||
|
||||
namespace nymeaserver {
|
||||
class MockTcpServer;
|
||||
|
||||
@ -47,6 +47,7 @@ int PluginInfoCompiler::compile(const QString &inputFile, const QString &outputF
|
||||
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qWarning() << "Error parsing input JSON. Aborting.";
|
||||
qWarning() << "Parser details:" << error.errorString();
|
||||
return 1;
|
||||
}
|
||||
QJsonObject jsonObject = QJsonObject::fromVariantMap(jsonDoc.toVariant().toMap());
|
||||
@ -112,7 +113,7 @@ int PluginInfoCompiler::compile(const QString &inputFile, const QString &outputF
|
||||
writeExtern();
|
||||
|
||||
// Include our API version in plugininfo.h so we can know against which library this plugin was built.
|
||||
write(QString("extern \"C\" const QString libnymea_api_version = QString(\"%1\");").arg(LIBNYMEA_API_VERSION));
|
||||
write(QString("extern \"C\" const QString libnymea_api_version() { return QString(\"%1\");}").arg(LIBNYMEA_API_VERSION));
|
||||
write();
|
||||
|
||||
// Declare a logging category for this plugin
|
||||
|
||||
Reference in New Issue
Block a user