Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,245 @@
|
||||
/**
|
||||
* AES Function Topic Client test executable
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "aes_test_danger_area.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QTest>
|
||||
#include <QTimer>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
const std::string TestDangerArea::s_name = "chris2";
|
||||
|
||||
TestDangerArea::TestDangerArea(QObject *parent)
|
||||
: TestBase("Test.DangerArea", parent)
|
||||
{}
|
||||
|
||||
bool TestDangerArea::init(int domainId, int exerciseId, int testId)
|
||||
{
|
||||
if (!TestBase::init(domainId, exerciseId, testId))
|
||||
return false;
|
||||
|
||||
m_dtc->waitForHistoricalDataDangerArea();
|
||||
|
||||
m_daData.id(-1);
|
||||
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::dangerAreaChanged,
|
||||
this, &TestDangerArea::dangerAreaChanged);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TestDangerArea::checkBaseData(const AreaEffectSimulation::DangerArea &a,
|
||||
const AreaEffectSimulation::DangerArea &b) const
|
||||
{
|
||||
|
||||
if (a.name() != b.name())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Name does not macht: " << a.name() << " - " << b.name();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a.effectStart() != b.effectStart())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "StartTime does not match: " << a.effectStart() << " - " << b.effectStart();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i<a.segments().size() && i<b.segments().size(); ++i)
|
||||
{
|
||||
if (a.segments()[i] != b.segments()[i])
|
||||
{
|
||||
WARNING_LOG(m_logger) << "impactPosition does not match: " << a.segments()[i] << " - " << b.segments()[i];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//
|
||||
// DangerArea
|
||||
//
|
||||
void TestDangerArea::tryCreateDangerArea()
|
||||
{
|
||||
m_daData = AreaEffectSimulation::DangerArea();
|
||||
AreaEffectSimulation::DangerArea esData;
|
||||
esData.id(0);
|
||||
esData.name("chris");
|
||||
esData.effectStart((time(nullptr) + 4) * 1000); // msec
|
||||
esData.sampleTime(time(nullptr) *1000);
|
||||
|
||||
std::vector<Core::GeoPosition2D> segments;
|
||||
segments.emplace_back(Core::GeoPosition2D(0.17001, 0.93001));
|
||||
segments.emplace_back(Core::GeoPosition2D(0.17002, 0.93002));
|
||||
segments.emplace_back(Core::GeoPosition2D(0.17003, 0.93003));
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send dangerAreaCreateRequest()";
|
||||
m_replyError = false;
|
||||
m_bIsCreatedRequest = true;
|
||||
if (!m_ftc->dangerAreaModifyRequest(
|
||||
DangerAreaModifyRequest(
|
||||
0,
|
||||
esData.name(),
|
||||
0, // Effect Duration
|
||||
311, // Charge Type Id -> 311 = Danger Area Dummy
|
||||
esData.effectStart(),
|
||||
segments,
|
||||
dds::core::optional<int32_t>(), // Party Id
|
||||
dds::core::optional<int32_t>(), // Player Id
|
||||
dds::core::optional<int32_t>() // associatedAesId
|
||||
),
|
||||
this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error during dangerAreaCreateRequest()";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!waitForData([this]() { return m_daData.id() == m_expectedAesId; }))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error creating danger area object";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
if (!checkBaseData(m_daData, esData))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Creation data does not match published data";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
QTimer::singleShot(0, this, &TestDangerArea::tryModifyDangerArea);
|
||||
INFO_LOG(m_logger) << "tryCreateDangerArea successful";
|
||||
}
|
||||
|
||||
void TestDangerArea::tryModifyDangerArea()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send modify request";
|
||||
m_daData.name(s_name);
|
||||
m_daData.effectStart(time(nullptr)+ 6 * 1000);
|
||||
|
||||
const AreaEffectSimulation::DangerArea esData(m_daData);
|
||||
m_daData = AreaEffectSimulation::DangerArea();
|
||||
m_daData.id(esData.id());
|
||||
|
||||
// resize to 2 elements
|
||||
std::vector<Core::GeoPosition2D> segments;
|
||||
segments.emplace_back(Core::GeoPosition2D(0.17004, 0.93004));
|
||||
segments.emplace_back(Core::GeoPosition2D(0.17004, 0.93005));
|
||||
|
||||
m_bIsCreatedRequest = false;
|
||||
if (!m_ftc->dangerAreaModifyRequest(
|
||||
DangerAreaModifyRequest(
|
||||
esData.id(),
|
||||
esData.name(),
|
||||
0, // Effect Duration
|
||||
311, // Charge Type Id -> 311 = Danger Area Dummy
|
||||
esData.effectStart(),
|
||||
segments,
|
||||
dds::core::optional<int32_t>(), // Party Id
|
||||
dds::core::optional<int32_t>(), // Player Id
|
||||
dds::core::optional<int32_t>() // associatedAesId
|
||||
),
|
||||
this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
if (!waitForData([this]() { return m_daData.segments().size() == 2;}))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error updating danger area object";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
|
||||
// increase to 4 elements
|
||||
segments.resize(4);
|
||||
segments[0] = Core::GeoPosition2D(0.17004, 0.93004);
|
||||
segments[1] = Core::GeoPosition2D(0.17004, 0.93005);
|
||||
segments[2] = Core::GeoPosition2D(0.17005, 0.93006);
|
||||
segments[3] = Core::GeoPosition2D(0.17006, 0.93007);
|
||||
|
||||
if (!m_ftc->dangerAreaModifyRequest(
|
||||
DangerAreaModifyRequest(
|
||||
esData.id(),
|
||||
esData.name(),
|
||||
0, // Effect Duration
|
||||
311, // Charge Type Id -> 311 = Danger Area Dummy
|
||||
esData.effectStart(),
|
||||
segments,
|
||||
dds::core::optional<int32_t>(), // Party Id
|
||||
dds::core::optional<int32_t>(), // Player Id
|
||||
dds::core::optional<int32_t>() // associatedAesId
|
||||
),
|
||||
this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
if (!waitForData([this]() { return m_daData.segments().size() == 4;}))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error updating danger area object";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, this, &TestDangerArea::tryRemoveDangerArea);
|
||||
INFO_LOG(m_logger) << "tryModifyDangerArea successful";
|
||||
}
|
||||
|
||||
void TestDangerArea::tryRemoveDangerArea()
|
||||
{
|
||||
m_expectedAesId = -1;
|
||||
if (!m_ftc->dangerAreaRemoveRequest(
|
||||
Core::RemoveElementRequest( m_daData.id()),
|
||||
this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data";
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
if (!waitForData([this]() { return m_daData.id() == m_expectedAesId; }))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error removing bc contamination object " << m_daData.id() << " != " << m_expectedAesId;
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
INFO_LOG(m_logger) << "tryRemoveDangerArea successful";
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DangerArea
|
||||
//
|
||||
void TestDangerArea::dangerAreaChanged(const AreaEffectSimulation::DangerArea &data, DataModification modType)
|
||||
{
|
||||
if (m_daData.id() == -1)
|
||||
return;
|
||||
onAesChanged(data, modType, m_daData);
|
||||
}
|
||||
|
||||
void TestDangerArea::onDangerAreaModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
if (m_bIsCreatedRequest)
|
||||
onAesCreateReply(replyObject);
|
||||
else
|
||||
onAesModifyReply(replyObject);
|
||||
}
|
||||
|
||||
void TestDangerArea::onDangerAreaRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
onAesRemoveReply(replyObject);
|
||||
}
|
||||
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return AreaEffectSimulation::mainBase(argc, argv, []() { return new AreaEffectSimulation::TestDangerArea; });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user