summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphilippe colliot <PSA>2015-11-23 11:25:10 +0100
committerphilippe colliot <PSA>2015-11-23 11:25:10 +0100
commitac6df86f6ba342a32ec0308b62471417c7c2f534 (patch)
tree40263e923f8030ff83dc4846a94bea9a5c51ec1a
parentd67268f037737e63a831419290f51505f39dfdfb (diff)
parent2dcedadc0a993445f458adfd9b6910f1d40c84e0 (diff)
downloadpoi-service-ac6df86f6ba342a32ec0308b62471417c7c2f534.tar.gz
Merge branch 'master' of ssh://git-genivi@git.projects.genivi.org/lbs/navigation.git
-rwxr-xr-xtest/navigation/test-map-viewer-control.py138
1 files changed, 138 insertions, 0 deletions
diff --git a/test/navigation/test-map-viewer-control.py b/test/navigation/test-map-viewer-control.py
new file mode 100755
index 0000000..78c4555
--- /dev/null
+++ b/test/navigation/test-map-viewer-control.py
@@ -0,0 +1,138 @@
+#!/usr/bin/python
+
+"""
+**************************************************************************
+* @licence app begin@
+* SPDX-License-Identifier: MPL-2.0
+*
+* \copyright Copyright (C) 2015, Mentor Graphics
+*
+* \file test-map-viewer-control.py
+*
+* \brief This simple test shows how the mapviewer
+* could be easily tested using a python script
+*
+* \author Marco Residori <marco.residori@mentor_graphics.com>
+*
+* \version 1.0
+*
+* This Source Code Form is subject to the terms of the
+* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+* List of changes:
+* <date>, <name>, <description of change>
+*
+* @licence end@
+**************************************************************************
+"""
+
+import dbus
+import gobject
+import time
+
+#constants as defined in the Navigation API
+LATITUDE = 0x00a0
+LONGITUDE = 0x00a1
+
+MAIN_MAP = 0x0010
+SPLIT_SCREEN = 0x0011
+
+print '\n--------------------------'
+print 'MapViewerControl Test'
+print '--------------------------\n'
+
+#connect to session bus
+bus = dbus.SessionBus()
+
+session = bus.get_object('org.genivi.mapviewer.Session','/org/genivi/mapviewer')
+session_interface = dbus.Interface(session, dbus_interface='org.genivi.mapviewer.Session')
+
+#get session handle
+sessionhandle = session_interface.CreateSession(dbus.String("test mapviewer"))
+print 'Session handle: ' + str(sessionhandle)
+
+MapViewerControl_obj = bus.get_object('org.genivi.mapviewer.MapViewerControl','/org/genivi/mapviewer')
+MapViewerControl_interface = dbus.Interface(MapViewerControl_obj, dbus_interface='org.genivi.mapviewer.MapViewerControl')
+
+#get mapviewer handle
+mapviewerhandle = MapViewerControl_interface.CreateMapViewInstance( \
+ dbus.UInt32(sessionhandle), \
+ dbus.Struct((dbus.UInt16(640),dbus.UInt16(640))), \
+ dbus.UInt16(MAIN_MAP))
+
+print 'MapView handle: ' + str(mapviewerhandle)
+
+# Bern
+lat1 = 46.9479
+lon1 = 7.4446
+alt1 = 0
+
+time.sleep(2)
+
+print 'Stop following the car position'
+MapViewerControl_interface.SetFollowCarMode( \
+ dbus.UInt32(sessionhandle), \
+ dbus.UInt32(mapviewerhandle), \
+ dbus.Boolean(False))
+
+print 'Set center in Bern(' + str(lat1) + ',' + str(lon1) + ')'
+MapViewerControl_interface.SetTargetPoint( \
+ dbus.UInt32(sessionhandle), \
+ dbus.UInt32(mapviewerhandle), \
+ dbus.Struct((dbus.Double(lat1),dbus.Double(lon1),dbus.Int32(alt1))))
+
+# Get current position
+targetPoint = MapViewerControl_interface.GetTargetPoint( \
+ dbus.UInt32(mapviewerhandle) )
+
+lat2 = targetPoint[0]
+lon2 = targetPoint[1]
+alt2 = targetPoint[2]
+
+print 'Get center -> (' + str(lat2) + ',' + str(lon2) + ')'
+
+if round(lat1,4) != round(lat2,4) :
+ print '\nTest Failed:' + str(round(lat1,4)) + '!=' + str(round(lat2,4)) + '\n'
+
+if round(lon1,4) != round(lon2,4) :
+ print '\nTest Failed:' + str(round(lon1,4)) + '!=' + str(round(lon2,4)) + '\n'
+
+if round(alt1,4) != round(alt2,4) :
+ print '\nTest Failed:' + str(round(alt1,4)) + '!=' + str(round(alt2,4)) + '\n'
+
+print 'Zoom in'
+MapViewerControl_interface.SetMapViewScaleByDelta( \
+ dbus.UInt32(sessionhandle), \
+ dbus.UInt32(mapviewerhandle), \
+ dbus.Int16(1))
+
+time.sleep(1)
+
+print 'Zoom in'
+MapViewerControl_interface.SetMapViewScaleByDelta( \
+ dbus.UInt32(sessionhandle), \
+ dbus.UInt32(mapviewerhandle), \
+ dbus.Int16(1))
+
+time.sleep(1)
+
+print 'Zoom out'
+MapViewerControl_interface.SetMapViewScaleByDelta( \
+ dbus.UInt32(sessionhandle), \
+ dbus.UInt32(mapviewerhandle), \
+ dbus.Int16(-1))
+
+time.sleep(1)
+
+print 'Zoom out'
+MapViewerControl_interface.SetMapViewScaleByDelta( \
+ dbus.UInt32(sessionhandle), \
+ dbus.UInt32(mapviewerhandle), \
+ dbus.Int16(-1))
+
+print '\nTest Finished\n'
+
+
+
+
+