From 7666421ecaa46c0244e6272db80e0192aed47a28 Mon Sep 17 00:00:00 2001 From: Aleksandar Donchev Date: Fri, 28 Mar 2014 16:34:25 +0100 Subject: * Some unit tests fixed due issues occured on pocky build systems. Signed-off-by: Christian Linke --- .../test/AmMapHandlerTest/CAmMapHandlerTest.cpp | 20 ++++++++++++++++---- .../CAmNodeStateCommunicatorTest.cpp | 1 + .../test/AmRouterMapTest/CAmRouterMapTest.cpp | 11 +++++++++-- .../test/CAmCommandSenderCAPITest.cpp | 6 ++++++ .../test/CAmRoutingReceiverAsync.cpp | 5 +++-- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp b/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp index 2dba164..ae05960 100644 --- a/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp +++ b/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp @@ -2268,7 +2268,10 @@ TEST_F(CAmMapHandlerTest, peekDomain_2) ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domain2ID)); ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains)); ASSERT_EQ(domainID, domain2ID); // FAILS, ID is 2 instead of 1 - ASSERT_TRUE(listDomains[0].domainID==domainID); + bool containsDomainID = std::find_if(listDomains.begin(), listDomains.end(), [&](const am_Domain_s & ref) { + return ref.domainID==domainID; + })!=listDomains.end(); + ASSERT_TRUE(containsDomainID); } TEST_F(CAmMapHandlerTest, connectionIDBoundary) @@ -2475,7 +2478,10 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_removeDomain) ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domain2ID)); ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains)); ASSERT_EQ(domainID, domain2ID); // FAILS, ID is 2 instead of 1 - ASSERT_TRUE(listDomains[0].domainID==domainID); + bool containsDomainID = std::find_if(listDomains.begin(), listDomains.end(), [&](const am_Domain_s & ref) { + return ref.domainID==domainID; + })!=listDomains.end(); + ASSERT_TRUE(containsDomainID); EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removeDomain(domainID)).Times(1); ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))<< "ERROR: database error"; EXPECT_TRUE(Mock::VerifyAndClearExpectations(MockDatabaseObserver::getMockObserverObject())); @@ -2513,7 +2519,10 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_update_removeSource) ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,source3ID)); ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources)); ASSERT_EQ(sourceID, source3ID); - ASSERT_TRUE(listSources[0].sourceID==sourceID); + bool containsSourceID = std::find_if(listSources.begin(), listSources.end(), [&](const am_Source_s & ref) { + return ref.sourceID==sourceID; + })!=listSources.end(); + ASSERT_TRUE(containsSourceID); std::vector listSoundProperties; std::vector listConnectionFormats; std::vector listMainSoundProperties; @@ -2556,7 +2565,10 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_update_removeSink) ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sink3ID)); ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks)); ASSERT_EQ(sinkID, sink3ID); - ASSERT_TRUE(listSinks[0].sinkID==sinkID); + bool containsSourceID = std::find_if(listSinks.begin(), listSinks.end(), [&](const am_Sink_s & ref) { + return ref.sinkID==sinkID; + })!=listSinks.end(); + ASSERT_TRUE(containsSourceID); std::vector listSoundProperties; std::vector listConnectionFormats; std::vector listMainSoundProperties; diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp index 0833dde..e41e556 100644 --- a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp +++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp @@ -164,6 +164,7 @@ TEST_F(CAmNodeStateCommunicatorTest, receiveLifecycleRequest) std::ostringstream send; send << "python send2nsm.py LifecycleRequest "<(2), listRoutes.size()); - ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); - ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[1])); + + bool containsRoute1 = std::find_if(listRoutes.begin(), listRoutes.end(), [&](const am_Route_s & ref) { + return pCF.compareRoute(compareRoute, ref); + })!=listRoutes.end(); + bool containsRoute2 = std::find_if(listRoutes.begin(), listRoutes.end(), [&](const am_Route_s & ref) { + return pCF.compareRoute(compareRoute1, ref); + })!=listRoutes.end(); + ASSERT_TRUE(containsRoute1); + ASSERT_TRUE(containsRoute2); } //test that checks 3 domains, one sink one source but the connectionformat of third domains do not fit. diff --git a/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp b/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp index 7cbc0c8..66bd0dc 100644 --- a/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp +++ b/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp @@ -85,6 +85,10 @@ void* run_service(void*) } else { + ON_CALL(*env->mpCommandReceive, getListMainSources(_)).WillByDefault(Return(E_OK)); + ON_CALL(*env->mpCommandReceive, getListMainSinks(_)).WillByDefault(Return(E_OK)); + ON_CALL(*env->mpCommandReceive, getListMainSourceSoundProperties(_,_)).WillByDefault(Return(E_OK)); + EXPECT_CALL(*env->mpCommandReceive,confirmCommandReady(10,_)); plugin.setCommandReady(10); socketHandler.start_listenting(); @@ -203,6 +207,8 @@ CAmCommandSenderCAPITest::~CAmCommandSenderCAPITest() void CAmCommandSenderCAPITest::SetUp() { ::testing::GTEST_FLAG(throw_on_failure) = false; + ::testing::FLAGS_gmock_verbose = "error"; +// ::testing::DefaultValue::Set(am_Error_e(E_OK)); } void CAmCommandSenderCAPITest::TearDown() diff --git a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp index c02d5d3..8111494 100644 --- a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp +++ b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp @@ -46,12 +46,13 @@ CAmEnvironment::~CAmEnvironment() void CAmEnvironment::SetUp() { + ::testing::GTEST_FLAG(throw_on_failure) = false; logInfo("RoutingSendInterface Test started "); std::vector domainIDs; domainIDs.push_back(0); domainIDs.push_back(1); - + EXPECT_TRUE(Mock::VerifyAndClearExpectations(&env->pReceiveInterface)); 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)); @@ -94,7 +95,7 @@ void CAmEnvironment::SetUp() void CAmEnvironment::TearDown() { - + ::testing::GTEST_FLAG(throw_on_failure) = true; } CAmRoutingReceiverAsync::CAmRoutingReceiverAsync() : -- cgit v1.2.1