split it up in separate projects
This commit is contained in:
parent
408c115d79
commit
2133c058cf
@ -1,34 +1,2 @@
|
|||||||
include(../../guh.pri)
|
TEMPLATE=subdirs
|
||||||
|
SUBDIRS=versioning devices jsonrpc
|
||||||
TARGET = guhtests
|
|
||||||
QT += testlib network
|
|
||||||
CONFIG += testcase c++11
|
|
||||||
DEFINES += TESTING_ENABLED
|
|
||||||
DEFINES += TESTS_SOURCE_DIR=\\\"$$top_srcdir/tests/auto/\\\"
|
|
||||||
|
|
||||||
INCLUDEPATH += $$top_srcdir/server/ $$top_srcdir/server/jsonrpc $$top_srcdir/libguh $$top_srcdir/tests/auto/
|
|
||||||
LIBS += -L$$top_builddir/libguh/ -lguh -L$$top_builddir/plugins/deviceplugins/mock/ -lguh_devicepluginmock
|
|
||||||
QMAKE_LFLAGS += -Wl,--rpath=$$top_builddir/libguh
|
|
||||||
|
|
||||||
include($$top_srcdir/server/server.pri)
|
|
||||||
|
|
||||||
testcases="TestJSONRPC TestVersioning TestDevices"
|
|
||||||
|
|
||||||
SOURCES += guhtestbase.cpp \
|
|
||||||
mocktcpserver.cpp \
|
|
||||||
testjsonrpc.cpp \
|
|
||||||
testversioning.cpp \
|
|
||||||
testdevices.cpp
|
|
||||||
|
|
||||||
HEADERS += mocktcpserver.h \
|
|
||||||
guhtestbase.h \
|
|
||||||
testdefines.h \
|
|
||||||
testversioning.h \
|
|
||||||
testjsonrpc.h \
|
|
||||||
testdevices.h
|
|
||||||
|
|
||||||
message("testcases: $${testcases}")
|
|
||||||
#DEFINES += TESTCASES=\\\"$${testcases}\\\"
|
|
||||||
#DEFINES += TESTCASES=\\\"TestJSONRPC\\\"
|
|
||||||
|
|
||||||
system(./generatedefines.sh $${testcases})
|
|
||||||
|
|||||||
5
tests/auto/devices/devices.pro
Normal file
5
tests/auto/devices/devices.pro
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
include(../../../guh.pri)
|
||||||
|
include(../autotests.pri)
|
||||||
|
|
||||||
|
TARGET = devices
|
||||||
|
SOURCES += testdevices.cpp
|
||||||
@ -16,17 +16,34 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "testdevices.h"
|
#include "guhtestbase.h"
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
|
|
||||||
TestDevices::TestDevices(QObject *parent) :
|
class TestDevices : public GuhTestBase
|
||||||
GuhTestBase(parent)
|
|
||||||
{
|
{
|
||||||
}
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void getSupportedVendors();
|
||||||
|
|
||||||
|
void getSupportedDevices_data();
|
||||||
|
void getSupportedDevices();
|
||||||
|
|
||||||
|
void addConfiguredDevice_data();
|
||||||
|
void addConfiguredDevice();
|
||||||
|
|
||||||
|
void getConfiguredDevices();
|
||||||
|
|
||||||
|
void removeDevice();
|
||||||
|
|
||||||
|
void storedDevices();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
void TestDevices::getSupportedVendors()
|
void TestDevices::getSupportedVendors()
|
||||||
{
|
{
|
||||||
@ -172,3 +189,6 @@ void TestDevices::storedDevices()
|
|||||||
response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
response = injectAndWait("Devices.RemoveConfiguredDevice", params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "testdevices.moc"
|
||||||
|
|
||||||
|
QTEST_MAIN(TestDevices)
|
||||||
@ -1,41 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo generating defines... $@
|
|
||||||
|
|
||||||
cat << EOF > testdefines.h
|
|
||||||
/****************************************************************************
|
|
||||||
* *
|
|
||||||
* 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 <QMetaType>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
for i in $@; do
|
|
||||||
echo \#include \"${i,,}.h\" >> testdefines.h
|
|
||||||
done
|
|
||||||
|
|
||||||
echo >> testdefines.h
|
|
||||||
|
|
||||||
echo \#define REGISTER_METATYPES \\ >> testdefines.h
|
|
||||||
|
|
||||||
for i in $@; do
|
|
||||||
echo qRegisterMetaType\<$i\>\(\"$i\"\)\; \\ >> testdefines.h
|
|
||||||
done
|
|
||||||
|
|
||||||
echo >> testdefines.h
|
|
||||||
|
|
||||||
echo \#define TESTCASES \"$@\" >> testdefines.h
|
|
||||||
@ -27,7 +27,6 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include "testdefines.h"
|
|
||||||
|
|
||||||
Q_IMPORT_PLUGIN(DevicePluginMock)
|
Q_IMPORT_PLUGIN(DevicePluginMock)
|
||||||
|
|
||||||
@ -99,23 +98,3 @@ QVariant GuhTestBase::injectAndWait(const QString &method, const QVariantMap &pa
|
|||||||
|
|
||||||
return jsonDoc.toVariant();
|
return jsonDoc.toVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
REGISTER_METATYPES
|
|
||||||
|
|
||||||
QGuiApplication app(argc, argv);
|
|
||||||
app.setAttribute(Qt::AA_Use96Dpi, true);
|
|
||||||
bool success = true;
|
|
||||||
qDebug() << "got testcases" << TESTCASES;
|
|
||||||
foreach (const QString &testcase, QString(TESTCASES).split(' ')) {
|
|
||||||
int id = QMetaType::type(testcase.toLatin1().data());
|
|
||||||
if (id != -1) {
|
|
||||||
GuhTestBase *testcase = static_cast<GuhTestBase*>(QMetaType::create(id));
|
|
||||||
success &= QTest::qExec(testcase, argc, argv);
|
|
||||||
delete testcase;
|
|
||||||
QCoreApplication::processEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|||||||
8
tests/auto/jsonrpc/jsonrpc.pro
Normal file
8
tests/auto/jsonrpc/jsonrpc.pro
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
include(../../../guh.pri)
|
||||||
|
include(../autotests.pri)
|
||||||
|
|
||||||
|
TARGET = jsonrpc
|
||||||
|
DEFINES += TESTING_ENABLED
|
||||||
|
DEFINES += TESTS_SOURCE_DIR=\\\"$$top_srcdir/tests/auto/\\\"
|
||||||
|
|
||||||
|
SOURCES += testjsonrpc.cpp
|
||||||
@ -17,7 +17,6 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "guhtestbase.h"
|
#include "guhtestbase.h"
|
||||||
#include "testjsonrpc.h"
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "mocktcpserver.h"
|
#include "mocktcpserver.h"
|
||||||
@ -31,6 +30,38 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
|
||||||
|
class TestJSONRPC: public GuhTestBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void testBasicCall();
|
||||||
|
void introspect();
|
||||||
|
|
||||||
|
void executeAction_data();
|
||||||
|
void executeAction();
|
||||||
|
|
||||||
|
void getActionTypes_data();
|
||||||
|
void getActionTypes();
|
||||||
|
|
||||||
|
void getEventTypes_data();
|
||||||
|
void getEventTypes();
|
||||||
|
|
||||||
|
void getStateTypes_data();
|
||||||
|
void getStateTypes();
|
||||||
|
|
||||||
|
void enableDisableNotifications_data();
|
||||||
|
void enableDisableNotifications();
|
||||||
|
|
||||||
|
void stateChangeEmitsNotifications();
|
||||||
|
|
||||||
|
void getRules();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList extractRefs(const QVariant &variant);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
QStringList TestJSONRPC::extractRefs(const QVariant &variant)
|
QStringList TestJSONRPC::extractRefs(const QVariant &variant)
|
||||||
{
|
{
|
||||||
if (variant.canConvert(QVariant::String)) {
|
if (variant.canConvert(QVariant::String)) {
|
||||||
@ -322,3 +353,7 @@ void TestJSONRPC::getRules()
|
|||||||
QVariant response = injectAndWait("Rules.GetRules", QVariantMap());
|
QVariant response = injectAndWait("Rules.GetRules", QVariantMap());
|
||||||
qDebug() << "got rules response" << response;
|
qDebug() << "got rules response" << response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "testjsonrpc.moc"
|
||||||
|
|
||||||
|
QTEST_MAIN(TestJSONRPC)
|
||||||
@ -1,50 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* *
|
|
||||||
* 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/>. *
|
|
||||||
* *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef TESTDEVICES_H
|
|
||||||
#define TESTDEVICES_H
|
|
||||||
|
|
||||||
#include "guhtestbase.h"
|
|
||||||
|
|
||||||
class TestDevices : public GuhTestBase
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit TestDevices(QObject *parent = 0);
|
|
||||||
TestDevices (const TestDevices &other) {}
|
|
||||||
TestDevices& operator=(const TestDevices &other) {}
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
|
|
||||||
void getSupportedVendors();
|
|
||||||
|
|
||||||
void getSupportedDevices_data();
|
|
||||||
void getSupportedDevices();
|
|
||||||
|
|
||||||
void addConfiguredDevice_data();
|
|
||||||
void addConfiguredDevice();
|
|
||||||
|
|
||||||
void getConfiguredDevices();
|
|
||||||
|
|
||||||
void removeDevice();
|
|
||||||
|
|
||||||
void storedDevices();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TESTDEVICES_H
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* *
|
|
||||||
* 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/>. *
|
|
||||||
* *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef TESTJSONRPC_H
|
|
||||||
#define TESTJSONRPC_H
|
|
||||||
|
|
||||||
#include "guhtestbase.h"
|
|
||||||
|
|
||||||
class TestJSONRPC: public GuhTestBase
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
TestJSONRPC(QObject *parent=0): GuhTestBase(parent) {}
|
|
||||||
TestJSONRPC (const TestJSONRPC &other) {}
|
|
||||||
TestJSONRPC& operator=(const TestJSONRPC &other) {}
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void testBasicCall();
|
|
||||||
void introspect();
|
|
||||||
|
|
||||||
void executeAction_data();
|
|
||||||
void executeAction();
|
|
||||||
|
|
||||||
void getActionTypes_data();
|
|
||||||
void getActionTypes();
|
|
||||||
|
|
||||||
void getEventTypes_data();
|
|
||||||
void getEventTypes();
|
|
||||||
|
|
||||||
void getStateTypes_data();
|
|
||||||
void getStateTypes();
|
|
||||||
|
|
||||||
void enableDisableNotifications_data();
|
|
||||||
void enableDisableNotifications();
|
|
||||||
|
|
||||||
void stateChangeEmitsNotifications();
|
|
||||||
|
|
||||||
void getRules();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QStringList extractRefs(const QVariant &variant);
|
|
||||||
|
|
||||||
};
|
|
||||||
Q_DECLARE_METATYPE(TestJSONRPC)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* *
|
|
||||||
* 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/>. *
|
|
||||||
* *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef TESTVERSIONING_H
|
|
||||||
#define TESTVERSIONING_H
|
|
||||||
|
|
||||||
#include "guhtestbase.h"
|
|
||||||
|
|
||||||
class TestVersioning: public GuhTestBase
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
TestVersioning () {}
|
|
||||||
TestVersioning (const TestVersioning &other) {}
|
|
||||||
TestVersioning& operator=(const TestVersioning &other) {}
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void version();
|
|
||||||
void apiChangeBumpsVersion();
|
|
||||||
};
|
|
||||||
Q_DECLARE_METATYPE(TestVersioning);
|
|
||||||
|
|
||||||
#endif //TESTVERSIONING_H
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "testversioning.h"
|
#include "guhtestbase.h"
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "mocktcpserver.h"
|
#include "mocktcpserver.h"
|
||||||
@ -29,6 +29,15 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
class TestVersioning: public GuhTestBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void version();
|
||||||
|
void apiChangeBumpsVersion();
|
||||||
|
};
|
||||||
|
|
||||||
void TestVersioning::version()
|
void TestVersioning::version()
|
||||||
{
|
{
|
||||||
QVariant response = injectAndWait("JSONRPC.Version");
|
QVariant response = injectAndWait("JSONRPC.Version");
|
||||||
@ -87,3 +96,6 @@ void TestVersioning::apiChangeBumpsVersion()
|
|||||||
|
|
||||||
QVERIFY2(false, QString("JSONRPC API has changed. Update %1.").arg(oldFilePath).toLatin1().data());
|
QVERIFY2(false, QString("JSONRPC API has changed. Update %1.").arg(oldFilePath).toLatin1().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "testversioning.moc"
|
||||||
|
QTEST_MAIN(TestVersioning)
|
||||||
5
tests/auto/versioning/versioning.pro
Normal file
5
tests/auto/versioning/versioning.pro
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
include(../../../guh.pri)
|
||||||
|
include(../autotests.pri)
|
||||||
|
|
||||||
|
TARGET = versioning
|
||||||
|
SOURCES += testversioning.cpp
|
||||||
Reference in New Issue
Block a user