Update capi-maps-service-test 09/162709/3 tizen_4.0_tv accepted/tizen/4.0/unified/20171207.070731 submit/tizen_4.0/20171205.065124 tizen_4.0.IoT.p2_release
authorchanywa <cbible.kim@samsung.com>
Tue, 5 Dec 2017 04:32:13 +0000 (13:32 +0900)
committerchanywa <cbible.kim@samsung.com>
Tue, 5 Dec 2017 06:42:13 +0000 (15:42 +0900)
Change-Id: I8cf5258338d1e0d2f52c18737ee035036d240b0a

12 files changed:
test/maps_test.c
test/maps_test.h
test/maps_test_geocode.c
test/maps_test_geocode.h
test/maps_test_log.c
test/maps_test_log.h
test/maps_test_search_place.c
test/maps_test_search_place.h
test/maps_test_search_route.c
test/maps_test_search_route.h
test/maps_test_util.c
test/maps_test_util.h

index 06f19b9bf7807e3984bd1ce9b5f89e6b1026c17f..0dddcf506e9f4cdf768ad923196194b1a307ea35 100755 (executable)
@@ -7,18 +7,26 @@
 #include "maps_test_geocode.h"
 #include "maps_test_util.h"
 
+////////////////////////////////////////////////////////////
+
+#define DEFAULT_PROVIDER_NAME ""
+#define DEFAULT_PROVIDER_KEY  ""
+
+maps_test_logging_type g_logging_type = MAPS_TEST_LOGGING_CONSOLE;
+
+////////////////////////////////////////////////////////////
 
 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] = "";
+char g_provider_name[PROVIDER_NAME_LEN+1] = DEFAULT_PROVIDER_NAME;
+char g_provider_key[PROVIDER_KEY_LEN+1] = DEFAULT_PROVIDER_KEY;
+char g_buffer[128];
 
 
 static int scanf_safety(const char *format, ...)
@@ -40,10 +48,17 @@ 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);
+       bool hide_key = (strlen(DEFAULT_PROVIDER_KEY) > 0 &&
+                                       !strncmp(g_provider_key, DEFAULT_PROVIDER_KEY, strlen(DEFAULT_PROVIDER_KEY)));
+       printf("Input provider key. [%s] : ", hide_key ? "*****" : g_provider_key);
        scanf_safety("%s", &g_provider_key);
 
-       return 0;
+       printf("Input how to print log [%s] (0:Off, 1:Console, 2:SDB, 3:All): ", get_logging_type_string(g_logging_type));
+       scanf_safety("%s", &g_buffer);
+       if (strlen(g_buffer) > 0)
+               g_logging_type = atoi(g_buffer);
+
+       return MAPS_ERROR_NONE;
 }
 
 int maps_test_create_maps_service()
@@ -55,15 +70,22 @@ int maps_test_create_maps_service()
                maps_service_set_user_consent(maps_svc, true);
                ret = maps_service_set_provider_key(maps_svc, g_provider_key);
        }
-       print_result(ret == MAPS_ERROR_NONE);
+
+       if (maps_pref == NULL)
+               maps_preference_create(&maps_pref);
+       maps_preference_set_max_results(maps_pref, 5);
+       maps_preference_set_language(maps_pref, "ko-KR");
+
        return ret;
 }
 
 int maps_test_destroy_maps_service()
 {
+       maps_preference_destroy(maps_pref);
+       maps_pref = NULL;
+
        int ret = maps_service_destroy(maps_svc);
        maps_svc = NULL;
-       print_result(ret == MAPS_ERROR_NONE);
        return ret;
 }
 
@@ -82,6 +104,7 @@ int maps_test_show_list_of_providers()
 
 void print_menu()
 {
+       printf("\n\n\n");
        printf("========================================\n");
        printf(" Maps Native API Tester\n");
        printf("----------------------------------------\n");
@@ -94,9 +117,13 @@ void print_menu()
        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("  5\t - Search Place & Cancel\n");
+       printf("  6\t - Geocode\n");
+       printf("  7\t - Reverse Geocode\n");
+       printf("  8\t - Multi-reverse Geocode\n");
+       printf("  9\t - Route\n");
+       printf("----------------------------------------\n");
+       printf("  A\t - Search Place x 200\n");
        printf("----------------------------------------\n");
        printf("  x\t - Exit\n");
        printf("========================================\n");
@@ -110,37 +137,44 @@ int maps_test_startup()
 
 int maps_test_finish()
 {
-       int ret = maps_test_destroy_maps_service();
+       int ret = 0;
+       if (maps_svc) {
+               ret = maps_service_destroy(maps_svc);
+               maps_svc = NULL;
+       }
+       print_result(ret);
        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;
-               }
+
+       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, maps_pref); break;
+       case '2': ret = maps_test_search_place_by_address(maps_svc, maps_pref); break;
+       case '3': ret = maps_test_search_place_by_area(maps_svc, maps_pref); break;
+       case '4': ret = maps_test_search_place_list(maps_svc, maps_pref); break;
+       case '5': ret = maps_test_search_place_cancel(maps_svc, maps_pref); break;
+       case '6': ret = maps_test_geocode(maps_svc, maps_pref); break;
+       case '7': ret = maps_test_reverse_geocode(maps_svc, maps_pref); break;
+       case '8': ret = maps_test_multi_reverse_geocode(maps_svc, maps_pref); break;
+       case '9': ret = maps_test_search_route(maps_svc, maps_pref); break;
+
+       case 'A': ret = maps_test_search_place_repeatedly(g_provider_name, g_provider_key, 200); break;
+
+       case 'x': return false;
+       case '\0':
+               print_menu();
                break;
+       default: printf("Unknown command\n"); break;
        }
-       if (ret != 0)
-               printf("Error = 0x%X\n", ret);
+       print_result(ret);
 
        return true;
 }
@@ -157,7 +191,8 @@ void *test_thread(void *data)
        };
 
        maps_test_finish();
-       exit(0);
+       g_main_loop_quit(data);
+       g_main_loop_unref(data);
        return NULL;
 }
 
@@ -169,7 +204,7 @@ int main(int argc, char **argv)
        g_type_init();
 #endif
        mainloop = g_main_loop_new(NULL, FALSE);
-       g_thread_new("capi-maps-service-test", &test_thread, NULL);
+       g_thread_new("capi-maps-service-test", &test_thread, mainloop);
        g_main_loop_run(mainloop);
 
        return 0;
index 61aa0951255760cfec5357ffecb2a4d0c8b4f352..969fad408ad5aa560dfc3fc1541021a0994c451e 100755 (executable)
@@ -25,8 +25,7 @@ typedef struct {
        long longval;
 } logval_type;
 
-extern maps_service_h maps_svc;
-extern maps_preference_h maps_pref;
+
 
 
 #ifndef MIN
@@ -38,12 +37,17 @@ extern maps_preference_h maps_pref;
 #endif
 
 
+
+#include <dlog.h>
+
 #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__);
+#undef LOGD
+#undef LOGE
+#define LOG_TAG "MAPS_TEST"
+#define LOGD(fmt, args...) log_print(DLOG_DEBUG, LOG_TAG, "%s(%d) "fmt"\n", __FUNCTION__, __LINE__, ##args)
+#define LOGE(fmt, args...) log_print(DLOG_DEBUG, LOG_TAG, "%s(%d) "fmt"\n", __FUNCTION__, __LINE__, ##args)
+#define ENTER_FUNC  log_print(DLOG_DEBUG, LOG_TAG, "ENTER FUNC : %s (%d)\n", __FUNCTION__, __LINE__);
+#define EXIT_FUNC   log_print(DLOG_DEBUG, LOG_TAG, "EXIT FUNC  : %s (%d)\n", __FUNCTION__, __LINE__);
 
 
 #define SEL_STR(name, str) (name && *name ? name : str)
@@ -56,23 +60,29 @@ extern maps_preference_h maps_pref;
        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"); \
+       log_print(DLOG_DEBUG, LOG_TAG, "\n"); \
+       log_print(DLOG_DEBUG, LOG_TAG, "================================================================================\n"); \
+       log_print(DLOG_DEBUG, LOG_TAG, fmt"\n", ##args); \
+       log_print(DLOG_DEBUG, LOG_TAG, "--------------------------------------------------------------------------------\n"); \
 }
 
 #define LOG_START(fmt, args...) \
-       if (fmt && *fmt && strlen(fmt) > 0) printf(fmt"\n", ##args);
+       if (fmt && *fmt && strlen(fmt) > 0) log_print(DLOG_DEBUG, LOG_TAG, fmt"\n", ##args);
 
 #define LOG_PRINT(fmt, args...) { \
-       if (fmt && *fmt) printf(fmt"\n", ##args); \
+       if (fmt && *fmt) log_print(DLOG_DEBUG, LOG_TAG, fmt"\n", ##args); \
+       if (lv.strval) { free(lv.strval); lv.strval = NULL; } \
+       lv.intval = 0; lv.dblval = 0.; lv.longval = 0; }
+
+#define LOG_PRINT_NOCR(fmt, args...) { \
+       if (fmt && *fmt) log_print(DLOG_DEBUG, LOG_TAG, fmt, ##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 (fmt && *fmt) log_print(DLOG_DEBUG, LOG_TAG, 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*/
index 1176e694b35495325fc90fe836c822025d14efe0..bb204f8c2e1db69c5f97f6b45a9cafd96efafbfe 100644 (file)
@@ -8,12 +8,18 @@ static void startup()
 {
 }
 
-static void cleanup(bool result)
+static void cleanup()
 {
-       print_result(result);
+}
+
+static void cleanup_callback(int error)
+{
+       print_result(error);
+       cleanup();
 }
 
 
+
 /*
  *
  *     callback functions for APIs
@@ -27,8 +33,7 @@ static bool __maps_test_geocode_cb(maps_error_e error, int request_id,
        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);
+               cleanup_callback(error);
                return false;
        }
 
@@ -37,19 +42,19 @@ static bool __maps_test_geocode_cb(maps_error_e error, int request_id,
        LOG_FINISH("");
 
        if (index == total - 1)
-               cleanup(true);
+               cleanup_callback(error);
        return true;
 }
 
-int maps_test_geocode(maps_service_h maps_svc)
+int maps_test_geocode(maps_service_h maps_svc, maps_preference_h maps_pref)
 {
        startup();
-       int request_id = 0, error;
+       int request_id = 0, error = MAPS_ERROR_NONE;
 
        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);
+               cleanup();
        return error;
 }
 
@@ -60,8 +65,7 @@ static void __maps_test_reverse_geocode_cb(maps_error_e error, int request_id,
        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);
+               cleanup_callback(error);
                return;
        }
 
@@ -70,19 +74,72 @@ static void __maps_test_reverse_geocode_cb(maps_error_e error, int request_id,
        LOG_FINISH("");
 
        if (index == total - 1)
-               cleanup(true);
+               cleanup_callback(error);
 }
 
-int maps_test_reverse_geocode(maps_service_h maps_svc)
+int maps_test_reverse_geocode(maps_service_h maps_svc, maps_preference_h maps_pref)
 {
        startup();
-       int request_id = 0, error;
+       int request_id = 0, error = MAPS_ERROR_NONE;
 
        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);
+               cleanup();
+       return error;
+}
+
+
+
+
+
+
+
+
+
+static bool __maps_test_multi_reverse_geocode_cb(maps_error_e error, int request_id, int total,
+       maps_address_list_h address_list, void *user_data)
+{
+       LOG_VARIABLES();
+
+       LOG_START_TITLE("%s [%d] ", (user_data ? (char*)user_data : __FUNCTION__), total);
+
+       if (error) {
+               cleanup_callback(error);
+               return false;
+       }
+
+       log_address_list("", address_list);
+       maps_address_list_destroy(address_list);
+       LOG_FINISH("");
+
+       cleanup_callback(error);
+       return true;
+}
+
+int maps_test_multi_reverse_geocode(maps_service_h maps_svc, maps_preference_h maps_pref)
+{
+       startup();
+       int request_id = 0, error = MAPS_ERROR_NONE;
+
+       maps_coordinates_h coordinates[3];
+       maps_coordinates_create(52.5309, 13.3845, &coordinates[0]);
+       maps_coordinates_create(50.1618996, 8.5334997, &coordinates[1]);
+       maps_coordinates_create(40.72962607104243, -73.98685008095087, &coordinates[2]);
+
+       maps_coordinates_list_h coordinates_list;
+       maps_coordinates_list_create(&coordinates_list);
+       maps_coordinates_list_append(coordinates_list, coordinates[0]);
+       maps_coordinates_list_append(coordinates_list, coordinates[1]);
+       maps_coordinates_list_append(coordinates_list, coordinates[2]);
+
+       error = maps_service_multi_reverse_geocode(maps_svc, coordinates_list, maps_pref,
+                       __maps_test_multi_reverse_geocode_cb, "Multi-reverse Geocoding", &request_id);
+       maps_coordinates_list_destroy(coordinates_list);
+
+       if (error != MAPS_ERROR_NONE)
+               cleanup();
        return error;
 }
 
index 2f25023282376c67f1a9ae4dba76c4d70a1e8701..c5745c094282440ff5177a898615c2530e7455f9 100644 (file)
@@ -1,7 +1,8 @@
 #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);
+int maps_test_geocode(maps_service_h maps_svc, maps_preference_h maps_pref);
+int maps_test_reverse_geocode(maps_service_h maps_svc, maps_preference_h maps_pref);
+int maps_test_multi_reverse_geocode(maps_service_h maps_svc, maps_preference_h maps_pref);
 
 #endif /*__MAPS_TEST_GEOCODE_H__*/
index c62c4b5670e3a85eb275d55d2102407c4977df87..ad312e4afb5f5d6a01c8cb16465b94303e7ffd51 100755 (executable)
@@ -47,11 +47,26 @@ void log_address(char *prefix, maps_address_h address)
        LOG_FINISH("%s}", prefix);
 }
 
+
+bool __log_address_list_cb(int index, maps_address_h address, void *user_data)
+{
+       char *prefix = (char*)user_data;
+       log_address(prefix, address);
+       return true;
+}
+
+void log_address_list(char *prefix, maps_address_list_h address_list)
+{
+       maps_address_list_foreach(address_list, __log_address_list_cb, prefix);
+}
+
+
+
 void log_area(char *prefix, maps_area_h area)
 {
        if (!area) return;
        LOG_VARIABLES();
-       LOG_START("%saddress = {", prefix);
+       LOG_START("%sarea = {", prefix);
 
        maps_area_s *_area = (maps_area_s*)area;
        if (_area->type == MAPS_AREA_RECTANGLE) {
@@ -149,3 +164,22 @@ void log_place_rating(char *prefix, maps_place_rating_h rating)
 
        LOG_FINISH("%s}", prefix);
 }
+
+
+
+extern maps_test_logging_type g_logging_type;
+
+void log_print(int level, const char *tag, const char *format, ...)
+{
+       maps_test_logging_type type = g_logging_type;
+       if (type == MAPS_TEST_LOGGING_NONE) return;
+
+       va_list args;
+       va_start(args, format);
+       if (type == MAPS_TEST_LOGGING_CONSOLE || type == MAPS_TEST_LOGGING_ALL)
+               vprintf(format, args);
+       if (type == MAPS_TEST_LOGGING_SDB || type == MAPS_TEST_LOGGING_ALL)
+               dlog_vprint(level, tag, format, args);
+       va_end(args);
+}
+
index 336947a325e514201bc90472c67f9598ba2b03a5..96aefae27d7e6595e76e807f0a70de04f942c7f8 100644 (file)
@@ -4,8 +4,17 @@
 #include <maps_service.h>
 
 
+typedef enum
+{
+       MAPS_TEST_LOGGING_NONE,
+       MAPS_TEST_LOGGING_CONSOLE,
+       MAPS_TEST_LOGGING_SDB,
+       MAPS_TEST_LOGGING_ALL,
+} maps_test_logging_type;
+
 
 void log_address(char *prefix, maps_address_h address);
+void log_address_list(char *prefix, maps_address_list_h address_list);
 void log_area(char *prefix, maps_area_h area);
 void log_coordinates(char *prefix, char *title, maps_coordinates_h position);
 
@@ -13,6 +22,6 @@ 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);
 
-
+void log_print(int level, const char *tag, const char *format, ...);
 
 #endif /*__MST_SERVICE_LOG_H__*/
index 1c72a88feef237a37cfdc712cd48f7849b6773cb..8c434608f71a658725b9357f5895503863ad42dd 100755 (executable)
@@ -2,6 +2,7 @@
 #include "maps_test_search_place.h"
 #include "maps_test_log.h"
 #include "maps_test_util.h"
+#include <glib.h>
 
 static maps_place_filter_h maps_place_filter = NULL;
 static int ref_cnt = 0;
@@ -13,15 +14,11 @@ static void startup()
        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)
+static void cleanup()
 {
-       print_result(result);
-
        unlimited_cnt = 0;
        if (--ref_cnt > 0) return;
 
@@ -30,6 +27,11 @@ static void cleanup(bool result)
        maps_place_filter = NULL;
 }
 
+static void cleanup_callback(int error)
+{
+       print_result(error);
+       cleanup();
+}
 
 
 
@@ -234,7 +236,7 @@ static bool __log_place(char *prefix, maps_place_h place)
        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);
+               distance_unit = get_current_distance_unit();
                LOG_PRINT("%sdistance = %d %s", prefix, distance, get_distance_unit_string(distance_unit));
        }
 
@@ -288,8 +290,7 @@ static bool __maps_service_search_place_cb(maps_error_e error, int request_id ,
        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);
+               cleanup_callback(error);
                return false;
        }
 
@@ -299,7 +300,7 @@ static bool __maps_service_search_place_cb(maps_error_e error, int request_id ,
        LOG_FINISH("");
 
        if (index == total - 1)
-               cleanup(true);
+               cleanup_callback(error);
        return true;
 }
 
@@ -320,12 +321,12 @@ 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);
+               print_result(error);
+               cleanup_callback(error);
                return;
        }
        maps_place_list_foreach(place_list, __maps_place_cb, user_data);
-       cleanup(true);
+       cleanup_callback(error);
 }
 
 
@@ -337,10 +338,10 @@ static void __maps_service_search_place_list_cb(maps_error_e error,
  *
  */
 
-int maps_test_search_place(maps_service_h maps_svc)
+int maps_test_search_place(maps_service_h maps_svc, maps_preference_h maps_pref)
 {
        startup();
-       int request_id = 0, error;
+       int request_id = 0, error = MAPS_ERROR_NONE;
 
        maps_coordinates_h coordinates;
        maps_coordinates_create(48.85784, 2.29516, &coordinates);
@@ -354,14 +355,14 @@ int maps_test_search_place(maps_service_h maps_svc)
        maps_coordinates_destroy(coordinates);
 
        if (error != MAPS_ERROR_NONE)
-               cleanup(false);
+               cleanup();
        return error;
 }
 
-int maps_test_search_place_by_address(maps_service_h maps_svc)
+int maps_test_search_place_by_address(maps_service_h maps_svc, maps_preference_h maps_pref)
 {
        startup();
-       int request_id = 0, error;
+       int request_id = 0, error = MAPS_ERROR_NONE;
 
        maps_coordinates_h top_left, bottom_right;
        maps_area_h area;
@@ -378,19 +379,19 @@ int maps_test_search_place_by_address(maps_service_h maps_svc)
        maps_area_destroy(area);
 
        if (error != MAPS_ERROR_NONE)
-               cleanup(false);
+               cleanup();
        return error;
 }
 
-int maps_test_search_place_by_area(maps_service_h maps_svc)
+int maps_test_search_place_by_area(maps_service_h maps_svc, maps_preference_h maps_pref)
 {
        startup();
-       int request_id = 0, error;
+       int request_id = 0, error = MAPS_ERROR_NONE;
 
        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_coordinates_create(52.51605, 12.37691, &top_left);
+       maps_coordinates_create(54.12351, 14.22351, &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,
@@ -401,15 +402,15 @@ int maps_test_search_place_by_area(maps_service_h maps_svc)
        maps_area_destroy(area);
 
        if (error != MAPS_ERROR_NONE)
-               cleanup(false);
+               cleanup();
        return error;
 }
 
 
-int maps_test_search_place_list(maps_service_h maps_svc)
+int maps_test_search_place_list(maps_service_h maps_svc, maps_preference_h maps_pref)
 {
        startup();
-       int request_id = 0, error;
+       int request_id = 0, error = MAPS_ERROR_NONE;
 
        maps_coordinates_h coordinates;
        maps_area_h area;
@@ -423,6 +424,101 @@ int maps_test_search_place_list(maps_service_h maps_svc)
        maps_area_destroy(area);
 
        if (error != MAPS_ERROR_NONE)
-               cleanup(false);
+               cleanup();
        return error;
 }
+
+
+int maps_test_search_place_cancel(maps_service_h maps_svc, maps_preference_h maps_pref)
+{
+       startup();
+       int request_id = 0, error = MAPS_ERROR_NONE;
+
+       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_service_cancel_request(maps_svc, request_id);
+       maps_coordinates_destroy(coordinates);
+
+       print_result(error);
+       if (error != MAPS_ERROR_NONE)
+               cleanup();
+       return error;
+}
+
+
+
+
+
+
+
+
+static bool g_responsed = false;
+static int g_result = false;
+
+static bool __maps_service_search_place_repeatedly_cb(maps_error_e error, int request_id , int index, int total, maps_place_h place, void* user_data)
+{
+       g_result = error;
+       if (index == total -1 || error != MAPS_ERROR_NONE) {
+               g_responsed = true;
+               return false;
+       } else {
+               return true;
+       }
+}
+
+
+int maps_test_search_place_repeatedly(char *provider_name, char *provider_key, int max_cnt)
+{
+       startup();
+       int request_id = 0, error = MAPS_ERROR_NONE;
+
+       LOG_VARIABLES();
+       int i;
+
+       for (i = 0; i < max_cnt; i++) {
+               g_responsed = false;
+
+               maps_service_h maps_svc = NULL;
+               int ret = maps_service_create_without_user_consent(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, provider_key);
+               }
+
+               maps_preference_h maps_pref = NULL;
+               maps_preference_create(&maps_pref);
+               maps_preference_set_property(maps_pref, MAPS_PLACE_FILTER_SORT_BY, "distance");
+
+               maps_coordinates_h coordinates = NULL;
+               maps_coordinates_create(48.85784, 2.29516, &coordinates);
+
+               maps_place_filter_set_place_name(maps_place_filter, "Berlin");
+
+               error = maps_service_search_place(maps_svc, coordinates, 5, maps_place_filter, maps_pref,
+                               __maps_service_search_place_repeatedly_cb, "Search Place", &request_id);
+
+               if (error != MAPS_ERROR_NONE) {
+                       maps_coordinates_destroy(coordinates);
+                       maps_service_destroy(maps_svc);
+                       break;
+               }
+               while (!g_responsed) g_usleep(100);
+               LOG_PRINT_NOCR("maps_test_search_place_repeatedly [%d/%d] : %s\n", i+1, max_cnt, get_result_string(g_result));
+
+               maps_coordinates_destroy(coordinates);
+               maps_preference_destroy(maps_pref);
+               error = maps_service_destroy(maps_svc);
+       }
+
+       cleanup(i == max_cnt && error == MAPS_ERROR_NONE);
+       return error;
+}
+
+
index 18ba40a01196eb0687a1372382d23917d313f6c0..c937b295e3ea1eb41b85862ed2d68e169f0188a9 100755 (executable)
@@ -1,12 +1,16 @@
 #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(maps_service_h maps_svc, maps_preference_h maps_pref);
 
-int maps_test_search_place_by_address(maps_service_h maps_svc);
+int maps_test_search_place_by_address(maps_service_h maps_svc, maps_preference_h maps_pref);
 
-int maps_test_search_place_by_area(maps_service_h maps_svc);
+int maps_test_search_place_by_area(maps_service_h maps_svc, maps_preference_h maps_pref);
 
-int maps_test_search_place_list(maps_service_h maps_svc);
+int maps_test_search_place_list(maps_service_h maps_svc, maps_preference_h maps_pref);
+
+int maps_test_search_place_cancel(maps_service_h maps_svc, maps_preference_h maps_pref);
+
+int maps_test_search_place_repeatedly();
 
 #endif /*__MAPS_TEST_SEARCH_PLACE_H__*/
index 73f82e22dafe5e359580455a16428417dd5cb698..d1450c09e1f3f9ce7fad21df81a2b2c12f7ea232 100644 (file)
@@ -10,12 +10,15 @@ static void startup()
 {
 }
 
-static void cleanup(bool result)
+static void cleanup()
 {
-       print_result(result);
 }
 
-
+static void cleanup_callback(int error)
+{
+       print_result(error);
+       cleanup();
+}
 
 
 
@@ -194,7 +197,8 @@ static bool __maps_service_search_route_cb(maps_error_e error,
        LOG_START_TITLE("%s [%d/%d] ", (user_data ? (char*)user_data : __FUNCTION__), MIN(index+1, total), total);
 
        if (error) {
-               cleanup(false);
+               print_result(error);
+               cleanup_callback(error);
                return false;
        }
 
@@ -204,12 +208,12 @@ static bool __maps_service_search_route_cb(maps_error_e error,
        LOG_FINISH("");
 
        if (index == total - 1)
-               cleanup(true);
+               cleanup_callback(error);
        return true;
 }
 
 
-int maps_test_search_route(maps_service_h maps_svc)
+int maps_test_search_route(maps_service_h maps_svc, maps_preference_h maps_pref)
 {
        startup();
        int request_id, error;
@@ -225,7 +229,7 @@ int maps_test_search_route(maps_service_h maps_svc)
        maps_coordinates_destroy(dest);
 
        if (error != MAPS_ERROR_NONE)
-               cleanup(false);
+               cleanup();
        return error;
 }
 
index 13c8022d78e60339641a890cd93a8d8bb0e187d9..d18f1fb6754131549c7a5c7567b478edd367ef1f 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef __MAPS_TEST_SEARCH_ROUTE_H__
 #define __MAPS_TEST_SEARCH_ROUTE_H__
 
-int maps_test_search_route(maps_service_h maps_svc);
+int maps_test_search_route(maps_service_h maps_svc, maps_preference_h maps_pref);
 
 #endif /*__MAPS_TEST_SEARCH_ROUTE_H__*/
index 0511d79651ab58f0793fa406518322f22fdde71c..6cfdf070e84633f8e8cabc7a7a37ab422edbc1a1 100755 (executable)
@@ -34,10 +34,60 @@ const char* get_distance_unit_string(maps_distance_unit_e distance_unit)
        return distance_unit_string[distance_unit];
 }
 
-void print_result(bool result)
+maps_distance_unit_e get_current_distance_unit()
 {
-       if (result)
-               printf("Ok\n");
+       extern maps_preference_h maps_pref;
+       maps_distance_unit_e distance_unit = MAPS_DISTANCE_UNIT_M;
+       maps_preference_get_distance_unit(maps_pref, &distance_unit);
+       return distance_unit;
+}
+
+const char* get_maps_error_string(int error)
+{
+       switch (error) {
+       case MAPS_ERROR_NONE:                  return "MAPS_ERROR_NONE";
+       case MAPS_ERROR_PERMISSION_DENIED:     return "MAPS_ERROR_PERMISSION_DENIED";
+       case MAPS_ERROR_OUT_OF_MEMORY:         return "MAPS_ERROR_OUT_OF_MEMORY";
+       case MAPS_ERROR_INVALID_PARAMETER:     return "MAPS_ERROR_INVALID_PARAMETER";
+       case MAPS_ERROR_NOT_SUPPORTED:         return "MAPS_ERROR_NOT_SUPPORTED";
+       case MAPS_ERROR_CONNECTION_TIME_OUT:   return "MAPS_ERROR_CONNECTION_TIME_OUT";
+       case MAPS_ERROR_NETWORK_UNREACHABLE:   return "MAPS_ERROR_NETWORK_UNREACHABLE";
+       case MAPS_ERROR_INVALID_OPERATION:     return "MAPS_ERROR_INVALID_OPERATION";
+       case MAPS_ERROR_KEY_NOT_AVAILABLE:     return "MAPS_ERROR_KEY_NOT_AVAILABLE";
+       case MAPS_ERROR_RESOURCE_BUSY:         return "MAPS_ERROR_RESOURCE_BUSY";
+       case MAPS_ERROR_CANCELED:              return "MAPS_ERROR_CANCELED";
+       case MAPS_ERROR_UNKNOWN:               return "MAPS_ERROR_UNKNOWN";
+       case MAPS_ERROR_USER_NOT_CONSENTED:    return "MAPS_ERROR_USER_NOT_CONSENTED";
+       case MAPS_ERROR_SERVICE_NOT_AVAILABLE: return "MAPS_ERROR_SERVICE_NOT_AVAILABLE";
+       case MAPS_ERROR_NOT_FOUND:             return "MAPS_ERROR_NOT_FOUND";
+       }
+       return "Unknow error code";
+}
+
+const char* get_logging_type_string(maps_test_logging_type type)
+{
+       switch (type) {
+       case MAPS_TEST_LOGGING_NONE:    break;
+       case MAPS_TEST_LOGGING_CONSOLE: return "Console";
+       case MAPS_TEST_LOGGING_SDB:     return "SDB";
+       case MAPS_TEST_LOGGING_ALL:     return "All";
+       }
+       return "Off";
+}
+
+void print_result(int error)
+{
+       if (error == MAPS_ERROR_NONE)
+               printf("## Ok\n");
        else
-               printf("Fail\n");
+               printf("## Fail (%s)\n", get_maps_error_string(error));
 }
+
+const char* get_result_string(int error)
+{
+       if (error == MAPS_ERROR_NONE)
+               return "Ok";
+       else
+               return "Fail";
+}
+
index 1d8ab643da4d4bcc8ca10fb4551c159695945cae..d58438439f8c31f21e30a92226078a311a4b2e6f 100755 (executable)
@@ -2,12 +2,17 @@
 #define __MAPS_TEST_UTIL_H__
 
 #include <maps_route.h>
+#include "maps_test_log.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);
+maps_distance_unit_e get_current_distance_unit();
 
-void print_result(bool result);
+const char* get_maps_error_string(int error);
+void print_result(int error);
+const char* get_logging_type_string(maps_test_logging_type type);
+const char* get_result_string(int error);
 
 #endif /*__MAPS_TEST_UTIL_H__*/