Implement autodevice reconfigure in mock plugin and prepare tests
This commit is contained in:
parent
13b0f38693
commit
beb00aa0f1
@ -260,3 +260,11 @@ Device *Devices::findById(const DeviceId &id)
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, Device *device)
|
||||||
|
{
|
||||||
|
dbg.nospace() << "Device(" << device->name();
|
||||||
|
dbg.nospace() << ", id" << device->id();
|
||||||
|
dbg.nospace() << ", deviceClassId" << device->deviceClassId() << ")";
|
||||||
|
return dbg.space();
|
||||||
|
}
|
||||||
|
|||||||
@ -94,6 +94,8 @@ private:
|
|||||||
bool m_autoCreated = false;
|
bool m_autoCreated = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, Device *device);
|
||||||
|
|
||||||
class Devices: public QList<Device*>
|
class Devices: public QList<Device*>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -383,6 +383,24 @@ void DevicePluginMock::onDisappear()
|
|||||||
emit autoDeviceDisappeared(device->id());
|
emit autoDeviceDisappeared(device->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DevicePluginMock::onReconfigureAutoDevice()
|
||||||
|
{
|
||||||
|
HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender());
|
||||||
|
if (!daemon) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Device *device = m_daemons.key(daemon);
|
||||||
|
qCDebug(dcMockDevice) << "Reconfigure auto device for" << device;
|
||||||
|
|
||||||
|
DeviceDescriptor deviceDescriptor;
|
||||||
|
deviceDescriptor.setTitle(device->name() + " (reconfigured)");
|
||||||
|
deviceDescriptor.setDescription("This auto device was reconfigured");
|
||||||
|
deviceDescriptor.setDeviceId(device->id());
|
||||||
|
deviceDescriptor.setParams(device->params());
|
||||||
|
|
||||||
|
emit autoDevicesAppeared(mockDeviceAutoDeviceClassId, { deviceDescriptor });
|
||||||
|
}
|
||||||
|
|
||||||
void DevicePluginMock::emitDevicesDiscovered()
|
void DevicePluginMock::emitDevicesDiscovered()
|
||||||
{
|
{
|
||||||
QList<DeviceDescriptor> deviceDescriptors;
|
QList<DeviceDescriptor> deviceDescriptors;
|
||||||
|
|||||||
@ -59,6 +59,7 @@ private slots:
|
|||||||
void setState(const StateTypeId &stateTypeId, const QVariant &value);
|
void setState(const StateTypeId &stateTypeId, const QVariant &value);
|
||||||
void triggerEvent(const EventTypeId &id);
|
void triggerEvent(const EventTypeId &id);
|
||||||
void onDisappear();
|
void onDisappear();
|
||||||
|
void onReconfigureAutoDevice();
|
||||||
void emitDevicesDiscovered();
|
void emitDevicesDiscovered();
|
||||||
void emitPushButtonDevicesDiscovered();
|
void emitPushButtonDevicesDiscovered();
|
||||||
void emitDisplayPinDevicesDiscovered();
|
void emitDisplayPinDevicesDiscovered();
|
||||||
|
|||||||
@ -114,6 +114,9 @@ void HttpDaemon::readClient()
|
|||||||
} else if (url.path() == "/disappear") {
|
} else if (url.path() == "/disappear") {
|
||||||
qCDebug(dcMockDevice) << "Should disappear";
|
qCDebug(dcMockDevice) << "Should disappear";
|
||||||
emit disappear();
|
emit disappear();
|
||||||
|
} else if (url.path() == "/reconfigureautodevice") {
|
||||||
|
qCDebug(dcMockDevice) << "Reconfigure auto device";
|
||||||
|
emit reconfigureAutodevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokens[0] == "GET") {
|
if (tokens[0] == "GET") {
|
||||||
|
|||||||
@ -47,6 +47,7 @@ signals:
|
|||||||
void setState(const StateTypeId &stateTypeId, const QVariant &value);
|
void setState(const StateTypeId &stateTypeId, const QVariant &value);
|
||||||
void triggerEvent(const EventTypeId &eventTypeId);
|
void triggerEvent(const EventTypeId &eventTypeId);
|
||||||
void disappear();
|
void disappear();
|
||||||
|
void reconfigureAutodevice();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void readClient();
|
void readClient();
|
||||||
|
|||||||
@ -91,6 +91,7 @@ private slots:
|
|||||||
void reconfigureByDiscovery();
|
void reconfigureByDiscovery();
|
||||||
|
|
||||||
void reconfigureByDiscoveryAndPair();
|
void reconfigureByDiscoveryAndPair();
|
||||||
|
void reconfigureAutodevice();
|
||||||
|
|
||||||
void removeDevice_data();
|
void removeDevice_data();
|
||||||
void removeDevice();
|
void removeDevice();
|
||||||
@ -1275,6 +1276,22 @@ void TestDevices::reconfigureByDiscoveryAndPair()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestDevices::reconfigureAutodevice()
|
||||||
|
{
|
||||||
|
// Get the current autodevice
|
||||||
|
|
||||||
|
QVariant response = injectAndWait("Devices.GetConfiguredDevices");
|
||||||
|
QVariantList devices = response.toMap().value("params").toMap().value("devices").toList();
|
||||||
|
|
||||||
|
QVariantMap autoDevice;
|
||||||
|
foreach (const QVariant &deviceVariant, devices) {
|
||||||
|
QVariantMap deviceMap = deviceVariant.toMap();
|
||||||
|
qDebug() << deviceMap;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TestDevices::removeDevice_data()
|
void TestDevices::removeDevice_data()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user