Ref T709, UNIT test for JSON settings

This commit is contained in:
Klaus Basan
2019-07-26 15:24:56 +02:00
committed by Mat Sutcliffe
parent dd6e14e2c8
commit 6a2f08b49f

View File

@@ -11,6 +11,7 @@
//! \ingroup testblackmisc //! \ingroup testblackmisc
#include "blackmisc/simulation/xplane/qtfreeutils.h" #include "blackmisc/simulation/xplane/qtfreeutils.h"
#include "blackmisc/simulation/settings/xswiftbussettings.h"
#include "blackmisc/directoryutils.h" #include "blackmisc/directoryutils.h"
#include "test.h" #include "test.h"
@@ -18,6 +19,7 @@
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Simulation::XPlane::QtFreeUtils; using namespace BlackMisc::Simulation::XPlane::QtFreeUtils;
using namespace BlackMisc::Simulation::Settings;
namespace BlackMiscTest namespace BlackMiscTest
{ {
@@ -32,6 +34,7 @@ namespace BlackMiscTest
void getBaseNameTest(); void getBaseNameTest();
void splitTest(); void splitTest();
void acfPropertiesTest(); void acfPropertiesTest();
void xSwiftBusSettingsTest();
}; };
void CTestXPlane::getFileNameTest() void CTestXPlane::getFileNameTest()
@@ -97,6 +100,39 @@ namespace BlackMiscTest
QCOMPARE(QString::fromStdString(acfProperties.modelName), QString("Beechcraft Baron 58")); QCOMPARE(QString::fromStdString(acfProperties.modelName), QString("Beechcraft Baron 58"));
QCOMPARE(QString::fromStdString(acfProperties.modelString), QString("swift project 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 //! main