ADTF
Loading...
Searching...
No Matches
adtf::system::testing::giant::cSessionTestSystem Class Reference

#include <test_system.h>

Inherits adtf::system::testing::giant::cTestSystem.

Public Member Functions

 cSessionTestSystem (const std::string &strUrl="", const std::string &strAdtfDirectory=ADTF_TESTING_ADTF_DIR, const std::string &strPluginDirectories=ADTF_TESTING_PLUGIN_DIRECTORIES, const std::string &strResources=ADTF_TESTING_MUTABLE_RESOURCES, const std::string &strResourcesOutputDirectory=ADTF_TESTING_BUILD_DIR)
 
 cSessionTestSystem (const std::string &strUrl, bool bCreateLoggingService, const std::string &strAdtfDirectory=ADTF_TESTING_ADTF_DIR, const std::string &strPluginDirectories=ADTF_TESTING_PLUGIN_DIRECTORIES, const std::string &strResources=ADTF_TESTING_MUTABLE_RESOURCES, const std::string &strResourcesOutputDirectory=ADTF_TESTING_BUILD_DIR)
 
void SetEnvironmentFile (const std::string &strFileName, bool bPluginDiscovery=true)
 
void CreateSession (const std::string &strFileName)
 
void Exec (std::chrono::microseconds tmTimeout)
 
void Exec (int8_t nInitialRunlevel, std::function< void()> fnStartup)
 
void ExecTest (int8_t nInitialRunlevel, std::function< void()> fnTest)
 
void Exec (int8_t nInitialRunlevel, int8_t nAutoQuitLevel, std::function< void()> fnStartup)
 
ucom::ant::object_ptr< services::ISessionGetSession ()
 
ucom::ant::object_ptr< streaming::ant::IStreamingGraphGetStreamingGraph ()
 
ucom::ant::object_ptr< streaming::ant::IFilterGraphGetFilterGraph ()
 
ucom::ant::object_ptr< streaming::ant::INamedGraphObjectGetGraphObject (const std::string &name)
 
- Public Member Functions inherited from adtf::system::testing::giant::cTestSystem
 cTestSystem (const std::string &strUrl="", const std::vector< std::string > &oPlugins={}, bool bCreateSessionManager=false, const std::string &strAdtfDirectory=ADTF_TESTING_ADTF_DIR, const std::string &strPluginDirectories=ADTF_TESTING_PLUGIN_DIRECTORIES, const std::string &strResources=ADTF_TESTING_MUTABLE_RESOURCES, const std::string &strResourcesOutputDirectory=ADTF_TESTING_BUILD_DIR)
 
 cTestSystem (const std::string &strUrl, const std::vector< std::string > &oPlugins, bool bCreateSessionManager, bool bCreateLoggingService, const std::string &strAdtfDirectory=ADTF_TESTING_ADTF_DIR, const std::string &strPluginDirectories=ADTF_TESTING_PLUGIN_DIRECTORIES, const std::string &strResources=ADTF_TESTING_MUTABLE_RESOURCES, const std::string &strResourcesOutputDirectory=ADTF_TESTING_BUILD_DIR)
 
 ~cTestSystem ()
 
void SetRunLevel (base::ant::tADTFRunLevel eRunlevel)
 
base::ant::tADTFRunLevel GetRunLevel () const
 
void LoadPlugin (const std::string &strPluginFileName, bool bCreateServices=true, base::ant::tADTFRunLevel nServicesRunlevel=base::tADTFRunLevel::RL_System)
 
ucom::ant::object_ptr< ucom::ant::IServiceCreateService (const std::string &strClassId, const std::string &strObjectId, base::ant::tADTFRunLevel nRunlevel=base::tADTFRunLevel::RL_System)
 
ucom::ant::object_ptr< ucom::ant::IServiceCreateService (const std::string &strPluginFileName, const std::string &strClassId, const std::string &strObjectId, base::ant::tADTFRunLevel nRunlevel=base::tADTFRunLevel::RL_System)
 
ucom::ant::object_ptr< ucom::ant::IServiceCreateService (const std::string &strClassId, const std::string &strObjectId, base::ant::tADTFRunLevel nRunlevel, const std::map< std::string, std::string > &oProperties)
 
ucom::ant::object_ptr< ucom::ant::IServiceCreateService (const std::string &strPluginFileName, const std::string &strClassId, const std::string &strObjectId, base::ant::tADTFRunLevel nRunlevel, const std::map< std::string, std::string > &oProperties)
 
std::string GetUrl () const
 
std::string GetMutableResourceDirectory () const
 

Additional Inherited Members

- Public Types inherited from adtf::system::testing::giant::cTestSystem
enum  tProtocolFamily { TCP_IPv4 , TCP_IPv6 , UDP_IPv4 , UDP_IPv6 }
 
- Static Public Member Functions inherited from adtf::system::testing::giant::cTestSystem
static void SetCurDirectory (const std::string &strRelativePath, const std::string &strTestSourceDirectory=ADTF_TESTING_SOURCE_DIR)
 
static void SetMacro (const std::string &strName, const std::string &strValue)
 
static uint16_t GetAvailablePort (tProtocolFamily eFamily, const std::string &strInterface={})
 
static std::string GetAvailableTestUrl ()
 
- Protected Attributes inherited from adtf::system::testing::giant::cTestSystem
std::unique_ptr< cImplementation > m_pImplementation
 

Detailed Description

This class allows you to create a test system based on an ADTF Session.

Example Usage

class cMyTestSystem : public adtf::system::testing::cSessionTestSystem
{
public:
cMyTestSystem()
{
CreateSession("my_session.adtfsession");
SetRunLevel(adtf::base::tADTFRunLevel::RL_FilterGraph);
}
};
void my_test_function()
{
cMyTestSystem oSystem;
auto pMyFilter = oSystem.GetGraphObject("filter_graph_name.my_filter");
adtf::filter::testing::cOutputRecorder oRecorder(pMyFilter, "output_pin");
oSystem.Exec(std::chrono::seconds(3));
auto oOutput = oRecorder.GetCurrentOutput();
if (oOutput.GetSamples().empty())
{
throw std::runtime_error("filter did not create samples");
}
}
Definition output_recorder.h:36
void CreateSession(const std::string &strFileName)
void SetRunLevel(base::ant::tADTFRunLevel eRunlevel)
Note
Our adtf_add_catch_test() macro from mainpage_testing_pkg will define the ADTF_TESTING_ADTF_DIR and ADTF_TESTING_ADTF_DIR macros. If you use another testing framework make sure you either pass values directly to the constructor or add these definitions as well.

Constructor & Destructor Documentation

◆ cSessionTestSystem() [1/2]

adtf::system::testing::giant::cSessionTestSystem::cSessionTestSystem ( const std::string & strUrl = "",
const std::string & strAdtfDirectory = ADTF_TESTING_ADTF_DIR,
const std::string & strPluginDirectories = ADTF_TESTING_PLUGIN_DIRECTORIES,
const std::string & strResources = ADTF_TESTING_MUTABLE_RESOURCES,
const std::string & strResourcesOutputDirectory = ADTF_TESTING_BUILD_DIR )

Constructs a test system.

Parameters
[in]strUrlIf set the RPC object registry will be created and listen at the given URL.
[in]strAdtfDirectoryThe ADTF root directory. The default is a macro that can be set by the test environment.
[in]strPluginDirectoriesA ';' separated list of plugin directories. The default is a macro that can be set by the test environment.
[in]strResourcesA ';' separated list of mutable test resources. Can be directories and/or files. The listed inputs will be copied to strResourcesOutputDirectory.
[in]strResourcesOutputDirectoryThe root directory where the listed inputs from strResources will be copied to. A unique folder name will be attached to the path. Mind that this unique folder is temporary!

◆ cSessionTestSystem() [2/2]

adtf::system::testing::giant::cSessionTestSystem::cSessionTestSystem ( const std::string & strUrl,
bool bCreateLoggingService,
const std::string & strAdtfDirectory = ADTF_TESTING_ADTF_DIR,
const std::string & strPluginDirectories = ADTF_TESTING_PLUGIN_DIRECTORIES,
const std::string & strResources = ADTF_TESTING_MUTABLE_RESOURCES,
const std::string & strResourcesOutputDirectory = ADTF_TESTING_BUILD_DIR )

Constructs a test system.

Parameters
[in]strUrlIf set the RPC object registry will be created and listen at the given URL.
[in]bCreateLoggingServiceWhether or not to create a logging service.
[in]strAdtfDirectoryThe ADTF root directory. The default is a macro that can be set by the test environment.
[in]strPluginDirectoriesA ';' separated list of plugin directories. The default is a macro that can be set by the test environment.
[in]strResourcesA ';' separated list of mutable test resources. Can be directories and/or files. The listed inputs will be copied to strResourcesOutputDirectory.
[in]strResourcesOutputDirectoryThe root directory where the listed inputs from strResources will be copied to. A unique folder name will be attached to the path. Mind that this unique folder is temporary!

Member Function Documentation

◆ CreateSession()

void adtf::system::testing::giant::cSessionTestSystem::CreateSession ( const std::string & strFileName)

Load and create a session.

This will create the services. The filter graph is created when you change the runlevel to RL_FilterGraph.

Parameters
[in]strFileNameThe path to the .adtfsession file.
Exceptions
tResultif an error occurred.

◆ Exec() [1/3]

void adtf::system::testing::giant::cSessionTestSystem::Exec ( int8_t nInitialRunlevel,
int8_t nAutoQuitLevel,
std::function< void()> fnStartup )

Executes a session and call the a callback function when ready.

Parameters
[in]nInitialRunlevelChange to this runlevel before the callback is called.
[in]nAutoQuitLevelExecution is stopped when the given runlevel is left by decrementing.
[in]fnStartupThis callback will be called once the session is ready.
Exceptions
tResultif an error occurred.

◆ Exec() [2/3]

void adtf::system::testing::giant::cSessionTestSystem::Exec ( int8_t nInitialRunlevel,
std::function< void()> fnStartup )

Executes a session and call the a callback function when ready.

Parameters
[in]nInitialRunlevelChange to this runlevel before the callback is called.
[in]fnStartupThis callback will be called once the session is ready.
Exceptions
tResultif an error occurred.

◆ Exec() [3/3]

void adtf::system::testing::giant::cSessionTestSystem::Exec ( std::chrono::microseconds tmTimeout)

Executes a session for a given amount of time. This will look for an IApplication implementation and call its IApplication::Execute() and quit when the timeout is reached. If there is no IApplication, then the runlevel will be set to RL_Running and shutdown after the timeout.

Parameters
[in]tmTimeoutThe amount of time the session should be executed.
Exceptions
tResultif an error occurred.

◆ ExecTest()

void adtf::system::testing::giant::cSessionTestSystem::ExecTest ( int8_t nInitialRunlevel,
std::function< void()> fnTest )

Execute a session, call a test function and shutdown the session afterwards.

Parameters
[in]nInitialRunlevelChange to this runlevel before the callback is called.
[in]fnTestThe test callback function.
Exceptions
tResultif an error occurred (i.e. an exception was thrown).

◆ GetFilterGraph()

ucom::ant::object_ptr< streaming::ant::IFilterGraph > adtf::system::testing::giant::cSessionTestSystem::GetFilterGraph ( )
Returns
the filter graph.

◆ GetGraphObject()

ucom::ant::object_ptr< streaming::ant::INamedGraphObject > adtf::system::testing::giant::cSessionTestSystem::GetGraphObject ( const std::string & name)

Retrieve a graph object from the streaming/filter graph.

Parameters
[in]nameThe full name of the object to retrieve.
Returns
A pointer to the graph object.
Exceptions
tResultif an error occurred.

◆ GetSession()

ucom::ant::object_ptr< services::ISession > adtf::system::testing::giant::cSessionTestSystem::GetSession ( )
Returns
the current session object.

◆ GetStreamingGraph()

ucom::ant::object_ptr< streaming::ant::IStreamingGraph > adtf::system::testing::giant::cSessionTestSystem::GetStreamingGraph ( )
Returns
the streaming graph.

◆ SetEnvironmentFile()

void adtf::system::testing::giant::cSessionTestSystem::SetEnvironmentFile ( const std::string & strFileName,
bool bPluginDiscovery = true )

Set the adtfenvironment.

This will set the adtfenvironment of the test system. It must be called before CreateSession()

Parameters
[in]strFileNameThe path to the .adtfenvironment file.
[in]bPluginDiscoveryWhether or not all available plugin descriptions from the environment should be loaded and used for the automatic lookup and loading of required plugins when creating class instances. Will also enable the loading of all available adtf_file plugins during session creation.
Exceptions
tResultif an error occurred.

The documentation for this class was generated from the following file: