split it up in separate projects

This commit is contained in:
Michael Zanetti 2014-05-04 00:38:04 +02:00
parent 408c115d79
commit 2133c058cf
12 changed files with 93 additions and 251 deletions

View File

@ -1,34 +1,2 @@
include(../../guh.pri)
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})
TEMPLATE=subdirs
SUBDIRS=versioning devices jsonrpc

View File

@ -0,0 +1,5 @@
include(../../../guh.pri)
include(../autotests.pri)
TARGET = devices
SOURCES += testdevices.cpp

View File

@ -16,17 +16,34 @@
* *
***************************************************************************/
#include "testdevices.h"
#include "guhtestbase.h"
#include "guhcore.h"
#include "devicemanager.h"
#include <QDebug>
#include <QSignalSpy>
TestDevices::TestDevices(QObject *parent) :
GuhTestBase(parent)
class TestDevices : public GuhTestBase
{
}
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()
{
@ -172,3 +189,6 @@ void TestDevices::storedDevices()
response = injectAndWait("Devices.RemoveConfiguredDevice", params);
}
#include "testdevices.moc"
QTEST_MAIN(TestDevices)

View File

@ -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

View File

@ -27,7 +27,6 @@
#include <QSettings>
#include <QtTest>
#include <QMetaType>
#include "testdefines.h"
Q_IMPORT_PLUGIN(DevicePluginMock)
@ -99,23 +98,3 @@ QVariant GuhTestBase::injectAndWait(const QString &method, const QVariantMap &pa
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;
}

View 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

View File

@ -17,7 +17,6 @@
***************************************************************************/
#include "guhtestbase.h"
#include "testjsonrpc.h"
#include "guhcore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -31,6 +30,38 @@
#include <QCoreApplication>
#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)
{
if (variant.canConvert(QVariant::String)) {
@ -322,3 +353,7 @@ void TestJSONRPC::getRules()
QVariant response = injectAndWait("Rules.GetRules", QVariantMap());
qDebug() << "got rules response" << response;
}
#include "testjsonrpc.moc"
QTEST_MAIN(TestJSONRPC)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -16,7 +16,7 @@
* *
***************************************************************************/
#include "testversioning.h"
#include "guhtestbase.h"
#include "guhcore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -29,6 +29,15 @@
#include <QNetworkReply>
#include <QCoreApplication>
class TestVersioning: public GuhTestBase
{
Q_OBJECT
private slots:
void version();
void apiChangeBumpsVersion();
};
void TestVersioning::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());
}
#include "testversioning.moc"
QTEST_MAIN(TestVersioning)

View File

@ -0,0 +1,5 @@
include(../../../guh.pri)
include(../autotests.pri)
TARGET = versioning
SOURCES += testversioning.cpp