added tests for GetStateValue
This commit is contained in:
parent
8334ec89ff
commit
016126e38c
@ -1,2 +1,2 @@
|
||||
TEMPLATE=subdirs
|
||||
SUBDIRS=versioning devices jsonrpc events
|
||||
SUBDIRS=versioning devices jsonrpc events states
|
||||
|
||||
@ -3,6 +3,4 @@ TARGET = events
|
||||
include(../../../guh.pri)
|
||||
include(../autotests.pri)
|
||||
|
||||
DEFINES += TESTS_SOURCE_DIR=\\\"$$top_srcdir/tests/auto/\\\"
|
||||
|
||||
SOURCES += testevents.cpp
|
||||
|
||||
6
tests/auto/states/states.pro
Normal file
6
tests/auto/states/states.pro
Normal file
@ -0,0 +1,6 @@
|
||||
TARGET = states
|
||||
|
||||
include(../../../guh.pri)
|
||||
include(../autotests.pri)
|
||||
|
||||
SOURCES += teststates.cpp
|
||||
74
tests/auto/states/teststates.cpp
Normal file
74
tests/auto/states/teststates.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "guhtestbase.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QCoreApplication>
|
||||
#include <QTcpSocket>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QCoreApplication>
|
||||
|
||||
class TestStates: public GuhTestBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void getStateValue_data();
|
||||
void getStateValue();
|
||||
};
|
||||
|
||||
void TestStates::getStateValue_data()
|
||||
{
|
||||
QList<Device*> devices = GuhCore::instance()->deviceManager()->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>("deviceId");
|
||||
QTest::addColumn<StateTypeId>("stateTypeId");
|
||||
QTest::addColumn<bool>("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);
|
||||
|
||||
qDebug() << "got response" << response;
|
||||
|
||||
verifySuccess(response, success);
|
||||
}
|
||||
|
||||
#include "teststates.moc"
|
||||
QTEST_MAIN(TestStates)
|
||||
Reference in New Issue
Block a user