84 lines
2.5 KiB
C++
Executable File
84 lines
2.5 KiB
C++
Executable File
/**
|
|
* AES Function Topic Client test executable
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AreaEffectSimulation/aes_ftc.h>
|
|
#include <AreaEffectSimulation/aes_dtc.h>
|
|
#include <AreaEffectSimulation/logger.h>
|
|
#include <QObject>
|
|
#include <DDS/DDSConnector/dds_connector.h>
|
|
#include <memory>
|
|
|
|
#include <AreaEffectSimulation/aes_test_base_export.h>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
class AES_TEST_BASE_EXPORT TestBase : public QObject
|
|
{
|
|
Q_OBJECT
|
|
protected:
|
|
explicit TestBase(const char *loggerName, QObject *parent);
|
|
public:
|
|
|
|
bool testsSuccessful() const { return m_bTestsSuccessful; }
|
|
|
|
virtual bool init(int domainId, int exerciseId, int testId);
|
|
|
|
public Q_SLOTS:
|
|
virtual void startTest() = 0;
|
|
protected:
|
|
static bool waitForData(const std::function<bool()> &func);
|
|
bool checkAesItem(const AreaEffectSimulation::AesItem &a,
|
|
const AreaEffectSimulation::AesItem &b) const;
|
|
|
|
void failExit();
|
|
|
|
void onAesCreateReply(const Core::FunctionReplyObject &replyObject);
|
|
void onAesModifyReply(const Core::FunctionReplyObject &replyObject);
|
|
void onAesRemoveReply(const Core::FunctionReplyObject &replyObject);
|
|
void onAesTriggerReply(const Core::FunctionReplyObject &replyObject);
|
|
|
|
template <typename T>
|
|
void onAesChanged(const T &dataIn, DataModification modType, T &dataOut)
|
|
{
|
|
INFO_LOG(m_logger) << "Got " << m_aesTypeName << " with mod type " << (int)modType
|
|
<< ", id: " << dataIn.id() << ", chargeType: " << dataIn.chargeStruct().chargeTypeId()
|
|
<< ", effectState: " << dataIn.effectStateId();
|
|
if (m_expectedAesId == dataIn.id())
|
|
{
|
|
DEBUG_LOG(m_logger) << "Expected aes id - updating data for " << m_aesTypeName;
|
|
dataOut = dataIn;
|
|
}
|
|
if (modType == DataModification::eRemoved && dataOut.id() == dataIn.id())
|
|
{
|
|
DEBUG_LOG(m_logger) << "Removed " << m_aesTypeName << " with id " << dataIn.id();
|
|
m_expectedAesId = dataIn.id();
|
|
}
|
|
}
|
|
|
|
protected:
|
|
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
|
std::shared_ptr<AreaEffectSimulation::Interface::Ftc> m_ftc;
|
|
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_dtc;
|
|
|
|
int m_expectedAesId; //!< contains the id of the created aes
|
|
bool m_bIsCreatedRequest;
|
|
bool m_bExpectedFailure;
|
|
bool m_replyError;
|
|
bool m_bTestsSuccessful;
|
|
int m_testId;
|
|
QString m_aesTypeName;
|
|
|
|
LOGGER_T m_logger;
|
|
};
|
|
|
|
int AES_TEST_BASE_EXPORT mainBase(int argc, char **argv,
|
|
const std::function<TestBase*()> &createFunc);
|
|
|
|
} // namespace AreaEffectSimulation
|