Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+419
@@ -0,0 +1,419 @@
|
||||
/**
|
||||
* EXM Function Topic test executable
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-10
|
||||
*/
|
||||
|
||||
#include "mvs_tests.h"
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QTimer>
|
||||
#include <QTest>
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
//----------------------------------------------------------------------------------
|
||||
MvsTests::MvsTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_testId(0)
|
||||
, m_teamId(0)
|
||||
, m_receiverId(0)
|
||||
, m_radioStationId(200)
|
||||
, m_exerciseId(0)
|
||||
, m_bTestsSuccessful(true)
|
||||
, m_logger(getLogger("Test"))
|
||||
{
|
||||
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
MvsTests::~MvsTests()
|
||||
{}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
bool MvsTests::init(int domainId, int testId, int teamId, int receiverId, int stationId, int exerciseId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "init begin";
|
||||
|
||||
m_testId = testId;
|
||||
m_teamId = teamId;
|
||||
m_receiverId = receiverId;
|
||||
m_radioStationId = stationId;
|
||||
m_exerciseId = exerciseId;
|
||||
|
||||
// initialize DDS, always on exercise 0
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Global));
|
||||
if (!m_ddsConnector->init())
|
||||
return false;
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
DEBUG_LOG(m_logger) << "create ftc MVS";
|
||||
m_ftc = AudioVideoManagement::Interface::Ftc::create(m_ddsConnector);
|
||||
DEBUG_LOG(m_logger) << "init ftc MVS";
|
||||
bool bRet = m_ftc->enableAll();
|
||||
DEBUG_LOG(m_logger) << "init end MVS - bRet = " << bRet;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Domain Id = " << domainId;
|
||||
DEBUG_LOG(m_logger) << "Team Id = " << teamId;
|
||||
DEBUG_LOG(m_logger) << "Test Id = " << testId;
|
||||
DEBUG_LOG(m_logger) << "Receiver Id = " << receiverId;
|
||||
DEBUG_LOG(m_logger) << "Radio Station Id = " << stationId;
|
||||
DEBUG_LOG(m_logger) << "Exercise Id = " << exerciseId;
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::startTest()
|
||||
{
|
||||
INFO_LOG(m_logger) << "startTest";
|
||||
switch (m_testId)
|
||||
{
|
||||
// case 1:
|
||||
// tryCreateVideoTeam();
|
||||
// break;
|
||||
case 2:
|
||||
tryModifyVideoTeam();
|
||||
break;
|
||||
// case 3:
|
||||
// tryDeleteVideoTeam();
|
||||
// break;
|
||||
case 4:
|
||||
tryCreateVideoReceiver();
|
||||
break;
|
||||
case 5:
|
||||
tryModifyVideoReceiver();
|
||||
break;
|
||||
case 6:
|
||||
tryDeleteVideoReceiver();
|
||||
break;
|
||||
case 7:
|
||||
tryModifyActiveVideoReceiver();
|
||||
break;
|
||||
case 8:
|
||||
tryModifyAvsVideoReceiver();
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG(m_logger) << "Unknown test case !";
|
||||
failExit();
|
||||
break;
|
||||
}
|
||||
INFO_LOG(m_logger) << "********* endTest **************";
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
//void MvsTests::tryCreateVideoTeam()
|
||||
//{
|
||||
// INFO_LOG(m_logger) << "trying to send createRequest VideoTeam";
|
||||
// VideoTeamModifyRequest request;
|
||||
|
||||
// request.id(0);
|
||||
// request.name("MVS00");
|
||||
// request.streamName("Stream name for MVS00");
|
||||
// request.ssrc(0);
|
||||
// request.vtPort(0);
|
||||
// if (m_exerciseId > 0)
|
||||
// request.exerciseId(m_exerciseId);
|
||||
// else
|
||||
// request.exerciseId(0);
|
||||
|
||||
// if (!m_ftc->videoTeamModifyRequest(request, this))
|
||||
// {
|
||||
// INFO_LOG(m_logger) << "Error requesting create data, as expected";
|
||||
// successExit();
|
||||
// }
|
||||
|
||||
// QTest::qWait(1000);
|
||||
//}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::tryModifyVideoTeam()
|
||||
{
|
||||
VideoTeamModifyRequest request;
|
||||
|
||||
request.id(m_teamId);
|
||||
request.name("MVS001");
|
||||
request.streamName("Stream name for MVS001");
|
||||
if (m_exerciseId > 0)
|
||||
request.exerciseId(m_exerciseId);
|
||||
else
|
||||
request.exerciseId(0);
|
||||
|
||||
request.vtPort(0);
|
||||
request.ssrc(0);
|
||||
|
||||
if (!m_ftc->videoTeamModifyRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
//void MvsTests::tryDeleteVideoTeam()
|
||||
//{
|
||||
// Core::RemoveElementRequest request;
|
||||
|
||||
// request.id(m_teamId);
|
||||
|
||||
// if (!m_ftc->videoTeamRemoveRequest(request, this))
|
||||
// {
|
||||
// ERROR_LOG(m_logger) << "Error requesting remove data";
|
||||
// failExit();
|
||||
// }
|
||||
|
||||
// QTest::qWait(1000);
|
||||
//}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::tryCreateVideoReceiver()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send createRequest VideoReceiver";
|
||||
VideoReceiverModifyRequest request;
|
||||
|
||||
request.id(0);
|
||||
request.streamName("Stream name MVS_00");
|
||||
request.mainStructureElementId(m_radioStationId);
|
||||
request.teamId(m_teamId);
|
||||
request.hostName("Hostname");
|
||||
request.frequency(0);
|
||||
request.isLocked(false);
|
||||
|
||||
if (!m_ftc->videoReceiverModifyRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::tryModifyVideoReceiver()
|
||||
{
|
||||
VideoReceiverModifyRequest request;
|
||||
|
||||
request.id(m_receiverId);
|
||||
request.streamName("Stream name MVS_001");
|
||||
request.mainStructureElementId(m_radioStationId);
|
||||
request.teamId(m_teamId);
|
||||
request.hostName("Hostname");
|
||||
request.frequency(0);
|
||||
request.isLocked(false);
|
||||
|
||||
if (!m_ftc->videoReceiverModifyRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::tryModifyAvsVideoReceiver()
|
||||
{
|
||||
VideoReceiverModifyAvsRequest request;
|
||||
|
||||
request.id(m_receiverId);
|
||||
request.dbm(80);
|
||||
request.snr(20);
|
||||
|
||||
if (!m_ftc->videoReceiverModifyAvsRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify AVS data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::tryModifyActiveVideoReceiver()
|
||||
{
|
||||
VideoReceiverModifyActiveRequest request;
|
||||
|
||||
request.id(m_receiverId);
|
||||
request.isActive(true);
|
||||
|
||||
if (!m_ftc->videoReceiverModifyActiveRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify active data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::tryDeleteVideoReceiver()
|
||||
{
|
||||
Core::RemoveElementRequest request;
|
||||
|
||||
request.id(m_receiverId);
|
||||
|
||||
if (!m_ftc->videoReceiverRemoveRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove data";
|
||||
failExit();
|
||||
}
|
||||
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::failExit()
|
||||
{
|
||||
ERROR_LOG(m_logger) << "FAIL EXIT !";
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::successExit()
|
||||
{
|
||||
INFO_LOG(m_logger) << "SUCCES EXIT !";
|
||||
m_bTestsSuccessful = true;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
/*
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::onVideoTeamModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "END (onVideoTeamModifyReply)";
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got onVideoTeamModifyReply error: " << replyObject();
|
||||
QTimer::singleShot(0, qApp, SLOT(quit()));
|
||||
return;
|
||||
}
|
||||
INFO_LOG(m_logger) << "Got Reply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
m_teamId = replyObject.id();
|
||||
|
||||
QTimer::singleShot(0, qApp, SLOT(quit()));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void MvsTests::onVideoReceiverModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "END (onVideoReceiverModifyReply)";
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got onVideoReceiverModifyReply error: " << replyObject();
|
||||
QTimer::singleShot(0, qApp, SLOT(quit()));
|
||||
return;
|
||||
}
|
||||
INFO_LOG(m_logger) << "Got Reply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
m_receiverId = replyObject.id();
|
||||
|
||||
QTimer::singleShot(0, qApp, SLOT(quit()));
|
||||
}
|
||||
*/
|
||||
// ------------------------------------------------------------------------------
|
||||
void MvsTests::onError(const QString &reason)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got Reply error: " << reason;
|
||||
failExit();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
void MvsTests::onReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
if (replyObject.error())
|
||||
{
|
||||
onError(replyObject.translated());
|
||||
return;
|
||||
}
|
||||
INFO_LOG(m_logger) << "Got Reply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
// QTimer::singleShot(0, qApp, SLOT(quit()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("t") << QLatin1String("testId")
|
||||
, QLatin1String("TestId.")
|
||||
, QLatin1String("Default: 0 ")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
addOption( { QStringList() << QLatin1String("p") << QLatin1String("teamId")
|
||||
, QLatin1String("TeamId")
|
||||
, QLatin1String("Default: 0 ")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
addOption( { QStringList() << QLatin1String("r") << QLatin1String("receiverId")
|
||||
, QLatin1String("ReceiverId")
|
||||
, QLatin1String("Default: 0 ")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
addOption( { QStringList() << QLatin1String("s") << QLatin1String("stationId")
|
||||
, QLatin1String("StationId")
|
||||
, QLatin1String("Default: 200 ")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
}
|
||||
|
||||
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : 0; }
|
||||
int teamId() const { return isSet(QLatin1String("p")) ? value(QLatin1String("p")).toInt() : 0; }
|
||||
int receiverId() const { return isSet(QLatin1String("r")) ? value(QLatin1String("r")).toInt() : 0; }
|
||||
int stationId() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : 200; }
|
||||
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int iRet = -1;
|
||||
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("AVM", 0);
|
||||
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return iRet;
|
||||
|
||||
std::unique_ptr<AudioVideoManagement::MvsTests> MvsTests(new AudioVideoManagement::MvsTests);
|
||||
|
||||
if (!MvsTests->init(options.domainId(), options.testId(), options.teamId(), options.receiverId(), options.stationId(), options.exerciseId()))
|
||||
return iRet;
|
||||
|
||||
QTimer::singleShot(0, MvsTests.get(), &AudioVideoManagement::MvsTests::startTest);
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
|
||||
iRet = MvsTests->testsSuccessful() ? 0 : 1;
|
||||
fprintf(stderr, "\n%d\n\n", iRet);
|
||||
|
||||
INFO_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user