mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #875, more tests / pings
This commit is contained in:
committed by
Mathew Sutcliffe
parent
2f4c86fac4
commit
94e5bbcc93
@@ -28,26 +28,27 @@
|
||||
//! main
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// of course the code here is containing too many lines, but as it
|
||||
// Of course the code here is containing too many lines, but as it
|
||||
// is just for testing, I did not split it up
|
||||
|
||||
BlackMisc::registerMetadata();
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
// trying to get the arguments into a list
|
||||
QStringList cmdlineArgs = QCoreApplication::arguments();
|
||||
const QStringList cmdlineArgs = QCoreApplication::arguments();
|
||||
if (cmdlineArgs.length() < 1)
|
||||
{
|
||||
qFatal("Missing name of executable");
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// some runtime settings
|
||||
QString ip = "192.168.0.133";
|
||||
const QStringList ipV4Addresses = BlackMisc::Network::CNetworkUtils::getKnownLocalIpV4Addresses();
|
||||
QString ip = ipV4Addresses.isEmpty() ? "192.168.0.125" : ipV4Addresses.last();
|
||||
QString port = "45000";
|
||||
const QString executable = QString(cmdlineArgs.at(0)); // used as command to fork myself
|
||||
const bool clientFlag = cmdlineArgs.contains("client", Qt::CaseInsensitive);
|
||||
bool useSessionBusForServer;
|
||||
bool useSessionBusForServer = false;
|
||||
if (cmdlineArgs.contains("session", Qt::CaseInsensitive))
|
||||
{
|
||||
// session mode
|
||||
@@ -72,7 +73,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Configure tests
|
||||
Menu:
|
||||
|
||||
qDebug() << "1 .. Run testservice to test data transfer" << addressTcp;
|
||||
qDebug() << "1sb. Run testservice via session bus";
|
||||
qDebug() << "----- Change address / port (no validation, do before starting server)";
|
||||
@@ -146,7 +146,6 @@ int main(int argc, char *argv[])
|
||||
args << ip;
|
||||
args << port;
|
||||
}
|
||||
BlackSample::ServiceTool::startNewProcess(executable, args, &a);
|
||||
|
||||
// run tests
|
||||
if (mode == "testservice")
|
||||
@@ -154,6 +153,12 @@ int main(int argc, char *argv[])
|
||||
BlackSample::ServiceTool::dataTransferTestServer(dBusServer);
|
||||
}
|
||||
|
||||
// in new process
|
||||
BlackSample::ServiceTool::startNewProcess(executable, args, &a);
|
||||
|
||||
// in same process
|
||||
// BlackSample::ServiceTool::dataTransferTestClient(address);
|
||||
|
||||
// loop
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -389,43 +389,69 @@ namespace BlackSample
|
||||
CSimulatorPluginInfo pluginInfo("fsx", "FSX Simulator", "FSX", "Flight Simulator X", true);
|
||||
CSimulatorPluginInfo pluginInfoReceived = testserviceInterface.pingPluginInfo(pluginInfo);
|
||||
qDebug() << "Pinged info via interface"
|
||||
<< ((pluginInfo == pluginInfoReceived) ? "OK" : "ERROR!") << pluginInfoReceived;
|
||||
<< ((pluginInfo == pluginInfoReceived) ? "OK" : "------------- ERROR! ------------") << pluginInfoReceived;
|
||||
|
||||
CAtcStation stationReceived = testserviceInterface.pingAtcStation(station);
|
||||
CSpeed speedNotNull(22, CSpeedUnit::m_s());
|
||||
speedNull = CSpeed(0, CSpeedUnit::nullUnit());
|
||||
speed = testserviceInterface.pingSpeed(speedNotNull);
|
||||
qDebug() << "Pinged not null speed via interface"
|
||||
<< ((speedNotNull == speed) ? "OK" : "------------- ERROR! ------------") << speed;
|
||||
speed = testserviceInterface.pingSpeed(speedNull);
|
||||
qDebug() << "Pinged null speed via interface"
|
||||
<< ((speedNull == speed) ? "OK" : "------------- ERROR! ------------") << speed;
|
||||
|
||||
CAtcStation stationReceived = testserviceInterface.pingAtcStation(station);
|
||||
qDebug() << "Pinged ATC station via interface"
|
||||
<< ((station == stationReceived) ? "OK" : "ERROR!") << stationReceived;
|
||||
<< ((station == stationReceived) ? "OK" : "------------- ERROR! ------------") << stationReceived;
|
||||
|
||||
CAircraftIcaoCode icaoData("B737", "L2J");
|
||||
CAircraftIcaoCode icaoReceived = testserviceInterface.pingAircraftIcaoData(icaoData);
|
||||
qDebug() << "Pinged ICAO data via interface"
|
||||
<< ((icaoData == icaoReceived) ? "OK" : "ERROR!") << icaoReceived;
|
||||
<< ((icaoData == icaoReceived) ? "OK" : "------------- ERROR! ------------") << icaoReceived;
|
||||
qDebug() << icaoData << icaoReceived;
|
||||
|
||||
CUser pingUser("223344", "Ping Me User");
|
||||
CUser userReceived = testserviceInterface.pingUser(pingUser);
|
||||
qDebug() << "Pinged user via interface"
|
||||
<< ((userReceived == pingUser) ? "OK" : "ERROR!") << userReceived;
|
||||
<< ((userReceived == pingUser) ? "OK" : "------------- ERROR! ------------") << userReceived;
|
||||
|
||||
CAircraftSituation situation;
|
||||
CAircraftSituation situationReceived = testserviceInterface.pingSituation(situation);
|
||||
qDebug() << "Pinged situation via interface"
|
||||
<< ((situation == situationReceived) ? "OK" : "ERROR!") << situationReceived;
|
||||
<< ((situation == situationReceived) ? "OK" : "------------- ERROR! ------------") << situationReceived;
|
||||
|
||||
CTransponder transponderReceived = testserviceInterface.pingTransponder(transponder);
|
||||
qDebug() << "Pinged transponder via interface"
|
||||
<< ((transponderReceived == transponder) ? "OK" : "ERROR!") << transponderReceived;
|
||||
<< ((transponderReceived == transponder) ? "OK" : "------------- ERROR! ------------") << transponderReceived;
|
||||
|
||||
CAircraftLights lights(true, false, true, false, true, false);
|
||||
CAircraftLights lightsReceived = testserviceInterface.pingAircraftLights(lights);
|
||||
qDebug() << "Pinged lights via interface"
|
||||
<< ((lightsReceived == lights) ? "OK" : "------------- ERROR! ------------") << lightsReceived;
|
||||
|
||||
CAircraftEngine engine(3, true);
|
||||
CAircraftEngine engineReceived = testserviceInterface.pingAircraftEngine(engine);
|
||||
qDebug() << "Pinged engine via interface"
|
||||
<< ((engineReceived == engine) ? "OK" : "------------- ERROR! ------------") << engineReceived;
|
||||
|
||||
CAircraftEngineList engines({engine});
|
||||
CAircraftParts parts(lights, true, 11, true, engines, true);
|
||||
CAircraftParts partsReceived = testserviceInterface.pingAircraftParts(parts);
|
||||
qDebug() << "Pinged parts via interface"
|
||||
<< ((partsReceived == parts) ? "OK" : "------------- ERROR! ------------") << partsReceived;
|
||||
|
||||
CSimulatedAircraft aircraft(callsign, CUser("123456", "Joe Pilot"), situation);
|
||||
aircraft.setTransponder(transponder);
|
||||
CSimulatedAircraft aircraftReceived(testserviceInterface.pingAircraft(aircraft));
|
||||
CSimulatedAircraft aircraftReceived(testserviceInterface.pingSimulatedAircraft(aircraft));
|
||||
qDebug() << "Pinged aircraft via interface"
|
||||
<< ((aircraft == aircraftReceived) ? "OK" : "ERROR!") << aircraftReceived;
|
||||
<< ((aircraft == aircraftReceived) ? "OK" : "------------- ERROR! ------------") << aircraftReceived;
|
||||
|
||||
CSimulatedAircraft simAircraft(aircraft);
|
||||
CAircraftModel model("foobar", CAircraftModel::TypeManuallySet);
|
||||
simAircraft.setModel(model);
|
||||
CSimulatedAircraft simAircraftReceived = testserviceInterface.pingSimulatedAircraft(simAircraft);
|
||||
qDebug() << "Pinged simulated aircraft via interface"
|
||||
<< ((simAircraft == simAircraftReceived) ? "OK" : "ERROR!") << simAircraftReceived;
|
||||
<< ((simAircraft == simAircraftReceived) ? "OK" : "------------- ERROR! ------------") << simAircraftReceived;
|
||||
|
||||
CAtcStationList atcStationList;
|
||||
atcStationList.push_back(station);
|
||||
@@ -462,7 +488,7 @@ namespace BlackSample
|
||||
qDebug() << "Send lengths via interface as CVariantList:";
|
||||
testserviceInterface.receiveLengthsQl(lengthsV);
|
||||
qDebug() << "Send lengths via interface as QList<CVariant>:";
|
||||
foreach(CVariant lv, cvList)
|
||||
foreach (CVariant lv, cvList)
|
||||
{
|
||||
qDebug() << " " << "Send length in list:" << lv;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackSample
|
||||
{
|
||||
|
||||
const QString Testservice::InterfaceName = QString(BLACKSAMPLE_TESTSERVICE_INTERFACENAME);
|
||||
const QString Testservice::ObjectPath = QString(BLACKSAMPLE_TESTSERVICE_OBJECTPATH);
|
||||
|
||||
@@ -264,6 +263,33 @@ namespace BlackSample
|
||||
return aircraftList;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping aircraft parts
|
||||
*/
|
||||
CAircraftParts Testservice::pingAircraftParts(const CAircraftParts &aircraftParts)
|
||||
{
|
||||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping aircrafts parts:" << aircraftParts;
|
||||
return aircraftParts;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping aircraft lights
|
||||
*/
|
||||
CAircraftLights Testservice::pingAircraftLights(const CAircraftLights &aircraftLights)
|
||||
{
|
||||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping aircrafts lights:" << aircraftLights;
|
||||
return aircraftLights;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping simulated aircraft
|
||||
*/
|
||||
CSimulatedAircraft Testservice::pingSimulatedAircraft(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping simulated aircraft:" << aircraft;
|
||||
return aircraft;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping airports
|
||||
*/
|
||||
@@ -354,24 +380,6 @@ namespace BlackSample
|
||||
return station;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping aircraft
|
||||
*/
|
||||
CSimulatedAircraft Testservice::pingAircraft(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping aircraft:" << aircraft;
|
||||
return aircraft;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping simulated aircraft
|
||||
*/
|
||||
CSimulatedAircraft Testservice::pingSimulatedAircraft(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping simulated aircraft:" << aircraft;
|
||||
return aircraft;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ping ICAO data
|
||||
*/
|
||||
|
||||
@@ -144,8 +144,11 @@ namespace BlackSample
|
||||
//! Ping transponder
|
||||
BlackMisc::Aviation::CTransponder pingTransponder(const BlackMisc::Aviation::CTransponder &transponder);
|
||||
|
||||
//! Ping aircraft
|
||||
BlackMisc::Simulation::CSimulatedAircraft pingAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
//! Ping aircraft lights
|
||||
BlackMisc::Aviation::CAircraftLights pingAircraftLights(const BlackMisc::Aviation::CAircraftLights &aircraftLights);
|
||||
|
||||
//! Ping parts
|
||||
BlackMisc::Aviation::CAircraftParts pingAircraftParts(const BlackMisc::Aviation::CAircraftParts &aircraftParts);
|
||||
|
||||
//! Ping simulated aircraft
|
||||
BlackMisc::Simulation::CSimulatedAircraft pingSimulatedAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
@@ -58,7 +58,6 @@ namespace BlackMisc
|
||||
|
||||
namespace BlackSample
|
||||
{
|
||||
|
||||
//! Proxy class for interface blackmisctest.testservice
|
||||
class TestServiceInterface: public QDBusAbstractInterface
|
||||
{
|
||||
@@ -73,10 +72,9 @@ namespace BlackSample
|
||||
TestServiceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
|
||||
|
||||
//! Destructor
|
||||
~TestServiceInterface();
|
||||
virtual ~TestServiceInterface();
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
//! DBus calls
|
||||
//! @{
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAtcStation> getAtcStation()
|
||||
@@ -151,14 +149,28 @@ namespace BlackSample
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(icaoData);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingIcaoData"), argumentList);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAircraftIcaoData"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Simulation::CSimulatedAircraft> pingAircraft(BlackMisc::Simulation::CSimulatedAircraft aircraft)
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAircraftLights> pingAircraftLights(BlackMisc::Aviation::CAircraftLights lights)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(aircraft);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAircraft"), argumentList);
|
||||
argumentList << QVariant::fromValue(lights);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAircraftLights"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAircraftParts> pingAircraftParts(BlackMisc::Aviation::CAircraftParts parts)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(parts);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAircraftParts"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Aviation::CAircraftEngine> pingAircraftEngine(BlackMisc::Aviation::CAircraftEngine engine)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(engine);
|
||||
return asyncCallWithArgumentList(QLatin1String("pingAircraftEngine"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<BlackMisc::Simulation::CSimulatedAircraft> pingSimulatedAircraft(BlackMisc::Simulation::CSimulatedAircraft aircraft)
|
||||
|
||||
Reference in New Issue
Block a user