summaryrefslogtreecommitdiff
path: root/PluginRoutingInterfaceAsync
diff options
context:
space:
mode:
authorchristian linke <christian.linke@bmw.de>2012-12-17 16:15:11 +0100
committerchristian linke <christian.linke@bmw.de>2012-12-17 16:15:11 +0100
commit54c5e965fe8f9a53a78834028fd65c792493da2b (patch)
tree560d7b1209e6a8d4798de9568e4b4a947c2ab42a /PluginRoutingInterfaceAsync
parent215e8a72dc81e8a86dd5b3a8ca40fd2c7c6a0b9c (diff)
downloadaudiomanager-54c5e965fe8f9a53a78834028fd65c792493da2b.tar.gz
* added new interfaces & nsm support + nsm tests + fixed some unit tests + fixed rundown
Signed-off-by: christian linke <christian.linke@bmw.de>
Diffstat (limited to 'PluginRoutingInterfaceAsync')
-rw-r--r--PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h3
-rw-r--r--PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h4
-rw-r--r--PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp48
-rw-r--r--PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp12
-rw-r--r--PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp117
-rw-r--r--PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h2
-rw-r--r--PluginRoutingInterfaceAsync/test/CMakeLists.txt1
-rw-r--r--PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h173
8 files changed, 205 insertions, 155 deletions
diff --git a/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h b/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h
index c0da207..6d1fbed 100644
--- a/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h
+++ b/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h
@@ -138,6 +138,9 @@ public:
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 ;
+ am_Error_e asyncSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes) ;
+ am_Error_e asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) ;
+ am_Error_e asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) ;
/**
* threadafe insert of route and connectionID
diff --git a/PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h b/PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h
index 90ced6f..48056f1 100644
--- a/PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h
+++ b/PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h
@@ -56,8 +56,8 @@ public:
am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
am_Error_e deregisterSource(const am_sourceID_t sourceID) ;
am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
- void confirmRoutingReady(uint16_t starupHandle);
- void confirmRoutingRundown(uint16_t rundownHandle);
+ void confirmRoutingReady(uint16_t starupHandle, am_Error_e error);
+ void confirmRoutingRundown(uint16_t rundownHandle,am_Error_e error);
private:
diff --git a/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp b/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp
index 43de210..83415e9 100644
--- a/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp
+++ b/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp
@@ -73,8 +73,8 @@ mNumThreads(numThreads)
mListWorkers.resize(mNumThreads);
for (int i=0;i<mNumThreads;i++)
{
- sem_init(&mListWorkers[i].block,NULL,NULL);
- sem_init(&mListWorkers[i].cancel,NULL,NULL);
+ sem_init(&mListWorkers[i].block,0,0);
+ sem_init(&mListWorkers[i].cancel,0,0);
mListWorkers[i].busy=false;
mListWorkers[i].workerID=++workerID;
pthread_create(&mListWorkers[i].threadID,NULL,&CAmWorkerThreadPool::CAmWorkerThread,(void*)&mListWorkers[i]);
@@ -234,7 +234,7 @@ void CAmRoutingSenderAsync::setRoutingReady(const uint16_t handle)
void CAmRoutingSenderAsync::setRoutingRundown(const uint16_t handle)
{
assert(mReceiveInterface!=0);
- mShadow->confirmRoutingRundown(handle);
+ mShadow->confirmRoutingRundown(handle,E_OK);
}
am_Error_e CAmRoutingSenderAsync::asyncAbort(const am_Handle_s handle)
@@ -315,7 +315,7 @@ am_Error_e CAmRoutingSenderAsync::asyncConnect(const am_Handle_s handle, const a
//save the handle related to the workerID
pthread_mutex_lock(&mMapHandleWorkerMutex);
- mMapHandleWorker.insert(std::make_pair(handle.handle, work));
+ mMapHandleWorker.insert(std::make_pair(+handle.handle, work));
pthread_mutex_unlock(&mMapHandleWorkerMutex);
return (E_OK);
@@ -350,7 +350,7 @@ am_Error_e CAmRoutingSenderAsync::asyncDisconnect(const am_Handle_s handle, cons
//save the handle related to the workerID
pthread_mutex_lock(&mMapHandleWorkerMutex);
- mMapHandleWorker.insert(std::make_pair(handle.handle, work));
+ mMapHandleWorker.insert(std::make_pair(+handle.handle, work));
pthread_mutex_unlock(&mMapHandleWorkerMutex);
return (E_OK);
@@ -392,7 +392,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSinkVolume(const am_Handle_s handle, c
//save the handle related to the workerID
pthread_mutex_lock(&mMapHandleWorkerMutex);
- mMapHandleWorker.insert(std::make_pair(handle.handle, work));
+ mMapHandleWorker.insert(std::make_pair(+handle.handle, work));
pthread_mutex_unlock(&mMapHandleWorkerMutex);
return (E_OK);
@@ -434,7 +434,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSourceVolume(const am_Handle_s handle,
//save the handle related to the workerID
pthread_mutex_lock(&mMapHandleWorkerMutex);
- mMapHandleWorker.insert(std::make_pair(handle.handle, work));
+ mMapHandleWorker.insert(std::make_pair(+handle.handle, work));
pthread_mutex_unlock(&mMapHandleWorkerMutex);
return (E_OK);
@@ -476,7 +476,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSourceState(const am_Handle_s handle,
//save the handle related to the workerID
pthread_mutex_lock(&mMapHandleWorkerMutex);
- mMapHandleWorker.insert(std::make_pair(handle.handle, work));
+ mMapHandleWorker.insert(std::make_pair(+handle.handle, work));
pthread_mutex_unlock(&mMapHandleWorkerMutex);
return (E_OK);
@@ -518,7 +518,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSinkSoundProperty(const am_Handle_s ha
//save the handle related to the workerID
pthread_mutex_lock(&mMapHandleWorkerMutex);
- mMapHandleWorker.insert(std::make_pair(handle.handle, work));
+ mMapHandleWorker.insert(std::make_pair(+handle.handle, work));
pthread_mutex_unlock(&mMapHandleWorkerMutex);
return (E_OK);
@@ -607,7 +607,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSourceSoundProperty(const am_Handle_s
//save the handle related to the workerID
pthread_mutex_lock(&mMapHandleWorkerMutex);
- mMapHandleWorker.insert(std::make_pair(handle.handle, work));
+ mMapHandleWorker.insert(std::make_pair(+handle.handle, work));
pthread_mutex_unlock(&mMapHandleWorkerMutex);
return (E_OK);
@@ -880,6 +880,32 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSinkSoundProperties(const am_Handle_s
return (E_NOT_USED);
}
+am_Error_e am::CAmRoutingSenderAsync::asyncSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes)
+{
+ (void)handle;
+ (void)listVolumes;
+ //todo: implement
+ return (E_NOT_USED);
+}
+
+am_Error_e am::CAmRoutingSenderAsync::asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration)
+{
+ (void)handle;
+ (void)sinkID;
+ (void)notificationConfiguration;
+ //todo: implement
+ return (E_NOT_USED);
+}
+
+am_Error_e am::CAmRoutingSenderAsync::asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration)
+{
+ (void)handle;
+ (void)sourceID;
+ (void)notificationConfiguration;
+ //todo: implement
+ return (E_NOT_USED);
+}
+
std::vector<am_Gateway_s> CAmRoutingSenderAsync::createGatewayTable()
{
std::vector<am_Gateway_s> table;
@@ -1283,7 +1309,7 @@ void syncRegisterWorker::start2work()
}
mAsyncSender->updateSinkListSafe(mListSinks);
- mShadow->confirmRoutingReady(mHandle);
+ mShadow->confirmRoutingReady(mHandle,E_OK);
}
void syncRegisterWorker::cancelWork()
diff --git a/PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp b/PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp
index 5ab2360..71b0cc5 100644
--- a/PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp
+++ b/PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp
@@ -99,12 +99,12 @@ void IAmRoutingReceiverShadow::hookInterruptStatusChange(const am_sourceID_t sou
void IAmRoutingReceiverShadow::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
{
- mSerializer.asyncCall<IAmRoutingReceive, const am_sinkID_t, const am_Availability_s&>(mRoutingReceiveInterface, &IAmRoutingReceive::hookSinkAvailablityStatusChange, sinkID, availability);
+ mSerializer.asyncCall<IAmRoutingReceive, const am_sinkID_t, const am_Availability_s>(mRoutingReceiveInterface, &IAmRoutingReceive::hookSinkAvailablityStatusChange, sinkID, availability);
}
void IAmRoutingReceiverShadow::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
{
- mSerializer.asyncCall<IAmRoutingReceive, const am_sourceID_t, const am_Availability_s&>(mRoutingReceiveInterface, &IAmRoutingReceive::hookSourceAvailablityStatusChange, sourceID, availability);
+ mSerializer.asyncCall<IAmRoutingReceive, const am_sourceID_t, const am_Availability_s>(mRoutingReceiveInterface, &IAmRoutingReceive::hookSourceAvailablityStatusChange, sourceID, availability);
}
void IAmRoutingReceiverShadow::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
@@ -173,14 +173,14 @@ am_Error_e am::IAmRoutingReceiverShadow::registerCrossfader(const am_Crossfader_
return (error);
}
-void am::IAmRoutingReceiverShadow::confirmRoutingReady(uint16_t starupHandle)
+void am::IAmRoutingReceiverShadow::confirmRoutingReady(uint16_t starupHandle, am_Error_e error)
{
- mSerializer.asyncCall<IAmRoutingReceive,uint16_t>(mRoutingReceiveInterface,&IAmRoutingReceive::confirmRoutingReady,starupHandle);
+ mSerializer.asyncCall<IAmRoutingReceive,uint16_t,am_Error_e>(mRoutingReceiveInterface,&IAmRoutingReceive::confirmRoutingReady,starupHandle,error);
}
-void am::IAmRoutingReceiverShadow::confirmRoutingRundown(uint16_t rundownHandle)
+void am::IAmRoutingReceiverShadow::confirmRoutingRundown(uint16_t rundownHandle, am_Error_e error)
{
- mSerializer.asyncCall<IAmRoutingReceive,uint16_t>(mRoutingReceiveInterface,&IAmRoutingReceive::confirmRoutingRundown,rundownHandle);
+ mSerializer.asyncCall<IAmRoutingReceive,uint16_t,am_Error_e>(mRoutingReceiveInterface,&IAmRoutingReceive::confirmRoutingRundown,rundownHandle,error);
}
diff --git a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp
index 17e4cff..c02d5d3 100644
--- a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp
+++ b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp
@@ -26,15 +26,18 @@
using namespace am;
using namespace testing;
+static CAmEnvironment* env;
+
am_domainID_t CAmEnvironment::mDomainIDCount = 0;
static IAmRoutingSend* pRouter;
-static CAmSocketHandler pSocketHandler;
-static MockIAmRoutingReceive pReceiveInterface;
CAmEnvironment::CAmEnvironment() :
+ pSocketHandler(),
+ pReceiveInterface(),
ptimerCallback(this, &CAmEnvironment::timerCallback)
{
DefaultValue<am_Error_e>::Set(E_OK); // Sets the default value to be returned.
+ env=this;
}
CAmEnvironment::~CAmEnvironment()
@@ -49,11 +52,11 @@ void CAmEnvironment::SetUp()
domainIDs.push_back(0);
domainIDs.push_back(1);
- EXPECT_CALL(pReceiveInterface,getSocketHandler(_)).WillOnce(DoAll(SetArgReferee<0>(&pSocketHandler), Return(E_OK)));
- EXPECT_CALL(pReceiveInterface,registerDomain(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleDomainRegister));
- EXPECT_CALL(pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSourceRegister));
- EXPECT_CALL(pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSinkRegister));
- EXPECT_CALL(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;
@@ -74,7 +77,7 @@ void CAmEnvironment::SetUp()
exit(1);
}
- pRouter->startupInterface(&pReceiveInterface);
+ pRouter->startupInterface(&env->pReceiveInterface);
pRouter->setRoutingReady(10);
timespec t;
@@ -84,8 +87,8 @@ void CAmEnvironment::SetUp()
sh_timerHandle_t handle;
//lets use a timeout so the test will finish
- pSocketHandler.addTimer(t, &ptimerCallback, handle, (void*) NULL);
- pSocketHandler.start_listenting();
+ env->pSocketHandler.addTimer(t, &ptimerCallback, handle, (void*) NULL);
+ env->pSocketHandler.start_listenting();
}
@@ -107,7 +110,7 @@ void CAmRoutingReceiverAsync::timerCallback(sh_timerHandle_t handle, void *userD
{
(void) handle;
(void) userData;
- pSocketHandler.stop_listening();
+ env->pSocketHandler.stop_listening();
}
void CAmRoutingReceiverAsync::SetUp()
@@ -120,7 +123,7 @@ void CAmRoutingReceiverAsync::SetUp()
//
// shTimerCallBack *buf = &ptimerCallback;
// //lets use a timeout so the test will finish
-// pSocketHandler.addTimer(t, buf, handle, (void*) NULL);
+// env->pSocketHandler.addTimer(t, buf, handle, (void*) NULL);
}
std::vector<std::string> CAmEnvironment::returnListPlugins()
@@ -154,8 +157,8 @@ void CAmEnvironment::timerCallback(sh_timerHandle_t handle, void *userData)
{
(void) handle;
(void) userData;
- pSocketHandler.restartTimer(handle);
- pSocketHandler.stop_listening();
+ env->pSocketHandler.restartTimer(handle);
+ env->pSocketHandler.stop_listening();
}
void CAmRoutingReceiverAsync::TearDown()
@@ -167,10 +170,10 @@ TEST_F(CAmRoutingReceiverAsync,setDomainState)
am_domainID_t domainID = 1;
am_DomainState_e state = DS_INDEPENDENT_RUNDOWN;
- EXPECT_CALL(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));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,setSourceSoundProperty)
@@ -185,10 +188,10 @@ TEST_F(CAmRoutingReceiverAsync,setSourceSoundProperty)
property.type = SP_EXAMPLE_MID;
property.value = 24;
- EXPECT_CALL(pReceiveInterface,ackSetSourceSoundProperty(_,E_OK)).Times(1);
+ EXPECT_CALL(env->pReceiveInterface,ackSetSourceSoundProperty(_,E_OK)).Times(1);
ASSERT_EQ(E_OK, pRouter->asyncSetSourceSoundProperty(handle,sourceID,property));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,setSinkSoundProperty)
@@ -203,10 +206,10 @@ TEST_F(CAmRoutingReceiverAsync,setSinkSoundProperty)
property.type = SP_EXAMPLE_MID;
property.value = 24;
- EXPECT_CALL(pReceiveInterface,ackSetSinkSoundProperty(_,E_OK)).Times(1);
+ EXPECT_CALL(env->pReceiveInterface,ackSetSinkSoundProperty(_,E_OK)).Times(1);
ASSERT_EQ(E_OK, pRouter->asyncSetSinkSoundProperty(handle,sinkID,property));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,setSourceState)
@@ -219,10 +222,10 @@ TEST_F(CAmRoutingReceiverAsync,setSourceState)
am_sourceID_t sourceID = 1;
am_SourceState_e state = SS_OFF;
- EXPECT_CALL(pReceiveInterface,ackSetSourceState(_,E_OK)).Times(1);
+ EXPECT_CALL(env->pReceiveInterface,ackSetSourceState(_,E_OK)).Times(1);
ASSERT_EQ(E_OK, pRouter->asyncSetSourceState(handle,sourceID,state));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,setSourceVolume)
@@ -237,11 +240,11 @@ TEST_F(CAmRoutingReceiverAsync,setSourceVolume)
am_RampType_e ramp = RAMP_GENIVI_DIRECT;
am_time_t myTime = 25;
- EXPECT_CALL(pReceiveInterface,ackSourceVolumeTick(_,sourceID,_)).Times(AtLeast(1));
- EXPECT_CALL(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));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,setSinkVolume)
@@ -256,11 +259,11 @@ TEST_F(CAmRoutingReceiverAsync,setSinkVolume)
am_RampType_e ramp = RAMP_GENIVI_DIRECT;
am_time_t myTime = 25;
- EXPECT_CALL(pReceiveInterface,ackSinkVolumeTick(_,sinkID,_)).Times(AtLeast(2));
- EXPECT_CALL(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));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,setSinkVolumeAbort)
@@ -275,13 +278,13 @@ TEST_F(CAmRoutingReceiverAsync,setSinkVolumeAbort)
am_RampType_e ramp = RAMP_GENIVI_DIRECT;
am_time_t myTime = 25;
- EXPECT_CALL(pReceiveInterface, ackSinkVolumeTick(_,sinkID,_));
- EXPECT_CALL(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));
sleep(0.5);
ASSERT_EQ(E_OK, pRouter->asyncAbort(handle));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,disconnectNonExisting)
@@ -293,10 +296,10 @@ TEST_F(CAmRoutingReceiverAsync,disconnectNonExisting)
am_connectionID_t connectionID = 4;
- EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
- EXPECT_CALL(pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0);
+ 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));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,disconnectTooEarly)
@@ -315,11 +318,11 @@ TEST_F(CAmRoutingReceiverAsync,disconnectTooEarly)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
- EXPECT_CALL(pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0);
+ 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));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,disconnectAbort)
@@ -338,13 +341,13 @@ TEST_F(CAmRoutingReceiverAsync,disconnectAbort)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
- EXPECT_CALL(pReceiveInterface, ackDisconnect(_,connectionID,E_ABORTED));
+ 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));
sleep(2);
ASSERT_EQ(E_OK, pRouter->asyncDisconnect(handle,connectionID));
ASSERT_EQ(E_OK, pRouter->asyncAbort(handle));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,disconnect)
@@ -363,12 +366,12 @@ TEST_F(CAmRoutingReceiverAsync,disconnect)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
- EXPECT_CALL(pReceiveInterface, ackDisconnect(_,connectionID,E_OK));
+ 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));
sleep(2);
ASSERT_EQ(E_OK, pRouter->asyncDisconnect(handle,connectionID));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,connectAbortTooLate)
@@ -383,11 +386,11 @@ TEST_F(CAmRoutingReceiverAsync,connectAbortTooLate)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(1);
+ EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(1);
ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
sleep(3);
ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncAbort(handle));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,connectAbort)
@@ -402,11 +405,11 @@ TEST_F(CAmRoutingReceiverAsync,connectAbort)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_ABORTED)).Times(1);
+ EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_ABORTED)).Times(1);
ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
sleep(0.5);
ASSERT_EQ(E_OK, pRouter->asyncAbort(handle));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,connectWrongFormat)
@@ -421,9 +424,9 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongFormat)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_MONO;
- EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
+ EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
ASSERT_EQ(E_WRONG_FORMAT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,connectWrongSink)
@@ -438,9 +441,9 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongSink)
am_sinkID_t sinkID = 122;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
+ EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,connectWrongSource)
@@ -454,9 +457,9 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongSource)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
+ EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,connect)
@@ -471,9 +474,9 @@ TEST_F(CAmRoutingReceiverAsync,connect)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
+ EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK));
ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
TEST_F(CAmRoutingReceiverAsync,connectNoMoreThreads)
@@ -488,7 +491,7 @@ TEST_F(CAmRoutingReceiverAsync,connectNoMoreThreads)
am_sinkID_t sinkID = 1;
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface,ackConnect(_,_,E_OK)).Times(10);
+ EXPECT_CALL(env->pReceiveInterface,ackConnect(_,_,E_OK)).Times(10);
for (int i = 0; i < 10; i++)
{
handle.handle++;
@@ -496,7 +499,7 @@ TEST_F(CAmRoutingReceiverAsync,connectNoMoreThreads)
ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
}
ASSERT_EQ(E_NOT_POSSIBLE, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
- pSocketHandler.start_listenting();
+ env->pSocketHandler.start_listenting();
}
int main(int argc, char **argv)
diff --git a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h
index 37fd5a1..a9b2007 100644
--- a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h
+++ b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h
@@ -33,6 +33,8 @@ namespace am
class CAmEnvironment: public ::testing::Environment
{
public:
+ CAmSocketHandler pSocketHandler;
+ 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/CMakeLists.txt b/PluginRoutingInterfaceAsync/test/CMakeLists.txt
index 1097d41..a8ca55c 100644
--- a/PluginRoutingInterfaceAsync/test/CMakeLists.txt
+++ b/PluginRoutingInterfaceAsync/test/CMakeLists.txt
@@ -29,7 +29,6 @@ FIND_PACKAGE(DBUS REQUIRED)
IF(WITH_DLT)
pkg_check_modules(DLT REQUIRED automotive-dlt)
-)
ENDIF(WITH_DLT)
pkg_check_modules(SQLITE REQUIRED sqlite3)
diff --git a/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h b/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h
index 0554c5c..1dafefc 100644
--- a/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h
+++ b/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h
@@ -24,84 +24,101 @@ namespace am {
class MockIAmRoutingReceive : public IAmRoutingReceive {
public:
- MOCK_METHOD3(ackConnect,
- void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error));
- MOCK_METHOD3(ackDisconnect,
- void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error));
- MOCK_METHOD3(ackSetSinkVolumeChange,
- void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error));
- MOCK_METHOD3(ackSetSourceVolumeChange,
- void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error));
- MOCK_METHOD2(ackSetSourceState,
- void(const am_Handle_s handle, const am_Error_e error));
- MOCK_METHOD2(ackSetSinkSoundProperties,
- void(const am_Handle_s handle, const am_Error_e error));
- MOCK_METHOD2(ackSetSinkSoundProperty,
- void(const am_Handle_s handle, const am_Error_e error));
- MOCK_METHOD2(ackSetSourceSoundProperties,
- void(const am_Handle_s handle, const am_Error_e error));
- MOCK_METHOD2(ackSetSourceSoundProperty,
- void(const am_Handle_s handle, const am_Error_e error));
- MOCK_METHOD3(ackCrossFading,
- void(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error));
- MOCK_METHOD3(ackSourceVolumeTick,
- void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume));
- MOCK_METHOD3(ackSinkVolumeTick,
- void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume));
- MOCK_METHOD2(peekDomain,
- am_Error_e(const std::string& name, am_domainID_t& domainID));
- MOCK_METHOD2(registerDomain,
- am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID));
- MOCK_METHOD1(deregisterDomain,
- am_Error_e(const am_domainID_t domainID));
- MOCK_METHOD2(registerGateway,
- am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID));
- MOCK_METHOD1(deregisterGateway,
- am_Error_e(const am_gatewayID_t gatewayID));
- MOCK_METHOD2(peekSink,
- am_Error_e(const std::string& name, am_sinkID_t& sinkID));
- MOCK_METHOD2(registerSink,
- am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID));
- MOCK_METHOD1(deregisterSink,
- am_Error_e(const am_sinkID_t sinkID));
- MOCK_METHOD2(peekSource,
- am_Error_e(const std::string& name, am_sourceID_t& sourceID));
- MOCK_METHOD2(registerSource,
- am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID));
- MOCK_METHOD1(deregisterSource,
- am_Error_e(const am_sourceID_t sourceID));
- MOCK_METHOD2(registerCrossfader,
- am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID));
- MOCK_METHOD1(deregisterCrossfader,
- am_Error_e(const am_crossfaderID_t crossfaderID));
- MOCK_METHOD2(peekSourceClassID,
- am_Error_e(const std::string& name, am_sourceClass_t& sourceClassID));
- MOCK_METHOD2(peekSinkClassID,
- am_Error_e(const std::string& name, am_sinkClass_t& sinkClassID));
- MOCK_METHOD2(hookInterruptStatusChange,
- void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState));
- MOCK_METHOD1(hookDomainRegistrationComplete,
- void(const am_domainID_t domainID));
- MOCK_METHOD2(hookSinkAvailablityStatusChange,
- void(const am_sinkID_t sinkID, const am_Availability_s& availability));
- MOCK_METHOD2(hookSourceAvailablityStatusChange,
- void(const am_sourceID_t sourceID, const am_Availability_s& availability));
- MOCK_METHOD2(hookDomainStateChange,
- void(const am_domainID_t domainID, const am_DomainState_e domainState));
- MOCK_METHOD2(hookTimingInformationChanged,
- void(const am_connectionID_t connectionID, const am_timeSync_t delay));
- MOCK_METHOD1(sendChangedData,
- void(const std::vector<am_EarlyData_s>& earlyData));
- MOCK_CONST_METHOD1(getDBusConnectionWrapper,
- am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper));
- MOCK_CONST_METHOD1(getSocketHandler,
- am_Error_e(CAmSocketHandler*& socketHandler));
- MOCK_CONST_METHOD1(getInterfaceVersion,
- void(std::string& version));
- MOCK_METHOD1(confirmRoutingReady,
- void(const uint16_t handle));
- MOCK_METHOD1(confirmRoutingRundown,
- void(const uint16_t handle));
+ MOCK_CONST_METHOD1(getInterfaceVersion,
+ void(std::string& version));
+ MOCK_METHOD3(ackConnect,
+ void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error));
+ MOCK_METHOD3(ackDisconnect,
+ void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error));
+ MOCK_METHOD3(ackSetSinkVolumeChange,
+ void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error));
+ MOCK_METHOD3(ackSetSourceVolumeChange,
+ void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error));
+ MOCK_METHOD2(ackSetSourceState,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSetSinkSoundProperties,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSetSinkSoundProperty,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSetSourceSoundProperties,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSetSourceSoundProperty,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD3(ackCrossFading,
+ void(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error));
+ MOCK_METHOD3(ackSourceVolumeTick,
+ void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume));
+ MOCK_METHOD3(ackSinkVolumeTick,
+ void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume));
+ MOCK_METHOD2(peekDomain,
+ am_Error_e(const std::string& name, am_domainID_t& domainID));
+ MOCK_METHOD2(registerDomain,
+ am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID));
+ MOCK_METHOD1(deregisterDomain,
+ am_Error_e(const am_domainID_t domainID));
+ MOCK_METHOD2(registerGateway,
+ am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID));
+ MOCK_METHOD1(deregisterGateway,
+ am_Error_e(const am_gatewayID_t gatewayID));
+ MOCK_METHOD2(peekSink,
+ am_Error_e(const std::string& name, am_sinkID_t& sinkID));
+ MOCK_METHOD2(registerSink,
+ am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID));
+ MOCK_METHOD1(deregisterSink,
+ am_Error_e(const am_sinkID_t sinkID));
+ MOCK_METHOD2(peekSource,
+ am_Error_e(const std::string& name, am_sourceID_t& sourceID));
+ MOCK_METHOD2(registerSource,
+ am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID));
+ MOCK_METHOD1(deregisterSource,
+ am_Error_e(const am_sourceID_t sourceID));
+ MOCK_METHOD2(registerCrossfader,
+ am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID));
+ MOCK_METHOD1(deregisterCrossfader,
+ am_Error_e(const am_crossfaderID_t crossfaderID));
+ MOCK_METHOD2(peekSourceClassID,
+ am_Error_e(const std::string& name, am_sourceClass_t& sourceClassID));
+ MOCK_METHOD2(peekSinkClassID,
+ am_Error_e(const std::string& name, am_sinkClass_t& sinkClassID));
+ MOCK_METHOD2(hookInterruptStatusChange,
+ void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState));
+ MOCK_METHOD1(hookDomainRegistrationComplete,
+ void(const am_domainID_t domainID));
+ MOCK_METHOD2(hookSinkAvailablityStatusChange,
+ void(const am_sinkID_t sinkID, const am_Availability_s& availability));
+ MOCK_METHOD2(hookSourceAvailablityStatusChange,
+ void(const am_sourceID_t sourceID, const am_Availability_s& availability));
+ MOCK_METHOD2(hookDomainStateChange,
+ void(const am_domainID_t domainID, const am_DomainState_e domainState));
+ MOCK_METHOD2(hookTimingInformationChanged,
+ void(const am_connectionID_t connectionID, const am_timeSync_t delay));
+ MOCK_METHOD1(sendChangedData,
+ void(const std::vector<am_EarlyData_s>& earlyData));
+ MOCK_CONST_METHOD1(getDBusConnectionWrapper,
+ am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper));
+ MOCK_CONST_METHOD1(getSocketHandler,
+ am_Error_e(CAmSocketHandler*& socketHandler));
+ MOCK_METHOD2(confirmRoutingReady,
+ void(const uint16_t handle, const am_Error_e error));
+ MOCK_METHOD2(confirmRoutingRundown,
+ void(const uint16_t handle, const am_Error_e error));
+ MOCK_METHOD4(updateGateway,
+ am_Error_e(const am_gatewayID_t gatewayID, std::vector<am_ConnectionFormat_e> listSourceFormats, const std::vector<am_ConnectionFormat_e> listSinkFormats, 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, std::vector<am_MainSoundProperty_s> listMainSoundProperties));
+ MOCK_METHOD5(updateSource,
+ am_Error_e(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, std::vector<am_SoundProperty_s> listSoundProperties, std::vector<am_ConnectionFormat_e> 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,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSourceNotificationConfiguration,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(hookSinkNotificationDataChange,
+ void(const am_sinkID_t sinkID, const am_NotificationPayload_s payload));
+ MOCK_METHOD2(hookSourceNotificationDataChange,
+ void(const am_sourceID_t sourceID, const am_NotificationPayload_s payload));
+
};
} // namespace am