Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(LinkedSources
|
||||
log4cxxTgtUnitTestShootback.props
|
||||
)
|
||||
|
||||
SET(UnitTest_SRCS
|
||||
unit_test.cpp
|
||||
unit_test.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP( LinkedSources FILES ${LinkedSources} )
|
||||
SOURCE_GROUP( UnitTestSources FILES ${UnitTest_SRCS} )
|
||||
|
||||
IF(BUILD_TESTING
|
||||
AND TARGET svcTgtClient
|
||||
AND TARGET svcCoreClient
|
||||
AND TARGET svcEemServer
|
||||
AND TARGET svcPpmServer
|
||||
AND TARGET svcTabServer
|
||||
)
|
||||
ADD_EXECUTABLE(tgtUnitTestShootback ${LinkedSources} ${UnitTest_SRCS} )
|
||||
|
||||
TARGET_LINK_LIBRARIES(tgtUnitTestShootback
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
Qt5::Network
|
||||
RTI::nddscpp2
|
||||
|
||||
NGLLogger
|
||||
nglapplication
|
||||
|
||||
ddsconnector
|
||||
svcTgtClient
|
||||
svcCoreClient
|
||||
svcEemServer
|
||||
svcPpmServer
|
||||
svcTabServer
|
||||
LtsCommandLineParser
|
||||
)
|
||||
ADD_TEST(NAME tgtUnitTestShootback COMMAND $<TARGET_FILE:tgtUnitTestShootback>)
|
||||
|
||||
ENDIF()
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file, stdout
|
||||
|
||||
# TGT
|
||||
###########################################################
|
||||
log4j.logger.TGT.UnitTestShootback=DEBUG
|
||||
|
||||
|
||||
|
||||
|
||||
# Appnd_File
|
||||
###########################################################
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.file=${LOG4QT_LOGDIR}/${LOG4QT_USER}_SituationMap.log
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %-5p %c{1} |#| %m (%-.30F:%L) %n
|
||||
|
||||
#log4j.appender.stdout.layout.ConversionPattern= %d %-5p %-30c |#| %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
|
||||
@@ -0,0 +1,949 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Unittest
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
|
||||
#include <TargetManagement/shootback_controller.h>
|
||||
|
||||
#include <QtTest/QTest>
|
||||
#include <QtTest/QSignalSpy>
|
||||
#include <QWeakPointer>
|
||||
|
||||
#include <nglapplication/nglapplication.h>
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QFlags>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
const int g_targetParticipantId_1 = 5;
|
||||
const int g_targetParticipantId_2 = 6;
|
||||
|
||||
const int g_movingParticipantId_1 = 30;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLApplication app(argc, argv);
|
||||
app.createLogger("TgtUnitTestShootback", "log4cxxTgtUnitTestShootback.props");
|
||||
|
||||
CmdLineParser options;
|
||||
|
||||
// C O M M E N T :
|
||||
// To use the domainId and exerciseId via CmdLineParser AND
|
||||
// support also parameter for QTest::qExec do not return
|
||||
// if options.init() fails...
|
||||
if(!options.init())
|
||||
{
|
||||
fprintf(stdout, "\n \e[33m usage: try -v2 testTargetAreaAssignment -d 111 -e 222 \e[0m");
|
||||
fprintf(stdout, "\n \e[33m -functions \e[0m \n\n");
|
||||
}
|
||||
|
||||
int domainId = options.value(QStringLiteral("d")).toInt();
|
||||
int exerciseId = options.value(QStringLiteral("e")).toInt();
|
||||
if (exerciseId<0)
|
||||
exerciseId = 42;
|
||||
|
||||
QSharedPointer<TargetManagement::tgtTestShootbackTarget> tc =
|
||||
QSharedPointer<TargetManagement::tgtTestShootbackTarget>(new TargetManagement::tgtTestShootbackTarget());
|
||||
|
||||
tc->setPara(domainId, exerciseId);
|
||||
|
||||
if (options.domainIdProvided())
|
||||
argc -= 2;
|
||||
if (options.exerciseIdProvided())
|
||||
argc -= 2;
|
||||
// : C O M M E N T
|
||||
|
||||
int retCode = QTest::qExec(tc.data(), argc, argv);
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
tgtTestShootbackTarget::tgtTestShootbackTarget()
|
||||
: m_logger(getLogger("UnitTestShootback"))
|
||||
{
|
||||
// register some datatypes QSignalSpy
|
||||
qRegisterMetaType<DataModification>("DataModification");
|
||||
qRegisterMetaType<TargetManagement::ShootbackArea>("TargetManagement::ShootbackArea");
|
||||
qRegisterMetaType<TargetManagement::ShootbackTarget>("TargetManagement::ShootbackTarget");
|
||||
qRegisterMetaType<TargetManagement::TargetAreaAssignment>("TargetManagement::TargetAreaAssignment");
|
||||
}
|
||||
|
||||
tgtTestShootbackTarget::~tgtTestShootbackTarget()
|
||||
{
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::initTestCase()
|
||||
{
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " do testing with"
|
||||
<< " domainId=" << m_domainId
|
||||
<< " exerciseId=" << m_exerciseId;
|
||||
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(m_domainId, IDL::PartitionType::Exercise, m_exerciseId));
|
||||
if (!m_ddsConnector->init())
|
||||
return;
|
||||
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
m_ftcTgt = TargetManagement::Interface::Ftc::create(m_ddsConnector);
|
||||
bool bRet = m_ftcTgt->enableAll();
|
||||
|
||||
m_dtcTgt = TargetManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_dtcTgt->enableAll();
|
||||
|
||||
m_dtsPpm = ParticipantManagement::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsPpm->enableAll();
|
||||
|
||||
m_dtsTab = TrainingAreaBase::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsTab->enableAll();
|
||||
|
||||
// time to process changed-signals:
|
||||
QTest::qWait(2000);
|
||||
|
||||
removeTestObjects();
|
||||
|
||||
if (!bRet)
|
||||
FATAL_LOG(m_logger) << LOGFUNCTION << " init failed!!!";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::testShootbackArea()
|
||||
{
|
||||
ShootbackAreaModifyRequest request;
|
||||
|
||||
request.id(0); // force create
|
||||
request.name("UnitTest ShootbackArea");
|
||||
double lon = 0.15530364;
|
||||
double lat = 0.92601523;
|
||||
request.position().lon(lon);
|
||||
request.position().lat(lat);
|
||||
request.width(100);
|
||||
request.height(100);
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackAreaModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackAreaModifyRequest failed");
|
||||
checkShootbackAreaChangedWasEmitted(1, __LINE__);
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " got m_replyShootbackAreaId: " << m_replyShootbackAreaId;
|
||||
|
||||
|
||||
// modify
|
||||
request.id(m_replyShootbackAreaId);
|
||||
request.name("UnitTest ShootbackAreaModified");
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackAreaModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
checkShootbackAreaChangedWasEmitted(1, __LINE__);
|
||||
|
||||
// verify mod
|
||||
{
|
||||
TargetManagement::ShootbackArea modData = m_dtcTgt->shootbackArea(m_replyShootbackAreaId);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "modData=" << modData;
|
||||
QVERIFY2((modData.id() == m_replyShootbackAreaId), " shootbackArea failed");
|
||||
QVERIFY2((modData.name().compare(request.name()) == 0), " verify name failed");
|
||||
}
|
||||
}
|
||||
|
||||
// remove
|
||||
{
|
||||
ShootbackAreaRemoveRequest request;
|
||||
request.id(m_replyShootbackAreaId); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->shootbackAreaRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
checkShootbackAreaChangedWasEmitted(1, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testShootbackTarget()
|
||||
{
|
||||
ShootbackTargetModifyRequest request;
|
||||
|
||||
request.id(0); // force create
|
||||
// request.targetParticipantId(); // here would be the reference to the orbat
|
||||
request.name("UnitTest ShootbackTarget");
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackTargetModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackTargetModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " got m_replyShootbackTargetId: " << m_replyShootbackTargetId;
|
||||
|
||||
|
||||
// modify
|
||||
request.id(m_replyShootbackTargetId);
|
||||
request.name("UnitTest ShootbackTargetModified");
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackTargetModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "spy.count()=" << spy.count();
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
|
||||
// verify mod
|
||||
{
|
||||
TargetManagement::ShootbackTarget modData = m_dtcTgt->shootbackTarget(m_replyShootbackTargetId);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "modData=" << modData;
|
||||
QVERIFY2((modData.id() == m_replyShootbackTargetId), " shootbackTarget failed");
|
||||
QVERIFY2((modData.name().compare(request.name()) == 0), " verify name failed");
|
||||
}
|
||||
}
|
||||
|
||||
// remove
|
||||
{
|
||||
ShootbackTargetRemoveRequest request;
|
||||
request.id(m_replyShootbackTargetId); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->shootbackTargetRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testTargetAreaAssignment()
|
||||
{
|
||||
TargetAreaAssignmentModifyRequest request;
|
||||
|
||||
// try to create
|
||||
request.id(0); // force create
|
||||
request.name("UnitTest TargetAreaAssignment");
|
||||
|
||||
// create
|
||||
{
|
||||
request.id(0); // force create
|
||||
request.name(QString(QStringLiteral("UnitTest-Assignment1")).toStdString());
|
||||
request.areaId(4711);
|
||||
request.targetParticipantId(4712);
|
||||
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "spy.count()=" << spy.count();
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
|
||||
m_assignmentId1 = m_replyTargetAreaAssignmentId;
|
||||
}
|
||||
|
||||
|
||||
// modify
|
||||
request.id(m_assignmentId1);
|
||||
request.name("UnitTest-Assignment1_Modified");
|
||||
{
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "spy.count()=" << spy.count();
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
|
||||
// verify mod
|
||||
{
|
||||
TargetManagement::TargetAreaAssignment modData = m_dtcTgt->targetAreaAssignment(m_replyTargetAreaAssignmentId);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "modData=" << modData;
|
||||
QVERIFY2((modData.id() == m_replyTargetAreaAssignmentId), " targetAreaAssignment failed");
|
||||
QVERIFY2((modData.name().compare(request.name()) == 0), " verify name failed");
|
||||
}
|
||||
}
|
||||
|
||||
// remove
|
||||
{
|
||||
TargetAreaAssignmentRemoveRequest request;
|
||||
request.id(m_replyTargetAreaAssignmentId); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::removeTestObjects()
|
||||
{
|
||||
// first, remove all TargetAreaAssignments:
|
||||
{
|
||||
QMap<qint32, TargetManagement::TargetAreaAssignment> allObj = m_dtcTgt->targetAreaAssignments();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove... (" << allObj.size() << " TargetAreaAssignments)";
|
||||
for (auto item: qAsConst(allObj))
|
||||
if (item.name().substr(0, 8).compare("UnitTest") == 0)
|
||||
removeAssignment(item.id());
|
||||
QTest::qWait(250); // time to process reply
|
||||
allObj = m_dtcTgt->targetAreaAssignments();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove targetAreaAssignments finished -> " << allObj.size() << " TargetAreaAssignments";
|
||||
}
|
||||
|
||||
// remove all Areas:
|
||||
{
|
||||
QMap<qint32, TargetManagement::ShootbackArea> allObj = m_dtcTgt->shootbackAreas();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove... (" << allObj.size() << " Areas)";
|
||||
for (auto item: qAsConst(allObj))
|
||||
if (item.name().substr(0, 8).compare("UnitTest") == 0)
|
||||
removeArea(item.id());
|
||||
QTest::qWait(250); // time to process reply
|
||||
allObj = m_dtcTgt->shootbackAreas();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove shootbackAreas finished -> " << allObj.size() << " Areas";
|
||||
}
|
||||
|
||||
// remove all Targets:
|
||||
{
|
||||
QMap<qint32, TargetManagement::ShootbackTarget> allObj = m_dtcTgt->shootbackTargets();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove... (" << allObj.size() << " Targets)";
|
||||
for (auto item: qAsConst(allObj))
|
||||
if (item.name().substr(0, 8).compare("UnitTest") == 0)
|
||||
removeTarget(item.id());
|
||||
QTest::qWait(250); // time to process reply
|
||||
|
||||
allObj = m_dtcTgt->shootbackTargets();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove shootbackTargets finished -> " << allObj.size() << " Targets";
|
||||
}
|
||||
QTest::qWait(1000); // time to process
|
||||
}
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::createArea(int &areaIdInOut, const QString &name, double lon, double lat)
|
||||
{
|
||||
m_replyShootbackAreaId = -1;
|
||||
|
||||
ShootbackAreaModifyRequest request;
|
||||
|
||||
request.id(areaIdInOut);
|
||||
request.name(name.toStdString());
|
||||
request.position().lon(lon);
|
||||
request.position().lat(lat);
|
||||
request.width(100);
|
||||
request.height(100);
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackAreaModifyRequest(request, this);
|
||||
|
||||
qCritical() << "shootbackAreaModifyRequest ret= " << ret;
|
||||
|
||||
QVERIFY2((ret != 0), " shootbackAreaModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackAreaChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " got m_replyShootbackAreaId: " << m_replyShootbackAreaId;
|
||||
|
||||
areaIdInOut = m_replyShootbackAreaId;
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::modifyArea(int &areaId, const QString &name, double lon, double lat)
|
||||
{
|
||||
ShootbackAreaModifyRequest request;
|
||||
|
||||
request.id(areaId);
|
||||
request.name(name.toStdString());
|
||||
request.position().lon(lon);
|
||||
request.position().lat(lat);
|
||||
|
||||
// create/modify
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackAreaModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackAreaModifyRequest failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::removeArea(int areaId, bool checkUsingSpy)
|
||||
{
|
||||
ShootbackAreaRemoveRequest request;
|
||||
request.id(areaId);
|
||||
|
||||
int32_t ret = m_ftcTgt->shootbackAreaRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
if (checkUsingSpy)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackAreaChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::createTarget(int &targetIdOut, int targetParticipantId, const QString &name)
|
||||
{
|
||||
ShootbackTargetModifyRequest request;
|
||||
|
||||
request.id(targetIdOut); // force create !?
|
||||
request.targetParticipantId(targetParticipantId);
|
||||
request.name(name.toStdString());
|
||||
request.position(Core::GeoPosition(0.149276, 0.92622, 50.0)); // 0.149276, 0.92622 -> 32u MD 70000 80000 -> 31m
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackTargetModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackTargetModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " got m_replyShootbackTargetId: " << m_replyShootbackTargetId;
|
||||
|
||||
targetIdOut = m_replyShootbackTargetId;
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::modifyTarget(int targetId, int targetParticipantId, const QString &name, double lon, double lat, double z)
|
||||
{
|
||||
ShootbackTargetModifyRequest request;
|
||||
|
||||
request.id(targetId);
|
||||
request.targetParticipantId(targetParticipantId);
|
||||
request.name(name.toStdString());
|
||||
request.position(Core::GeoPosition(lon, lat, z)); // 0.149276, 0.92622 -> 32u MD 70000 80000 -> 31m
|
||||
|
||||
// modify
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackTargetModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackTargetModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::removeTarget(int targetId, bool checkUsingSpy)
|
||||
{
|
||||
ShootbackTargetRemoveRequest request;
|
||||
request.id(targetId); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->shootbackTargetRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
if (checkUsingSpy)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::createAssignment(int areaId, int targetParticipantId, int &assignmentIdOut, const QString &name)
|
||||
{
|
||||
TargetAreaAssignmentModifyRequest request;
|
||||
|
||||
request.id(assignmentIdOut); // force create !?
|
||||
request.name(name.toStdString());
|
||||
request.areaId(areaId);
|
||||
request.targetParticipantId(targetParticipantId);
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " targetAreaAssignmentModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " got m_replyTargetAreaAssignmentId: " << m_replyTargetAreaAssignmentId;
|
||||
|
||||
assignmentIdOut = m_replyTargetAreaAssignmentId;
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::modifyAssignment(int areaId, int targetParticipantId, int &assignmentId, const QString &name)
|
||||
{
|
||||
TargetAreaAssignmentModifyRequest request;
|
||||
|
||||
request.id(assignmentId);
|
||||
request.name(name.toStdString());
|
||||
request.areaId(areaId);
|
||||
request.targetParticipantId(targetParticipantId);
|
||||
|
||||
// modify
|
||||
{
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " targetAreaAssignmentModifyRequest failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::removeAssignment(int id, bool checkUsingSpy)
|
||||
{
|
||||
TargetAreaAssignmentRemoveRequest request;
|
||||
request.id(id); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
if (checkUsingSpy)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int32_t> tgtTestShootbackTarget::visiParticpantsOfTarget(int targetId)
|
||||
{
|
||||
TargetManagement::ShootbackTarget sbTarget = m_dtcTgt->shootbackTarget(targetId);
|
||||
return sbTarget.visibleParticipants();
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::moveParticipant(int participantId, double lon, double lat)
|
||||
{
|
||||
if (!m_dtsPpm)
|
||||
return;
|
||||
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " move Participant: id = " << participantId;
|
||||
ParticipantManagement::ParticipantPosition posReq;
|
||||
posReq.participantId(participantId);
|
||||
posReq.sampleTime(currentSampleTime());
|
||||
posReq.pos(Core::GeoPosition(lon, lat, 50.12345));
|
||||
posReq.partyId(2); // 0 and 1 will be skipped
|
||||
if (!m_dtsPpm->publish(posReq))
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " Error publish posReq";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::checkShootbackAreaChangedWasEmitted(int number, int line)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackAreaChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(1000);
|
||||
QString msg = QString(QStringLiteral("Area-Spy failed: %1 of %2 (line=%3)")).arg(spy.count()).arg(number).arg(line);
|
||||
QVERIFY2((spy.count() == number), msg.toStdString().c_str());
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::checkShootbackTargetChangedWasEmitted(int number, int line)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(1000);
|
||||
QString msg = QString(QStringLiteral("Target-Spy failed: %1 of %2 (line=%3)")).arg(spy.count()).arg(number).arg(line);
|
||||
QVERIFY2((spy.count() == number), msg.toStdString().c_str());
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::checkAssignmentChangedWasEmitted(int number, int line)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(1000);
|
||||
QString msg = QString(QStringLiteral("Assignment-Spy failed: %1 of %2 (line=%3)")).arg(spy.count()).arg(number).arg(line);
|
||||
QVERIFY2((spy.count() == number), msg.toStdString().c_str());
|
||||
}
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::prepareDefaultSituation()
|
||||
{
|
||||
const int timeToProcess = 100;
|
||||
removeTestObjects();
|
||||
|
||||
// move outside:
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.922); // g_movingParticipantId_1 -> 30
|
||||
|
||||
// some areas
|
||||
m_areaId1 = 0;
|
||||
createArea(m_areaId1, QStringLiteral("UnitTest-Area1"), 0.155, 0.926);
|
||||
QVERIFY2((m_areaId1 > 0), " createArea failed");
|
||||
|
||||
m_areaId2 = 0;
|
||||
createArea(m_areaId2, QStringLiteral("UnitTest-Area2"), 0.155, 0.930);
|
||||
QVERIFY2((m_areaId2 > 0), " createArea failed");
|
||||
|
||||
QTest::qWait(timeToProcess); // time to process
|
||||
|
||||
// some targets
|
||||
m_targetDataId1 = 0;
|
||||
createTarget(m_targetDataId1, g_targetParticipantId_1, QStringLiteral("UnitTest-TargetDataId1_Part=5"));
|
||||
QVERIFY2((m_targetDataId1 > 0), " createTarget failed");
|
||||
|
||||
m_targetDataId2 = 0;
|
||||
createTarget(m_targetDataId2, g_targetParticipantId_2, QStringLiteral("UnitTest-TargetDataId2_Part=6"));
|
||||
QVERIFY2((m_targetDataId2 > 0), " createTarget failed");
|
||||
|
||||
QTest::qWait(timeToProcess); // time to process
|
||||
|
||||
// some assignments
|
||||
m_assignmentId1 = 0;
|
||||
createAssignment(m_areaId1, g_targetParticipantId_1, m_assignmentId1, QStringLiteral("UnitTest-Assignment1"));
|
||||
QVERIFY2((m_assignmentId1 > 0), " createAssignment failed");
|
||||
|
||||
// move Player, still outside
|
||||
QTest::qWait(timeToProcess); // time to process
|
||||
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.925);
|
||||
checkShootbackTargetChangedWasEmitted(0, __LINE__);
|
||||
|
||||
QTest::qWait(timeToProcess); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
|
||||
NOTICE_LOG(m_logger) << " -------------- DefaultSituation established --------------";
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testPlayerMoves()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// no enter
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.925);
|
||||
checkShootbackTargetChangedWasEmitted(0, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// leave 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.927);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// enter 2
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.93);
|
||||
checkShootbackTargetChangedWasEmitted(0, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed"); // targetId2 has no assignment -> 0
|
||||
}
|
||||
|
||||
// leave 2
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.94);
|
||||
checkShootbackTargetChangedWasEmitted(0, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testPlayerMovesLos()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
|
||||
|
||||
// move assigned target 1 slightly:
|
||||
{
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " move target1 ...";
|
||||
modifyTarget(m_targetDataId1, g_targetParticipantId_1, QStringLiteral("UnitTest-TargetDataId1_Moved"), 0.149, 0.926, 55.0);
|
||||
|
||||
QTest::qWait(250); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// move (z) assigned target 1 to interrupt line of sight:
|
||||
{
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " move target1 ...";
|
||||
modifyTarget(m_targetDataId1, g_targetParticipantId_1, QStringLiteral("UnitTest-TargetDataId1_Moved"), 0.152, 0.926, 2.0);
|
||||
|
||||
QTest::qWait(250); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testPlayerRemove()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// remove ParticipantPOSTION
|
||||
m_dtsPpm->removeParticipantPositionByKey(g_movingParticipantId_1);
|
||||
{
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testAreaChanges()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// move participant in the near of the target to ensure lineOfSight
|
||||
// target1: Pos 0.149276, 0.9262
|
||||
|
||||
moveParticipant(g_movingParticipantId_1, 0.149, 0.926);
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
|
||||
// move to area 1 (assigned to target1) over p1
|
||||
modifyArea(m_areaId1, QStringLiteral("UnitTest-Area1_Mod-AreaChanges"), 0.149, 0.926);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testAreaRemove()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
removeArea(m_areaId1, false);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testAssignmentRemove()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
removeAssignment(m_assignmentId1, false);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testAssignmentChanges()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// switch assignment: area1 -> area2
|
||||
modifyAssignment(m_areaId2, m_targetDataId1, m_assignmentId1, QStringLiteral("UnitTest-Assignment1_Mod"));
|
||||
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::cleanupTestCase()
|
||||
{
|
||||
// called one time at the end
|
||||
QTest::qWait(1000); // time to process
|
||||
removeTestObjects();
|
||||
QTest::qWait(1000); // time to process
|
||||
}
|
||||
|
||||
//
|
||||
// DdsSlots:
|
||||
//
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Area
|
||||
void tgtTestShootbackTarget::onShootbackAreaModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyShootbackAreaId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'";
|
||||
m_replyShootbackAreaId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::onShootbackAreaRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyShootbackAreaId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'"
|
||||
<< ", id="<< reply.id();
|
||||
m_replyShootbackAreaId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Target
|
||||
void tgtTestShootbackTarget::onShootbackTargetModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyShootbackTargetId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'";
|
||||
m_replyShootbackTargetId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::onShootbackTargetRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyShootbackTargetId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'"
|
||||
<< ", id="<< reply.id();
|
||||
m_replyShootbackTargetId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// TargetAreaAssignment
|
||||
void tgtTestShootbackTarget::onTargetAreaAssignmentModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyTargetAreaAssignmentId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'";
|
||||
m_replyTargetAreaAssignmentId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::onTargetAreaAssignmentRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyTargetAreaAssignmentId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'"
|
||||
<< ", id="<< reply.id();
|
||||
m_replyTargetAreaAssignmentId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
qint64 tgtTestShootbackTarget::currentSampleTime()
|
||||
{
|
||||
return QDateTime::currentDateTimeUtc().toMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Unittest
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <TargetManagement/tgt_dtc.h>
|
||||
#include <TargetManagement/tgt_ftc.h>
|
||||
#include <TargetManagement/tgt_ftc_types.h>
|
||||
#include <TargetManagement/logger.h>
|
||||
#include <ExerciseEventManagement/eem_dts.h>
|
||||
#include <ParticipantManagement/ppm_dts.h>
|
||||
#include <Proxies/TrainingAreaBase/tab_dts.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class tgtTestShootbackTarget : public QObject
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackAreaModifyReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackAreaRemoveReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackTargetModifyReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackTargetRemoveReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::TargetAreaAssignmentModifyReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::TargetAreaAssignmentRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tgtTestShootbackTarget();
|
||||
virtual ~tgtTestShootbackTarget();
|
||||
|
||||
void setPara(int domainId, int exerciseId)
|
||||
{
|
||||
m_domainId = domainId;
|
||||
m_exerciseId = exerciseId;
|
||||
}
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase(); // one time at the beginning
|
||||
|
||||
// basics
|
||||
void testShootbackArea();
|
||||
void testShootbackTarget();
|
||||
void testTargetAreaAssignment();
|
||||
|
||||
// based on defaultSituation:
|
||||
void testPlayerMoves();
|
||||
void testPlayerMovesLos();
|
||||
|
||||
|
||||
void testPlayerRemove();
|
||||
|
||||
void testAreaChanges();
|
||||
void testAreaRemove();
|
||||
|
||||
void testAssignmentRemove();
|
||||
void testAssignmentChanges();
|
||||
|
||||
void cleanupTestCase(); // one time at the end
|
||||
|
||||
protected:
|
||||
void onShootbackAreaModifyReply(const Core::FunctionReplyObject &reply) override final;
|
||||
void onShootbackAreaRemoveReply(const Core::FunctionReplyObject &reply) override final;
|
||||
|
||||
void onShootbackTargetModifyReply(const Core::FunctionReplyObject &reply) override final;
|
||||
void onShootbackTargetRemoveReply(const Core::FunctionReplyObject &reply) override final;
|
||||
|
||||
void onTargetAreaAssignmentModifyReply(const Core::FunctionReplyObject &reply) override final;
|
||||
void onTargetAreaAssignmentRemoveReply(const Core::FunctionReplyObject &reply) override final;
|
||||
|
||||
private:
|
||||
qint64 currentSampleTime();
|
||||
void checkShootbackAreaChangedWasEmitted(int number, int line);
|
||||
void checkShootbackTargetChangedWasEmitted(int number, int line);
|
||||
void checkAssignmentChangedWasEmitted(int number, int line);
|
||||
void removeTestObjects();
|
||||
|
||||
void createArea(int &areaIdInOut, const QString &name, double lon, double lat);
|
||||
void modifyArea(int &areaId, const QString &name, double lon, double lat);
|
||||
void removeArea(int areaId, bool checkUsingSpy = true);
|
||||
|
||||
void createTarget(int &targetIdOut, int targetParticipantId, const QString &name);
|
||||
void modifyTarget(int targetId, int targetParticipantId, const QString &name, double lon, double lat, double z);
|
||||
void removeTarget(int targetId, bool checkUsingSpy = true);
|
||||
std::vector<int32_t> visiParticpantsOfTarget(int targetId);
|
||||
|
||||
void createAssignment(int areaId, int targetParticipantId, int &assignmentIdOut, const QString &name);
|
||||
void modifyAssignment(int areaId, int targetParticipantId, int &assignmentId, const QString &name);
|
||||
void removeAssignment(int id, bool checkUsingSpy = true);
|
||||
|
||||
void moveParticipant(int participantId, double lon, double lat);
|
||||
|
||||
void prepareDefaultSituation();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<TargetManagement::Interface::Ftc> m_ftcTgt;
|
||||
std::shared_ptr<TargetManagement::Interface::Dtc> m_dtcTgt;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dts> m_dtsPpm;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_dtsTab;
|
||||
|
||||
int m_domainId = -1;
|
||||
int m_exerciseId = -1;
|
||||
|
||||
int m_areaId1 = -1;
|
||||
int m_areaId2 = -1;
|
||||
int m_targetDataId1 = -1;
|
||||
int m_targetDataId2 = -1;
|
||||
int m_assignmentId1 = -1;
|
||||
|
||||
int m_replyShootbackAreaId = -1;
|
||||
int m_replyShootbackTargetId = -1;
|
||||
int m_replyTargetAreaAssignmentId = -1;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
Reference in new issue
Block a user