swift
Loading...
Searching...
No Matches
testserviceinterface.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_TEST_TESTSERVICEINTERFACE_H
7#define SWIFT_MISC_TEST_TESTSERVICEINTERFACE_H
8
9#include <QDBusAbstractInterface>
10#include <QDBusPendingCall>
11#include <QDBusPendingReply>
12#include <QLatin1String>
13#include <QList>
14#include <QObject>
15#include <QString>
16#include <QTextStream>
17#include <QVariant>
18
28#include "misc/aviation/track.h"
31#include "misc/network/client.h"
33#include "misc/network/user.h"
34#include "misc/pq/length.h"
35#include "misc/pq/speed.h"
43#include "misc/variantlist.h"
44
45class QDBusConnection;
46class QDBusObjectPath;
47class QDBusVariant;
48
49namespace swift::misc
50{
51 class CVariant;
52 namespace simulation::FsCommon
53 {
54 class CAircraftCfgEntriesList;
55 }
56} // namespace swift::misc
57
58namespace swift::misc::test
59{
62 {
64
65 public:
68 QObject *parent = nullptr);
69
71 ~ITestServiceInterface() override = default;
72
74 static int pingTests(ITestServiceInterface &testServiceInterface, bool verbose);
75
83
86 {
87 QList<QVariant> argumentList;
88 argumentList << QVariant::fromValue(number);
89 return asyncCallWithArgumentList(QLatin1String("getAircraftCfgEntriesList"), argumentList);
90 }
91
93 {
94 QList<QVariant> argumentList;
95 argumentList << QVariant::fromValue(number);
96 return asyncCallWithArgumentList(QLatin1String("getAtcStationList"), argumentList);
97 }
98
100 {
101 QList<QVariant> argumentList;
102 argumentList << QVariant::fromValue(number);
103 return asyncCallWithArgumentList(QLatin1String("getObjectPaths"), argumentList);
104 }
105
111
114 {
115 QList<QVariant> argumentList;
116 argumentList << QVariant::fromValue(altitude);
117 return asyncCallWithArgumentList(QLatin1String("pingAltitude"), argumentList);
118 }
119
122 {
123 QList<QVariant> argumentList;
124 argumentList << QVariant::fromValue(situation);
125 return asyncCallWithArgumentList(QLatin1String("pingSituation"), argumentList);
126 }
127
129 {
130 QList<QVariant> argumentList;
131 argumentList << QVariant::fromValue(user);
132 return asyncCallWithArgumentList(QLatin1String("pingUser"), argumentList);
133 }
134
137 {
138 QList<QVariant> argumentList;
139 argumentList << QVariant::fromValue(transponder);
140 return asyncCallWithArgumentList(QLatin1String("pingTransponder"), argumentList);
141 }
142
145 {
146 QList<QVariant> argumentList;
147 argumentList << QVariant::fromValue(station);
148 return asyncCallWithArgumentList(QLatin1String("pingAtcStation"), argumentList);
149 }
150
153 {
154 QList<QVariant> argumentList;
155 argumentList << QVariant::fromValue(icaoData);
156 return asyncCallWithArgumentList(QLatin1String("pingAircraftIcaoData"), argumentList);
157 }
158
161 {
162 QList<QVariant> argumentList;
163 argumentList << QVariant::fromValue(lights);
164 return asyncCallWithArgumentList(QLatin1String("pingAircraftLights"), argumentList);
165 }
166
169 {
170 QList<QVariant> argumentList;
171 argumentList << QVariant::fromValue(parts);
172 return asyncCallWithArgumentList(QLatin1String("pingAircraftParts"), argumentList);
173 }
174
177 {
178 QList<QVariant> argumentList;
179 argumentList << QVariant::fromValue(engine);
180 return asyncCallWithArgumentList(QLatin1String("pingAircraftEngine"), argumentList);
181 }
182
185 {
186 QList<QVariant> argumentList;
187 argumentList << QVariant::fromValue(model);
188 return asyncCallWithArgumentList(QLatin1String("pingAircraftModel"), argumentList);
189 }
190
193 {
194 QList<QVariant> argumentList;
195 argumentList << QVariant::fromValue(model);
196 return asyncCallWithArgumentList(QLatin1String("pingAircraftModelList"), argumentList);
197 }
198
201 {
202 QList<QVariant> argumentList;
203 argumentList << QVariant::fromValue(aircraft);
204 return asyncCallWithArgumentList(QLatin1String("pingSimulatedAircraft"), argumentList);
205 }
206
209 {
210 QList<QVariant> argumentList;
211 argumentList << QVariant::fromValue(info);
212 return asyncCallWithArgumentList(QLatin1String("pingPluginInfo"), argumentList);
213 }
214
217 {
218 QList<QVariant> argumentList;
219 argumentList << QVariant::fromValue(atcStationList);
220 return asyncCallWithArgumentList(QLatin1String("pingAtcStationList"), argumentList);
221 }
222
225 {
226 QList<QVariant> argumentList;
227 argumentList << QVariant::fromValue(speed);
228 return asyncCallWithArgumentList(QLatin1String("pingSpeed"), argumentList);
229 }
230
233 {
234 QList<QVariant> argumentList;
235 argumentList << QVariant::fromValue(aircraftList);
236 return asyncCallWithArgumentList(QLatin1String("pingAircraftList"), argumentList);
237 }
238
241 {
242 QList<QVariant> argumentList;
243 argumentList << QVariant::fromValue(airportList);
244 return asyncCallWithArgumentList(QLatin1String("pingAirportList"), argumentList);
245 }
246
249 {
250 QList<QVariant> argumentList;
251 argumentList << QVariant::fromValue(clientList);
252 return asyncCallWithArgumentList(QLatin1String("pingClientList"), argumentList);
253 }
254
256 {
257 QList<QVariant> argumentList;
258 argumentList << QVariant::fromValue(client);
259 return asyncCallWithArgumentList(QLatin1String("pingClient"), argumentList);
260 }
261
263 {
264 QList<QVariant> argumentList;
265 argumentList << QVariant::fromValue(variant);
266 return asyncCallWithArgumentList(QLatin1String("pingCVariant"), argumentList);
267 }
268
270 {
271 QList<QVariant> argumentList;
272 argumentList << QVariant::fromValue(index);
273 return asyncCallWithArgumentList(QLatin1String("pingPropertyIndex"), argumentList);
274 }
275
278 {
279 QList<QVariant> argumentList;
280 argumentList << QVariant::fromValue(indexVariantMap);
281 return asyncCallWithArgumentList(QLatin1String("pingIndexVariantMap"), argumentList);
282 }
283
285 {
286 QList<QVariant> argumentList;
287 argumentList << QVariant::fromValue(flightPlan);
288 return asyncCallWithArgumentList(QLatin1String("pingFlightPlan"), argumentList);
289 }
290
293 {
294 QList<QVariant> argumentList;
295 argumentList << QVariant::fromValue(altitude);
296 return asyncCallWithArgumentList(QLatin1String("receiveAltitude"), argumentList);
297 }
298
300 {
301 QList<QVariant> argumentList;
302 argumentList << QVariant::fromValue(station);
303 return asyncCallWithArgumentList(QLatin1String("receiveAtcStation"), argumentList);
304 }
305
307 {
308 QList<QVariant> argumentList;
309 argumentList << QVariant::fromValue(atcStationList);
310 return asyncCallWithArgumentList(QLatin1String("receiveAtcStationList"), argumentList);
311 }
312
314 {
315 QList<QVariant> argumentList;
316 argumentList << QVariant::fromValue(callsign);
317 return asyncCallWithArgumentList(QLatin1String("receiveCallsign"), argumentList);
318 }
319
321 {
322 QList<QVariant> argumentList;
323 argumentList << QVariant::fromValue(comUnit);
324 return asyncCallWithArgumentList(QLatin1String("receiveComUnit"), argumentList);
325 }
326
328 {
329 QList<QVariant> argumentList;
330 argumentList << QVariant::fromValue(geo);
331 return asyncCallWithArgumentList(QLatin1String("receiveGeoPosition"), argumentList);
332 }
333
335 {
336 QList<QVariant> argumentList;
337 argumentList << QVariant::fromValue(length);
338 return asyncCallWithArgumentList(QLatin1String("receiveLength"), argumentList);
339 }
340
342 {
343 QList<QVariant> argumentList;
344 argumentList << QVariant::fromValue(list);
345 return asyncCallWithArgumentList(QLatin1String("receiveVariantList"), argumentList);
346 }
347
349 {
350 QList<QVariant> argumentList;
351 argumentList << QVariant::fromValue(list);
352 return asyncCallWithArgumentList(QLatin1String("receiveList"), argumentList);
353 }
354
356 {
357 QList<QVariant> argumentList;
358 argumentList << QVariant::fromValue(speed);
359 return asyncCallWithArgumentList(QLatin1String("receiveSpeed"), argumentList);
360 }
361
363 {
364 QList<QVariant> argumentList;
365 argumentList << QVariant::fromValue(message);
366 return asyncCallWithArgumentList(QLatin1String("receiveStringMessage"), argumentList);
367 }
368
370 {
371 QList<QVariant> argumentList;
372 argumentList << QVariant::fromValue(track);
373 return asyncCallWithArgumentList(QLatin1String("receiveTrack"), argumentList);
374 }
375
377 {
378 QList<QVariant> argumentList;
379 argumentList << QVariant::fromValue(transponder);
380 return asyncCallWithArgumentList(QLatin1String("receiveTransponder"), argumentList);
381 }
382
384 {
385 QList<QVariant> argumentList;
386 argumentList << QVariant::fromValue(valueMap);
387 return asyncCallWithArgumentList(QLatin1String("receiveValueMap"), argumentList);
388 }
389
390 QDBusPendingReply<> receiveVariant(const QDBusVariant &variant, int localMetyType)
391 {
392 QList<QVariant> argumentList;
393 argumentList << QVariant::fromValue(variant) << QVariant::fromValue(localMetyType);
394 return asyncCallWithArgumentList(QLatin1String("receiveVariant"), argumentList);
395 }
396
397
398 signals:
400 void sendStringMessage(const QString &message);
401
402 private:
404 static const char *InterfaceName();
405
407 template <class ValueObject>
408 static bool pingCompare(const ValueObject &in, const ValueObject &out, QTextStream &ts, bool verbose,
409 int &errors)
410 {
411 const bool equal = (in == out && extraCompare(in, out));
412 if (!equal)
413 {
414 errors++;
415 if (verbose)
416 {
417 ts << "I: " << in.toQString() << Qt::endl << "O: " << out.toQString() << Qt::endl;
418 }
419 }
420 return equal;
421 }
422
425 template <class ValueObject>
426 static bool extraCompare(const ValueObject &, const ValueObject &)
427 {
428 return true;
429 }
430
431 static bool extraCompare(const swift::misc::aviation::CFlightPlan &in,
433 {
434 // flight plan: check units are preserved
435 if (in.getEnrouteTime().getUnit() != out.getEnrouteTime().getUnit())
436 {
437 return false;
438 }
439 if (in.getFuelTime().getUnit() != out.getFuelTime().getUnit())
440 {
441 return false;
442 }
444 {
445 return false;
446 }
448 {
449 return false;
450 }
451 return true;
452 }
454
456 static const QString &errorInfo(bool ok);
457 };
458} // namespace swift::misc::test
459#endif // SWIFT_MISC_TEST_TESTSERVICEINTERFACE_H
Specialized value object compliant map for variants, based on indexes.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition variant.h:69
Value object encapsulating a list of variants.
Definition variantlist.h:29
Value object encapsulating information about aircraft's engines.
Value object for ICAO classification.
Value object encapsulating information about aircraft's lights.
Value object encapsulating information of aircraft's parts.
Value object encapsulating information of an aircraft's situation.
Value object for a list of airports.
Definition airportlist.h:29
Altitude as used in aviation, can be AGL or MSL altitude.
Definition altitude.h:52
Value object encapsulating information about an ATC station.
Definition atcstation.h:38
Value object for a list of ATC stations.
Value object encapsulating information of a callsign.
Definition callsign.h:30
COM system (aka "radio").
Definition comsystem.h:37
Value object for a flight plan.
Definition flightplan.h:148
const CAltitude & getCruiseAltitude() const
Cruising altitudes.
Definition flightplan.h:348
const physical_quantities::CTime & getEnrouteTime() const
Get planned enroute flight time.
Definition flightplan.h:330
const physical_quantities::CSpeed & getCruiseTrueAirspeed() const
Get planned cruise TAS.
Definition flightplan.h:354
const physical_quantities::CTime & getFuelTime() const
Get amount of fuel load in time.
Definition flightplan.h:339
Track as used in aviation, can be true or magnetic Track.
Definition track.h:44
Another client software.
Definition client.h:27
Value object encapsulating a list of voice rooms.
Definition clientlist.h:27
Value object encapsulating information of a user.
Definition user.h:28
Physical unit length (length).
Definition length.h:18
Aircraft model (used by another pilot, my models on disk).
Value object encapsulating a list of aircraft models.
Comprehensive information of an aircraft.
Value object encapsulating a list of aircraft.
QDBusPendingReply< swift::misc::aviation::CAircraftLights > pingAircraftLights(const swift::misc::aviation::CAircraftLights &lights)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CTransponder > pingTransponder(const swift::misc::aviation::CTransponder &transponder)
DBus calls.
QDBusPendingReply receiveAtcStation(const swift::misc::aviation::CAtcStation &station)
DBus calls.
QDBusPendingReply receiveStringMessage(const QString &message)
DBus calls.
QDBusPendingReply< swift::misc::simulation::CAircraftModelList > pingAircraftModelList(const swift::misc::simulation::CAircraftModelList &model)
DBus calls.
QDBusPendingReply< swift::misc::simulation::CSimulatedAircraftList > pingAircraftList(const swift::misc::simulation::CSimulatedAircraftList &aircraftList)
DBus calls.
QDBusPendingReply receiveSpeed(const swift::misc::physical_quantities::CSpeed &speed)
DBus calls.
QDBusPendingReply< swift::misc::simulation::CSimulatorPluginInfo > pingPluginInfo(const swift::misc::simulation::CSimulatorPluginInfo &info)
DBus calls.
void sendStringMessage(const QString &message)
send message
QDBusPendingReply< swift::misc::physical_quantities::CSpeed > pingSpeed(const swift::misc::physical_quantities::CSpeed &speed)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAltitude > receiveAltitude(const swift::misc::aviation::CAltitude &altitude)
DBus calls.
QDBusPendingReply< swift::misc::network::CClientList > pingClientList(const swift::misc::network::CClientList &clientList)
DBus calls.
QDBusPendingReply receiveVariantList(const swift::misc::CVariantList &list)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAircraftEngine > pingAircraftEngine(const swift::misc::aviation::CAircraftEngine &engine)
DBus calls.
QDBusPendingReply receiveCallsign(const swift::misc::aviation::CCallsign &callsign)
DBus calls.
QDBusPendingReply receiveLength(const swift::misc::physical_quantities::CLength &length)
DBus calls.
QDBusPendingReply receiveList(const QList< double > &list)
DBus calls.
QDBusPendingReply receiveComUnit(const swift::misc::aviation::CComSystem &comUnit)
DBus calls.
ITestServiceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent=nullptr)
Constructor.
QDBusPendingReply< swift::misc::physical_quantities::CSpeed > getSpeed()
DBus calls.
QDBusPendingReply< swift::misc::simulation::CSimulatedAircraft > pingSimulatedAircraft(const swift::misc::simulation::CSimulatedAircraft &aircraft)
DBus calls.
QDBusPendingReply receiveGeoPosition(const swift::misc::geo::CCoordinateGeodetic &geo)
DBus calls.
QDBusPendingReply receiveTransponder(const swift::misc::aviation::CTransponder &transponder)
DBus calls.
QDBusPendingReply< swift::misc::CVariant > pingCVariant(const swift::misc::CVariant &variant)
DBus calls.
QDBusPendingReply< swift::misc::CPropertyIndex > pingPropertyIndex(const swift::misc::CPropertyIndex &index)
DBus calls.
QDBusPendingReply< swift::misc::CPropertyIndexVariantMap > pingIndexVariantMap(const swift::misc::CPropertyIndexVariantMap &indexVariantMap)
DBus calls.
QDBusPendingReply< swift::misc::network::CUser > pingUser(const swift::misc::network::CUser &user)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAtcStationList > getAtcStationList(int number)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAtcStationList > pingAtcStationList(const swift::misc::aviation::CAtcStationList &atcStationList)
DBus calls.
QDBusPendingReply receiveAtcStationList(const swift::misc::aviation::CAtcStationList &atcStationList)
DBus calls.
QDBusPendingReply receiveTrack(const swift::misc::aviation::CTrack &track)
DBus calls.
QDBusPendingReply< swift::misc::simulation::CAircraftModel > pingAircraftModel(const swift::misc::simulation::CAircraftModel &model)
DBus calls.
static int pingTests(ITestServiceInterface &testServiceInterface, bool verbose)
Ping via DBus, tests object marshalling/unmarshalling.
QDBusPendingReply< swift::misc::aviation::CAircraftIcaoCode > pingAircraftIcaoData(const swift::misc::aviation::CAircraftIcaoCode &icaoData)
DBus calls.
QDBusPendingReply< swift::misc::network::CClient > pingClient(const swift::misc::network::CClient &client)
DBus calls.
QDBusPendingReply receiveVariant(const QDBusVariant &variant, int localMetyType)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAirportList > pingAirportList(const swift::misc::aviation::CAirportList &airportList)
DBus calls.
~ITestServiceInterface()=default
Destructor.
QDBusPendingReply< swift::misc::aviation::CAtcStation > getAtcStation()
DBus calls.
QDBusPendingReply receiveValueMap(const swift::misc::CPropertyIndexVariantMap &valueMap)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CFlightPlan > pingFlightPlan(const aviation::CFlightPlan &flightPlan)
DBus calls.
QDBusPendingReply< QList< QDBusObjectPath > > getObjectPaths(int number)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAircraftParts > pingAircraftParts(const swift::misc::aviation::CAircraftParts &parts)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAtcStation > pingAtcStation(const swift::misc::aviation::CAtcStation &station)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAltitude > pingAltitude(const swift::misc::aviation::CAltitude &altitude)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAircraftSituation > pingSituation(const swift::misc::aviation::CAircraftSituation &situation)
DBus calls.
QDBusPendingReply< swift::misc::simulation::fscommon::CAircraftCfgEntriesList > getAircraftCfgEntriesList(int number)
DBus calls.
Generate data for testing purposes.
Definition testdata.h:45
Free functions in swift::misc.
QDBusPendingCall asyncCallWithArgumentList(const QString &method, const QList< QVariant > &args)
QDBusConnection connection() const const
QString path() const const
QString service() const const
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
QTextStream & endl(QTextStream &stream)
QVariant fromValue(T &&value)
#define SWIFT_MISC_EXPORT
Export a class or function from the library.