add test for edit device name
This commit is contained in:
parent
1ef6c80e79
commit
4d5429cb2b
5
guh.pri
5
guh.pri
@ -20,10 +20,7 @@ equals(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 3) {
|
|||||||
DEFINES += BLUETOOTH_LE
|
DEFINES += BLUETOOTH_LE
|
||||||
}
|
}
|
||||||
|
|
||||||
top_srcdir=$$PWD
|
# Enable coverage option
|
||||||
top_builddir=$$shadowed($$PWD)
|
|
||||||
|
|
||||||
# Enable coverage option
|
|
||||||
coverage {
|
coverage {
|
||||||
OBJECTS_DIR =
|
OBJECTS_DIR =
|
||||||
MOC_DIR =
|
MOC_DIR =
|
||||||
|
|||||||
@ -84,6 +84,10 @@ private slots:
|
|||||||
void getStateValues_data();
|
void getStateValues_data();
|
||||||
void getStateValues();
|
void getStateValues();
|
||||||
|
|
||||||
|
void editDevices_data();
|
||||||
|
void editDevices();
|
||||||
|
|
||||||
|
|
||||||
void reconfigureDevices_data();
|
void reconfigureDevices_data();
|
||||||
void reconfigureDevices();
|
void reconfigureDevices();
|
||||||
|
|
||||||
@ -737,6 +741,62 @@ void TestDevices::getStateValues()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestDevices::editDevices_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QString>("name");
|
||||||
|
|
||||||
|
QTest::newRow("change name") << "New device name";
|
||||||
|
QTest::newRow("change name") << "Blub device";
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestDevices::editDevices()
|
||||||
|
{
|
||||||
|
QFETCH(QString, name);
|
||||||
|
|
||||||
|
QString originalName = "Test device";
|
||||||
|
|
||||||
|
// add device
|
||||||
|
QVariantMap params;
|
||||||
|
params.insert("deviceClassId", mockParentDeviceClassId);
|
||||||
|
params.insert("name", originalName);
|
||||||
|
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params);
|
||||||
|
verifyDeviceError(response);
|
||||||
|
DeviceId deviceId = DeviceId(response.toMap().value("params").toMap().value("deviceId").toString());
|
||||||
|
|
||||||
|
// edit device
|
||||||
|
params.clear();
|
||||||
|
params.insert("deviceId", deviceId);
|
||||||
|
params.insert("name", name);
|
||||||
|
|
||||||
|
response = injectAndWait("Devices.EditDevice", params);
|
||||||
|
verifyDeviceError(response);
|
||||||
|
|
||||||
|
QString newName;
|
||||||
|
response = injectAndWait("Devices.GetConfiguredDevices");
|
||||||
|
devices = response.toMap().value("params").toMap().value("devices").toList();
|
||||||
|
foreach (const QVariant &deviceVariant, devices) {
|
||||||
|
QVariantMap device = deviceVariant.toMap();
|
||||||
|
if (DeviceId(device.value("deviceId").toString()) == m_mockDeviceId) {
|
||||||
|
qDebug() << device.value("name").toString();
|
||||||
|
newName = device.value("name").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QCOMPARE(newName, name);
|
||||||
|
|
||||||
|
restartServer();
|
||||||
|
|
||||||
|
response = injectAndWait("Devices.GetConfiguredDevices");
|
||||||
|
devices = response.toMap().value("params").toMap().value("devices").toList();
|
||||||
|
foreach (const QVariant &deviceVariant, devices) {
|
||||||
|
QVariantMap device = deviceVariant.toMap();
|
||||||
|
if (DeviceId(device.value("deviceId").toString()) == m_mockDeviceId) {
|
||||||
|
newName = device.value("name").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QCOMPARE(newName, name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TestDevices::reconfigureDevices_data()
|
void TestDevices::reconfigureDevices_data()
|
||||||
{
|
{
|
||||||
QVariantList asyncChangeDeviceParams;
|
QVariantList asyncChangeDeviceParams;
|
||||||
|
|||||||
Reference in New Issue
Block a user