From 1580c63e57e4de61a8f24d2bed2c44e3316a3641 Mon Sep 17 00:00:00 2001 From: asanoaozora Date: Fri, 1 Sep 2017 16:26:35 +0200 Subject: minor improvement of test scripts --- .../genivi_navigationcore_guidance.cxx | 14 +++- .../genivi_navigationcore_routing.cxx | 28 ++++--- .../poi-cam/genivi_poiservice_cam_navit.cxx | 3 +- test/navigation/script/test-all | 94 ++++++++++++++-------- test/navigation/script/test-guidance.py | 13 ++- 5 files changed, 102 insertions(+), 50 deletions(-) diff --git a/src/navigation/navigation-core/guidance-plugin/genivi_navigationcore_guidance.cxx b/src/navigation/navigation-core/guidance-plugin/genivi_navigationcore_guidance.cxx index cc64b72..a7b8419 100644 --- a/src/navigation/navigation-core/guidance-plugin/genivi_navigationcore_guidance.cxx +++ b/src/navigation/navigation-core/guidance-plugin/genivi_navigationcore_guidance.cxx @@ -410,8 +410,10 @@ GuidanceObj::GetDestinationInformation(uint32_t& Distance, uint32_t& TravelTime, struct attr destination_time, destination_length; struct map_rect *mr=get_map_rect(); struct item *item; - if (!mr) + if (!mr) { + LOG_ERROR_MSG(gCtx,"GetDestinationInformation: failed to get map rect"); throw DBus::ErrorFailed("internal error:failed to get map rect"); + } while (item=map_rect_get_item(mr)) { if (item_coord_get(item, &c[idx], 1)) { if (!idx) { @@ -600,6 +602,10 @@ void GuidanceObj::GetGuidanceDetails(bool& voiceGuidance, bool& vehicleOnTheRoad, bool& isDestinationReached, int32_t& maneuver) { struct map_rect *mr=get_map_rect(); + if (!mr) { + LOG_ERROR_MSG(gCtx,"Failed to get map rect"); + return; + } struct item *item; item=get_item(mr); std::string road_name_after_maneuver; @@ -618,7 +624,11 @@ void GuidanceObj::GetManeuversList(const uint16_t& requestedNumberOfManeuvers, const uint32_t& maneuverOffset, uint16_t& numberOfManeuvers,std::vector< ::DBus::Struct< std::vector< ::DBus::Struct< std::string, std::vector< ::DBus::Struct< int32_t, std::string > >, std::string > >, std::string, std::string, std::string, std::string, uint16_t, int32_t, uint32_t, std::vector< ::DBus::Struct< uint32_t, uint32_t, int32_t, int32_t, std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > > > > >& maneuversList) { struct map_rect *mr=get_map_rect(); - struct item *item; + if (!mr) { + LOG_ERROR_MSG(gCtx,"Failed to get map rect"); + return; + } + struct item *item; uint16_t maneuverIndex; std::map< int32_t, DBusCommonAPIVariant >::iterator it; diff --git a/src/navigation/navigation-core/routing-plugin/genivi_navigationcore_routing.cxx b/src/navigation/navigation-core/routing-plugin/genivi_navigationcore_routing.cxx index 99156d6..6e68da5 100644 --- a/src/navigation/navigation-core/routing-plugin/genivi_navigationcore_routing.cxx +++ b/src/navigation/navigation-core/routing-plugin/genivi_navigationcore_routing.cxx @@ -657,11 +657,15 @@ void RoutingObj::GetRouteSegments(int16_t detailLevel , const std::vector< DBusCommonAPIEnumeration >& valuesToReturn, const uint32_t& numberOfSegments, const uint32_t& offset, uint32_t& totalNumberOfSegments, std::vector< std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > >& RouteSegments) { struct map *m=route_get_map(m_route.u.route); - if (!m) - throw DBus::ErrorFailed("internal error:failed to get route map"); + if (!m){ + LOG_ERROR_MSG(gCtx,"GetRouteSegments: failed to get route map"); + throw DBus::ErrorFailed("internal error:failed to get route map"); + } struct map_rect *mr=map_rect_new(m, NULL); - if (!mr) - throw DBus::ErrorFailed("internal error:failed to create route map rect"); + if (!mr){ + LOG_ERROR_MSG(gCtx,"GetRouteSegments: failed to create route map rect"); + throw DBus::ErrorFailed("internal error:failed to create route map rect"); + } struct item *item; struct coord c[128],last; int count,i; @@ -749,12 +753,16 @@ RoutingObj::GetRouteBoundingBox(::DBus::Struct< ::DBus::Struct< double, double > struct map *m=route_get_map(m_route.u.route); struct item *item; - if (!m) - throw DBus::ErrorFailed("internal error:failed to get route map"); - struct map_rect *mr=map_rect_new(m, NULL); - if (!mr) - throw DBus::ErrorFailed("internal error:failed to create route map rect"); - while ((item=map_rect_get_item(mr))) { + if (!m){ + LOG_ERROR_MSG(gCtx,"GetRouteBoundingBox: failed to get route map"); + throw DBus::ErrorFailed("internal error:failed to get route map"); + } + struct map_rect *mr=map_rect_new(m, NULL); + if (!mr){ + LOG_ERROR_MSG(gCtx,"GetRouteBoundingBox: failed to create route map rect"); + throw DBus::ErrorFailed("internal error:failed to create route map rect"); + } + while ((item=map_rect_get_item(mr))) { struct coord c[128]; int count,i; do { diff --git a/src/navigation/poi-cam/genivi_poiservice_cam_navit.cxx b/src/navigation/poi-cam/genivi_poiservice_cam_navit.cxx index 9680be7..951e670 100644 --- a/src/navigation/poi-cam/genivi_poiservice_cam_navit.cxx +++ b/src/navigation/poi-cam/genivi_poiservice_cam_navit.cxx @@ -239,7 +239,6 @@ class ContentAccessModule { struct attr label; struct coord c; - LOG_DEBUG_MSG(gCtx,"adding poi"); ::DBus::Struct< uint32_t, std::string, uint32_t, ::DBus::Struct< double, double, double >, uint16_t, std::vector< ::DBus::Struct< uint32_t, int32_t, DBusCommonAPIVariant > > > result; ::DBus::Struct< uint32_t, int32_t, DBusCommonAPIVariant > attribute; bool stringMatched=false; @@ -402,7 +401,7 @@ class ContentAccessModule g.lat=location._1; g.lng=location._2; transform_from_geo(projection_mg, &g, &m_center); - LOG_DEBUG(gCtx,"c 0x%x,0x%x",m_center.x,m_center.y); + LOG_DEBUG(gCtx,"center 0x%x,0x%x",m_center.x,m_center.y); m_scale=transform_scale(m_center.y); int d=m_max_radius*10/m_scale; m_selection.next=NULL; diff --git a/test/navigation/script/test-all b/test/navigation/script/test-all index f762500..f5350af 100755 --- a/test/navigation/script/test-all +++ b/test/navigation/script/test-all @@ -1,45 +1,71 @@ #!/bin/bash export PYTHONIOENCODING=utf-8 +verbose=0 -result="$(./test-location-input.py -l ../resource/locations.xml 2>&1 >/dev/null)" -echo $result -if [[ $result != *"PASSED"* ]]; then - exit 1 -fi +while getopts hv opt +do + case $opt in + v) + verbose=1 + ;; + h) + echo "Usage:" + echo "-h: Help" + echo "-v: Verbose" + exit 1 + esac +done -result="$(./test-address-input.py -l ../resource/location.xml 2>&1 >/dev/null)" -echo $result -if [[ $result != *"PASSED"* ]]; then - exit 1 -fi +if [ "$verbose" = 1 ] +then + ./test-location-input.py -l ../resource/locations.xml + ./test-address-input.py -l ../resource/location.xml + ./test-route-calculation.py -r ../resource/routes.xml + ./test-poi.py -l ../resource/location.xml -s "sChü" + ./test-poi-guidance.py -l ../resource/location-poi.xml -s "cOnT" + ./test-guidance.py -r ../resource/route.xml + ./test-map-viewer-control.py -l ../resource/location.xml +else + result="$(./test-location-input.py -l ../resource/locations.xml 2>&1 >/dev/null)" + echo $result + if [[ $result != *"PASSED"* ]]; then + exit 1 + fi -result="$(./test-route-calculation.py -r ../resource/routes.xml 2>&1 >/dev/null)" -echo $result -if [[ $result != *"PASSED"* ]]; then - exit 1 -fi + result="$(./test-address-input.py -l ../resource/location.xml 2>&1 >/dev/null)" + echo $result + if [[ $result != *"PASSED"* ]]; then + exit 1 + fi -result="$(./test-poi.py -l ../resource/location.xml -s "sChü" 2>&1 >/dev/null)" -echo $result -if [[ $result != *"PASSED"* ]]; then - exit 1 -fi + result="$(./test-route-calculation.py -r ../resource/routes.xml 2>&1 >/dev/null)" + echo $result + if [[ $result != *"PASSED"* ]]; then + exit 1 + fi -result="$(./test-poi-guidance.py -l ../resource/location-poi.xml -s "cOnT" 2>&1 >/dev/null)" -echo $result -if [[ $result != *"PASSED"* ]]; then - exit 1 -fi + result="$(./test-poi.py -l ../resource/location.xml -s "sChü" 2>&1 >/dev/null)" + echo $result + if [[ $result != *"PASSED"* ]]; then + exit 1 + fi -result="$(./test-guidance.py -r ../resource/route.xml 2>&1 >/dev/null)" -echo $result -if [[ $result != *"PASSED"* ]]; then - exit 1 -fi + result="$(./test-poi-guidance.py -l ../resource/location-poi.xml -s "cOnT" 2>&1 >/dev/null)" + echo $result + if [[ $result != *"PASSED"* ]]; then + exit 1 + fi + + result="$(./test-guidance.py -r ../resource/route.xml 2>&1 >/dev/null)" + echo $result + if [[ $result != *"PASSED"* ]]; then + exit 1 + fi -result="$(./test-map-viewer-control.py -l ../resource/location.xml 2>&1 >/dev/null)" -echo $result -if [[ $result == *"PASSED"* ]]; then - echo "Batch test PASSED" + result="$(./test-map-viewer-control.py -l ../resource/location.xml 2>&1 >/dev/null)" + echo $result + if [[ $result == *"PASSED"* ]]; then + echo "Batch test PASSED" + fi fi diff --git a/test/navigation/script/test-guidance.py b/test/navigation/script/test-guidance.py index 6ebfbaf..7eb7a4d 100755 --- a/test/navigation/script/test-guidance.py +++ b/test/navigation/script/test-guidance.py @@ -53,7 +53,10 @@ HORIZONTAL_SIZE = 800 VERTICAL_SIZE = 480 NUMBER_OF_SEGMENTS = 500 ZOOM_GUIDANCE = 2 -SPEED_FACTOR = 16 +SPEED_FACTOR_SLOW = 16 +SPEED_FACTOR_FAST = 128 +SPEED_THRESHOLD_TO_FAST = 8 +SPEED_THRESHOLD_TO_SLOW = 2 #add signal receivers def routing_routeCalculationProgressUpdate_handler(routeHandle, status, percentage): @@ -90,6 +93,8 @@ def routing_routeCalculationSuccessful_handler(routeHandle,unfullfilledPreferenc g_guidance_active = True # pdb.set_trace() display_route(routeHandle) + #wait to display the route + time.sleep(2) launch_guidance(routeHandle) def session_sessionDeleted_handler(sessionHandle): @@ -139,6 +144,10 @@ def guidance_maneuverChanged_handler(maneuver): ret = g_guidance_interface.GetManeuversList(dbus.UInt16(10),dbus.UInt32(0)) print ("Number of maneuvers: " +str(ret[1])) print ("Next road to turn: " +ret[2][0][4]) + if ret[1] ==SPEED_THRESHOLD_TO_FAST: + g_mapmatchedposition_interface.SetSimulationSpeed(dbus.UInt32(g_navigationcore_session_handle), dbus.Byte(SPEED_FACTOR_FAST)) + if ret[1] == SPEED_THRESHOLD_TO_SLOW: + g_mapmatchedposition_interface.SetSimulationSpeed(dbus.UInt32(g_navigationcore_session_handle), dbus.Byte(SPEED_FACTOR_SLOW)) def guidance_waypointReached_handler(isDestination): print("Waypoint reached: " +str(isDestination)) @@ -185,7 +194,7 @@ def launch_guidance(route): dbus.Double(0)\ ))) g_mapmatchedposition_interface.StartSimulation(dbus.UInt32(g_navigationcore_session_handle)) - g_mapmatchedposition_interface.SetSimulationSpeed(dbus.UInt32(g_navigationcore_session_handle), dbus.Byte(SPEED_FACTOR)) + g_mapmatchedposition_interface.SetSimulationSpeed(dbus.UInt32(g_navigationcore_session_handle), dbus.Byte(SPEED_FACTOR_SLOW)) def launch_route_calculation(route): global g_current_route -- cgit v1.2.1