Skip to content

Commit b645acb

Browse files
Fixed unit tests
1 parent ee437e9 commit b645acb

1 file changed

Lines changed: 60 additions & 2 deletions

File tree

Implementation/UnitTest/amc_unittests_signalslot.hpp

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4646
#include <mutex>
4747
#include "common_utils.hpp"
4848
#include "common_chrono.hpp"
49+
#include "amc_telemetry.hpp"
50+
#include "libmcdata_dynamic.hpp"
4951

5052

5153
namespace AMCUnitTest {
@@ -54,6 +56,11 @@ namespace AMCUnitTest {
5456

5557
public:
5658

59+
CDummyRegistry()
60+
{
61+
initializeTelemetry();
62+
}
63+
5764
void registerMessage(const std::string& sMessageUUID, AMC::CStateSignalSlot* pSignalSlot) override
5865
{
5966

@@ -71,9 +78,60 @@ namespace AMCUnitTest {
7178

7279
AMC::PTelemetryChannel registerTelemetryChannel(const std::string& sChannelIdentifier, const std::string& sChannelDescription, LibMCData::eTelemetryChannelType channelType) override
7380
{
74-
return nullptr;
81+
return m_pTelemetryHandler->registerChannel(sChannelIdentifier, sChannelDescription, channelType);
82+
}
83+
84+
private:
85+
#define __STRINGIZE(x) #x
86+
#define __STRINGIZE_VALUE_OF(x) __STRINGIZE(x)
87+
88+
std::string getDataModelLibraryName()
89+
{
90+
std::string sBaseName = std::string(__STRINGIZE_VALUE_OF(__GITHASH)) + "_core_libmcdata";
91+
std::string sLibraryName;
92+
#ifdef _WIN32
93+
sLibraryName = sBaseName + ".dll";
94+
#elif defined(__APPLE__)
95+
sLibraryName = sBaseName + ".dylib";
96+
#else
97+
sLibraryName = sBaseName + ".so";
98+
#endif
99+
std::string sLocalPath = "./" + sLibraryName;
100+
if (AMCCommon::CUtils::fileOrPathExistsOnDisk(sLocalPath))
101+
return sLocalPath;
102+
103+
return "./Output/" + sLibraryName;
75104
}
76105

106+
void initializeTelemetry()
107+
{
108+
std::string sRootPath = "testoutput";
109+
if (!AMCCommon::CUtils::fileOrPathExistsOnDisk(sRootPath))
110+
AMCCommon::CUtils::createDirectoryOnDisk(sRootPath);
111+
112+
std::string sBasePath = sRootPath + "/signalslot_" + AMCCommon::CUtils::createUUID();
113+
if (!AMCCommon::CUtils::fileOrPathExistsOnDisk(sBasePath))
114+
AMCCommon::CUtils::createDirectoryOnDisk(sBasePath);
115+
116+
std::string sDatabaseFile = sBasePath + "/signalslot.db";
117+
118+
m_pDataWrapper = LibMCData::CWrapper::loadLibrary(getDataModelLibraryName());
119+
m_pDataModel = m_pDataWrapper->CreateDataModelInstance();
120+
m_pDataModel->InitialiseDatabase(sBasePath, LibMCData::eDataBaseType::SqLite, sDatabaseFile);
121+
m_pTelemetrySession = m_pDataModel->CreateTelemetrySession();
122+
123+
m_pChrono = std::make_shared<AMCCommon::CChrono>();
124+
m_pTelemetryWriter = std::make_shared<AMC::CTelemetryWriter>(m_pTelemetrySession, m_pChrono);
125+
m_pTelemetryHandler = std::make_shared<AMC::CTelemetryHandler>(m_pTelemetryWriter);
126+
}
127+
128+
LibMCData::PWrapper m_pDataWrapper;
129+
LibMCData::PDataModel m_pDataModel;
130+
LibMCData::PTelemetrySession m_pTelemetrySession;
131+
AMCCommon::PChrono m_pChrono;
132+
AMC::PTelemetryWriter m_pTelemetryWriter;
133+
std::shared_ptr<AMC::CTelemetryHandler> m_pTelemetryHandler;
134+
77135
};
78136

79137

@@ -304,4 +362,4 @@ class CUnitTestGroup_SignalSlot : public CUnitTestGroup {
304362
}
305363

306364

307-
#endif // __AMCTEST_UNITTEST_SIGNALSLOT
365+
#endif // __AMCTEST_UNITTEST_SIGNALSLOT

0 commit comments

Comments
 (0)