summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasanoaozora <fifitaneki@hotmail.com>2017-03-02 11:14:57 +0100
committerasanoaozora <fifitaneki@hotmail.com>2017-03-02 11:14:57 +0100
commit07095c495f1c088522e103846448651249d4c324 (patch)
tree114f7cd1041a07873909b2c4531174086455aabf
parent292d2ab9d3a9ded69f0135e23ace632fa9021d80 (diff)
downloadpoi-service-07095c495f1c088522e103846448651249d4c324.tar.gz
fix a bug for GDP version, add test for Tokyo area
-rw-r--r--src/navigation/README.md20
-rw-r--r--src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx62
-rw-r--r--src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx62
-rw-r--r--src/poi-service/README.md19
-rw-r--r--test/navigation/location_tokyo.xml10
-rw-r--r--test/navigation/route_tokyo.xml17
-rwxr-xr-xtest/navigation/test-all2
-rwxr-xr-xtest/navigation/test-all_tokyo11
-rwxr-xr-xtest/navigation/test-map-viewer-control.py61
-rwxr-xr-xtest/poi-service/test-poi.py177
10 files changed, 335 insertions, 106 deletions
diff --git a/src/navigation/README.md b/src/navigation/README.md
index dec2bb1..47270a0 100644
--- a/src/navigation/README.md
+++ b/src/navigation/README.md
@@ -40,18 +40,24 @@ sudo apt-get install python-pip python-dbus python-gobject python-pil
sudo pip install --upgrade pip
To test, launch the navigation middleware by entering:
-./run -r
-'bug safe' test files (can be launched several times):
-./test-location-input.py -l location.xml
-./test-route-calculation.py -r route.xml
-'bug to be fixed' test files (can be launched only one time):
-./test-guidance.py -r route.xml
-./test-map-viewer-control.py
+../../src/navigation/run -r
+and the test batch:
+./test-all
If everything is OK, you must see:
Test PASSED
+### How to test for Tokyo area (draft)
+It's also possible to launch test for Japan.
+Before testing it's necessary to get the map by picking it from this site:
+http://maps9.navit-project.org/api/map/?bbox=139.1,35.5,140.4,36.0&timestamp=170217
+Rename the file to tokyo.bin, copy it to ./map and do ./build.sh -c
+To test, launch the navigation middleware by entering:
+../../src/navigation/run -r -c tokyo
+and the test batch:
+./test-all_tokyo
+
##Directory Structure
map-viewer/
diff --git a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx
index a591cfb..726503a 100644
--- a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx
+++ b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx
@@ -30,7 +30,6 @@
#if LM
#include <ilm/ilm_client.h>
-#include <ilm/ilm_client.h>
#include <ilm/ilm_control.h>
//Align with Qt Surfaces = 8000 + Layer.
#ifndef FSA_SURFACE
@@ -1431,7 +1430,6 @@ MapViewerControlObj::ConvertGeoCoordsToPixelCoords(uint32_t sessionHandle, const
static void callbackFunction(ilmObjectType object, t_ilm_uint surfaceId, t_ilm_bool created, void *user_data)
{
(void)user_data;
- struct ilmSurfaceProperties sp;
t_ilm_int pLength = 0;
t_ilm_layer* ppArray = NULL;
@@ -1441,53 +1439,27 @@ static void callbackFunction(ilmObjectType object, t_ilm_uint surfaceId, t_ilm_b
if (object == ILM_SURFACE) {
if (created) {
if (surfaceId == FSA_SURFACE) {
- //Configure map surface
- if (ilm_getPropertiesOfSurface(surfaceId, &sp) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n");
- }
- if (ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, sp.origSourceWidth, sp.origSourceHeight) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceSetSourceRectangle\n");
- }
+ //Timing issue for creation - Need to add tempo
+ sleep(1);
- //RenderOrder with the hmi-launcher Qt surface
- /*
- * ilm_getLayerIDsOnScreen will give the layer attached
- * to the hmi-launcher Qt surface following hmi-launcher Qt surface
- */
- if (ilm_getLayerIDsOnScreen(0, &pLength, &ppArray) != ILM_SUCCESS) {
- dbg(lvl_error, "error on ilm_getLayerIDsOnScreen\n");
+ //Grab all the layers - HMI will be pLength-2 and FSA pLength-1
+ if (ilm_getLayerIDs(&pLength, &ppArray) != ILM_SUCCESS) {
+ fprintf(stderr, "error on ilm_getLayerIDs\n");
}
- /* The last one is the hmi-launcher layer and thus surface.
- * Then hmi-launcher surface toped the map surface into the hmi-launcher layer.
- */
- renderOrder[1] = SURFACE_OFFSET + ppArray[pLength - 1];
+ renderOrder[1] = SURFACE_OFFSET + ppArray[pLength - 2];
renderOrder[0] = FSA_SURFACE;
if (ilm_layerSetRenderOrder(ppArray[pLength - 1],renderOrder,2) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_layerSetRenderOrder\n");
- }
-
- //Put the map at the same resolution as the hmi-launcher
- if (ilm_getPropertiesOfSurface(SURFACE_OFFSET + ppArray[pLength - 1], &pSurfaceProperties) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n");
- }
-
- if (ilm_surfaceSetDestinationRectangle(surfaceId, pSurfaceProperties.destX, pSurfaceProperties.destY,
- pSurfaceProperties.destWidth, pSurfaceProperties.destHeight) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceSetDestinationRectangle\n");
- }
-
- if (ilm_surfaceSetVisibility(surfaceId, ILM_TRUE) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceSetVisibility\n");
+ fprintf(stderr,"error on ilm_layerSetRenderOrder\n");
}
if (ilm_commitChanges() != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_commitChanges\n");
+ fprintf(stderr,"error on ilm_commitChanges\n");
}
}
- }
+ }
}
}
#endif
@@ -1575,7 +1547,7 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControl *mapviewercontrol, uin
t_ilm_nativedisplay display = (t_ilm_nativedisplay)graphics_get_data(m_graphics.u.graphics, "display");
if (ilmClient_init(display) != ILM_SUCCESS) {
- dbg(lvl_error, "error on ilm_initWidthNativeDisplay\n");
+ fprintf(stderr, "error on ilm_initWidthNativeDisplay\n");
}
t_ilm_nativehandle nativehandle=(t_ilm_nativehandle)graphics_get_data(m_graphics.u.graphics,"xwindow_id");
@@ -1583,17 +1555,17 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControl *mapviewercontrol, uin
//Register Notification
if (ilm_registerNotification(callbackFunction, NULL) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_registerNotification\n");
+ fprintf(stderr,"error on ilm_registerNotification\n");
}
- //Create surface for the map and add notification when created
+ //Create surface for the map and add notification when created. Note: width, heigh & pixel format are not taking in count at the end.
if (ilm_surfaceCreate(nativehandle, MapViewSize._1, MapViewSize._2, ILM_PIXELFORMAT_RGBA_8888, &surfaceId) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceCreate\n");
+ fprintf(stderr,"error on ilm_surfaceCreate\n");
}
//Commit all changes
if (ilm_commitChanges() != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_commitChanges\n");
+ fprintf(stderr,"error on ilm_commitChanges\n");
}
#endif
@@ -1605,11 +1577,11 @@ MapViewerControlObj::~MapViewerControlObj()
t_ilm_surface surfaceId=FSA_SURFACE;
if (ilm_surfaceRemove(surfaceId) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceRemove\n");
+ fprintf(stderr,"error on ilm_surfaceRemove\n");
}
if (ilm_commitChanges() != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_commitChanges\n");
+ fprintf(stderr,"error on ilm_commitChanges\n");
}
#endif
@@ -1784,7 +1756,7 @@ plugin_init(void)
#if LM
if (ilm_init() != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_init\n");
+ fprintf(stderr,"error on ilm_init\n");
}
#endif
}
diff --git a/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx
index 62a7b0f..c5a3a00 100644
--- a/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx
+++ b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx
@@ -29,7 +29,6 @@
#include <stdlib.h>
#if LM
#include <ilm/ilm_client.h>
-#include <ilm/ilm_client.h>
#include <ilm/ilm_control.h>
//Align with Qt Surfaces = 8000 + Layer.
#ifndef FSA_SURFACE
@@ -1581,7 +1580,6 @@ MapViewerControlObj::ConvertGeoCoordsToPixelCoords(NavigationTypes::Handle Sessi
static void callbackFunction(ilmObjectType object, t_ilm_uint surfaceId, t_ilm_bool created, void *user_data)
{
(void)user_data;
- struct ilmSurfaceProperties sp;
t_ilm_int pLength = 0;
t_ilm_layer* ppArray = NULL;
@@ -1591,53 +1589,27 @@ static void callbackFunction(ilmObjectType object, t_ilm_uint surfaceId, t_ilm_b
if (object == ILM_SURFACE) {
if (created) {
if (surfaceId == FSA_SURFACE) {
- //Configure map surface
- if (ilm_getPropertiesOfSurface(surfaceId, &sp) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n");
- }
- if (ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, sp.origSourceWidth, sp.origSourceHeight) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceSetSourceRectangle\n");
- }
+ //Timing issue for creation - Need to add tempo
+ sleep(1);
- //RenderOrder with the hmi-launcher Qt surface
- /*
- * ilm_getLayerIDsOnScreen will give the layer attached
- * to the hmi-launcher Qt surface following hmi-launcher Qt surface
- */
- if (ilm_getLayerIDsOnScreen(0, &pLength, &ppArray) != ILM_SUCCESS) {
- dbg(lvl_error, "error on ilm_getLayerIDsOnScreen\n");
+ //Grab all the layers - HMI will be pLength-2 and FSA pLength-1
+ if (ilm_getLayerIDs(&pLength, &ppArray) != ILM_SUCCESS) {
+ fprintf(stderr, "error on ilm_getLayerIDs\n");
}
- /* The last one is the hmi-launcher layer and thus surface.
- * Then hmi-launcher surface toped the map surface into the hmi-launcher layer.
- */
- renderOrder[1] = SURFACE_OFFSET + ppArray[pLength - 1];
+ renderOrder[1] = SURFACE_OFFSET + ppArray[pLength - 2];
renderOrder[0] = FSA_SURFACE;
if (ilm_layerSetRenderOrder(ppArray[pLength - 1],renderOrder,2) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_layerSetRenderOrder\n");
- }
-
- //Put the map at the same resolution as the hmi-launcher
- if (ilm_getPropertiesOfSurface(SURFACE_OFFSET + ppArray[pLength - 1], &pSurfaceProperties) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n");
- }
-
- if (ilm_surfaceSetDestinationRectangle(surfaceId, pSurfaceProperties.destX, pSurfaceProperties.destY,
- pSurfaceProperties.destWidth, pSurfaceProperties.destHeight) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceSetDestinationRectangle\n");
- }
-
- if (ilm_surfaceSetVisibility(surfaceId, ILM_TRUE) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceSetVisibility\n");
+ fprintf(stderr,"error on ilm_layerSetRenderOrder\n");
}
if (ilm_commitChanges() != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_commitChanges\n");
+ fprintf(stderr,"error on ilm_commitChanges\n");
}
}
- }
+ }
}
}
#endif
@@ -1731,7 +1703,7 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControlServerStub *mapviewerco
t_ilm_nativedisplay display = (t_ilm_nativedisplay)graphics_get_data(m_graphics.u.graphics, "display");
if (ilmClient_init(display) != ILM_SUCCESS) {
- dbg(lvl_error, "error on ilm_initWidthNativeDisplay\n");
+ fprintf(stderr, "error on ilm_initWidthNativeDisplay\n");
}
t_ilm_nativehandle nativehandle=(t_ilm_nativehandle)graphics_get_data(m_graphics.u.graphics,"xwindow_id");
@@ -1739,17 +1711,17 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControlServerStub *mapviewerco
//Register Notification
if (ilm_registerNotification(callbackFunction, NULL) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_registerNotification\n");
+ fprintf(stderr,"error on ilm_registerNotification\n");
}
- //Create surface for the map and add notification when created
+ //Create surface for the map and add notification when created. Note: width, heigh & pixel format are not taking in count at the end.
if (ilm_surfaceCreate(nativehandle, MapViewSize._1, MapViewSize._2, ILM_PIXELFORMAT_RGBA_8888, &surfaceId) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceCreate\n");
+ fprintf(stderr,"error on ilm_surfaceCreate\n");
}
//Commit all changes
if (ilm_commitChanges() != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_commitChanges\n");
+ fprintf(stderr,"error on ilm_commitChanges\n");
}
#endif
@@ -1761,11 +1733,11 @@ MapViewerControlObj::~MapViewerControlObj()
t_ilm_surface surfaceId=FSA_SURFACE;
if (ilm_surfaceRemove(surfaceId) != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_surfaceRemove\n");
+ fprintf(stderr,"error on ilm_surfaceRemove\n");
}
if (ilm_commitChanges() != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_commitChanges\n");
+ fprintf(stderr,"error on ilm_commitChanges\n");
}
#endif
@@ -1942,7 +1914,7 @@ plugin_init(void)
#if LM
if (ilm_init() != ILM_SUCCESS) {
- dbg(lvl_error,"error on ilm_init\n");
+ fprintf(stderr,"error on ilm_init\n");
}
#endif
diff --git a/src/poi-service/README.md b/src/poi-service/README.md
index a8ebd94..89ba24f 100644
--- a/src/poi-service/README.md
+++ b/src/poi-service/README.md
@@ -28,6 +28,25 @@ or to build updated parts
## How To Run
```./bin/poi-server -f ./resource/poi-database-sample.db```
+## How To Test
+```./run &```
+```../../test/poi-service/test-poi.py```
+If everything is OK, you must see:
+Search for hotel and station with keyword: Saint-Germain
+Category ID: 2
+Name: hotel
+Category ID: 6
+Name: station
+Search handle: 1
+language: fra
+country: FRA
+script: Latn
+Search finished
+Results: 2
+Hotel: Au Manoir Saint-Germain des Prés
+Station: Saint-Germain des Prés
+Test PASSED
+
## How to for the CommonAPI based version
## Prerequisites
diff --git a/test/navigation/location_tokyo.xml b/test/navigation/location_tokyo.xml
new file mode 100644
index 0000000..8718582
--- /dev/null
+++ b/test/navigation/location_tokyo.xml
@@ -0,0 +1,10 @@
+<location-set area="Tokyo">
+<location>
+<latitude>35.660111</latitude>
+<longitude>139.699535</longitude>
+<country>Japan</country>
+<city>東京</city>
+<street>井ノ頭通り</street>
+<number>17</number>
+</location>
+</location-set>
diff --git a/test/navigation/route_tokyo.xml b/test/navigation/route_tokyo.xml
new file mode 100644
index 0000000..439c2bc
--- /dev/null
+++ b/test/navigation/route_tokyo.xml
@@ -0,0 +1,17 @@
+<route-set country="Japan">
+<route>
+<start>"Hamura"</start>
+<destination>"Shibuya"</destination>
+<name>"Route HAMURA to SHIBUYA"</name>
+<handle>0</handle>
+</route>
+<location name='"Hamura"'>
+<latitude>35.758795</latitude>
+<longitude>139.316533</longitude>
+</location>
+<location name='"Shibuya"'>
+<latitude>35.660687</latitude>
+<longitude>139.699284</longitude>
+</location>
+</route-set><!--NB: don't use accent.-->
+
diff --git a/test/navigation/test-all b/test/navigation/test-all
index 215e522..d2810d7 100755
--- a/test/navigation/test-all
+++ b/test/navigation/test-all
@@ -8,4 +8,4 @@ sleep 2
sleep 2
./test-guidance.py -r route.xml
sleep 2
-./test-map-viewer-control.py
+./test-map-viewer-control.py -l location.xml
diff --git a/test/navigation/test-all_tokyo b/test/navigation/test-all_tokyo
new file mode 100755
index 0000000..1dce7b4
--- /dev/null
+++ b/test/navigation/test-all_tokyo
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+./test-location-input.py -l location_tokyo.xml
+sleep 2
+./test-route-calculation.py -r route_tokyo.xml
+sleep 2
+./test-address-input.py -l location_tokyo.xml
+sleep 2
+./test-guidance.py -r route_tokyo.xml
+sleep 2
+./test-map-viewer-control.py -l location_tokyo.xml
diff --git a/test/navigation/test-map-viewer-control.py b/test/navigation/test-map-viewer-control.py
index aae6058..4029cbd 100755
--- a/test/navigation/test-map-viewer-control.py
+++ b/test/navigation/test-map-viewer-control.py
@@ -32,6 +32,11 @@ import gobject
import dbus.mainloop.glib
import time
from dltTrigger import *
+from xml.dom.minidom import parse
+import xml.dom.minidom
+import argparse
+import sys
+import errno
#import pdb; pdb.set_trace()
#name of the test
@@ -51,6 +56,15 @@ TIME_OUT = 20000
MIN_SCALE = 0
MAX_SCALE = 21
+# List of coordinates
+LATITUDE = list()
+LONGITUDE = list()
+ALTITUDE = list()
+COUNTRY_STRING = list()
+CITY_STRING = list()
+STREET_STRING = list()
+HOUSE_NUMBER_STRING = list()
+
def mapviewer_mapViewScaleChanged_handler(mapViewInstanceHandle,scale,isMinMax):
global g_scale
new_scale=int(scale)
@@ -94,6 +108,36 @@ print '\n--------------------------'
print 'MapViewerControl Test'
print '--------------------------\n'
+parser = argparse.ArgumentParser(description='Map Viewer Test for navigation PoC and FSA.')
+parser.add_argument('-l','--loc',action='store', dest='locations', help='List of locations in xml format')
+parser.add_argument("-v", "--verbose", action='store_true',help='print the whole log messages')
+args = parser.parse_args()
+
+if args.locations == None:
+ print('location file is missing')
+ sys.exit(1)
+else:
+ try:
+ DOMTree = xml.dom.minidom.parse(args.locations)
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ print('file not exists')
+ sys.exit(1)
+ location_set = DOMTree.documentElement
+
+print("Area : %s" % location_set.getAttribute("area"))
+
+locations = location_set.getElementsByTagName("location")
+
+for location in location_set.getElementsByTagName("location"):
+ LATITUDE.append(location.getElementsByTagName("latitude")[0].childNodes[0].data)
+ LONGITUDE.append(location.getElementsByTagName("longitude")[0].childNodes[0].data)
+ ALTITUDE.append(0)
+ COUNTRY_STRING.append(location.getElementsByTagName("country")[0].childNodes[0].data)
+ CITY_STRING.append(location.getElementsByTagName("city")[0].childNodes[0].data)
+ STREET_STRING.append(location.getElementsByTagName("street")[0].childNodes[0].data)
+ HOUSE_NUMBER_STRING.append(location.getElementsByTagName("number")[0].childNodes[0].data)
+
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -134,10 +178,11 @@ mapviewerhandle=ret[1]
print 'MapView handle: ' + str(mapviewerhandle)
-# Bern
-lat1 = 46.9479
-lon1 = 7.4446
-alt1 = 0
+index=0
+
+lat1 = LATITUDE[index]
+lon1 = LONGITUDE[index]
+alt1 = ALTITUDE[index]
time.sleep(2)
@@ -147,7 +192,7 @@ MapViewerControl_interface.SetFollowCarMode( \
dbus.UInt32(mapviewerhandle), \
dbus.Boolean(False))
-print 'Set center in Bern(' + str(lat1) + ',' + str(lon1) + ')'
+print 'Set center in '+ CITY_STRING[index]+ ' (' + str(lat1) + ',' + str(lon1) + ')'
MapViewerControl_interface.SetTargetPoint( \
dbus.UInt32(sessionhandle), \
dbus.UInt32(mapviewerhandle), \
@@ -163,13 +208,13 @@ alt2 = targetPoint[2]
print 'Get center -> (' + str(lat2) + ',' + str(lon2) + ')'
-if round(lat1,4) != round(lat2,4) :
+if round(float(lat1),4) != round(float(lat2),4) :
print '\nTest Failed:' + str(round(lat1,4)) + '!=' + str(round(lat2,4)) + '\n'
-if round(lon1,4) != round(lon2,4) :
+if round(float(lon1),4) != round(float(lon2),4) :
print '\nTest Failed:' + str(round(lon1,4)) + '!=' + str(round(lon2,4)) + '\n'
-if round(alt1,4) != round(alt2,4) :
+if round(float(alt1),4) != round(float(alt2),4) :
print '\nTest Failed:' + str(round(alt1,4)) + '!=' + str(round(alt2,4)) + '\n'
ret=MapViewerControl_interface.GetMapViewScale(dbus.UInt32(mapviewerhandle))
diff --git a/test/poi-service/test-poi.py b/test/poi-service/test-poi.py
new file mode 100755
index 0000000..53e50c3
--- /dev/null
+++ b/test/poi-service/test-poi.py
@@ -0,0 +1,177 @@
+#!/usr/bin/python
+
+"""
+**************************************************************************
+* @licence app begin@
+* SPDX-License-Identifier: MPL-2.0
+*
+* \copyright Copyright (C) 2016, PSA GROUP
+*
+* \file test-poi.py
+*
+* \brief This simple test shows how the poi search
+* could be easily tested using a python script
+*
+* \author Philippe Colliot <philippe.colliot@mpsa.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:
+*
+* @licence end@
+**************************************************************************
+"""
+
+import dbus
+import gobject
+import dbus.mainloop.glib
+import time
+
+import pdb;
+#pdb.set_trace()
+#from dltTrigger import *
+
+#name of the test
+test_name = "poi search"
+
+#constants as defined in the Navigation API
+GENIVI_Configuration_Settings_LOCALE = 37
+GENIVI_SearchStatusState_FINISHED = 512
+GENIVI_SearchStatusState_NOT_STARTED = 510
+
+#constants used into the script
+TIME_OUT = 10000
+LATITUDE_PARIS = 48.8578
+LONGITUDE_PARIS = 2.3380
+ALTITUDE_PARIS = 30.0
+ID_HOTEL = 2
+ID_STATION = 6
+ATTRIBUTE_SOURCE = 0
+ATTRIBUTE_PHONE = 2
+RADIUS_HOTEL = 100 #in tenth of meter !
+RADIUS_STATION = 500
+STRING_TO_SEARCH = "Saint-Germain"
+
+def catch_poi_configurationChanged_signal_handler(changedSettings):
+ for changedSetting in changedSettings:
+ if changedSetting == GENIVI_Configuration_Settings_LOCALE:
+ ret=g_poiConfiguration_interface.GetLocale()
+ print("language: " + ret[0])
+ print("country: " + ret[1])
+ print("script: " + ret[2])
+
+def catch_poi_poiStatus_signal_handler(poiSearchHandle,statusValue):
+ if poiSearchHandle == g_searchHandle:
+ if statusValue == GENIVI_SearchStatusState_FINISHED:
+ print("Search finished")
+ elif statusValue == GENIVI_SearchStatusState_NOT_STARTED:
+ g_poiSearch_interface.DeletePoiSearchHandle(poiSearchHandle)
+ print("Test PASSED")
+ exit()
+
+def catch_poi_resultListChanged_signal_handler(poiSearchHandle,resultListSize):
+ poiList=[]
+ if poiSearchHandle == g_searchHandle and resultListSize != 0:
+ ret=g_poiSearch_interface.RequestResultList(dbus.UInt32(poiSearchHandle),dbus.UInt16(0),dbus.UInt16(resultListSize),[ATTRIBUTE_SOURCE,ATTRIBUTE_PHONE])
+ if ret[0] == GENIVI_SearchStatusState_FINISHED and ret[1] >= 0:
+ print("Results: "+str(int(ret[1])))
+ for result in ret[2]:
+ poiList.append(result[0])
+ ret=g_poiSearch_interface.GetPoiDetails(poiList)
+ for resultDetail in ret:
+ if resultDetail[1][0] == ID_HOTEL:
+ print("Hotel: " +resultDetail[0][1])
+ elif resultDetail[1][0] == ID_STATION:
+ print("Station: " +resultDetail[0][1])
+ g_poiSearch_interface.CancelPoiSearch(dbus.UInt32(poiSearchHandle))
+
+#timeout
+def timeout():
+ print ('Timeout Expired')
+ print ('\nTest FAILED')
+ exit()
+
+def exit():
+# stopTrigger(test_name)
+ loop.quit()
+
+if __name__ == '__main__':
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+print("Search for hotel and station with keyword: "+ STRING_TO_SEARCH)
+
+#connect to session bus
+bus = dbus.SessionBus()
+
+bus.add_signal_receiver(catch_poi_configurationChanged_signal_handler, \
+ dbus_interface = "org.genivi.navigation.poiservice.POIConfiguration", \
+ signal_name = "ConfigurationChanged")
+
+bus.add_signal_receiver(catch_poi_poiStatus_signal_handler, \
+ dbus_interface = "org.genivi.navigation.poiservice.POISearch", \
+ signal_name = "PoiStatus")
+
+bus.add_signal_receiver(catch_poi_resultListChanged_signal_handler, \
+ dbus_interface = "org.genivi.navigation.poiservice.POISearch", \
+ signal_name = "ResultListChanged")
+
+#startTrigger(test_name)
+
+poiConfiguration = bus.get_object('org.genivi.navigation.poiservice.POIConfiguration','/org/genivi/poiservice/POIConfiguration')
+g_poiConfiguration_interface = dbus.Interface(poiConfiguration, dbus_interface='org.genivi.navigation.poiservice.POIConfiguration')
+
+poiContentAccess = bus.get_object('org.genivi.navigation.poiservice.POIContentAccess','/org/genivi/poiservice/POIContentAccess')
+g_poiContentAccess_interface = dbus.Interface(poiContentAccess, dbus_interface='org.genivi.navigation.poiservice.POIContentAccess')
+
+poiSearch = bus.get_object('org.genivi.navigation.poiservice.POISearch','/org/genivi/poiservice/POISearch')
+g_poiSearch_interface = dbus.Interface(poiSearch, dbus_interface='org.genivi.navigation.poiservice.POISearch')
+
+g_poiConfiguration_interface.SetLocale(dbus.String("fra"),dbus.String("FRA"),dbus.String("Latn"))
+
+categories=[]
+ret=g_poiSearch_interface.GetAvailableCategories()
+for categoryAndName in ret:
+ if categoryAndName[0] == ID_HOTEL or categoryAndName[0] == ID_STATION:
+ print("Category ID: " + str(int(categoryAndName[0])))
+ categories.append(categoryAndName[0])
+ print("Name: " + categoryAndName[1])
+
+attributes_hotel=[]
+attributes_station=[]
+attributesDetails=[]
+ret=g_poiSearch_interface.GetCategoriesDetails(categories)
+for results in ret:
+ if results[0][0] == ID_HOTEL:
+ for attribute in results[1]:
+ attributes_hotel.append(attribute[0])
+ attributesDetails.append(dbus.Struct([dbus.UInt32(attribute[0]),dbus.UInt32(ID_HOTEL),dbus.Int32(1280),dbus.Struct([dbus.Byte(2),dbus.String("")]),dbus.Int32(1314),dbus.Boolean(False)]))
+ elif results[0][0] == ID_STATION:
+ for attribute in results[1]:
+ attributes_station.append(attribute[0])
+ attributesDetails.append(dbus.Struct([dbus.UInt32(attribute[0]),dbus.UInt32(ID_STATION),dbus.Int32(1280),dbus.Struct([dbus.Byte(2),dbus.String("")]),dbus.Int32(1314),dbus.Boolean(False)]))
+
+ret=g_poiSearch_interface.GetRootCategory()
+
+g_searchHandle=g_poiSearch_interface.CreatePoiSearchHandle()
+print("Search handle: " + str(int(g_searchHandle)))
+
+lat = LATITUDE_PARIS
+lon = LONGITUDE_PARIS
+alt = ALTITUDE_PARIS
+
+g_poiSearch_interface.SetCenter(g_searchHandle,dbus.Struct([lat,lon,alt]))
+
+g_poiSearch_interface.SetCategories(g_searchHandle,[dbus.Struct([dbus.UInt32(ID_HOTEL),dbus.UInt32(RADIUS_HOTEL)]),dbus.Struct([dbus.UInt32(ID_STATION),dbus.UInt32(RADIUS_STATION)])])
+
+g_poiSearch_interface.SetAttributes(g_searchHandle,attributesDetails)
+
+g_poiSearch_interface.StartPoiSearch(g_searchHandle,dbus.String(STRING_TO_SEARCH),dbus.Int32(1376))
+
+
+#main loop
+gobject.timeout_add(TIME_OUT, timeout)
+loop = gobject.MainLoop()
+loop.run()