test GetPlugins and removeDevice with an invalid param
This commit is contained in:
parent
70f6f783b9
commit
8334ec89ff
@ -25,6 +25,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
||||||
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
||||||
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
|
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
|
||||||
DeviceClassId mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
|
DeviceClassId mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
|
||||||
@ -202,7 +203,7 @@ QString DevicePluginMock::pluginName() const
|
|||||||
|
|
||||||
PluginId DevicePluginMock::pluginId() const
|
PluginId DevicePluginMock::pluginId() const
|
||||||
{
|
{
|
||||||
return PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
return mockPluginId;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMock::setupDevice(Device *device)
|
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMock::setupDevice(Device *device)
|
||||||
|
|||||||
@ -29,6 +29,8 @@ class TestDevices : public GuhTestBase
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void getPlugins();
|
||||||
|
|
||||||
void getSupportedVendors();
|
void getSupportedVendors();
|
||||||
|
|
||||||
void getSupportedDevices_data();
|
void getSupportedDevices_data();
|
||||||
@ -39,6 +41,7 @@ private slots:
|
|||||||
|
|
||||||
void getConfiguredDevices();
|
void getConfiguredDevices();
|
||||||
|
|
||||||
|
void removeDevice_data();
|
||||||
void removeDevice();
|
void removeDevice();
|
||||||
|
|
||||||
void storedDevices();
|
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()
|
void TestDevices::getSupportedVendors()
|
||||||
{
|
{
|
||||||
QVariant supportedVendors = injectAndWait("Devices.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()
|
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()
|
void TestDevices::removeDevice()
|
||||||
{
|
{
|
||||||
QVERIFY(!m_mockDeviceId.isNull());
|
QFETCH(DeviceId, deviceId);
|
||||||
|
QFETCH(bool, success);
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup(m_mockDeviceId.toString());
|
if (success) {
|
||||||
// Make sure we have some config values for this device
|
settings.beginGroup(m_mockDeviceId.toString());
|
||||||
QVERIFY(settings.allKeys().count() > 0);
|
// Make sure we have some config values for this device
|
||||||
|
QVERIFY(settings.allKeys().count() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap params;
|
QVariantMap params;
|
||||||
params.insert("deviceId", m_mockDeviceId);
|
params.insert("deviceId", deviceId);
|
||||||
|
|
||||||
QVariant response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
QVariant response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
||||||
|
|
||||||
verifySuccess(response);
|
verifySuccess(response, success);
|
||||||
|
|
||||||
// Make sure the device is gone from settings too
|
if (success) {
|
||||||
QCOMPARE(settings.allKeys().count(), 0);
|
// Make sure the device is gone from settings too
|
||||||
|
QCOMPARE(settings.allKeys().count(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDevices::storedDevices()
|
void TestDevices::storedDevices()
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
|
extern PluginId mockPluginId;
|
||||||
extern VendorId guhVendorId;
|
extern VendorId guhVendorId;
|
||||||
extern DeviceClassId mockDeviceClassId;
|
extern DeviceClassId mockDeviceClassId;
|
||||||
extern DeviceClassId mockDeviceAutoClassId;
|
extern DeviceClassId mockDeviceAutoClassId;
|
||||||
|
|||||||
Reference in New Issue
Block a user