added more devicemanager tests
This commit is contained in:
parent
edb6c956e6
commit
bce1cacbc7
@ -136,5 +136,6 @@ private:
|
||||
friend class DevicePlugin;
|
||||
};
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(DeviceManager::HardwareResources)
|
||||
Q_DECLARE_METATYPE(DeviceManager::DeviceError)
|
||||
|
||||
#endif // DEVICEMANAGER_H
|
||||
|
||||
@ -30,6 +30,7 @@ DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab
|
||||
DeviceClassId mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
|
||||
DeviceClassId mockDeviceDiscoveryClassId = DeviceClassId("1bbaf751-36b7-4d3d-b05a-58dab2a3be8c");
|
||||
DeviceClassId mockDeviceAsyncSetupClassId = DeviceClassId("c08a8b27-8200-413d-b96b-4cff78b864d9");
|
||||
DeviceClassId mockDeviceBrokenClassId = DeviceClassId("ba5fb404-c9ce-4db4-8cd4-f48c61c24b13");
|
||||
EventTypeId mockEvent1Id = EventTypeId("45bf3752-0fc6-46b9-89fd-ffd878b5b22b");
|
||||
EventTypeId mockEvent2Id = EventTypeId("863d5920-b1cf-4eb9-88bd-8f7b8583b1cf");
|
||||
StateTypeId mockIntStateId = StateTypeId("80baec19-54de-4948-ac46-31eabfaceb83");
|
||||
@ -146,8 +147,6 @@ QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
||||
deviceClassMockAsync.setName("Mock Device (Async setup)");
|
||||
deviceClassMockAsync.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
|
||||
mockParams.clear();
|
||||
mockParams.append(portParam);
|
||||
deviceClassMockAsync.setParams(mockParams);
|
||||
deviceClassMockAsync.setStates(mockStates);
|
||||
deviceClassMockAsync.setEvents(mockEvents);
|
||||
@ -155,6 +154,18 @@ QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
||||
|
||||
ret.append(deviceClassMockAsync);
|
||||
|
||||
// Async setup device
|
||||
DeviceClass deviceClassMockBroken(pluginId(), guhVendorId, mockDeviceBrokenClassId);
|
||||
deviceClassMockBroken.setName("Mock Device (Broken setup)");
|
||||
deviceClassMockBroken.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
|
||||
deviceClassMockBroken.setParams(mockParams);
|
||||
deviceClassMockBroken.setStates(mockStates);
|
||||
deviceClassMockBroken.setEvents(mockEvents);
|
||||
deviceClassMockBroken.setActions(mockActions);
|
||||
|
||||
ret.append(deviceClassMockBroken);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -185,6 +196,10 @@ QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMock::setupDevice(D
|
||||
{
|
||||
qDebug() << "Mockdevice created returning true" << device->paramValue("httpport").toInt();
|
||||
|
||||
if (device->deviceClassId() == mockDeviceBrokenClassId) {
|
||||
return reportDeviceSetup(DeviceManager::DeviceSetupStatusFailure, "This device is intentionally broken.");
|
||||
}
|
||||
|
||||
HttpDaemon *daemon = new HttpDaemon(device, this);
|
||||
m_daemons.insert(device, daemon);
|
||||
|
||||
|
||||
@ -101,6 +101,8 @@ void TestDevices::addConfiguredDevice_data()
|
||||
QTest::newRow("Auto, JustAdd") << mockDeviceAutoClassId << deviceParams << false;
|
||||
QTest::newRow("Discovery, JustAdd") << mockDeviceDiscoveryClassId << deviceParams << false;
|
||||
QTest::newRow("User, JustAdd, Async") << mockDeviceAsyncSetupClassId << deviceParams << true;
|
||||
QTest::newRow("Invalid DeviceClassId") << DeviceClassId::createDeviceClassId() << deviceParams << false;
|
||||
QTest::newRow("Setup failure") << mockDeviceBrokenClassId << deviceParams << false;
|
||||
|
||||
QVariantMap invalidDeviceParams;
|
||||
invalidDeviceParams.insert("tropptth", m_mockDevice1Port - 1);
|
||||
|
||||
@ -32,6 +32,7 @@ extern DeviceClassId mockDeviceClassId;
|
||||
extern DeviceClassId mockDeviceAutoClassId;
|
||||
extern DeviceClassId mockDeviceDiscoveryClassId;
|
||||
extern DeviceClassId mockDeviceAsyncSetupClassId;
|
||||
extern DeviceClassId mockDeviceBrokenClassId;
|
||||
extern ActionTypeId mockAction1Id;
|
||||
extern EventTypeId mockEvent1Id;
|
||||
extern StateTypeId mockIntStateId;
|
||||
|
||||
Reference in New Issue
Block a user