mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
(will be consolidated with existing utility classes)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
ae5b0310b6
commit
ed820da20d
75
src/blackmisc/test/testdata.cpp
Normal file
75
src/blackmisc/test/testdata.cpp
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "testdata.h"
|
||||||
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
using namespace BlackMisc::Geo;
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
const CCoordinateGeodetic &CTestData::coordinateMunichTower()
|
||||||
|
{
|
||||||
|
static const CCoordinateGeodetic c = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CCoordinateGeodetic &CTestData::coordinateFrankfurtTower()
|
||||||
|
{
|
||||||
|
static const CCoordinateGeodetic c = CCoordinateGeodetic::fromWgs84("50° 1' 18.38″ N", "8° 33' 23.24″ E", { 355, CLengthUnit::ft() });
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CAtcStationList &CTestData::getTowerStations()
|
||||||
|
{
|
||||||
|
static const CAtcStationList stations(
|
||||||
|
{
|
||||||
|
CAtcStation(CCallsign("EDDF_TWR"), CUser("654321", "Joe Bar"),
|
||||||
|
CFrequency(118.7, CFrequencyUnit::MHz()), CTestData::coordinateMunichTower(), CLength(50, CLengthUnit::km())),
|
||||||
|
CAtcStation(CCallsign("EDDM_TWR"), CUser("654321", "John Doe"),
|
||||||
|
CFrequency(119.9, CFrequencyUnit::MHz()), CTestData::coordinateFrankfurtTower(), CLength(50, CLengthUnit::km()))
|
||||||
|
});
|
||||||
|
return stations;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CAtcStation &CTestData::getAtcStation()
|
||||||
|
{
|
||||||
|
return getTowerStations()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
const CCallsign &CTestData::getRandomAtcCallsign()
|
||||||
|
{
|
||||||
|
static const QList<CCallsign> callsigns(
|
||||||
|
{
|
||||||
|
CCallsign("EDDM_TWR"), CCallsign("EDDM_APP"), CCallsign("EDDM_GND"),
|
||||||
|
CCallsign("EDDF_TWR"), CCallsign("EDDF_APP"),
|
||||||
|
CCallsign("EDDF_GND")
|
||||||
|
});
|
||||||
|
int i = (rand() % (callsigns.size()));
|
||||||
|
return callsigns[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
const CCallsign &CTestData::getRandomAircraftCallsign()
|
||||||
|
{
|
||||||
|
static const QList<CCallsign> callsigns(
|
||||||
|
{
|
||||||
|
CCallsign("DEMBZ"), CCallsign("DLH123"), CCallsign("RYR635L"),
|
||||||
|
CCallsign("LGL974"), CCallsign("AUI129"),
|
||||||
|
CCallsign("CLX756")
|
||||||
|
});
|
||||||
|
int i = (rand() % (callsigns.size()));
|
||||||
|
return callsigns[i];
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
59
src/blackmisc/test/testdata.h
Normal file
59
src/blackmisc/test/testdata.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_TEST_TESTDATA_H
|
||||||
|
#define BLACKMISC_TEST_TESTDATA_H
|
||||||
|
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Aviation
|
||||||
|
{
|
||||||
|
class CAtcStation;
|
||||||
|
class CAtcStationList;
|
||||||
|
class CCallsign;
|
||||||
|
}
|
||||||
|
namespace Geo
|
||||||
|
{
|
||||||
|
class CCoordinateGeodetic;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Testdata for unit tests/data
|
||||||
|
*/
|
||||||
|
class BLACKMISC_EXPORT CTestData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Munich tower coordinate
|
||||||
|
static const BlackMisc::Geo::CCoordinateGeodetic &coordinateMunichTower();
|
||||||
|
|
||||||
|
//! Frankfurt tower coordinate
|
||||||
|
static const BlackMisc::Geo::CCoordinateGeodetic &coordinateFrankfurtTower();
|
||||||
|
|
||||||
|
//! Tower stations
|
||||||
|
static const BlackMisc::Aviation::CAtcStationList &getTowerStations();
|
||||||
|
|
||||||
|
//! Get ATC station
|
||||||
|
static const BlackMisc::Aviation::CAtcStation &getAtcStation();
|
||||||
|
|
||||||
|
//! Get a random callsign (ATC)
|
||||||
|
static const BlackMisc::Aviation::CCallsign &getRandomAtcCallsign();
|
||||||
|
|
||||||
|
//! Get a random callsign (aircraft)
|
||||||
|
static const BlackMisc::Aviation::CCallsign &getRandomAircraftCallsign();
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -18,8 +18,7 @@
|
|||||||
#include "testnetwork.h"
|
#include "testnetwork.h"
|
||||||
#include "testreaders.h"
|
#include "testreaders.h"
|
||||||
#include "testcontext.h"
|
#include "testcontext.h"
|
||||||
#include "testdbus.h"
|
#include "blackmisc/test/test.h"
|
||||||
#include "blackmisc/test.h"
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
@@ -27,12 +26,8 @@ namespace BlackCoreTest
|
|||||||
{
|
{
|
||||||
int CBlackCoreTestMain::unitMain(int argc, char *argv[])
|
int CBlackCoreTestMain::unitMain(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
BlackMisc::CTest test(argc, argv);
|
BlackMisc::Test::CTest test(argc, argv);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
{
|
|
||||||
CTestDBus dbusTests;
|
|
||||||
status |= test.exec(&dbusTests, "blackcore_dbus");
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
CTestContext contextTests;
|
CTestContext contextTests;
|
||||||
status |= test.exec(&contextTests, "blackcore_context");
|
status |= test.exec(&contextTests, "blackcore_context");
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "testblackguimain.h"
|
#include "testblackguimain.h"
|
||||||
#include "testutils.h"
|
#include "testutils.h"
|
||||||
#include "blackmisc/test.h"
|
#include "blackmisc/test/test.h"
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
@@ -28,7 +28,7 @@ namespace BlackGuiTest
|
|||||||
*/
|
*/
|
||||||
int CBlackGuiTestMain::unitMain(int argc, char *argv[])
|
int CBlackGuiTestMain::unitMain(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
BlackMisc::CTest test(argc, argv);
|
BlackMisc::Test::CTest test(argc, argv);
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,11 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//! \cond PRIVATE_TESTS
|
//! \cond PRIVATE_TESTS
|
||||||
|
//! \file
|
||||||
/*!
|
//! \ingroup testblackmisc
|
||||||
* \file
|
|
||||||
* \ingroup testblackmisc
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "testblackmiscmain.h"
|
#include "testblackmiscmain.h"
|
||||||
#include "blackmisc/registermetadata.h"
|
#include "blackmisc/registermetadata.h"
|
||||||
|
|||||||
@@ -8,11 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//! \cond PRIVATE_TESTS
|
//! \cond PRIVATE_TESTS
|
||||||
|
//! \file
|
||||||
/*!
|
//! \ingroup testblackmisc
|
||||||
* \file
|
|
||||||
* \ingroup testblackmisc
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "testaviation.h"
|
#include "testaviation.h"
|
||||||
#include "testblackmiscmain.h"
|
#include "testblackmiscmain.h"
|
||||||
@@ -30,7 +27,8 @@
|
|||||||
#include "testvaluecache.h"
|
#include "testvaluecache.h"
|
||||||
#include "testvariantandmap.h"
|
#include "testvariantandmap.h"
|
||||||
#include "testweather.h"
|
#include "testweather.h"
|
||||||
#include "blackmisc/test.h"
|
#include "testdbus.h"
|
||||||
|
#include "blackmisc/test/test.h"
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
@@ -42,7 +40,7 @@ namespace BlackMiscTest
|
|||||||
*/
|
*/
|
||||||
int CBlackMiscTestMain::unitMain(int argc, char *argv[])
|
int CBlackMiscTestMain::unitMain(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
BlackMisc::CTest test(argc, argv);
|
BlackMisc::Test::CTest test(argc, argv);
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
{
|
{
|
||||||
@@ -105,6 +103,10 @@ namespace BlackMiscTest
|
|||||||
CTestProcess processTests;
|
CTestProcess processTests;
|
||||||
status |= test.exec(&processTests, "blackmisc_process");
|
status |= test.exec(&processTests, "blackmisc_process");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
CTestDBus testDBus;
|
||||||
|
status |= test.exec(&testDBus, "blackmisc_dbus");
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -16,16 +16,16 @@
|
|||||||
|
|
||||||
#include "testdbus.h"
|
#include "testdbus.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||||
#include "blackcore/test/testutils.h"
|
#include "blackmisc/test/testutils.h"
|
||||||
#include "blackcore/test/testservice.h"
|
#include "blackmisc/test/testservice.h"
|
||||||
#include "blackcore/test/testserviceinterface.h"
|
#include "blackmisc/test/testserviceinterface.h"
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackCore::Test;
|
using namespace BlackMisc::Test;
|
||||||
|
|
||||||
namespace BlackCoreTest
|
namespace BlackMiscTest
|
||||||
{
|
{
|
||||||
void CTestDBus::marshallUnmarshall()
|
void CTestDBus::marshallUnmarshall()
|
||||||
{
|
{
|
||||||
@@ -38,7 +38,7 @@ namespace BlackCoreTest
|
|||||||
CTestService *testService = CTestService::registerTestService(connection, false, QCoreApplication::instance());
|
CTestService *testService = CTestService::registerTestService(connection, false, QCoreApplication::instance());
|
||||||
Q_UNUSED(testService);
|
Q_UNUSED(testService);
|
||||||
ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(), connection);
|
ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(), connection);
|
||||||
int errors = ITestServiceInterface::pingTests(testServiceInterface, false);
|
const int errors = ITestServiceInterface::pingTests(testServiceInterface, false);
|
||||||
QVERIFY2(errors == 0, "DBus Ping tests fail");
|
QVERIFY2(errors == 0, "DBus Ping tests fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
//! \cond PRIVATE_TESTS
|
//! \cond PRIVATE_TESTS
|
||||||
//! \file
|
//! \file
|
||||||
//! \ingroup testblackcore
|
//! \ingroup testblackmisc
|
||||||
|
|
||||||
namespace BlackCoreTest
|
namespace BlackMiscTest
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
* DBus implementation classes tests
|
* DBus implementation classes tests
|
||||||
Reference in New Issue
Block a user