From 2133c058cf3312b46bfcb4fd50c58a2f82795ea5 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 4 May 2014 00:38:04 +0200 Subject: [PATCH] split it up in separate projects --- tests/auto/auto.pro | 36 +---------- tests/auto/devices/devices.pro | 5 ++ tests/auto/{ => devices}/testdevices.cpp | 28 +++++++-- tests/auto/generatedefines.sh | 41 ------------- tests/auto/guhtestbase.cpp | 21 ------- tests/auto/jsonrpc/jsonrpc.pro | 8 +++ tests/auto/{ => jsonrpc}/testjsonrpc.cpp | 37 ++++++++++- tests/auto/testdevices.h | 50 --------------- tests/auto/testjsonrpc.h | 61 ------------------- tests/auto/testversioning.h | 38 ------------ .../auto/{ => versioning}/testversioning.cpp | 14 ++++- tests/auto/versioning/versioning.pro | 5 ++ 12 files changed, 93 insertions(+), 251 deletions(-) create mode 100644 tests/auto/devices/devices.pro rename tests/auto/{ => devices}/testdevices.cpp (94%) delete mode 100755 tests/auto/generatedefines.sh create mode 100644 tests/auto/jsonrpc/jsonrpc.pro rename tests/auto/{ => jsonrpc}/testjsonrpc.cpp (95%) delete mode 100644 tests/auto/testdevices.h delete mode 100644 tests/auto/testjsonrpc.h delete mode 100644 tests/auto/testversioning.h rename tests/auto/{ => versioning}/testversioning.cpp (94%) create mode 100644 tests/auto/versioning/versioning.pro diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 8a09deaa..a8b34056 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -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 diff --git a/tests/auto/devices/devices.pro b/tests/auto/devices/devices.pro new file mode 100644 index 00000000..b8d607bc --- /dev/null +++ b/tests/auto/devices/devices.pro @@ -0,0 +1,5 @@ +include(../../../guh.pri) +include(../autotests.pri) + +TARGET = devices +SOURCES += testdevices.cpp diff --git a/tests/auto/testdevices.cpp b/tests/auto/devices/testdevices.cpp similarity index 94% rename from tests/auto/testdevices.cpp rename to tests/auto/devices/testdevices.cpp index df4be1db..591a2616 100644 --- a/tests/auto/testdevices.cpp +++ b/tests/auto/devices/testdevices.cpp @@ -16,17 +16,34 @@ * * ***************************************************************************/ -#include "testdevices.h" +#include "guhtestbase.h" #include "guhcore.h" #include "devicemanager.h" #include #include -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) diff --git a/tests/auto/generatedefines.sh b/tests/auto/generatedefines.sh deleted file mode 100755 index c311b982..00000000 --- a/tests/auto/generatedefines.sh +++ /dev/null @@ -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 . * - * * - ***************************************************************************/ - -#include -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 diff --git a/tests/auto/guhtestbase.cpp b/tests/auto/guhtestbase.cpp index 569237f9..9e4b7547 100644 --- a/tests/auto/guhtestbase.cpp +++ b/tests/auto/guhtestbase.cpp @@ -27,7 +27,6 @@ #include #include #include -#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(QMetaType::create(id)); - success &= QTest::qExec(testcase, argc, argv); - delete testcase; - QCoreApplication::processEvents(); - } - } - return success; -} diff --git a/tests/auto/jsonrpc/jsonrpc.pro b/tests/auto/jsonrpc/jsonrpc.pro new file mode 100644 index 00000000..aeced67f --- /dev/null +++ b/tests/auto/jsonrpc/jsonrpc.pro @@ -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 diff --git a/tests/auto/testjsonrpc.cpp b/tests/auto/jsonrpc/testjsonrpc.cpp similarity index 95% rename from tests/auto/testjsonrpc.cpp rename to tests/auto/jsonrpc/testjsonrpc.cpp index 5245d9c2..ff5d73b7 100644 --- a/tests/auto/testjsonrpc.cpp +++ b/tests/auto/jsonrpc/testjsonrpc.cpp @@ -17,7 +17,6 @@ ***************************************************************************/ #include "guhtestbase.h" -#include "testjsonrpc.h" #include "guhcore.h" #include "devicemanager.h" #include "mocktcpserver.h" @@ -31,6 +30,38 @@ #include #include +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) diff --git a/tests/auto/testdevices.h b/tests/auto/testdevices.h deleted file mode 100644 index 0ca2e3de..00000000 --- a/tests/auto/testdevices.h +++ /dev/null @@ -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 . * - * * - ***************************************************************************/ - -#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 diff --git a/tests/auto/testjsonrpc.h b/tests/auto/testjsonrpc.h deleted file mode 100644 index 0d82035d..00000000 --- a/tests/auto/testjsonrpc.h +++ /dev/null @@ -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 . * - * * - ***************************************************************************/ - -#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 diff --git a/tests/auto/testversioning.h b/tests/auto/testversioning.h deleted file mode 100644 index a7b257fb..00000000 --- a/tests/auto/testversioning.h +++ /dev/null @@ -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 . * - * * - ***************************************************************************/ - -#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 diff --git a/tests/auto/testversioning.cpp b/tests/auto/versioning/testversioning.cpp similarity index 94% rename from tests/auto/testversioning.cpp rename to tests/auto/versioning/testversioning.cpp index 5a5d190a..3b7130d1 100644 --- a/tests/auto/testversioning.cpp +++ b/tests/auto/versioning/testversioning.cpp @@ -16,7 +16,7 @@ * * ***************************************************************************/ -#include "testversioning.h" +#include "guhtestbase.h" #include "guhcore.h" #include "devicemanager.h" #include "mocktcpserver.h" @@ -29,6 +29,15 @@ #include #include +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) diff --git a/tests/auto/versioning/versioning.pro b/tests/auto/versioning/versioning.pro new file mode 100644 index 00000000..9c060be6 --- /dev/null +++ b/tests/auto/versioning/versioning.pro @@ -0,0 +1,5 @@ +include(../../../guh.pri) +include(../autotests.pri) + +TARGET = versioning +SOURCES += testversioning.cpp