From 6a2f08b49f54f8af0268d2647e79bcd36a768f10 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 26 Jul 2019 15:24:56 +0200 Subject: [PATCH] Ref T709, UNIT test for JSON settings --- .../simulation/testxplane/testxplane.cpp | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/blackmisc/simulation/testxplane/testxplane.cpp b/tests/blackmisc/simulation/testxplane/testxplane.cpp index d3f0e8404..edc196ef6 100644 --- a/tests/blackmisc/simulation/testxplane/testxplane.cpp +++ b/tests/blackmisc/simulation/testxplane/testxplane.cpp @@ -11,6 +11,7 @@ //! \ingroup testblackmisc #include "blackmisc/simulation/xplane/qtfreeutils.h" +#include "blackmisc/simulation/settings/xswiftbussettings.h" #include "blackmisc/directoryutils.h" #include "test.h" @@ -18,6 +19,7 @@ using namespace BlackMisc; using namespace BlackMisc::Simulation::XPlane::QtFreeUtils; +using namespace BlackMisc::Simulation::Settings; namespace BlackMiscTest { @@ -32,6 +34,7 @@ namespace BlackMiscTest void getBaseNameTest(); void splitTest(); void acfPropertiesTest(); + void xSwiftBusSettingsTest(); }; void CTestXPlane::getFileNameTest() @@ -97,6 +100,39 @@ namespace BlackMiscTest QCOMPARE(QString::fromStdString(acfProperties.modelName), QString("Beechcraft Baron 58")); QCOMPARE(QString::fromStdString(acfProperties.modelString), QString("swift project Beechcraft Baron 58")); } + + void CTestXPlane::xSwiftBusSettingsTest() + { + CXSwiftBusSettings s = CXSwiftBusSettings::defaultValue(); + s.setMaxPlanes(33); + s.setMaxDrawDistanceNM(11.11); + s.setDrawingLabels(false); + QString json = s.toXSwiftBusJsonStringQt(); + + qDebug() << json; + qDebug() << s.toQString(); + + CXSwiftBusSettings s2(json); + QCOMPARE(s.getMaxDrawDistanceNM(), s2.getMaxDrawDistanceNM()); + QCOMPARE(s.getMaxPlanes(), s2.getMaxPlanes()); + QCOMPARE(s.isDrawingLabels(), s2.isDrawingLabels()); + QCOMPARE(s.getDBusServerAddressQt(), s2.getDBusServerAddressQt()); + + s.setDBusServerAddressQt(CDBusServer::sessionBusAddress()); + json = s.toXSwiftBusJsonStringQt(); + s2 = CXSwiftBusSettings(json); + QCOMPARE(CDBusServer::sessionBusAddress(), s2.getDBusServerAddressQt()); + + // standard value object test + json = s.toJsonString(); // standard swift/Qt + qDebug() << json; + + s2.fromJson(json); + QCOMPARE(s.getMaxDrawDistanceNM(), s2.getMaxDrawDistanceNM()); + QCOMPARE(s.getMaxPlanes(), s2.getMaxPlanes()); + QCOMPARE(s.isDrawingLabels(), s2.isDrawingLabels()); + QCOMPARE(s.getDBusServerAddressQt(), s2.getDBusServerAddressQt()); + } } //! main