summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Donchev <Aleksander.Donchev@partner.bmw.de>2017-01-26 10:09:13 +0100
committerChristian Linke <christian.linke@bmw.de>2017-02-20 08:49:44 -0800
commitf7ef940971df9f938bed059824e5bf1d7eab8d65 (patch)
treeaf4795c09c137f904ba8a2102269ae2ab9df6829
parent1fec58235fa9c3c273e244b11ee6b3b77922b6bf (diff)
downloadaudiomanager-f7ef940971df9f938bed059824e5bf1d7eab8d65.tar.gz
* CAmRouterTest adoptions.
Signed-off-by: Christian Linke <christian.linke@bmw.de>
-rw-r--r--AudioManagerCore/include/CAmRouter.h11
-rw-r--r--AudioManagerCore/src/CAmRouter.cpp16
-rw-r--r--AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp8
3 files changed, 17 insertions, 18 deletions
diff --git a/AudioManagerCore/include/CAmRouter.h b/AudioManagerCore/include/CAmRouter.h
index f4955d6..1242824 100644
--- a/AudioManagerCore/include/CAmRouter.h
+++ b/AudioManagerCore/include/CAmRouter.h
@@ -219,6 +219,8 @@ class CAmRouter
/**
* Connection format permutations.
+ *
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
*/
am_Error_e determineConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes, std::vector<am_Route_s> & result);
am_Error_e doConnectionFormatsForPath(am_Route_s & routeObjects,
@@ -251,7 +253,7 @@ public:
* @param sourceID start point.
* @param sinkID end point.
* @param returnList list with all possible paths
- * @return E_OK on success(0 or more paths) or E_NOT_POSSIBLE on failure.
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
*/
am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList);
am_Error_e getRoute(const bool onlyfree, const am_Source_s & source, const am_Sink_s & sink, std::vector<am_Route_s> & listRoutes);
@@ -262,7 +264,7 @@ public:
* @param sourceID start point.
* @param sinkID end point.
* @param returnList list with all possible paths
- * @return E_OK on success(0 or more paths) or E_NOT_POSSIBLE on failure.
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
*/
am_Error_e getRouteFromLoadedNodes(const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList);
am_Error_e getRouteFromLoadedNodes(const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes);
@@ -273,17 +275,18 @@ public:
* @param source start point.
* @param sink end point.
* @param returnList list with all possible paths.
- * @return E_OK on success(0 or more paths) or E_NOT_POSSIBLE on failure.
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
*/
am_Error_e getFirstNShortestPaths(CAmRoutingNode & source, CAmRoutingNode & sink, std::vector<am_Route_s> & resultPath);
/**
* Find the shortest path between given source and sink. This method should be called only after 'load' has been called.
+ * This method do not pay attention on the parameter mMaxAllowedCycles and go through all possible paths.
*
* @param source start point.
* @param sink end point.
* @param returnList list with the connection format permutations of the shortest path.
- * @return E_OK on success(0 or more paths) or E_NOT_POSSIBLE on failure.
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
*/
am_Error_e getShortestPath(CAmRoutingNode & source, CAmRoutingNode & sink, std::vector<am_Route_s> & resultPath);
diff --git a/AudioManagerCore/src/CAmRouter.cpp b/AudioManagerCore/src/CAmRouter.cpp
index 1796fe6..002bd9d 100644
--- a/AudioManagerCore/src/CAmRouter.cpp
+++ b/AudioManagerCore/src/CAmRouter.cpp
@@ -558,23 +558,19 @@ am_Error_e CAmRouter::doConnectionFormatsForPath(am_Route_s & routeObjects,
listMergeConnectionFormats, listPriorityConnectionFormats))!= E_OK)
return (returnError);
+ if (listPriorityConnectionFormats.empty())
+ return (E_NOT_POSSIBLE);
//we have the list sorted after priors - now we try one after the other with the next part of the route
std::vector<am_CustomConnectionFormat_t>::iterator connectionFormatIterator = listPriorityConnectionFormats.begin();
//here we need to check if we are at the end and stop
std::vector<am_RoutingElement_s>::iterator nextIterator = currentRoutingElementIterator + 1;//next pair source and sink
if (nextIterator == routeObjects.route.end())
{
- if (!listPriorityConnectionFormats.empty())
+ for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
{
- for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
- {
- currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
- result.push_back(routeObjects);
- }
- return (E_OK);
+ currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
+ result.push_back(routeObjects);
}
- else
- return (E_NOT_POSSIBLE);
}
else
{
@@ -583,8 +579,8 @@ am_Error_e CAmRouter::doConnectionFormatsForPath(am_Route_s & routeObjects,
currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
doConnectionFormatsForPath(routeObjects, nodes, nextIterator, currentNodeIterator, result);
}
- return (E_OK);
}
+ return (E_OK);
}
am_Error_e CAmRouter::cfPermutationsForPath(am_Route_s shortestRoute, std::vector<CAmRoutingNode*> resultNodesPath, std::vector<am_Route_s>& resultPath)
diff --git a/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp b/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp
index e1acd65..b4ab247 100644
--- a/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp
+++ b/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp
@@ -143,7 +143,7 @@ TEST_F(CAmRouterTest,simpleRoute2withDomainNoMatchFormats)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
+ ASSERT_EQ(E_NOT_POSSIBLE, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
@@ -435,7 +435,7 @@ TEST_F(CAmRouterTest,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(E_NOT_POSSIBLE, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
@@ -1416,7 +1416,7 @@ TEST_F(CAmRouterTest,simpleRoute3DomainsNoConnection)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
+ ASSERT_EQ(E_NOT_POSSIBLE, pRouter.getRoute(false,sourceID,sinkID,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
@@ -1629,7 +1629,7 @@ TEST_F(CAmRouterTest,simpleRoute2DomainsNoMatchConnectionFormats)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
+ ASSERT_EQ(E_NOT_POSSIBLE, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}