From 77ce9f8b8ad75bca59e710bbb23b714f15484738 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Wed, 22 Aug 2018 13:22:01 +0200 Subject: [PATCH] Split the giant test binaries into smaller unit tests This is an intermediate step to have smaller unit tests. It is a trade off between having many many test executables compared to a few bigger ones. But this comes a lot closer to what QtTest is meant to be used. --- cppcheck.supp | 2 +- src/blackmisc/test/test.cpp | 37 ---- src/blackmisc/test/test.h | 69 -------- tests/blackcore/blackcore.pro | 6 + tests/blackcore/context/context.pro | 3 + .../{ => context/testcontext}/testcontext.cpp | 46 ++++- .../context/testcontext/testcontext.pro | 28 +++ tests/blackcore/main.cpp | 44 ----- tests/blackcore/testblackcore.pro | 22 --- tests/blackcore/testblackcoremain.cpp | 52 ------ tests/blackcore/testblackcoremain.h | 37 ---- tests/blackcore/testconnectivity.h | 63 ------- .../testconnectivity.cpp | 56 +++++- .../testconnectivity/testconnectivity.h} | 27 +-- .../testconnectivity/testconnectivity.pro | 28 +++ tests/blackcore/testcontext.h | 45 ----- tests/blackcore/testnetwork.h | 55 ------ tests/blackcore/testreaders.h | 69 -------- .../{ => testreaders}/testreaders.cpp | 58 +++++-- tests/blackcore/testreaders/testreaders.pro | 27 +++ .../{ => vatsim/testnetwork}/expect.cpp | 0 .../{ => vatsim/testnetwork}/expect.h | 0 .../{ => vatsim/testnetwork}/testnetwork.cpp | 70 ++++++-- .../vatsim/testnetwork/testnetwork.pro | 33 ++++ tests/blackcore/vatsim/vatsim.pro | 3 + tests/blackgui/blackgui.pro | 4 + tests/blackgui/main.cpp | 33 ---- tests/blackgui/testblackgui.pro | 22 --- tests/blackgui/testblackguimain.cpp | 42 ----- tests/blackgui/testblackguimain.h | 38 ----- .../testguiutility.cpp} | 29 ++-- .../testguiutility.h} | 14 -- .../testguiutility/testguiutility.pro | 28 +++ tests/blackmisc/aviation/aviation.pro | 6 + .../testaircraftparts}/testaircraftparts.cpp | 27 ++- .../testaircraftparts/testaircraftparts.pro | 27 +++ .../testaircraftsituation.cpp | 68 ++++++-- .../testaircraftsituation.pro | 27 +++ .../testaviation}/testaviation.cpp | 47 ++++-- .../aviation/testaviation/testaviation.pro | 27 +++ .../testflightplan}/testflightplan.cpp | 20 ++- .../testflightplan/testflightplan.pro | 27 +++ tests/blackmisc/blackmisc.pro | 23 +++ tests/blackmisc/geo/geo.pro | 3 + tests/blackmisc/{ => geo/testgeo}/testgeo.cpp | 29 +++- .../testgeo/testgeo.pro} | 22 ++- tests/blackmisc/input/input.pro | 3 + .../{ => input/testinput}/testinput.cpp | 27 ++- tests/blackmisc/input/testinput/testinput.pro | 27 +++ tests/blackmisc/main.cpp | 38 ----- tests/blackmisc/math/math.pro | 3 + .../{ => math/testmath}/testmath.cpp | 24 ++- tests/blackmisc/math/testmath/testmath.pro | 27 +++ tests/blackmisc/pq/pq.pro | 3 + .../testphysicalquantities.cpp | 111 ++++++------ .../testphysicalquantities.pro | 27 +++ tests/blackmisc/simulation/simulation.pro | 5 + .../testinterpolatorlinear.cpp | 31 +++- .../testinterpolatorlinear.pro | 27 +++ .../testinterpolatormisc.cpp | 24 ++- .../testinterpolatormisc.pro | 27 +++ .../testinterpolatorparts.cpp | 34 +++- .../testinterpolatorparts.pro | 27 +++ tests/blackmisc/testaircraftparts.h | 43 ----- tests/blackmisc/testaircraftsituation.h | 78 --------- tests/blackmisc/testaviation.h | 61 ------- tests/blackmisc/testblackmiscmain.cpp | 159 ------------------ tests/blackmisc/testblackmiscmain.h | 34 ---- tests/blackmisc/testcompress.h | 38 ----- .../{ => testcompress}/testcompress.cpp | 25 ++- tests/blackmisc/testcompress/testcompress.pro | 27 +++ tests/blackmisc/testcontainers.h | 45 ----- .../{ => testcontainers}/testcontainers.cpp | 30 +++- .../testcontainers/testcontainers.pro | 27 +++ tests/blackmisc/testdbus.h | 46 ----- tests/blackmisc/{ => testdbus}/testdbus.cpp | 31 +++- tests/blackmisc/testdbus/testdbus.pro | 27 +++ tests/blackmisc/testflightplan.h | 41 ----- tests/blackmisc/testgeo.h | 41 ----- tests/blackmisc/{ => testicon}/testicon.cpp | 24 ++- tests/blackmisc/testicon/testicon.pro | 27 +++ tests/blackmisc/testidentifier.h | 52 ------ .../{ => testidentifier}/testidentifier.cpp | 33 +++- .../testidentifier/testidentifier.pro | 27 +++ tests/blackmisc/testinput.h | 47 ------ tests/blackmisc/testinterpolatorlinear.h | 54 ------ tests/blackmisc/testinterpolatormisc.h | 44 ----- tests/blackmisc/testinterpolatorparts.h | 57 ------- tests/blackmisc/testlibrarypath.h | 43 ----- .../{ => testlibrarypath}/testlibrarypath.cpp | 26 ++- .../testlibrarypath/testlibrarypath.pro | 27 +++ tests/blackmisc/testmath.h | 40 ----- tests/blackmisc/testmisc.h | 38 ----- tests/blackmisc/testphysicalquantities.h | 77 --------- tests/blackmisc/testprocess.h | 38 ----- .../{ => testprocess}/testprocess.cpp | 24 ++- tests/blackmisc/testprocess/testprocess.pro | 27 +++ tests/blackmisc/testpropertyindex.h | 41 ----- .../testpropertyindex.cpp | 21 ++- .../testpropertyindex/testpropertyindex.pro | 27 +++ tests/blackmisc/testslot.h | 43 ----- tests/blackmisc/{ => testslot}/testslot.cpp | 23 ++- tests/blackmisc/testslot/testslot.pro | 27 +++ .../teststatusmessage.cpp} | 21 ++- .../teststatusmessage/teststatusmessage.pro | 27 +++ tests/blackmisc/teststringutils.h | 44 ----- .../{ => teststringutils}/teststringutils.cpp | 19 ++- .../teststringutils/teststringutils.pro | 27 +++ tests/blackmisc/testvaluecache.h | 88 ---------- .../{ => testvaluecache}/testvaluecache.cpp | 71 +++++++- .../testvaluecache/testvaluecache.pro | 27 +++ tests/blackmisc/testvalueobject.cpp | 72 -------- tests/blackmisc/testvalueobject.h | 47 +++++- tests/blackmisc/testvariantandmap.h | 41 ----- .../testvariantandmap.cpp | 29 +++- .../testvariantandmap/testvariantandmap.pro | 27 +++ tests/blackmisc/testweather.h | 53 ------ .../{ => weather/testweather}/testweather.cpp | 49 ++++-- .../weather/testweather/testweather.pro | 27 +++ tests/blackmisc/weather/weather.pro | 3 + tests/test.h | 70 ++++++++ tests/tests.pro | 16 +- 122 files changed, 1884 insertions(+), 2422 deletions(-) delete mode 100644 src/blackmisc/test/test.cpp delete mode 100644 src/blackmisc/test/test.h create mode 100644 tests/blackcore/blackcore.pro create mode 100644 tests/blackcore/context/context.pro rename tests/blackcore/{ => context/testcontext}/testcontext.cpp (69%) create mode 100644 tests/blackcore/context/testcontext/testcontext.pro delete mode 100644 tests/blackcore/main.cpp delete mode 100644 tests/blackcore/testblackcore.pro delete mode 100644 tests/blackcore/testblackcoremain.cpp delete mode 100644 tests/blackcore/testblackcoremain.h delete mode 100644 tests/blackcore/testconnectivity.h rename tests/blackcore/{ => testconnectivity}/testconnectivity.cpp (73%) rename tests/{blackmisc/testicon.h => blackcore/testconnectivity/testconnectivity.h} (53%) create mode 100644 tests/blackcore/testconnectivity/testconnectivity.pro delete mode 100644 tests/blackcore/testcontext.h delete mode 100644 tests/blackcore/testnetwork.h delete mode 100644 tests/blackcore/testreaders.h rename tests/blackcore/{ => testreaders}/testreaders.cpp (83%) create mode 100644 tests/blackcore/testreaders/testreaders.pro rename tests/blackcore/{ => vatsim/testnetwork}/expect.cpp (100%) rename tests/blackcore/{ => vatsim/testnetwork}/expect.h (100%) rename tests/blackcore/{ => vatsim/testnetwork}/testnetwork.cpp (71%) create mode 100644 tests/blackcore/vatsim/testnetwork/testnetwork.pro create mode 100644 tests/blackcore/vatsim/vatsim.pro create mode 100644 tests/blackgui/blackgui.pro delete mode 100644 tests/blackgui/main.cpp delete mode 100644 tests/blackgui/testblackgui.pro delete mode 100644 tests/blackgui/testblackguimain.cpp delete mode 100644 tests/blackgui/testblackguimain.h rename tests/blackgui/{testutils.cpp => testguiutility/testguiutility.cpp} (67%) rename tests/blackgui/{testutils.h => testguiutility/testguiutility.h} (68%) create mode 100644 tests/blackgui/testguiutility/testguiutility.pro create mode 100644 tests/blackmisc/aviation/aviation.pro rename tests/blackmisc/{ => aviation/testaircraftparts}/testaircraftparts.cpp (87%) create mode 100644 tests/blackmisc/aviation/testaircraftparts/testaircraftparts.pro rename tests/blackmisc/{ => aviation/testaircraftsituation}/testaircraftsituation.cpp (89%) create mode 100644 tests/blackmisc/aviation/testaircraftsituation/testaircraftsituation.pro rename tests/blackmisc/{ => aviation/testaviation}/testaviation.cpp (91%) create mode 100644 tests/blackmisc/aviation/testaviation/testaviation.pro rename tests/blackmisc/{ => aviation/testflightplan}/testflightplan.cpp (92%) create mode 100644 tests/blackmisc/aviation/testflightplan/testflightplan.pro create mode 100644 tests/blackmisc/blackmisc.pro create mode 100644 tests/blackmisc/geo/geo.pro rename tests/blackmisc/{ => geo/testgeo}/testgeo.cpp (84%) rename tests/blackmisc/{testblackmisc.pro => geo/testgeo/testgeo.pro} (50%) create mode 100644 tests/blackmisc/input/input.pro rename tests/blackmisc/{ => input/testinput}/testinput.cpp (92%) create mode 100644 tests/blackmisc/input/testinput/testinput.pro delete mode 100644 tests/blackmisc/main.cpp create mode 100644 tests/blackmisc/math/math.pro rename tests/blackmisc/{ => math/testmath}/testmath.cpp (86%) create mode 100644 tests/blackmisc/math/testmath/testmath.pro create mode 100644 tests/blackmisc/pq/pq.pro rename tests/blackmisc/{ => pq/testphysicalquantities}/testphysicalquantities.cpp (88%) create mode 100644 tests/blackmisc/pq/testphysicalquantities/testphysicalquantities.pro create mode 100644 tests/blackmisc/simulation/simulation.pro rename tests/blackmisc/{ => simulation/testinterpolatorlinear}/testinterpolatorlinear.cpp (91%) create mode 100644 tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.pro rename tests/blackmisc/{ => simulation/testinterpolatormisc}/testinterpolatormisc.cpp (79%) create mode 100644 tests/blackmisc/simulation/testinterpolatormisc/testinterpolatormisc.pro rename tests/blackmisc/{ => simulation/testinterpolatorparts}/testinterpolatorparts.cpp (88%) create mode 100644 tests/blackmisc/simulation/testinterpolatorparts/testinterpolatorparts.pro delete mode 100644 tests/blackmisc/testaircraftparts.h delete mode 100644 tests/blackmisc/testaircraftsituation.h delete mode 100644 tests/blackmisc/testaviation.h delete mode 100644 tests/blackmisc/testblackmiscmain.cpp delete mode 100644 tests/blackmisc/testblackmiscmain.h delete mode 100644 tests/blackmisc/testcompress.h rename tests/blackmisc/{ => testcompress}/testcompress.cpp (80%) create mode 100644 tests/blackmisc/testcompress/testcompress.pro delete mode 100644 tests/blackmisc/testcontainers.h rename tests/blackmisc/{ => testcontainers}/testcontainers.cpp (95%) create mode 100644 tests/blackmisc/testcontainers/testcontainers.pro delete mode 100644 tests/blackmisc/testdbus.h rename tests/blackmisc/{ => testdbus}/testdbus.cpp (79%) create mode 100644 tests/blackmisc/testdbus/testdbus.pro delete mode 100644 tests/blackmisc/testflightplan.h delete mode 100644 tests/blackmisc/testgeo.h rename tests/blackmisc/{ => testicon}/testicon.cpp (81%) create mode 100644 tests/blackmisc/testicon/testicon.pro delete mode 100644 tests/blackmisc/testidentifier.h rename tests/blackmisc/{ => testidentifier}/testidentifier.cpp (69%) create mode 100644 tests/blackmisc/testidentifier/testidentifier.pro delete mode 100644 tests/blackmisc/testinput.h delete mode 100644 tests/blackmisc/testinterpolatorlinear.h delete mode 100644 tests/blackmisc/testinterpolatormisc.h delete mode 100644 tests/blackmisc/testinterpolatorparts.h delete mode 100644 tests/blackmisc/testlibrarypath.h rename tests/blackmisc/{ => testlibrarypath}/testlibrarypath.cpp (76%) create mode 100644 tests/blackmisc/testlibrarypath/testlibrarypath.pro delete mode 100644 tests/blackmisc/testmath.h delete mode 100644 tests/blackmisc/testmisc.h delete mode 100644 tests/blackmisc/testphysicalquantities.h delete mode 100644 tests/blackmisc/testprocess.h rename tests/blackmisc/{ => testprocess}/testprocess.cpp (79%) create mode 100644 tests/blackmisc/testprocess/testprocess.pro delete mode 100644 tests/blackmisc/testpropertyindex.h rename tests/blackmisc/{ => testpropertyindex}/testpropertyindex.cpp (90%) create mode 100644 tests/blackmisc/testpropertyindex/testpropertyindex.pro delete mode 100644 tests/blackmisc/testslot.h rename tests/blackmisc/{ => testslot}/testslot.cpp (80%) create mode 100644 tests/blackmisc/testslot/testslot.pro rename tests/blackmisc/{testmisc.cpp => teststatusmessage/teststatusmessage.cpp} (78%) create mode 100644 tests/blackmisc/teststatusmessage/teststatusmessage.pro delete mode 100644 tests/blackmisc/teststringutils.h rename tests/blackmisc/{ => teststringutils}/teststringutils.cpp (92%) create mode 100644 tests/blackmisc/teststringutils/teststringutils.pro delete mode 100644 tests/blackmisc/testvaluecache.h rename tests/blackmisc/{ => testvaluecache}/testvaluecache.cpp (85%) create mode 100644 tests/blackmisc/testvaluecache/testvaluecache.pro delete mode 100644 tests/blackmisc/testvalueobject.cpp delete mode 100644 tests/blackmisc/testvariantandmap.h rename tests/blackmisc/{ => testvariantandmap}/testvariantandmap.cpp (90%) create mode 100644 tests/blackmisc/testvariantandmap/testvariantandmap.pro delete mode 100644 tests/blackmisc/testweather.h rename tests/blackmisc/{ => weather/testweather}/testweather.cpp (92%) create mode 100644 tests/blackmisc/weather/testweather/testweather.pro create mode 100644 tests/blackmisc/weather/weather.pro create mode 100644 tests/test.h diff --git a/cppcheck.supp b/cppcheck.supp index 3f36cad5a..373eda7eb 100644 --- a/cppcheck.supp +++ b/cppcheck.supp @@ -19,7 +19,7 @@ passedByValue:src/blackmisc/lockfree.h // Passing std::function by value is acceptable passedByValue:src/xswiftbus/libxplanemp/src/ResourceManager.h -passedByValue:tests/blackcore/expect.h +passedByValue:tests/blackcore/vatsim/testnetwork/expect.h passedByValue:src/xswiftbus/command.h // Unique pointers should be passed by value diff --git a/src/blackmisc/test/test.cpp b/src/blackmisc/test/test.cpp deleted file mode 100644 index a47a9972d..000000000 --- a/src/blackmisc/test/test.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2016 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "blackmisc/test/test.h" - -namespace BlackMisc -{ - namespace Test - { - CTestBase::CTestBase(int argc, const char *const *argv) - { - m_arguments.reserve(argc); - for (int i = 0; i < argc; ++i) - { - m_arguments.append(argv[i]); - } - - // Output to stdout - m_arguments.append({ "-o", "-,txt" }); - } - - CTestBase::~CTestBase() - {} - - int CTestBase::exec(QObject *test, const QString &name) - { - auto additionalArguments = QStringList { "-o", name + "_testresults.xml,xml" }; - return this->qExec(test, m_arguments + additionalArguments); - } - } // ns -} // ns diff --git a/src/blackmisc/test/test.h b/src/blackmisc/test/test.h deleted file mode 100644 index af2d1fe43..000000000 --- a/src/blackmisc/test/test.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2016 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_TEST_TEST_H -#define BLACKMISC_TEST_TEST_H - -#include "blackmisc/blackmiscexport.h" -#include - -#ifdef QT_TESTLIB_LIB -#include -#endif - -class QObject; - -namespace BlackMisc -{ - namespace Test - { - /*! - * Helper base class for executing unit tests. - * Contains the parts that do not depend upon QtTest library, and pure - * virtual functions for derived class to implement the parts that do. - */ - class BLACKMISC_EXPORT CTestBase - { - public: - //! Constructor expects command line arguments. - CTestBase(int argc, const char *const *argv); - - //! Destructor. - virtual ~CTestBase(); - - //! Execute the given test case. - int exec(QObject *test, const QString &name); - - private: - virtual int qExec(QObject *test, const QStringList &args) = 0; - - QStringList m_arguments; - }; - -#ifdef QT_TESTLIB_LIB - /*! - * Helper derived class for executing unit tests. - * Defined inline and only when building with QT += testlib so blackmisc - * doesn't need to link against QtTest library. - */ - class CTest : public CTestBase - { - public: - using CTestBase::CTestBase; - - private: - virtual int qExec(QObject *test, const QStringList &args) override { return QTest::qExec(test, args); } - }; -#endif - } // ns -} // ns - -#endif // guard diff --git a/tests/blackcore/blackcore.pro b/tests/blackcore/blackcore.pro new file mode 100644 index 000000000..c40f0b660 --- /dev/null +++ b/tests/blackcore/blackcore.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + context \ + testconnectivity \ + vatsim \ diff --git a/tests/blackcore/context/context.pro b/tests/blackcore/context/context.pro new file mode 100644 index 000000000..f21fd4329 --- /dev/null +++ b/tests/blackcore/context/context.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testcontext \ diff --git a/tests/blackcore/testcontext.cpp b/tests/blackcore/context/testcontext/testcontext.cpp similarity index 69% rename from tests/blackcore/testcontext.cpp rename to tests/blackcore/context/testcontext/testcontext.cpp index 4a88280d4..7d16c9ccb 100644 --- a/tests/blackcore/testcontext.cpp +++ b/tests/blackcore/context/testcontext/testcontext.cpp @@ -8,26 +8,38 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackcore -/*! - * \file - * \ingroup testblackcore - */ - -#include "testcontext.h" #include "blackcore/context/contextallproxies.h" +#include "blackcore/application.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/dbusutils.h" +#include "test.h" #include using namespace BlackMisc; using namespace BlackMisc::Aviation; using namespace BlackMisc::Simulation; +using namespace BlackCore; using namespace BlackCore::Context; namespace BlackCoreTest { - void CTestContext::contextInitTest() + //! Context implementation classes tests + class CTestContext : public QObject + { + Q_OBJECT + + private slots: + //! Init tests for context + void initTestCase(); + + //! Test the DBus signatures + void dBusSignatures(); + }; + + void CTestContext::initTestCase() { // will cause asserts when signal connects fail QDBusConnection connection = QDBusConnection::sessionBus(); @@ -65,4 +77,24 @@ namespace BlackCoreTest } } // ns +//! main +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + BLACKTEST_INIT(BlackCoreTest::CTestContext) + CApplication a(CApplicationInfo::UnitTest); + a.addVatlibOptions(); + const bool setup = a.parseAndSynchronizeSetup(); + if (!setup) { qWarning() << "No setup loaded"; } + int r = EXIT_FAILURE; + if (a.start()) + { + r = QTest::qExec(&to, args); + } + a.gracefulShutdown(); + return r; +} + +#include "testcontext.moc" + //! \endcond diff --git a/tests/blackcore/context/testcontext/testcontext.pro b/tests/blackcore/context/testcontext/testcontext.pro new file mode 100644 index 000000000..b091ebd97 --- /dev/null +++ b/tests/blackcore/context/testcontext/testcontext.pro @@ -0,0 +1,28 @@ +load(common_pre) + +QT += core dbus network testlib + +TARGET = testcontext +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += blackcore +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testcontext.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackcore/main.cpp b/tests/blackcore/main.cpp deleted file mode 100644 index 85797148b..000000000 --- a/tests/blackcore/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2014 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackcore - */ - -#include "testblackcoremain.h" -#include "blackcore/application.h" -#include -#include - -using namespace BlackMisc; -using namespace BlackCore; -using namespace BlackCoreTest; - -//! Starter for test cases -int main(int argc, char *argv[]) -{ - QCoreApplication qa(argc, argv); - Q_UNUSED(qa); - CApplication a(CApplicationInfo::UnitTest); - a.addVatlibOptions(); - const bool setup = a.parseAndSynchronizeSetup(); - if (!setup) { qWarning() << "No setup loaded"; } - int r = EXIT_FAILURE; - if (a.start()) - { - r = CBlackCoreTestMain::unitMain(argc, argv); - } - a.gracefulShutdown(); - return r; -} - -//! \endcond diff --git a/tests/blackcore/testblackcore.pro b/tests/blackcore/testblackcore.pro deleted file mode 100644 index 5f2314a90..000000000 --- a/tests/blackcore/testblackcore.pro +++ /dev/null @@ -1,22 +0,0 @@ -load(common_pre) - -QT += core testlib dbus network - -TARGET = testblackcore -TEMPLATE = app - -CONFIG += console -CONFIG -= app_bundle -CONFIG += blackmisc blackcore -CONFIG += testcase -CONFIG += no_testcase_installs - -DEPENDPATH += . $$SourceRoot/src -INCLUDEPATH += . $$SourceRoot/src - -HEADERS += *.h -SOURCES += *.cpp - -DESTDIR = $$DestRoot/bin - -load(common_post) diff --git a/tests/blackcore/testblackcoremain.cpp b/tests/blackcore/testblackcoremain.cpp deleted file mode 100644 index f2c12126b..000000000 --- a/tests/blackcore/testblackcoremain.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2014 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackcore - */ - -#include "testblackcoremain.h" -#include "testnetwork.h" -#include "testreaders.h" -#include "testcontext.h" -#include "testconnectivity.h" -#include "blackmisc/test/test.h" -#include -#include - -namespace BlackCoreTest -{ - int CBlackCoreTestMain::unitMain(int argc, char *argv[]) - { - BlackMisc::Test::CTest test(argc, argv); - int status = 0; - { - CTestConnectivity connectivityTest; - status |= test.exec(&connectivityTest, "blackcore_network"); - } - { - CTestContext contextTests; - status |= test.exec(&contextTests, "blackcore_context"); - } - { - CTestReaders readersTests; - status |= test.exec(&readersTests, "blackcore_readers"); - } - { - CTestNetwork networkTests; - status |= test.exec(&networkTests, "blackcore_network"); - } - return status; - } -} // namespace - -//! \endcond diff --git a/tests/blackcore/testblackcoremain.h b/tests/blackcore/testblackcoremain.h deleted file mode 100644 index 7659be8f1..000000000 --- a/tests/blackcore/testblackcoremain.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKCORETEST_TESTMAIN_H -#define BLACKCORETEST_TESTMAIN_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackcore - */ - -namespace BlackCoreTest -{ - /*! - * Class firing all unit tests in this namespace. - * Avoids clashes with other main(..) functions and allows to fire the test cases - * simply from any other main. - */ - class CBlackCoreTestMain - { - public: - //! Unit tests - static int unitMain(int argc, char *argv[]); - }; -} // ns - -//! \endcond - -#endif // guard diff --git a/tests/blackcore/testconnectivity.h b/tests/blackcore/testconnectivity.h deleted file mode 100644 index 5ed2c076d..000000000 --- a/tests/blackcore/testconnectivity.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2017 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKCORETEST_TESTCONNECTIVITY_H -#define BLACKCORETEST_TESTCONNECTIVITY_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackcore - -#include "blackcore/db/networkwatchdog.h" -#include "blackcore/setupreader.h" -#include "blackmisc/network/networkutils.h" -#include "blackmisc/statusmessagelist.h" -#include - -namespace BlackCoreTest -{ - /*! - * Test connectivity such as \c canConnect \c ping and - * BlackCore::Db::CNetworkWatchdog - */ - class CTestConnectivity : public QObject - { - Q_OBJECT - - public: - //! Constructor. - explicit CTestConnectivity(QObject *parent = nullptr); - - //! Destructor - virtual ~CTestConnectivity(); - - private slots: - //! Init - void initTestCase(); - - //! Setup reader - void checkSetupReader(); - - //! Connecting test server - void connectServer(); - - //! ping test server - void pingServer(); - - //! Test the watchdog BlackCore::Db::CNetworkWatchdog - void testNetworkWatchdog(); - - private: - int m_networkCheckCount = -1; - }; -} //namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackcore/testconnectivity.cpp b/tests/blackcore/testconnectivity/testconnectivity.cpp similarity index 73% rename from tests/blackcore/testconnectivity.cpp rename to tests/blackcore/testconnectivity/testconnectivity.cpp index 8adf2ac92..e5dd9b0ea 100644 --- a/tests/blackcore/testconnectivity.cpp +++ b/tests/blackcore/testconnectivity/testconnectivity.cpp @@ -11,9 +11,14 @@ //! \file //! \ingroup testblackcore -#include "testconnectivity.h" #include "blackcore/application.h" #include "blackcore/db/networkwatchdog.h" +#include "blackcore/setupreader.h" +#include "blackmisc/applicationinfo.h" +#include "blackmisc/network/networkutils.h" +#include "blackmisc/statusmessagelist.h" +#include "test.h" +#include #include #include #include @@ -22,16 +27,35 @@ using namespace BlackCore; using namespace BlackCore::Db; +using namespace BlackMisc; using namespace BlackMisc::Network; namespace BlackCoreTest { - CTestConnectivity::CTestConnectivity(QObject *parent) : - QObject(parent) - { } + //! Test connectivity such as \c canConnect \c ping and BlackCore::Db::CNetworkWatchdog + class CTestConnectivity : public QObject + { + Q_OBJECT - CTestConnectivity::~CTestConnectivity() - { } + private slots: + //! Init + void initTestCase(); + + //! Setup reader + void checkSetupReader(); + + //! Connecting test server + void connectServer(); + + //! ping test server + void pingServer(); + + //! Test the watchdog BlackCore::Db::CNetworkWatchdog + void testNetworkWatchdog(); + + private: + int m_networkCheckCount = -1; + }; void CTestConnectivity::initTestCase() { @@ -99,4 +123,24 @@ namespace BlackCoreTest } } // ns +//! main +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + BLACKTEST_INIT(BlackCoreTest::CTestConnectivity) + CApplication a(CApplicationInfo::UnitTest); + a.addVatlibOptions(); + const bool setup = a.parseAndSynchronizeSetup(); + if (!setup) { qWarning() << "No setup loaded"; } + int r = EXIT_FAILURE; + if (a.start()) + { + r = QTest::qExec(&to, args); + } + a.gracefulShutdown(); + return r; +} + +#include "testconnectivity.moc" + //! \endcond diff --git a/tests/blackmisc/testicon.h b/tests/blackcore/testconnectivity/testconnectivity.h similarity index 53% rename from tests/blackmisc/testicon.h rename to tests/blackcore/testconnectivity/testconnectivity.h index f29634d3a..875ec41f3 100644 --- a/tests/blackmisc/testicon.h +++ b/tests/blackcore/testconnectivity/testconnectivity.h @@ -7,34 +7,19 @@ * contained in the LICENSE file. */ -#ifndef BLACKMISCTEST_TESTICON_H -#define BLACKMISCTEST_TESTICON_H +#ifndef BLACKCORETEST_TESTCONNECTIVITY_H +#define BLACKCORETEST_TESTCONNECTIVITY_H //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackcore -/*! - * \file - * \ingroup testblackmisc - */ -#include -namespace BlackMiscTest +namespace BlackCoreTest { - //! Testing icons - class CTestIcon : public QObject - { - Q_OBJECT - public: - //! Constructor - explicit CTestIcon(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Icon order/index - void iconIndex(); - }; -} // namespace +} //namespace //! \endcond diff --git a/tests/blackcore/testconnectivity/testconnectivity.pro b/tests/blackcore/testconnectivity/testconnectivity.pro new file mode 100644 index 000000000..a6baa6a5a --- /dev/null +++ b/tests/blackcore/testconnectivity/testconnectivity.pro @@ -0,0 +1,28 @@ +load(common_pre) + +QT += core dbus network testlib + +TARGET = testconnectivity +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += blackcore +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testconnectivity.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackcore/testcontext.h b/tests/blackcore/testcontext.h deleted file mode 100644 index 411106b2f..000000000 --- a/tests/blackcore/testcontext.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2017 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKCORETEST_TESTCONTEXT_H -#define BLACKCORETEST_TESTCONTEXT_H - -#include - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackcore - -namespace BlackCoreTest -{ - /*! - * Context implementation classes tests - */ - class CTestContext : public QObject - { - Q_OBJECT - - public: - //! Constructor. - explicit CTestContext(QObject *parent = nullptr) : - QObject(parent) - {} - - private slots: - //! Init tests for context - void contextInitTest(); - - //! Test the DBus signatures - void dBusSignatures(); - }; -} //namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackcore/testnetwork.h b/tests/blackcore/testnetwork.h deleted file mode 100644 index f4fbb6557..000000000 --- a/tests/blackcore/testnetwork.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2014 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKCORETEST_TESTNETWORK_H -#define BLACKCORETEST_TESTNETWORK_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackcore - -#include "blackcore/vatsim/networkvatlib.h" -#include "blackmisc/simulation/ownaircraftproviderdummy.h" - -#include -#include - -namespace BlackCore { class INetwork; } -namespace BlackMisc { namespace Network { class CServer; } } -namespace BlackCoreTest -{ - /*! - * INetwork implementation classes tests - */ - class CTestNetwork : public QObject - { - Q_OBJECT - - public: - //! Constructor. - explicit CTestNetwork(QObject *parent = nullptr); - - private slots: - //! Test the vatlib - void networkVatlibTest() { networkTest(&m_networkVatlib); } - - private: - //! Common part used by all tests. - void networkTest(BlackCore::INetwork *); - - BlackCore::Vatsim::CNetworkVatlib m_networkVatlib ; //!< vatlib instance - - //! Test if server is available - static bool pingServer(const BlackMisc::Network::CServer &server); - }; -} //namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackcore/testreaders.h b/tests/blackcore/testreaders.h deleted file mode 100644 index ff17ec590..000000000 --- a/tests/blackcore/testreaders.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2015 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKCORETEST_TESTREADERS_H -#define BLACKCORETEST_TESTREADERS_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackcore - -#include "blackmisc/network/url.h" -#include -#include - -namespace BlackCore -{ - namespace Db - { - class CAirportDataReader; - class CIcaoDataReader; - class CModelDataReader; - } -} - -namespace BlackCoreTest -{ - /*! - * Test data readers (for bookings, JSON, etc.) - */ - class CTestReaders : public QObject - { - Q_OBJECT - - public: - //! Constructor. - explicit CTestReaders(QObject *parent = nullptr); - - //! Destructor - virtual ~CTestReaders(); - - private slots: - //! Read ICAO data - void readIcaoData(); - - //! Read model data - void readModelData(); - - //! Read airport data - void readAirportData(); - - private: - BlackCore::Db::CAirportDataReader *m_airportReader = nullptr; - BlackCore::Db::CIcaoDataReader *m_icaoReader = nullptr; - BlackCore::Db::CModelDataReader *m_modelReader = nullptr; - - //! Test if server is available - static bool connectServer(const BlackMisc::Network::CUrl &url); - }; -} //namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackcore/testreaders.cpp b/tests/blackcore/testreaders/testreaders.cpp similarity index 83% rename from tests/blackcore/testreaders.cpp rename to tests/blackcore/testreaders/testreaders.cpp index d11cf33a0..6e49e8f1a 100644 --- a/tests/blackcore/testreaders.cpp +++ b/tests/blackcore/testreaders/testreaders.cpp @@ -11,7 +11,6 @@ //! \file //! \ingroup testblackcore -#include "testreaders.h" #include "blackcore/application.h" #include "blackcore/data/globalsetup.h" #include "blackcore/db/airportdatareader.h" @@ -26,6 +25,7 @@ #include "blackmisc/network/networkutils.h" #include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/simulation/aircraftmodellist.h" +#include "test.h" #include #include @@ -43,24 +43,44 @@ using namespace BlackCore::Db; namespace BlackCoreTest { - CTestReaders::CTestReaders(QObject *parent) : - QObject(parent), - m_airportReader(new CAirportDataReader(this, CDatabaseReaderConfigList::allDirectDbAccess())), - m_icaoReader(new CIcaoDataReader(this, CDatabaseReaderConfigList::allDirectDbAccess())), - m_modelReader(new CModelDataReader(this, CDatabaseReaderConfigList::allDirectDbAccess())) + //! Test data readers (for bookings, JSON, etc.) + class CTestReaders : public QObject { + Q_OBJECT + + private slots: + void initTestCase(); + + //! Read ICAO data + void readIcaoData(); + + //! Read model data + void readModelData(); + + //! Read airport data + void readAirportData(); + + void cleanupTestCase(); + + private: + BlackCore::Db::CAirportDataReader *m_airportReader = nullptr; + BlackCore::Db::CIcaoDataReader *m_icaoReader = nullptr; + BlackCore::Db::CModelDataReader *m_modelReader = nullptr; + + //! Test if server is available + static bool connectServer(const BlackMisc::Network::CUrl &url); + }; + + void CTestReaders::initTestCase() + { + m_airportReader = new CAirportDataReader(this, CDatabaseReaderConfigList::allDirectDbAccess()); + m_icaoReader = new CIcaoDataReader(this, CDatabaseReaderConfigList::allDirectDbAccess()); + m_modelReader = new CModelDataReader(this, CDatabaseReaderConfigList::allDirectDbAccess()); m_airportReader->markAsUsedInUnitTest(); m_icaoReader->markAsUsedInUnitTest(); m_modelReader->markAsUsedInUnitTest(); } - CTestReaders::~CTestReaders() - { - this->m_airportReader->setEnabled(false); - this->m_icaoReader->setEnabled(false); - this->m_modelReader->setEnabled(false); - } - void CTestReaders::readIcaoData() { const CUrl url(sApp->getGlobalSetup().getDbIcaoReaderUrl()); @@ -178,6 +198,18 @@ namespace BlackCoreTest return false; } } + + void CTestReaders::cleanupTestCase() + { + m_airportReader->quitAndWait(); + m_icaoReader->quitAndWait(); + m_modelReader->quitAndWait(); + } } // ns +//! main +BLACKTEST_APPLESS_MAIN(BlackCoreTest::CTestReaders); + +#include "testreaders.moc" + //! \endcond diff --git a/tests/blackcore/testreaders/testreaders.pro b/tests/blackcore/testreaders/testreaders.pro new file mode 100644 index 000000000..d7c231c0c --- /dev/null +++ b/tests/blackcore/testreaders/testreaders.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testreaders +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testreaders.cpp + +DESTDIR = $$DestRoot/tests + +load(common_post) diff --git a/tests/blackcore/expect.cpp b/tests/blackcore/vatsim/testnetwork/expect.cpp similarity index 100% rename from tests/blackcore/expect.cpp rename to tests/blackcore/vatsim/testnetwork/expect.cpp diff --git a/tests/blackcore/expect.h b/tests/blackcore/vatsim/testnetwork/expect.h similarity index 100% rename from tests/blackcore/expect.h rename to tests/blackcore/vatsim/testnetwork/expect.h diff --git a/tests/blackcore/testnetwork.cpp b/tests/blackcore/vatsim/testnetwork/testnetwork.cpp similarity index 71% rename from tests/blackcore/testnetwork.cpp rename to tests/blackcore/vatsim/testnetwork/testnetwork.cpp index cd13ea961..3fb67b7f1 100644 --- a/tests/blackcore/testnetwork.cpp +++ b/tests/blackcore/vatsim/testnetwork/testnetwork.cpp @@ -8,25 +8,26 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackcore -/*! - * \file - * \ingroup testblackcore - */ - -#include "testnetwork.h" #include "expect.h" +#include "blackcore/application.h" #include "blackcore/network.h" +#include "blackcore/vatsim/networkvatlib.h" #include "blackmisc/aviation/aircrafticaocode.h" #include "blackmisc/aviation/airlineicaocode.h" #include "blackmisc/aviation/callsign.h" +#include "blackmisc/network/clientprovider.h" #include "blackmisc/network/networkutils.h" #include "blackmisc/network/server.h" #include "blackmisc/network/url.h" #include "blackmisc/network/user.h" #include "blackmisc/pq/time.h" #include "blackmisc/simulation/simulatedaircraft.h" +#include "blackmisc/simulation/ownaircraftproviderdummy.h" #include "blackmisc/stringutils.h" +#include "test.h" #include #include @@ -34,6 +35,7 @@ #include using namespace BlackCore; +using namespace BlackCore::Vatsim; using namespace BlackMisc; using namespace BlackMisc::Aviation; using namespace BlackMisc::Simulation; @@ -43,10 +45,33 @@ using namespace BlackMisc::PhysicalQuantities; namespace BlackCoreTest { - CTestNetwork::CTestNetwork(QObject *parent) : - QObject(parent), - m_networkVatlib(CClientProviderDummy::instance(), COwnAircraftProviderDummy::instance(), parent) - {} + //! INetwork implementation classes tests + class CTestNetwork : public QObject + { + Q_OBJECT + + private slots: + void initTestCase(); + + //! Test the vatlib + void networkVatlibTest() { networkTest(m_networkVatlib); } + + void cleanupTestCase(); + + private: + //! Common part used by all tests. + void networkTest(BlackCore::INetwork *net); + + CNetworkVatlib *m_networkVatlib = nullptr; //!< vatlib instance + + //! Test if server is available + static bool pingServer(const BlackMisc::Network::CServer &server); + }; + + void CTestNetwork::initTestCase() + { + m_networkVatlib = new CNetworkVatlib(CClientProviderDummy::instance(), COwnAircraftProviderDummy::instance()); + } void CTestNetwork::networkTest(BlackCore::INetwork *net) { @@ -115,6 +140,31 @@ namespace BlackCoreTest } return true; } + + void CTestNetwork::cleanupTestCase() + { + delete m_networkVatlib; + } } +//! main +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + BLACKTEST_INIT(BlackCoreTest::CTestNetwork) + CApplication a(CApplicationInfo::UnitTest); + a.addVatlibOptions(); + const bool setup = a.parseAndSynchronizeSetup(); + if (!setup) { qWarning() << "No setup loaded"; } + int r = EXIT_FAILURE; + if (a.start()) + { + r = QTest::qExec(&to, args); + } + a.gracefulShutdown(); + return r; +} + +#include "testnetwork.moc" + //! \endcond diff --git a/tests/blackcore/vatsim/testnetwork/testnetwork.pro b/tests/blackcore/vatsim/testnetwork/testnetwork.pro new file mode 100644 index 000000000..efa5dd824 --- /dev/null +++ b/tests/blackcore/vatsim/testnetwork/testnetwork.pro @@ -0,0 +1,33 @@ +load(common_pre) + +QT += core dbus network testlib + +TARGET = testnetwork +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += blackcore +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +HEADERS += \ + expect.h + +SOURCES += \ + testnetwork.cpp \ + expect.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackcore/vatsim/vatsim.pro b/tests/blackcore/vatsim/vatsim.pro new file mode 100644 index 000000000..f33df779e --- /dev/null +++ b/tests/blackcore/vatsim/vatsim.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testnetwork \ diff --git a/tests/blackgui/blackgui.pro b/tests/blackgui/blackgui.pro new file mode 100644 index 000000000..be09ed597 --- /dev/null +++ b/tests/blackgui/blackgui.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + testguiutility \ diff --git a/tests/blackgui/main.cpp b/tests/blackgui/main.cpp deleted file mode 100644 index 3c3cd6193..000000000 --- a/tests/blackgui/main.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2015 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackgui - */ - -#include "testblackguimain.h" - -#include -#include - -using namespace BlackGuiTest; - -//! Starter for test cases -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - Q_UNUSED(a); - - return CBlackGuiTestMain::unitMain(argc, argv); -} - -//! \endcond diff --git a/tests/blackgui/testblackgui.pro b/tests/blackgui/testblackgui.pro deleted file mode 100644 index 15abd85fb..000000000 --- a/tests/blackgui/testblackgui.pro +++ /dev/null @@ -1,22 +0,0 @@ -load(common_pre) - -QT += core testlib dbus network gui svg -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = testblackgui -TEMPLATE = app - -CONFIG -= app_bundle -CONFIG += blackmisc blackcore blackgui -CONFIG += testcase -CONFIG += no_testcase_installs - -DEPENDPATH += . $$SourceRoot/src -INCLUDEPATH += . $$SourceRoot/src - -HEADERS += *.h -SOURCES += *.cpp - -DESTDIR = $$DestRoot/bin - -load(common_post) diff --git a/tests/blackgui/testblackguimain.cpp b/tests/blackgui/testblackguimain.cpp deleted file mode 100644 index 5b4106e59..000000000 --- a/tests/blackgui/testblackguimain.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2015 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackgui - */ - -#include "testblackguimain.h" -#include "testutils.h" -#include "blackmisc/test/test.h" - -#include -#include - -namespace BlackGuiTest -{ - /* - * Starting main, equivalent to QTEST_APPLESS_MAIN for multiple test classes. - */ - int CBlackGuiTestMain::unitMain(int argc, char *argv[]) - { - BlackMisc::Test::CTest test(argc, argv); - - int status = 0; - { - CTestGuiUtilities utilityTests; - status |= test.exec(&utilityTests, "blackgui_guiutilities"); - } - return status; - } -} // namespace - -//! \endcond diff --git a/tests/blackgui/testblackguimain.h b/tests/blackgui/testblackguimain.h deleted file mode 100644 index 9bededcfc..000000000 --- a/tests/blackgui/testblackguimain.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackgui - */ - -#ifndef BLACKGUITEST_TESTMAIN_H -#define BLACKGUITEST_TESTMAIN_H - -namespace BlackGuiTest -{ - - /*! - * Class firing all unit tests in this namespace. - * Avoids clashes with other main(..) functions and allows to fire the test cases - * simply from any other main. - */ - class CBlackGuiTestMain - { - public: - //! Unit tests - static int unitMain(int argc, char *argv[]); - }; -} - -//! \endcond - -#endif // guard diff --git a/tests/blackgui/testutils.cpp b/tests/blackgui/testguiutility/testguiutility.cpp similarity index 67% rename from tests/blackgui/testutils.cpp rename to tests/blackgui/testguiutility/testguiutility.cpp index 28c00e91b..500892310 100644 --- a/tests/blackgui/testutils.cpp +++ b/tests/blackgui/testguiutility/testguiutility.cpp @@ -8,27 +8,27 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackgui -/*! - * \file - * \ingroup testblackgui - */ - -#include "testutils.h" #include "blackgui/guiutility.h" - -#include +#include "test.h" using namespace BlackGui; namespace BlackGuiTest { + //! Test GUI utilities + class CTestGuiUtility : public QObject + { + Q_OBJECT - CTestGuiUtilities::CTestGuiUtilities(QObject *parent) : - QObject(parent) - { } + private slots: + //! Test the lenientTitleComparison + void testLenientTitleComparison(); + }; - void CTestGuiUtilities::utilityFunctions() + void CTestGuiUtility::testLenientTitleComparison() { QVERIFY2(CGuiUtility::lenientTitleComparison("foo", "foo"), "wrong title match"); QVERIFY2(CGuiUtility::lenientTitleComparison("foo&", "&Foo"), "wrong title match"); @@ -36,4 +36,9 @@ namespace BlackGuiTest } } // ns +//! main +BLACKTEST_APPLESS_MAIN(BlackGuiTest::CTestGuiUtility); + +#include "testguiutility.moc" + //! \endcond diff --git a/tests/blackgui/testutils.h b/tests/blackgui/testguiutility/testguiutility.h similarity index 68% rename from tests/blackgui/testutils.h rename to tests/blackgui/testguiutility/testguiutility.h index 3cff28691..7624ed86d 100644 --- a/tests/blackgui/testutils.h +++ b/tests/blackgui/testguiutility/testguiutility.h @@ -21,21 +21,7 @@ namespace BlackGuiTest { - /** - * Test GUI utilities - */ - class CTestGuiUtilities : public QObject - { - Q_OBJECT - public: - //! Constructor. - explicit CTestGuiUtilities(QObject *parent = nullptr); - - private slots: - //! Test the utility functions - void utilityFunctions(); - }; } //namespace diff --git a/tests/blackgui/testguiutility/testguiutility.pro b/tests/blackgui/testguiutility/testguiutility.pro new file mode 100644 index 000000000..699325434 --- /dev/null +++ b/tests/blackgui/testguiutility/testguiutility.pro @@ -0,0 +1,28 @@ +load(common_pre) + +QT += core dbus gui testlib widgets + +TARGET = testguiutility +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += blackgui +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testguiutility.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/aviation/aviation.pro b/tests/blackmisc/aviation/aviation.pro new file mode 100644 index 000000000..a1f499a4f --- /dev/null +++ b/tests/blackmisc/aviation/aviation.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testaircraftparts \ + testaircraftsituation \ + testaviation \ + testflightplan \ diff --git a/tests/blackmisc/testaircraftparts.cpp b/tests/blackmisc/aviation/testaircraftparts/testaircraftparts.cpp similarity index 87% rename from tests/blackmisc/testaircraftparts.cpp rename to tests/blackmisc/aviation/testaircraftparts/testaircraftparts.cpp index 3bb64d264..56867ba77 100644 --- a/tests/blackmisc/testaircraftparts.cpp +++ b/tests/blackmisc/aviation/testaircraftparts/testaircraftparts.cpp @@ -8,15 +8,12 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testaircraftparts.h" #include "blackmisc/aviation/aircraftparts.h" #include "blackmisc/json.h" +#include "test.h" #include #include @@ -25,6 +22,20 @@ using namespace BlackMisc::Json; namespace BlackMiscTest { + //! Aircraft parts tests + class CTestAircraftParts : public QObject + { + Q_OBJECT + + private slots: + //! Test ground flag + void groundFlag(); + + private: + //! Test parts + BlackMisc::Aviation::CAircraftParts testParts1() const; + }; + void CTestAircraftParts::groundFlag() { const CAircraftParts ap1 = this->testParts1(); @@ -77,4 +88,8 @@ namespace BlackMiscTest } } // ns +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestAircraftParts) + +#include "testaircraftparts.moc" + //! \endcond diff --git a/tests/blackmisc/aviation/testaircraftparts/testaircraftparts.pro b/tests/blackmisc/aviation/testaircraftparts/testaircraftparts.pro new file mode 100644 index 000000000..35e636edb --- /dev/null +++ b/tests/blackmisc/aviation/testaircraftparts/testaircraftparts.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testaircraftparts +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testaircraftparts.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testaircraftsituation.cpp b/tests/blackmisc/aviation/testaircraftsituation/testaircraftsituation.cpp similarity index 89% rename from tests/blackmisc/testaircraftsituation.cpp rename to tests/blackmisc/aviation/testaircraftsituation/testaircraftsituation.cpp index 158283b88..e45e62bcd 100644 --- a/tests/blackmisc/testaircraftsituation.cpp +++ b/tests/blackmisc/aviation/testaircraftsituation/testaircraftsituation.cpp @@ -8,18 +8,16 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testaircraftsituation.h" -#include "blackmisc/network/fsdsetup.h" -#include "blackmisc/aviation/aircraftsituationchange.h" -#include "blackmisc/math/mathutils.h" -#include "blackmisc/stringutils.h" #include "blackconfig/buildconfig.h" +#include "blackmisc/aviation/aircraftsituationchange.h" +#include "blackmisc/aviation/aircraftsituationlist.h" +#include "blackmisc/network/fsdsetup.h" +// #include "blackmisc/math/mathutils.h" +// #include "blackmisc/stringutils.h" +#include "test.h" #include #include @@ -36,10 +34,49 @@ using namespace BlackMisc::Math; namespace BlackMiscTest { - CTestAircraftSituation::CTestAircraftSituation(QObject *parent): QObject(parent) + //! CAircraftSituation and CAircraftSituationChange tests + class CTestAircraftSituation : public QObject { - // void - } + Q_OBJECT + + private slots: + //! All GND flags + void allGndFlagsAndTakeOff() const; + + //! All not GND flags + void allNotGndFlagsAndTouchdown() const; + + //! Ascending aircraft + void ascending(); + + //! Descending aircraft + void descending(); + + //! Rotating up aircraft + void rotateUp(); + + //! Test sort order + void sortOrder() const; + + //! Altitude correction + void altitudeCorrection(); + + //! Using sort hint + void sortHint(); + + private: + //! Test situations (ascending) + static BlackMisc::Aviation::CAircraftSituationList testSituations(); + + //! Set descending altitudes + static BlackMisc::Aviation::CAircraftSituationList testSetDescendingAltitudes(const BlackMisc::Aviation::CAircraftSituationList &situations); + + //! Set descending altitudes + static BlackMisc::Aviation::CAircraftSituationList testSetRotateUpPitch(const BlackMisc::Aviation::CAircraftSituationList &situations); + + //! CG + static const BlackMisc::PhysicalQuantities::CLength &cg(); + }; void CTestAircraftSituation::allGndFlagsAndTakeOff() const { @@ -309,4 +346,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_MAIN(BlackMiscTest::CTestAircraftSituation); + +#include "testaircraftsituation.moc" + //! \endcond diff --git a/tests/blackmisc/aviation/testaircraftsituation/testaircraftsituation.pro b/tests/blackmisc/aviation/testaircraftsituation/testaircraftsituation.pro new file mode 100644 index 000000000..405b9a471 --- /dev/null +++ b/tests/blackmisc/aviation/testaircraftsituation/testaircraftsituation.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testaircraftsituation +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testaircraftsituation.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testaviation.cpp b/tests/blackmisc/aviation/testaviation/testaviation.cpp similarity index 91% rename from tests/blackmisc/testaviation.cpp rename to tests/blackmisc/aviation/testaviation/testaviation.cpp index 34a0ded04..9bebe8a67 100644 --- a/tests/blackmisc/testaviation.cpp +++ b/tests/blackmisc/aviation/testaviation/testaviation.cpp @@ -8,13 +8,9 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testaviation.h" #include "blackmisc/aviation/aircrafticaocode.h" #include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/airlineicaocode.h" @@ -38,6 +34,7 @@ #include "blackmisc/pq/length.h" #include "blackmisc/pq/physicalquantity.h" #include "blackmisc/pq/units.h" +#include "test.h" #include #include @@ -50,10 +47,33 @@ using namespace BlackMisc::Geo; namespace BlackMiscTest { - CTestAviation::CTestAviation(QObject *parent): QObject(parent) + //! Aviation classes basic tests + class CTestAviation : public QObject { - // void - } + Q_OBJECT + + private slots: + //! Basic unit tests for physical units + void headingBasics(); + + //! COM and NAV units + void comAndNav(); + + //! Transponder + void transponder(); + + //! Callsigns and callsign containers + void callsignWithContainers(); + + //! Testing copying and equality of objects + void copyAndEqual(); + + //! CAltitude tests + void altitude(); + + //! Test some of the guessing functions + void testGuessing(); + }; void CTestAviation::headingBasics() { @@ -70,11 +90,11 @@ namespace BlackMiscTest QVERIFY2(h4 == h1, "Values shall be equal"); h1 -= h1; - QVERIFY2(h1.value() == 0, "Value shall be 0"); + QCOMPARE(h1.value() + 1, 1.0); // h4 = h1 + h2; does not work, because misleading h2 += h2; // add just angle - QVERIFY2(h2.value() == 360, "Value shall be 360"); + QCOMPARE(h2.value(), 360.0); } void CTestAviation::comAndNav() @@ -222,4 +242,9 @@ namespace BlackMiscTest } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestAviation); + +#include "testaviation.moc" + //! \endcond diff --git a/tests/blackmisc/aviation/testaviation/testaviation.pro b/tests/blackmisc/aviation/testaviation/testaviation.pro new file mode 100644 index 000000000..58c66747d --- /dev/null +++ b/tests/blackmisc/aviation/testaviation/testaviation.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testaviation +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testaviation.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testflightplan.cpp b/tests/blackmisc/aviation/testflightplan/testflightplan.cpp similarity index 92% rename from tests/blackmisc/testflightplan.cpp rename to tests/blackmisc/aviation/testflightplan/testflightplan.cpp index 7319f5198..acf0ab63c 100644 --- a/tests/blackmisc/testflightplan.cpp +++ b/tests/blackmisc/aviation/testflightplan/testflightplan.cpp @@ -11,10 +11,10 @@ //! \file //! \ingroup testblackmisc -#include "testflightplan.h" #include "blackmisc/aviation/flightplan.h" #include "blackmisc/aviation/selcal.h" #include "blackmisc/network/voicecapabilities.h" +#include "test.h" #include using namespace BlackMisc::Aviation; @@ -23,6 +23,19 @@ using namespace BlackMisc::PhysicalQuantities; namespace BlackMiscTest { + //! Flightplan unit tests + class CTestFlightPlan : public QObject + { + Q_OBJECT + + private slots: + //! Flight plan remarks (parsing) + void flightPlanRemarks(); + + //! Flight plan altitude + void flightPlanAltitude(); + }; + void CTestFlightPlan::flightPlanRemarks() { QString remarks; @@ -92,4 +105,9 @@ namespace BlackMiscTest } } // ns +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestFlightPlan); + +#include "testflightplan.moc" + //! \endcond diff --git a/tests/blackmisc/aviation/testflightplan/testflightplan.pro b/tests/blackmisc/aviation/testflightplan/testflightplan.pro new file mode 100644 index 000000000..b2d4cfabf --- /dev/null +++ b/tests/blackmisc/aviation/testflightplan/testflightplan.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testflightplan +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testflightplan.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/blackmisc.pro b/tests/blackmisc/blackmisc.pro new file mode 100644 index 000000000..b37eb26b6 --- /dev/null +++ b/tests/blackmisc/blackmisc.pro @@ -0,0 +1,23 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + aviation \ + geo \ + input \ + math \ + pq \ + simulation \ + testcompress \ + testcontainers \ + testdbus \ + testicon \ + testidentifier \ + testlibrarypath \ + testprocess \ + testpropertyindex \ + testslot \ + teststatusmessage \ + teststringutils \ + testvaluecache \ + testvariantandmap \ + weather \ diff --git a/tests/blackmisc/geo/geo.pro b/tests/blackmisc/geo/geo.pro new file mode 100644 index 000000000..7e921a062 --- /dev/null +++ b/tests/blackmisc/geo/geo.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testgeo \ diff --git a/tests/blackmisc/testgeo.cpp b/tests/blackmisc/geo/testgeo/testgeo.cpp similarity index 84% rename from tests/blackmisc/testgeo.cpp rename to tests/blackmisc/geo/testgeo/testgeo.cpp index 3a98d2f46..e158f4b45 100644 --- a/tests/blackmisc/testgeo.cpp +++ b/tests/blackmisc/geo/testgeo/testgeo.cpp @@ -8,18 +8,15 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testgeo.h" #include "blackmisc/geo/coordinategeodetic.h" #include "blackmisc/geo/earthangle.h" #include "blackmisc/geo/latitude.h" #include "blackmisc/pq/physicalquantity.h" #include "blackmisc/pq/units.h" +#include "test.h" #include @@ -29,6 +26,19 @@ using namespace BlackMisc::Math; namespace BlackMiscTest { + //! Geo classes tests + class CTestGeo : public QObject + { + Q_OBJECT + + private slots: + //! Basic unit tests for geo classes + void geoBasics(); + + //! CCoordinateGeodetic unit tests + void coordinateGeodetic(); + }; + void CTestGeo::geoBasics() { CLatitude lat(10, CAngleUnit::deg()); @@ -68,8 +78,13 @@ namespace BlackMiscTest CLatitude newLat(90.0, CAngleUnit::deg()); testCoordinate.setLatitude(newLat); latValue = testCoordinate.latitude().value(CAngleUnit::deg()); - QVERIFY2(latValue == newLat.value(CAngleUnit::deg()), "Latitude value supposed to be equal"); + QCOMPARE(latValue, newLat.value(CAngleUnit::deg())); } } // ns +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestGeo); + +#include "testgeo.moc" + //! \endcond diff --git a/tests/blackmisc/testblackmisc.pro b/tests/blackmisc/geo/testgeo/testgeo.pro similarity index 50% rename from tests/blackmisc/testblackmisc.pro rename to tests/blackmisc/geo/testgeo/testgeo.pro index e0c50696d..58c38f065 100644 --- a/tests/blackmisc/testblackmisc.pro +++ b/tests/blackmisc/geo/testgeo/testgeo.pro @@ -1,22 +1,26 @@ load(common_pre) -QT += core testlib dbus network +QT += core dbus testlib -TARGET = testblackmisc -TEMPLATE = app - -CONFIG += console +TARGET = testgeo CONFIG -= app_bundle CONFIG += blackconfig CONFIG += blackmisc CONFIG += testcase CONFIG += no_testcase_installs -DEPENDPATH += . $$SourceRoot/src -INCLUDEPATH += . $$SourceRoot/src +TEMPLATE = app -HEADERS += *.h -SOURCES += *.cpp +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testgeo.cpp DESTDIR = $$DestRoot/bin diff --git a/tests/blackmisc/input/input.pro b/tests/blackmisc/input/input.pro new file mode 100644 index 000000000..95854fa49 --- /dev/null +++ b/tests/blackmisc/input/input.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testinput \ diff --git a/tests/blackmisc/testinput.cpp b/tests/blackmisc/input/testinput/testinput.cpp similarity index 92% rename from tests/blackmisc/testinput.cpp rename to tests/blackmisc/input/testinput/testinput.cpp index a2827bb7d..eebc91cd2 100644 --- a/tests/blackmisc/testinput.cpp +++ b/tests/blackmisc/input/testinput/testinput.cpp @@ -11,7 +11,6 @@ //! \file //! \ingroup testblackmisc -#include "testinput.h" #include "blackmisc/compare.h" #include "blackmisc/identifier.h" #include "blackmisc/input/actionhotkey.h" @@ -20,6 +19,7 @@ #include "blackmisc/input/keyboardkey.h" #include "blackmisc/input/keycodes.h" #include "blackmisc/variant.h" +#include "test.h" #include #include @@ -29,10 +29,24 @@ using namespace BlackMisc::Input; namespace BlackMiscTest { - CTestInput::CTestInput(QObject *parent): QObject(parent) + //! Input classes basic tests + class CTestInput : public QObject { - // void - } + Q_OBJECT + + private slots: + //! CKeyboardKey basic tests + void keyboardKey(); + + //! CHotkeyCombination tests + void hotkeyCombination(); + + void hotKeyEqual(); + void hotKeyNonEqual(); + void hotkeyEqualFromVariant(); + void hotkeyFindSupersetOf(); + void hotkeyFindSubsetOf(); + }; void CTestInput::keyboardKey() { @@ -180,4 +194,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestInput); + +#include "testinput.moc" + //! \endcond diff --git a/tests/blackmisc/input/testinput/testinput.pro b/tests/blackmisc/input/testinput/testinput.pro new file mode 100644 index 000000000..7ff134682 --- /dev/null +++ b/tests/blackmisc/input/testinput/testinput.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testinput +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testinput.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/main.cpp b/tests/blackmisc/main.cpp deleted file mode 100644 index 182c23a72..000000000 --- a/tests/blackmisc/main.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include "testblackmiscmain.h" -#include "blackmisc/registermetadata.h" - -#include -#include - -using namespace BlackMiscTest; - -/*! - * Starter for test cases - * \brief main - * \param argc - * \param argv - * \return - */ -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - Q_UNUSED(a); - - BlackMisc::registerMetadata(); - return CBlackMiscTestMain::unitMain(argc, argv);; -} - -//! \endcond diff --git a/tests/blackmisc/math/math.pro b/tests/blackmisc/math/math.pro new file mode 100644 index 000000000..fc938ad97 --- /dev/null +++ b/tests/blackmisc/math/math.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testmath \ diff --git a/tests/blackmisc/testmath.cpp b/tests/blackmisc/math/testmath/testmath.cpp similarity index 86% rename from tests/blackmisc/testmath.cpp rename to tests/blackmisc/math/testmath/testmath.cpp index 054745446..718bc6dd9 100644 --- a/tests/blackmisc/testmath.cpp +++ b/tests/blackmisc/math/testmath/testmath.cpp @@ -8,14 +8,11 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testmath.h" #include "blackmisc/math/mathutils.h" +#include "test.h" #include @@ -23,6 +20,16 @@ using namespace BlackMisc::Math; namespace BlackMiscTest { + //! Math unit tests + class CTestMath : public QObject + { + Q_OBJECT + + private slots: + //! Unit test for round to multiple of + void testRoundToMultipleOf(); + }; + void CTestMath::testRoundToMultipleOf() { QVERIFY2(CMathUtils::roundToMultipleOf(0, 3) == 0, "Nearest multiple of 3 from 0 should be 0"); @@ -46,4 +53,9 @@ namespace BlackMiscTest } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestMath); + +#include "testmath.moc" + //! \endcond diff --git a/tests/blackmisc/math/testmath/testmath.pro b/tests/blackmisc/math/testmath/testmath.pro new file mode 100644 index 000000000..a2c8c7d6b --- /dev/null +++ b/tests/blackmisc/math/testmath/testmath.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testmath +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testmath.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/pq/pq.pro b/tests/blackmisc/pq/pq.pro new file mode 100644 index 000000000..c8c1cc474 --- /dev/null +++ b/tests/blackmisc/pq/pq.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testphysicalquantities \ diff --git a/tests/blackmisc/testphysicalquantities.cpp b/tests/blackmisc/pq/testphysicalquantities/testphysicalquantities.cpp similarity index 88% rename from tests/blackmisc/testphysicalquantities.cpp rename to tests/blackmisc/pq/testphysicalquantities/testphysicalquantities.cpp index 768b7fd03..aec4e65f3 100644 --- a/tests/blackmisc/testphysicalquantities.cpp +++ b/tests/blackmisc/pq/testphysicalquantities/testphysicalquantities.cpp @@ -8,13 +8,9 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testphysicalquantities.h" #include "blackmisc/math/mathutils.h" #include "blackmisc/pq/acceleration.h" #include "blackmisc/pq/angle.h" @@ -31,6 +27,7 @@ #include "blackmisc/pq/time.h" #include "blackmisc/pq/units.h" #include "blackmisc/variant.h" +#include "test.h" #include #include @@ -41,9 +38,52 @@ using namespace BlackMisc::Math; namespace BlackMiscTest { - /* - * Basic unit tests for physical units - */ + //! Physical quantities, basic tests + class CTestPhysicalQuantities : public QObject + { + Q_OBJECT + + private slots: + //! Basic unit tests for physical units + void unitsBasics(); + + //! Basic tests around length + void lengthBasics(); + + //! Basic tests about speed + void speedBasics(); + + //! Frequency tests + void frequencyTests(); + + //! Testing angles (degrees / radians) + void angleTests(); + + //! Testing mass + void massTests(); + + //! Testing pressure + void pressureTests(); + + //! Testing temperature + void temperatureTests(); + + //! Testing time + void timeTests(); + + //! Testing acceleration + void accelerationTests(); + + //! Testing construction / destruction in memory + void memoryTests(); + + //! Test parsing on PQs + void parserTests(); + + //! Basic arithmetic such as +/- + void basicArithmetic(); + }; + void CTestPhysicalQuantities::unitsBasics() { // some tests on units @@ -59,9 +99,6 @@ namespace BlackMiscTest QVERIFY2(fu1 != du1, "Hz must not be meter"); } - /* - * Distance tests - */ void CTestPhysicalQuantities::lengthBasics() { CLength d1(1, CLengthUnit::m()); // 1m @@ -92,9 +129,6 @@ namespace BlackMiscTest QVERIFY2(d1 > d2, "d1 shall be greater"); } - /* - * Unit tests for speed - */ void CTestPhysicalQuantities::speedBasics() { CSpeed s1(100, CSpeedUnit::km_h()); @@ -103,22 +137,16 @@ namespace BlackMiscTest QVERIFY2(CMathUtils::epsilonEqual(s2.valueRounded(CSpeedUnit::m_s(), 1), 5.1), qPrintable(QString("1000ft/min is not %1 m/s").arg(s2.valueRounded(CSpeedUnit::m_s(), 1)))); } - /* - * Frequency unit tests - */ void CTestPhysicalQuantities::frequencyTests() { CFrequency f1(1, CFrequencyUnit::MHz()); - QVERIFY2(f1.valueRounded(CFrequencyUnit::kHz(), 2) == 1000, "Mega is 1000kHz"); - QVERIFY2(f1.value() == 1 , "1MHz"); - QVERIFY2(f1.value(CFrequencyUnit::defaultUnit()) == 1000000 , "1E6 Hz"); + QCOMPARE(f1.valueRounded(CFrequencyUnit::kHz(), 2), 1000.0); // "Mega is 1000kHz + QCOMPARE(f1.value(), 1.0); // 1MHz + QCOMPARE(f1.value(CFrequencyUnit::defaultUnit()), 1000000.0); // 1E6 Hz CFrequency f2(1e+6, CFrequencyUnit::Hz()) ; // 1 Megahertz QVERIFY2(f1 == f2 , "MHz is 1E6 Hz"); } - /* - * Angle tests - */ void CTestPhysicalQuantities::angleTests() { CAngle a1(180, CAngleUnit::deg()); @@ -143,23 +171,17 @@ namespace BlackMiscTest QVERIFY2(CMathUtils::epsilonEqual(a8.value(CAngleUnit::sexagesimalDegMin()), a9.value(CAngleUnit::sexagesimalDegMin())), "Conversion via radians yields same answer"); } - /* - * Weight tests - */ void CTestPhysicalQuantities::massTests() { CMass w1(1000, CMassUnit::kg()); CMass w2(w1.value(), CMassUnit::kg()); w2.switchUnit(CMassUnit::tonne()); - QVERIFY2(w2.value() == 1, "1tonne shall be 1000kg"); + QCOMPARE(w2.value(), 1.0); // 1tonne shall be 1000kg w2.switchUnit(CMassUnit::lb()); QVERIFY2(CMathUtils::epsilonEqual(w2.valueRounded(2), 2204.62), "1tonne shall be 2204pounds"); QVERIFY2(w1 == w2, "Masses shall be equal"); } - /* - * Pressure tests - */ void CTestPhysicalQuantities::pressureTests() { const CPressure p1(CPhysicalQuantitiesConstants::ISASeaLevelPressure()); @@ -169,7 +191,7 @@ namespace BlackMiscTest // does not match exactly QVERIFY2(p1 != p2, "Standard pressure test little difference"); - QVERIFY2(p1.value() == p4.value(), "mbar/hPa test"); + QCOMPARE(p1.value(), p4.value()); // mbar/hPa test // Unit substract test const CPressure seaLevelPressure(918.0, CPressureUnit::mbar()); @@ -180,9 +202,6 @@ namespace BlackMiscTest QCOMPARE(deltaV, expected); } - /* - * Temperature tests - */ void CTestPhysicalQuantities::temperatureTests() { CTemperature t1(0, CTemperatureUnit::C()); // 0C @@ -195,9 +214,6 @@ namespace BlackMiscTest QVERIFY2(CMathUtils::epsilonEqual(t4.valueRounded(CTemperatureUnit::K()), 260.93), qPrintable(QString("10F shall be 260.93K, not %1 K").arg(t4.valueRounded(CTemperatureUnit::K())))); } - /* - * Time tests - */ void CTestPhysicalQuantities::timeTests() { CTime t1(1, CTimeUnit::h()); @@ -220,9 +236,6 @@ namespace BlackMiscTest QVERIFY2(t7.formattedHrsMinSec() == "27:30:55", "Parsed time greater than 24h failed"); } - /* - * Test acceleration - */ void CTestPhysicalQuantities::accelerationTests() { CLength oneMeter(1, CLengthUnit::m()); @@ -236,9 +249,6 @@ namespace BlackMiscTest a1.valueRounded(6)), "Numerical values should be equal"); } - /* - * Just testing obvious memory create / destruct flaws - */ void CTestPhysicalQuantities::memoryTests() { CLength *c = new CLength(100, CLengthUnit::m()); @@ -254,9 +264,6 @@ namespace BlackMiscTest delete a; } - /* - * Parsing tests - */ void CTestPhysicalQuantities::parserTests() { QVERIFY2(CLength(33.0, CLengthUnit::ft()) == CLength("33.0 ft"), "Length"); @@ -277,9 +284,6 @@ namespace BlackMiscTest QVERIFY2(CFrequency(122.8, CFrequencyUnit::MHz()) == parsedPq3, "Parsed frequency via variant"); } - /* - * Some very basic arithmetic tests on the PQs - */ void CTestPhysicalQuantities::basicArithmetic() { // pressure @@ -291,7 +295,7 @@ namespace BlackMiscTest p3 /= 2.0; QVERIFY2(p3 == p1, "Pressure needs to be the same (1time)"); p3 = p3 - p3; - QVERIFY2(p3.value() == 0, "Value needs to be zero"); + QCOMPARE(p3.value() + 1, 1.0); // Value needs to be zero p3 = CPressure(1013, CPressureUnit::hPa()); QVERIFY2(p3 * 1.5 == 1.5 * p3, "Basic commutative test on PQ failed"); @@ -314,4 +318,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestPhysicalQuantities); + +#include "testphysicalquantities.moc" + //! \endcond diff --git a/tests/blackmisc/pq/testphysicalquantities/testphysicalquantities.pro b/tests/blackmisc/pq/testphysicalquantities/testphysicalquantities.pro new file mode 100644 index 000000000..306b12fde --- /dev/null +++ b/tests/blackmisc/pq/testphysicalquantities/testphysicalquantities.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testphysicalquantities +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testphysicalquantities.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/simulation/simulation.pro b/tests/blackmisc/simulation/simulation.pro new file mode 100644 index 000000000..ab4600a6f --- /dev/null +++ b/tests/blackmisc/simulation/simulation.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testinterpolatorlinear \ + testinterpolatormisc \ + testinterpolatorparts \ diff --git a/tests/blackmisc/testinterpolatorlinear.cpp b/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.cpp similarity index 91% rename from tests/blackmisc/testinterpolatorlinear.cpp rename to tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.cpp index fcbdf67fd..a59cbc506 100644 --- a/tests/blackmisc/testinterpolatorlinear.cpp +++ b/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.cpp @@ -8,13 +8,9 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testinterpolatorlinear.h" #include "blackmisc/simulation/interpolator.h" #include "blackmisc/simulation/interpolatorlinear.h" #include "blackmisc/simulation/remoteaircraftproviderdummy.h" @@ -35,6 +31,7 @@ #include "blackmisc/pq/speed.h" #include "blackmisc/pq/units.h" #include "blackmisc/compare.h" +#include "test.h" #include #include @@ -52,6 +49,23 @@ using namespace BlackMisc::Simulation; namespace BlackMiscTest { + //! Interpolator classes basic tests + class CTestInterpolatorLinear : public QObject + { + Q_OBJECT + + private slots: + //! Basic unit tests for interpolator + void basicInterpolatorTests(); + + private: + //! Test situation for testing + static BlackMisc::Aviation::CAircraftSituation getTestSituation(const BlackMisc::Aviation::CCallsign &callsign, int number, qint64 ts, qint64 deltaT, qint64 offset); + + //! Test parts + static BlackMisc::Aviation::CAircraftParts getTestParts(int number, qint64 ts, qint64 deltaT); + }; + void CTestInterpolatorLinear::basicInterpolatorTests() { const CCallsign cs("SWIFT"); @@ -182,4 +196,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestInterpolatorLinear); + +#include "testinterpolatorlinear.moc" + //! \endcond diff --git a/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.pro b/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.pro new file mode 100644 index 000000000..ed0ebb3dd --- /dev/null +++ b/tests/blackmisc/simulation/testinterpolatorlinear/testinterpolatorlinear.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testinterpolatorlinear +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testinterpolatorlinear.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testinterpolatormisc.cpp b/tests/blackmisc/simulation/testinterpolatormisc/testinterpolatormisc.cpp similarity index 79% rename from tests/blackmisc/testinterpolatormisc.cpp rename to tests/blackmisc/simulation/testinterpolatormisc/testinterpolatormisc.cpp index 11abe1810..9638c58cc 100644 --- a/tests/blackmisc/testinterpolatormisc.cpp +++ b/tests/blackmisc/simulation/testinterpolatormisc/testinterpolatormisc.cpp @@ -8,14 +8,11 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testinterpolatormisc.h" #include "blackmisc/simulation/interpolationrenderingsetup.h" +#include "test.h" #include #include @@ -27,6 +24,16 @@ using namespace BlackMisc::Simulation; namespace BlackMiscTest { + //! Interpolator related basic tests + class CTestInterpolatorMisc : public QObject + { + Q_OBJECT + + private slots: + //! Basic unit tests for interpolation setup + void setupTests(); + }; + void CTestInterpolatorMisc::setupTests() { const CInterpolationAndRenderingSetupGlobal gs1; @@ -46,4 +53,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestInterpolatorMisc); + +#include "testinterpolatormisc.moc" + //! \endcond diff --git a/tests/blackmisc/simulation/testinterpolatormisc/testinterpolatormisc.pro b/tests/blackmisc/simulation/testinterpolatormisc/testinterpolatormisc.pro new file mode 100644 index 000000000..9f0f97963 --- /dev/null +++ b/tests/blackmisc/simulation/testinterpolatormisc/testinterpolatormisc.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testinterpolatormisc +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testinterpolatormisc.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testinterpolatorparts.cpp b/tests/blackmisc/simulation/testinterpolatorparts/testinterpolatorparts.cpp similarity index 88% rename from tests/blackmisc/testinterpolatorparts.cpp rename to tests/blackmisc/simulation/testinterpolatorparts/testinterpolatorparts.cpp index 25071c329..99fd1312c 100644 --- a/tests/blackmisc/testinterpolatorparts.cpp +++ b/tests/blackmisc/simulation/testinterpolatorparts/testinterpolatorparts.cpp @@ -8,15 +8,12 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testinterpolatorparts.h" #include "blackmisc/simulation/interpolatorspline.h" #include "blackmisc/simulation/remoteaircraftproviderdummy.h" +#include "test.h" #include #include @@ -28,6 +25,26 @@ using namespace BlackMisc::Simulation; namespace BlackMiscTest { + //! Aircraft parts interpolation, mainly ground flag interpolation + class CTestInterpolatorParts : public QObject + { + Q_OBJECT + + private slots: + //! Basic unit tests for interpolator + void groundFlagInterpolation(); + + //! Tests adjusting the ground flag by parts + void partsToSituationGndFlag(); + + private: + //! Test parts + static BlackMisc::Aviation::CAircraftParts createTestParts(int number, qint64 ts, qint64 deltaT, bool onGround); + + //! Test situation for testing + static BlackMisc::Aviation::CAircraftSituation createTestSituation(const BlackMisc::Aviation::CCallsign &callsign, int number, qint64 ts, qint64 deltaT, qint64 offset); + }; + void CTestInterpolatorParts::groundFlagInterpolation() { const CCallsign cs("SWIFT"); @@ -167,4 +184,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestInterpolatorParts); + +#include "testinterpolatorparts.moc" + //! \endcond diff --git a/tests/blackmisc/simulation/testinterpolatorparts/testinterpolatorparts.pro b/tests/blackmisc/simulation/testinterpolatorparts/testinterpolatorparts.pro new file mode 100644 index 000000000..ce1373f0d --- /dev/null +++ b/tests/blackmisc/simulation/testinterpolatorparts/testinterpolatorparts.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testinterpolatorparts +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testinterpolatorparts.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testaircraftparts.h b/tests/blackmisc/testaircraftparts.h deleted file mode 100644 index 739078cbb..000000000 --- a/tests/blackmisc/testaircraftparts.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2018 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTAIRCRAFTPARTS_H -#define BLACKMISCTEST_TESTAIRCRAFTPARTS_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include "blackmisc/aviation/aircraftparts.h" -#include - -namespace BlackMiscTest -{ - //! Geo classes tests - class CTestAircraftParts : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestAircraftParts(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Test ground flag - void groundFlag(); - - private: - //! Test parts - BlackMisc::Aviation::CAircraftParts testParts1() const; - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testaircraftsituation.h b/tests/blackmisc/testaircraftsituation.h deleted file mode 100644 index ec1ff19ce..000000000 --- a/tests/blackmisc/testaircraftsituation.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (C) 2018 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTAIRCRAFTSITUATION_H -#define BLACKMISCTEST_TESTAIRCRAFTSITUATION_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include "blackmisc/aviation/aircraftsituationlist.h" -#include - -namespace BlackMiscTest -{ - /*! - * CAircraftSituation and CAircraftSituationChange tests - */ - class CTestAircraftSituation : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestAircraftSituation(QObject *parent = nullptr); - - private slots: - //! All GND flags - void allGndFlagsAndTakeOff() const; - - //! All not GND flags - void allNotGndFlagsAndTouchdown() const; - - //! Ascending aircraft - void ascending(); - - //! Descending aircraft - void descending(); - - //! Rotating up aircraft - void rotateUp(); - - //! Test sort order - void sortOrder() const; - - //! Altitude correction - void altitudeCorrection(); - - //! Using sort hint - void sortHint(); - - private: - //! Test situations (ascending) - static BlackMisc::Aviation::CAircraftSituationList testSituations(); - - //! Set descending altitudes - static BlackMisc::Aviation::CAircraftSituationList testSetDescendingAltitudes(const BlackMisc::Aviation::CAircraftSituationList &situations); - - //! Set descending altitudes - static BlackMisc::Aviation::CAircraftSituationList testSetRotateUpPitch(const BlackMisc::Aviation::CAircraftSituationList &situations); - - //! CG - static const BlackMisc::PhysicalQuantities::CLength &cg(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testaviation.h b/tests/blackmisc/testaviation.h deleted file mode 100644 index a425e0cc8..000000000 --- a/tests/blackmisc/testaviation.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTAVIATIONBASE_H -#define BLACKMISCTEST_TESTAVIATIONBASE_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include - -namespace BlackMiscTest -{ - /*! - * Aviation classes basic tests - */ - class CTestAviation : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestAviation(QObject *parent = nullptr); - - private slots: - //! Basic unit tests for physical units - void headingBasics(); - - //! COM and NAV units - void comAndNav(); - - //! Transponder - void transponder(); - - //! Callsigns and callsign containers - void callsignWithContainers(); - - //! Testing copying and equality of objects - void copyAndEqual(); - - //! CAltitude tests - void altitude(); - - //! Test some of the guessing functions - void testGuessing(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testblackmiscmain.cpp b/tests/blackmisc/testblackmiscmain.cpp deleted file mode 100644 index e109cca26..000000000 --- a/tests/blackmisc/testblackmiscmain.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include "testaircraftparts.h" -#include "testaircraftsituation.h" -#include "testaviation.h" -#include "testblackmiscmain.h" -#include "testcompress.h" -#include "testcontainers.h" -#include "testdbus.h" -#include "testflightplan.h" -#include "testgeo.h" -#include "testicon.h" -#include "testidentifier.h" -#include "testinput.h" -#include "testinterpolatorlinear.h" -#include "testinterpolatorparts.h" -#include "testinterpolatormisc.h" -#include "testlibrarypath.h" -#include "testmath.h" -#include "testmisc.h" -#include "testphysicalquantities.h" -#include "testprocess.h" -#include "testpropertyindex.h" -#include "testslot.h" -#include "teststringutils.h" -#include "testvaluecache.h" -#include "testvariantandmap.h" -#include "testweather.h" -#include "blackmisc/test/test.h" - -#include -#include - -namespace BlackMiscTest -{ - /* - * Starting main, equivalent to QTEST_APPLESS_MAIN for multiple test classes. - */ - int CBlackMiscTestMain::unitMain(int argc, char *argv[]) - { - BlackMisc::Test::CTest test(argc, argv); - - int status = 0; - { - CTestCompress compressTest; - status |= test.exec(&compressTest, "blackmisc_compress"); - } - { - CTestMisc miscTest; - status |= test.exec(&miscTest, "blackmisc_misc"); - } - { - CTestPhysicalQuantities pqBaseTests; - status |= test.exec(&pqBaseTests, "blackmisc_physicalQuantities"); - } - { - CTestAviation avBaseTests; - status |= test.exec(&avBaseTests, "blackmisc_aviation"); - } - { - CTestPropertyIndex piTests; - status |= test.exec(&piTests, "blackmisc_propertyindex"); - } - { - CTestAircraftParts apTests; - status |= test.exec(&apTests, "blackmisc_aircraftParts"); - } - { - CTestAircraftSituation sitTests; - status |= test.exec(&sitTests, "blackmisc_aircraftSituation"); - } - { - CTestGeo geoTests; - status |= test.exec(&geoTests, "blackmisc_geo"); - } - { - CTestFlightPlan fpTests; - status |= test.exec(&fpTests, "blackmisc_flightplan"); - } - { - CTestContainers containerTests; - status |= test.exec(&containerTests, "blackmisc_containers"); - } - { - CTestVariantAndMap variantAndMap; - status |= test.exec(&variantAndMap, "blackmisc_variantandmap"); - } - { - CTestInput inputTests; - status |= test.exec(&inputTests, "blackmisc_input"); - } - { - CTestIdentifier identifierTests; - status |= test.exec(&identifierTests, "blackmisc_identifier"); - } - { - CTestSlot slotTests; - status |= test.exec(&slotTests, "blackmisc_slot"); - } - { - CTestStringUtils stringUtilTests; - status |= test.exec(&stringUtilTests, "blackmisc_stringutils"); - } - { - CTestValueCache valueCacheTests; - status |= test.exec(&valueCacheTests, "blackmisc_valuecache"); - } - { - CTestWeather weatherTests; - status |= test.exec(&weatherTests, "blackmisc_weather"); - } - { - CTestMath mathTests; - status |= test.exec(&mathTests, "blackmisc_math"); - } - { - CTestInterpolatorLinear interpolatorTests; - status |= test.exec(&interpolatorTests, "blackmisc_interpolatorlinear"); - } - { - CTestInterpolatorParts interpolatorParts; - status |= test.exec(&interpolatorParts, "blackmisc_interpolatorparts"); - } - { - CTestInterpolatorMisc interpolatorMisc; - status |= test.exec(&interpolatorMisc, "blackmisc_interpolatormisc"); - } - { - CTestLibraryPath libraryPathTests; - status |= test.exec(&libraryPathTests, "blackmisc_librarypath"); - } - { - CTestProcess processTests; - status |= test.exec(&processTests, "blackmisc_process"); - } - { - CTestDBus testDBus; - status |= test.exec(&testDBus, "blackmisc_dbus"); - } - { - CTestIcon testIcon; - status |= test.exec(&testIcon, "blackmisc_icon"); - } - return status; - } -} // namespace - -//! \endcond diff --git a/tests/blackmisc/testblackmiscmain.h b/tests/blackmisc/testblackmiscmain.h deleted file mode 100644 index 310381b0e..000000000 --- a/tests/blackmisc/testblackmiscmain.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2014 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTMAIN_H -#define BLACKMISCTEST_TESTMAIN_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -namespace BlackMiscTest -{ - /*! - * Class firing all unit tests in this namespace. - * Avoids clashes with other main(..) functions and allows to fire the test cases - * simply from any other main. - */ - class CBlackMiscTestMain - { - public: - //! Starting all - static int unitMain(int argc, char *argv[]); - }; -} - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testcompress.h b/tests/blackmisc/testcompress.h deleted file mode 100644 index e72b24046..000000000 --- a/tests/blackmisc/testcompress.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2016 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTCOMPRESS_H -#define BLACKMISCTEST_TESTCOMPRESS_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Testing process tools - class CTestCompress : public QObject - { - Q_OBJECT - - public: - //! Constructor - explicit CTestCompress(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Uncompress file - void uncompressFile(); - }; -} - -//! \endcond - -#endif diff --git a/tests/blackmisc/testcompress.cpp b/tests/blackmisc/testcompress/testcompress.cpp similarity index 80% rename from tests/blackmisc/testcompress.cpp rename to tests/blackmisc/testcompress/testcompress.cpp index a0be21b74..009a17891 100644 --- a/tests/blackmisc/testcompress.cpp +++ b/tests/blackmisc/testcompress/testcompress.cpp @@ -14,12 +14,13 @@ * \ingroup testblackmisc */ -#include "testcompress.h" #include "blackconfig/buildconfig.h" #include "blackmisc/compressutils.h" #include "blackmisc/directoryutils.h" #include "blackmisc/fileutils.h" +#include "test.h" +#include #include #include #include @@ -29,6 +30,23 @@ using namespace BlackConfig; namespace BlackMiscTest { + //! Testing process tools + class CTestCompress : public QObject + { + Q_OBJECT + + public: + //! Constructor + explicit CTestCompress(QObject *parent = nullptr) : QObject(parent) {} + + //! Destructor + virtual ~CTestCompress() {} + + private slots: + //! Uncompress file + void uncompressFile(); + }; + void CTestCompress::uncompressFile() { QTemporaryDir tempDir; @@ -61,4 +79,9 @@ namespace BlackMiscTest } } +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestCompress); + +#include "testcompress.moc" + //! \endcond diff --git a/tests/blackmisc/testcompress/testcompress.pro b/tests/blackmisc/testcompress/testcompress.pro new file mode 100644 index 000000000..b7de5971b --- /dev/null +++ b/tests/blackmisc/testcompress/testcompress.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testcompress +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testcompress.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testcontainers.h b/tests/blackmisc/testcontainers.h deleted file mode 100644 index 87efe63c6..000000000 --- a/tests/blackmisc/testcontainers.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2014 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTCONTAINERS_H -#define BLACKMISCTEST_TESTCONTAINERS_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Testing containers - class CTestContainers : public QObject - { - Q_OBJECT - - public: - //! Constructor - explicit CTestContainers(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - void initTestCase(); - - void collectionBasics(); - void sequenceBasics(); - void joinAndSplit(); - void findTests(); - void dictionaryBasics(); - void timestampList(); - void offsetTimestampList(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testcontainers.cpp b/tests/blackmisc/testcontainers/testcontainers.cpp similarity index 95% rename from tests/blackmisc/testcontainers.cpp rename to tests/blackmisc/testcontainers/testcontainers.cpp index 89ae453e5..ca9b2e6a3 100644 --- a/tests/blackmisc/testcontainers.cpp +++ b/tests/blackmisc/testcontainers/testcontainers.cpp @@ -14,8 +14,7 @@ * \ingroup testblackmisc */ -#include "testcontainers.h" -#include "testvalueobject.h" +#include "../testvalueobject.h" #include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituationlist.h" #include "blackmisc/aviation/callsign.h" @@ -26,6 +25,7 @@ #include "blackmisc/range.h" #include "blackmisc/registermetadata.h" #include "blackmisc/sequence.h" +#include "test.h" #include #include @@ -48,6 +48,27 @@ using namespace BlackMisc::PhysicalQuantities; namespace BlackMiscTest { + //! Testing containers + class CTestContainers : public QObject + { + Q_OBJECT + + public: + //! Constructor + explicit CTestContainers(QObject *parent = nullptr) : QObject(parent) {} + + private slots: + void initTestCase(); + + void collectionBasics(); + void sequenceBasics(); + void joinAndSplit(); + void findTests(); + void dictionaryBasics(); + void timestampList(); + void offsetTimestampList(); + }; + void CTestContainers::initTestCase() { BlackMisc::registerMetadata(); @@ -361,4 +382,9 @@ namespace BlackMiscTest } } //namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestContainers); + +#include "testcontainers.moc" + //! \endcond diff --git a/tests/blackmisc/testcontainers/testcontainers.pro b/tests/blackmisc/testcontainers/testcontainers.pro new file mode 100644 index 000000000..fd3f15742 --- /dev/null +++ b/tests/blackmisc/testcontainers/testcontainers.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testcontainers +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testcontainers.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testdbus.h b/tests/blackmisc/testdbus.h deleted file mode 100644 index 05c4fccdf..000000000 --- a/tests/blackmisc/testdbus.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2017 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKCORETEST_TESTDBUS_H -#define BLACKCORETEST_TESTDBUS_H - -#include "blackmisc/variant.h" -#include - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -namespace BlackMiscTest -{ - /*! - * DBus implementation classes tests - */ - class CTestDBus : public QObject - { - Q_OBJECT - - public: - //! Constructor. - explicit CTestDBus(QObject *parent = nullptr) : - QObject(parent) - {} - - private slots: - //! Test marshalling/unmarshalling - void marshallUnmarshall(); - - //! Signature size - void signatureSize(); - }; -} //namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testdbus.cpp b/tests/blackmisc/testdbus/testdbus.cpp similarity index 79% rename from tests/blackmisc/testdbus.cpp rename to tests/blackmisc/testdbus/testdbus.cpp index 1bbd1dd07..99ef6cb1b 100644 --- a/tests/blackmisc/testdbus.cpp +++ b/tests/blackmisc/testdbus/testdbus.cpp @@ -11,14 +11,15 @@ /*! * \file - * \ingroup testblackcore + * \ingroup testblackmisc */ -#include "testdbus.h" +#include "blackmisc/registermetadata.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/test/testservice.h" #include "blackmisc/test/testserviceinterface.h" #include "blackmisc/dbusutils.h" +#include "test.h" #include #include @@ -28,6 +29,27 @@ using namespace BlackMisc::Test; namespace BlackMiscTest { + //! DBus implementation classes tests + class CTestDBus : public QObject + { + Q_OBJECT + + private slots: + //! Init test case data + void initTestCase(); + + //! Test marshalling/unmarshalling + void marshallUnmarshall(); + + //! Signature size + void signatureSize(); + }; + + void CTestDBus::initTestCase() + { + BlackMisc::registerMetadata(); + } + void CTestDBus::marshallUnmarshall() { QDBusConnection connection = QDBusConnection::sessionBus(); @@ -63,4 +85,9 @@ namespace BlackMiscTest } } +//! main +BLACKTEST_MAIN(BlackMiscTest::CTestDBus); + +#include "testdbus.moc" + //! \endcond diff --git a/tests/blackmisc/testdbus/testdbus.pro b/tests/blackmisc/testdbus/testdbus.pro new file mode 100644 index 000000000..053aeeda4 --- /dev/null +++ b/tests/blackmisc/testdbus/testdbus.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testdbus +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testdbus.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testflightplan.h b/tests/blackmisc/testflightplan.h deleted file mode 100644 index 4ce20c954..000000000 --- a/tests/blackmisc/testflightplan.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2017 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTFLIGHTPLAN_H -#define BLACKMISCTEST_TESTFLIGHTPLAN_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Geo classes tests - class CTestFlightPlan : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestFlightPlan(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Flight plan remarks (parsing) - void flightPlanRemarks(); - - //! Flight plan altitude - void flightPlanAltitude(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testgeo.h b/tests/blackmisc/testgeo.h deleted file mode 100644 index f58d92c07..000000000 --- a/tests/blackmisc/testgeo.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2014 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTGEO_H -#define BLACKMISCTEST_TESTGEO_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Geo classes tests - class CTestGeo : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestGeo(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Basic unit tests for geo classes - void geoBasics(); - - //! CCoordinateGeodetic unit tests - void coordinateGeodetic(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testicon.cpp b/tests/blackmisc/testicon/testicon.cpp similarity index 81% rename from tests/blackmisc/testicon.cpp rename to tests/blackmisc/testicon/testicon.cpp index f1e17cf28..6d5e56cce 100644 --- a/tests/blackmisc/testicon.cpp +++ b/tests/blackmisc/testicon/testicon.cpp @@ -8,14 +8,11 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testicon.h" #include "blackmisc/iconlist.h" +#include "test.h" #include #include @@ -23,6 +20,16 @@ using namespace BlackMisc; namespace BlackMiscTest { + //! Testing icons + class CTestIcon : public QObject + { + Q_OBJECT + + private slots: + //! Icon order/index + void iconIndex(); + }; + void CTestIcon::iconIndex() { const int max = static_cast(CIcons::IconIsGenerated); @@ -44,4 +51,9 @@ namespace BlackMiscTest } } //namespace +//! main +BLACKTEST_MAIN(BlackMiscTest::CTestIcon); + +#include "testicon.moc" + //! \endcond diff --git a/tests/blackmisc/testicon/testicon.pro b/tests/blackmisc/testicon/testicon.pro new file mode 100644 index 000000000..2fb57e107 --- /dev/null +++ b/tests/blackmisc/testicon/testicon.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testicon +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testicon.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testidentifier.h b/tests/blackmisc/testidentifier.h deleted file mode 100644 index 466463eb5..000000000 --- a/tests/blackmisc/testidentifier.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2014 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTIDENTIFIER_H -#define BLACKMISCTEST_TESTIDENTIFIER_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include "blackmisc/identifiable.h" - -#include - -namespace BlackMiscTest -{ - //! Testing object identifier - class CTestIdentifier : public QObject - { - Q_OBJECT - - public: - //! Constructor - explicit CTestIdentifier(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Identifier tests - void identifierBasics(); - }; - - //! Test identifiable object - class CTestIdentifiable : public BlackMisc::CIdentifiable - { - public: - //! Constructor - CTestIdentifiable(QObject *nameObject); - }; - -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testidentifier.cpp b/tests/blackmisc/testidentifier/testidentifier.cpp similarity index 69% rename from tests/blackmisc/testidentifier.cpp rename to tests/blackmisc/testidentifier/testidentifier.cpp index 781876943..4f41b4ac4 100644 --- a/tests/blackmisc/testidentifier.cpp +++ b/tests/blackmisc/testidentifier/testidentifier.cpp @@ -8,16 +8,15 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testidentifier.h" #include "blackmisc/compare.h" #include "blackmisc/identifier.h" +#include "blackmisc/identifiable.h" +#include "test.h" +#include #include #include @@ -25,6 +24,23 @@ using namespace BlackMisc; namespace BlackMiscTest { + //! Testing object identifier + class CTestIdentifier : public QObject + { + Q_OBJECT + + private slots: + //! Identifier tests + void identifierBasics(); + }; + + //! Test identifiable object + class CTestIdentifiable : public BlackMisc::CIdentifiable + { + public: + //! Constructor + CTestIdentifiable(QObject *nameObject); + }; void CTestIdentifier::identifierBasics() { @@ -48,4 +64,9 @@ namespace BlackMiscTest } //namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestIdentifier); + +#include "testidentifier.moc" + //! \endcond diff --git a/tests/blackmisc/testidentifier/testidentifier.pro b/tests/blackmisc/testidentifier/testidentifier.pro new file mode 100644 index 000000000..32383b224 --- /dev/null +++ b/tests/blackmisc/testidentifier/testidentifier.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testidentifier +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testidentifier.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testinput.h b/tests/blackmisc/testinput.h deleted file mode 100644 index 6522cff68..000000000 --- a/tests/blackmisc/testinput.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2014 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTINPUT_H -#define BLACKMISCTEST_TESTINPUT_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Input classes basic tests - class CTestInput : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestInput(QObject *parent = nullptr); - - private slots: - //! CKeyboardKey basic tests - void keyboardKey(); - - //! CHotkeyCombination tests - void hotkeyCombination(); - - void hotKeyEqual(); - void hotKeyNonEqual(); - void hotkeyEqualFromVariant(); - void hotkeyFindSupersetOf(); - void hotkeyFindSubsetOf(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testinterpolatorlinear.h b/tests/blackmisc/testinterpolatorlinear.h deleted file mode 100644 index ee7fc0d9d..000000000 --- a/tests/blackmisc/testinterpolatorlinear.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2015 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTINTERPOLATORLINEAR_H -#define BLACKMISCTEST_TESTINTERPOLATORLINEAR_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include "blackmisc/aviation/aircraftparts.h" -#include "blackmisc/aviation/aircraftsituation.h" -#include -#include - -namespace BlackMisc { namespace Aviation { class CCallsign; } } -namespace BlackMiscTest -{ - /*! - * Interpolator classes basic tests - */ - class CTestInterpolatorLinear : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestInterpolatorLinear(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Basic unit tests for interpolator - void basicInterpolatorTests(); - - private: - //! Test situation for testing - static BlackMisc::Aviation::CAircraftSituation getTestSituation(const BlackMisc::Aviation::CCallsign &callsign, int number, qint64 ts, qint64 deltaT, qint64 offset); - - //! Test parts - static BlackMisc::Aviation::CAircraftParts getTestParts(int number, qint64 ts, qint64 deltaT); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testinterpolatormisc.h b/tests/blackmisc/testinterpolatormisc.h deleted file mode 100644 index 348f93697..000000000 --- a/tests/blackmisc/testinterpolatormisc.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2018 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTINTERPOLATORMISC_H -#define BLACKMISCTEST_TESTINTERPOLATORMISC_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include -#include - -namespace BlackMiscTest -{ - /*! - * Interpolator related basic tests - */ - class CTestInterpolatorMisc : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestInterpolatorMisc(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Basic unit tests for interpolation setup - void setupTests(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testinterpolatorparts.h b/tests/blackmisc/testinterpolatorparts.h deleted file mode 100644 index a869126d3..000000000 --- a/tests/blackmisc/testinterpolatorparts.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2018 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTINTERPOLATORPARTS_H -#define BLACKMISCTEST_TESTINTERPOLATORPARTS_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include "blackmisc/aviation/aircraftparts.h" -#include "blackmisc/aviation/aircraftsituation.h" - -#include -#include - -namespace BlackMiscTest -{ - /*! - * Aircraft parts interpolation, mainly ground flag interpolation - */ - class CTestInterpolatorParts : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestInterpolatorParts(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Basic unit tests for interpolator - void groundFlagInterpolation(); - - //! Tests adjusting the ground flag by parts - void partsToSituationGndFlag(); - - private: - //! Test parts - static BlackMisc::Aviation::CAircraftParts createTestParts(int number, qint64 ts, qint64 deltaT, bool onGround); - - //! Test situation for testing - static BlackMisc::Aviation::CAircraftSituation createTestSituation(const BlackMisc::Aviation::CCallsign &callsign, int number, qint64 ts, qint64 deltaT, qint64 offset); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testlibrarypath.h b/tests/blackmisc/testlibrarypath.h deleted file mode 100644 index b901b4a73..000000000 --- a/tests/blackmisc/testlibrarypath.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2016 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTLIBRARYPATH_H -#define BLACKMISCTEST_TESTLIBRARYPATH_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include - -namespace BlackMiscTest -{ - - //! Geo classes tests - class CTestLibraryPath : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestLibraryPath(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Basic unit tests for library path - void libraryPath(); - }; - -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testlibrarypath.cpp b/tests/blackmisc/testlibrarypath/testlibrarypath.cpp similarity index 76% rename from tests/blackmisc/testlibrarypath.cpp rename to tests/blackmisc/testlibrarypath/testlibrarypath.cpp index 492ccd34a..cea1dcf5d 100644 --- a/tests/blackmisc/testlibrarypath.cpp +++ b/tests/blackmisc/testlibrarypath/testlibrarypath.cpp @@ -8,18 +8,27 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testlibrarypath.h" #include "blackconfig/buildconfig.h" #include "blackmisc/librarypath.h" +#include "test.h" + +#include namespace BlackMiscTest { + //! Geo classes tests + class CTestLibraryPath : public QObject + { + Q_OBJECT + + private slots: + //! Basic unit tests for library path + void libraryPath(); + }; + void CTestLibraryPath::libraryPath() { if (!BlackConfig::CBuildConfig::isRunningOnWindowsNtPlatform()) { return; } @@ -37,4 +46,9 @@ namespace BlackMiscTest } // namespace +//! main +BLACKTEST_MAIN(BlackMiscTest::CTestLibraryPath); + +#include "testlibrarypath.moc" + //! \endcond diff --git a/tests/blackmisc/testlibrarypath/testlibrarypath.pro b/tests/blackmisc/testlibrarypath/testlibrarypath.pro new file mode 100644 index 000000000..0420761a7 --- /dev/null +++ b/tests/blackmisc/testlibrarypath/testlibrarypath.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testlibrarypath +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testlibrarypath.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testmath.h b/tests/blackmisc/testmath.h deleted file mode 100644 index f7720c414..000000000 --- a/tests/blackmisc/testmath.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2016 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTMATH_H -#define BLACKMISCTEST_TESTMATH_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - /*! - * Math classes tests - */ - class CTestMath : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestMath(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Unit test for round to multiple of - void testRoundToMultipleOf(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testmisc.h b/tests/blackmisc/testmisc.h deleted file mode 100644 index 67b03ee1f..000000000 --- a/tests/blackmisc/testmisc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2018 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTMISC_H -#define BLACKMISCTEST_TESTMISC_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Testing property index access - class CTestMisc : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestMisc(QObject *parent = nullptr); - - private slots: - //! Status message - void statusMessage(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testphysicalquantities.h b/tests/blackmisc/testphysicalquantities.h deleted file mode 100644 index bb402899d..000000000 --- a/tests/blackmisc/testphysicalquantities.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTPHYSICALQUANTITIESBASE_H -#define BLACKMISCTEST_TESTPHYSICALQUANTITIESBASE_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include - -namespace BlackMiscTest -{ - //! Physical quantities, basic tests - class CTestPhysicalQuantities : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestPhysicalQuantities(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Basic unit tests for physical units - void unitsBasics(); - - //! Basic tests around length - void lengthBasics(); - - //! Basic tests about speed - void speedBasics(); - - //! Frequency tests - void frequencyTests(); - - //! Testing angles (degrees / radians) - void angleTests(); - - //! Testing mass - void massTests(); - - //! Testing pressure - void pressureTests(); - - //! Testing temperature - void temperatureTests(); - - //! Testing time - void timeTests(); - - //! Testing acceleration - void accelerationTests(); - - //! Testing construction / destruction in memory - void memoryTests(); - - //! Test parsing on PQs - void parserTests(); - - //! Basic arithmetic such as +/- - void basicArithmetic(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testprocess.h b/tests/blackmisc/testprocess.h deleted file mode 100644 index b9918e33c..000000000 --- a/tests/blackmisc/testprocess.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2016 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTPROCESS_H -#define BLACKMISCTEST_TESTPROCESS_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Testing process tools - class CTestProcess : public QObject - { - Q_OBJECT - - public: - //! Constructor - explicit CTestProcess(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Process info tests - void processInfo(); - }; -} - -//! \endcond - -#endif diff --git a/tests/blackmisc/testprocess.cpp b/tests/blackmisc/testprocess/testprocess.cpp similarity index 79% rename from tests/blackmisc/testprocess.cpp rename to tests/blackmisc/testprocess/testprocess.cpp index d1d0b3026..de6165f44 100644 --- a/tests/blackmisc/testprocess.cpp +++ b/tests/blackmisc/testprocess/testprocess.cpp @@ -8,14 +8,11 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! -* \file -* \ingroup testblackmisc -*/ - -#include "testprocess.h" #include "blackmisc/processinfo.h" +#include "test.h" #include #include @@ -23,6 +20,16 @@ using namespace BlackMisc; namespace BlackMiscTest { + //! Testing process tools + class CTestProcess : public QObject + { + Q_OBJECT + + private slots: + //! Process info tests + void processInfo(); + }; + void CTestProcess::processInfo() { CProcessInfo invalid; @@ -37,4 +44,9 @@ namespace BlackMiscTest } } +//! main +BLACKTEST_MAIN(BlackMiscTest::CTestProcess); + +#include "testprocess.moc" + //! \endcond diff --git a/tests/blackmisc/testprocess/testprocess.pro b/tests/blackmisc/testprocess/testprocess.pro new file mode 100644 index 000000000..780251445 --- /dev/null +++ b/tests/blackmisc/testprocess/testprocess.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testprocess +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testprocess.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testpropertyindex.h b/tests/blackmisc/testpropertyindex.h deleted file mode 100644 index 9d48485e8..000000000 --- a/tests/blackmisc/testpropertyindex.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2017 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTPROPERTYINDEX_H -#define BLACKMISCTEST_TESTPROPERTYINDEX_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Testing property index access - class CTestPropertyIndex : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestPropertyIndex(QObject *parent = nullptr); - - private slots: - //! Simulated aircraft index checks - void propertyIndexCSimulatedAircraft(); - - //! Sorting based on property index - void propertyIndexSort(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testpropertyindex.cpp b/tests/blackmisc/testpropertyindex/testpropertyindex.cpp similarity index 90% rename from tests/blackmisc/testpropertyindex.cpp rename to tests/blackmisc/testpropertyindex/testpropertyindex.cpp index ae07f3b32..c0731af92 100644 --- a/tests/blackmisc/testpropertyindex.cpp +++ b/tests/blackmisc/testpropertyindex/testpropertyindex.cpp @@ -11,11 +11,11 @@ //! \file //! \ingroup testblackmisc -#include "testpropertyindex.h" #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/statusmessagelist.h" #include "blackmisc/sequence.h" #include "blackmisc/comparefunctions.h" +#include "test.h" #include using namespace BlackMisc; @@ -25,10 +25,18 @@ using namespace BlackMisc::PhysicalQuantities; namespace BlackMiscTest { - CTestPropertyIndex::CTestPropertyIndex(QObject *parent): QObject(parent) + //! Testing property index access + class CTestPropertyIndex : public QObject { - // void - } + Q_OBJECT + + private slots: + //! Simulated aircraft index checks + void propertyIndexCSimulatedAircraft(); + + //! Sorting based on property index + void propertyIndexSort(); + }; void CTestPropertyIndex::propertyIndexCSimulatedAircraft() { @@ -109,4 +117,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestPropertyIndex); + +#include "testpropertyindex.moc" + //! \endcond diff --git a/tests/blackmisc/testpropertyindex/testpropertyindex.pro b/tests/blackmisc/testpropertyindex/testpropertyindex.pro new file mode 100644 index 000000000..32ef1fdce --- /dev/null +++ b/tests/blackmisc/testpropertyindex/testpropertyindex.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testpropertyindex +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testpropertyindex.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testslot.h b/tests/blackmisc/testslot.h deleted file mode 100644 index 8a4d41eb8..000000000 --- a/tests/blackmisc/testslot.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2016 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTSLOT_H -#define BLACKMISCTEST_TESTSLOT_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include - -namespace BlackMiscTest -{ - - //! CSlot tests - class CTestSlot : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestSlot(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Basic unit tests for CSlot - void slotBasics(); - }; - -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testslot.cpp b/tests/blackmisc/testslot/testslot.cpp similarity index 80% rename from tests/blackmisc/testslot.cpp rename to tests/blackmisc/testslot/testslot.cpp index d4b6dca12..9e3d85bad 100644 --- a/tests/blackmisc/testslot.cpp +++ b/tests/blackmisc/testslot/testslot.cpp @@ -8,14 +8,11 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testslot.h" #include "blackmisc/slot.h" +#include "test.h" #include @@ -23,6 +20,15 @@ using namespace BlackMisc; namespace BlackMiscTest { + //! CSlot tests + class CTestSlot : public QObject + { + Q_OBJECT + + private slots: + //! Basic unit tests for CSlot + void slotBasics(); + }; void CTestSlot::slotBasics() { @@ -40,4 +46,9 @@ namespace BlackMiscTest } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestSlot); + +#include "testslot.moc" + //! \endcond diff --git a/tests/blackmisc/testslot/testslot.pro b/tests/blackmisc/testslot/testslot.pro new file mode 100644 index 000000000..cdeff605e --- /dev/null +++ b/tests/blackmisc/testslot/testslot.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testslot +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testslot.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testmisc.cpp b/tests/blackmisc/teststatusmessage/teststatusmessage.cpp similarity index 78% rename from tests/blackmisc/testmisc.cpp rename to tests/blackmisc/teststatusmessage/teststatusmessage.cpp index 5d23c9ab5..437fde9ca 100644 --- a/tests/blackmisc/testmisc.cpp +++ b/tests/blackmisc/teststatusmessage/teststatusmessage.cpp @@ -11,20 +11,26 @@ //! \file //! \ingroup testblackmisc -#include "testmisc.h" #include "blackmisc/statusmessage.h" +#include "test.h" +#include #include using namespace BlackMisc; namespace BlackMiscTest { - CTestMisc::CTestMisc(QObject *parent): QObject(parent) + //! Testing property index access + class CTestStatusMessage : public QObject { - // void - } + Q_OBJECT - void CTestMisc::statusMessage() + private slots: + //! Status message + void statusMessage(); + }; + + void CTestStatusMessage::statusMessage() { CStatusMessage s1(CStatusMessage::SeverityDebug, "debug msg."); s1.setMSecsSinceEpoch(4000); @@ -44,4 +50,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestStatusMessage); + +#include "teststatusmessage.moc" + //! \endcond diff --git a/tests/blackmisc/teststatusmessage/teststatusmessage.pro b/tests/blackmisc/teststatusmessage/teststatusmessage.pro new file mode 100644 index 000000000..3aca5170c --- /dev/null +++ b/tests/blackmisc/teststatusmessage/teststatusmessage.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = teststatusmessage +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += teststatusmessage.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/teststringutils.h b/tests/blackmisc/teststringutils.h deleted file mode 100644 index 88e6045bc..000000000 --- a/tests/blackmisc/teststringutils.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2014 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTSTRINGUTILS_H -#define BLACKMISCTEST_TESTSTRINGUTILS_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include - -namespace BlackMiscTest -{ - //! Testing string utilities - class CTestStringUtils : public QObject - { - Q_OBJECT - - public: - //! Constructor - explicit CTestStringUtils(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - void testRemove(); - void testContains(); - void testIndexOf(); - void testSplit(); - void testTimestampParsing(); - }; -} - -//! \endcond - -#endif diff --git a/tests/blackmisc/teststringutils.cpp b/tests/blackmisc/teststringutils/teststringutils.cpp similarity index 92% rename from tests/blackmisc/teststringutils.cpp rename to tests/blackmisc/teststringutils/teststringutils.cpp index 37199b102..4debad27f 100644 --- a/tests/blackmisc/teststringutils.cpp +++ b/tests/blackmisc/teststringutils/teststringutils.cpp @@ -14,8 +14,8 @@ * \ingroup testblackmisc */ -#include "teststringutils.h" #include "blackmisc/stringutils.h" +#include "test.h" #include #include @@ -24,6 +24,18 @@ using namespace BlackMisc; namespace BlackMiscTest { + //! Testing string utilities + class CTestStringUtils : public QObject + { + Q_OBJECT + + private slots: + void testRemove(); + void testContains(); + void testIndexOf(); + void testSplit(); + void testTimestampParsing(); + }; void CTestStringUtils::testRemove() { @@ -129,4 +141,9 @@ namespace BlackMiscTest } } +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestStringUtils); + +#include "teststringutils.moc" + //! \endcond diff --git a/tests/blackmisc/teststringutils/teststringutils.pro b/tests/blackmisc/teststringutils/teststringutils.pro new file mode 100644 index 000000000..33affb0d2 --- /dev/null +++ b/tests/blackmisc/teststringutils/teststringutils.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = teststringutils +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += teststringutils.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testvaluecache.h b/tests/blackmisc/testvaluecache.h deleted file mode 100644 index b827d2cf3..000000000 --- a/tests/blackmisc/testvaluecache.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2015 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTVALUECACHE_H -#define BLACKMISCTEST_TESTVALUECACHE_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include "blackmisc/valuecache.h" - -#include -#include - -namespace BlackMiscTest -{ - - /*! - * Unit tests for value cache system. - */ - class CTestValueCache : public QObject - { - Q_OBJECT - - public: - //! Constructor. - explicit CTestValueCache(QObject *parent = nullptr); - - private slots: - //! Test insert and getAll functions of CValueCache. - void insertAndGet(); - - //! Test using CCached locally in one process. - void localOnly(); - - //! Test using CCached locally in one process, with multiple threads. - void localOnlyWithThreads(); - - //! Test using CCached distributed among two processes. - void distributed(); - - //! Test using batched changes. - void batched(); - - //! Test Json serialization. - void json(); - - //! Test saving to and loading from files. - void saveAndLoad(); - }; - - /*! - * Simple class which uses CCached, for testing. - */ - class CValueCacheUser : public QObject - { - Q_OBJECT - - public: - //! Constructor. - explicit CValueCacheUser(BlackMisc::CValueCache *cache); - - //! Slot to be called when a cached value changes. - void ps_valueChanged(); - - //! Detect whether the slot was called, for verification. - bool slotFired(); - - std::promise m_slotFired; //!< Flag marking whether the slot was called. - BlackMisc::CCached m_value1; //!< First cached value. - BlackMisc::CCached m_value2; //!< Second cached value. - }; - -} - -//! \endcond - -#endif diff --git a/tests/blackmisc/testvaluecache.cpp b/tests/blackmisc/testvaluecache/testvaluecache.cpp similarity index 85% rename from tests/blackmisc/testvaluecache.cpp rename to tests/blackmisc/testvaluecache/testvaluecache.cpp index 66b4814fd..3e417bd5a 100644 --- a/tests/blackmisc/testvaluecache.cpp +++ b/tests/blackmisc/testvaluecache/testvaluecache.cpp @@ -8,23 +8,22 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testvaluecache.h" +#include "blackmisc/valuecache.h" #include "blackmisc/aviation/atcstation.h" #include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/dictionary.h" #include "blackmisc/identifier.h" +#include "blackmisc/registermetadata.h" #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/statusmessage.h" #include "blackmisc/variant.h" #include "blackmisc/variantmap.h" #include "blackmisc/worker.h" +#include "test.h" #include #include @@ -51,9 +50,60 @@ namespace BlackMiscTest using namespace BlackMisc::Aviation; using namespace BlackMisc::Simulation; - CTestValueCache::CTestValueCache(QObject *parent) : QObject(parent) + //! Unit tests for value cache system. + class CTestValueCache : public QObject { - CVariant::registerMetadata(); + Q_OBJECT + + private slots: + //! Init test case data + void initTestCase(); + + //! Test insert and getAll functions of CValueCache. + void insertAndGet(); + + //! Test using CCached locally in one process. + void localOnly(); + + //! Test using CCached locally in one process, with multiple threads. + void localOnlyWithThreads(); + + //! Test using CCached distributed among two processes. + void distributed(); + + //! Test using batched changes. + void batched(); + + //! Test Json serialization. + void json(); + + //! Test saving to and loading from files. + void saveAndLoad(); + }; + + //! Simple class which uses CCached, for testing. + class CValueCacheUser : public QObject + { + Q_OBJECT + + public: + //! Constructor. + explicit CValueCacheUser(BlackMisc::CValueCache *cache); + + //! Slot to be called when a cached value changes. + void ps_valueChanged(); + + //! Detect whether the slot was called, for verification. + bool slotFired(); + + std::promise m_slotFired; //!< Flag marking whether the slot was called. + BlackMisc::CCached m_value1; //!< First cached value. + BlackMisc::CCached m_value2; //!< Second cached value. + }; + + void CTestValueCache::initTestCase() + { + BlackMisc::registerMetadata(); } void CTestValueCache::insertAndGet() @@ -298,4 +348,9 @@ namespace BlackMiscTest } } // ns +//! main +BLACKTEST_MAIN(BlackMiscTest::CTestValueCache); + +#include "testvaluecache.moc" + //! \endcond diff --git a/tests/blackmisc/testvaluecache/testvaluecache.pro b/tests/blackmisc/testvaluecache/testvaluecache.pro new file mode 100644 index 000000000..b27a51582 --- /dev/null +++ b/tests/blackmisc/testvaluecache/testvaluecache.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testvaluecache +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testvaluecache.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testvalueobject.cpp b/tests/blackmisc/testvalueobject.cpp deleted file mode 100644 index 7656f1f9d..000000000 --- a/tests/blackmisc/testvalueobject.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testvalueobject.h" - -namespace BlackMisc -{ - /* - * Convert to string - */ - QString CTestValueObject::convertToQString(bool /*i18n*/) const - { - QString s(this->m_name); - s.append(" ").append(this->m_description); - return s; - } - - /* - * Property by index - */ - CVariant CTestValueObject::propertyByIndex(const BlackMisc::CPropertyIndex &index) const - { - if (index.isMyself()) { return CVariant::from(*this); } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexDescription: - return CVariant::fromValue(this->m_description); - case IndexName: - return CVariant::fromValue(this->m_name); - default: - return CValueObject::propertyByIndex(index); - } - } - - /* - * Property by index (setter) - */ - void CTestValueObject::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant) - { - if (index.isMyself()) { (*this) = variant.to(); return; } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexDescription: - this->setDescription(variant.value()); - break; - case IndexName: - this->setName(variant.value()); - break; - default: - CValueObject::setPropertyByIndex(index, variant); - break; - } - } - -} // namespace - -//! \endcond diff --git a/tests/blackmisc/testvalueobject.h b/tests/blackmisc/testvalueobject.h index fd60a0602..072ae33de 100644 --- a/tests/blackmisc/testvalueobject.h +++ b/tests/blackmisc/testvalueobject.h @@ -11,11 +11,9 @@ #define BLACKMISC_TESTVALUEOBJECT_H //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ #include "blackmisc/collection.h" #include "blackmisc/dictionary.h" #include "blackmisc/metaclass.h" @@ -67,13 +65,48 @@ namespace BlackMisc void setDescription(const QString &description) { m_description = description; } //! \copydoc BlackMisc::Mixin::Index::propertyByIndex - CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; + CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const + { + if (index.isMyself()) { return CVariant::from(*this); } + ColumnIndex i = index.frontCasted(); + switch (i) + { + case IndexDescription: + return CVariant::fromValue(this->m_description); + case IndexName: + return CVariant::fromValue(this->m_name); + default: + return CValueObject::propertyByIndex(index); + } + } //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex - void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant); + void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant) + { + if (index.isMyself()) { (*this) = variant.to(); return; } + ColumnIndex i = index.frontCasted(); + switch (i) + { + case IndexDescription: + this->setDescription(variant.value()); + break; + case IndexName: + this->setName(variant.value()); + break; + default: + CValueObject::setPropertyByIndex(index, variant); + break; + } + } //! \copydoc BlackMisc::Mixin::String::toQString() - QString convertToQString(bool i18n = false) const; + QString convertToQString(bool i18n = false) const + { + Q_UNUSED(i18n); + QString s(this->m_name); + s.append(" ").append(this->m_description); + return s; + } private: QString m_name; diff --git a/tests/blackmisc/testvariantandmap.h b/tests/blackmisc/testvariantandmap.h deleted file mode 100644 index f3d7b8c39..000000000 --- a/tests/blackmisc/testvariantandmap.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2013 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTVARIANTANDMAP_H -#define BLACKMISCTEST_TESTVARIANTANDMAP_H - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include - -namespace BlackMiscTest -{ - //! Variant and map related tests - class CTestVariantAndMap : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestVariantAndMap(QObject *parent = nullptr) : QObject(parent) {} - - private slots: - //! Basic unit tests for value objects and variants - void variant(); - - //! Unit tests for value maps and value objects - void valueMap(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testvariantandmap.cpp b/tests/blackmisc/testvariantandmap/testvariantandmap.cpp similarity index 90% rename from tests/blackmisc/testvariantandmap.cpp rename to tests/blackmisc/testvariantandmap/testvariantandmap.cpp index 40d64932b..d7589438b 100644 --- a/tests/blackmisc/testvariantandmap.cpp +++ b/tests/blackmisc/testvariantandmap/testvariantandmap.cpp @@ -14,7 +14,6 @@ * \ingroup testblackmisc */ -#include "testvariantandmap.h" #include "blackmisc/aviation/atcstation.h" #include "blackmisc/aviation/callsign.h" #include "blackmisc/compare.h" @@ -25,7 +24,9 @@ #include "blackmisc/pq/physicalquantity.h" #include "blackmisc/pq/units.h" #include "blackmisc/propertyindexvariantmap.h" +#include "blackmisc/registermetadata.h" #include "blackmisc/variant.h" +#include "test.h" #include #include @@ -38,6 +39,27 @@ using namespace BlackMisc::Network; namespace BlackMiscTest { + //! Variant and map related tests + class CTestVariantAndMap : public QObject + { + Q_OBJECT + + private slots: + //! Init test case data + void initTestCase(); + + //! Basic unit tests for value objects and variants + void variant(); + + //! Unit tests for value maps and value objects + void valueMap(); + }; + + void CTestVariantAndMap::initTestCase() + { + BlackMisc::registerMetadata(); + } + void CTestVariantAndMap::variant() { // ATC station @@ -124,4 +146,9 @@ namespace BlackMiscTest } } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestVariantAndMap); + +#include "testvariantandmap.moc" + //! \endcond diff --git a/tests/blackmisc/testvariantandmap/testvariantandmap.pro b/tests/blackmisc/testvariantandmap/testvariantandmap.pro new file mode 100644 index 000000000..fd960f98f --- /dev/null +++ b/tests/blackmisc/testvariantandmap/testvariantandmap.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testvariantandmap +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testvariantandmap.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/testweather.h b/tests/blackmisc/testweather.h deleted file mode 100644 index 2b8f1340d..000000000 --- a/tests/blackmisc/testweather.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2015 - * swift Project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#ifndef BLACKMISCTEST_TESTWEATHER_H -#define BLACKMISCTEST_TESTWEATHER_H - -//! \cond PRIVATE_TESTS - -/*! - * \file - * \ingroup testblackmisc - */ - -#include - -namespace BlackMiscTest -{ - //! Aviation classes basic tests - class CTestWeather : public QObject - { - Q_OBJECT - - public: - //! Standard test case constructor - explicit CTestWeather(QObject *parent = nullptr); - - private slots: - //! Testing CCloudLayer/CCloudLayerList - void cloudLayer(); - - //! Testing CTemperatureLayer/CTemperatureLayerList - void temperatureLayer(); - - //! Testing CVisibilityLayer/CVisibilityLayerList - void visibilityLayer(); - - //! Testing CWindLayer/CWindLayerList - void windLayer(); - - //! Testing METAR decoder - void metarDecoder(); - }; -} // namespace - -//! \endcond - -#endif // guard diff --git a/tests/blackmisc/testweather.cpp b/tests/blackmisc/weather/testweather/testweather.cpp similarity index 92% rename from tests/blackmisc/testweather.cpp rename to tests/blackmisc/weather/testweather/testweather.cpp index edadb313f..69eb55881 100644 --- a/tests/blackmisc/testweather.cpp +++ b/tests/blackmisc/weather/testweather/testweather.cpp @@ -8,13 +8,9 @@ */ //! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc -/*! - * \file - * \ingroup testblackmisc - */ - -#include "testweather.h" #include "blackmisc/aviation/airporticaocode.h" #include "blackmisc/aviation/altitude.h" #include "blackmisc/compare.h" @@ -38,6 +34,7 @@ #include "blackmisc/weather/visibilitylayerlist.h" #include "blackmisc/weather/windlayer.h" #include "blackmisc/weather/windlayerlist.h" +#include "test.h" #include @@ -47,14 +44,27 @@ using namespace BlackMisc::PhysicalQuantities; namespace BlackMiscTest { - - /* - * Constructor - */ - CTestWeather::CTestWeather(QObject *parent): QObject(parent) + //! Weather unit tests + class CTestWeather : public QObject { - // void - } + Q_OBJECT + + private slots: + //! Testing CCloudLayer/CCloudLayerList + void cloudLayer(); + + //! Testing CTemperatureLayer/CTemperatureLayerList + void temperatureLayer(); + + //! Testing CVisibilityLayer/CVisibilityLayerList + void visibilityLayer(); + + //! Testing CWindLayer/CWindLayerList + void windLayer(); + + //! Testing METAR decoder + void metarDecoder(); + }; void CTestWeather::cloudLayer() { @@ -64,7 +74,7 @@ namespace BlackMiscTest CCloudLayer cl1 (base1, top1, CCloudLayer::Scattered); QVERIFY(cl1.getBase() == base1); QVERIFY(cl1.getTop() == top1); - QVERIFY(cl1.getPrecipitationRate() == 0); + QCOMPARE(cl1.getPrecipitationRate(), 0.0); QVERIFY(cl1.getPrecipitation() == CCloudLayer::NoPrecipitation); QVERIFY(cl1.getClouds() == CCloudLayer::NoClouds); QVERIFY(cl1.getCoverage() == CCloudLayer::Scattered); @@ -75,7 +85,7 @@ namespace BlackMiscTest CCloudLayer cl2 { base2, top2, 5, CCloudLayer::Rain, CCloudLayer::Cirrus, CCloudLayer::Scattered }; QVERIFY(cl2.getBase() == base2); QVERIFY(cl2.getTop() == top2); - QVERIFY(cl2.getPrecipitationRate() == 5); + QCOMPARE(cl2.getPrecipitationRate(), 5.0); QVERIFY(cl2.getPrecipitation() == CCloudLayer::Rain); QVERIFY(cl2.getClouds() == CCloudLayer::Cirrus); QVERIFY(cl2.getCoverage() == CCloudLayer::Scattered); @@ -95,13 +105,13 @@ namespace BlackMiscTest const CAltitude level1 { 0, CAltitude::AboveGround, CLengthUnit::ft() }; const CTemperature temp1 { 25, CTemperatureUnit::C() }; const CTemperature dp1 { 15, CTemperatureUnit::C() }; - const int rh = 80; + const double rh = 80.0; CTemperatureLayer tl1 (level1, temp1, dp1, rh); QVERIFY(tl1.getLevel() == level1); QVERIFY(tl1.getTemperature() == temp1); QVERIFY(tl1.getDewPoint() == dp1); - QVERIFY(tl1.getRelativeHumidity() == rh); + QCOMPARE(tl1.getRelativeHumidity(), rh); CAltitude level2 { 25000, CAltitude::AboveGround, CLengthUnit::ft() }; CTemperatureLayerList tll { tl1 }; @@ -208,4 +218,9 @@ namespace BlackMiscTest } // namespace +//! main +BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestWeather); + +#include "testweather.moc" + //! \endcond diff --git a/tests/blackmisc/weather/testweather/testweather.pro b/tests/blackmisc/weather/testweather/testweather.pro new file mode 100644 index 000000000..5a66a2503 --- /dev/null +++ b/tests/blackmisc/weather/testweather/testweather.pro @@ -0,0 +1,27 @@ +load(common_pre) + +QT += core dbus testlib + +TARGET = testweather +CONFIG -= app_bundle +CONFIG += blackconfig +CONFIG += blackmisc +CONFIG += testcase +CONFIG += no_testcase_installs + +TEMPLATE = app + +DEPENDPATH += \ + . \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +INCLUDEPATH += \ + $$SourceRoot/src \ + $$SourceRoot/tests \ + +SOURCES += testweather.cpp + +DESTDIR = $$DestRoot/bin + +load(common_post) diff --git a/tests/blackmisc/weather/weather.pro b/tests/blackmisc/weather/weather.pro new file mode 100644 index 000000000..e1c2e0684 --- /dev/null +++ b/tests/blackmisc/weather/weather.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += \ + testweather \ diff --git a/tests/test.h b/tests/test.h new file mode 100644 index 000000000..fe72a22c4 --- /dev/null +++ b/tests/test.h @@ -0,0 +1,70 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKMISCTEST_TEST_H +#define BLACKMISCTEST_TEST_H + +//! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackmisc + +#include +#include +#include + +//! Implements a main() function that executes all tests in TestObject +//! without instantiating a QApplication object. +//! Also adds arguments automatically to print test results to an xml file. +#define BLACKTEST_INIT(TestObject) \ +TestObject to; \ +QTEST_SET_MAIN_SOURCE_PATH \ +\ +QStringList args; \ +args.reserve(argc); \ +for (int i = 0; i < argc; ++i) \ +{ \ + args.append(argv[i]); \ +} \ +\ +/* Output to stdout */ \ +args.append({ "-o", "-,txt" }); \ +\ +/* Be silent */ \ +args.append("-silent"); \ +\ +/* Output to file */ \ +QString resultsFileName = QString(#TestObject).replace("::", "_").toLower(); \ +args.append({ "-o", resultsFileName + "_testresults.xml,xml" }); \ + + +//! Implements a main() function that executes all tests in TestObject +//! without instantiating a QApplication object. +//! Also adds arguments automatically to print test results to an xml file. +#define BLACKTEST_APPLESS_MAIN(TestObject) \ +int main(int argc, char *argv[]) \ +{ \ + BLACKTEST_INIT(TestObject) \ + return QTest::qExec(&to, args); \ +} + +//! Implements a main() function that executes all tests in TestObject +//! including instantiating a QCoreApplication object. +//! Also adds arguments automatically to print test results to an xml file. +#define BLACKTEST_MAIN(TestObject) \ +int main(int argc, char *argv[]) \ +{ \ + QCoreApplication app(argc, argv); \ + BLACKTEST_INIT(TestObject) \ + return QTest::qExec(&to, args); \ +} + + +//! \endcond + +#endif // guard diff --git a/tests/tests.pro b/tests/tests.pro index 1bca3bf2d..e91117ead 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,19 +1,15 @@ -load(common_pre) - TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += testblackmisc -SUBDIRS += testblackcore -SUBDIRS += testblackgui +SUBDIRS += blackmisc +SUBDIRS += blackcore +SUBDIRS += blackgui -testblackmisc.file = blackmisc/testblackmisc.pro -testblackcore.file = blackcore/testblackcore.pro -testblackgui.file = blackgui/testblackgui.pro +# testblackmisc.file = blackmisc/testblackmisc.pro +# testblackcore.file = blackcore/testblackcore.pro +# testblackgui.file = blackgui/testblackgui.pro contains(BLACK_CONFIG,FSX|P3D) { SUBDIRS += testsimpluginfsxp3d testsimpluginfsxp3d.file = blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro } - -load(common_post)