/** * AES Function Topic Client test executable * $Id$ * $HeadURL$ * $Author$ */ #pragma once #include #include #include #include #include #include #include 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 &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 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 m_ddsConnector; std::shared_ptr m_ftc; std::shared_ptr 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 &createFunc); } // namespace AreaEffectSimulation