summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasanoaozora <fifitaneki@hotmail.com>2016-08-22 18:26:14 +0200
committerasanoaozora <fifitaneki@hotmail.com>2016-08-22 18:26:14 +0200
commit9207b98e3d20750c64e57fea0b5e56c2659e593f (patch)
treedf2faf5914f2bc82ae33d7cfcdea7c42d2c33ff6
parent2cb3270bbf19649ddb1b5dad764ca4b8e25708ec (diff)
downloadpoi-service-9207b98e3d20750c64e57fea0b5e56c2659e593f.tar.gz
add test file for poi search (common api version)
-rw-r--r--api/franca/navigation/poiservice/POIServiceTypes.fidl2
-rw-r--r--src/navigation/map-viewer/configuration-server-plugin/genivi_mapviewer_configuration.cxx20
-rw-r--r--src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx20
-rw-r--r--src/poi-service/poi-server-capi/main.cpp22
-rwxr-xr-xtest/navigation/test-poi-capi.py166
5 files changed, 225 insertions, 5 deletions
diff --git a/api/franca/navigation/poiservice/POIServiceTypes.fidl b/api/franca/navigation/poiservice/POIServiceTypes.fidl
index 1dca5c3..e54432b 100644
--- a/api/franca/navigation/poiservice/POIServiceTypes.fidl
+++ b/api/franca/navigation/poiservice/POIServiceTypes.fidl
@@ -286,7 +286,7 @@ typeCollection POIServiceTypes {
}
- <** @description: used in setAttrbutes and CAM startPOISearch**>
+ <** @description: used in setAttributes and CAM startPOISearch**>
struct AttributeDetails
{
<** @description : id of attribute .**>
diff --git a/src/navigation/map-viewer/configuration-server-plugin/genivi_mapviewer_configuration.cxx b/src/navigation/map-viewer/configuration-server-plugin/genivi_mapviewer_configuration.cxx
index 7e34b39..7665f13 100644
--- a/src/navigation/map-viewer/configuration-server-plugin/genivi_mapviewer_configuration.cxx
+++ b/src/navigation/map-viewer/configuration-server-plugin/genivi_mapviewer_configuration.cxx
@@ -159,8 +159,8 @@ void MapViewerConfigurationServerStub::setLocale(const std::shared_ptr<CommonAPI
m_scriptCode = _scriptCode;
changedSettings.push_back(Configuration::Settings::LOCALE);
-
fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void MapViewerConfigurationServerStub::getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply)
@@ -175,7 +175,13 @@ void MapViewerConfigurationServerStub::getSupportedLocales(const std::shared_ptr
void MapViewerConfigurationServerStub::setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply)
{
+ std::vector<Configuration::Settings> changedSettings;
+
m_timeFormat = _format;
+
+ changedSettings.push_back(Configuration::Settings::TIME_FORMAT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void MapViewerConfigurationServerStub::getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply)
@@ -190,7 +196,13 @@ void MapViewerConfigurationServerStub::getSupportedTimeFormats(const std::shared
void MapViewerConfigurationServerStub::setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply)
{
+ std::vector<Configuration::Settings> changedSettings;
+
m_coordinatesFormat = _coordinatesFormat;
+
+ changedSettings.push_back(Configuration::Settings::COORDINATES_FORMAT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void MapViewerConfigurationServerStub::getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply)
@@ -205,7 +217,13 @@ void MapViewerConfigurationServerStub::getSupportedCoordinatesFormat(const std::
void MapViewerConfigurationServerStub::setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply)
{
+ std::vector<Configuration::Settings> changedSettings;
+
m_unitsOfMeasurement = _unitsOfMeasurementList;
+
+ changedSettings.push_back(Configuration::Settings::UNITS_OF_MEASUREMENT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void MapViewerConfigurationServerStub::getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply)
diff --git a/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx b/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx
index 88c15de..76b5aa3 100644
--- a/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx
+++ b/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx
@@ -168,8 +168,8 @@ void NavigationCoreConfigurationServerStub::setLocale(const std::shared_ptr<Comm
m_scriptCode = _scriptCode;
changedSettings.push_back(Configuration::Settings::LOCALE);
-
fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void NavigationCoreConfigurationServerStub::getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply)
@@ -184,7 +184,13 @@ void NavigationCoreConfigurationServerStub::getSupportedLocales(const std::share
void NavigationCoreConfigurationServerStub::setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply)
{
+ std::vector<Configuration::Settings> changedSettings;
+
m_timeFormat = _format;
+
+ changedSettings.push_back(Configuration::Settings::TIME_FORMAT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void NavigationCoreConfigurationServerStub::getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply)
@@ -199,7 +205,13 @@ void NavigationCoreConfigurationServerStub::getSupportedTimeFormats(const std::s
void NavigationCoreConfigurationServerStub::setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply)
{
+ std::vector<Configuration::Settings> changedSettings;
+
m_coordinatesFormat = _coordinatesFormat;
+
+ changedSettings.push_back(Configuration::Settings::COORDINATES_FORMAT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void NavigationCoreConfigurationServerStub::getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply)
@@ -214,7 +226,13 @@ void NavigationCoreConfigurationServerStub::getSupportedCoordinatesFormat(const
void NavigationCoreConfigurationServerStub::setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply)
{
+ std::vector<Configuration::Settings> changedSettings;
+
m_unitsOfMeasurement = _unitsOfMeasurementList;
+
+ changedSettings.push_back(Configuration::Settings::UNITS_OF_MEASUREMENT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void NavigationCoreConfigurationServerStub::getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply)
diff --git a/src/poi-service/poi-server-capi/main.cpp b/src/poi-service/poi-server-capi/main.cpp
index 5ef7306..1f9756e 100644
--- a/src/poi-service/poi-server-capi/main.cpp
+++ b/src/poi-service/poi-server-capi/main.cpp
@@ -1402,6 +1402,7 @@ void POISearchServerStub::getCategoriesDetails(const std::shared_ptr<CommonAPI::
categoryAttribute.setId((m_availableCategoryTable[category_index].attributeList.at(sub_index)).id);
categoryAttribute.setName((m_availableCategoryTable[category_index].attributeList.at(sub_index)).name);
categoryAttribute.setType(POIServiceTypes::AttributeType::BOOLEAN);
+ operatorList.clear();
categoryOperator.setType(POIServiceTypes::OperatorType::EQUAL);
categoryOperator.setName("EQUAL"); //redondancy
categoryOperator.setValue(std::string(""));
@@ -1684,7 +1685,6 @@ void POISearchServerStub::cancelPoiSearch(const std::shared_ptr<CommonAPI::Clien
_reply();
}
-
void POISearchServerStub::startPoiProximityAlert(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _poiSearchHandle, std::string _inputString, ::v4::org::genivi::navigation::poiservice::POIServiceTypes::SortOption _sortOption, startPoiProximityAlertReply_t _reply)
{
if ((m_poiSearchHandle == INVALID_HANDLE) || (_poiSearchHandle != m_poiSearchHandle))
@@ -2428,8 +2428,8 @@ void POIConfigurationServerStub::setLocale(const std::shared_ptr<CommonAPI::Clie
m_scriptCode = _scriptCode;
changedSettings.push_back(POIServiceTypes::Settings::LOCALE);
-
fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void POIConfigurationServerStub::getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply)
@@ -2444,7 +2444,13 @@ void POIConfigurationServerStub::getSupportedLocales(const std::shared_ptr<Commo
void POIConfigurationServerStub::setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply)
{
+ std::vector<POIServiceTypes::Settings> changedSettings;
+
m_timeFormat = _format;
+
+ changedSettings.push_back(POIServiceTypes::Settings::TIME_FORMAT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void POIConfigurationServerStub::getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply)
@@ -2459,7 +2465,13 @@ void POIConfigurationServerStub::getSupportedTimeFormats(const std::shared_ptr<C
void POIConfigurationServerStub::setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, POIConfiguration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply)
{
+ std::vector<POIServiceTypes::Settings> changedSettings;
+
m_coordinatesFormat = _coordinatesFormat;
+
+ changedSettings.push_back(POIServiceTypes::Settings::COORDINATES_FORMAT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void POIConfigurationServerStub::getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply)
@@ -2474,7 +2486,13 @@ void POIConfigurationServerStub::getSupportedCoordinatesFormat(const std::shared
void POIConfigurationServerStub::setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, POIConfiguration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply)
{
+ std::vector<POIServiceTypes::Settings> changedSettings;
+
m_unitsOfMeasurement = _unitsOfMeasurementList;
+
+ changedSettings.push_back(POIServiceTypes::Settings::UNITS_OF_MEASUREMENT);
+ fireConfigurationChangedEvent(changedSettings);
+ _reply();
}
void POIConfigurationServerStub::getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply)
diff --git a/test/navigation/test-poi-capi.py b/test/navigation/test-poi-capi.py
new file mode 100755
index 0000000..3137341
--- /dev/null
+++ b/test/navigation/test-poi-capi.py
@@ -0,0 +1,166 @@
+#!/usr/bin/python
+
+"""
+**************************************************************************
+* @licence app begin@
+* SPDX-License-Identifier: MPL-2.0
+*
+* \copyright Copyright (C) 2016, PSA GROUP
+*
+* \file test-poi-capi.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()
+#constants as defined in the Navigation API
+GENIVI_Configuration_Settings_LOCALE = 37
+GENIVI_SearchStatusState_FINISHED = 1298
+GENIVI_SearchStatusState_NOT_STARTED = 1296
+
+#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"
+
+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")
+ loop.quit()
+
+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')
+ 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")
+
+poiConfiguration = bus.get_object('org.genivi.navigation.poiservice.POIConfiguration_POIConfiguration','/POIConfiguration')
+g_poiConfiguration_interface = dbus.Interface(poiConfiguration, dbus_interface='org.genivi.navigation.poiservice.POIConfiguration')
+
+poiContentAccess = bus.get_object('org.genivi.navigation.poiservice.POIContentAccess_POIContentAccess','/POIContentAccess')
+g_poiContentAccess_interface = dbus.Interface(poiContentAccess, dbus_interface='org.genivi.navigation.poiservice.POIContentAccess')
+
+poiSearch = bus.get_object('org.genivi.navigation.poiservice.POISearch_POISearch','/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()