diff --git a/plugins/deviceplugins/mock/devicepluginmock.cpp b/plugins/deviceplugins/mock/devicepluginmock.cpp index 48c86ee4..a52abaee 100644 --- a/plugins/deviceplugins/mock/devicepluginmock.cpp +++ b/plugins/deviceplugins/mock/devicepluginmock.cpp @@ -25,6 +25,7 @@ #include #include +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 DevicePluginMock::setupDevice(Device *device) diff --git a/tests/auto/devices/testdevices.cpp b/tests/auto/devices/testdevices.cpp index 2c760a99..828ce187 100644 --- a/tests/auto/devices/testdevices.cpp +++ b/tests/auto/devices/testdevices.cpp @@ -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"); + QTest::addColumn("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() diff --git a/tests/auto/guhtestbase.h b/tests/auto/guhtestbase.h index c239024c..75764680 100644 --- a/tests/auto/guhtestbase.h +++ b/tests/auto/guhtestbase.h @@ -27,6 +27,7 @@ #include #include +extern PluginId mockPluginId; extern VendorId guhVendorId; extern DeviceClassId mockDeviceClassId; extern DeviceClassId mockDeviceAutoClassId;