fix tests and remove mockdevices name param
This commit is contained in:
parent
b2763cafd0
commit
449c224da0
@ -144,7 +144,7 @@
|
||||
create the Devices.DeviceParamsChanged notification.
|
||||
*/
|
||||
|
||||
/*! \fn void DeviceManager::deviceEditFinished(Device *device, DeviceError status);
|
||||
/*! \fn void DeviceManager::deviceReconfigurationFinished(Device *device, DeviceError status);
|
||||
This signal is emitted when the edit process of a \a device is finished. The \a status parameter describes the
|
||||
\l{DeviceManager::DeviceError}{DeviceError} that occurred.
|
||||
*/
|
||||
@ -414,7 +414,7 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassI
|
||||
* from a discovery or if the user set them. If it came from discovery not writable parameters (readOnly) will be changed too.
|
||||
*
|
||||
* Returns \l{DeviceError} to inform about the result. */
|
||||
DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, const ParamList ¶ms, bool fromDiscovery)
|
||||
DeviceManager::DeviceError DeviceManager::reconfigureDevice(const DeviceId &deviceId, const ParamList ¶ms, bool fromDiscovery)
|
||||
{
|
||||
Device *device = findConfiguredDevice(deviceId);
|
||||
if (!device) {
|
||||
@ -490,7 +490,7 @@ DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, c
|
||||
* This method allows to rediscover a device and update it's \l{Param}{Params}.
|
||||
*
|
||||
* Returns \l{DeviceError} to inform about the result. */
|
||||
DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId)
|
||||
DeviceManager::DeviceError DeviceManager::reconfigureDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId)
|
||||
{
|
||||
Device *device = findConfiguredDevice(deviceId);
|
||||
if (!device) {
|
||||
@ -510,7 +510,7 @@ DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, c
|
||||
return DeviceErrorDeviceDescriptorNotFound;
|
||||
}
|
||||
|
||||
return editDevice(deviceId, descriptor.params(), true);
|
||||
return reconfigureDevice(deviceId, descriptor.params(), true);
|
||||
}
|
||||
|
||||
/*! Initiates a pairing with a \l{DeviceClass}{Device} with the given \a pairingTransactionId, \a deviceClassId and \a params.
|
||||
@ -1095,7 +1095,7 @@ void DeviceManager::slotDeviceSetupFinished(Device *device, DeviceManager::Devic
|
||||
// TODO: recover old params.??
|
||||
|
||||
emit deviceParamsChanged(device);
|
||||
emit deviceEditFinished(device, DeviceError::DeviceErrorSetupFailed);
|
||||
emit deviceReconfigurationFinished(device, DeviceError::DeviceErrorSetupFailed);
|
||||
}
|
||||
qCWarning(dcDeviceManager) << QString("Error in device setup. Device %1 (%2) will not be functional.").arg(device->name()).arg(device->id().toString());
|
||||
emit deviceSetupFinished(device, DeviceError::DeviceErrorSetupFailed);
|
||||
@ -1133,7 +1133,7 @@ void DeviceManager::slotDeviceSetupFinished(Device *device, DeviceManager::Devic
|
||||
storeConfiguredDevices();
|
||||
device->setupCompleted();
|
||||
emit deviceParamsChanged(device);
|
||||
emit deviceEditFinished(device, DeviceManager::DeviceErrorNoError);
|
||||
emit deviceReconfigurationFinished(device, DeviceManager::DeviceErrorNoError);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -115,8 +115,8 @@ public:
|
||||
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
||||
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId, const DeviceId &id = DeviceId::createDeviceId());
|
||||
|
||||
DeviceError editDevice(const DeviceId &deviceId, const ParamList ¶ms, bool fromDiscovery = false);
|
||||
DeviceError editDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId);
|
||||
DeviceError reconfigureDevice(const DeviceId &deviceId, const ParamList ¶ms, bool fromDiscovery = false);
|
||||
DeviceError reconfigureDevice(const DeviceId &deviceId, const DeviceDescriptorId &deviceDescriptorId);
|
||||
|
||||
DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
||||
DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId);
|
||||
@ -141,7 +141,7 @@ signals:
|
||||
void deviceParamsChanged(Device *device);
|
||||
void devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> &devices);
|
||||
void deviceSetupFinished(Device *device, DeviceError status);
|
||||
void deviceEditFinished(Device *device, DeviceError status);
|
||||
void deviceReconfigurationFinished(Device *device, DeviceError status);
|
||||
void pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceError status, const DeviceId &deviceId = DeviceId());
|
||||
void actionExecutionFinished(const ActionId &actionId, DeviceManager::DeviceError status);
|
||||
|
||||
@ -201,7 +201,7 @@ private:
|
||||
QHash<QUuid, QPair<DeviceClassId, ParamList> > m_pairingsJustAdd;
|
||||
QHash<QUuid, QPair<DeviceClassId, DeviceDescriptorId> > m_pairingsDiscovery;
|
||||
|
||||
QList<Device *> m_asyncDeviceEdit;
|
||||
QList<Device *> m_asyncDeviceReconfiguration;
|
||||
|
||||
QList<DevicePlugin *> m_discoveringPlugins;
|
||||
|
||||
|
||||
@ -69,7 +69,6 @@ DeviceManager::DeviceSetupStatus DevicePluginMock::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == mockDeviceClassId || device->deviceClassId() == mockDeviceAutoDeviceClassId) {
|
||||
qCDebug(dcMockDevice) << "Mockdevice created returning true"
|
||||
<< device->paramValue("name").toString()
|
||||
<< device->paramValue("httpport").toInt()
|
||||
<< device->paramValue("async").toBool()
|
||||
<< device->paramValue("broken").toBool();
|
||||
@ -282,9 +281,7 @@ void DevicePluginMock::emitDevicesDiscovered()
|
||||
if (m_discoveredDeviceCount > 0) {
|
||||
DeviceDescriptor d1(mockDeviceClassId, "Mock Device 1 (Discovered)", "55555");
|
||||
ParamList params;
|
||||
Param name("name", "Discovered Mock Device 1");
|
||||
Param httpParam("httpport", "55555");
|
||||
params.append(name);
|
||||
params.append(httpParam);
|
||||
d1.setParams(params);
|
||||
deviceDescriptors.append(d1);
|
||||
@ -293,9 +290,7 @@ void DevicePluginMock::emitDevicesDiscovered()
|
||||
if (m_discoveredDeviceCount > 1) {
|
||||
DeviceDescriptor d2(mockDeviceClassId, "Mock Device 2 (Discovered)", "55556");
|
||||
ParamList params;
|
||||
Param name("name", "Discovered Mock Device 2");
|
||||
Param httpParam("httpport", "55556");
|
||||
params.append(name);
|
||||
params.append(httpParam);
|
||||
d2.setParams(params);
|
||||
deviceDescriptors.append(d2);
|
||||
@ -310,19 +305,11 @@ void DevicePluginMock::emitPushButtonDevicesDiscovered()
|
||||
|
||||
if (m_discoveredDeviceCount > 0) {
|
||||
DeviceDescriptor d1(mockPushButtonDeviceClassId, "Mock Device (Push Button)", "1");
|
||||
ParamList params;
|
||||
Param name("name", "PushButton Mock Device 1");
|
||||
params.append(name);
|
||||
d1.setParams(params);
|
||||
deviceDescriptors.append(d1);
|
||||
}
|
||||
|
||||
if (m_discoveredDeviceCount > 1) {
|
||||
DeviceDescriptor d2(mockPushButtonDeviceClassId, "Mock Device (Push Button)", "2");
|
||||
ParamList params;
|
||||
Param name("name", "PushButton Mock Device 2");
|
||||
params.append(name);
|
||||
d2.setParams(params);
|
||||
deviceDescriptors.append(d2);
|
||||
}
|
||||
emit devicesDiscovered(mockPushButtonDeviceClassId, deviceDescriptors);
|
||||
@ -338,19 +325,11 @@ void DevicePluginMock::emitDisplayPinDevicesDiscovered()
|
||||
|
||||
if (m_discoveredDeviceCount > 0) {
|
||||
DeviceDescriptor d1(mockDisplayPinDeviceClassId, "Mock Device (Display Pin)", "1");
|
||||
ParamList params;
|
||||
Param name("name", "DisplayPin Mock Device 1");
|
||||
params.append(name);
|
||||
d1.setParams(params);
|
||||
deviceDescriptors.append(d1);
|
||||
}
|
||||
|
||||
if (m_discoveredDeviceCount > 1) {
|
||||
DeviceDescriptor d2(mockDisplayPinDeviceClassId, "Mock Device (Display Pin)", "2");
|
||||
ParamList params;
|
||||
Param name("name", "DisplayPin Mock Device 2");
|
||||
params.append(name);
|
||||
d2.setParams(params);
|
||||
deviceDescriptors.append(d2);
|
||||
}
|
||||
|
||||
@ -402,7 +381,6 @@ void DevicePluginMock::onChildDeviceDiscovered(const DeviceId &parentId)
|
||||
qCDebug(dcMockDevice) << "Child device discovered for parent" << parentId.toString();
|
||||
DeviceDescriptor mockDescriptor(mockChildDeviceClassId, "Child Mock Device (Auto created)");
|
||||
ParamList params;
|
||||
params.append(Param("name", "Child"));
|
||||
params.append(Param("parent uuid", parentId));
|
||||
mockDescriptor.setParams(params);
|
||||
|
||||
|
||||
@ -42,13 +42,6 @@
|
||||
}
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"defaultValue": "Mock device",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"name": "httpport",
|
||||
"type": "int"
|
||||
@ -56,7 +49,8 @@
|
||||
{
|
||||
"name": "async",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
"defaultValue": false,
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"name": "broken",
|
||||
@ -143,13 +137,6 @@
|
||||
"createMethods": ["auto"],
|
||||
"deviceIcon": "Tune",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"defaultValue": "Mock device",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"name": "httpport",
|
||||
"type": "int"
|
||||
@ -157,7 +144,8 @@
|
||||
{
|
||||
"name": "async",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
"defaultValue": false,
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"name": "broken",
|
||||
@ -250,15 +238,6 @@
|
||||
"allowedValues": [1, 2]
|
||||
}
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"defaultValue": "Mock device",
|
||||
"readOnly": true
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "20dc7c22-c50e-42db-837c-2bbced939f8e",
|
||||
@ -342,13 +321,6 @@
|
||||
}
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"defaultValue": "Mock device",
|
||||
"readOnly": true
|
||||
},
|
||||
{
|
||||
"name": "pin",
|
||||
"type": "QString",
|
||||
@ -429,14 +401,6 @@
|
||||
"Gateway"
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"defaultValue": "Parent Mock Device"
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "d24ede5f-4064-4898-bb84-cfb533b1fbc0",
|
||||
@ -458,12 +422,6 @@
|
||||
"Actuator"
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"defaultValue": "Child Mock Device"
|
||||
},
|
||||
{
|
||||
"name": "parent uuid",
|
||||
"type": "QUuid",
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
\l{DeviceManager::DeviceError}{DeviceError} that occurred.
|
||||
*/
|
||||
|
||||
/*! \fn void guhserver::GuhCore::deviceEditFinished(Device *device, DeviceManager::DeviceError status);
|
||||
/*! \fn void guhserver::GuhCore::deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status);
|
||||
This signal is emitted when the edit request of a \a device is finished. The \a status of the edit request will be
|
||||
described as \l{DeviceManager::DeviceError}{DeviceError}.
|
||||
*/
|
||||
@ -378,7 +378,7 @@ GuhCore::GuhCore(QObject *parent) :
|
||||
connect(m_deviceManager, &DeviceManager::actionExecutionFinished, this, &GuhCore::actionExecutionFinished);
|
||||
connect(m_deviceManager, &DeviceManager::devicesDiscovered, this, &GuhCore::devicesDiscovered);
|
||||
connect(m_deviceManager, &DeviceManager::deviceSetupFinished, this, &GuhCore::deviceSetupFinished);
|
||||
connect(m_deviceManager, &DeviceManager::deviceEditFinished, this, &GuhCore::deviceEditFinished);
|
||||
connect(m_deviceManager, &DeviceManager::deviceReconfigurationFinished, this, &GuhCore::deviceReconfigurationFinished);
|
||||
connect(m_deviceManager, &DeviceManager::pairingFinished, this, &GuhCore::pairingFinished);
|
||||
|
||||
connect(m_ruleEngine, &RuleEngine::ruleAdded, this, &GuhCore::ruleAdded);
|
||||
|
||||
@ -79,7 +79,7 @@ signals:
|
||||
|
||||
void devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> deviceDescriptors);
|
||||
void deviceSetupFinished(Device *device, DeviceManager::DeviceError status);
|
||||
void deviceEditFinished(Device *device, DeviceManager::DeviceError status);
|
||||
void deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status);
|
||||
void pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId);
|
||||
|
||||
void ruleRemoved(const RuleId &ruleId);
|
||||
|
||||
@ -160,7 +160,7 @@ DeviceHandler::DeviceHandler(QObject *parent) :
|
||||
setReturns("GetDiscoveredDevices", returns);
|
||||
|
||||
params.clear(); returns.clear();
|
||||
setDescription("EditDevice", "Edit the parameters of a device. The device params will be set to the "
|
||||
setDescription("ReconfigureDevice", "Edit the parameter configuration of the device. The device params will be set to the "
|
||||
"passed parameters and the setup device will be called. If the device is discoverable, "
|
||||
"you can perform a GetDiscoveredDevices before calling this method and pass "
|
||||
"the new DeviceDescriptor (rediscover). If a parameter is not writable, you will find a "
|
||||
@ -170,9 +170,9 @@ DeviceHandler::DeviceHandler(QObject *parent) :
|
||||
QVariantList newDeviceParams;
|
||||
newDeviceParams.append(JsonTypes::paramRef());
|
||||
params.insert("o:deviceParams", newDeviceParams);
|
||||
setParams("EditDevice", params);
|
||||
setParams("ReconfigureDevice", params);
|
||||
returns.insert("deviceError", JsonTypes::deviceErrorRef());
|
||||
setReturns("EditDevice", returns);
|
||||
setReturns("ReconfigureDevice", returns);
|
||||
|
||||
params.clear(); returns.clear();
|
||||
setDescription("RemoveConfiguredDevice", "Remove a device from the system.");
|
||||
@ -267,7 +267,7 @@ DeviceHandler::DeviceHandler(QObject *parent) :
|
||||
connect(GuhCore::instance(), &GuhCore::deviceParamsChanged, this, &DeviceHandler::deviceParamsChangedNotification);
|
||||
connect(GuhCore::instance(), &GuhCore::devicesDiscovered, this, &DeviceHandler::devicesDiscovered, Qt::QueuedConnection);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceSetupFinished, this, &DeviceHandler::deviceSetupFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceEditFinished, this, &DeviceHandler::deviceEditFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceReconfigurationFinished, this, &DeviceHandler::deviceReconfigurationFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DeviceHandler::pairingFinished);
|
||||
}
|
||||
|
||||
@ -436,7 +436,7 @@ JsonReply* DeviceHandler::GetConfiguredDevices(const QVariantMap ¶ms) const
|
||||
return createReply(returns);
|
||||
}
|
||||
|
||||
JsonReply *DeviceHandler::EditDevice(const QVariantMap ¶ms)
|
||||
JsonReply *DeviceHandler::ReconfigureDevice(const QVariantMap ¶ms)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
DeviceId deviceId = DeviceId(params.value("deviceId").toString());
|
||||
@ -445,13 +445,13 @@ JsonReply *DeviceHandler::EditDevice(const QVariantMap ¶ms)
|
||||
DeviceManager::DeviceError status;
|
||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||
if (deviceDescriptorId.isNull()) {
|
||||
status = GuhCore::instance()->deviceManager()->editDevice(deviceId, deviceParams);
|
||||
status = GuhCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceParams);
|
||||
} else {
|
||||
status = GuhCore::instance()->deviceManager()->editDevice(deviceId, deviceDescriptorId);
|
||||
status = GuhCore::instance()->deviceManager()->reconfigureDevice(deviceId, deviceDescriptorId);
|
||||
}
|
||||
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
JsonReply *asyncReply = createAsyncReply("EditDevice");
|
||||
JsonReply *asyncReply = createAsyncReply("ReconfigureDevice");
|
||||
m_asynDeviceEditAdditions.insert(deviceId, asyncReply);
|
||||
return asyncReply;
|
||||
}
|
||||
@ -641,9 +641,9 @@ void DeviceHandler::deviceSetupFinished(Device *device, DeviceManager::DeviceErr
|
||||
reply->finished();
|
||||
}
|
||||
|
||||
void DeviceHandler::deviceEditFinished(Device *device, DeviceManager::DeviceError status)
|
||||
void DeviceHandler::deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status)
|
||||
{
|
||||
qCDebug(dcJsonRpc) << "got async edit finished";
|
||||
qCDebug(dcJsonRpc) << "Got async device reconfiguration finished";
|
||||
if (!m_asynDeviceEditAdditions.contains(device->id())) {
|
||||
return;
|
||||
}
|
||||
@ -657,7 +657,7 @@ void DeviceHandler::deviceEditFinished(Device *device, DeviceManager::DeviceErro
|
||||
|
||||
void DeviceHandler::pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId)
|
||||
{
|
||||
qCDebug(dcJsonRpc) << "got pairing finished";
|
||||
qCDebug(dcJsonRpc) << "Got pairing finished";
|
||||
JsonReply *reply = m_asyncPairingRequests.take(pairingTransactionId);
|
||||
if (!reply) {
|
||||
return;
|
||||
|
||||
@ -55,7 +55,7 @@ public:
|
||||
|
||||
Q_INVOKABLE JsonReply* GetConfiguredDevices(const QVariantMap ¶ms) const;
|
||||
|
||||
Q_INVOKABLE JsonReply* EditDevice(const QVariantMap ¶ms);
|
||||
Q_INVOKABLE JsonReply* ReconfigureDevice(const QVariantMap ¶ms);
|
||||
|
||||
Q_INVOKABLE JsonReply* RemoveConfiguredDevice(const QVariantMap ¶ms);
|
||||
|
||||
@ -88,7 +88,7 @@ private slots:
|
||||
|
||||
void deviceSetupFinished(Device *device, DeviceManager::DeviceError status);
|
||||
|
||||
void deviceEditFinished(Device *device, DeviceManager::DeviceError status);
|
||||
void deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status);
|
||||
|
||||
void pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId);
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ DevicesResource::DevicesResource(QObject *parent) :
|
||||
{
|
||||
connect(GuhCore::instance(), &GuhCore::actionExecuted, this, &DevicesResource::actionExecuted);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceSetupFinished, this, &DevicesResource::deviceSetupFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceEditFinished, this, &DevicesResource::deviceEditFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::deviceReconfigurationFinished, this, &DevicesResource::deviceReconfigurationFinished);
|
||||
connect(GuhCore::instance(), &GuhCore::pairingFinished, this, &DevicesResource::pairingFinished);
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ HttpReply *DevicesResource::proccessPutRequest(const HttpRequest &request, const
|
||||
|
||||
// PUT /api/v1/devices/{deviceId}
|
||||
if (urlTokens.count() == 4)
|
||||
return editDevice(m_device, request.payload());
|
||||
return reconfigureDevice(m_device, request.payload());
|
||||
|
||||
return createErrorReply(HttpReply::NotImplemented);
|
||||
}
|
||||
@ -459,7 +459,7 @@ HttpReply *DevicesResource::confirmPairDevice(const QByteArray &payload) const
|
||||
return createDeviceErrorReply(HttpReply::Ok, DeviceManager::DeviceErrorNoError);
|
||||
}
|
||||
|
||||
HttpReply *DevicesResource::editDevice(Device *device, const QByteArray &payload) const
|
||||
HttpReply *DevicesResource::reconfigureDevice(Device *device, const QByteArray &payload) const
|
||||
{
|
||||
qCDebug(dcRest) << "Edit device" << device->id();
|
||||
QPair<bool, QVariant> verification = RestResource::verifyPayload(payload);
|
||||
@ -473,16 +473,16 @@ HttpReply *DevicesResource::editDevice(Device *device, const QByteArray &payload
|
||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||
if (deviceDescriptorId.isNull()) {
|
||||
qCDebug(dcRest) << "Edit device with params:" << deviceParams;
|
||||
status = GuhCore::instance()->deviceManager()->editDevice(device->id(), deviceParams);
|
||||
status = GuhCore::instance()->deviceManager()->reconfigureDevice(device->id(), deviceParams);
|
||||
} else {
|
||||
qCDebug(dcRest) << "Edit device using the discovered device with descriptorId:" << deviceDescriptorId.toString();
|
||||
status = GuhCore::instance()->deviceManager()->editDevice(device->id(), deviceDescriptorId);
|
||||
status = GuhCore::instance()->deviceManager()->reconfigureDevice(device->id(), deviceDescriptorId);
|
||||
}
|
||||
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
HttpReply *reply = createAsyncReply();
|
||||
qCDebug(dcRest) << "Device edit async reply";
|
||||
m_asyncEditDevice.insert(device, reply);
|
||||
m_asyncReconfigureDevice.insert(device, reply);
|
||||
return reply;
|
||||
}
|
||||
|
||||
@ -553,20 +553,20 @@ void DevicesResource::deviceSetupFinished(Device *device, DeviceManager::DeviceE
|
||||
reply->finished();
|
||||
}
|
||||
|
||||
void DevicesResource::deviceEditFinished(Device *device, DeviceManager::DeviceError status)
|
||||
void DevicesResource::deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status)
|
||||
{
|
||||
if (!m_asyncEditDevice.contains(device))
|
||||
if (!m_asyncReconfigureDevice.contains(device))
|
||||
return; // Not the device we are waiting for.
|
||||
|
||||
QVariantMap response;
|
||||
response.insert("error", JsonTypes::deviceErrorToString(status));
|
||||
|
||||
if (m_asyncEditDevice.value(device).isNull()) {
|
||||
if (m_asyncReconfigureDevice.value(device).isNull()) {
|
||||
qCWarning(dcRest) << "Async reply for device edit does not exist any more (timeout).";
|
||||
return;
|
||||
}
|
||||
|
||||
HttpReply *reply = m_asyncEditDevice.take(device);
|
||||
HttpReply *reply = m_asyncReconfigureDevice.take(device);
|
||||
reply->setHeader(HttpReply::ContentTypeHeader, "application/json; charset=\"utf-8\";");
|
||||
if (status == DeviceManager::DeviceErrorNoError) {
|
||||
qCDebug(dcRest) << "Device edit finished successfully";
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
private:
|
||||
mutable QHash<ActionId, QPointer<HttpReply> > m_asyncActionExecutions;
|
||||
mutable QHash<DeviceId, QPointer<HttpReply> > m_asyncDeviceAdditions;
|
||||
mutable QHash<Device *, QPointer<HttpReply> > m_asyncEditDevice;
|
||||
mutable QHash<Device *, QPointer<HttpReply> > m_asyncReconfigureDevice;
|
||||
mutable QHash<PairingTransactionId, QPointer<HttpReply> > m_asyncPairingRequests;
|
||||
|
||||
Device *m_device;
|
||||
@ -73,12 +73,12 @@ private:
|
||||
HttpReply *confirmPairDevice(const QByteArray &payload) const;
|
||||
|
||||
// Put methods
|
||||
HttpReply *editDevice(Device *device, const QByteArray &payload) const;
|
||||
HttpReply *reconfigureDevice(Device *device, const QByteArray &payload) const;
|
||||
|
||||
private slots:
|
||||
void actionExecuted(const ActionId &actionId, DeviceManager::DeviceError status);
|
||||
void deviceSetupFinished(Device *device, DeviceManager::DeviceError status);
|
||||
void deviceEditFinished(Device *device, DeviceManager::DeviceError status);
|
||||
void deviceReconfigurationFinished(Device *device, DeviceManager::DeviceError status);
|
||||
void pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceError status, const DeviceId &deviceId);
|
||||
};
|
||||
|
||||
|
||||
@ -84,11 +84,11 @@ private slots:
|
||||
void getStateValues_data();
|
||||
void getStateValues();
|
||||
|
||||
void editDevices_data();
|
||||
void editDevices();
|
||||
void reconfigureDevices_data();
|
||||
void reconfigureDevices();
|
||||
|
||||
void editByDiscovery_data();
|
||||
void editByDiscovery();
|
||||
void reconfigureByDiscovery_data();
|
||||
void reconfigureByDiscovery();
|
||||
|
||||
// Keep this the last one! It'll remove the configured mock device
|
||||
void removeDevice_data();
|
||||
@ -277,6 +277,7 @@ void TestDevices::addConfiguredDevice()
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", deviceClassId);
|
||||
params.insert("name", "Test Add Device");
|
||||
params.insert("deviceParams", deviceParams);
|
||||
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||
qDebug() << "response is" << response;
|
||||
@ -304,11 +305,8 @@ void TestDevices::storedDevices()
|
||||
{
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", mockDeviceClassId);
|
||||
params.insert("name", "Test stored Device");
|
||||
QVariantList deviceParams;
|
||||
QVariantMap nameParam;
|
||||
nameParam.insert("name", "name");
|
||||
nameParam.insert("value", "Blub Blub device");
|
||||
deviceParams.append(nameParam);
|
||||
QVariantMap asyncParam;
|
||||
asyncParam.insert("name", "async");
|
||||
asyncParam.insert("value", false);
|
||||
@ -345,7 +343,6 @@ void TestDevices::storedDevices()
|
||||
}
|
||||
QVERIFY2(found, "Device missing in config!");
|
||||
|
||||
|
||||
params.clear();
|
||||
params.insert("deviceId", addedDeviceId);
|
||||
response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
||||
@ -393,6 +390,7 @@ void TestDevices::discoverDevices()
|
||||
|
||||
params.clear();
|
||||
params.insert("deviceClassId", deviceClassId);
|
||||
params.insert("name", "Discoverd mock device");
|
||||
params.insert("deviceDescriptorId", descriptorId.toString());
|
||||
response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||
|
||||
@ -442,6 +440,7 @@ void TestDevices::addPushButtonDevices()
|
||||
DeviceDescriptorId descriptorId = DeviceDescriptorId(response.toMap().value("params").toMap().value("deviceDescriptors").toList().first().toMap().value("id").toString());
|
||||
params.clear();
|
||||
params.insert("deviceClassId", deviceClassId);
|
||||
params.insert("name", "Pushbutton device");
|
||||
params.insert("deviceDescriptorId", descriptorId.toString());
|
||||
response = injectAndWait("Devices.PairDevice", params);
|
||||
|
||||
@ -506,6 +505,7 @@ void TestDevices::addDisplayPinDevices()
|
||||
DeviceDescriptorId descriptorId = DeviceDescriptorId(response.toMap().value("params").toMap().value("deviceDescriptors").toList().first().toMap().value("id").toString());
|
||||
params.clear();
|
||||
params.insert("deviceClassId", deviceClassId);
|
||||
params.insert("name", "Display pin mock device");
|
||||
params.insert("deviceDescriptorId", descriptorId.toString());
|
||||
response = injectAndWait("Devices.PairDevice", params);
|
||||
|
||||
@ -514,7 +514,7 @@ void TestDevices::addDisplayPinDevices()
|
||||
PairingTransactionId pairingTransactionId(response.toMap().value("params").toMap().value("pairingTransactionId").toString());
|
||||
QString displayMessage = response.toMap().value("params").toMap().value("displayMessage").toString();
|
||||
|
||||
//qDebug() << "displayMessage" << displayMessage;
|
||||
qDebug() << "displayMessage" << displayMessage;
|
||||
|
||||
params.clear();
|
||||
params.insert("pairingTransactionId", pairingTransactionId.toString());
|
||||
@ -539,6 +539,7 @@ void TestDevices::parentChildDevices()
|
||||
// add parent device
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", mockParentDeviceClassId);
|
||||
params.insert("name", "Parent device");
|
||||
|
||||
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||
verifyDeviceError(response);
|
||||
@ -736,7 +737,7 @@ void TestDevices::getStateValues()
|
||||
}
|
||||
}
|
||||
|
||||
void TestDevices::editDevices_data()
|
||||
void TestDevices::reconfigureDevices_data()
|
||||
{
|
||||
QVariantList asyncChangeDeviceParams;
|
||||
QVariantMap asyncParamDifferent;
|
||||
@ -747,7 +748,7 @@ void TestDevices::editDevices_data()
|
||||
QVariantList httpportChangeDeviceParams;
|
||||
QVariantMap httpportParamDifferent;
|
||||
httpportParamDifferent.insert("name", "httpport");
|
||||
httpportParamDifferent.insert("value", 8893); // if change -> change also newPort in editDevices()
|
||||
httpportParamDifferent.insert("value", 8893); // if change -> change also newPort in reconfigureDevices()
|
||||
httpportChangeDeviceParams.append(httpportParamDifferent);
|
||||
|
||||
QVariantList brokenChangedDeviceParams;
|
||||
@ -756,36 +757,26 @@ void TestDevices::editDevices_data()
|
||||
brokenParamDifferent.insert("value", true);
|
||||
brokenChangedDeviceParams.append(brokenParamDifferent);
|
||||
|
||||
QVariantList nameChangedDeviceParams;
|
||||
QVariantMap nameParam;
|
||||
nameParam.insert("name", "name");
|
||||
nameParam.insert("value", "Awesome Mockdevice");
|
||||
nameChangedDeviceParams.append(nameParam);
|
||||
|
||||
|
||||
QVariantList asyncAndPortChangeDeviceParams;
|
||||
asyncAndPortChangeDeviceParams.append(asyncParamDifferent);
|
||||
asyncAndPortChangeDeviceParams.append(httpportParamDifferent);
|
||||
|
||||
|
||||
QVariantList changeAllWritableDeviceParams;
|
||||
changeAllWritableDeviceParams.append(nameParam);
|
||||
changeAllWritableDeviceParams.append(asyncParamDifferent);
|
||||
changeAllWritableDeviceParams.append(httpportParamDifferent);
|
||||
|
||||
|
||||
QTest::addColumn<bool>("broken");
|
||||
QTest::addColumn<QVariantList>("newDeviceParams");
|
||||
QTest::addColumn<DeviceManager::DeviceError>("deviceError");
|
||||
|
||||
QTest::newRow("valid - change async param") << false << asyncChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
||||
QTest::newRow("valid - change async param") << false << asyncChangeDeviceParams << DeviceManager::DeviceErrorParameterNotWritable;
|
||||
QTest::newRow("valid - change httpport param") << false << httpportChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
||||
QTest::newRow("valid - change httpport and async param") << false << asyncAndPortChangeDeviceParams << DeviceManager::DeviceErrorNoError;
|
||||
QTest::newRow("invalid - change name param (not writable)") << false << nameChangedDeviceParams << DeviceManager::DeviceErrorParameterNotWritable;
|
||||
QTest::newRow("invalid - change httpport and async param") << false << asyncAndPortChangeDeviceParams << DeviceManager::DeviceErrorParameterNotWritable;
|
||||
QTest::newRow("invalid - change all params (except broken)") << false << changeAllWritableDeviceParams << DeviceManager::DeviceErrorParameterNotWritable;
|
||||
}
|
||||
|
||||
void TestDevices::editDevices()
|
||||
void TestDevices::reconfigureDevices()
|
||||
{
|
||||
QFETCH(bool, broken);
|
||||
QFETCH(QVariantList, newDeviceParams);
|
||||
@ -794,11 +785,8 @@ void TestDevices::editDevices()
|
||||
// add device
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", mockDeviceClassId);
|
||||
params.insert("name", "Device to edit");
|
||||
QVariantList deviceParams;
|
||||
QVariantMap nameParam;
|
||||
nameParam.insert("name", "name");
|
||||
nameParam.insert("value", "Test edit mockdevice");
|
||||
deviceParams.append(nameParam);
|
||||
QVariantMap asyncParam;
|
||||
asyncParam.insert("name", "async");
|
||||
asyncParam.insert("value", false);
|
||||
@ -825,7 +813,7 @@ void TestDevices::editDevices()
|
||||
QVariantMap editParams;
|
||||
editParams.insert("deviceId", deviceId);
|
||||
editParams.insert("deviceParams", newDeviceParams);
|
||||
response = injectAndWait("Devices.EditDevice", editParams);
|
||||
response = injectAndWait("Devices.ReconfigureDevice", editParams);
|
||||
verifyDeviceError(response, deviceError);
|
||||
|
||||
// if the edit should have been successfull
|
||||
@ -914,7 +902,7 @@ void TestDevices::editDevices()
|
||||
}
|
||||
|
||||
|
||||
void TestDevices::editByDiscovery_data()
|
||||
void TestDevices::reconfigureByDiscovery_data()
|
||||
{
|
||||
QTest::addColumn<DeviceClassId>("deviceClassId");
|
||||
QTest::addColumn<int>("resultCount");
|
||||
@ -930,7 +918,7 @@ void TestDevices::editByDiscovery_data()
|
||||
QTest::newRow("discover 2 devices with params") << mockDeviceClassId << 2 << DeviceManager::DeviceErrorNoError << discoveryParams;
|
||||
}
|
||||
|
||||
void TestDevices::editByDiscovery()
|
||||
void TestDevices::reconfigureByDiscovery()
|
||||
{
|
||||
QFETCH(DeviceClassId, deviceClassId);
|
||||
QFETCH(int, resultCount);
|
||||
@ -967,6 +955,7 @@ void TestDevices::editByDiscovery()
|
||||
params.clear();
|
||||
response.clear();
|
||||
params.insert("deviceClassId", deviceClassId);
|
||||
params.insert("name", "Discoverd mock device");
|
||||
params.insert("deviceDescriptorId", descriptorId1);
|
||||
response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||
|
||||
@ -1003,7 +992,7 @@ void TestDevices::editByDiscovery()
|
||||
params.clear();
|
||||
params.insert("deviceId", deviceId.toString());
|
||||
params.insert("deviceDescriptorId", descriptorId2);
|
||||
response = injectAndWait("Devices.EditDevice", params);
|
||||
response = injectAndWait("Devices.ReconfigureDevice", params);
|
||||
verifyDeviceError(response, error);
|
||||
|
||||
response.clear();
|
||||
@ -1027,9 +1016,6 @@ void TestDevices::editByDiscovery()
|
||||
|
||||
// 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("name") == "name") {
|
||||
QCOMPARE(param.toMap().value("value").toString(), QString("Discovered Mock Device 2"));
|
||||
}
|
||||
if (param.toMap().value("name") == "httpport") {
|
||||
QCOMPARE(param.toMap().value("value").toInt(), 55556);
|
||||
}
|
||||
|
||||
@ -97,6 +97,7 @@ void GuhTestBase::initTestCase()
|
||||
// Lets add one instance of the mockdevice
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", "{753f0d32-0468-4d08-82ed-1964aab03298}");
|
||||
params.insert("name", "Test Mock Device");
|
||||
|
||||
QVariantList deviceParams;
|
||||
QVariantMap httpPortParam;
|
||||
|
||||
@ -283,6 +283,7 @@ void TestJSONRPC::deviceAddedRemovedNotifications()
|
||||
|
||||
QVariantMap params; clientSpy.clear();
|
||||
params.insert("deviceClassId", mockDeviceClassId);
|
||||
params.insert("name", "Mock device");
|
||||
params.insert("deviceParams", deviceParams);
|
||||
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||
clientSpy.wait();
|
||||
@ -493,6 +494,7 @@ void TestJSONRPC::deviceParamsChangedNotifications()
|
||||
|
||||
params.clear(); response.clear(); clientSpy.clear();
|
||||
params.insert("deviceClassId", mockDeviceClassId);
|
||||
params.insert("name", "Mock");
|
||||
params.insert("deviceParams", deviceParams);
|
||||
response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||
DeviceId deviceId = DeviceId(response.toMap().value("params").toMap().value("deviceId").toString());
|
||||
@ -520,13 +522,13 @@ void TestJSONRPC::deviceParamsChangedNotifications()
|
||||
params.clear(); response.clear(); clientSpy.clear();
|
||||
params.insert("deviceId", deviceId);
|
||||
params.insert("deviceParams", newDeviceParams);
|
||||
response = injectAndWait("Devices.EditDevice", params);
|
||||
response = injectAndWait("Devices.ReconfigureDevice", params);
|
||||
clientSpy.wait();
|
||||
verifyDeviceError(response);
|
||||
QVariantMap editDeviceNotificationMap = checkNotification(clientSpy, "Devices.DeviceParamsChanged").toMap().value("params").toMap().value("device").toMap();
|
||||
QCOMPARE(editDeviceNotificationMap.value("deviceClassId").toString(), mockDeviceClassId.toString());
|
||||
QCOMPARE(editDeviceNotificationMap.value("id").toString(), deviceId.toString());
|
||||
foreach (const QVariant ¶m, editDeviceNotificationMap.value("params").toList()) {
|
||||
QVariantMap reconfigureDeviceNotificationMap = checkNotification(clientSpy, "Devices.DeviceParamsChanged").toMap().value("params").toMap().value("device").toMap();
|
||||
QCOMPARE(reconfigureDeviceNotificationMap.value("deviceClassId").toString(), mockDeviceClassId.toString());
|
||||
QCOMPARE(reconfigureDeviceNotificationMap.value("id").toString(), deviceId.toString());
|
||||
foreach (const QVariant ¶m, reconfigureDeviceNotificationMap.value("params").toList()) {
|
||||
if (param.toMap().value("name").toString() == "httpport") {
|
||||
QCOMPARE(param.toMap().value("value").toInt(), newHttpportParam.value("value").toInt());
|
||||
}
|
||||
|
||||
@ -61,8 +61,8 @@ private slots:
|
||||
void getStateValue_data();
|
||||
void getStateValue();
|
||||
|
||||
void editDevices_data();
|
||||
void editDevices();
|
||||
void reconfigureDevices_data();
|
||||
void reconfigureDevices();
|
||||
|
||||
void editByDiscovery_data();
|
||||
void editByDiscovery();
|
||||
@ -92,9 +92,6 @@ void TestRestDevices::addConfiguredDevice_data()
|
||||
QTest::addColumn<QVariantList>("deviceParams");
|
||||
QTest::addColumn<int>("expectedStatusCode");
|
||||
|
||||
QVariantMap nameParam;
|
||||
nameParam.insert("name", "name");
|
||||
nameParam.insert("value", "Test Mockdevice");
|
||||
QVariantMap httpportParam;
|
||||
httpportParam.insert("name", "httpport");
|
||||
httpportParam.insert("value", m_mockDevice1Port - 1);
|
||||
@ -113,18 +110,18 @@ void TestRestDevices::addConfiguredDevice_data()
|
||||
|
||||
QVariantList deviceParams;
|
||||
|
||||
deviceParams.clear(); deviceParams << nameParam << httpportParam << notAsyncParam << notBrokenParam;
|
||||
deviceParams.clear(); deviceParams << httpportParam << notAsyncParam << notBrokenParam;
|
||||
QTest::newRow("User, JustAdd") << mockDeviceClassId << deviceParams << 200;
|
||||
|
||||
deviceParams.clear(); deviceParams << nameParam << httpportParam << asyncParam << notBrokenParam;
|
||||
deviceParams.clear(); deviceParams << httpportParam << asyncParam << notBrokenParam;
|
||||
QTest::newRow("User, JustAdd, Async") << mockDeviceClassId << deviceParams << 200;
|
||||
|
||||
QTest::newRow("Invalid DeviceClassId") << DeviceClassId::createDeviceClassId() << deviceParams << 500;
|
||||
|
||||
deviceParams.clear(); deviceParams << nameParam << httpportParam << brokenParam;
|
||||
deviceParams.clear(); deviceParams << httpportParam << brokenParam;
|
||||
QTest::newRow("Setup failure") << mockDeviceClassId << deviceParams << 500;
|
||||
|
||||
deviceParams.clear(); deviceParams << nameParam << httpportParam << asyncParam << brokenParam;
|
||||
deviceParams.clear(); deviceParams << httpportParam << asyncParam << brokenParam;
|
||||
QTest::newRow("Setup failure, Async") << mockDeviceClassId << deviceParams << 500;
|
||||
|
||||
QVariantList invalidDeviceParams;
|
||||
@ -149,6 +146,7 @@ void TestRestDevices::addConfiguredDevice()
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", deviceClassId);
|
||||
params.insert("name", "Mock device");
|
||||
params.insert("deviceParams", deviceParams);
|
||||
|
||||
QNetworkRequest request(QUrl("http://localhost:3333/api/v1/devices"));
|
||||
@ -211,6 +209,7 @@ void TestRestDevices::addPushButtonDevices()
|
||||
// Pair
|
||||
params.clear();
|
||||
params.insert("deviceClassId", deviceClassId.toString());
|
||||
params.insert("name", "Push button mock device");
|
||||
params.insert("deviceDescriptorId", deviceDescriptoId);
|
||||
|
||||
QNetworkRequest pairRequest(QUrl("http://localhost:3333/api/v1/devices/pair"));
|
||||
@ -291,6 +290,7 @@ void TestRestDevices::addDisplayPinDevices()
|
||||
// Pair
|
||||
params.clear();
|
||||
params.insert("deviceClassId", deviceClassId.toString());
|
||||
params.insert("name", "Display pin mock device");
|
||||
params.insert("deviceDescriptorId", deviceDescriptoId);
|
||||
|
||||
QNetworkRequest pairRequest(QUrl("http://localhost:3333/api/v1/devices/pair"));
|
||||
@ -331,10 +331,6 @@ void TestRestDevices::parentChildDevices()
|
||||
// Add parent device
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", mockParentDeviceClassId);
|
||||
QVariantMap nameParam;
|
||||
nameParam.insert("name", "name");
|
||||
nameParam.insert("value", "Test edit mockdevice");
|
||||
params.insert("deviceParams", QVariantList() << nameParam);
|
||||
|
||||
QNetworkRequest request(QUrl(QString("http://localhost:3333/api/v1/devices")));
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "text/json");
|
||||
@ -523,7 +519,7 @@ void TestRestDevices::getStateValue()
|
||||
|
||||
}
|
||||
|
||||
void TestRestDevices::editDevices_data()
|
||||
void TestRestDevices::reconfigureDevices_data()
|
||||
{
|
||||
QVariantList asyncChangeDeviceParams;
|
||||
QVariantMap asyncParamDifferent;
|
||||
@ -534,7 +530,7 @@ void TestRestDevices::editDevices_data()
|
||||
QVariantList httpportChangeDeviceParams;
|
||||
QVariantMap httpportParamDifferent;
|
||||
httpportParamDifferent.insert("name", "httpport");
|
||||
httpportParamDifferent.insert("value", 8895); // if change -> change also newPort in editDevices()
|
||||
httpportParamDifferent.insert("value", 8895); // if change -> change also newPort in reconfigureDevices()
|
||||
httpportChangeDeviceParams.append(httpportParamDifferent);
|
||||
|
||||
QVariantList brokenChangedDeviceParams;
|
||||
@ -543,35 +539,26 @@ void TestRestDevices::editDevices_data()
|
||||
brokenParamDifferent.insert("value", true);
|
||||
brokenChangedDeviceParams.append(brokenParamDifferent);
|
||||
|
||||
QVariantList nameChangedDeviceParams;
|
||||
QVariantMap nameParam;
|
||||
nameParam.insert("name", "name");
|
||||
nameParam.insert("value", "Awesome Mockdevice");
|
||||
nameChangedDeviceParams.append(nameParam);
|
||||
|
||||
QVariantList asyncAndPortChangeDeviceParams;
|
||||
asyncAndPortChangeDeviceParams.append(asyncParamDifferent);
|
||||
asyncAndPortChangeDeviceParams.append(httpportParamDifferent);
|
||||
|
||||
QVariantList changeAllWritableDeviceParams;
|
||||
changeAllWritableDeviceParams.append(nameParam);
|
||||
changeAllWritableDeviceParams.append(asyncParamDifferent);
|
||||
changeAllWritableDeviceParams.append(httpportParamDifferent);
|
||||
|
||||
|
||||
QTest::addColumn<bool>("broken");
|
||||
QTest::addColumn<QVariantList>("newDeviceParams");
|
||||
QTest::addColumn<int>("expectedStatusCode");
|
||||
QTest::addColumn<DeviceManager::DeviceError>("error");
|
||||
|
||||
QTest::newRow("valid - change async param") << false << asyncChangeDeviceParams << 200 << DeviceManager::DeviceErrorNoError;
|
||||
QTest::newRow("invalid - change async param") << false << asyncChangeDeviceParams << 500 << DeviceManager::DeviceErrorParameterNotWritable;
|
||||
QTest::newRow("valid - change httpport param") << false << httpportChangeDeviceParams << 200 << DeviceManager::DeviceErrorNoError;
|
||||
QTest::newRow("valid - change httpport and async param") << false << asyncAndPortChangeDeviceParams << 200 << DeviceManager::DeviceErrorNoError;
|
||||
QTest::newRow("invalid - change name param (not writable)") << false << nameChangedDeviceParams << 500 << DeviceManager::DeviceErrorParameterNotWritable;
|
||||
QTest::newRow("valid - change httpport and async param") << false << asyncAndPortChangeDeviceParams << 500 << DeviceManager::DeviceErrorParameterNotWritable;
|
||||
QTest::newRow("invalid - change all params (except broken)") << false << changeAllWritableDeviceParams << 500 << DeviceManager::DeviceErrorParameterNotWritable;
|
||||
}
|
||||
|
||||
void TestRestDevices::editDevices()
|
||||
void TestRestDevices::reconfigureDevices()
|
||||
{
|
||||
QFETCH(bool, broken);
|
||||
QFETCH(QVariantList, newDeviceParams);
|
||||
@ -581,11 +568,8 @@ void TestRestDevices::editDevices()
|
||||
// add device
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", mockDeviceClassId);
|
||||
params.insert("name", "Edit mock device");
|
||||
QVariantList deviceParams;
|
||||
QVariantMap nameParam;
|
||||
nameParam.insert("name", "name");
|
||||
nameParam.insert("value", "Test edit mockdevice");
|
||||
deviceParams.append(nameParam);
|
||||
QVariantMap asyncParam;
|
||||
asyncParam.insert("name", "async");
|
||||
asyncParam.insert("value", false);
|
||||
@ -691,6 +675,7 @@ void TestRestDevices::editByDiscovery()
|
||||
}
|
||||
params.clear();
|
||||
params.insert("deviceClassId", deviceClassId);
|
||||
params.insert("name", "Discovered mock device");
|
||||
params.insert("deviceDescriptorId", descriptorId1.toString());
|
||||
|
||||
QVariant response = postAndWait(request, params, expectedStatusCode);
|
||||
|
||||
Reference in New Issue
Block a user