@ONLY
)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig)
+
+
+
+ADD_SUBDIRECTORY(test)
%{_includedir}/maps/maps_plugin*.h
%{_includedir}/maps/maps_*_plugin.h
%{_includedir}/maps/maps_extra_types.h
+
+
+
+
+%package test
+Summary: Test
+Group: Location/Test
+Requires: %{name} = %{version}-%{release}
+
+%description test
+Test
+
+%post test
+/sbin/ldconfig
+
+%postun test
+/sbin/ldconfig
+
+%files test
+%manifest test/capi-maps-service-test.manifest
+%defattr(-,root,root,-)
+%{_bindir}/%{name}-test
+
--- /dev/null
+SET(fw_test "${fw_name}-test")
+
+SET(dependents "capi-base-common glib-2.0")
+SET(pc_dependents "capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED ${dependents})
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_C_FLAGS "${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+aux_source_directory(. sources)
+#FOREACH(src ${sources})
+ MESSAGE("${fw_test}")
+ ADD_EXECUTABLE(${fw_test} ${sources})
+ TARGET_LINK_LIBRARIES(${fw_test} ${fw_name} ${${fw_test}_LDFLAGS})
+#ENDFOREACH()
+
+INSTALL(TARGETS ${fw_test} RUNTIME DESTINATION bin/)
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/capi-maps-service-test" exec_label="System::Privileged"/>
+ </assign>
+</manifest>
--- /dev/null
+
+#include <glib.h>
+
+#include "maps_test.h"
+#include "maps_test_search_place.h"
+#include "maps_test_search_route.h"
+#include "maps_test_geocode.h"
+#include "maps_test_util.h"
+
+
+maps_service_h maps_svc = NULL;
+maps_view_h maps_view = NULL;
+maps_test_state_type maps_test_state = MAPS_TEST_STATE_MAIN;
+maps_preference_h maps_pref = NULL;
+
+
+#define PROVIDER_NAME_LEN 512
+#define PROVIDER_KEY_LEN 1024
+
+char g_provider_name[PROVIDER_NAME_LEN+1] = "";
+char g_provider_key[PROVIDER_KEY_LEN+1] = "";
+
+
+static int scanf_safety(const char *format, ...)
+{
+ char line[256];
+ if (fgets(line, sizeof(line), stdin) == NULL)
+ return -1;
+
+ va_list args;
+ va_start(args, format);
+ int ret = vsscanf(line, format, args);
+ va_end(args);
+
+ return ret;
+}
+
+int maps_test_set_configuration()
+{
+ printf("Input provider name. [%s] : ", g_provider_name);
+ scanf_safety("%s", &g_provider_name);
+
+ printf("Input provider key. [%s] : ", g_provider_key);
+ scanf_safety("%s", &g_provider_key);
+
+ return 0;
+}
+
+int maps_test_create_maps_service()
+{
+ if (maps_svc)
+ return MAPS_ERROR_INVALID_OPERATION;
+ int ret = maps_service_create_without_user_consent(g_provider_name, &maps_svc);
+ if (ret == MAPS_ERROR_NONE) {
+ maps_service_set_user_consent(maps_svc, true);
+ ret = maps_service_set_provider_key(maps_svc, g_provider_key);
+ }
+ print_result(ret);
+ return ret;
+}
+
+int maps_test_destroy_maps_service()
+{
+ int ret = maps_service_destroy(maps_svc);
+ maps_svc = NULL;
+ print_result(ret);
+ return ret;
+}
+
+static bool __maps_service_provider_info_cb(char *maps_provider, void *user_data)
+{
+ int *number = (int*)user_data;
+ printf("%d : %s\n", ++*number, maps_provider);
+ return true;
+}
+
+int maps_test_show_list_of_providers()
+{
+ int number = 0;
+ return maps_service_foreach_provider(__maps_service_provider_info_cb, &number);
+}
+
+void print_menu()
+{
+ printf("========================================\n");
+ printf(" Maps Native API Tester\n");
+ printf("----------------------------------------\n");
+ printf(" a\t - Show list of Providers\n");
+ printf(" b\t - Set configuration\n");
+ printf(" c\t - Create Maps service\n");
+ printf(" d\t - Destroy Maps service\n");
+ printf("----------------------------------------\n");
+ printf(" 1\t - Search Place\n");
+ printf(" 2\t - Search Place By Address\n");
+ printf(" 3\t - Search Place By Area\n");
+ printf(" 4\t - Search Place List\n");
+ printf(" 5\t - Geocode\n");
+ printf(" 6\t - Reverse Geocode\n");
+ printf(" 7\t - Route\n");
+ printf("----------------------------------------\n");
+ printf(" x\t - Exit\n");
+ printf("========================================\n");
+}
+
+int maps_test_startup()
+{
+ print_menu();
+ return 0;
+}
+
+int maps_test_finish()
+{
+ int ret = maps_test_destroy_maps_service();
+ return ret;
+}
+
+bool run_command(char cmd)
+{
+ int ret = 0;
+ switch ((int)maps_test_state) {
+ case MAPS_TEST_STATE_MAIN:
+ switch (cmd) {
+ case 'a': ret = maps_test_show_list_of_providers(); break;
+ case 'b': ret = maps_test_set_configuration(); break;
+ case 'c': ret = maps_test_create_maps_service(); break;
+ case 'd': ret = maps_test_destroy_maps_service(); break;
+
+ case '1': ret = maps_test_search_place(maps_svc); break;
+ case '2': ret = maps_test_search_place_by_address(maps_svc); break;
+ case '3': ret = maps_test_search_place_by_area(maps_svc); break;
+ case '4': ret = maps_test_search_place_list(maps_svc); break;
+ case '5': ret = maps_test_geocode(maps_svc); break;
+ case '6': ret = maps_test_reverse_geocode(maps_svc); break;
+ case '7': ret = maps_test_search_route(maps_svc); break;
+
+ case 'x': return false;
+ case '\0': print_menu(); break;
+ default: printf("Unknown command\n"); break;
+ }
+ break;
+ }
+ if (ret != 0)
+ printf("Error = 0x%X\n", ret);
+
+ return true;
+}
+
+void *test_thread(void *data)
+{
+ maps_test_startup();
+
+ while (1) {
+ char input[256] = "";
+ scanf_safety("%s", &input);
+ if (run_command(input[0]) == false)
+ break;
+ };
+
+ maps_test_finish();
+ exit(0);
+ return NULL;
+}
+
+
+int main(int argc, char **argv)
+{
+ GMainLoop *mainloop;
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_thread_new("capi-maps-service-test", &test_thread, NULL);
+ g_main_loop_run(mainloop);
+
+ return 0;
+}
--- /dev/null
+#ifndef MAPS_TEST_H
+#define MAPS_TEST_H
+
+
+#include <maps_service.h>
+#include <maps_service_internal.h>
+
+
+typedef enum {
+ MAPS_TEST_STATE_MAIN,
+ MAPS_TEST_STATE_CONFIG,
+ MAPS_TEST_STATE_AUTOTEST,
+ MAPS_TEST_STATE_MANUALTEST,
+} maps_test_state_type;
+
+typedef enum {
+ MAPS_TEST_SUBSTATE_AUTO_SEARCH_PLACE,
+ MAPS_TEST_SUBSTATE_AUTO_SEARCH_PLACE_BY_ADDRESS,
+} maps_test_substate_type;
+
+typedef struct {
+ char *strval;
+ int intval;
+ double dblval;
+ long longval;
+} logval_type;
+
+extern maps_service_h maps_svc;
+extern maps_preference_h maps_pref;
+
+
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+
+#undef LOG_TAG
+#define LOG_TAG "MST_SERVICE"
+#define LOGD(fmt, args...) printf("%s(%d) "fmt"\n", __FUNCTION__, __LINE__, ##args)
+#define LOGE(fmt, args...) printf("%s(%d) "fmt"\n", __FUNCTION__, __LINE__, ##args)
+#define ENTER_FUNC printf("ENTER FUNC : %s (%d)\n", __FUNCTION__, __LINE__);
+#define EXIT_FUNC printf("EXIT FUNC : %s (%d)\n", __FUNCTION__, __LINE__);
+
+
+#define SEL_STR(name, str) (name && *name ? name : str)
+
+
+
+#define LOG_PREFIX " "
+
+#define LOG_VARIABLES() \
+ logval_type lv; lv.strval = NULL; lv.intval = 0; lv.dblval = 0; lv.longval = 0;
+
+#define LOG_START_TITLE(fmt, args...) {\
+ printf("\n"); \
+ printf("================================================================================\n"); \
+ printf(fmt"\n", ##args); \
+ printf("--------------------------------------------------------------------------------\n"); \
+}
+
+#define LOG_START(fmt, args...) \
+ if (fmt && *fmt && strlen(fmt) > 0) printf(fmt"\n", ##args);
+
+#define LOG_PRINT(fmt, args...) { \
+ if (fmt && *fmt) printf(fmt"\n", ##args); \
+ if (lv.strval) { free(lv.strval); lv.strval = NULL; } \
+ lv.intval = 0; lv.dblval = 0.; lv.longval = 0; }
+
+#define LOG_FINISH(fmt, args...) \
+ if (fmt && *fmt) printf(fmt"\n", ##args); \
+ if (lv.strval) { free(lv.strval); lv.strval = NULL; } \
+ lv.intval = 0; lv.dblval = 0.; lv.longval = 0;
+
+#endif /*MAPS_TEST_H*/
--- /dev/null
+#include "maps_test.h"
+#include "maps_test_geocode.h"
+#include "maps_test_log.h"
+#include "maps_test_util.h"
+
+
+static void startup()
+{
+}
+
+static void cleanup(bool result)
+{
+ print_result(result);
+}
+
+
+/*
+ *
+ * callback functions for APIs
+ *
+ */
+
+static bool __maps_test_geocode_cb(maps_error_e error, int request_id,
+ int index, int total, maps_coordinates_h coord, void *user_data)
+{
+ LOG_VARIABLES();
+ LOG_START_TITLE("%s [%d/%d] ", (user_data ? (char*)user_data : __FUNCTION__), MIN(index+1, total), total);
+
+ if (error) {
+ LOGD("error=%d", error);
+ cleanup(false);
+ return false;
+ }
+
+ log_coordinates("", "Geocoding", coord);
+ maps_coordinates_destroy(coord);
+ LOG_FINISH("");
+
+ if (index == total - 1)
+ cleanup(true);
+ return true;
+}
+
+int maps_test_geocode(maps_service_h maps_svc)
+{
+ startup();
+ int request_id = 0, error;
+
+ error = maps_service_geocode(maps_svc, "Berlin", maps_pref, __maps_test_geocode_cb, "Geocoding with Berlin", &request_id);
+
+ if (error != MAPS_ERROR_NONE)
+ cleanup(false);
+ return error;
+}
+
+static void __maps_test_reverse_geocode_cb(maps_error_e error, int request_id,
+ int index, int total, maps_address_h address, void *user_data)
+{
+ LOG_VARIABLES();
+ LOG_START_TITLE("%s [%d/%d] ", (user_data ? (char*)user_data : __FUNCTION__), MIN(index+1, total), total);
+
+ if (error) {
+ LOGD("error=%d", error);
+ cleanup(false);
+ return;
+ }
+
+ log_address("", address);
+ maps_address_destroy(address);
+ LOG_FINISH("");
+
+ if (index == total - 1)
+ cleanup(true);
+}
+
+int maps_test_reverse_geocode(maps_service_h maps_svc)
+{
+ startup();
+ int request_id = 0, error;
+
+ error = maps_service_reverse_geocode(maps_svc, 12.944594, 77.554303, maps_pref,
+ __maps_test_reverse_geocode_cb, "Reverse-geocoding with [12.944594, 77.554303]", &request_id);
+
+ if (error != MAPS_ERROR_NONE)
+ cleanup(false);
+ return error;
+}
+
--- /dev/null
+#ifndef __MAPS_TEST_GEOCODE_H__
+#define __MAPS_TEST_GEOCODE_H__
+
+int maps_test_geocode(maps_service_h maps_svc);
+int maps_test_reverse_geocode(maps_service_h maps_svc);
+
+#endif /*__MAPS_TEST_GEOCODE_H__*/
--- /dev/null
+#include "maps_test_log.h"
+#include "maps_test.h"
+
+
+/*
+ *
+ * log printer functions
+ *
+ */
+
+void log_address(char *prefix, maps_address_h address)
+{
+ if (!address) return;
+ LOG_VARIABLES();
+ LOG_START("%saddress = {", prefix);
+
+ if (maps_address_get_building_number(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sbuilding_number = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_street(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sstreet = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_district(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sdistrict = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_city(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%scity = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_state(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sstate = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_country(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%scountry = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_country_code(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%scountry_code = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_county(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%scounty = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_postal_code(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%spostal_code = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_address_get_freetext(address, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sfreetext = %s", prefix, LOG_PREFIX, lv.strval);
+
+ LOG_FINISH("%s}", prefix);
+}
+
+void log_area(char *prefix, maps_area_h area)
+{
+ if (!area) return;
+ LOG_VARIABLES();
+ LOG_START("%saddress = {", prefix);
+
+ maps_area_s *_area = (maps_area_s*)area;
+ if (_area->type == MAPS_AREA_RECTANGLE) {
+ double lat1, lng1, lat2, lng2;
+ maps_coordinates_get_latitude(&_area->rect.top_left, &lat1);
+ maps_coordinates_get_longitude(&_area->rect.top_left, &lng1);
+ maps_coordinates_get_latitude(&_area->rect.bottom_right, &lat2);
+ maps_coordinates_get_longitude(&_area->rect.bottom_right, &lng2);
+ LOG_PRINT("%s%sarea box : %f, %f, %f, %f", prefix, LOG_PREFIX, lat1, lng1, lat2, lng2);
+ } else if (_area->type == MAPS_AREA_CIRCLE) {
+ double lat, lng, radius;
+ maps_coordinates_get_latitude(&_area->circle.center, &lat);
+ maps_coordinates_get_longitude(&_area->circle.center, &lng);
+ maps_coordinates_get_latitude(&_area->circle.radius, &radius);
+ LOG_PRINT("%s%sarea circle : %f, %f, r = %f", prefix, LOG_PREFIX, lat, lng, radius);
+ } else {
+ LOG_PRINT("%sarea unknown", prefix);
+ }
+
+ LOG_FINISH("%s}", prefix);
+}
+
+void log_coordinates(char *prefix, char *title, maps_coordinates_h position)
+{
+ if (!position) return;
+ LOG_VARIABLES();
+ LOG_START("");
+
+ double lat, lng;
+ maps_coordinates_get_latitude(position, &lat);
+ maps_coordinates_get_longitude(position, &lng);
+ LOG_PRINT("%s%s = %f, %f", prefix, SEL_STR(title, "position"), lat, lng);
+ LOG_FINISH("");
+}
+
+void log_place_link_object(char *prefix, char *title, maps_place_link_object_h link)
+{
+ if (!link) return;
+ LOG_VARIABLES();
+ LOG_START("%s%s = {", prefix, title);
+
+ if (maps_place_link_object_get_id(link, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sid = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_place_link_object_get_name(link, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sname = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_place_link_object_get_string(link, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sstring = %s", prefix, LOG_PREFIX, lv.strval);
+
+ if (maps_place_link_object_get_type(link, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%stype = %s", prefix, LOG_PREFIX, lv.strval);
+
+ LOG_FINISH("%s}", prefix);
+}
+
+void log_place_media(char *prefix, maps_place_media_h media)
+{
+ if (!media) return;
+ LOG_VARIABLES();
+ LOG_START("%smedia object = {", prefix);
+
+ if (maps_place_media_get_attribution(media, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sattribution = %s", prefix, LOG_PREFIX, lv.strval);
+
+ char _prefix[100];
+ sprintf(_prefix, "%s%s", prefix, LOG_PREFIX);
+
+ maps_place_link_object_h supplier = NULL;
+ if (maps_place_media_get_supplier(media, &supplier) == MAPS_ERROR_NONE) {
+ log_place_link_object(_prefix, "supplier", supplier);
+ maps_place_link_object_destroy(supplier);
+ }
+
+ maps_place_link_object_h via = NULL;
+ if (maps_place_media_get_via(media, &via) == MAPS_ERROR_NONE) {
+ log_place_link_object(_prefix, "via", via);
+ maps_place_link_object_destroy(via);
+ }
+
+ LOG_FINISH("%s}", prefix);
+}
+
+void log_place_rating(char *prefix, maps_place_rating_h rating)
+{
+ if (!rating) return;
+ LOG_VARIABLES();
+ LOG_START("%srating = {", prefix);
+
+ maps_place_rating_get_count(rating, &lv.intval);
+ LOG_PRINT("%s%scount = %d", prefix, LOG_PREFIX, lv.intval);
+
+ maps_place_rating_get_average(rating, &lv.dblval);
+ LOG_PRINT("%s%saverage = %.2f", prefix, LOG_PREFIX, lv.dblval);
+
+ LOG_FINISH("%s}", prefix);
+}
--- /dev/null
+#ifndef __MST_SERVICE_LOG_H__
+#define __MST_SERVICE_LOG_H__
+
+#include <maps_service.h>
+
+
+
+void log_address(char *prefix, maps_address_h address);
+void log_area(char *prefix, maps_area_h area);
+void log_coordinates(char *prefix, char *title, maps_coordinates_h position);
+
+void log_place_rating(char *prefix, maps_place_rating_h rating);
+void log_place_link_object(char *prefix, char *title, maps_place_link_object_h link);
+void log_place_media(char *prefix, maps_place_media_h media);
+
+
+
+#endif /*__MST_SERVICE_LOG_H__*/
--- /dev/null
+#include "maps_test.h"
+#include "maps_test_search_place.h"
+#include "maps_test_log.h"
+#include "maps_test_util.h"
+
+static maps_place_filter_h maps_place_filter = NULL;
+static int ref_cnt = 0;
+static int unlimited_cnt = 0;
+
+static void startup()
+{
+ unlimited_cnt = 0;
+ if (ref_cnt++) return;
+
+ if (maps_place_filter) return;
+ maps_preference_set_max_results(maps_pref, 5);
+ maps_preference_set_language(maps_pref, "ko-KR");
+ maps_place_filter_create(&maps_place_filter);
+}
+
+static void cleanup(bool result)
+{
+ print_result(result);
+
+ unlimited_cnt = 0;
+ if (--ref_cnt > 0) return;
+
+ if (!maps_place_filter) return;
+ maps_place_filter_destroy(maps_place_filter);
+ maps_place_filter = NULL;
+}
+
+
+
+
+
+/*
+ *
+ * callback functions for APIs
+ *
+ */
+
+static bool __maps_place_attribute_cb(int index, int total, maps_place_attribute_h attribute, void *user_data)
+{
+ if (!attribute) return false;
+
+ LOG_VARIABLES();
+ LOG_START("attributes [%d/%d] = {", MIN(index+1, total), total);
+
+ if (maps_place_attribute_get_id(attribute, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sid = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_attribute_get_label(attribute, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%slabel = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_attribute_get_text(attribute, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%stext = %s", LOG_PREFIX, lv.strval);
+
+ maps_place_attribute_destroy(attribute);
+
+ LOG_FINISH("}");
+ return true;
+}
+
+static bool __maps_place_categories_cb(int index, int total, maps_place_category_h category, void *user_data)
+{
+ if (!category) return false;
+ LOG_VARIABLES();
+ LOG_START("categories [%d/%d] = {", MIN(index+1, total), total);
+
+ if (maps_place_category_get_name(category, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sname = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_category_get_id(category, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sid = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_category_get_url(category, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%surl = %s", LOG_PREFIX, lv.strval);
+
+ maps_place_category_destroy(category);
+
+ LOG_FINISH("}");
+ return true;
+}
+
+static bool __maps_place_contacts_cb(int index, int total, maps_place_contact_h contact, void *user_data)
+{
+ if (!contact) return false;
+ LOG_VARIABLES();
+ LOG_START("contacts [%d/%d] = {", MIN(index+1, total), total);
+
+ if (maps_place_contact_get_label(contact, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%slabel = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_contact_get_type(contact, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%stype = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_contact_get_value(contact, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%svalue = %s", LOG_PREFIX, lv.strval);
+
+ maps_place_contact_destroy(contact);
+
+ LOG_FINISH("}");
+ return true;
+}
+
+static bool __maps_place_editorials_cb(int index, int total, maps_place_editorial_h editorial, void *user_data)
+{
+ if (!editorial) return false;
+ LOG_VARIABLES();
+ LOG_START("editorial [%d/%d] = {", MIN(index+1, total), total);
+
+ if (maps_place_editorial_get_description(editorial, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sdescription = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_editorial_get_language(editorial, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%slanguage = %s", LOG_PREFIX, lv.strval);
+
+ maps_place_media_h media = NULL;
+ if (maps_place_editorial_get_media(editorial, &media) == MAPS_ERROR_NONE) {
+ log_place_media(" ", media);
+ maps_place_media_destroy(media);
+ }
+
+ maps_place_editorial_destroy(editorial);
+
+ LOG_FINISH("}");
+ return true;
+}
+
+static bool __maps_place_images_cb(int index, int total, maps_place_image_h image, void *user_data)
+{
+ if (!image) return false;
+ LOG_VARIABLES();
+ LOG_START("image [%d/%d] = {", MIN(index+1, total), total);
+
+ if (maps_place_image_get_id(image, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sid = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_image_get_url(image, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%surl = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_image_get_width(image, &lv.intval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%swidth = %d", LOG_PREFIX, lv.intval);
+
+ if (maps_place_image_get_height(image, &lv.intval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sheight = %d", LOG_PREFIX, lv.intval);
+
+ maps_place_link_object_h user_link = NULL;
+ if (maps_place_image_get_user_link(image, &user_link) == MAPS_ERROR_NONE) {
+ log_place_link_object(LOG_PREFIX, "user link", user_link);
+ maps_place_link_object_destroy(user_link);
+ }
+
+ maps_place_media_h media = NULL;
+ if (maps_place_image_get_media(image, &media) == MAPS_ERROR_NONE) {
+ log_place_media(LOG_PREFIX, media);
+ maps_place_media_destroy(media);
+ }
+
+ maps_place_image_destroy(image);
+
+ LOG_FINISH("}");
+ return true;
+}
+
+static bool __maps_place_properties_cb(int index, int total, char* key, void* value, void* user_data)
+{
+ LOG_VARIABLES();
+ LOG_START("properties [%d/%d] %s = %s", MIN(index+1, total), total, (char*)key, (char*)value);
+ LOG_FINISH("");
+ return true;
+}
+
+static bool __maps_place_reviews_cb(int index, int total, maps_place_review_h review, void *user_data)
+{
+ if (!review) return false;
+ LOG_VARIABLES();
+ LOG_START("review [%d/%d] {", MIN(index+1, total), total);
+
+ if (maps_place_review_get_date(review, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sdate = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_review_get_title(review, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%stitle = %s", LOG_PREFIX, lv.strval);
+
+ if (maps_place_review_get_rating(review, &lv.dblval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%srating = %.2f", LOG_PREFIX, lv.dblval);
+
+ if (maps_place_review_get_description(review, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sdescription = %s", LOG_PREFIX, lv.strval);
+
+ maps_place_media_h media = NULL;
+ if (maps_place_review_get_media(review, &media) == MAPS_ERROR_NONE) {
+ log_place_media(LOG_PREFIX, media);
+ maps_place_media_destroy(media);
+ }
+
+ maps_place_link_object_h user_link = NULL;
+ if (maps_place_review_get_user_link(review, &user_link) == MAPS_ERROR_NONE) {
+ log_place_link_object(LOG_PREFIX, "user link", user_link);
+ maps_place_link_object_destroy(user_link);
+ }
+
+ maps_place_review_destroy(review);
+
+ LOG_FINISH("}");
+ return true;
+}
+
+static bool __log_place(char *prefix, maps_place_h place)
+{
+ LOG_VARIABLES();
+ LOG_START("");
+
+ if (maps_place_get_id(place, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sid = %s", prefix, lv.strval);
+
+ if (maps_place_get_name(place, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%sname = %s", prefix, lv.strval);
+
+ if (maps_place_get_uri(place, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%suri = %s", prefix, lv.strval);
+
+ maps_coordinates_h coord = NULL;
+ if (maps_place_get_location(place, &coord) == MAPS_ERROR_NONE) {
+ double lat, lng;
+ maps_coordinates_get_latitude(coord, &lat);
+ maps_coordinates_get_longitude(coord, &lng);
+ LOG_PRINT("%slocation = %f, %f", prefix, lat, lng);
+ maps_coordinates_destroy(coord);
+ }
+
+ int distance = 0;
+ maps_distance_unit_e distance_unit;
+ if (maps_place_get_distance(place, &distance) == MAPS_ERROR_NONE) {
+ maps_preference_get_distance_unit(maps_pref, &distance_unit);
+ LOG_PRINT("%sdistance = %d %s", prefix, distance, get_distance_unit_string(distance_unit));
+ }
+
+ maps_address_h address = NULL;
+ if (maps_place_get_address(place, &address) == MAPS_ERROR_NONE) {
+ log_address(prefix, address);
+ maps_address_destroy(address);
+ }
+
+ maps_place_rating_h rating = NULL;
+ if (maps_place_get_rating(place, &rating) == MAPS_ERROR_NONE && rating) {
+ log_place_rating(prefix, rating);
+ maps_place_rating_destroy(rating);
+ }
+
+ int ret = maps_place_foreach_property(place, __maps_place_properties_cb, NULL);
+ if (ret != MAPS_ERROR_NONE && ret != MAPS_ERROR_NOT_FOUND)
+ LOG_PRINT("%sproperties : error (%d)", prefix, ret);
+
+ ret = maps_place_foreach_category(place, __maps_place_categories_cb, NULL);
+ if (ret != MAPS_ERROR_NONE && ret != MAPS_ERROR_NOT_FOUND)
+ LOG_PRINT("%scategories : error (%d)", prefix, ret);
+
+ ret = maps_place_foreach_attribute(place, __maps_place_attribute_cb, NULL);
+ if (ret != MAPS_ERROR_NONE && ret != MAPS_ERROR_NOT_FOUND)
+ LOG_PRINT("%sattributes : error (%d)", prefix, ret);
+
+ ret = maps_place_foreach_contact(place, __maps_place_contacts_cb, NULL);
+ if (ret != MAPS_ERROR_NONE && ret != MAPS_ERROR_NOT_FOUND)
+ LOG_PRINT("%scontacts : error (%d)", prefix, ret);
+
+ ret = maps_place_foreach_editorial(place, __maps_place_editorials_cb, NULL);
+ if (ret != MAPS_ERROR_NONE && ret != MAPS_ERROR_NOT_FOUND)
+ LOG_PRINT("%seditorials : error (%d)", prefix, ret);
+
+ ret = maps_place_foreach_image(place, __maps_place_images_cb, NULL);
+ if (ret != MAPS_ERROR_NONE && ret != MAPS_ERROR_NOT_FOUND)
+ LOG_PRINT("%simages : error (%d)", prefix, ret);
+
+ ret = maps_place_foreach_review(place, __maps_place_reviews_cb, NULL);
+ if (ret != MAPS_ERROR_NONE && ret != MAPS_ERROR_NOT_FOUND)
+ LOG_PRINT("%sreviews : error (%d)", prefix, ret);
+
+ LOG_FINISH("");
+ return true;
+}
+
+static bool __maps_service_search_place_cb(maps_error_e error, int request_id , int index, int total, maps_place_h place, void* user_data)
+{
+ LOG_VARIABLES();
+ LOG_START_TITLE("%s [%d/%d] ", (user_data ? (char*)user_data : __FUNCTION__), MIN(index+1, total), total);
+
+ if (error) {
+ LOG_PRINT("error=%d", error);
+ cleanup(false);
+ return false;
+ }
+
+ __log_place("", place);
+ maps_place_destroy(place);
+
+ LOG_FINISH("");
+
+ if (index == total - 1)
+ cleanup(true);
+ return true;
+}
+
+
+static bool __maps_place_cb(int index, maps_place_h place, void *user_data)
+{
+ LOG_VARIABLES();
+ LOG_START_TITLE("%s [%d] ", (user_data ? (char*)user_data : __FUNCTION__), index+1);
+
+ __log_place("", place);
+ maps_place_destroy(place);
+
+ LOG_FINISH("");
+ return true;
+}
+
+static void __maps_service_search_place_list_cb(maps_error_e error,
+ int request_id, int total, maps_place_list_h place_list, void *user_data)
+{
+ if (error) {
+ LOGD("error=%d", error);
+ cleanup(false);
+ return;
+ }
+ maps_place_list_foreach(place_list, __maps_place_cb, user_data);
+ cleanup(true);
+}
+
+
+
+
+/*
+ *
+ * query functions to use APIs
+ *
+ */
+
+int maps_test_search_place(maps_service_h maps_svc)
+{
+ startup();
+ int request_id = 0, error;
+
+ maps_coordinates_h coordinates;
+ maps_coordinates_create(48.85784, 2.29516, &coordinates);
+
+ maps_place_filter_set_place_name(maps_place_filter, "Berlin");
+ maps_preference_set_property(maps_pref, MAPS_PLACE_FILTER_SORT_BY, "distance");
+
+ error = maps_service_search_place(maps_svc, coordinates, 5, maps_place_filter, maps_pref,
+ __maps_service_search_place_cb, "Search Place", &request_id);
+
+ maps_coordinates_destroy(coordinates);
+
+ if (error != MAPS_ERROR_NONE)
+ cleanup(false);
+ return error;
+}
+
+int maps_test_search_place_by_address(maps_service_h maps_svc)
+{
+ startup();
+ int request_id = 0, error;
+
+ maps_coordinates_h top_left, bottom_right;
+ maps_area_h area;
+ maps_coordinates_create(15.665354, 74.311523, &top_left);
+ maps_coordinates_create(10.617418, 79.145508, &bottom_right);
+ maps_area_create_rectangle(top_left, bottom_right, &area);
+
+ error = maps_service_search_place_by_address(maps_svc, "Bengaluru",
+ area, maps_place_filter, maps_pref,
+ __maps_service_search_place_cb, "Search Place By Address", &request_id);
+
+ maps_coordinates_destroy(top_left);
+ maps_coordinates_destroy(bottom_right);
+ maps_area_destroy(area);
+
+ if (error != MAPS_ERROR_NONE)
+ cleanup(false);
+ return error;
+}
+
+int maps_test_search_place_by_area(maps_service_h maps_svc)
+{
+ startup();
+ int request_id = 0, error;
+
+ maps_coordinates_h top_left, bottom_right;
+ maps_area_h area;
+ maps_coordinates_create(15.665354, 74.311523, &top_left);
+ maps_coordinates_create(10.617418, 79.145508, &bottom_right);
+ maps_area_create_rectangle(top_left, bottom_right, &area);
+
+ error = maps_service_search_place_by_area(maps_svc, area, maps_place_filter, maps_pref,
+ __maps_service_search_place_cb, "Search Place By Area", &request_id);
+
+ maps_coordinates_destroy(top_left);
+ maps_coordinates_destroy(bottom_right);
+ maps_area_destroy(area);
+
+ if (error != MAPS_ERROR_NONE)
+ cleanup(false);
+ return error;
+}
+
+
+int maps_test_search_place_list(maps_service_h maps_svc)
+{
+ startup();
+ int request_id = 0, error;
+
+ maps_coordinates_h coordinates;
+ maps_area_h area;
+ maps_coordinates_create(52.5167, 13.383, &coordinates);
+ maps_area_create_circle(coordinates, 5000, &area);
+
+ error = maps_service_search_place_list(maps_svc, area, maps_place_filter, maps_pref,
+ __maps_service_search_place_list_cb, "Search Place List", &request_id);
+
+ maps_coordinates_destroy(coordinates);
+ maps_area_destroy(area);
+
+ if (error != MAPS_ERROR_NONE)
+ cleanup(false);
+ return error;
+}
--- /dev/null
+#ifndef __MAPS_TEST_SEARCH_PLACE_H__
+#define __MAPS_TEST_SEARCH_PLACE_H__
+
+int maps_test_search_place(maps_service_h maps_svc);
+
+int maps_test_search_place_by_address(maps_service_h maps_svc);
+
+int maps_test_search_place_by_area(maps_service_h maps_svc);
+
+int maps_test_search_place_list(maps_service_h maps_svc);
+
+#endif /*__MAPS_TEST_SEARCH_PLACE_H__*/
--- /dev/null
+#include "maps_test.h"
+#include "maps_test_search_route.h"
+#include "maps_test_log.h"
+#include "maps_test_util.h"
+
+
+static maps_distance_unit_e g_distance_unit = MAPS_DISTANCE_UNIT_M;
+
+static void startup()
+{
+}
+
+static void cleanup(bool result)
+{
+ print_result(result);
+}
+
+
+
+
+
+static bool __maps_route_segment_maneuver_cb(int index, int total, maps_route_maneuver_h maneuver, void *user_data)
+{
+ if (!maneuver) return false;
+
+ LOG_VARIABLES();
+ LOG_START("%smaneuver [%d/%d] = {", LOG_PREFIX, index+1, total);
+
+ if (maps_route_maneuver_get_instruction_text(maneuver, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sinstruction = %s", LOG_PREFIX, LOG_PREFIX, lv.strval);
+
+ if (maps_route_maneuver_get_distance_to_next_instruction(maneuver, &lv.dblval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sdistance = %.2f %s", LOG_PREFIX, LOG_PREFIX, lv.dblval, get_distance_unit_string(g_distance_unit));
+
+ if (maps_route_maneuver_get_time_to_next_instruction(maneuver, &lv.intval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%stime = %d sec", LOG_PREFIX, LOG_PREFIX, lv.intval);
+
+ if (maps_route_maneuver_get_direction_id(maneuver, (maps_route_direction_e*)&lv.intval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sdirection_id = %s (%d)", LOG_PREFIX, LOG_PREFIX, get_direction_string(lv.intval), lv.intval);
+
+ if (maps_route_maneuver_get_turn_type(maneuver, (maps_route_turn_type_e*)&lv.intval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sturn_type = %s (%d)", LOG_PREFIX, LOG_PREFIX, get_turn_type_string(lv.intval), lv.intval);
+
+ maps_coordinates_h coord;
+ if (maps_route_maneuver_get_position(maneuver, &coord) == MAPS_ERROR_NONE) {
+ double lat, lng;
+ maps_coordinates_get_latitude(coord, &lat);
+ maps_coordinates_get_longitude(coord, &lng);
+ LOG_PRINT("%s%sposition = %f, %f", LOG_PREFIX, LOG_PREFIX, lat, lng);
+ maps_coordinates_destroy(coord);
+ }
+
+ if (maps_route_maneuver_get_road_name(maneuver, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%sroad_name = %s", LOG_PREFIX, LOG_PREFIX, lv.strval);
+
+ if (maps_route_maneuver_get_locale(maneuver, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("%s%slocale = %s", LOG_PREFIX, LOG_PREFIX, lv.strval);
+
+ maps_route_maneuver_destroy(maneuver);
+
+ LOG_FINISH("%s}", LOG_PREFIX);
+ return true;
+}
+
+
+static bool __maps_route_path_cb(int index, int total, maps_coordinates_h coordinates, void *user_data)
+{
+ if (!coordinates) return false;
+
+ char buffer[30] = "";
+ sprintf(buffer, "path [%d/%d]", index+1, total);
+
+ log_coordinates("", buffer, coordinates);
+ maps_coordinates_destroy(coordinates);
+ return true;
+}
+
+static bool __maps_route_segment_path_cb(int index, int total, maps_coordinates_h coordinates, void *user_data)
+{
+ if (!coordinates) return false;
+
+ char buffer[30] = "";
+ sprintf(buffer, "path [%d/%d]", index+1, total);
+
+ log_coordinates(LOG_PREFIX, buffer, coordinates);
+ maps_coordinates_destroy(coordinates);
+ return true;
+}
+
+
+static bool __maps_route_segment_cb(int index, int total, maps_route_segment_h segment, void *user_data)
+{
+ LOG_VARIABLES();
+ LOG_START("segment [%d/%d] = {", index+1, total);
+
+ double distance;
+ if (maps_route_segment_get_distance(segment, &distance) == MAPS_ERROR_NONE && distance > 0)
+ LOG_PRINT("%sdistance = %.2f %s", LOG_PREFIX, distance, get_distance_unit_string(g_distance_unit));
+
+ long duration = 0;
+ if (maps_route_segment_get_duration(segment, &duration) == MAPS_ERROR_NONE && duration > 0)
+ LOG_PRINT("%sduration = %ld sec", LOG_PREFIX, duration);
+
+ maps_coordinates_h origin;
+ if (maps_route_segment_get_origin(segment, &origin) == MAPS_ERROR_NONE) {
+ log_coordinates(LOG_PREFIX, "origin", origin);
+ maps_coordinates_destroy(origin);
+ }
+
+ maps_coordinates_h destination;
+ if (maps_route_segment_get_destination(segment, &destination) == MAPS_ERROR_NONE) {
+ log_coordinates(LOG_PREFIX, "destination", destination);
+ maps_coordinates_destroy(destination);
+ }
+
+ maps_area_h area;
+ if (maps_route_segment_get_bounding_box(segment, &area) == MAPS_ERROR_NONE) {
+ log_area(LOG_PREFIX, area);
+ maps_area_destroy(area);
+ }
+
+ maps_route_segment_foreach_maneuver(segment, __maps_route_segment_maneuver_cb, user_data);
+
+ maps_route_segment_foreach_path(segment, __maps_route_segment_path_cb, user_data);
+
+ maps_route_segment_destroy(segment);
+
+ LOG_FINISH("}");
+ return true;
+}
+
+
+static bool __log_route(maps_route_h route, void *user_data)
+{
+ LOG_VARIABLES();
+ LOG_START("");
+
+ if (maps_route_get_route_id(route, &lv.strval) == MAPS_ERROR_NONE)
+ LOG_PRINT("route_id = %s", lv.strval);
+
+ maps_coordinates_h coord;
+ double lat, lon;
+ if (maps_route_get_origin(route, &coord) == MAPS_ERROR_NONE) {
+ maps_coordinates_get_latitude_longitude(coord, &lat, &lon);
+ maps_coordinates_destroy(coord);
+ LOG_PRINT("origin = %f, %f", lat, lon);
+ }
+ if (maps_route_get_destination(route, &coord) == MAPS_ERROR_NONE) {
+ maps_coordinates_get_latitude_longitude(coord, &lat, &lon);
+ maps_coordinates_destroy(coord);
+ LOG_PRINT("destination = %f, %f", lat, lon);
+ }
+
+ if (maps_route_get_distance_unit(route, (maps_distance_unit_e*)&lv.intval) == MAPS_ERROR_NONE) {
+ g_distance_unit = lv.intval;
+ LOG_PRINT("distance_unit = '%s' (%d)", get_distance_unit_string(lv.intval), lv.intval);
+ }
+
+ if (maps_route_get_total_distance(route, &lv.dblval) == MAPS_ERROR_NONE)
+ LOG_PRINT("distance = %.2f %s", lv.dblval, get_distance_unit_string(g_distance_unit));
+
+ if (maps_route_get_total_duration(route, &lv.longval) == MAPS_ERROR_NONE)
+ LOG_PRINT("duration = %ld sec", lv.longval);
+
+ if (maps_route_get_transport_mode(route, (maps_route_transport_mode_e*)&lv.intval) == MAPS_ERROR_NONE)
+ LOG_PRINT("transport = %s", get_transport_string(lv.intval));
+
+ maps_area_h area = NULL;
+ if (maps_route_get_bounding_box(route, &area) == MAPS_ERROR_NONE) {
+ log_area("", area);
+ maps_area_destroy(area);
+ }
+
+ maps_route_foreach_path(route, __maps_route_path_cb, user_data);
+
+ maps_route_foreach_segment(route, __maps_route_segment_cb, user_data);
+
+ LOG_FINISH("");
+ return true;
+}
+
+
+/*
+ *
+ * query functions to use APIs
+ *
+ */
+static bool __maps_service_search_route_cb(maps_error_e error,
+ int request_id, int index,
+ int total, maps_route_h route,
+ void *user_data)
+{
+ LOG_VARIABLES();
+ LOG_START_TITLE("%s [%d/%d] ", (user_data ? (char*)user_data : __FUNCTION__), MIN(index+1, total), total);
+
+ if (error) {
+ cleanup(false);
+ return false;
+ }
+
+ __log_route(route, user_data);
+ maps_route_destroy(route);
+
+ LOG_FINISH("");
+
+ if (index == total - 1)
+ cleanup(true);
+ return true;
+}
+
+
+int maps_test_search_route(maps_service_h maps_svc)
+{
+ startup();
+ int request_id, error;
+
+ maps_coordinates_h origin = NULL, dest = NULL;
+ maps_coordinates_create(52.525324, 13.369911, &origin);
+ maps_coordinates_create(52.469051, 13.441912, &dest);
+
+ error = maps_service_search_route(maps_svc, origin, dest, maps_pref,
+ __maps_service_search_route_cb, "Search Route", &request_id);
+
+ maps_coordinates_destroy(origin);
+ maps_coordinates_destroy(dest);
+
+ if (error != MAPS_ERROR_NONE)
+ cleanup(false);
+ return error;
+}
+
--- /dev/null
+#ifndef __MAPS_TEST_SEARCH_ROUTE_H__
+#define __MAPS_TEST_SEARCH_ROUTE_H__
+
+int maps_test_search_route(maps_service_h maps_svc);
+
+#endif /*__MAPS_TEST_SEARCH_ROUTE_H__*/
--- /dev/null
+#include "maps_test_util.h"
+#include <maps_service.h>
+
+const char* get_direction_string(maps_route_direction_e direction)
+{
+ const char *direction_string[] = { "None", "North", "Northwest", "Northeast", "South", "Southwest", "Southeast", "West", "East", "Unknown" };
+ if (direction < MAPS_ROUTE_DIRECTION_NONE || direction > MAPS_ROUTE_DIRECTION_EAST)
+ direction = MAPS_ROUTE_DIRECTION_EAST + 1;
+ return direction_string[direction];
+}
+
+const char* get_turn_type_string(maps_route_turn_type_e turn_type)
+{
+ const char *turn_type_string[] = { "None", "Straight", "Bear Right", "Light Right", "Right", "Hard Right", "U-Turn Right", "U-Turn Left",
+ "Hard Left", "Left", "Light Left", "Bear Left", "Right Fork", "Left Fork", "Straight Fork", "Unknown" };
+ if (turn_type < MAPS_ROUTE_TURN_TYPE_NONE || turn_type > MAPS_ROUTE_TURN_TYPE_STRAIGHT_FORK)
+ turn_type = MAPS_ROUTE_TURN_TYPE_STRAIGHT_FORK + 1;
+ return turn_type_string[turn_type];
+}
+
+const char* get_transport_string(maps_route_transport_mode_e transport)
+{
+ const char *transport_string[] = { "Car", "Pedestrian", "Bicycle", "Public Transit", "Truck", "Unknown" };
+ if (transport < MAPS_ROUTE_TRANSPORT_MODE_CAR || transport > MAPS_ROUTE_TRANSPORT_MODE_TRUCK)
+ transport = MAPS_ROUTE_TRANSPORT_MODE_TRUCK + 1;
+ return transport_string[transport];
+}
+
+const char* get_distance_unit_string(maps_distance_unit_e distance_unit)
+{
+ const char *distance_unit_string[] = { "m", "km", "ft", "yd", "Unknown" };
+ if (distance_unit < MAPS_DISTANCE_UNIT_M || distance_unit > MAPS_DISTANCE_UNIT_YD)
+ distance_unit = MAPS_DISTANCE_UNIT_YD + 1;
+ return distance_unit_string[distance_unit];
+}
+
+void print_result(int result)
+{
+ if (result == MAPS_ERROR_NONE)
+ printf("Ok\n");
+ else
+ printf("Fail\n");
+}
--- /dev/null
+#ifndef __MAPS_TEST_UTIL_H__
+#define __MAPS_TEST_UTIL_H__
+
+#include <maps_route.h>
+
+const char* get_direction_string(maps_route_direction_e direction);
+const char* get_turn_type_string(maps_route_turn_type_e turn_type);
+const char* get_transport_string(maps_route_transport_mode_e transport);
+const char* get_distance_unit_string(maps_distance_unit_e distance_unit);
+
+void print_result(int result);
+
+#endif /*__MAPS_TEST_UTIL_H__*/