- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
207 lines
6.1 KiB
C++
Executable File
207 lines
6.1 KiB
C++
Executable File
/**
|
|
* AES Function Topic Client test executable
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "aes_test_base.h"
|
|
#include <nglapplication/nglcoreapplication.h>
|
|
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
|
#include <QTimer>
|
|
#include <QtTest/QTest>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
|
|
TestBase::TestBase(const char *loggerName, QObject *parent)
|
|
: QObject(parent)
|
|
, m_expectedAesId(-1)
|
|
, m_bIsCreatedRequest(false)
|
|
, m_bExpectedFailure(false)
|
|
, m_replyError(false)
|
|
, m_bTestsSuccessful(true)
|
|
, m_testId(0)
|
|
, m_aesTypeName(QString::fromLatin1(loggerName).splitRef(QLatin1Char('.')).last().toString())
|
|
, m_logger(getLogger(loggerName))
|
|
{}
|
|
|
|
|
|
bool TestBase::init(int domainId, int exerciseId, int testId)
|
|
{
|
|
INFO_LOG() << "init begin";
|
|
m_testId = testId;
|
|
|
|
// initialize DDS
|
|
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId));
|
|
if (!m_ddsConnector->init())
|
|
return false;
|
|
m_ddsConnector->initPublisherSubscriber();
|
|
|
|
INFO_LOG() << "init create ftc";
|
|
m_ftc = AreaEffectSimulation::Interface::Ftc::create(m_ddsConnector);
|
|
INFO_LOG() << "init init ftc";
|
|
bool bRet = m_ftc->enableAll();
|
|
|
|
m_dtc = AreaEffectSimulation::Interface::Dtc::create(m_ddsConnector);
|
|
bRet = bRet && m_dtc->enableAll();
|
|
|
|
INFO_LOG() << "init end - bRet = " << bRet;
|
|
return bRet;
|
|
}
|
|
|
|
bool TestBase::waitForData(const std::function<bool()> &func)
|
|
{
|
|
// wait for data
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
if (func())
|
|
return true;
|
|
QTest::qWait(100);
|
|
}
|
|
return func();
|
|
}
|
|
|
|
bool TestBase::checkAesItem(const AreaEffectSimulation::AesItem &a,
|
|
const AreaEffectSimulation::AesItem &b) const
|
|
{
|
|
if (a.name() != b.name())
|
|
{
|
|
WARNING_LOG() << "name does not match: " << a.name() << " - " << b.name();
|
|
return false;
|
|
}
|
|
if (a.effectStart() != b.effectStart())
|
|
{
|
|
WARNING_LOG() << "effectStart does not match: " << a.effectStart() << " - " << b.effectStart();
|
|
return false;
|
|
}
|
|
if (a.chargeStruct().chargeTypeId() != b.chargeStruct().chargeTypeId())
|
|
{
|
|
WARNING_LOG() << "chargeTypeId does not match: " << a.chargeStruct().chargeTypeId() << " - " << b.chargeStruct().chargeTypeId();
|
|
return false;
|
|
}
|
|
if (a.partyId() != b.partyId())
|
|
{
|
|
WARNING_LOG() << "partyId does not match: " << a.partyId() << " - " << b.partyId();
|
|
return false;
|
|
}
|
|
if (a.participantId() != b.participantId())
|
|
{
|
|
WARNING_LOG() << "participantId does not match: " << a.participantId() << " - " << b.participantId();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void TestBase::failExit()
|
|
{
|
|
ERROR_LOG() << "fail exit!";
|
|
m_bTestsSuccessful = false;
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
}
|
|
|
|
void TestBase::onAesCreateReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG() << "Got create " << m_aesTypeName << " reply with id " << replyObject.id()
|
|
<< ", error = " << replyObject.error()
|
|
<< " and errorString = '" << replyObject.translated() << "'";
|
|
m_replyError = replyObject.error();
|
|
if (m_replyError && !m_bExpectedFailure)
|
|
ERROR_LOG() << "Got create " << m_aesTypeName << " reply error: " << replyObject();
|
|
else
|
|
m_expectedAesId = replyObject.id(); // only works as expected because reply is sent before publishing data occours
|
|
}
|
|
|
|
void TestBase::onAesModifyReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
if (m_expectedAesId != replyObject.id())
|
|
return;
|
|
INFO_LOG() << "Got modify " << m_aesTypeName << " reply with id " << replyObject.id()
|
|
<< ", error = " << replyObject.error()
|
|
<< " and errorString = '" << replyObject.translated() << "'";
|
|
m_replyError = replyObject.error();
|
|
if (m_replyError && !m_bExpectedFailure)
|
|
ERROR_LOG() << "Got modify " << m_aesTypeName << " reply error: " << replyObject();
|
|
else
|
|
m_expectedAesId = replyObject.id();
|
|
}
|
|
|
|
void TestBase::onAesRemoveReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG() << "Got remove " << m_aesTypeName << " reply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
m_replyError = replyObject.error();
|
|
if (m_replyError && !m_bExpectedFailure)
|
|
ERROR_LOG() << "Got remove " << m_aesTypeName << " reply error: " << replyObject();
|
|
else
|
|
m_expectedAesId = replyObject.id();
|
|
}
|
|
|
|
void TestBase::onAesTriggerReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG() << "Got trigger " << m_aesTypeName << " reply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
m_replyError = replyObject.error();
|
|
if (m_replyError && !m_bExpectedFailure)
|
|
ERROR_LOG() << "Got remove " << m_aesTypeName << " reply error: " << replyObject();
|
|
else
|
|
m_expectedAesId = replyObject.id();
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
|
{
|
|
public:
|
|
CmdLineParser()
|
|
: LtsCommandLineParser()
|
|
{
|
|
addOption( { QStringList() << QLatin1String("t") << QLatin1String("testId")
|
|
, QLatin1String("TestId.")
|
|
, QLatin1String("Default: 0")
|
|
, QLatin1String("0")
|
|
} );
|
|
}
|
|
|
|
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : 0; }
|
|
};
|
|
|
|
// ------------------------------------------------------------------
|
|
int mainBase(int argc, char **argv,
|
|
const std::function<TestBase*()> &createFunc)
|
|
{
|
|
NGLCoreApplication app(argc, argv);
|
|
app.createLogger("AES", "log4cxx_aes.props");
|
|
|
|
CmdLineParser options;
|
|
if (!options.init())
|
|
return -1;
|
|
|
|
if (options.exerciseId() <= 0)
|
|
{
|
|
fprintf(stderr, "ExerciseId not set!\n");
|
|
return -2;
|
|
}
|
|
|
|
int iRet = -1;
|
|
{
|
|
std::unique_ptr <TestBase> test(createFunc());
|
|
if (!test->init(options.domainId(), options.exerciseId(), options.testId()))
|
|
return iRet;
|
|
|
|
QTimer::singleShot(0, test.get(), &TestBase::startTest);
|
|
|
|
STARTUP_LOG(app.baseLogger());
|
|
|
|
app.exec();
|
|
|
|
iRet = test->testsSuccessful() ? 0 : 1;
|
|
fprintf(stderr, "%d\n", iRet);
|
|
|
|
SHUTDOWN_LOG(app.baseLogger());
|
|
}
|
|
|
|
return iRet;
|
|
}
|
|
|
|
} // namespace AreaEffectSimulation
|