diff --git a/tests/blacksimpluginfsxp3d/blacksimpluginfsxp3dtest.h b/tests/blacksimpluginfsxp3d/blacksimpluginfsxp3dtest.h new file mode 100644 index 000000000..5c159f802 --- /dev/null +++ b/tests/blacksimpluginfsxp3d/blacksimpluginfsxp3dtest.h @@ -0,0 +1,26 @@ +/* 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 BLACKSIMPLUGINFSXP3DTEST_H +#define BLACKSIMPLUGINFSXP3DTEST_H + +//! \cond PRIVATE_TESTS + +/*! + * \namespace Plugins + * \defgroup testpluginsfsxp3d BlackSimPluginFsxP3D Unit Tests + * \ingroup tests + * Unit tests for BlackSimPluginFsxP3D. Unit tests do have their own namespace, so + * the regular namespace BlackSimPlugin is completely free of unit tests. + * Add any new tests to TestMain::unitMain as shown there. + */ + +//! \endcond + +#endif // guard diff --git a/tests/blacksimpluginfsxp3d/main.cpp b/tests/blacksimpluginfsxp3d/main.cpp new file mode 100644 index 000000000..1f16d86d4 --- /dev/null +++ b/tests/blacksimpluginfsxp3d/main.cpp @@ -0,0 +1,37 @@ +/* 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. + */ + +//! \cond PRIVATE_TESTS +//! \file +//! \ingroup testpluginfsxp3d + +#include "testblacksimpluginfsxp3dmain.h" +#include "blackmisc/registermetadata.h" +#include +#include + +using namespace BlackSimPluginFsxP3D; + +/*! + * 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 CBlackSimPluginFsxP3DTest::unitMain(argc, argv);; +} + +//! \endcond diff --git a/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro b/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro new file mode 100644 index 000000000..10a4c1afb --- /dev/null +++ b/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro @@ -0,0 +1,33 @@ +load(common_pre) + +QT += core testlib dbus network gui widgets + +TARGET = testsimpluginfsxp3d +TEMPLATE = app + +CONFIG += console +CONFIG -= app_bundle +CONFIG += blackmisc blackcore blackconfig blackgui +CONFIG += testcase +CONFIG += no_testcase_installs + +DEPENDPATH += . $$SourceRoot/src +INCLUDEPATH += . $$SourceRoot/src +HEADERS += *.h +SOURCES += *.cpp +DESTDIR = $$DestRoot/bin + +LIBS *= -lsimulatorfsxcommon -lsimulatorfscommon -lfsuipc -lsimulatorplugincommon + +# include(../../src/plugins/simulator/fsxp3d.pri) +include(../../src/plugins/simulator/fsxp3d_include.pri) + +addStaticLibraryDependency(simulatorfscommon) +addStaticLibraryDependency(simulatorfsxcommon) +addStaticLibraryDependency(fsuipc) +addStaticLibraryDependency(simulatorplugincommon) + +# Ignore linker warning about missing pdb files from Simconnect +msvc: QMAKE_LFLAGS *= /ignore:4099 + +load(common_post) diff --git a/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.cpp b/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.cpp new file mode 100644 index 000000000..c46e05b07 --- /dev/null +++ b/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.cpp @@ -0,0 +1,35 @@ +/* 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. + */ + +//! \cond PRIVATE_TESTS +//! \file +//! \ingroup testplugins + +#include "testblacksimpluginfsxp3dmain.h" +#include "testfsxp3dcommon.h" +#include "blackmisc/test/test.h" +#include +#include + +namespace BlackSimPluginFsxP3D +{ + int CBlackSimPluginFsxP3DTest::unitMain(int argc, char *argv[]) + { + BlackMisc::Test::CTest test(argc, argv); + + int status = 0; + { + CTestFsxP3DCommon commonTest; + status |= test.exec(&commonTest, "blacksimpluginfsxp3d_fsxp3dcommon"); + } + return status; + } +} // namespace + +//! \endcond diff --git a/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.h b/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.h new file mode 100644 index 000000000..7b1df8284 --- /dev/null +++ b/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.h @@ -0,0 +1,34 @@ +/* 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 BLACKSIMPLUGINFSXP3D_TESTMAIN_H +#define BLACKSIMPLUGINFSXP3D_TESTMAIN_H + +//! \cond PRIVATE_TESTS +//! \file +//! \ingroup testplugins + +namespace BlackSimPluginFsxP3D +{ + /*! + * 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 CBlackSimPluginFsxP3DTest + { + public: + //! Starting all + static int unitMain(int argc, char *argv[]); + }; +} // ns + +//! \endcond + +#endif // guard diff --git a/tests/blacksimpluginfsxp3d/testfsxp3dcommon.cpp b/tests/blacksimpluginfsxp3d/testfsxp3dcommon.cpp new file mode 100644 index 000000000..f76f01ef2 --- /dev/null +++ b/tests/blacksimpluginfsxp3d/testfsxp3dcommon.cpp @@ -0,0 +1,64 @@ +/* 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. + */ + +//! \cond PRIVATE_TESTS + +/*! + * \file + * \ingroup testblacksimplugin + */ + +#include "testfsxp3dcommon.h" +#include "plugins/simulator/fsxcommon/simconnectdatadefinition.h" +#include "plugins/simulator/fsxcommon/simulatorfsxcommon.h" +#include + +using namespace BlackSimPlugin::FsxCommon; + +namespace BlackSimPluginFsxP3D +{ + void CTestFsxP3DCommon::requestIds() + { + DWORD objectId = 666; + DWORD requestId = CSimulatorFsxCommon::unitTestRequestId(CSimConnectObject::Aircraft); + CSimConnectObject simObject(CSimConnectObject::Aircraft); + simObject.setRequestId(requestId); + simObject.setObjectId(objectId); + + QVERIFY(CSimulatorFsxCommon::isRequestForSimObjAircraft(requestId)); + QVERIFY(!CSimulatorFsxCommon::isRequestForSimObjTerrainProbe(requestId)); + CSimConnectDefinitions::SimObjectRequest sor = CSimulatorFsxCommon::requestToSimObjectRequest(requestId); + QVERIFY(sor == CSimConnectDefinitions::SimObjectBaseId); + + requestId = simObject.getRequestId(CSimConnectDefinitions::SimObjectAdd); + sor = CSimulatorFsxCommon::requestToSimObjectRequest(requestId); + QVERIFY(sor == CSimConnectDefinitions::SimObjectAdd); + + requestId = simObject.getRequestId(CSimConnectDefinitions::SimObjectLights); + sor = CSimulatorFsxCommon::requestToSimObjectRequest(requestId); + QVERIFY(sor == CSimConnectDefinitions::SimObjectLights); + + requestId = simObject.getRequestId(CSimConnectDefinitions::SimObjectRemove); + sor = CSimulatorFsxCommon::requestToSimObjectRequest(requestId); + QVERIFY(sor == CSimConnectDefinitions::SimObjectRemove); + + requestId = CSimulatorFsxCommon::unitTestRequestId(CSimConnectObject::TerrainProbe); + simObject.setRequestId(requestId); + + requestId = simObject.getRequestId(CSimConnectDefinitions::SimObjectPositionData); + sor = CSimulatorFsxCommon::requestToSimObjectRequest(requestId); + QVERIFY(sor == CSimConnectDefinitions::SimObjectPositionData); + + requestId = simObject.getRequestId(CSimConnectDefinitions::SimObjectMisc); + sor = CSimulatorFsxCommon::requestToSimObjectRequest(requestId); + QVERIFY(sor == CSimConnectDefinitions::SimObjectMisc); + } +} // ns + +//! \endcond diff --git a/tests/blacksimpluginfsxp3d/testfsxp3dcommon.h b/tests/blacksimpluginfsxp3d/testfsxp3dcommon.h new file mode 100644 index 000000000..242069a44 --- /dev/null +++ b/tests/blacksimpluginfsxp3d/testfsxp3dcommon.h @@ -0,0 +1,38 @@ +/* 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 BLACKSIMPLUGINFSXP3D_TESTFSXP3DCOMMON_H +#define BLACKSIMPLUGINFSXP3D_TESTFSXP3DCOMMON_H + +//! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblacksimplugin + +#include + +namespace BlackSimPluginFsxP3D +{ + //! FSX/P3D common tests + class CTestFsxP3DCommon : public QObject + { + Q_OBJECT + + public: + //! Standard test case constructor + explicit CTestFsxP3DCommon(QObject *parent = nullptr) : QObject(parent) {} + + private slots: + //! Request IDs + void requestIds(); + }; +} // namespace + +//! \endcond + +#endif // guard diff --git a/tests/tests.pro b/tests/tests.pro index 3bc69a15c..1bca3bf2d 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -9,6 +9,11 @@ SUBDIRS += testblackgui testblackmisc.file = blackmisc/testblackmisc.pro testblackcore.file = blackcore/testblackcore.pro -testblackgui.file = blackgui/testblackgui.pro +testblackgui.file = blackgui/testblackgui.pro + +contains(BLACK_CONFIG,FSX|P3D) { + SUBDIRS += testsimpluginfsxp3d + testsimpluginfsxp3d.file = blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro +} load(common_post)