summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/test
diff options
context:
space:
mode:
authorchristian linke <christian.linke@bmw.de>2012-12-06 13:31:52 +0100
committerchristian linke <christian.linke@bmw.de>2012-12-06 13:38:51 +0100
commit215e8a72dc81e8a86dd5b3a8ca40fd2c7c6a0b9c (patch)
treee9ef5639752a65ee2e678bafdb36bd56b09bfd91 /AudioManagerDaemon/test
parent104255615d643a2278d8430a876413793563ab36 (diff)
downloadaudiomanager-215e8a72dc81e8a86dd5b3a8ca40fd2c7c6a0b9c.tar.gz
fix [OSS BUG 23] - connection removed if routing returns !=E_OK. added test case to test this as well
Signed-off-by: christian linke <christian.linke@bmw.de>
Diffstat (limited to 'AudioManagerDaemon/test')
-rw-r--r--AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp63
-rw-r--r--AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp1
2 files changed, 64 insertions, 0 deletions
diff --git a/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp b/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
index f056819..c4f71e1 100644
--- a/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
@@ -28,6 +28,8 @@
using namespace am;
using namespace testing;
+DLT_DECLARE_CONTEXT(AudioManager)
+
CAmControlInterfaceTest::CAmControlInterfaceTest() :
pSocketHandler(), //
pDBusWrapper((CAmDbusWrapper*) 1), //
@@ -47,6 +49,9 @@ CAmControlInterfaceTest::CAmControlInterfaceTest() :
pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), //
pRoutingReceiver(&pDatabaseHandler, &pRoutingSender, &pControlSender, &pSocketHandler, pDBusWrapper)
{
+ CAmDltWrapper::instance(0)->registerApp("AudioManagerDeamon", "AudioManagerDeamon");
+ CAmDltWrapper::instance()->registerContext(AudioManager, "Main", "Main Context");
+ logInfo("The Audiomanager is started");
pDatabaseHandler.registerObserver(&pDatabaseObserver);
pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender, &pMockRoutingInterface, "mock");
@@ -259,6 +264,64 @@ TEST_F(CAmControlInterfaceTest,ackDisconnect)
ASSERT_EQ(E_NON_EXISTENT, pControlReceiver.disconnect(handle,2));
}
+TEST_F(CAmControlInterfaceTest,ackDisconnectFailAndRetry)
+{
+ logInfo("ackDisconnectFailAndRetry test started");
+ am_connectionID_t connectionID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Connection_s> connectionList;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //now we first need to connect, we expect a call on the routing interface
+ EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_GENIVI_STEREO)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_GENIVI_STEREO,2,2));
+
+ //answer with an ack to insert the connection in the database
+ EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
+ pRoutingReceiver.ackConnect(handle, connectionID, E_OK);
+
+ //now we can start to disconnect and expect a call on the routing interface
+ EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.disconnect(handle,1));
+
+ //during the disconnection, the connection is still in the list!
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(!connectionList.empty());
+
+ //then we fire the ack and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckDisconnect(_,E_NON_EXISTENT)).Times(1);
+ pRoutingReceiver.ackDisconnect(handle, connectionID, E_NON_EXISTENT);
+
+ //make sure the handle is gone
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //make sure the connection is still there
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_FALSE(connectionList.empty());
+
+ ASSERT_TRUE(pDatabaseHandler.existConnectionID(1));
+
+ //Now let's try to disconnect now
+ EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.disconnect(handle,1));
+ logInfo("ackDisconnectFailAndRetry test finished");
+}
+
TEST_F(CAmControlInterfaceTest,setSourceState)
{
diff --git a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
index fe3694b..47181b3 100644
--- a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
@@ -399,6 +399,7 @@ TEST_F(CAmRoutingInterfaceTest,disconnect)
ASSERT_TRUE(listHandles[1].handleType==handle.handleType);
}
+
TEST_F(CAmRoutingInterfaceTest,nothingTodisconnect)
{
am_Handle_s handle;