/**************************************************************************** * * * This file is part of guh. * * * * Guh is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, version 2 of the License. * * * * Guh is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with guh. If not, see . * * * ***************************************************************************/ #include "guhtestbase.h" #include "guhcore.h" #include "devicemanager.h" #include "mocktcpserver.h" #include #include #include #include #include #include #include class TestStates: public GuhTestBase { Q_OBJECT private slots: void getStateValue_data(); void getStateValue(); }; void TestStates::getStateValue_data() { QList devices = GuhCore::instance()->findConfiguredDevices(mockDeviceClassId); QVERIFY2(devices.count() > 0, "There needs to be at least one configured Mock Device for this test"); Device *device = devices.first(); QTest::addColumn("deviceId"); QTest::addColumn("stateTypeId"); QTest::addColumn("success"); QTest::newRow("existing state") << device->id() << mockIntStateId << true; QTest::newRow("invalid device") << DeviceId::createDeviceId() << mockIntStateId << false; QTest::newRow("invalid statetype") << device->id() << StateTypeId::createStateTypeId() << false; } void TestStates::getStateValue() { QFETCH(DeviceId, deviceId); QFETCH(StateTypeId, stateTypeId); QFETCH(bool, success); QVariantMap params; params.insert("deviceId", deviceId.toString()); params.insert("stateTypeId", stateTypeId.toString()); QVariant response = injectAndWait("Devices.GetStateValue", params); verifySuccess(response, success); } #include "teststates.moc" QTEST_MAIN(TestStates)