diff options
author | Jens Lorenz <jlorenz@de.adit-jv.com> | 2014-06-11 18:14:58 +0200 |
---|---|---|
committer | Christian Linke <christian.linke@bmw.de> | 2014-06-23 14:05:37 +0200 |
commit | 20491c0f31d70e254c56f171c69b95f3d4ad2813 (patch) | |
tree | 5409ce980ecf4285a21cf0f1b38ba19dafe3129a /PluginRoutingInterfaceAsync | |
parent | b0bc6ede2d23dde9a177483aa9470871422fe9aa (diff) | |
download | audiomanager-20491c0f31d70e254c56f171c69b95f3d4ad2813.tar.gz |
* Bug #100 - removed projecttypes.h which causes compiling conflicts5.1
Signed-off-by: Jens Lorenz <jlorenz@de.adit-jv.com>
Diffstat (limited to 'PluginRoutingInterfaceAsync')
5 files changed, 145 insertions, 134 deletions
diff --git a/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h b/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h index 6d1fbed..22fded2 100644 --- a/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h +++ b/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h @@ -125,16 +125,16 @@ public: void setRoutingReady(const uint16_t handle) ; void setRoutingRundown(const uint16_t handle) ; am_Error_e asyncAbort(const am_Handle_s handle) ; - am_Error_e asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) ; + am_Error_e asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat) ; am_Error_e asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID) ; - am_Error_e asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ; - am_Error_e asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ; + am_Error_e asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time) ; + am_Error_e asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time) ; am_Error_e asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state) ; am_Error_e asyncSetSinkSoundProperties(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties) ; am_Error_e asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) ; am_Error_e asyncSetSourceSoundProperties(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties) ; am_Error_e asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) ; - am_Error_e asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time) ; + am_Error_e asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time) ; am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) ; am_Error_e returnBusName(std::string& BusName) const ; void getInterfaceVersion(std::string& version) const ; @@ -245,7 +245,7 @@ private: class asycConnectWorker: public CAmWorker { public: - asycConnectWorker(CAmRoutingSenderAsync * asyncSender, CAmWorkerThreadPool* pool, IAmRoutingReceiverShadow* shadow, const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat); + asycConnectWorker(CAmRoutingSenderAsync * asyncSender, CAmWorkerThreadPool* pool, IAmRoutingReceiverShadow* shadow, const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat); void start2work(); void cancelWork(); private: @@ -255,7 +255,7 @@ private: am_connectionID_t mConnectionID; am_sourceID_t mSourceID; am_sinkID_t mSinkID; - am_ConnectionFormat_e mConnectionFormat; + am_CustomConnectionFormat_t mConnectionFormat; }; /** @@ -272,7 +272,7 @@ private: IAmRoutingReceiverShadow *mShadow; am_Handle_s mHandle; am_connectionID_t mConnectionID; - am_ConnectionFormat_e mConnectionFormat; + am_CustomConnectionFormat_t mConnectionFormat; }; /** @@ -286,7 +286,7 @@ private: class asyncSetSinkVolumeWorker: public CAmWorker { public: - asyncSetSinkVolumeWorker(CAmRoutingSenderAsync * asyncSender, CAmWorkerThreadPool* pool, IAmRoutingReceiverShadow* shadow, const am_volume_t currentVolume, const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time); + asyncSetSinkVolumeWorker(CAmRoutingSenderAsync * asyncSender, CAmWorkerThreadPool* pool, IAmRoutingReceiverShadow* shadow, const am_volume_t currentVolume, const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time); void start2work(); void cancelWork(); private: @@ -296,14 +296,14 @@ private: am_Handle_s mHandle; am_sinkID_t mSinkID; am_volume_t mVolume; - am_RampType_e mRamp; + am_CustomRampType_t mRamp; am_time_t mTime; }; class asyncSetSourceVolumeWorker: public CAmWorker { public: - asyncSetSourceVolumeWorker(CAmRoutingSenderAsync * asyncSender, CAmWorkerThreadPool* pool, IAmRoutingReceiverShadow* shadow, const am_volume_t currentVolume, const am_Handle_s handle, const am_sourceID_t SourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time); + asyncSetSourceVolumeWorker(CAmRoutingSenderAsync * asyncSender, CAmWorkerThreadPool* pool, IAmRoutingReceiverShadow* shadow, const am_volume_t currentVolume, const am_Handle_s handle, const am_sourceID_t SourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time); void start2work(); void cancelWork(); private: @@ -313,7 +313,7 @@ private: am_Handle_s mHandle; am_sourceID_t mSourceID; am_volume_t mVolume; - am_RampType_e mRamp; + am_CustomRampType_t mRamp; am_time_t mTime; }; diff --git a/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp b/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp index d6680d5..58499b0 100644 --- a/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp +++ b/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp @@ -266,7 +266,7 @@ am_Error_e CAmRoutingSenderAsync::asyncAbort(const am_Handle_s handle) return (E_UNKNOWN); } -am_Error_e CAmRoutingSenderAsync::asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) +am_Error_e CAmRoutingSenderAsync::asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat) { assert(mReceiveInterface!=0); assert(handle.handle!=0); @@ -364,7 +364,7 @@ am_Error_e CAmRoutingSenderAsync::asyncDisconnect(const am_Handle_s handle, cons return (E_OK); } -am_Error_e CAmRoutingSenderAsync::asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) +am_Error_e CAmRoutingSenderAsync::asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time) { assert(mReceiveInterface!=0); assert(handle.handle!=0); @@ -406,7 +406,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSinkVolume(const am_Handle_s handle, c return (E_OK); } -am_Error_e CAmRoutingSenderAsync::asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) +am_Error_e CAmRoutingSenderAsync::asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time) { assert(mReceiveInterface!=0); assert(handle.handle!=0); @@ -532,7 +532,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSinkSoundProperty(const am_Handle_s ha return (E_OK); } -am_Error_e CAmRoutingSenderAsync::asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time) +am_Error_e CAmRoutingSenderAsync::asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time) { //todo: implement crossfader (void) handle; @@ -655,17 +655,17 @@ std::vector<am_Sink_s> CAmRoutingSenderAsync::createSinkTable() std::vector<am_Sink_s> table; am_Sink_s item; am_SoundProperty_s sp; - sp.type = SP_EXAMPLE_BASS; + sp.type = SP_GENIVI_BASS; sp.value = 0; std::vector<am_MainSoundProperty_s> listMainSoundProperties; am_MainSoundProperty_s msp; - msp.type = MSP_EXAMPLE_BASS; + msp.type = MSP_GENIVI_BASS; msp.value = 5; listMainSoundProperties.push_back(msp); - msp.type = MSP_EXAMPLE_MID; + msp.type = MSP_GENIVI_MID; listMainSoundProperties.push_back(msp); - msp.type = MSP_EXAMPLE_TREBLE; + msp.type = MSP_GENIVI_TREBLE; listMainSoundProperties.push_back(msp); for (int16_t i = 0; i <= 10; i++) { @@ -926,7 +926,7 @@ std::vector<am_Gateway_s> CAmRoutingSenderAsync::createGatewayTable() return (table); } -asycConnectWorker::asycConnectWorker(CAmRoutingSenderAsync * asyncSender, CAmWorkerThreadPool *pool, IAmRoutingReceiverShadow* shadow, const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) : +asycConnectWorker::asycConnectWorker(CAmRoutingSenderAsync * asyncSender, CAmWorkerThreadPool *pool, IAmRoutingReceiverShadow* shadow, const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat) : CAmWorker(pool), // mAsyncSender(asyncSender), // mShadow(shadow), // @@ -1008,7 +1008,7 @@ void asycDisConnectWorker::cancelWork() mShadow->ackDisconnect(mHandle, mConnectionID, E_ABORTED); } -asyncSetSinkVolumeWorker::asyncSetSinkVolumeWorker(CAmRoutingSenderAsync *asyncSender, CAmWorkerThreadPool *pool, IAmRoutingReceiverShadow *shadow, const am_volume_t currentVolume, const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) : +asyncSetSinkVolumeWorker::asyncSetSinkVolumeWorker(CAmRoutingSenderAsync *asyncSender, CAmWorkerThreadPool *pool, IAmRoutingReceiverShadow *shadow, const am_volume_t currentVolume, const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time) : CAmWorker(pool), // mAsyncSender(asyncSender), // mShadow(shadow), // @@ -1057,7 +1057,7 @@ void asyncSetSinkVolumeWorker::cancelWork() mShadow->ackSetSinkVolumeChange(mHandle, mCurrentVolume, E_ABORTED); } -asyncSetSourceVolumeWorker::asyncSetSourceVolumeWorker(CAmRoutingSenderAsync *asyncSender, CAmWorkerThreadPool *pool, IAmRoutingReceiverShadow *shadow, const am_volume_t currentVolume, const am_Handle_s handle, const am_sourceID_t SourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) : +asyncSetSourceVolumeWorker::asyncSetSourceVolumeWorker(CAmRoutingSenderAsync *asyncSender, CAmWorkerThreadPool *pool, IAmRoutingReceiverShadow *shadow, const am_volume_t currentVolume, const am_Handle_s handle, const am_sourceID_t SourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time) : CAmWorker(pool), // mAsyncSender(asyncSender), // mShadow(shadow), // diff --git a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp index 8111494..6fff1a4 100644 --- a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp +++ b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp @@ -21,7 +21,7 @@ #include "TAmPluginTemplate.h" #include "MockIAmRoutingReceive.h" #include "shared/CAmDltWrapper.h" -#include "routing/IAmRoutingSend.h" + using namespace am; using namespace testing; @@ -29,11 +29,12 @@ using namespace testing; static CAmEnvironment* env; am_domainID_t CAmEnvironment::mDomainIDCount = 0; -static IAmRoutingSend* pRouter; + CAmEnvironment::CAmEnvironment() : pSocketHandler(), - pReceiveInterface(), + pRouter(NULL), + pReceiveInterface(NULL), ptimerCallback(this, &CAmEnvironment::timerCallback) { DefaultValue<am_Error_e>::Set(E_OK); // Sets the default value to be returned. @@ -46,18 +47,19 @@ CAmEnvironment::~CAmEnvironment() void CAmEnvironment::SetUp() { - ::testing::GTEST_FLAG(throw_on_failure) = false; logInfo("RoutingSendInterface Test started "); + pReceiveInterface = new MockIAmRoutingReceive(); + std::vector<int> domainIDs; domainIDs.push_back(0); domainIDs.push_back(1); - EXPECT_TRUE(Mock::VerifyAndClearExpectations(&env->pReceiveInterface)); - EXPECT_CALL(env->pReceiveInterface,getSocketHandler(_)).WillOnce(DoAll(SetArgReferee<0>(&env->pSocketHandler), Return(E_OK))); - EXPECT_CALL(env->pReceiveInterface,registerDomain(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleDomainRegister)); - EXPECT_CALL(env->pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSourceRegister)); - EXPECT_CALL(env->pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSinkRegister)); - EXPECT_CALL(env->pReceiveInterface,confirmRoutingReady(_,_)).Times(1); + + EXPECT_CALL(*env->pReceiveInterface,getSocketHandler(_)).WillOnce(DoAll(SetArgReferee<0>(&env->pSocketHandler), Return(E_OK))); + EXPECT_CALL(*env->pReceiveInterface,registerDomain(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleDomainRegister)); + EXPECT_CALL(*env->pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSourceRegister)); + EXPECT_CALL(*env->pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSinkRegister)); + EXPECT_CALL(*env->pReceiveInterface,confirmRoutingReady(_,_)).Times(1); IAmRoutingSend* (*createFunc)(); void* tempLibHandle = NULL; @@ -78,7 +80,7 @@ void CAmEnvironment::SetUp() exit(1); } - pRouter->startupInterface(&env->pReceiveInterface); + pRouter->startupInterface(env->pReceiveInterface); pRouter->setRoutingReady(10); timespec t; @@ -95,36 +97,10 @@ void CAmEnvironment::SetUp() void CAmEnvironment::TearDown() { - ::testing::GTEST_FLAG(throw_on_failure) = true; -} - -CAmRoutingReceiverAsync::CAmRoutingReceiverAsync() : - ptimerCallback(this, &CAmRoutingReceiverAsync::timerCallback) -{ -} - -CAmRoutingReceiverAsync::~CAmRoutingReceiverAsync() -{ -} - -void CAmRoutingReceiverAsync::timerCallback(sh_timerHandle_t handle, void *userData) -{ - (void) handle; - (void) userData; - env->pSocketHandler.stop_listening(); -} - -void CAmRoutingReceiverAsync::SetUp() -{ -// timespec t; -// t.tv_nsec = 0; -// t.tv_sec = 2; -// -// sh_timerHandle_t handle; -// -// shTimerCallBack *buf = &ptimerCallback; -// //lets use a timeout so the test will finish -// env->pSocketHandler.addTimer(t, buf, handle, (void*) NULL); + if(pReceiveInterface) + delete pReceiveInterface, pReceiveInterface = NULL; + if(pRouter) + delete pRouter, pRouter = NULL; } std::vector<std::string> CAmEnvironment::returnListPlugins() @@ -162,21 +138,54 @@ void CAmEnvironment::timerCallback(sh_timerHandle_t handle, void *userData) env->pSocketHandler.stop_listening(); } + +CAmRoutingReceiverAsync::CAmRoutingReceiverAsync() : + ptimerCallback(this, &CAmRoutingReceiverAsync::timerCallback) +{ +} + +CAmRoutingReceiverAsync::~CAmRoutingReceiverAsync() +{ +} + +void CAmRoutingReceiverAsync::timerCallback(sh_timerHandle_t handle, void *userData) +{ + (void) handle; + (void) userData; + env->pSocketHandler.stop_listening(); +} + +void CAmRoutingReceiverAsync::SetUp() +{ +// timespec t; +// t.tv_nsec = 0; +// t.tv_sec = 2; +// +// sh_timerHandle_t handle; +// +// shTimerCallBack *buf = &ptimerCallback; +// //lets use a timeout so the test will finish +// env->pSocketHandler.addTimer(t, buf, handle, (void*) NULL); +} + void CAmRoutingReceiverAsync::TearDown() { + } + TEST_F(CAmRoutingReceiverAsync,setDomainState) { am_domainID_t domainID = 1; am_DomainState_e state = DS_INDEPENDENT_RUNDOWN; - EXPECT_CALL(env->pReceiveInterface,hookDomainStateChange(_,DS_INDEPENDENT_RUNDOWN)).Times(1); + EXPECT_CALL(*env->pReceiveInterface,hookDomainStateChange(_,DS_INDEPENDENT_RUNDOWN)).Times(1); - ASSERT_EQ(E_OK, pRouter->setDomainState(domainID,state)); + ASSERT_EQ(E_OK, env->pRouter->setDomainState(domainID,state)); env->pSocketHandler.start_listenting(); } + TEST_F(CAmRoutingReceiverAsync,setSourceSoundProperty) { @@ -186,12 +195,12 @@ TEST_F(CAmRoutingReceiverAsync,setSourceSoundProperty) am_sourceID_t sourceID = 3; am_SoundProperty_s property; - property.type = SP_EXAMPLE_MID; + property.type = SP_GENIVI_MID; property.value = 24; - EXPECT_CALL(env->pReceiveInterface,ackSetSourceSoundProperty(_,E_OK)).Times(1); + EXPECT_CALL(*env->pReceiveInterface,ackSetSourceSoundProperty(_,E_OK)).Times(1); - ASSERT_EQ(E_OK, pRouter->asyncSetSourceSoundProperty(handle,sourceID,property)); + ASSERT_EQ(E_OK, env->pRouter->asyncSetSourceSoundProperty(handle,sourceID,property)); env->pSocketHandler.start_listenting(); } @@ -204,12 +213,12 @@ TEST_F(CAmRoutingReceiverAsync,setSinkSoundProperty) am_sinkID_t sinkID = 1; am_SoundProperty_s property; - property.type = SP_EXAMPLE_MID; + property.type = SP_GENIVI_MID; property.value = 24; - EXPECT_CALL(env->pReceiveInterface,ackSetSinkSoundProperty(_,E_OK)).Times(1); + EXPECT_CALL(*env->pReceiveInterface,ackSetSinkSoundProperty(_,E_OK)).Times(1); - ASSERT_EQ(E_OK, pRouter->asyncSetSinkSoundProperty(handle,sinkID,property)); + ASSERT_EQ(E_OK, env->pRouter->asyncSetSinkSoundProperty(handle,sinkID,property)); env->pSocketHandler.start_listenting(); } @@ -223,9 +232,9 @@ TEST_F(CAmRoutingReceiverAsync,setSourceState) am_sourceID_t sourceID = 1; am_SourceState_e state = SS_OFF; - EXPECT_CALL(env->pReceiveInterface,ackSetSourceState(_,E_OK)).Times(1); + EXPECT_CALL(*env->pReceiveInterface,ackSetSourceState(_,E_OK)).Times(1); - ASSERT_EQ(E_OK, pRouter->asyncSetSourceState(handle,sourceID,state)); + ASSERT_EQ(E_OK, env->pRouter->asyncSetSourceState(handle,sourceID,state)); env->pSocketHandler.start_listenting(); } @@ -238,13 +247,13 @@ TEST_F(CAmRoutingReceiverAsync,setSourceVolume) am_sourceID_t sourceID = 3; am_volume_t volume = 3; - am_RampType_e ramp = RAMP_GENIVI_DIRECT; + am_CustomRampType_t ramp = RAMP_GENIVI_DIRECT; am_time_t myTime = 25; - EXPECT_CALL(env->pReceiveInterface,ackSourceVolumeTick(_,sourceID,_)).Times(AtLeast(1)); - EXPECT_CALL(env->pReceiveInterface,ackSetSourceVolumeChange(_,volume,E_OK)).Times(1); + EXPECT_CALL(*env->pReceiveInterface,ackSourceVolumeTick(_,sourceID,_)).Times(AtLeast(1)); + EXPECT_CALL(*env->pReceiveInterface,ackSetSourceVolumeChange(_,volume,E_OK)).Times(1); - ASSERT_EQ(E_OK, pRouter->asyncSetSourceVolume(handle,sourceID,volume,ramp,myTime)); + ASSERT_EQ(E_OK, env->pRouter->asyncSetSourceVolume(handle,sourceID,volume,ramp,myTime)); env->pSocketHandler.start_listenting(); } @@ -257,13 +266,13 @@ TEST_F(CAmRoutingReceiverAsync,setSinkVolume) am_sinkID_t sinkID = 1; am_volume_t volume = 9; - am_RampType_e ramp = RAMP_GENIVI_DIRECT; + am_CustomRampType_t ramp = RAMP_GENIVI_DIRECT; am_time_t myTime = 25; - EXPECT_CALL(env->pReceiveInterface,ackSinkVolumeTick(_,sinkID,_)).Times(AtLeast(2)); - EXPECT_CALL(env->pReceiveInterface,ackSetSinkVolumeChange(_,volume,E_OK)).Times(1); + EXPECT_CALL(*env->pReceiveInterface,ackSinkVolumeTick(_,sinkID,_)).Times(AtLeast(2)); + EXPECT_CALL(*env->pReceiveInterface,ackSetSinkVolumeChange(_,volume,E_OK)).Times(1); - ASSERT_EQ(E_OK, pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime)); + ASSERT_EQ(E_OK, env->pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime)); env->pSocketHandler.start_listenting(); } @@ -276,15 +285,15 @@ TEST_F(CAmRoutingReceiverAsync,setSinkVolumeAbort) am_sinkID_t sinkID = 2; am_volume_t volume = 25; - am_RampType_e ramp = RAMP_GENIVI_DIRECT; + am_CustomRampType_t ramp = RAMP_GENIVI_DIRECT; am_time_t myTime = 25; - EXPECT_CALL(env->pReceiveInterface, ackSinkVolumeTick(_,sinkID,_)); - EXPECT_CALL(env->pReceiveInterface,ackSetSinkVolumeChange(_,AllOf(Ne(volume),Ne(0)),E_ABORTED)).Times(1); + EXPECT_CALL(*env->pReceiveInterface, ackSinkVolumeTick(_,sinkID,_)); + EXPECT_CALL(*env->pReceiveInterface,ackSetSinkVolumeChange(_,AllOf(Ne(volume),Ne(0)),E_ABORTED)).Times(1); - ASSERT_EQ(E_OK, pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime)); + ASSERT_EQ(E_OK, env->pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime)); sleep(0.5); - ASSERT_EQ(E_OK, pRouter->asyncAbort(handle)); + ASSERT_EQ(E_OK, env->pRouter->asyncAbort(handle)); env->pSocketHandler.start_listenting(); } @@ -297,9 +306,9 @@ TEST_F(CAmRoutingReceiverAsync,disconnectNonExisting) am_connectionID_t connectionID = 4; - EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); - EXPECT_CALL(env->pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0); - ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncDisconnect(handle,connectionID)); + EXPECT_CALL(*env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); + EXPECT_CALL(*env->pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0); + ASSERT_EQ(E_NON_EXISTENT, env->pRouter->asyncDisconnect(handle,connectionID)); env->pSocketHandler.start_listenting(); } @@ -317,12 +326,12 @@ TEST_F(CAmRoutingReceiverAsync,disconnectTooEarly) am_connectionID_t connectionID = 4; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); - EXPECT_CALL(env->pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0); - ASSERT_EQ(E_OK, pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); - ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncDisconnect(handle,connectionID)); + EXPECT_CALL(*env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); + EXPECT_CALL(*env->pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0); + ASSERT_EQ(E_OK, env->pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); + ASSERT_EQ(E_NON_EXISTENT, env->pRouter->asyncDisconnect(handle,connectionID)); env->pSocketHandler.start_listenting(); } @@ -340,14 +349,14 @@ TEST_F(CAmRoutingReceiverAsync,disconnectAbort) am_connectionID_t connectionID = 5; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); - EXPECT_CALL(env->pReceiveInterface, ackDisconnect(_,connectionID,E_ABORTED)); - ASSERT_EQ(E_OK, pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); + EXPECT_CALL(*env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); + EXPECT_CALL(*env->pReceiveInterface, ackDisconnect(_,connectionID,E_ABORTED)); + ASSERT_EQ(E_OK, env->pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); sleep(2); - ASSERT_EQ(E_OK, pRouter->asyncDisconnect(handle,connectionID)); - ASSERT_EQ(E_OK, pRouter->asyncAbort(handle)); + ASSERT_EQ(E_OK, env->pRouter->asyncDisconnect(handle,connectionID)); + ASSERT_EQ(E_OK, env->pRouter->asyncAbort(handle)); env->pSocketHandler.start_listenting(); } @@ -365,13 +374,13 @@ TEST_F(CAmRoutingReceiverAsync,disconnect) am_connectionID_t connectionID = 4; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); - EXPECT_CALL(env->pReceiveInterface, ackDisconnect(_,connectionID,E_OK)); - ASSERT_EQ(E_OK, pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); + EXPECT_CALL(*env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); + EXPECT_CALL(*env->pReceiveInterface, ackDisconnect(_,connectionID,E_OK)); + ASSERT_EQ(E_OK, env->pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); sleep(2); - ASSERT_EQ(E_OK, pRouter->asyncDisconnect(handle,connectionID)); + ASSERT_EQ(E_OK, env->pRouter->asyncDisconnect(handle,connectionID)); env->pSocketHandler.start_listenting(); } @@ -385,12 +394,12 @@ TEST_F(CAmRoutingReceiverAsync,connectAbortTooLate) am_connectionID_t connectionID = 4; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(1); - ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); + EXPECT_CALL(*env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(1); + ASSERT_EQ(E_OK, env->pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); sleep(3); - ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncAbort(handle)); + ASSERT_EQ(E_NON_EXISTENT, env->pRouter->asyncAbort(handle)); env->pSocketHandler.start_listenting(); } @@ -404,12 +413,12 @@ TEST_F(CAmRoutingReceiverAsync,connectAbort) am_connectionID_t connectionID = 4; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_ABORTED)).Times(1); - ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); + EXPECT_CALL(*env->pReceiveInterface,ackConnect(_,connectionID,E_ABORTED)).Times(1); + ASSERT_EQ(E_OK, env->pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); sleep(0.5); - ASSERT_EQ(E_OK, pRouter->asyncAbort(handle)); + ASSERT_EQ(E_OK, env->pRouter->asyncAbort(handle)); env->pSocketHandler.start_listenting(); } @@ -423,10 +432,10 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongFormat) am_connectionID_t connectionID = 4; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_MONO; + am_CustomConnectionFormat_t format = CF_GENIVI_MONO; - EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); - ASSERT_EQ(E_WRONG_FORMAT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); + EXPECT_CALL(*env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); + ASSERT_EQ(E_WRONG_FORMAT, env->pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); env->pSocketHandler.start_listenting(); } @@ -440,10 +449,10 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongSink) am_connectionID_t connectionID = 4; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 122; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); - ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); + EXPECT_CALL(*env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); + ASSERT_EQ(E_NON_EXISTENT, env->pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); env->pSocketHandler.start_listenting(); } @@ -456,10 +465,10 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongSource) am_connectionID_t connectionID = 4; am_sourceID_t sourceID = 25; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); - ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); + EXPECT_CALL(*env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); + ASSERT_EQ(E_NON_EXISTENT, env->pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); env->pSocketHandler.start_listenting(); } @@ -473,10 +482,10 @@ TEST_F(CAmRoutingReceiverAsync,connect) am_connectionID_t connectionID = 4; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); - ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); + EXPECT_CALL(*env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); + ASSERT_EQ(E_OK, env->pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); env->pSocketHandler.start_listenting(); } @@ -490,23 +499,23 @@ TEST_F(CAmRoutingReceiverAsync,connectNoMoreThreads) am_connectionID_t connectionID = 1; am_sourceID_t sourceID = 2; am_sinkID_t sinkID = 1; - am_ConnectionFormat_e format = CF_GENIVI_ANALOG; + am_CustomConnectionFormat_t format = CF_GENIVI_ANALOG; - EXPECT_CALL(env->pReceiveInterface,ackConnect(_,_,E_OK)).Times(10); + EXPECT_CALL(*env->pReceiveInterface,ackConnect(_,_,E_OK)).Times(10); for (int i = 0; i < 10; i++) { handle.handle++; connectionID++; - ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); + ASSERT_EQ(E_OK, env->pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); } - ASSERT_EQ(E_NOT_POSSIBLE, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); + ASSERT_EQ(E_NOT_POSSIBLE, env->pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); env->pSocketHandler.start_listenting(); } int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - ::testing::Environment* const env = ::testing::AddGlobalTestEnvironment(new CAmEnvironment); + CAmEnvironment* const env = (CAmEnvironment*)::testing::AddGlobalTestEnvironment(new CAmEnvironment); (void) env; return RUN_ALL_TESTS(); } diff --git a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h index a9b2007..0c478e7 100644 --- a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h +++ b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h @@ -24,6 +24,7 @@ #include "MockIAmRoutingReceive.h" #include "shared/CAmSocketHandler.h" #include "shared/CAmSerializer.h" +#include "routing/IAmRoutingSend.h" #define UNIT_TEST 1 @@ -34,7 +35,8 @@ class CAmEnvironment: public ::testing::Environment { public: CAmSocketHandler pSocketHandler; - MockIAmRoutingReceive pReceiveInterface; + IAmRoutingSend* pRouter; + MockIAmRoutingReceive *pReceiveInterface; static std::vector<std::string> returnListPlugins(); static am_Error_e handleDomainRegister(const am_Domain_s& domainData, am_domainID_t& domainID); static am_Error_e handleSourceRegister(const am_Source_s& sourceData, am_sourceID_t& sourceID); diff --git a/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h b/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h index d9507ab..02ecd25 100644 --- a/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h +++ b/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h @@ -103,11 +103,11 @@ class MockIAmRoutingReceive : public IAmRoutingReceive { MOCK_METHOD2(confirmRoutingRundown, void(const uint16_t handle, const am_Error_e error)); MOCK_METHOD4(updateGateway, - am_Error_e(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceFormats, const std::vector<am_ConnectionFormat_e>& listSinkFormats, const std::vector<bool>& convertionMatrix)); + am_Error_e(const am_gatewayID_t gatewayID, const std::vector<am_CustomAvailabilityReason_t>& listSourceFormats, const std::vector<am_CustomAvailabilityReason_t>& listSinkFormats, const std::vector<bool>& convertionMatrix)); MOCK_METHOD5(updateSink, - am_Error_e(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)); + am_Error_e(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomAvailabilityReason_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)); MOCK_METHOD5(updateSource, - am_Error_e(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)); + am_Error_e(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomAvailabilityReason_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)); MOCK_METHOD3(ackSetVolumes, void(const am_Handle_s handle, const std::vector<am_Volumes_s>& listvolumes, const am_Error_e error)); MOCK_METHOD2(ackSinkNotificationConfiguration, |