summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.cpp')
-rw-r--r--AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.cpp1122
1 files changed, 1039 insertions, 83 deletions
diff --git a/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.cpp b/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.cpp
index 2ea9639..a6680e5 100644
--- a/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.cpp
+++ b/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.cpp
@@ -12,7 +12,7 @@
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*
- * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013, 2014
*
* For further information see http://www.genivi.org/.
*
@@ -22,6 +22,7 @@
#include <string.h>
#include "shared/CAmDltWrapper.h"
+
using namespace am;
using namespace testing;
@@ -65,6 +66,85 @@ ACTION(returnConnectionFormat){
arg4=arg3;
}
+void CAmRouterMapTest::enterDomainDB(const std::string & domainName, am_domainID_t & domainID)
+{
+ am_Domain_s domain1;
+ domain1.domainID = 0;
+ domain1.name = domainName;
+ domain1.busname = "domain1bus";
+ domain1.state = DS_CONTROLLED;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID));
+}
+
+void CAmRouterMapTest::enterSourceDB(const std::string & sourceName, const am_domainID_t domainID, const std::vector<am_CustomConnectionFormat_t> & connectionFormats, am_sourceID_t & sourceID)
+{
+ am_Source_s source;
+ source.domainID = domainID;
+ source.name = sourceName;
+ source.sourceState = SS_ON;
+ source.sourceID = 0;
+ source.sourceClassID = 5;
+ source.listConnectionFormats = connectionFormats;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+}
+
+void CAmRouterMapTest::enterSinkDB(const std::string & sinkName, const am_domainID_t domainID, const std::vector<am_CustomConnectionFormat_t> & connectionFormats, am_sinkID_t & sinkID)
+{
+ am_Sink_s sink;
+ sink.domainID = domainID;
+ sink.name = sinkName;
+ sink.sinkID = 0;
+ sink.sinkClassID = 5;
+ sink.muteState = MS_MUTED;
+ sink.listConnectionFormats = connectionFormats;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+}
+
+void CAmRouterMapTest::enterGatewayDB(const std::string & gwName,
+ const am_domainID_t domainSourceID,
+ const am_domainID_t domainSinkID,
+ const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats,
+ const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats,
+ const std::vector<bool> & matrix,
+ const am_sourceID_t & sourceID,
+ const am_sinkID_t & sinkID,
+ am_gatewayID_t & gatewayID)
+{
+ am_Gateway_s gateway;
+ gateway.controlDomainID = domainSourceID;
+ gateway.gatewayID = 0;
+ gateway.sinkID = sinkID;
+ gateway.sourceID = sourceID;
+ gateway.domainSourceID = domainSourceID;
+ gateway.domainSinkID = domainSinkID;
+ gateway.listSinkFormats = sinkConnectionFormats;
+ gateway.listSourceFormats = sourceConnectionFormats;
+ gateway.convertionMatrix = matrix;
+ gateway.name = gwName;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
+}
+
+void CAmRouterMapTest::enterConverterDB(const std::string & gwName,
+ const am_domainID_t domainID,
+ const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats,
+ const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats,
+ const std::vector<bool> & matrix,
+ const am_sourceID_t & sourceID,
+ const am_sinkID_t & sinkID,
+ am_converterID_t & converterID)
+{
+ am_Converter_s converter;
+ converter.converterID = 0;
+ converter.sinkID = sinkID;
+ converter.sourceID = sourceID;
+ converter.domainID = domainID;
+ converter.listSinkFormats = sinkConnectionFormats;
+ converter.listSourceFormats = sourceConnectionFormats;
+ converter.convertionMatrix = matrix;
+ converter.name = gwName;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterConverterDB(converter,converterID));
+}
+
//test that checks just sinks and source in a domain but connectionformats do not match
TEST_F(CAmRouterMapTest,simpleRoute2withDomainNoMatchFormats)
{
@@ -121,9 +201,13 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomainNoMatchFormats)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
-
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(true, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
//test that checks just sinks and source in a domain
@@ -182,17 +266,19 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomain)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
-
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(true, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
//test that checks just 2 domains, one sink one source with only one connection format each
TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFree)
{
-
-
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
//initialize 2 domains
@@ -290,17 +376,20 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFree)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+
ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
-
}
+
//test that checks just 2 domains, one sink one source with only one connection format each
TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFreeNotFree)
{
-
-
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
//initialize 2 domains
@@ -412,18 +501,23 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFreeNotFree)
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,id1));
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection1,id2));
- ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
-
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(true, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
//test that checks just 2 domains, with gateway for each direction (possible circular route)
TEST_F(CAmRouterMapTest,simpleRoute2DomainsCircularGWOnlyFree)
{
-
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
//initialize 2 domains
@@ -549,15 +643,19 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsCircularGWOnlyFree)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(true, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
//test that checks 3 domains, one sink one source, longer lists of connectionformats.
TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_2)
{
-
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
//initialize 2 domains
@@ -709,9 +807,13 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_2)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
//test that checks 3 domains, one sink one source, longer lists of connectionformats.
@@ -863,9 +965,13 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_1)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
@@ -1012,9 +1118,13 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
@@ -1246,23 +1356,27 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains2Routes)
compareRoute1.sinkID = sinkID;
compareRoute1.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
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);
+ 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.
TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
{
-
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
//initialize 2 domains
@@ -1400,14 +1514,17 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
//test that checks just 2 domains, one sink one source with only one connection format each
TEST_F(CAmRouterMapTest,simpleRoute2Domains)
{
-
-
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
//initialize 2 domains
@@ -1505,17 +1622,18 @@ TEST_F(CAmRouterMapTest,simpleRoute2Domains)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
-
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
//test that checks just 2 domains, one sink one source but the connectionformat of source
TEST_F(CAmRouterMapTest,simpleRoute2DomainsNoMatchConnectionFormats)
{
-
-
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
//initialize 2 domains
@@ -1591,31 +1709,14 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsNoMatchConnectionFormats)
ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
std::vector<am_Route_s> listRoutes;
- std::vector<am_RoutingElement_s> listRoutingElements;
- am_RoutingElement_s hopp1;
- am_RoutingElement_s hopp2;
-
- hopp1.sinkID = gwSinkID;
- hopp1.sourceID = sourceID;
- hopp1.domainID = domainID1;
- hopp1.connectionFormat = source.listConnectionFormats[0];
-
- hopp2.sinkID = sinkID;
- hopp2.sourceID = gwSourceID;
- hopp2.domainID = domainID2;
- hopp2.connectionFormat = sink.listConnectionFormats[0];
-
- listRoutingElements.push_back(hopp1);
- listRoutingElements.push_back(hopp2);
- am_Route_s compareRoute;
- compareRoute.route = listRoutingElements;
- compareRoute.sinkID = sinkID;
- compareRoute.sourceID = sourceID;
-
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
-}
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+ }
//test that checks 3 domains, one sink one source.
TEST_F(CAmRouterMapTest,simpleRoute3Domains)
@@ -1757,9 +1858,14 @@ TEST_F(CAmRouterMapTest,simpleRoute3Domains)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
//test that checks 4 domains, one sink and one source.
@@ -1942,10 +2048,860 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- size_t size(1);
- ASSERT_EQ(size, listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Source_s sourceDb;
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, sourceDb, sinkDb, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+}
+
+TEST_F(CAmRouterMapTest,getAllowedFormatsFromConvMatrix)
+{
+ std::vector<bool> convertionMatrix;
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(0);
+ convertionMatrix.push_back(0);
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(0);
+
+ std::vector<am_CustomConnectionFormat_t> listSourceFormats;
+ listSourceFormats.push_back(CF_GENIVI_ANALOG);
+ listSourceFormats.push_back(CF_GENIVI_STEREO);
+
+ std::vector<am_CustomConnectionFormat_t> listSinkFormats;
+ listSinkFormats.push_back(CF_GENIVI_MONO);
+ listSinkFormats.push_back(CF_GENIVI_AUTO);
+ listSinkFormats.push_back(CF_GENIVI_STEREO);
+
+ std::vector<am_CustomConnectionFormat_t> sourceFormats;
+ std::vector<am_CustomConnectionFormat_t> sinkFormats;
+
+ ASSERT_TRUE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
+
+ ASSERT_TRUE(sourceFormats.size()==3);
+ ASSERT_TRUE(sinkFormats.size()==3);
+ ASSERT_TRUE(sourceFormats.at(0)==CF_GENIVI_ANALOG);
+ ASSERT_TRUE(sourceFormats.at(1)==CF_GENIVI_STEREO);
+ ASSERT_TRUE(sourceFormats.at(2)==CF_GENIVI_ANALOG);
+ ASSERT_TRUE(sinkFormats.at(0)==CF_GENIVI_MONO);
+ ASSERT_TRUE(sinkFormats.at(1)==CF_GENIVI_AUTO);
+ ASSERT_TRUE(sinkFormats.at(2)==CF_GENIVI_STEREO);
+
+ sinkFormats.clear();
+ sourceFormats.clear();
+ convertionMatrix.clear();
+ listSinkFormats.clear();
+ listSourceFormats.clear();
+
+ convertionMatrix.push_back(1);
+ listSinkFormats.push_back(CF_GENIVI_STEREO);
+ listSourceFormats.push_back(CF_GENIVI_STEREO);
+
+ ASSERT_TRUE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
+
+ sinkFormats.clear();
+ sourceFormats.clear();
+ convertionMatrix.clear();
+ listSinkFormats.clear();
+ listSourceFormats.clear();
+
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(0);
+ listSourceFormats.push_back(CF_GENIVI_STEREO);
+ listSinkFormats.push_back(CF_GENIVI_STEREO);
+
+ ASSERT_FALSE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
+
+ sinkFormats.clear();
+ sourceFormats.clear();
+ convertionMatrix.clear();
+ listSinkFormats.clear();
+ listSourceFormats.clear();
+
+ convertionMatrix.push_back(1);
+ listSinkFormats.push_back(CF_GENIVI_STEREO);
+
+ ASSERT_FALSE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
+}
+
+TEST_F(CAmRouterMapTest,route1Domain1Source1Sink)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ am_domainID_t domainID1;
+ enterDomainDB("domain1", domainID1);
+
+ am_sourceID_t sourceID;
+ std::vector<am_CustomConnectionFormat_t> cf1;
+ cf1.push_back(CF_GENIVI_STEREO);
+ cf1.push_back(CF_GENIVI_ANALOG);
+ enterSourceDB("source1", domainID1, cf1, sourceID);
+
+ am_sinkID_t sinkID;
+ std::vector<am_CustomConnectionFormat_t> cf2;
+ cf2.push_back(CF_GENIVI_ANALOG);
+ cf2.push_back(CF_GENIVI_MONO);
+ enterSinkDB("sink1", domainID1, cf2, sinkID);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+
+ pDatabaseHandler.getSinkInfoDB(sinkID, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+ std::vector<am_Route_s> listRoutes;
+ std::vector<am_RoutingElement_s> listRoutingElements;
+ am_RoutingElement_s hopp1;
+
+ hopp1.sourceID = sourceID;
+ hopp1.sinkID = sinkID;
+ hopp1.domainID = domainID1;
+ hopp1.connectionFormat = cf2[0];
+
+ listRoutingElements.push_back(hopp1);
+
+ am_Route_s compareRoute;
+ compareRoute.route = listRoutingElements;
+ compareRoute.sinkID = sinkID;
+ compareRoute.sourceID = sourceID;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+}
+
+TEST_F(CAmRouterMapTest,route1Domain1Source1Converter1Sink)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ am_domainID_t domainID1;
+ enterDomainDB("domain1", domainID1);
+
+ am_sourceID_t sourceID;
+ std::vector<am_CustomConnectionFormat_t> cf1;
+ cf1.push_back(CF_GENIVI_STEREO);
+ cf1.push_back(CF_GENIVI_AUTO);
+ enterSourceDB("source1", domainID1, cf1, sourceID);
+
+ am_sinkID_t sinkID1, sinkID2;
+ std::vector<am_CustomConnectionFormat_t> cf2;
+ cf2.push_back(CF_GENIVI_MONO);
+ cf2.push_back(CF_GENIVI_ANALOG);
+ enterSinkDB("sink1", domainID1, cf2, sinkID1);
+ enterSinkDB("sink2", domainID1, cf2, sinkID2);
+
+ am_sourceID_t gwSourceID;
+ std::vector<am_CustomConnectionFormat_t> cf3;
+ cf3.push_back(CF_GENIVI_MONO);
+ cf3.push_back(CF_GENIVI_ANALOG);
+ enterSourceDB("gwSource1", domainID1, cf3, gwSourceID);
+
+ am_sinkID_t gwSinkID;
+ std::vector<am_CustomConnectionFormat_t> cf4;
+ cf4.push_back(CF_GENIVI_STEREO);
+ cf4.push_back(CF_GENIVI_ANALOG);
+ enterSinkDB("gwSink1", domainID1, cf4, gwSinkID);
+
+ am_converterID_t converterID;
+ std::vector<bool> matrix;
+ matrix.resize(4, false);
+ matrix[0]=(true);
+ matrix[1]=(true);
+ enterConverterDB("converter", domainID1, cf3, cf4, matrix, gwSourceID, gwSinkID, converterID);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+
+ pDatabaseHandler.getSinkInfoDB(sinkID1, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+ std::vector<am_Route_s> listRoutes;
+ std::vector<am_RoutingElement_s> listRoutingElements;
+ am_RoutingElement_s hopp1;
+ am_RoutingElement_s hopp2;
+
+ hopp1.sourceID = sourceID;
+ hopp1.sinkID = gwSinkID;
+ hopp1.domainID = domainID1;
+ hopp1.connectionFormat = CF_GENIVI_STEREO;
+
+ hopp2.sourceID = gwSourceID;
+ hopp2.sinkID = sinkID1;
+ hopp2.domainID = domainID1;
+ hopp2.connectionFormat = CF_GENIVI_MONO;
+
+ listRoutingElements.push_back(hopp1);
+ listRoutingElements.push_back(hopp2);
+
+ am_Route_s compareRoute;
+ compareRoute.route = listRoutingElements;
+ compareRoute.sinkID = sinkID1;
+ compareRoute.sourceID = sourceID;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+}
+
+TEST_F(CAmRouterMapTest,route1Domain1Source3Converters1Sink)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ am_domainID_t domainID1;
+ enterDomainDB("domain1", domainID1);
+
+ std::vector<am_CustomConnectionFormat_t> cf1;
+ cf1.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cf2;
+ cf2.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cf3;
+ cf3.push_back(CF_GENIVI_AUTO);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cf1, sourceID);
+
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID1, cf3, sinkID);
+
+ am_sourceID_t gwSourceID;
+ enterSourceDB("gwSource1", domainID1, cf2, gwSourceID);
+ am_sinkID_t gwSinkID;
+ enterSinkDB("gwSink1", domainID1, cf1, gwSinkID);
+ am_converterID_t converterID;
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ enterConverterDB("converter1", domainID1, cf2, cf1, matrix, gwSourceID, gwSinkID, converterID);
+
+ am_sourceID_t gwSourceID1;
+ enterSourceDB("gwSource2", domainID1, cf2, gwSourceID1);
+ am_sinkID_t gwSinkID1;
+ enterSinkDB("gwSink2", domainID1, cf1, gwSinkID1);
+ am_converterID_t converterID1;
+ enterConverterDB("converter2", domainID1, cf2, cf1, matrix, gwSourceID1, gwSinkID1, converterID1);
+
+ am_sourceID_t gwSourceID2;
+ enterSourceDB("gwSource3", domainID1, cf3, gwSourceID2);
+ am_sinkID_t gwSinkID2;
+ enterSinkDB("gwSink3", domainID1, cf2, gwSinkID2);
+ am_converterID_t converterID2;
+ enterConverterDB("converter3", domainID1, cf3, cf2, matrix, gwSourceID2, gwSinkID2, converterID2);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+
+ std::vector<am_Route_s> listRoutes;
+ std::vector<am_RoutingElement_s> listRoutingElements1;
+ std::vector<am_RoutingElement_s> listRoutingElements2;
+ am_RoutingElement_s hopp11;
+ am_RoutingElement_s hopp12;
+ am_RoutingElement_s hopp13;
+ am_RoutingElement_s hopp21;
+ am_RoutingElement_s hopp22;
+
+ hopp11.sourceID = sourceID;
+ hopp11.sinkID = gwSinkID;
+ hopp11.domainID = domainID1;
+ hopp11.connectionFormat = CF_GENIVI_STEREO;
+
+ hopp12.sourceID = gwSourceID;
+ hopp12.sinkID = gwSinkID2;
+ hopp12.domainID = domainID1;
+ hopp12.connectionFormat = CF_GENIVI_MONO;
+
+ hopp21.sourceID = sourceID;
+ hopp21.sinkID = gwSinkID1;
+ hopp21.domainID = domainID1;
+ hopp21.connectionFormat = CF_GENIVI_STEREO;
+
+ hopp22.sourceID = gwSourceID1;
+ hopp22.sinkID = gwSinkID2;
+ hopp22.domainID = domainID1;
+ hopp22.connectionFormat = CF_GENIVI_MONO;
+
+ hopp13.sourceID = gwSourceID2;
+ hopp13.sinkID = sinkID;
+ hopp13.domainID = domainID1;
+ hopp13.connectionFormat = CF_GENIVI_AUTO;
+
+ listRoutingElements1.push_back(hopp11);
+ listRoutingElements1.push_back(hopp12);
+ listRoutingElements1.push_back(hopp13);
+
+ listRoutingElements2.push_back(hopp21);
+ listRoutingElements2.push_back(hopp22);
+ listRoutingElements2.push_back(hopp13);
+
+ am_Route_s compareRoute1;
+ compareRoute1.route = listRoutingElements1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+ ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+
+ am_Route_s compareRoute2;
+ compareRoute2.route = listRoutingElements2;
+ compareRoute2.sinkID = sinkID;
+ compareRoute2.sourceID = sourceID;
+ ASSERT_TRUE(pCF.compareRoute(compareRoute2,listRoutes[1]));
+}
+
+TEST_F(CAmRouterMapTest,route2Domains1Source1Sink)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ am_sourceID_t sourceID;
+ std::vector<am_CustomConnectionFormat_t> cf1;
+ cf1.push_back(CF_GENIVI_STEREO);
+ enterSourceDB("source1", domainID1, cf1, sourceID);
+
+ am_sinkID_t sinkID;
+ std::vector<am_CustomConnectionFormat_t> cf2;
+ cf2.push_back(CF_GENIVI_ANALOG);
+ enterSinkDB("sink1", domainID2, cf2, sinkID);
+
+ am_sourceID_t gwSourceID;
+ std::vector<am_CustomConnectionFormat_t> cf3;
+ cf3.push_back(CF_GENIVI_ANALOG);
+ enterSourceDB("gwSource1", domainID2, cf3, gwSourceID);
+
+ am_sinkID_t gwSinkID;
+ std::vector<am_CustomConnectionFormat_t> cf4;
+ cf4.push_back(CF_GENIVI_STEREO);
+ enterSinkDB("gwSink1", domainID1, cf4, gwSinkID);
+
+ am_gatewayID_t gatewayID;
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ enterGatewayDB("gateway", domainID2, domainID1, cf3, cf4, matrix, gwSourceID, gwSinkID, gatewayID);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+
+ pDatabaseHandler.getSinkInfoDB(sinkID, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+ std::vector<am_Route_s> listRoutes;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back({sourceID, gwSinkID, domainID1, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({gwSourceID, sinkID, domainID2, CF_GENIVI_ANALOG});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+}
+
+TEST_F(CAmRouterMapTest,route3Domains1Source1Sink)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ am_domainID_t domainID1, domainID2, domainID3;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+ enterDomainDB("domain3", domainID3);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
+
+ am_sinkID_t gwSinkID1;
+ enterSinkDB("gwSink1", domainID1, cfStereo, gwSinkID1);
+
+ am_sourceID_t gwSourceID1;
+ enterSourceDB("gwSource1", domainID2, cfMono, gwSourceID1);
+
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+
+ am_gatewayID_t gatewayID;
+ enterGatewayDB("gateway", domainID2, domainID1, cfMono, cfStereo, matrix, gwSourceID1, gwSinkID1, gatewayID);
+
+ am_sourceID_t gwSourceID2;
+ enterSourceDB("gwSource2", domainID3, cfStereo, gwSourceID2);
+
+ am_sinkID_t gwSinkID2;
+ enterSinkDB("gwSink2", domainID2, cfMono, gwSinkID2);
+
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID3, cfStereo, sinkID);
+
+ am_gatewayID_t gatewayID1;
+ enterGatewayDB("gateway", domainID3, domainID2, cfStereo, cfMono, matrix, gwSourceID2, gwSinkID2, gatewayID1);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+
+ pDatabaseHandler.getSinkInfoDB(sinkID, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+ std::vector<am_Route_s> listRoutes;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back({sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({gwSourceID1, gwSinkID2, domainID2, CF_GENIVI_MONO});
+ compareRoute1.route.push_back({gwSourceID2, sinkID, domainID3, CF_GENIVI_STEREO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+}
+
+TEST_F(CAmRouterMapTest,route3Domains1Source3Gateways3Convertres1Sink)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ am_domainID_t domainID1, domainID2, domainID3;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+ enterDomainDB("domain3", domainID3);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
+
+ am_sinkID_t gwSinkID1;
+ enterSinkDB("gwSink1", domainID1, cfStereo, gwSinkID1);
+
+ am_sourceID_t gwSourceID1;
+ enterSourceDB("gwSource1", domainID2, cfMono, gwSourceID1);
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_gatewayID_t gatewayID;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfMono, cfStereo, matrix, gwSourceID1, gwSinkID1, gatewayID);
+
+
+ am_sourceID_t gwSourceID21;
+ enterSourceDB("gwSource21", domainID3, cfAuto, gwSourceID21);
+ am_sinkID_t gwSinkID21;
+ enterSinkDB("gwSink21", domainID1, cfMono, gwSinkID21);
+ am_gatewayID_t gatewayID21;
+ enterGatewayDB("gateway21", domainID3, domainID2, cfAuto, cfMono, matrix, gwSourceID21, gwSinkID21, gatewayID21);
+
+ am_sourceID_t gwSourceID22;
+ enterSourceDB("gwSource22", domainID3, cfAuto, gwSourceID22);
+ am_sinkID_t gwSinkID22;
+ enterSinkDB("gwSink22", domainID2, cfMono, gwSinkID22);
+ am_gatewayID_t gatewayID22;
+ enterGatewayDB("gateway22", domainID3, domainID2, cfAuto, cfMono, matrix, gwSourceID22, gwSinkID22, gatewayID22);
+
+ am_sourceID_t gwSourceID3;
+ enterSourceDB("gwSource3", domainID3, cfAnalog, gwSourceID3);
+ am_sinkID_t gwSinkID3;
+ enterSinkDB("gwSink3", domainID3, cfAuto, gwSinkID3);
+ am_converterID_t converterID1;
+ enterConverterDB("converter1", domainID3, cfAnalog, cfAuto, matrix, gwSourceID3, gwSinkID3, converterID1);
+
+ am_sourceID_t gwSourceID4;
+ enterSourceDB("gwSource4", domainID3, cfStereo, gwSourceID4);
+ am_sinkID_t gwSinkID4;
+ enterSinkDB("gwSink4", domainID3, cfAnalog, gwSinkID4);
+ am_converterID_t converterID2;
+ enterConverterDB("converter2", domainID3, cfStereo, cfAnalog, matrix, gwSourceID4, gwSinkID4, converterID2);
+
+ am_sourceID_t gwSourceID5;
+ enterSourceDB("gwSource5", domainID3, cfStereo, gwSourceID5);
+ am_sinkID_t gwSinkID5;
+ enterSinkDB("gwSink5", domainID3, cfAnalog, gwSinkID5);
+ am_converterID_t converterID3;
+ enterConverterDB("converter3", domainID3, cfStereo, cfAnalog, matrix, gwSourceID5, gwSinkID5, converterID3);
+
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID3, cfStereo, sinkID);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+
+ pDatabaseHandler.getSinkInfoDB(sinkID, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+ std::vector<am_Route_s> listRoutes;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+ ASSERT_EQ(static_cast<uint>(4), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back({sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({gwSourceID1, gwSinkID21, domainID1, CF_GENIVI_MONO});
+ compareRoute1.route.push_back({gwSourceID21, gwSinkID3, domainID3, CF_GENIVI_AUTO});
+ compareRoute1.route.push_back({gwSourceID3, gwSinkID4, domainID3, CF_GENIVI_ANALOG});
+ compareRoute1.route.push_back({gwSourceID4, sinkID, domainID3, CF_GENIVI_STEREO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+
+ am_Route_s compareRoute2;
+ compareRoute2.sinkID = sinkID;
+ compareRoute2.sourceID = sourceID;
+ compareRoute2.route.push_back({sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
+ compareRoute2.route.push_back({gwSourceID1, gwSinkID21, domainID1, CF_GENIVI_MONO});
+ compareRoute2.route.push_back({gwSourceID21, gwSinkID3, domainID3, CF_GENIVI_AUTO});
+ compareRoute2.route.push_back({gwSourceID3, gwSinkID5, domainID3, CF_GENIVI_ANALOG});
+ compareRoute2.route.push_back({gwSourceID5, sinkID, domainID3, CF_GENIVI_STEREO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute2,listRoutes[1]));
+
+
+ am_Route_s compareRoute3;
+ compareRoute3.sinkID = sinkID;
+ compareRoute3.sourceID = sourceID;
+ compareRoute3.route.push_back({sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
+ compareRoute3.route.push_back({gwSourceID1, gwSinkID22, domainID2, CF_GENIVI_MONO});
+ compareRoute3.route.push_back({gwSourceID22, gwSinkID3, domainID3, CF_GENIVI_AUTO});
+ compareRoute3.route.push_back({gwSourceID3, gwSinkID4, domainID3, CF_GENIVI_ANALOG});
+ compareRoute3.route.push_back({gwSourceID4, sinkID, domainID3, CF_GENIVI_STEREO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute3,listRoutes[2]));
+
+ am_Route_s compareRoute4;
+ compareRoute4.sinkID = sinkID;
+ compareRoute4.sourceID = sourceID;
+ compareRoute4.route.push_back({sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
+ compareRoute4.route.push_back({gwSourceID1, gwSinkID22, domainID2, CF_GENIVI_MONO});
+ compareRoute4.route.push_back({gwSourceID22, gwSinkID3, domainID3, CF_GENIVI_AUTO});
+ compareRoute4.route.push_back({gwSourceID3, gwSinkID5, domainID3, CF_GENIVI_ANALOG});
+ compareRoute4.route.push_back({gwSourceID5, sinkID, domainID3, CF_GENIVI_STEREO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute4,listRoutes[3]));
+}
+
+TEST_F(CAmRouterMapTest,routeSource1Sink2PathThroughConv1Gate1)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
+
+ am_sinkID_t gwSinkID1;
+ enterSinkDB("gwSink1", domainID1, cfMono, gwSinkID1);
+
+ am_sinkID_t coSinkID21;
+ enterSinkDB("coSink21", domainID1, cfStereo, coSinkID21);
+
+ am_sourceID_t coSourceID21;
+ enterSourceDB("coSource21", domainID1, cfMono, coSourceID21);
+
+ am_converterID_t converterID1;
+ enterConverterDB("converter1", domainID1, cfMono, cfStereo, matrix, coSourceID21, coSinkID21, converterID1);
+
+ am_sourceID_t gwSourceID1;
+ enterSourceDB("gwSource21", domainID2, cfAuto, gwSourceID1);
+
+ am_gatewayID_t gatewayID;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfAuto, cfMono, matrix, gwSourceID1, gwSinkID1, gatewayID);
+
+ am_sinkID_t sinkID1;
+ enterSinkDB("sink1", domainID2, cfAuto, sinkID1);
+
+ am_sinkID_t sinkID2;
+ enterSinkDB("sink2", domainID1, cfAuto, sinkID2);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink1;
+ pDatabaseHandler.getSinkInfoDB(sinkID1, sink1);
+ am::am_Sink_s sink2;
+ pDatabaseHandler.getSinkInfoDB(sinkID2, sink2);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+ std::vector<am_Route_s> listRoutes;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink1, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID1;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back({sourceID, coSinkID21, domainID1, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({coSourceID21, gwSinkID1, domainID1, CF_GENIVI_MONO});
+ compareRoute1.route.push_back({gwSourceID1, sinkID1, domainID2, CF_GENIVI_AUTO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+
+ listRoutes.clear();
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink2, listRoutes));
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+}
+
+TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughDomain2)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
+
+ am_sinkID_t gwSinkID11;
+ enterSinkDB("gwSink11", domainID1, cfStereo, gwSinkID11);
+ am_sourceID_t gwSourceID11;
+ enterSourceDB("gwSource11", domainID2, cfAnalog, gwSourceID11);
+ am_converterID_t gatewayID1;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfStereo, matrix, gwSourceID11, gwSinkID11, gatewayID1);
+
+ am_sinkID_t gwSinkID21;
+ enterSinkDB("gwSink21", domainID2, cfAnalog, gwSinkID21);
+ am_sourceID_t gwSourceID12;
+ enterSourceDB("gwSource12", domainID1, cfAuto, gwSourceID12);
+ am_gatewayID_t gatewayID2;
+ enterGatewayDB("gateway2", domainID1, domainID2, cfAuto, cfAnalog, matrix, gwSourceID12, gwSinkID21, gatewayID2);
+
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID1, cfAuto, sinkID);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+
+ pDatabaseHandler.getSinkInfoDB(sinkID, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+ std::vector<am_Route_s> listRoutes;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back({sourceID, gwSinkID11, domainID1, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({gwSourceID11, gwSinkID21, domainID2, CF_GENIVI_ANALOG});
+ compareRoute1.route.push_back({gwSourceID12, sinkID, domainID1, CF_GENIVI_AUTO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+}
+
+TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughGate1Conv2Gate2)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
+
+ am_sinkID_t gwSinkID11;
+ enterSinkDB("gwSink11", domainID1, cfStereo, gwSinkID11);
+
+ am_sourceID_t gwSourceID21;
+ enterSourceDB("gwSource21", domainID2, cfAnalog, gwSourceID21);
+
+ am_converterID_t gatewayID1;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfStereo, matrix, gwSourceID21, gwSinkID11, gatewayID1);
+
+ am_sinkID_t gwSinkID21;
+ enterSinkDB("gwSink21", domainID2, cfStereo, gwSinkID21);
+
+ am_sourceID_t gwSourceID12;
+ enterSourceDB("gwSource12", domainID1, cfAuto, gwSourceID12);
+
+ am_sinkID_t coSinkID21;
+ enterSinkDB("coSink21", domainID2, cfAnalog, coSinkID21);
+
+ am_sourceID_t coSourceID21;
+ enterSourceDB("coSource21", domainID2, cfStereo, coSourceID21);
+
+ am_converterID_t converterID2;
+ enterConverterDB("converter2", domainID2, cfStereo, cfAnalog, matrix, coSourceID21, coSinkID21, converterID2);
+
+
+ am_gatewayID_t gatewayID2;
+ enterGatewayDB("gateway2", domainID1, domainID2, cfAuto, cfStereo, matrix, gwSourceID12, gwSinkID21, gatewayID2);
+
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID1, cfAuto, sinkID);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+
+ pDatabaseHandler.getSinkInfoDB(sinkID, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+ std::vector<am_Route_s> listRoutes;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back({sourceID, gwSinkID11, domainID1, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG});
+ compareRoute1.route.push_back({coSourceID21, gwSinkID21, domainID2, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({gwSourceID12, sinkID, domainID1, CF_GENIVI_AUTO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+}
+
+TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughConv1Gate1Conv2Gate2)
+{
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
+ std::vector<am_CustomConnectionFormat_t> cfFuture1;
+ cfFuture1.push_back(5);
+ std::vector<am_CustomConnectionFormat_t> cfFuture2;
+ cfFuture2.push_back(6);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
+
+ am_sinkID_t coSinkID11;
+ enterSinkDB("coSink11", domainID1, cfStereo, coSinkID11);
+ am_sourceID_t coSourceID11;
+ enterSourceDB("coSource11", domainID1, cfFuture1, coSourceID11);
+ am_converterID_t converterID11;
+ enterConverterDB("converter11", domainID1, cfFuture1, cfStereo, matrix, coSourceID11, coSinkID11, converterID11);
+
+ am_sinkID_t coSinkID12;
+ enterSinkDB("coSink12", domainID1, cfStereo, coSinkID12);
+ am_sourceID_t coSourceID12;
+ enterSourceDB("coSource12", domainID1, cfFuture2, coSourceID12);
+ am_converterID_t converterID12;
+ enterConverterDB("converter12", domainID1, cfFuture2, cfStereo, matrix, coSourceID12, coSinkID12, converterID12);
+
+ am_sinkID_t coSinkID13;
+ enterSinkDB("coSink13", domainID1, cfFuture2, coSinkID13);
+ am_sourceID_t coSourceID13;
+ enterSourceDB("coSource13", domainID1, cfFuture1, coSourceID13);
+ am_converterID_t converterID13;
+ enterConverterDB("converter13", domainID1, cfFuture1, cfFuture2, matrix, coSourceID13, coSinkID13, converterID13);
+
+ am_sinkID_t gwSinkID11;
+ enterSinkDB("gwSink11", domainID1, cfFuture1, gwSinkID11);
+ am_sourceID_t gwSourceID21;
+ enterSourceDB("gwSource21", domainID2, cfAnalog, gwSourceID21);
+ am_converterID_t gatewayID1;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfFuture1, matrix, gwSourceID21, gwSinkID11, gatewayID1);
+
+ am_sinkID_t gwSinkID21;
+ enterSinkDB("gwSink21", domainID2, cfStereo, gwSinkID21);
+
+ am_sourceID_t gwSourceID12;
+ enterSourceDB("gwSource12", domainID1, cfAuto, gwSourceID12);
+
+ am_sinkID_t coSinkID21;
+ enterSinkDB("coSink21", domainID2, cfAnalog, coSinkID21);
+
+ am_sourceID_t coSourceID21;
+ enterSourceDB("coSource21", domainID2, cfStereo, coSourceID21);
+
+ am_converterID_t converterID2;
+ enterConverterDB("converter2", domainID2, cfStereo, cfAnalog, matrix, coSourceID21, coSinkID21, converterID2);
+
+
+ am_gatewayID_t gatewayID2;
+ enterGatewayDB("gateway2", domainID1, domainID2, cfAuto, cfStereo, matrix, gwSourceID12, gwSinkID21, gatewayID2);
+
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID1, cfAuto, sinkID);
+
+ am::am_Source_s source;
+ am::am_Sink_s sink;
+
+ pDatabaseHandler.getSinkInfoDB(sinkID, sink);
+ pDatabaseHandler.getSourceInfoDB(sourceID, source);
+
+ std::vector<am_Route_s> listRoutes;
+
+ ASSERT_EQ(E_OK, pRouter.getRoute(false, source, sink, listRoutes));
+
+ ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back({sourceID, coSinkID11, domainID1, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({coSourceID11, gwSinkID11, domainID1, 5});
+ compareRoute1.route.push_back({gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG});
+ compareRoute1.route.push_back({coSourceID21, gwSinkID21, domainID2, CF_GENIVI_STEREO});
+ compareRoute1.route.push_back({gwSourceID12, sinkID, domainID1, CF_GENIVI_AUTO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+
+ am_Route_s compareRoute2;
+ compareRoute2.sinkID = sinkID;
+ compareRoute2.sourceID = sourceID;
+ compareRoute2.route.push_back({sourceID, coSinkID12, domainID1, CF_GENIVI_STEREO});
+ compareRoute2.route.push_back({coSourceID12, coSinkID13, domainID1, 6});
+ compareRoute2.route.push_back({coSourceID13, gwSinkID21, domainID1, 5});
+ compareRoute2.route.push_back({gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG});
+ compareRoute2.route.push_back({gwSourceID12, sinkID, domainID1, CF_GENIVI_AUTO});
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
}
int main(int argc, char **argv)