ADTF  3.18.2
Test for Demo Data Trigger Plugin
Description
This examples test the Demo Data Trigger Plugin
Location
./src/examples/src/adtf/filters/standard_filters/data_triggered_filter/test/
Namespace for entire ADTF SDK.
Build Environment
To see how to set up the build environment have a look at ADTF CMake Environment
this implementation shows:
Implementation
#include "../demo_data_trigger_function.h"
{
cMyTestSystem()
{
LoadPlugin("demo_data_triggered_filter.adtfplugin");
}
};
adtf::ucom::object_ptr<adtf::streaming::IFilter> create_filter(cSimpleDataCalculator::tOperator eOperator)
{
REQUIRE_OK(_runtime->CreateInstance("demo_data_trigger.filter.adtf.cid", pFilter));
auto pConfiguration = adtf::ucom::ucom_cast<adtf::base::IConfiguration*>(pFilter.Get());
adtf::base::set_property_by_path<uint32_t>(*pConfiguration, "calculator_function/operator", eOperator);
return pFilter;
}
void test_calculation(cSimpleDataCalculator::tOperator eOperator, float fExpectedResult)
{
auto pFilter = create_filter(eOperator);
adtf::filter::testing::cOutputRecorder oOutput(pFilter, "out");
oWriter1.Write<float>(4.0, true);
oWriter2.Write<float>(2.0, true);
auto oOutputSamples = oOutput.GetCurrentOutput().GetSamples();
REQUIRE(oOutputSamples.size() == 1);
REQUIRE(adtf::streaming::sample_data<float>(oOutputSamples.back()) == Approx(fExpectedResult));
}
TEST_CASE_METHOD(cMyTestSystem, "Test Addition")
{
test_calculation(cSimpleDataCalculator::tOperator::ePLUS, 6.0);
}
TEST_CASE_METHOD(cMyTestSystem, "Test Substraction")
{
test_calculation(cSimpleDataCalculator::tOperator::eMINUS, 2.0);
}
TEST_CASE_METHOD(cMyTestSystem, "Test Multiplication")
{
test_calculation(cSimpleDataCalculator::tOperator::eMULTI, 8.0);
}
TEST_CASE_METHOD(cMyTestSystem, "Test Division")
{
test_calculation(cSimpleDataCalculator::tOperator::eDIVIDE, 2.0);
}
TEST_CASE_METHOD(cMyTestSystem, "Test Invalid Operator")
{
auto pFilter = create_filter(static_cast<cSimpleDataCalculator::tOperator>(cSimpleDataCalculator::tOperator::eDIVIDE + 1));
REQUIRE(ERR_INVALID_ARG == pFilter->SetState(adtf::streaming::IFilter::tFilterState::State_Running));
}
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Test Helper class that records triggers, types and samples created by a graph object.
Tester helper class to emulate a writing OutPin to InPin connection for sending samples and type to a...
Definition: test_writer.h:40
@ State_Running
Filter is in streaming State, all pins are activated for streaming (Start() has been called) The fil...
Easy data access for input samples of non trivial type @T (see Supported types for adtf_memory<T> for...
Definition: sample_data.h:428
Generator template to create an instance of a ant::IStreamType class for penguin::stream_meta_type_pl...
This class enables you to setup an ADTF system where you can test your filters and services.
Definition: test_system.h:67
void LoadPlugin(const std::string &strPluginFileName, bool bCreateServices=true, base::ant::tADTFRunLevel nServicesRunlevel=base::tADTFRunLevel::RL_System)
Load a plugin and optionally create instances of all found ADTF Service classes.
virtual tResult CreateInstance(const char *strCID, iobject_ptr< IObject > &pObject, const tChar *strNameOfObject="") const =0
Creates a new instance of an object.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
virtual T * Get() const
Get pointer to shared object.
Definition: object_ptr.h:381
adtf::ucom::IRuntime * _runtime
Global Runtime Pointer to reference to the current runtime.
Copyright © Audi Electronics Venture GmbH.