mirror of https://github.com/nymea/nymea.git
test GetPlugins and removeDevice with an invalid param
parent
70f6f783b9
commit
8334ec89ff
|
|
@ -25,6 +25,7 @@
|
|||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
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");
|
||||
|
|
@ -202,7 +203,7 @@ QString DevicePluginMock::pluginName() const
|
|||
|
||||
PluginId DevicePluginMock::pluginId() const
|
||||
{
|
||||
return PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
||||
return mockPluginId;
|
||||
}
|
||||
|
||||
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMock::setupDevice(Device *device)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class TestDevices : public GuhTestBase
|
|||
|
||||
private slots:
|
||||
|
||||
void getPlugins();
|
||||
|
||||
void getSupportedVendors();
|
||||
|
||||
void getSupportedDevices_data();
|
||||
|
|
@ -39,6 +41,7 @@ private slots:
|
|||
|
||||
void getConfiguredDevices();
|
||||
|
||||
void removeDevice_data();
|
||||
void removeDevice();
|
||||
|
||||
void storedDevices();
|
||||
|
|
@ -47,6 +50,16 @@ private slots:
|
|||
|
||||
};
|
||||
|
||||
void TestDevices::getPlugins()
|
||||
{
|
||||
QVariant response = injectAndWait("Devices.GetPlugins");
|
||||
|
||||
QVariantList plugins = response.toMap().value("params").toMap().value("plugins").toList();
|
||||
|
||||
QCOMPARE(plugins.count(), 1);
|
||||
QCOMPARE(PluginId(plugins.first().toMap().value("id").toString()), mockPluginId);
|
||||
}
|
||||
|
||||
void TestDevices::getSupportedVendors()
|
||||
{
|
||||
QVariant supportedVendors = injectAndWait("Devices.GetSupportedVendors");
|
||||
|
|
@ -143,23 +156,38 @@ void TestDevices::getConfiguredDevices()
|
|||
QCOMPARE(devices.count(), 2); // There should be one auto created mock device and the one created in initTestcase()
|
||||
}
|
||||
|
||||
void TestDevices::removeDevice_data()
|
||||
{
|
||||
QTest::addColumn<DeviceId>("deviceId");
|
||||
QTest::addColumn<bool>("success");
|
||||
|
||||
QTest::newRow("Existing Device") << m_mockDeviceId << true;
|
||||
QTest::newRow("Not existing Device") << DeviceId::createDeviceId() << false;
|
||||
}
|
||||
|
||||
void TestDevices::removeDevice()
|
||||
{
|
||||
QVERIFY(!m_mockDeviceId.isNull());
|
||||
QFETCH(DeviceId, deviceId);
|
||||
QFETCH(bool, success);
|
||||
|
||||
QSettings settings;
|
||||
settings.beginGroup(m_mockDeviceId.toString());
|
||||
// Make sure we have some config values for this device
|
||||
QVERIFY(settings.allKeys().count() > 0);
|
||||
if (success) {
|
||||
settings.beginGroup(m_mockDeviceId.toString());
|
||||
// Make sure we have some config values for this device
|
||||
QVERIFY(settings.allKeys().count() > 0);
|
||||
}
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("deviceId", m_mockDeviceId);
|
||||
params.insert("deviceId", deviceId);
|
||||
|
||||
QVariant response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
||||
|
||||
verifySuccess(response);
|
||||
verifySuccess(response, success);
|
||||
|
||||
// Make sure the device is gone from settings too
|
||||
QCOMPARE(settings.allKeys().count(), 0);
|
||||
if (success) {
|
||||
// Make sure the device is gone from settings too
|
||||
QCOMPARE(settings.allKeys().count(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TestDevices::storedDevices()
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <QVariantMap>
|
||||
#include <QtTest>
|
||||
|
||||
extern PluginId mockPluginId;
|
||||
extern VendorId guhVendorId;
|
||||
extern DeviceClassId mockDeviceClassId;
|
||||
extern DeviceClassId mockDeviceAutoClassId;
|
||||
|
|
|
|||
Loading…
Reference in New Issue