diff --git a/src/blackcore/blackcore.pro b/src/blackcore/blackcore.pro index b5c253b3e..9efabce67 100644 --- a/src/blackcore/blackcore.pro +++ b/src/blackcore/blackcore.pro @@ -28,14 +28,12 @@ HEADERS += $$PWD/audio/*.h HEADERS += $$PWD/context/*.h HEADERS += $$PWD/data/*.h HEADERS += $$PWD/db/*.h -HEADERS += $$PWD/test/*.h HEADERS += $$PWD/vatsim/*.h SOURCES += *.cpp SOURCES += $$PWD/context/*.cpp SOURCES += $$PWD/data/*.cpp SOURCES += $$PWD/db/*.cpp -SOURCES += $$PWD/test/*.cpp SOURCES += $$PWD/vatsim/*.cpp LIBS *= -lvatlib diff --git a/src/blackcore/test/testserviceinterface.h b/src/blackcore/test/testserviceinterface.h deleted file mode 100644 index 419f53a6d..000000000 --- a/src/blackcore/test/testserviceinterface.h +++ /dev/null @@ -1,405 +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. - */ - -//! \file - -#ifndef BLACKCORE_TEST_TESTSERVICEINTERFACE_H -#define BLACKCORE_TEST_TESTSERVICEINTERFACE_H - -#include "blackcore/blackcoreexport.h" -#include "blackmisc/aviation/aircrafticaocode.h" -#include "blackmisc/aviation/aircraftsituation.h" -#include "blackmisc/aviation/airportlist.h" -#include "blackmisc/aviation/altitude.h" -#include "blackmisc/aviation/atcstation.h" -#include "blackmisc/aviation/atcstationlist.h" -#include "blackmisc/aviation/callsign.h" -#include "blackmisc/aviation/comsystem.h" -#include "blackmisc/aviation/track.h" -#include "blackmisc/aviation/transponder.h" -#include "blackmisc/geo/coordinategeodetic.h" -#include "blackmisc/network/client.h" -#include "blackmisc/network/clientlist.h" -#include "blackmisc/network/user.h" -#include "blackmisc/pq/length.h" -#include "blackmisc/pq/speed.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/propertyindexvariantmap.h" -#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h" -#include "blackmisc/simulation/simulatedaircraft.h" -#include "blackmisc/simulation/simulatedaircraftlist.h" -#include "blackmisc/simulation/simulatorplugininfo.h" -#include "blackmisc/variantlist.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class QDBusConnection; -class QDBusObjectPath; -class QDBusVariant; - -namespace BlackMisc -{ - class CVariant; - namespace Simulation { namespace FsCommon { class CAircraftCfgEntriesList; } } -} - -namespace BlackCore -{ - namespace Test - { - //! Proxy class for BlackCore::Test::TestService. This part is the caller. - class BLACKCORE_EXPORT ITestServiceInterface: public QDBusAbstractInterface - { - Q_OBJECT - - public: - //! Constructor - ITestServiceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); - - //! Destructor - virtual ~ITestServiceInterface(); - - //! Ping via DBus, tests object marshalling/unmarshalling - static int pingTests(ITestServiceInterface &testServiceInterface, bool verbose); - - //! DBus calls - //! @{ - inline QDBusPendingReply getAtcStation() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("getAtcStation"), argumentList); - } - - inline QDBusPendingReply getAircraftCfgEntriesList(int number) - { - QList argumentList; - argumentList << QVariant::fromValue(number); - return asyncCallWithArgumentList(QLatin1String("getAircraftCfgEntriesList"), argumentList); - } - - inline QDBusPendingReply getAtcStationList(int number) - { - QList argumentList; - argumentList << QVariant::fromValue(number); - return asyncCallWithArgumentList(QLatin1String("getAtcStationList"), argumentList); - } - - inline QDBusPendingReply> getObjectPaths(int number) - { - QList argumentList; - argumentList << QVariant::fromValue(number); - return asyncCallWithArgumentList(QLatin1String("getObjectPaths"), argumentList); - } - - inline QDBusPendingReply getSpeed() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("getSpeed"), argumentList); - } - - inline QDBusPendingReply pingAltitude(const BlackMisc::Aviation::CAltitude &altitude) - { - QList argumentList; - argumentList << QVariant::fromValue(altitude); - return asyncCallWithArgumentList(QLatin1String("pingAltitude"), argumentList); - } - - inline QDBusPendingReply pingSituation(const BlackMisc::Aviation::CAircraftSituation &situation) - { - QList argumentList; - argumentList << QVariant::fromValue(situation); - return asyncCallWithArgumentList(QLatin1String("pingSituation"), argumentList); - } - - inline QDBusPendingReply pingUser(const BlackMisc::Network::CUser &user) - { - QList argumentList; - argumentList << QVariant::fromValue(user); - return asyncCallWithArgumentList(QLatin1String("pingUser"), argumentList); - } - - inline QDBusPendingReply pingTransponder(const BlackMisc::Aviation::CTransponder &transponder) - { - QList argumentList; - argumentList << QVariant::fromValue(transponder); - return asyncCallWithArgumentList(QLatin1String("pingTransponder"), argumentList); - } - - inline QDBusPendingReply pingAtcStation(const BlackMisc::Aviation::CAtcStation &station) - { - QList argumentList; - argumentList << QVariant::fromValue(station); - return asyncCallWithArgumentList(QLatin1String("pingAtcStation"), argumentList); - } - - inline QDBusPendingReply pingAircraftIcaoData(const BlackMisc::Aviation::CAircraftIcaoCode &icaoData) - { - QList argumentList; - argumentList << QVariant::fromValue(icaoData); - return asyncCallWithArgumentList(QLatin1String("pingAircraftIcaoData"), argumentList); - } - - inline QDBusPendingReply pingAircraftLights(const BlackMisc::Aviation::CAircraftLights &lights) - { - QList argumentList; - argumentList << QVariant::fromValue(lights); - return asyncCallWithArgumentList(QLatin1String("pingAircraftLights"), argumentList); - } - - inline QDBusPendingReply pingAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts) - { - QList argumentList; - argumentList << QVariant::fromValue(parts); - return asyncCallWithArgumentList(QLatin1String("pingAircraftParts"), argumentList); - } - - inline QDBusPendingReply pingAircraftEngine(const BlackMisc::Aviation::CAircraftEngine &engine) - { - QList argumentList; - argumentList << QVariant::fromValue(engine); - return asyncCallWithArgumentList(QLatin1String("pingAircraftEngine"), argumentList); - } - - inline QDBusPendingReply pingAircraftModel(const BlackMisc::Simulation::CAircraftModel &model) - { - QList argumentList; - argumentList << QVariant::fromValue(model); - return asyncCallWithArgumentList(QLatin1String("pingAircraftModel"), argumentList); - } - - inline QDBusPendingReply pingAircraftModelList(const BlackMisc::Simulation::CAircraftModelList &model) - { - QList argumentList; - argumentList << QVariant::fromValue(model); - return asyncCallWithArgumentList(QLatin1String("pingAircraftModelList"), argumentList); - } - - inline QDBusPendingReply pingSimulatedAircraft(BlackMisc::Simulation::CSimulatedAircraft aircraft) - { - QList argumentList; - argumentList << QVariant::fromValue(aircraft); - return asyncCallWithArgumentList(QLatin1String("pingSimulatedAircraft"), argumentList); - } - - inline QDBusPendingReply pingPluginInfo(BlackMisc::Simulation::CSimulatorPluginInfo info) - { - QList argumentList; - argumentList << QVariant::fromValue(info); - return asyncCallWithArgumentList(QLatin1String("pingPluginInfo"), argumentList); - } - - inline QDBusPendingReply pingAtcStationList(BlackMisc::Aviation::CAtcStationList atcStationList) - { - QList argumentList; - argumentList << QVariant::fromValue(atcStationList); - return asyncCallWithArgumentList(QLatin1String("pingAtcStationList"), argumentList); - } - - inline QDBusPendingReply pingSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed) - { - QList argumentList; - argumentList << QVariant::fromValue(speed); - return asyncCallWithArgumentList(QLatin1String("pingSpeed"), argumentList); - } - - inline QDBusPendingReply pingAircraftList(const BlackMisc::Simulation::CSimulatedAircraftList &aircraftList) - { - QList argumentList; - argumentList << QVariant::fromValue(aircraftList); - return asyncCallWithArgumentList(QLatin1String("pingAircraftList"), argumentList); - } - - inline QDBusPendingReply pingAirportList(const BlackMisc::Aviation::CAirportList &airportList) - { - QList argumentList; - argumentList << QVariant::fromValue(airportList); - return asyncCallWithArgumentList(QLatin1String("pingAirportList"), argumentList); - } - - inline QDBusPendingReply pingClientList(const BlackMisc::Network::CClientList &clientList) - { - QList argumentList; - argumentList << QVariant::fromValue(clientList); - return asyncCallWithArgumentList(QLatin1String("pingClientList"), argumentList); - } - - inline QDBusPendingReply pingClient(const BlackMisc::Network::CClient &client) - { - QList argumentList; - argumentList << QVariant::fromValue(client); - return asyncCallWithArgumentList(QLatin1String("pingClient"), argumentList); - } - - inline QDBusPendingReply pingCVariant(const BlackMisc::CVariant &variant) - { - QList argumentList; - argumentList << QVariant::fromValue(variant); - return asyncCallWithArgumentList(QLatin1String("pingCVariant"), argumentList); - } - - inline QDBusPendingReply pingPropertyIndex(const BlackMisc::CPropertyIndex &index) - { - QList argumentList; - argumentList << QVariant::fromValue(index); - return asyncCallWithArgumentList(QLatin1String("pingPropertyIndex"), argumentList); - } - - inline QDBusPendingReply pingIndexVariantMap(BlackMisc::CPropertyIndexVariantMap indexVariantMap) - { - QList argumentList; - argumentList << QVariant::fromValue(indexVariantMap); - return asyncCallWithArgumentList(QLatin1String("pingIndexVariantMap"), argumentList); - } - - inline QDBusPendingReply receiveAltitude(const BlackMisc::Aviation::CAltitude &altitude) - { - QList argumentList; - argumentList << QVariant::fromValue(altitude); - return asyncCallWithArgumentList(QLatin1String("receiveAltitude"), argumentList); - } - - inline QDBusPendingReply<> receiveAtcStation(const BlackMisc::Aviation::CAtcStation &station) - { - QList argumentList; - argumentList << QVariant::fromValue(station); - return asyncCallWithArgumentList(QLatin1String("receiveAtcStation"), argumentList); - } - - inline QDBusPendingReply<> receiveAtcStationList(const BlackMisc::Aviation::CAtcStationList &atcStationList) - { - QList argumentList; - argumentList << QVariant::fromValue(atcStationList); - return asyncCallWithArgumentList(QLatin1String("receiveAtcStationList"), argumentList); - } - - inline QDBusPendingReply<> receiveCallsign(const BlackMisc::Aviation::CCallsign &callsign) - { - QList argumentList; - argumentList << QVariant::fromValue(callsign); - return asyncCallWithArgumentList(QLatin1String("receiveCallsign"), argumentList); - } - - inline QDBusPendingReply<> receiveComUnit(const BlackMisc::Aviation::CComSystem &comUnit) - { - QList argumentList; - argumentList << QVariant::fromValue(comUnit); - return asyncCallWithArgumentList(QLatin1String("receiveComUnit"), argumentList); - } - - inline QDBusPendingReply<> receiveGeoPosition(const BlackMisc::Geo::CCoordinateGeodetic &geo) - { - QList argumentList; - argumentList << QVariant::fromValue(geo); - return asyncCallWithArgumentList(QLatin1String("receiveGeoPosition"), argumentList); - } - - inline QDBusPendingReply<> receiveLength(const BlackMisc::PhysicalQuantities::CLength &length) - { - QList argumentList; - argumentList << QVariant::fromValue(length); - return asyncCallWithArgumentList(QLatin1String("receiveLength"), argumentList); - } - - inline QDBusPendingReply<> receiveLengthsQl(const BlackMisc::CVariantList &lengthsList) - { - QList argumentList; - argumentList << QVariant::fromValue(lengthsList); - return asyncCallWithArgumentList(QLatin1String("receiveLengthsQl"), argumentList); - } - - inline QDBusPendingReply<> receiveLengthsQvl(const BlackMisc::CVariantList &lengthsVariantList) - { - QList argumentList; - argumentList << QVariant::fromValue(lengthsVariantList); - return asyncCallWithArgumentList(QLatin1String("receiveLengthsQvl"), argumentList); - } - - inline QDBusPendingReply<> receiveList(const QList &list) - { - QList argumentList; - argumentList << QVariant::fromValue(list); - return asyncCallWithArgumentList(QLatin1String("receiveList"), argumentList); - } - - inline QDBusPendingReply<> receiveSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed) - { - QList argumentList; - argumentList << QVariant::fromValue(speed); - return asyncCallWithArgumentList(QLatin1String("receiveSpeed"), argumentList); - } - - inline QDBusPendingReply<> receiveStringMessage(const QString &message) - { - QList argumentList; - argumentList << QVariant::fromValue(message); - return asyncCallWithArgumentList(QLatin1String("receiveStringMessage"), argumentList); - } - - inline QDBusPendingReply<> receiveTrack(BlackMisc::Aviation::CTrack track) - { - QList argumentList; - argumentList << QVariant::fromValue(track); - return asyncCallWithArgumentList(QLatin1String("receiveTrack"), argumentList); - } - - inline QDBusPendingReply<> receiveTransponder(const BlackMisc::Aviation::CTransponder &transponder) - { - QList argumentList; - argumentList << QVariant::fromValue(transponder); - return asyncCallWithArgumentList(QLatin1String("receiveTransponder"), argumentList); - } - - inline QDBusPendingReply<> receiveValueMap(const BlackMisc::CPropertyIndexVariantMap &valueMap) - { - QList argumentList; - argumentList << QVariant::fromValue(valueMap); - return asyncCallWithArgumentList(QLatin1String("receiveValueMap"), argumentList); - } - - inline QDBusPendingReply<> receiveVariant(const QDBusVariant &variant, int localMetyType) - { - QList argumentList; - argumentList << QVariant::fromValue(variant) << QVariant::fromValue(localMetyType); - return asyncCallWithArgumentList(QLatin1String("receiveVariant"), argumentList); - } - //! @} - - signals: - //! send message - void sendStringMessage(const QString &message); - - private: - //! Interface name - static const char *InterfaceName(); - - //! Compare objects and output info - template - static bool pingCompare(const ValueObject &in, const ValueObject &out, QTextStream &ts, bool verbose, int &errors) - { - const bool equal = (in == out); - if (!equal) { errors++; } - if (equal && !verbose) { return true; } - ts << "I: " << in.toQString() << endl << "O: " << out.toQString() << endl; - return equal; - } - - //! Error info string - static const QString &errorInfo(bool ok); - }; - } // ns -} // ns -#endif diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index b0c78c06a..473562ac4 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -40,6 +40,7 @@ HEADERS += *.h \ $$PWD/simulation/fscommon/*.h \ $$PWD/simulation/fsx/*.h \ $$PWD/simulation/xplane/*.h \ + $$PWD/test/*.h \ $$PWD/weather/*.h SOURCES += *.cpp \ @@ -56,6 +57,7 @@ SOURCES += *.cpp \ $$PWD/simulation/fscommon/*.cpp \ $$PWD/simulation/fsx/*.cpp \ $$PWD/simulation/xplane/*.cpp \ + $$PWD/test/*.cpp \ $$PWD/weather/*.cpp win32 { diff --git a/src/blackcore/test/testservice.cpp b/src/blackmisc/test/testservice.cpp similarity index 98% rename from src/blackcore/test/testservice.cpp rename to src/blackmisc/test/testservice.cpp index 888940278..8c324e83c 100644 --- a/src/blackcore/test/testservice.cpp +++ b/src/blackmisc/test/testservice.cpp @@ -33,7 +33,7 @@ using namespace BlackMisc::Geo; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Network; -namespace BlackCore +namespace BlackMisc { namespace Test { @@ -56,7 +56,7 @@ namespace BlackCore const QString &CTestService::InterfaceName() { - static const QString i(BLACKSAMPLE_TESTSERVICE_INTERFACENAME); + static const QString i(BLACKMISC_TESTSERVICE_INTERFACENAME); return i; } @@ -90,7 +90,7 @@ namespace BlackCore if (connection.connect(service, CTestService::ObjectPath(), CTestService::InterfaceName(), "sendStringMessage", pTestService, SLOT(receiveStringMessage(const QString &)))) { - out() << "Connected object with bus sendStringMessage" << endl; + out() << "Connected object with DBus 'sendStringMessage'" << endl; } else { @@ -99,7 +99,7 @@ namespace BlackCore return pTestService; } - bool CTestService::unRegisterTestService(QDBusConnection &connection) + bool CTestService::unregisterTestService(QDBusConnection &connection) { return connection.unregisterService(CTestService::InterfaceName()); } diff --git a/src/blackcore/test/testservice.h b/src/blackmisc/test/testservice.h similarity index 94% rename from src/blackcore/test/testservice.h rename to src/blackmisc/test/testservice.h index ab943a6bd..6917db895 100644 --- a/src/blackcore/test/testservice.h +++ b/src/blackmisc/test/testservice.h @@ -9,14 +9,13 @@ //! \file -#ifndef BLACKCORE_TEST_TESTSERVICE_H -#define BLACKCORE_TEST_TESTSERVICE_H +#ifndef BLACKMISC_TEST_TESTSERVICE_H +#define BLACKMISC_TEST_TESTSERVICE_H // clash with struct interface in objbase.h used to happen #pragma push_macro("interface") #undef interface -#include "blackcore/blackcoreexport.h" #include "blackmisc/aviation/aircrafticaocode.h" #include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/airportlist.h" @@ -37,6 +36,7 @@ #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/variant.h" +#include "blackmisc/blackmiscexport.h" #include #include @@ -60,18 +60,18 @@ namespace BlackMisc } //! DBus interface for test service -#define BLACKSAMPLE_TESTSERVICE_INTERFACENAME "blackcore.test" +#define BLACKMISC_TESTSERVICE_INTERFACENAME "blackmisc.test" -namespace BlackCore +namespace BlackMisc { namespace Test { //! Testservice for PQ / CValueObject DBus tests. This part is the callee. - //! \remark corresponds with BlackCore::Test::TestServiceInterface - class BLACKCORE_EXPORT CTestService : public QObject + //! \remark corresponds with BlackMisc::Test::ITestServiceInterface + class BLACKMISC_EXPORT CTestService : public QObject { Q_OBJECT - Q_CLASSINFO("D-Bus Interface", BLACKSAMPLE_TESTSERVICE_INTERFACENAME) + Q_CLASSINFO("D-Bus Interface", BLACKMISC_TESTSERVICE_INTERFACENAME) // For some reasons the interface name in the XML is not set correctly // to the above name @@ -90,7 +90,7 @@ namespace BlackCore static CTestService *registerTestService(QDBusConnection &connection, bool verbose, QObject *parent = nullptr); //! Can the testservice be registered? - static bool unRegisterTestService(QDBusConnection &connection); + static bool unregisterTestService(QDBusConnection &connection); //! Process id static qint64 getPid() { return QCoreApplication::applicationPid(); } diff --git a/src/blackcore/test/testserviceinterface.cpp b/src/blackmisc/test/testserviceinterface.cpp similarity index 98% rename from src/blackcore/test/testserviceinterface.cpp rename to src/blackmisc/test/testserviceinterface.cpp index 53c927f9a..182b89a0d 100644 --- a/src/blackcore/test/testserviceinterface.cpp +++ b/src/blackmisc/test/testserviceinterface.cpp @@ -10,6 +10,7 @@ #include "testserviceinterface.h" #include "testservice.h" #include "testutils.h" +#include "blackmisc/test/testdata.h" #include class QDBusConnection; @@ -19,9 +20,10 @@ using namespace BlackMisc::Aviation; using namespace BlackMisc::Simulation; using namespace BlackMisc::Geo; using namespace BlackMisc::Network; +using namespace BlackMisc::Test; using namespace BlackMisc::PhysicalQuantities; -namespace BlackCore +namespace BlackMisc { namespace Test { @@ -67,7 +69,7 @@ namespace BlackCore ok = pingCompare(speedNull, speedNullPing, out, verbose, errors); if (verbose) { out << "Pinged null speed via interface" << errorInfo(ok) << endl; } - const CAtcStation station = CTestUtils::getAtcStation(); + const CAtcStation station = CTestData::getAtcStation(); const CAtcStation stationPing = testServiceInterface.pingAtcStation(station); ok = pingCompare(station, stationPing, out, verbose, errors); if (verbose) { out << "Pinged ATC station via interface" << errorInfo(ok) << endl; } diff --git a/src/blackmisc/test/testserviceinterface.h b/src/blackmisc/test/testserviceinterface.h new file mode 100644 index 000000000..7f8bad860 --- /dev/null +++ b/src/blackmisc/test/testserviceinterface.h @@ -0,0 +1,405 @@ +/* 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. + */ + +//! \file + +#ifndef BLACKMISC_TEST_TESTSERVICEINTERFACE_H +#define BLACKMISC_TEST_TESTSERVICEINTERFACE_H + +#include "blackmisc/blackmiscexport.h" +#include "blackmisc/aviation/aircrafticaocode.h" +#include "blackmisc/aviation/aircraftsituation.h" +#include "blackmisc/aviation/airportlist.h" +#include "blackmisc/aviation/altitude.h" +#include "blackmisc/aviation/atcstation.h" +#include "blackmisc/aviation/atcstationlist.h" +#include "blackmisc/aviation/callsign.h" +#include "blackmisc/aviation/comsystem.h" +#include "blackmisc/aviation/track.h" +#include "blackmisc/aviation/transponder.h" +#include "blackmisc/geo/coordinategeodetic.h" +#include "blackmisc/network/client.h" +#include "blackmisc/network/clientlist.h" +#include "blackmisc/network/user.h" +#include "blackmisc/pq/length.h" +#include "blackmisc/pq/speed.h" +#include "blackmisc/propertyindex.h" +#include "blackmisc/propertyindexvariantmap.h" +#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h" +#include "blackmisc/simulation/simulatedaircraft.h" +#include "blackmisc/simulation/simulatedaircraftlist.h" +#include "blackmisc/simulation/simulatorplugininfo.h" +#include "blackmisc/variantlist.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class QDBusConnection; +class QDBusObjectPath; +class QDBusVariant; + +namespace BlackMisc +{ + class CVariant; + namespace Simulation { namespace FsCommon { class CAircraftCfgEntriesList; } } +} + +namespace BlackMisc +{ + namespace Test + { + //! Proxy class for BlackMisc::Test::CTestService. This part is the caller. + class BLACKMISC_EXPORT ITestServiceInterface: public QDBusAbstractInterface + { + Q_OBJECT + + public: + //! Constructor + ITestServiceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); + + //! Destructor + virtual ~ITestServiceInterface(); + + //! Ping via DBus, tests object marshalling/unmarshalling + static int pingTests(ITestServiceInterface &testServiceInterface, bool verbose); + + //! DBus calls + //! @{ + QDBusPendingReply getAtcStation() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1Literal("getAtcStation"), argumentList); + } + + QDBusPendingReply getAircraftCfgEntriesList(int number) + { + QList argumentList; + argumentList << QVariant::fromValue(number); + return asyncCallWithArgumentList(QLatin1Literal("getAircraftCfgEntriesList"), argumentList); + } + + QDBusPendingReply getAtcStationList(int number) + { + QList argumentList; + argumentList << QVariant::fromValue(number); + return asyncCallWithArgumentList(QLatin1Literal("getAtcStationList"), argumentList); + } + + QDBusPendingReply> getObjectPaths(int number) + { + QList argumentList; + argumentList << QVariant::fromValue(number); + return asyncCallWithArgumentList(QLatin1Literal("getObjectPaths"), argumentList); + } + + QDBusPendingReply getSpeed() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1Literal("getSpeed"), argumentList); + } + + QDBusPendingReply pingAltitude(const BlackMisc::Aviation::CAltitude &altitude) + { + QList argumentList; + argumentList << QVariant::fromValue(altitude); + return asyncCallWithArgumentList(QLatin1Literal("pingAltitude"), argumentList); + } + + QDBusPendingReply pingSituation(const BlackMisc::Aviation::CAircraftSituation &situation) + { + QList argumentList; + argumentList << QVariant::fromValue(situation); + return asyncCallWithArgumentList(QLatin1Literal("pingSituation"), argumentList); + } + + QDBusPendingReply pingUser(const BlackMisc::Network::CUser &user) + { + QList argumentList; + argumentList << QVariant::fromValue(user); + return asyncCallWithArgumentList(QLatin1Literal("pingUser"), argumentList); + } + + QDBusPendingReply pingTransponder(const BlackMisc::Aviation::CTransponder &transponder) + { + QList argumentList; + argumentList << QVariant::fromValue(transponder); + return asyncCallWithArgumentList(QLatin1Literal("pingTransponder"), argumentList); + } + + QDBusPendingReply pingAtcStation(const BlackMisc::Aviation::CAtcStation &station) + { + QList argumentList; + argumentList << QVariant::fromValue(station); + return asyncCallWithArgumentList(QLatin1Literal("pingAtcStation"), argumentList); + } + + QDBusPendingReply pingAircraftIcaoData(const BlackMisc::Aviation::CAircraftIcaoCode &icaoData) + { + QList argumentList; + argumentList << QVariant::fromValue(icaoData); + return asyncCallWithArgumentList(QLatin1Literal("pingAircraftIcaoData"), argumentList); + } + + QDBusPendingReply pingAircraftLights(const BlackMisc::Aviation::CAircraftLights &lights) + { + QList argumentList; + argumentList << QVariant::fromValue(lights); + return asyncCallWithArgumentList(QLatin1Literal("pingAircraftLights"), argumentList); + } + + QDBusPendingReply pingAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts) + { + QList argumentList; + argumentList << QVariant::fromValue(parts); + return asyncCallWithArgumentList(QLatin1Literal("pingAircraftParts"), argumentList); + } + + QDBusPendingReply pingAircraftEngine(const BlackMisc::Aviation::CAircraftEngine &engine) + { + QList argumentList; + argumentList << QVariant::fromValue(engine); + return asyncCallWithArgumentList(QLatin1Literal("pingAircraftEngine"), argumentList); + } + + QDBusPendingReply pingAircraftModel(const BlackMisc::Simulation::CAircraftModel &model) + { + QList argumentList; + argumentList << QVariant::fromValue(model); + return asyncCallWithArgumentList(QLatin1Literal("pingAircraftModel"), argumentList); + } + + QDBusPendingReply pingAircraftModelList(const BlackMisc::Simulation::CAircraftModelList &model) + { + QList argumentList; + argumentList << QVariant::fromValue(model); + return asyncCallWithArgumentList(QLatin1Literal("pingAircraftModelList"), argumentList); + } + + QDBusPendingReply pingSimulatedAircraft(BlackMisc::Simulation::CSimulatedAircraft aircraft) + { + QList argumentList; + argumentList << QVariant::fromValue(aircraft); + return asyncCallWithArgumentList(QLatin1Literal("pingSimulatedAircraft"), argumentList); + } + + QDBusPendingReply pingPluginInfo(BlackMisc::Simulation::CSimulatorPluginInfo info) + { + QList argumentList; + argumentList << QVariant::fromValue(info); + return asyncCallWithArgumentList(QLatin1Literal("pingPluginInfo"), argumentList); + } + + QDBusPendingReply pingAtcStationList(BlackMisc::Aviation::CAtcStationList atcStationList) + { + QList argumentList; + argumentList << QVariant::fromValue(atcStationList); + return asyncCallWithArgumentList(QLatin1Literal("pingAtcStationList"), argumentList); + } + + QDBusPendingReply pingSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed) + { + QList argumentList; + argumentList << QVariant::fromValue(speed); + return asyncCallWithArgumentList(QLatin1Literal("pingSpeed"), argumentList); + } + + QDBusPendingReply pingAircraftList(const BlackMisc::Simulation::CSimulatedAircraftList &aircraftList) + { + QList argumentList; + argumentList << QVariant::fromValue(aircraftList); + return asyncCallWithArgumentList(QLatin1Literal("pingAircraftList"), argumentList); + } + + QDBusPendingReply pingAirportList(const BlackMisc::Aviation::CAirportList &airportList) + { + QList argumentList; + argumentList << QVariant::fromValue(airportList); + return asyncCallWithArgumentList(QLatin1Literal("pingAirportList"), argumentList); + } + + QDBusPendingReply pingClientList(const BlackMisc::Network::CClientList &clientList) + { + QList argumentList; + argumentList << QVariant::fromValue(clientList); + return asyncCallWithArgumentList(QLatin1Literal("pingClientList"), argumentList); + } + + QDBusPendingReply pingClient(const BlackMisc::Network::CClient &client) + { + QList argumentList; + argumentList << QVariant::fromValue(client); + return asyncCallWithArgumentList(QLatin1Literal("pingClient"), argumentList); + } + + QDBusPendingReply pingCVariant(const BlackMisc::CVariant &variant) + { + QList argumentList; + argumentList << QVariant::fromValue(variant); + return asyncCallWithArgumentList(QLatin1Literal("pingCVariant"), argumentList); + } + + QDBusPendingReply pingPropertyIndex(const BlackMisc::CPropertyIndex &index) + { + QList argumentList; + argumentList << QVariant::fromValue(index); + return asyncCallWithArgumentList(QLatin1Literal("pingPropertyIndex"), argumentList); + } + + QDBusPendingReply pingIndexVariantMap(BlackMisc::CPropertyIndexVariantMap indexVariantMap) + { + QList argumentList; + argumentList << QVariant::fromValue(indexVariantMap); + return asyncCallWithArgumentList(QLatin1Literal("pingIndexVariantMap"), argumentList); + } + + QDBusPendingReply receiveAltitude(const BlackMisc::Aviation::CAltitude &altitude) + { + QList argumentList; + argumentList << QVariant::fromValue(altitude); + return asyncCallWithArgumentList(QLatin1Literal("receiveAltitude"), argumentList); + } + + QDBusPendingReply<> receiveAtcStation(const BlackMisc::Aviation::CAtcStation &station) + { + QList argumentList; + argumentList << QVariant::fromValue(station); + return asyncCallWithArgumentList(QLatin1Literal("receiveAtcStation"), argumentList); + } + + QDBusPendingReply<> receiveAtcStationList(const BlackMisc::Aviation::CAtcStationList &atcStationList) + { + QList argumentList; + argumentList << QVariant::fromValue(atcStationList); + return asyncCallWithArgumentList(QLatin1Literal("receiveAtcStationList"), argumentList); + } + + QDBusPendingReply<> receiveCallsign(const BlackMisc::Aviation::CCallsign &callsign) + { + QList argumentList; + argumentList << QVariant::fromValue(callsign); + return asyncCallWithArgumentList(QLatin1Literal("receiveCallsign"), argumentList); + } + + QDBusPendingReply<> receiveComUnit(const BlackMisc::Aviation::CComSystem &comUnit) + { + QList argumentList; + argumentList << QVariant::fromValue(comUnit); + return asyncCallWithArgumentList(QLatin1Literal("receiveComUnit"), argumentList); + } + + QDBusPendingReply<> receiveGeoPosition(const BlackMisc::Geo::CCoordinateGeodetic &geo) + { + QList argumentList; + argumentList << QVariant::fromValue(geo); + return asyncCallWithArgumentList(QLatin1Literal("receiveGeoPosition"), argumentList); + } + + QDBusPendingReply<> receiveLength(const BlackMisc::PhysicalQuantities::CLength &length) + { + QList argumentList; + argumentList << QVariant::fromValue(length); + return asyncCallWithArgumentList(QLatin1Literal("receiveLength"), argumentList); + } + + QDBusPendingReply<> receiveLengthsQl(const BlackMisc::CVariantList &lengthsList) + { + QList argumentList; + argumentList << QVariant::fromValue(lengthsList); + return asyncCallWithArgumentList(QLatin1Literal("receiveLengthsQl"), argumentList); + } + + QDBusPendingReply<> receiveLengthsQvl(const BlackMisc::CVariantList &lengthsVariantList) + { + QList argumentList; + argumentList << QVariant::fromValue(lengthsVariantList); + return asyncCallWithArgumentList(QLatin1Literal("receiveLengthsQvl"), argumentList); + } + + QDBusPendingReply<> receiveList(const QList &list) + { + QList argumentList; + argumentList << QVariant::fromValue(list); + return asyncCallWithArgumentList(QLatin1Literal("receiveList"), argumentList); + } + + QDBusPendingReply<> receiveSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed) + { + QList argumentList; + argumentList << QVariant::fromValue(speed); + return asyncCallWithArgumentList(QLatin1Literal("receiveSpeed"), argumentList); + } + + QDBusPendingReply<> receiveStringMessage(const QString &message) + { + QList argumentList; + argumentList << QVariant::fromValue(message); + return asyncCallWithArgumentList(QLatin1Literal("receiveStringMessage"), argumentList); + } + + QDBusPendingReply<> receiveTrack(BlackMisc::Aviation::CTrack track) + { + QList argumentList; + argumentList << QVariant::fromValue(track); + return asyncCallWithArgumentList(QLatin1Literal("receiveTrack"), argumentList); + } + + QDBusPendingReply<> receiveTransponder(const BlackMisc::Aviation::CTransponder &transponder) + { + QList argumentList; + argumentList << QVariant::fromValue(transponder); + return asyncCallWithArgumentList(QLatin1Literal("receiveTransponder"), argumentList); + } + + QDBusPendingReply<> receiveValueMap(const BlackMisc::CPropertyIndexVariantMap &valueMap) + { + QList argumentList; + argumentList << QVariant::fromValue(valueMap); + return asyncCallWithArgumentList(QLatin1Literal("receiveValueMap"), argumentList); + } + + QDBusPendingReply<> receiveVariant(const QDBusVariant &variant, int localMetyType) + { + QList argumentList; + argumentList << QVariant::fromValue(variant) << QVariant::fromValue(localMetyType); + return asyncCallWithArgumentList(QLatin1Literal("receiveVariant"), argumentList); + } + //! @} + + signals: + //! send message + void sendStringMessage(const QString &message); + + private: + //! Interface name + static const char *InterfaceName(); + + //! Compare objects and output info + template + static bool pingCompare(const ValueObject &in, const ValueObject &out, QTextStream &ts, bool verbose, int &errors) + { + const bool equal = (in == out); + if (!equal) { errors++; } + if (equal && !verbose) { return true; } + ts << "I: " << in.toQString() << endl << "O: " << out.toQString() << endl; + return equal; + } + + //! Error info string + static const QString &errorInfo(bool ok); + }; + } // ns +} // ns +#endif diff --git a/src/blackcore/test/testutils.cpp b/src/blackmisc/test/testutils.cpp similarity index 85% rename from src/blackcore/test/testutils.cpp rename to src/blackmisc/test/testutils.cpp index ecd2c8e90..f6ca705eb 100644 --- a/src/blackcore/test/testutils.cpp +++ b/src/blackmisc/test/testutils.cpp @@ -7,8 +7,6 @@ * contained in the LICENSE file. */ -//! \file - #include "testutils.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include @@ -24,7 +22,7 @@ using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation::FsCommon; -namespace BlackCore +namespace BlackMisc { namespace Test { @@ -108,37 +106,6 @@ namespace BlackCore out << "CVariant" << " size: " << s.size() << " sig: " << s << endl; } - CCallsign CTestUtils::getRandomAtcCallsign() - { - static QList callsigns; - if (callsigns.isEmpty()) - { - callsigns << CCallsign("EDDM_TWR"); - callsigns << CCallsign("EDDM_APP"); - callsigns << CCallsign("EDDM_GND"); - callsigns << CCallsign("EDDF_TWR"); - callsigns << CCallsign("EDDF_APP"); - callsigns << CCallsign("EDDF_GND"); - } - int i = (rand() % (callsigns.size())); - CCallsign cs = callsigns.at(i); - return cs; - } - - CAtcStation CTestUtils::getAtcStation() - { - const CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() }); // Munich - const CAtcStation station(CCallsign("eddm_twr"), CUser("654321", "client"), - CFrequency(118.7, CFrequencyUnit::MHz()), - geoPos, CLength(50, CLengthUnit::km())); - return station; - } - - CSpeed CTestUtils::getSpeed() - { - return CSpeed(666, CSpeedUnit::km_h()); - } - CAtcStationList CTestUtils::getStations(int number) { BlackMisc::Aviation::CAtcStationList list; diff --git a/src/blackcore/test/testutils.h b/src/blackmisc/test/testutils.h similarity index 80% rename from src/blackcore/test/testutils.h rename to src/blackmisc/test/testutils.h index ca868ac4f..7e352b926 100644 --- a/src/blackcore/test/testutils.h +++ b/src/blackmisc/test/testutils.h @@ -9,22 +9,22 @@ //! \file -#ifndef BLACKCORE_TEST_TESTUTILS_H -#define BLACKCORE_TEST_TESTUTILS_H +#ifndef BLACKMISC_TEST_TESTUTILS_H +#define BLACKMISC_TEST_TESTUTILS_H -#include "blackcore/blackcoreexport.h" +#include "blackmisc/blackmiscexport.h" #include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h" #include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/aviation/airportlist.h" #include "blackmisc/network/clientlist.h" #include -namespace BlackCore +namespace BlackMisc { namespace Test { //! Utils for UNIT tests / samples - class BLACKCORE_EXPORT CTestUtils + class BLACKMISC_EXPORT CTestUtils { public: //! Get QDBusArgument signature (formatted) @@ -46,16 +46,6 @@ namespace BlackCore static void showDBusSignatures(QTextStream &out); // ----------------- some test data -------------------- - - //! Get a random callsign - static BlackMisc::Aviation::CCallsign getRandomAtcCallsign(); - - //! Get ATC station - static BlackMisc::Aviation::CAtcStation getAtcStation(); - - //! Get speed - static BlackMisc::PhysicalQuantities::CSpeed getSpeed(); - //! Get ATC stations static BlackMisc::Aviation::CAtcStationList getStations(int number);