/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2015 Simon Stuerz * * Copyright (C) 2014 Michael Zanetti * * * * 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("error"); QTest::newRow("existing state") << device->id() << mockIntStateId << DeviceManager::DeviceErrorNoError; QTest::newRow("invalid device") << DeviceId::createDeviceId() << mockIntStateId << DeviceManager::DeviceErrorDeviceNotFound; QTest::newRow("invalid statetype") << device->id() << StateTypeId::createStateTypeId() << DeviceManager::DeviceErrorStateTypeNotFound; } void TestStates::getStateValue() { QFETCH(DeviceId, deviceId); QFETCH(StateTypeId, stateTypeId); QFETCH(DeviceManager::DeviceError, error); QVariantMap params; params.insert("deviceId", deviceId.toString()); params.insert("stateTypeId", stateTypeId.toString()); QVariant response = injectAndWait("Devices.GetStateValue", params); verifyDeviceError(response, error); } #include "teststates.moc" QTEST_MAIN(TestStates)