Add test trigger for auto device reconfiguration
This commit is contained in:
parent
beb00aa0f1
commit
36778e8eda
@ -110,6 +110,7 @@ DeviceManager::DeviceSetupStatus DevicePluginMock::setupDevice(Device *device)
|
|||||||
connect(daemon, &HttpDaemon::setState, this, &DevicePluginMock::setState);
|
connect(daemon, &HttpDaemon::setState, this, &DevicePluginMock::setState);
|
||||||
// Keep this queued or it might happen that the HttpDaemon is deleted before it is able to reply to the caller
|
// Keep this queued or it might happen that the HttpDaemon is deleted before it is able to reply to the caller
|
||||||
connect(daemon, &HttpDaemon::disappear, this, &DevicePluginMock::onDisappear, Qt::QueuedConnection);
|
connect(daemon, &HttpDaemon::disappear, this, &DevicePluginMock::onDisappear, Qt::QueuedConnection);
|
||||||
|
connect(daemon, &HttpDaemon::reconfigureAutodevice, this, &DevicePluginMock::onReconfigureAutoDevice, Qt::QueuedConnection);
|
||||||
|
|
||||||
if (async) {
|
if (async) {
|
||||||
m_asyncSetupDevices.append(device);
|
m_asyncSetupDevices.append(device);
|
||||||
|
|||||||
@ -52,6 +52,8 @@ private slots:
|
|||||||
|
|
||||||
void storedDevices();
|
void storedDevices();
|
||||||
|
|
||||||
|
void reconfigureAutodevice();
|
||||||
|
|
||||||
void discoverDevices_data();
|
void discoverDevices_data();
|
||||||
void discoverDevices();
|
void discoverDevices();
|
||||||
|
|
||||||
@ -91,7 +93,6 @@ private slots:
|
|||||||
void reconfigureByDiscovery();
|
void reconfigureByDiscovery();
|
||||||
|
|
||||||
void reconfigureByDiscoveryAndPair();
|
void reconfigureByDiscoveryAndPair();
|
||||||
void reconfigureAutodevice();
|
|
||||||
|
|
||||||
void removeDevice_data();
|
void removeDevice_data();
|
||||||
void removeDevice();
|
void removeDevice();
|
||||||
@ -1278,17 +1279,23 @@ void TestDevices::reconfigureByDiscoveryAndPair()
|
|||||||
|
|
||||||
void TestDevices::reconfigureAutodevice()
|
void TestDevices::reconfigureAutodevice()
|
||||||
{
|
{
|
||||||
// Get the current autodevice
|
qCDebug(dcTests()) << "Reconfigure auto device";
|
||||||
|
|
||||||
QVariant response = injectAndWait("Devices.GetConfiguredDevices");
|
QList<Device *> devices = NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceAutoClassId);
|
||||||
QVariantList devices = response.toMap().value("params").toMap().value("devices").toList();
|
QVERIFY2(devices.count() > 0, "There needs to be at least one auto-created Mock Device for this test");
|
||||||
|
Device *device = devices.first();
|
||||||
|
|
||||||
|
// Setup connection to mock client
|
||||||
|
QNetworkAccessManager *nam = new QNetworkAccessManager(this);
|
||||||
|
QSignalSpy spy(nam, SIGNAL(finished(QNetworkReply*)));
|
||||||
|
|
||||||
|
// trigger reconfigure signal in mock device
|
||||||
|
QNetworkReply *reply = nam->get(QNetworkRequest(QUrl(QString("http://localhost:%1/reconfigureautodevice").arg(device->paramValue(httpportParamTypeId).toInt()))));
|
||||||
|
spy.wait();
|
||||||
|
QCOMPARE(spy.count(), 1);
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
QVariantMap autoDevice;
|
|
||||||
foreach (const QVariant &deviceVariant, devices) {
|
|
||||||
QVariantMap deviceMap = deviceVariant.toMap();
|
|
||||||
qDebug() << deviceMap;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user