diff options
author | Christian Linke <christian.linke@bmw.de> | 2017-02-15 01:47:24 -0800 |
---|---|---|
committer | Christian Linke <christian.linke@bmw.de> | 2017-02-20 08:49:44 -0800 |
commit | 9ad6f67f6c39ec4ff49c382d5beaf9006f664fcb (patch) | |
tree | 7f1a8705f35bff4350ba813962318e562b623b82 /AudioManagerCore/test | |
parent | b616ca1e864f7530b9dfce4c38f9d24a9f0809c9 (diff) | |
download | audiomanager-9ad6f67f6c39ec4ff49c382d5beaf9006f664fcb.tar.gz |
handle overflow of handles correctly
Signed-off-by: Christian Linke <christian.linke@bmw.de>
Diffstat (limited to 'AudioManagerCore/test')
-rw-r--r-- | AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp b/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp index 2cd2b55..3a576e6 100644 --- a/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp +++ b/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp @@ -546,6 +546,103 @@ TEST_F(CAmRoutingInterfaceTest,nothingTodisconnect) ASSERT_TRUE(listHandles.empty()); } +TEST_F(CAmRoutingInterfaceTest,handleOverflow) +{ + am_Handle_s handle,handleOverflow1,handleOverflow2,handleOverflowCheck1,handleOverflowCheck2; + am_sinkID_t sinkID; + am_Sink_s sink; + am_Domain_s domain; + am_domainID_t domainID; + + pCF.createSink(sink); + pCF.createDomain(domain); + domain.name = "mock"; + domain.busname = "mock"; + sink.sinkID = 2; + sink.domainID = DYNAMIC_ID_BOUNDARY; + am_SoundProperty_s soundProperty; + soundProperty.type = SP_GENIVI_TREBLE; + soundProperty.value = 23; + + 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,_)).WillRepeatedly(Return(E_OK)); + + //open handles till 50 + for(int i=0;i<50;i++) + { + handle.handle=0; + soundProperty.value = i; + ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty)); + } + //now we ack 2 handles + EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK)); + ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflow1,sinkID,soundProperty)); + pRoutingReceiver.ackSetSinkSoundProperty(handleOverflow1,E_OK); + + EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK)); + ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflow2,sinkID,soundProperty)); + pRoutingReceiver.ackSetSinkSoundProperty(handleOverflow2,E_OK); + + for(int i=52;i<1023;i++) //now we get into the overflow areay + { + handle.handle=0; + soundProperty.value = i; + ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty)); + } + + //the next two handles must be the one we already acked + ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflowCheck1,sinkID,soundProperty)); + ASSERT_EQ(handleOverflow1.handle,handleOverflowCheck1.handle); + + ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflowCheck2,sinkID,soundProperty)); + ASSERT_EQ(handleOverflow2.handle,handleOverflowCheck2.handle); + +} + +TEST_F(CAmRoutingInterfaceTest,handleOverflowAbsolute) +{ + am_Handle_s handle,handleOverflow1,handleOverflow2,handleOverflowCheck1,handleOverflowCheck2; + am_sinkID_t sinkID; + am_Sink_s sink; + am_Domain_s domain; + am_domainID_t domainID; + + pCF.createSink(sink); + pCF.createDomain(domain); + domain.name = "mock"; + domain.busname = "mock"; + sink.sinkID = 2; + sink.domainID = DYNAMIC_ID_BOUNDARY; + am_SoundProperty_s soundProperty; + soundProperty.type = SP_GENIVI_TREBLE; + soundProperty.value = 23; + + 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,_)).WillRepeatedly(Return(E_OK)); + + + for(int i=0;i<1023;i++) //we fill up the handles + { + handle.handle=0; + soundProperty.value = i; + ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty)); + } + + //the next handle must return 0! + ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflowCheck1,sinkID,soundProperty)); + ASSERT_EQ(handleOverflowCheck1.handle,0); +} + int main(int argc, char **argv) |