mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T275, unit tests for FSX/P3D
In that very case testing the offsets for request ids
This commit is contained in:
26
tests/blacksimpluginfsxp3d/blacksimpluginfsxp3dtest.h
Normal file
26
tests/blacksimpluginfsxp3d/blacksimpluginfsxp3dtest.h
Normal file
@@ -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
|
||||
37
tests/blacksimpluginfsxp3d/main.cpp
Normal file
37
tests/blacksimpluginfsxp3d/main.cpp
Normal file
@@ -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 <QCoreApplication>
|
||||
#include <QtGlobal>
|
||||
|
||||
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
|
||||
33
tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro
Normal file
33
tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro
Normal file
@@ -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)
|
||||
35
tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.cpp
Normal file
35
tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.cpp
Normal file
@@ -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 <QStringList>
|
||||
#include <QTest>
|
||||
|
||||
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
|
||||
34
tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.h
Normal file
34
tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3dmain.h
Normal file
@@ -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
|
||||
64
tests/blacksimpluginfsxp3d/testfsxp3dcommon.cpp
Normal file
64
tests/blacksimpluginfsxp3d/testfsxp3dcommon.cpp
Normal file
@@ -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 <QTest>
|
||||
|
||||
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
|
||||
38
tests/blacksimpluginfsxp3d/testfsxp3dcommon.h
Normal file
38
tests/blacksimpluginfsxp3d/testfsxp3dcommon.h
Normal file
@@ -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 <QObject>
|
||||
|
||||
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
|
||||
@@ -11,4 +11,9 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user