From f7ef940971df9f938bed059824e5bf1d7eab8d65 Mon Sep 17 00:00:00 2001 From: Aleksandar Donchev Date: Thu, 26 Jan 2017 10:09:13 +0100 Subject: * CAmRouterTest adoptions. Signed-off-by: Christian Linke --- AudioManagerCore/include/CAmRouter.h | 11 +++++++---- AudioManagerCore/src/CAmRouter.cpp | 16 ++++++---------- AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp | 8 ++++---- 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 & nodes, std::vector & 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& returnList); am_Error_e getRoute(const bool onlyfree, const am_Source_s & source, const am_Sink_s & sink, std::vector & 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 & returnList); am_Error_e getRouteFromLoadedNodes(const am_Source_s & aSource, const am_Sink_s & aSink, std::vector & 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 & 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 & 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::iterator connectionFormatIterator = listPriorityConnectionFormats.begin(); //here we need to check if we are at the end and stop std::vector::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 resultNodesPath, std::vector& 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(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(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(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(0), listRoutes.size()); } -- cgit v1.2.1