From 58d62c4af578c10375bf9baa946e33f340c42a1f Mon Sep 17 00:00:00 2001 From: christian mueller Date: Thu, 26 Jan 2012 18:10:02 +0100 Subject: * regenerated EA code based on Conti Feedback. * changed paths of audiomanagertypes include in generated files * changed order of parameters in asyncSetSinkSoundProperty / asyncSetSourceSoundProperty / cbTimingInformationChanged to have common style over all interfaces. * changed default include paths for Controller etc... * cleanup of warnings --- .../test/controlInterface/MockInterfaces.h | 9 +- .../test/controlInterface/controlInterfaceTest.cpp | 9 +- .../test/controlInterface/controlInterfaceTest.h | 4 +- AudioManagerDaemon/test/database/MockInterfaces.h | 3 +- AudioManagerDaemon/test/database/databaseTest.cpp | 4 +- AudioManagerDaemon/test/database/databaseTest.h | 4 + AudioManagerDaemon/test/routing/MockInterfaces.h | 2 +- AudioManagerDaemon/test/routing/routingTest.cpp | 196 ++++++++++----------- .../test/routingInterface/MockRoutingInterface.h | 9 +- .../test/routingInterface/routingInterfaceTest.cpp | 12 +- .../test/routingInterface/routingInterfaceTest.h | 3 + .../test/sockethandler/sockethandlerTest.cpp | 31 +++- 12 files changed, 152 insertions(+), 134 deletions(-) (limited to 'AudioManagerDaemon/test') diff --git a/AudioManagerDaemon/test/controlInterface/MockInterfaces.h b/AudioManagerDaemon/test/controlInterface/MockInterfaces.h index 9ac325f..746d70e 100644 --- a/AudioManagerDaemon/test/controlInterface/MockInterfaces.h +++ b/AudioManagerDaemon/test/controlInterface/MockInterfaces.h @@ -53,13 +53,13 @@ class MockRoutingSendInterface : public RoutingSendInterface { MOCK_METHOD3(asyncSetSourceState, am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state)); MOCK_METHOD3(asyncSetSinkSoundProperties, - am_Error_e(const am_Handle_s handle, const std::vector& listSoundProperties, const am_sinkID_t sinkID)); + am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector& listSoundProperties)); MOCK_METHOD3(asyncSetSinkSoundProperty, - am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID)); + am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty)); MOCK_METHOD3(asyncSetSourceSoundProperties, - am_Error_e(const am_Handle_s handle, const std::vector& listSoundProperties, const am_sourceID_t sourceID)); + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector& listSoundProperties)); MOCK_METHOD3(asyncSetSourceSoundProperty, - am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID)); + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty)); MOCK_METHOD5(asyncCrossFade, am_Error_e(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)); MOCK_METHOD2(setDomainState, @@ -71,6 +71,7 @@ class MockRoutingSendInterface : public RoutingSendInterface { }; + class MockControlSendInterface : public ControlSendInterface { public: MOCK_METHOD1(startupController, diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp index 5d3a4f1..c22f175 100644 --- a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp +++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp @@ -42,12 +42,13 @@ controlInterfaceTest::controlInterfaceTest() : pCommandSender(plistCommandPluginDirs), // pMockControlInterface(), // pMockRoutingInterface(), // - pControlSender(std::string("")), // pRoutingInterfaceBackdoor(), // pCommandInterfaceBackdoor(), // pControlInterfaceBackdoor(), // + pControlSender(std::string("")), // + pRouter(&pDatabaseHandler,&pControlSender), // pDatabaseObserver(&pCommandSender, &pRoutingSender), // - pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), // + pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender,&pRouter), // pRoutingReceiver(&pDatabaseHandler, &pRoutingSender, &pControlSender, pDBusWrapper) { pDatabaseHandler.registerObserver(&pDatabaseObserver); @@ -440,7 +441,7 @@ TEST_F(controlInterfaceTest,ackSetSinkSoundProperty) ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID)); //change the soundproperty, expect a call on the routinginterface - EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,_,2)).WillOnce(Return(E_OK)); + EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,2,_)).WillOnce(Return(E_OK)); ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty)); //check the list of handles. The handle must be in there and have the right type @@ -492,7 +493,7 @@ TEST_F(controlInterfaceTest,ackSetSourceSoundProperty) ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID)); //we trigger the change and wait for a call on the routinginterface - EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,_,2)).WillOnce(Return(E_OK)); + EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,2,_)).WillOnce(Return(E_OK)); ASSERT_EQ(E_OK, pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty)); //check the list of handles. The handle must be in there and have the right type diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h index 1bc3ce8..0029d73 100644 --- a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h +++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h @@ -36,6 +36,7 @@ #include "DatabaseObserver.h" #include "ControlSender.h" #include "RoutingSender.h" +#include "Router.h" #include "../RoutingInterfaceBackdoor.h" #include "../CommandInterfaceBackdoor.h" #include "../ControlInterfaceBackdoor.h" @@ -57,10 +58,11 @@ public: CommandSender pCommandSender; MockControlSendInterface pMockControlInterface; MockRoutingSendInterface pMockRoutingInterface; - ControlSender pControlSender; RoutingInterfaceBackdoor pRoutingInterfaceBackdoor; CommandInterfaceBackdoor pCommandInterfaceBackdoor; ControlInterfaceBackdoor pControlInterfaceBackdoor; + ControlSender pControlSender; + Router pRouter; DatabaseObserver pDatabaseObserver; ControlReceiver pControlReceiver; RoutingReceiver pRoutingReceiver; diff --git a/AudioManagerDaemon/test/database/MockInterfaces.h b/AudioManagerDaemon/test/database/MockInterfaces.h index 514c7cf..b48c8e8 100644 --- a/AudioManagerDaemon/test/database/MockInterfaces.h +++ b/AudioManagerDaemon/test/database/MockInterfaces.h @@ -70,10 +70,9 @@ class MockCommandSendInterface : public CommandSendInterface { MOCK_METHOD1(cbSystemPropertyChanged, void(const am_SystemProperty_s& systemProperty)); MOCK_METHOD2(cbTimingInformationChanged, - void (const am_timeSync_t time, const am_mainConnectionID_t mainConnectionID)); + void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)); MOCK_CONST_METHOD0(getInterfaceVersion, uint16_t()); - }; diff --git a/AudioManagerDaemon/test/database/databaseTest.cpp b/AudioManagerDaemon/test/database/databaseTest.cpp index 9913011..064cc05 100644 --- a/AudioManagerDaemon/test/database/databaseTest.cpp +++ b/AudioManagerDaemon/test/database/databaseTest.cpp @@ -54,7 +54,9 @@ routingTest::routingTest() : pMockInterface(), // pRoutingInterfaceBackdoor(), // pCommandInterfaceBackdoor(), // - pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), // + pControlSender(""),// + pRouter(&pDatabaseHandler,&pControlSender), // + pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), // pObserver(&pCommandSender, &pRoutingSender) { pDatabaseHandler.registerObserver(&pObserver); diff --git a/AudioManagerDaemon/test/database/databaseTest.h b/AudioManagerDaemon/test/database/databaseTest.h index 0d46b68..466567b 100644 --- a/AudioManagerDaemon/test/database/databaseTest.h +++ b/AudioManagerDaemon/test/database/databaseTest.h @@ -41,6 +41,8 @@ #include "ControlSender.h" #include "DatabaseObserver.h" #include "RoutingSender.h" +#include "Router.h" +#include "ControlSender.h" #include "../ControlInterfaceBackdoor.h" #include "../CommandInterfaceBackdoor.h" #include "../CommonFunctions.h" @@ -61,6 +63,8 @@ public: MockCommandSendInterface pMockInterface; RoutingInterfaceBackdoor pRoutingInterfaceBackdoor; CommandInterfaceBackdoor pCommandInterfaceBackdoor; + ControlSender pControlSender; + Router pRouter; ControlReceiver pControlReceiver; DatabaseObserver pObserver; CommonFunctions pCF; diff --git a/AudioManagerDaemon/test/routing/MockInterfaces.h b/AudioManagerDaemon/test/routing/MockInterfaces.h index 9ece31c..ac7b839 100644 --- a/AudioManagerDaemon/test/routing/MockInterfaces.h +++ b/AudioManagerDaemon/test/routing/MockInterfaces.h @@ -71,7 +71,7 @@ class MockCommandSendInterface : public CommandSendInterface { MOCK_METHOD1(cbSystemPropertyChanged, void(const am_SystemProperty_s& systemProperty)); MOCK_METHOD2(cbTimingInformationChanged, - void(const am_timeSync_t time, const am_mainConnectionID_t mainConnectionID)); + void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)); MOCK_CONST_METHOD0(getInterfaceVersion, uint16_t()); }; diff --git a/AudioManagerDaemon/test/routing/routingTest.cpp b/AudioManagerDaemon/test/routing/routingTest.cpp index 2950255..2ed2c9b 100644 --- a/AudioManagerDaemon/test/routing/routingTest.cpp +++ b/AudioManagerDaemon/test/routing/routingTest.cpp @@ -29,6 +29,7 @@ #include "ControlReceiver.h" #include "ControlSender.h" #include "DatabaseObserver.h" +#include "Router.h" #include "../ControlInterfaceBackdoor.h" #include "../CommandInterfaceBackdoor.h" #include "../CommonFunctions.h" @@ -39,13 +40,6 @@ using namespace testing; DLT_DECLARE_CONTEXT(DLT_CONTEXT) -//extern int GetRandomNumber(int nLow, int nHigh); -//extern bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b); -extern bool equalMainSoundProperty(const am_MainSoundProperty_s a, const am_MainSoundProperty_s b); -extern bool equalRoutingElement(const am_RoutingElement_s a, const am_RoutingElement_s b); -extern bool equalClassProperties(const am_ClassProperty_s a, const am_ClassProperty_s b); -extern std::string int2string(int i); - routingTest::routingTest() : plistRoutingPluginDirs(), // plistCommandPluginDirs(), // @@ -59,7 +53,7 @@ routingTest::routingTest() : pRoutingInterfaceBackdoor(), // pCommandInterfaceBackdoor(), // pControlInterfaceBackdoor(), // - pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), // + pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), // pObserver(&pCommandSender, &pRoutingSender) { pDatabaseHandler.registerObserver(&pObserver); @@ -88,18 +82,16 @@ ACTION(returnConnectionFormat) arg3=arg2; } - - -//test that checks just 2 domains, one sink one source with only one connection format each -TEST_F(routingTest,simpleRoute2Domains) +//test that checks 3 domains, one sink one source but the connectionformat of third domains do not fit. +TEST_F(routingTest,simpleRoute3DomainsNoConnection) { - EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2); - EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2); + EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3); + EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3); EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(),Return(E_OK))); //initialize 2 domains - am_Domain_s domain1, domain2; - am_domainID_t domainID1, domainID2; + am_Domain_s domain1, domain2, domain3; + am_domainID_t domainID1, domainID2, domainID3; domain1.domainID = 0; domain1.name = "domain1"; @@ -109,52 +101,73 @@ TEST_F(routingTest,simpleRoute2Domains) domain2.name = "domain2"; domain2.busname = "domain2bus"; domain2.state = DS_CONTROLLED; + domain3.domainID = 0; + domain3.name = "domain3"; + domain3.busname = "domain3bus"; + domain3.state = DS_CONTROLLED; ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1)); ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2)); + ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3)); - am_Source_s source, gwSource; - am_sourceID_t sourceID, gwSourceID; + am_Source_s source, gwSource, gwSource1; + am_sourceID_t sourceID, gwSourceID, gwSourceID1; source.domainID = domainID1; source.name = "source1"; source.sourceState = SS_ON; source.sourceID = 0; source.sourceClassID = 5; - source.listConnectionFormats.push_back(CF_ANALOG); + source.listConnectionFormats.push_back(CF_MONO); gwSource.domainID = domainID2; gwSource.name = "gwsource1"; gwSource.sourceState = SS_ON; gwSource.sourceID = 0; gwSource.sourceClassID = 5; - gwSource.listConnectionFormats.push_back(CF_MONO); + gwSource.listConnectionFormats.push_back(CF_ANALOG); + + gwSource1.domainID = domainID3; + gwSource1.name = "gwsource2"; + gwSource1.sourceState = SS_ON; + gwSource1.sourceID = 0; + gwSource1.sourceClassID = 5; + gwSource1.listConnectionFormats.push_back(CF_MONO); ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID)); ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID)); + ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1)); - am_Sink_s sink, gwSink; - am_sinkID_t sinkID, gwSinkID; + am_Sink_s sink, gwSink, gwSink1; + am_sinkID_t sinkID, gwSinkID, gwSinkID1; - sink.domainID = domainID2; + sink.domainID = domainID3; sink.name = "sink1"; sink.sinkID = 0; sink.sinkClassID = 5; sink.muteState = MS_MUTED; - sink.listConnectionFormats.push_back(CF_MONO); + sink.listConnectionFormats.push_back(CF_STEREO); gwSink.domainID = domainID1; gwSink.name = "gwSink"; gwSink.sinkID = 0; gwSink.sinkClassID = 5; gwSink.muteState = MS_MUTED; - gwSink.listConnectionFormats.push_back(CF_ANALOG); + gwSink.listConnectionFormats.push_back(CF_MONO); + + gwSink1.domainID = domainID2; + gwSink1.name = "gwSink1"; + gwSink1.sinkID = 0; + gwSink1.sinkClassID = 5; + gwSink1.muteState = MS_MUTED; + gwSink1.listConnectionFormats.push_back(CF_ANALOG); ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID)); ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID)); + ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1)); - am_Gateway_s gateway; - am_gatewayID_t gatewayID; + am_Gateway_s gateway, gateway1; + am_gatewayID_t gatewayID, gatewayID1; gateway.controlDomainID = domainID1; gateway.gatewayID = 0; @@ -167,25 +180,44 @@ TEST_F(routingTest,simpleRoute2Domains) gateway.convertionMatrix.push_back(true); gateway.name = "gateway"; + gateway1.controlDomainID = domainID2; + gateway1.gatewayID = 0; + gateway1.sinkID = gwSinkID1; + gateway1.sourceID = gwSourceID1; + gateway1.domainSourceID = domainID3; + gateway1.domainSinkID = domainID2; + gateway1.listSinkFormats = gwSink1.listConnectionFormats; + gateway1.listSourceFormats = gwSource1.listConnectionFormats; + gateway1.convertionMatrix.push_back(true); + gateway1.name = "gateway"; + ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID)); + ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1)); std::vector listRoutes; std::vector listRoutingElements; am_RoutingElement_s hopp1; am_RoutingElement_s hopp2; + am_RoutingElement_s hopp3; - hopp1.sinkID = gwSinkID; hopp1.sourceID = sourceID; + hopp1.sinkID = gwSinkID; hopp1.domainID = domainID1; hopp1.connectionFormat = source.listConnectionFormats[0]; - hopp2.sinkID = sinkID; hopp2.sourceID = gwSourceID; + hopp2.sinkID = gwSinkID1; hopp2.domainID = domainID2; - hopp2.connectionFormat = sink.listConnectionFormats[0]; + hopp2.connectionFormat = gwSink1.listConnectionFormats[0]; + + hopp3.sourceID = gwSourceID1; + hopp3.sinkID = sinkID; + hopp3.domainID = domainID3; + hopp3.connectionFormat = sink.listConnectionFormats[0]; listRoutingElements.push_back(hopp1); listRoutingElements.push_back(hopp2); + listRoutingElements.push_back(hopp3); am_Route_s compareRoute; compareRoute.route = listRoutingElements; @@ -193,13 +225,10 @@ TEST_F(routingTest,simpleRoute2Domains) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); - ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); - + ASSERT_EQ(0, listRoutes.size()); } - -//test that checks just 2 domains, one sink one source but the connectionformat of source -TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats) +//test that checks just 2 domains, one sink one source with only one connection format each +TEST_F(routingTest,simpleRoute2Domains) { EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2); EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2); @@ -229,7 +258,7 @@ TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats) source.sourceState = SS_ON; source.sourceID = 0; source.sourceClassID = 5; - source.listConnectionFormats.push_back(CF_STEREO); + source.listConnectionFormats.push_back(CF_ANALOG); gwSource.domainID = domainID2; gwSource.name = "gwsource1"; @@ -301,19 +330,21 @@ TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(0, listRoutes.size()); + ASSERT_EQ(1, listRoutes.size()); + ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); + } -//test that checks 3 domains, one sink one source. -TEST_F(routingTest,simpleRoute3Domains) +//test that checks just 2 domains, one sink one source but the connectionformat of source +TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats) { - EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3); - EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3); + EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2); + EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2); EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(),Return(E_OK))); //initialize 2 domains - am_Domain_s domain1, domain2, domain3; - am_domainID_t domainID1, domainID2, domainID3; + am_Domain_s domain1, domain2; + am_domainID_t domainID1, domainID2; domain1.domainID = 0; domain1.name = "domain1"; @@ -323,47 +354,34 @@ TEST_F(routingTest,simpleRoute3Domains) domain2.name = "domain2"; domain2.busname = "domain2bus"; domain2.state = DS_CONTROLLED; - domain3.domainID = 0; - domain3.name = "domain3"; - domain3.busname = "domain3bus"; - domain3.state = DS_CONTROLLED; ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1)); ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2)); - ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3)); - am_Source_s source, gwSource, gwSource1; - am_sourceID_t sourceID, gwSourceID, gwSourceID1; + am_Source_s source, gwSource; + am_sourceID_t sourceID, gwSourceID; source.domainID = domainID1; source.name = "source1"; source.sourceState = SS_ON; source.sourceID = 0; source.sourceClassID = 5; - source.listConnectionFormats.push_back(CF_MONO); + source.listConnectionFormats.push_back(CF_STEREO); gwSource.domainID = domainID2; gwSource.name = "gwsource1"; gwSource.sourceState = SS_ON; gwSource.sourceID = 0; gwSource.sourceClassID = 5; - gwSource.listConnectionFormats.push_back(CF_ANALOG); - - gwSource1.domainID = domainID3; - gwSource1.name = "gwsource2"; - gwSource1.sourceState = SS_ON; - gwSource1.sourceID = 0; - gwSource1.sourceClassID = 5; - gwSource1.listConnectionFormats.push_back(CF_MONO); + gwSource.listConnectionFormats.push_back(CF_MONO); ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID)); ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID)); - ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1)); - am_Sink_s sink, gwSink, gwSink1; - am_sinkID_t sinkID, gwSinkID, gwSinkID1; + am_Sink_s sink, gwSink; + am_sinkID_t sinkID, gwSinkID; - sink.domainID = domainID3; + sink.domainID = domainID2; sink.name = "sink1"; sink.sinkID = 0; sink.sinkClassID = 5; @@ -375,21 +393,13 @@ TEST_F(routingTest,simpleRoute3Domains) gwSink.sinkID = 0; gwSink.sinkClassID = 5; gwSink.muteState = MS_MUTED; - gwSink.listConnectionFormats.push_back(CF_MONO); - - gwSink1.domainID = domainID2; - gwSink1.name = "gwSink1"; - gwSink1.sinkID = 0; - gwSink1.sinkClassID = 5; - gwSink1.muteState = MS_MUTED; - gwSink1.listConnectionFormats.push_back(CF_ANALOG); + gwSink.listConnectionFormats.push_back(CF_ANALOG); ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID)); ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID)); - ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1)); - am_Gateway_s gateway, gateway1; - am_gatewayID_t gatewayID, gatewayID1; + am_Gateway_s gateway; + am_gatewayID_t gatewayID; gateway.controlDomainID = domainID1; gateway.gatewayID = 0; @@ -402,44 +412,25 @@ TEST_F(routingTest,simpleRoute3Domains) gateway.convertionMatrix.push_back(true); gateway.name = "gateway"; - gateway1.controlDomainID = domainID2; - gateway1.gatewayID = 0; - gateway1.sinkID = gwSinkID1; - gateway1.sourceID = gwSourceID1; - gateway1.domainSourceID = domainID3; - gateway1.domainSinkID = domainID2; - gateway1.listSinkFormats = gwSink1.listConnectionFormats; - gateway1.listSourceFormats = gwSource1.listConnectionFormats; - gateway1.convertionMatrix.push_back(true); - gateway1.name = "gateway"; - ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID)); - ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1)); std::vector listRoutes; std::vector listRoutingElements; am_RoutingElement_s hopp1; am_RoutingElement_s hopp2; - am_RoutingElement_s hopp3; - hopp1.sourceID = sourceID; hopp1.sinkID = gwSinkID; + hopp1.sourceID = sourceID; hopp1.domainID = domainID1; hopp1.connectionFormat = source.listConnectionFormats[0]; + hopp2.sinkID = sinkID; hopp2.sourceID = gwSourceID; - hopp2.sinkID = gwSinkID1; hopp2.domainID = domainID2; - hopp2.connectionFormat = gwSink1.listConnectionFormats[0]; - - hopp3.sourceID = gwSourceID1; - hopp3.sinkID = sinkID; - hopp3.domainID = domainID3; - hopp3.connectionFormat = sink.listConnectionFormats[0]; + hopp2.connectionFormat = sink.listConnectionFormats[0]; listRoutingElements.push_back(hopp1); listRoutingElements.push_back(hopp2); - listRoutingElements.push_back(hopp3); am_Route_s compareRoute; compareRoute.route = listRoutingElements; @@ -447,12 +438,11 @@ TEST_F(routingTest,simpleRoute3Domains) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); - ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); + ASSERT_EQ(0, listRoutes.size()); } -//test that checks 3 domains, one sink one source but the connectionformat of third domains do not fit. -TEST_F(routingTest,simpleRoute3DomainsNoConnection) +//test that checks 3 domains, one sink one source. +TEST_F(routingTest,simpleRoute3Domains) { EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3); EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3); @@ -515,7 +505,7 @@ TEST_F(routingTest,simpleRoute3DomainsNoConnection) sink.sinkID = 0; sink.sinkClassID = 5; sink.muteState = MS_MUTED; - sink.listConnectionFormats.push_back(CF_STEREO); + sink.listConnectionFormats.push_back(CF_MONO); gwSink.domainID = domainID1; gwSink.name = "gwSink"; @@ -594,7 +584,7 @@ TEST_F(routingTest,simpleRoute3DomainsNoConnection) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(0, listRoutes.size()); + ASSERT_EQ(1, listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } diff --git a/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h b/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h index 850d90c..6c93507 100644 --- a/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h +++ b/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h @@ -53,13 +53,13 @@ class MockRoutingSendInterface : public RoutingSendInterface { MOCK_METHOD3(asyncSetSourceState, am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state)); MOCK_METHOD3(asyncSetSinkSoundProperties, - am_Error_e(const am_Handle_s handle, const std::vector& listSoundProperties, const am_sinkID_t sinkID)); + am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector& listSoundProperties)); MOCK_METHOD3(asyncSetSinkSoundProperty, - am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID)); + am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty)); MOCK_METHOD3(asyncSetSourceSoundProperties, - am_Error_e(const am_Handle_s handle, const std::vector& listSoundProperties, const am_sourceID_t sourceID)); + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector& listSoundProperties)); MOCK_METHOD3(asyncSetSourceSoundProperty, - am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID)); + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty)); MOCK_METHOD5(asyncCrossFade, am_Error_e(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)); MOCK_METHOD2(setDomainState, @@ -69,7 +69,6 @@ class MockRoutingSendInterface : public RoutingSendInterface { MOCK_CONST_METHOD0(getInterfaceVersion, uint16_t()); }; - } // namespace am diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp index 6ebd99d..5adb863 100644 --- a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp +++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp @@ -28,7 +28,7 @@ using namespace am; using namespace testing; -DLT_DECLARE_CONTEXT(DLT_CONTEXT); +DLT_DECLARE_CONTEXT(DLT_CONTEXT) routingInterfaceTest::routingInterfaceTest() : plistRoutingPluginDirs(), // @@ -36,10 +36,12 @@ routingInterfaceTest::routingInterfaceTest() : pDatabaseHandler(std::string(":memory:")), // pRoutingSender(plistRoutingPluginDirs), // pCommandSender(plistCommandPluginDirs), // + pControlSender(""), // + pRouter(&pDatabaseHandler, &pControlSender), // pMockInterface(), // pRoutingInterfaceBackdoor(), // pCommandInterfaceBackdoor(), // - pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), // + pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), // pObserver(&pCommandSender, &pRoutingSender) { pDatabaseHandler.registerObserver(&pObserver); @@ -160,7 +162,7 @@ TEST_F(routingInterfaceTest,setSinkSoundPropertyNoChange) sink.listSoundProperties.push_back(soundProperty); ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID)); ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID)); - EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).Times(0); + EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,sinkID,_)).Times(0); ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty)); } @@ -203,7 +205,7 @@ TEST_F(routingInterfaceTest,setSourceSoundProperty) source.domainID = 1; ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID)); ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID)); - EXPECT_CALL(pMockInterface,asyncSetSourceSoundProperty(_,_,sourceID)).WillOnce(Return(E_OK)); + EXPECT_CALL(pMockInterface,asyncSetSourceSoundProperty(_,sourceID,_)).WillOnce(Return(E_OK)); ASSERT_EQ(E_OK, pControlReceiver.setSourceSoundProperty(handle,sourceID,soundProperty)); ASSERT_NE(handle.handle, 0); ASSERT_EQ(handle.handleType, H_SETSOURCESOUNDPROPERTY); @@ -229,7 +231,7 @@ TEST_F(routingInterfaceTest,setSinkSoundProperty) sink.domainID = 1; ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID)); ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID)); - EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).WillOnce(Return(E_OK)); + EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,sinkID,_)).WillOnce(Return(E_OK)); ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty)); ASSERT_NE(handle.handle, 0); ASSERT_EQ(handle.handleType, H_SETSINKSOUNDPROPERTY); diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h index 4da9643..8ad77eb 100644 --- a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h +++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h @@ -38,6 +38,7 @@ #include "ControlReceiver.h" #include "ControlSender.h" #include "DatabaseObserver.h" +#include "Router.h" #include "../RoutingInterfaceBackdoor.h" #include "../CommandInterfaceBackdoor.h" #include "../CommonFunctions.h" @@ -55,6 +56,8 @@ public: DatabaseHandler pDatabaseHandler; RoutingSender pRoutingSender; CommandSender pCommandSender; + ControlSender pControlSender; + Router pRouter; MockRoutingSendInterface pMockInterface; RoutingInterfaceBackdoor pRoutingInterfaceBackdoor; CommandInterfaceBackdoor pCommandInterfaceBackdoor; diff --git a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp index 5c23789..0ac36fa 100644 --- a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp +++ b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp @@ -23,8 +23,6 @@ using namespace am; DLT_DECLARE_CONTEXT(AudioManager) -static volatile sig_atomic_t gDispatch = 1; //this global is used to stop the mainloop - sockethandlerTest::sockethandlerTest() { } @@ -49,6 +47,8 @@ am::timerCallBack::~timerCallBack() void am::timerCallBack::timer1Callback(sh_timerHandle_t handle, void* userData) { + (void) handle; + (void) userData; std::cout << "callback1 called" << std::endl; timespec timeout; timeout.tv_nsec = 0; @@ -60,6 +60,8 @@ void am::timerCallBack::timer1Callback(sh_timerHandle_t handle, void* userData) void am::timerCallBack::timer2Callback(sh_timerHandle_t handle, void* userData) { + (void) handle; + (void) userData; std::cout << "callback2 called" << std::endl; timespec timeout; timeout.tv_nsec = 0; @@ -71,35 +73,40 @@ void am::timerCallBack::timer2Callback(sh_timerHandle_t handle, void* userData) void am::timerCallBack::timer3Callback(sh_timerHandle_t, void* userData) { + (void) userData; std::cout << "callback3 called" << std::endl; } void am::timerCallBack::timer4Callback(sh_timerHandle_t, void* userData) { + (void) userData; std::cout << "callback4 called" << std::endl; mSocketHandler->stop_listening(); } void* playWithSocketServer(void* data) { + (void) data; SocketHandler myHandler; SamplePlugin::sockType_e type = SamplePlugin::INET; SamplePlugin myplugin(&myHandler, type); myHandler.start_listenting(); + return (NULL); } void* playWithUnixSocketServer(void* data) { + (void) data; SocketHandler myHandler; SamplePlugin::sockType_e type = SamplePlugin::UNIX; SamplePlugin myplugin(&myHandler, type); myHandler.start_listenting(); + return (NULL); } TEST(sockethandlerTest,playWithUNIXSockets) { pthread_t serverThread; - char buffer[3000]; struct sockaddr_un servAddr; int socket_; @@ -135,7 +142,6 @@ TEST(sockethandlerTest,playWithUNIXSockets) TEST(sockethandlerTest,playWithSockets) { pthread_t serverThread; - char buffer[3000]; struct sockaddr_in servAddr; unsigned short servPort = 6060; struct hostent *host; @@ -154,7 +160,7 @@ TEST(sockethandlerTest,playWithSockets) if ((host = (struct hostent*) gethostbyname("localhost")) == 0) { std::cout << "ERROR: gethostbyname() failed\n" << std::endl; - + exit(1); } memset(&servAddr, 0, sizeof(servAddr)); @@ -229,7 +235,6 @@ am::SamplePlugin::SamplePlugin(SocketHandler *mySocketHandler, sockType_e socket mReceiveHandle(), // msgList() { - int ret; int yes = 1; int socketHandle; @@ -276,6 +281,8 @@ am::SamplePlugin::SamplePlugin(SocketHandler *mySocketHandler, sockType_e socket void am::SamplePlugin::connectSocket(const pollfd pollfd1, const sh_pollHandle_t handle, void *userData) { + (void) handle; + (void) userData; //first, accept the connection, create a new filedescriptor std::cout << "Got a connection request !" << std::endl; struct sockaddr answer; @@ -293,6 +300,8 @@ void am::SamplePlugin::connectSocket(const pollfd pollfd1, const sh_pollHandle_t void am::SamplePlugin::receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void *userData) { + (void) handle; + (void) userData; //initialize buffer char buffer[10]; //read until buffer is full or no more data is there @@ -308,6 +317,8 @@ void am::SamplePlugin::receiveData(const pollfd pollfd, const sh_pollHandle_t ha bool am::SamplePlugin::dispatchData(const sh_pollHandle_t handle, void *userData) { + (void) handle; + (void) userData; //read data from the queue std::cout << "Data:" << msgList.front() << std::endl; @@ -318,15 +329,19 @@ bool am::SamplePlugin::dispatchData(const sh_pollHandle_t handle, void *userData } //remove the message from the queue and return false if there is no more message to read. msgList.pop(); - if (msgList.size() != 0) return true; + if (msgList.size() != 0) + return true; return false; } bool am::SamplePlugin::check(const sh_pollHandle_t handle, void *userData) { + (void) handle; + (void) userData; //checks if there is data to dispatch std::cout << "check!:" << std::endl; - if (msgList.size() != 0) return true; + if (msgList.size() != 0) + return true; return false; } -- cgit v1.2.1