* Some unit tests fixed due issues occured on pocky build systems.
authorAleksandar Donchev <Aleksander.Donchev@partner.bmw.de>
Fri, 28 Mar 2014 15:34:25 +0000 (16:34 +0100)
committerChristian Linke <christian.linke@bmw.de>
Fri, 28 Mar 2014 15:48:03 +0000 (16:48 +0100)
Signed-off-by: Christian Linke <christian.linke@bmw.de>
AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp
AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp
AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.cpp
PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp
PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp

index 2dba164..ae05960 100644 (file)
@@ -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<am_SoundProperty_s> listSoundProperties;
     std::vector<am_ConnectionFormat_e> listConnectionFormats;
     std::vector<am_MainSoundProperty_s> 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<am_SoundProperty_s> listSoundProperties;
     std::vector<am_ConnectionFormat_e> listConnectionFormats;
     std::vector<am_MainSoundProperty_s> listMainSoundProperties;
index 0833dde..e41e556 100644 (file)
@@ -164,6 +164,7 @@ TEST_F(CAmNodeStateCommunicatorTest, receiveLifecycleRequest)
     std::ostringstream send;
     send << "python send2nsm.py LifecycleRequest "<<Request<<" "<<RequestID;
     system(send.str().c_str());
+    sleep(2);
 }
 
 TEST_F(CAmNodeStateCommunicatorTest, UnRegisterShutdownClient)
index 4c55c34..2ea9639 100644 (file)
@@ -1248,8 +1248,15 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains2Routes)
 
     ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
     ASSERT_EQ(static_cast<uint>(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.
index 7cbc0c8..66bd0dc 100644 (file)
@@ -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<am_Error_e>::Set(am_Error_e(E_OK));
 }
 
 void CAmCommandSenderCAPITest::TearDown()
index c02d5d3..8111494 100644 (file)
@@ -46,12 +46,13 @@ CAmEnvironment::~CAmEnvironment()
 
 void CAmEnvironment::SetUp()
 {
+       ::testing::GTEST_FLAG(throw_on_failure) = false;
     logInfo("RoutingSendInterface Test started ");
 
     std::vector<int> 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() :