summaryrefslogtreecommitdiff
path: root/PluginRoutingInterfaceAsync/test
diff options
context:
space:
mode:
authorchristian mueller <christian.ei.mueller@bmw.de>2012-02-29 13:27:27 +0100
committerchristian mueller <christian.ei.mueller@bmw.de>2012-02-29 13:27:27 +0100
commitd3ccf97331935b181041394b80be20dca282ea71 (patch)
treef85e7b649c8a6d58c11e9728b2442cdcff53826d /PluginRoutingInterfaceAsync/test
parentaa93713377d28a8ce7821466ef828f79a18e982d (diff)
downloadaudiomanager-d3ccf97331935b181041394b80be20dca282ea71.tar.gz
* [ performance] for classes that do not need to be derived from, removed virtual desctructor
* implemented confirmation of routing ready in RoutingReceiver * [Sockethandler] automatically set gDispatchDone to 0 when starting mainloop * fixed unit text to work with latest changes (expect Dbus command interface) * [GAM-4] added way to do synchronous calling on interfaces with the help of CAmSerializer.h * reworked AsyncRoutingPlugin to work with CAmSerializer.h * reworked AsyncRoutingPlugin to register elemtes in thread using CAmSerializer.h * reworked AsncPlugin Tests to work with remodelled Plugin
Diffstat (limited to 'PluginRoutingInterfaceAsync/test')
-rw-r--r--PluginRoutingInterfaceAsync/test/CMakeLists.txt4
-rw-r--r--PluginRoutingInterfaceAsync/test/mocklnterfaces.h155
-rw-r--r--PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.cpp213
-rw-r--r--PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.h28
-rw-r--r--PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsyncInterrupt.cpp4
5 files changed, 247 insertions, 157 deletions
diff --git a/PluginRoutingInterfaceAsync/test/CMakeLists.txt b/PluginRoutingInterfaceAsync/test/CMakeLists.txt
index e80d80b..aa4c39d 100644
--- a/PluginRoutingInterfaceAsync/test/CMakeLists.txt
+++ b/PluginRoutingInterfaceAsync/test/CMakeLists.txt
@@ -34,6 +34,8 @@ find_package (Threads)
FIND_PACKAGE(PkgConfig)
FIND_PACKAGE(DBUS REQUIRED)
pkg_check_modules(DLT REQUIRED automotive-dlt)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+
INCLUDE_DIRECTORIES(
${STD_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
@@ -51,7 +53,6 @@ INCLUDE_DIRECTORIES(
file(GLOB ASYNC_PLUGIN_INTERFACE_SRCS_CXX
"../../AudioManagerDaemon/src/SocketHandler.cpp"
- "../../AudioManagerDaemon/src/RoutingSender.cpp"
"../../AudioManagerDaemon/src/DLTWrapper.cpp"
"../src/*.cpp"
"testRoutingInterfaceAsync.cpp"
@@ -76,6 +77,7 @@ TARGET_LINK_LIBRARIES(asyncRoutingInterfaceTest
${CMAKE_THREAD_LIBS_INIT}
${GTEST_LIBRARIES}
${DBUS_LIBRARY}
+ ${SQLITE_LIBRARIES}
gmock
)
diff --git a/PluginRoutingInterfaceAsync/test/mocklnterfaces.h b/PluginRoutingInterfaceAsync/test/mocklnterfaces.h
index 328d416..d8eef1f 100644
--- a/PluginRoutingInterfaceAsync/test/mocklnterfaces.h
+++ b/PluginRoutingInterfaceAsync/test/mocklnterfaces.h
@@ -31,81 +31,86 @@ namespace am {
class MockRoutingReceiveInterface : public RoutingReceiveInterface {
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(DBusWrapper*& dbusConnectionWrapper));
- MOCK_CONST_METHOD1(getSocketHandler,
- am_Error_e(SocketHandler*& socketHandler));
- MOCK_CONST_METHOD0(getInterfaceVersion,
- uint16_t());
-};
+ 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(DBusWrapper*& dbusConnectionWrapper));
+ MOCK_CONST_METHOD1(getSocketHandler,
+ am_Error_e(SocketHandler*& 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));
+
+ };
} // namespace am
diff --git a/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.cpp b/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.cpp
index 3149e7e..1e672a6 100644
--- a/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.cpp
+++ b/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.cpp
@@ -25,26 +25,28 @@
#include "testRoutingInterfaceAsync.h"
#include "config.h"
#include "DLTWrapper.h"
+#include "RoutingReceiver.h"
+#include "PluginTemplate.h"
using namespace am;
using namespace testing;
-std::vector<std::string> testRoutingInterfaceAsync::pListRoutingPluginDirs = returnListPlugins();
-am_domainID_t testRoutingInterfaceAsync::mDomainIDCount = 0;
-RoutingSender testRoutingInterfaceAsync::pRoutingSender = RoutingSender(pListRoutingPluginDirs);
+am_domainID_t MyEnvironment::mDomainIDCount = 0;
+static RoutingSendInterface* pRouter;
+static SocketHandler pSocketHandler;
+static MockRoutingReceiveInterface pReceiveInterface;
-testRoutingInterfaceAsync::testRoutingInterfaceAsync() :
- pSocketHandler(), //
- pReceiveInterface(), //
- ptimerCallback(this, &testRoutingInterfaceAsync::timerCallback)
+MyEnvironment::MyEnvironment() :
+ ptimerCallback(this, &MyEnvironment::timerCallback)
{
+ DefaultValue<am_Error_e>::Set(E_OK); // Sets the default value to be returned.
}
-testRoutingInterfaceAsync::~testRoutingInterfaceAsync()
+MyEnvironment::~MyEnvironment()
{
}
-void testRoutingInterfaceAsync::SetUp()
+void MyEnvironment::SetUp()
{
logInfo("RoutingSendInterface Test started ");
@@ -53,59 +55,116 @@ void testRoutingInterfaceAsync::SetUp()
domainIDs.push_back(1);
EXPECT_CALL(pReceiveInterface,getSocketHandler(_)).WillOnce(DoAll(SetArgReferee<0>(&pSocketHandler), Return(E_OK)));
- EXPECT_CALL(pReceiveInterface,registerDomain(_,_)).WillRepeatedly(Invoke(testRoutingInterfaceAsync::handleDomainRegister));
- EXPECT_CALL(pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(testRoutingInterfaceAsync::handleSourceRegister));
- EXPECT_CALL(pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(testRoutingInterfaceAsync::handleSinkRegister));
+ EXPECT_CALL(pReceiveInterface,registerDomain(_,_)).WillRepeatedly(Invoke(MyEnvironment::handleDomainRegister));
+ EXPECT_CALL(pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(MyEnvironment::handleSourceRegister));
+ EXPECT_CALL(pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(MyEnvironment::handleSinkRegister));
+ EXPECT_CALL(pReceiveInterface,confirmRoutingReady(_)).Times(1);
+
+ RoutingSendInterface* (*createFunc)();
+ void* tempLibHandle = NULL;
+ std::string libname("../plugins/routing/libPluginRoutingInterfaceAsync.so");
+ createFunc = getCreateFunction<RoutingSendInterface*()>(libname, tempLibHandle);
- pRoutingSender.startupRoutingInterface(&pReceiveInterface);
- pRoutingSender.routingInterfacesReady();
+ if (!createFunc)
+ {
+ logError("RoutingSendInterface Test Entry point of RoutingPlugin not found");
+ exit(1);
+ }
+
+ pRouter = createFunc();
+
+ if (!pRouter)
+ {
+ logError("RoutingSendInterface Test RoutingPlugin initialization failed. Entry Function not callable");
+ exit(1);
+ }
+
+ pRouter->startupInterface(&pReceiveInterface);
+ pRouter->setRoutingReady(10);
timespec t;
t.tv_nsec = 0;
- t.tv_sec = 4;
+ t.tv_sec = 2;
sh_timerHandle_t handle;
shTimerCallBack *buf = &ptimerCallback;
//lets use a timeout so the test will finish
pSocketHandler.addTimer(t, buf, handle, (void*) NULL);
+ pSocketHandler.start_listenting();
+
+}
+
+void MyEnvironment::TearDown()
+{
+
+}
+
+testRoutingInterfaceAsync::testRoutingInterfaceAsync() :
+ ptimerCallback(this, &testRoutingInterfaceAsync::timerCallback)
+{
+}
+
+testRoutingInterfaceAsync::~testRoutingInterfaceAsync()
+{
+}
+
+void testRoutingInterfaceAsync::timerCallback(sh_timerHandle_t handle, void *userData)
+{
+ (void) handle;
+ (void) userData;
+ pSocketHandler.stop_listening();
+}
+
+void testRoutingInterfaceAsync::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
+// pSocketHandler.addTimer(t, buf, handle, (void*) NULL);
}
-std::vector<std::string> am::testRoutingInterfaceAsync::returnListPlugins()
+std::vector<std::string> MyEnvironment::returnListPlugins()
{
std::vector<std::string> list;
list.push_back(std::string(DEFAULT_PLUGIN_ROUTING_DIR));
return (list);
}
-am_Error_e am::testRoutingInterfaceAsync::handleSourceRegister(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+am_Error_e MyEnvironment::handleSourceRegister(const am_Source_s & sourceData, am_sourceID_t & sourceID)
{
sourceID = sourceData.sourceID;
- pRoutingSender.addSourceLookup(sourceData);
return (E_OK);
}
-am_Error_e am::testRoutingInterfaceAsync::handleSinkRegister(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+am_Error_e MyEnvironment::handleSinkRegister(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
{
sinkID = sinkData.sinkID;
- pRoutingSender.addSinkLookup(sinkData);
return (E_OK);
}
-am_Error_e am::testRoutingInterfaceAsync::handleDomainRegister(const am_Domain_s & domainData, am_domainID_t & domainID)
+am_Error_e MyEnvironment::handleDomainRegister(const am_Domain_s & domainData, am_domainID_t & domainID)
{
am_Domain_s domain = domainData;
- domainID = mDomainIDCount++;
+ domainID = ++mDomainIDCount;
domain.domainID = domainID;
- pRoutingSender.addDomainLookup(domain);
return (E_OK);
}
-void am::testRoutingInterfaceAsync::timerCallback(sh_timerHandle_t handle, void *userData)
+void MyEnvironment::timerCallback(sh_timerHandle_t handle, void *userData)
{
(void) handle;
(void) userData;
pSocketHandler.stop_listening();
+ timespec t;
+ t.tv_nsec = 0;
+ t.tv_sec = 2;
+ pSocketHandler.restartTimer(handle, t);
}
void testRoutingInterfaceAsync::TearDown()
@@ -119,7 +178,7 @@ TEST_F(testRoutingInterfaceAsync,setDomainState)
EXPECT_CALL(pReceiveInterface,hookDomainStateChange(_,DS_INDEPENDENT_RUNDOWN)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.setDomainState(domainID,state));
+ ASSERT_EQ(E_OK, pRouter->setDomainState(domainID,state));
pSocketHandler.start_listenting();
}
@@ -137,7 +196,7 @@ TEST_F(testRoutingInterfaceAsync,setSourceSoundProperty)
EXPECT_CALL(pReceiveInterface,ackSetSourceSoundProperty(_,E_OK)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.asyncSetSourceSoundProperty(handle,sourceID,property));
+ ASSERT_EQ(E_OK, pRouter->asyncSetSourceSoundProperty(handle,sourceID,property));
pSocketHandler.start_listenting();
}
@@ -155,7 +214,7 @@ TEST_F(testRoutingInterfaceAsync,setSinkSoundProperty)
EXPECT_CALL(pReceiveInterface,ackSetSinkSoundProperty(_,E_OK)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.asyncSetSinkSoundProperty(handle,sinkID,property));
+ ASSERT_EQ(E_OK, pRouter->asyncSetSinkSoundProperty(handle,sinkID,property));
pSocketHandler.start_listenting();
}
@@ -164,14 +223,14 @@ TEST_F(testRoutingInterfaceAsync,setSourceState)
am_Handle_s handle;
handle.handle = 1;
- handle.handleType = H_SETSOURCEVOLUME;
+ handle.handleType = H_SETSOURCESTATE;
am_sourceID_t sourceID = 1;
am_SourceState_e state = SS_OFF;
EXPECT_CALL(pReceiveInterface,ackSetSourceState(_,E_OK)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.asyncSetSourceState(handle,sourceID,state));
+ ASSERT_EQ(E_OK, pRouter->asyncSetSourceState(handle,sourceID,state));
pSocketHandler.start_listenting();
}
@@ -187,10 +246,10 @@ TEST_F(testRoutingInterfaceAsync,setSourceVolume)
am_RampType_e ramp = RAMP_GENIVI_DIRECT;
am_time_t myTime = 25;
- EXPECT_CALL(pReceiveInterface,ackSourceVolumeTick(_,sourceID,_)).Times(3);
+ EXPECT_CALL(pReceiveInterface,ackSourceVolumeTick(_,sourceID,_)).Times(AtLeast(1));
EXPECT_CALL(pReceiveInterface,ackSetSourceVolumeChange(_,volume,E_OK)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.asyncSetSourceVolume(handle,sourceID,volume,ramp,myTime));
+ ASSERT_EQ(E_OK, pRouter->asyncSetSourceVolume(handle,sourceID,volume,ramp,myTime));
pSocketHandler.start_listenting();
}
@@ -206,10 +265,10 @@ TEST_F(testRoutingInterfaceAsync,setSinkVolume)
am_RampType_e ramp = RAMP_GENIVI_DIRECT;
am_time_t myTime = 25;
- EXPECT_CALL(pReceiveInterface,ackSinkVolumeTick(_,sinkID,_)).Times(9);
+ EXPECT_CALL(pReceiveInterface,ackSinkVolumeTick(_,sinkID,_)).Times(AtLeast(2));
EXPECT_CALL(pReceiveInterface,ackSetSinkVolumeChange(_,volume,E_OK)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime));
+ ASSERT_EQ(E_OK, pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime));
pSocketHandler.start_listenting();
}
@@ -228,37 +287,37 @@ TEST_F(testRoutingInterfaceAsync,setSinkVolumeAbort)
EXPECT_CALL(pReceiveInterface, ackSinkVolumeTick(_,sinkID,_));
EXPECT_CALL(pReceiveInterface,ackSetSinkVolumeChange(_,AllOf(Ne(volume),Ne(0)),E_ABORTED)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime));
+ ASSERT_EQ(E_OK, pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime));
sleep(0.5);
- ASSERT_EQ(E_OK, pRoutingSender.asyncAbort(handle));
+ ASSERT_EQ(E_OK, pRouter->asyncAbort(handle));
pSocketHandler.start_listenting();
}
-TEST_F(testRoutingInterfaceAsync,disconnectTooEarly)
+TEST_F(testRoutingInterfaceAsync,disconnectNonExisting)
{
am_Handle_s handle;
handle.handle = 1;
- handle.handleType = H_CONNECT;
+ handle.handleType = H_DISCONNECT;
am_connectionID_t connectionID = 4;
- am_sourceID_t sourceID = 2;
- am_sinkID_t sinkID = 1;
- am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
+ EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
EXPECT_CALL(pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0);
- ASSERT_EQ(E_OK, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
- ASSERT_EQ(E_NON_EXISTENT, pRoutingSender.asyncDisconnect(handle,connectionID));
+ ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncDisconnect(handle,connectionID));
pSocketHandler.start_listenting();
}
-TEST_F(testRoutingInterfaceAsync,disconnectAbort)
+TEST_F(testRoutingInterfaceAsync,disconnectTooEarly)
{
+ am_Handle_s handle_c;
+ handle_c.handle = 1;
+ handle_c.handleType = H_CONNECT;
+
am_Handle_s handle;
handle.handle = 1;
- handle.handleType = H_CONNECT;
+ handle.handleType = H_DISCONNECT;
am_connectionID_t connectionID = 4;
am_sourceID_t sourceID = 2;
@@ -266,35 +325,47 @@ TEST_F(testRoutingInterfaceAsync,disconnectAbort)
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
- EXPECT_CALL(pReceiveInterface, ackDisconnect(_,connectionID,E_ABORTED));
- ASSERT_EQ(E_OK, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
- sleep(2);
- ASSERT_EQ(E_OK, pRoutingSender.asyncDisconnect(handle,connectionID));
- ASSERT_EQ(E_OK, pRoutingSender.asyncAbort(handle));
+ EXPECT_CALL(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();
}
-TEST_F(testRoutingInterfaceAsync,disconnectNonExisting)
+TEST_F(testRoutingInterfaceAsync,disconnectAbort)
{
+ am_Handle_s handle_c;
+ handle_c.handle = 1;
+ handle_c.handleType = H_CONNECT;
+
am_Handle_s handle;
handle.handle = 1;
- handle.handleType = H_CONNECT;
+ handle.handleType = H_DISCONNECT;
- am_connectionID_t connectionID = 4;
+ am_connectionID_t connectionID = 5;
+ am_sourceID_t sourceID = 2;
+ am_sinkID_t sinkID = 1;
+ am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
- EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
- EXPECT_CALL(pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0);
- ASSERT_EQ(E_NON_EXISTENT, pRoutingSender.asyncDisconnect(handle,connectionID));
+ EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
+ EXPECT_CALL(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();
}
TEST_F(testRoutingInterfaceAsync,disconnect)
{
+ am_Handle_s handle_c;
+ handle_c.handle = 1;
+ handle_c.handleType = H_CONNECT;
+
am_Handle_s handle;
handle.handle = 1;
- handle.handleType = H_CONNECT;
+ handle.handleType = H_DISCONNECT;
am_connectionID_t connectionID = 4;
am_sourceID_t sourceID = 2;
@@ -303,9 +374,9 @@ TEST_F(testRoutingInterfaceAsync,disconnect)
EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
EXPECT_CALL(pReceiveInterface, ackDisconnect(_,connectionID,E_OK));
- ASSERT_EQ(E_OK, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
+ ASSERT_EQ(E_OK, pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format));
sleep(2);
- ASSERT_EQ(E_OK, pRoutingSender.asyncDisconnect(handle,connectionID));
+ ASSERT_EQ(E_OK, pRouter->asyncDisconnect(handle,connectionID));
pSocketHandler.start_listenting();
}
@@ -322,12 +393,12 @@ TEST_F(testRoutingInterfaceAsync,connectNoMoreThreads)
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
EXPECT_CALL(pReceiveInterface,ackConnect(_,_,E_OK)).Times(10);
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < 9; i++)
{
handle.handle++;
connectionID++;
- ASSERT_EQ(E_OK, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
- }ASSERT_EQ(E_NOT_POSSIBLE, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
+ 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();
}
@@ -344,9 +415,9 @@ TEST_F(testRoutingInterfaceAsync,connectAbortTooLate)
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
+ ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
sleep(3);
- ASSERT_EQ(E_NON_EXISTENT, pRoutingSender.asyncAbort(handle));
+ ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncAbort(handle));
pSocketHandler.start_listenting();
}
@@ -363,9 +434,9 @@ TEST_F(testRoutingInterfaceAsync,connectAbort)
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_ABORTED)).Times(1);
- ASSERT_EQ(E_OK, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
+ ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
sleep(0.5);
- ASSERT_EQ(E_OK, pRoutingSender.asyncAbort(handle));
+ ASSERT_EQ(E_OK, pRouter->asyncAbort(handle));
pSocketHandler.start_listenting();
}
@@ -382,7 +453,7 @@ TEST_F(testRoutingInterfaceAsync,connectWrongFormat)
am_ConnectionFormat_e format = CF_GENIVI_MONO;
EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
- ASSERT_EQ(E_WRONG_FORMAT, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
+ ASSERT_EQ(E_WRONG_FORMAT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
pSocketHandler.start_listenting();
}
@@ -399,7 +470,7 @@ TEST_F(testRoutingInterfaceAsync,connectWrongSink)
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
- ASSERT_EQ(E_NON_EXISTENT, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
+ ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
pSocketHandler.start_listenting();
}
@@ -415,7 +486,7 @@ TEST_F(testRoutingInterfaceAsync,connectWrongSource)
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
- ASSERT_EQ(E_NON_EXISTENT, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
+ ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
pSocketHandler.start_listenting();
}
@@ -432,13 +503,15 @@ TEST_F(testRoutingInterfaceAsync,connect)
am_ConnectionFormat_e format = CF_GENIVI_ANALOG;
EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK));
- ASSERT_EQ(E_OK, pRoutingSender.asyncConnect(handle,connectionID,sourceID,sinkID,format));
+ ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
pSocketHandler.start_listenting();
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
+ ::testing::Environment* const env = ::testing::AddGlobalTestEnvironment(new MyEnvironment);
+ (void) env;
return RUN_ALL_TESTS();
}
diff --git a/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.h b/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.h
index 364100c..3139b5a 100644
--- a/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.h
+++ b/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsync.h
@@ -30,33 +30,43 @@
#include "mocklnterfaces.h"
#include "SocketHandler.h"
#include "../../AudioManagerDaemon/include/RoutingSender.h"
+#include "CAmSerializer.h"
#define UNIT_TEST 1
namespace am
{
-class testRoutingInterfaceAsync: public ::testing::Test
+class MyEnvironment: public ::testing::Environment
{
public:
- static std::vector<std::string> pListRoutingPluginDirs;
- SocketHandler pSocketHandler;
- MockRoutingReceiveInterface pReceiveInterface;
- static RoutingSender pRoutingSender;
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);
static am_Error_e handleSinkRegister(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
void timerCallback(sh_timerHandle_t handle, void* userData);
- shTimerCallBack_T<testRoutingInterfaceAsync> ptimerCallback;
- testRoutingInterfaceAsync();
- virtual ~testRoutingInterfaceAsync();
-
+ shTimerCallBack_T<MyEnvironment> ptimerCallback;
+ MyEnvironment();
+ ~MyEnvironment();
+ // Override this to define how to set up the environment.
void SetUp();
+ // Override this to define how to tear down the environment.
void TearDown();
private:
static am_domainID_t mDomainIDCount;
};
+class testRoutingInterfaceAsync: public ::testing::Test
+{
+public:
+ testRoutingInterfaceAsync();
+ ~testRoutingInterfaceAsync();
+ void timerCallback(sh_timerHandle_t handle, void* userData);
+ shTimerCallBack_T<testRoutingInterfaceAsync> ptimerCallback;
+ void SetUp();
+ void TearDown();
+private:
+};
+
} /* namespace am */
#endif /* TESTROUTINGINTERFACEASYNC_H_ */
diff --git a/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsyncInterrupt.cpp b/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsyncInterrupt.cpp
index f8ece51..e00de40 100644
--- a/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsyncInterrupt.cpp
+++ b/PluginRoutingInterfaceAsync/test/testRoutingInterfaceAsyncInterrupt.cpp
@@ -59,8 +59,8 @@ void testRoutingInterfaceAsync::SetUp()
EXPECT_CALL(pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(testRoutingInterfaceAsync::handleSourceRegister));
EXPECT_CALL(pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(testRoutingInterfaceAsync::handleSinkRegister));
- pRoutingSender.startupRoutingInterface(&pReceiveInterface);
- pRoutingSender.routingInterfacesReady();
+ //pRoutingSender.startupRoutingInterface(&pReceiveInterface);
+ //pRoutingSender.routingInterfacesReady();
timespec t;
t.tv_nsec = 0;