4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include <glib/gprintf.h>
23 /*----------------------------------------------------------------------------*/
25 /* Select between unit testing mode: */
28 /* - Correctness Unit Tests */
29 #define MAPS_SERVICE_CORRECTNESS_TEST
31 /* - Load Unit Tests */
32 /*#define MAPS_SERVICE_LOAD_TEST*/
34 /* - Valgrind Tests */
35 /*#define MAPS_SERVICE_VALGRIND_TEST */
38 /*----------------------------------------------------------- */
39 /* Number of iterations Test Cases to be run */
40 /* It it is not a memory leak test, */
41 /* the value of iterations will be automatically reduced to 1 */
42 static long long iterations = 250* 1000; /* For load test */
45 #ifdef MAPS_SERVICE_LOAD_TEST
46 /* Sleep before next iteration */
47 static unsigned int sleep_microseconds = 0; /* No delay */
48 /*10*1000;*/ /* 10 milliseconds */
49 /*100*1000;*/ /* 100 milliseconds */
50 /*500*1000;*/ /* Half a second */
51 /*1000*1000;*/ /* 1 second */
53 #endif /* MAPS_SERVICE_LOAD_TEST */
55 /*----------------------------------------------------------------------------*/
57 #ifdef MAPS_SERVICE_VALGRIND_TEST
59 /* This macro allows to skip tests, which generate Valgrind warning */
60 /* Usually, these warnings are coming from the depth of glib */
61 /*#define SUPPRESS_VALGRIND_WARNINGS */
63 /* This macro turnes off g_assert */
64 #define G_DISABLE_ASSERT
66 #endif /* MAPS_SERVICE_VALGRIND_TEST */
68 /* Type of each unit test */
69 typedef void (*test_funcvoid) (void);
74 #include "discovery_test.h"
75 #include "module_test.h"
77 #include "command_test.h"
78 #include "commands_test.h"
79 #include "command_queue_test.h"
80 #include "thread_test.h"
82 #include "maps_address_test.h"
83 #include "maps_api_test.h"
84 #include "maps_area_test.h"
85 #include "maps_coordinates_test.h"
86 #include "maps_extra_types_test.h"
88 #include "maps_place_test.h"
89 #include "maps_place_category_test.h"
90 #include "maps_place_attribute_test.h"
91 #include "maps_place_contact_test.h"
92 #include "maps_place_editorial_test.h"
93 #include "maps_place_link_object_test.h"
94 #include "maps_place_media_test.h"
95 #include "maps_place_url_test.h"
96 #include "maps_place_review_test.h"
97 #include "maps_place_rating_test.h"
98 #include "maps_place_image_test.h"
99 #include "maps_place_filter_test.h"
101 #include "maps_route_test.h"
102 #include "maps_route_maneuver_test.h"
103 #include "maps_route_segment_test.h"
105 #include "maps_preference_test.h"
107 #include "maps_service_tutorial.h"
109 static void __test_add_func_load(const char *testpath, test_funcvoid func,
112 static char test_name[100] = { 0 };
114 g_sprintf(test_name, "%lld%s", i, testpath);
116 g_sprintf(test_name, "%s", testpath);
118 #ifdef MAPS_SERVICE_CORRECTNESS_TEST
119 g_test_add_func(test_name, func);
121 g_print("%s\n", test_name);
123 #endif /* MAPS_SERVICE_CORRECTNESS_TEST */
126 static void __utc_simple_test(void)
128 g_print("Simple Test");
132 static void __add_plugin_tests(int i)
134 __test_add_func_load("/plugin/discovery/provider_info_construct_p",
135 utc_provider_info_construct_p, i);
136 /*__test_add_func_load("/plugin/discovery/operator_provider_info_h_p",
137 * utc_operator_maps_provider_info_h_p, i); */
138 __test_add_func_load("/plugin/discovery/provider_info_empty_p",
139 utc_provider_info_empty_p, i);
140 __test_add_func_load("/plugin/discovery/provider_info_empty_n_01",
141 utc_provider_info_empty_n_01, i);
142 __test_add_func_load("/plugin/discovery/provider_info_empty_n_02",
143 utc_provider_info_empty_n_02, i);
144 __test_add_func_load("/plugin/discovery/provider_info_empty_n_03",
145 utc_provider_info_empty_n_03, i);
147 #ifndef SUPPRESS_VALGRIND_WARNINGS /* Valgrind warnings!!! */
148 __test_add_func_load("/plugin/discovery/get_available_list_p",
149 utc_get_available_plugin_list, i);
150 __test_add_func_load("/plugin/binary_extractor/init_p",
151 utc_binary_extractor_init_plugin_p, i);
155 static void __add_session_tests(int i)
157 __test_add_func_load("/session/command/get_empty_command_ptr_p",
158 utc_command_empty_ptr_p, i);
160 #ifndef SUPPRESS_VALGRIND_WARNINGS
161 __test_add_func_load("/session/command_queue/push_p",
162 utc_command_queue_push_p, i);
163 /* Valgrind warnings!!! */
164 __test_add_func_load("/session/command_queue/push_n",
165 utc_command_queue_push_n, i);
166 /* Valgrind warnings!!! */
168 __test_add_func_load("/session/glib_hashtable/use_p",
169 utc_use_hash_table_p, i);
171 __test_add_func_load("/session/pending_request/add_p",
172 utc_pending_request_add_p, i);
173 __test_add_func_load("/session/pending_request/add_n",
174 utc_pending_request_add_n, i);
175 __test_add_func_load("/session/pending_request/update_p",
176 utc_pending_request_update_p, i);
177 __test_add_func_load("/session/pending_request/update_n",
178 utc_pending_request_update_n, i);
179 __test_add_func_load("/session/pending_request/remove_p",
180 utc_pending_request_remove_p, i);
181 __test_add_func_load("/session/pending_request/remove_n",
182 utc_pending_request_remove_n, i);
183 __test_add_func_load("/session/pending_request/look_up_p",
184 utc_pending_request_look_up_p, i);
185 __test_add_func_load("/session/pending_request/look_up_n",
186 utc_pending_request_look_up_n, i);
187 __test_add_func_load("/session/pending_request/extract_p",
188 utc_pending_request_extract_p, i);
189 __test_add_func_load("/session/pending_request/extract_n",
190 utc_pending_request_extract_n, i);
191 __test_add_func_load("/session/pending_request/contains_p",
192 utc_pending_request_contains_p, i);
193 __test_add_func_load("/session/pending_request/contains_n",
194 utc_pending_request_contains_n, i);
198 static void __add_extra_data_structure_tests(int i)
200 #ifndef SUPPRESS_VALGRIND_WARNINGS /* Valgrind warnings!!! */
201 /* API: Extra Data Structures: List */
202 __test_add_func_load("/api/list/create_p", utc_maps_item_list_create_p,
204 __test_add_func_load("/api/list/create_n", utc_maps_item_list_create_n,
206 __test_add_func_load("/api/list/append_p", utc_maps_item_list_append_p,
208 __test_add_func_load("/api/list/append_n", utc_maps_item_list_append_n,
210 __test_add_func_load("/api/list/foreach_p",
211 utc_maps_item_list_foreach_p, i);
212 __test_add_func_load("/api/list/foreach_n",
213 utc_maps_item_list_foreach_n, i);
215 /* API: Extra Data Structures: Hash Table */
216 __test_add_func_load("/api/string_hashtable/create_p",
217 utc_maps_string_hashtable_create_p, i);
218 __test_add_func_load("/api/string_hashtable/create_n",
219 utc_maps_string_hashtable_create_n, i);
220 __test_add_func_load("/api/string_hashtable/set_p",
221 utc_maps_string_hashtable_set_p, i);
222 __test_add_func_load("/api/string_hashtable/set_n",
223 utc_maps_string_hashtable_set_n, i);
224 __test_add_func_load("/api/string_hashtable/foreach_p",
225 utc_maps_string_hashtable_foreach_p, i);
226 __test_add_func_load("/api/string_hashtable/foreach_n",
227 utc_maps_string_hashtable_foreach_n, i);
229 /* API: Extra Data Structures: Hash Table */
230 __test_add_func_load("/api/item_hashtable/create_p",
231 utc_maps_item_hashtable_create_p, i);
232 __test_add_func_load("/api/item_hashtable/create_n",
233 utc_maps_item_hashtable_create_n, i);
234 __test_add_func_load("/api/item_hashtable/set_p",
235 utc_maps_item_hashtable_set_p, i);
236 __test_add_func_load("/api/item_hashtable/set_n",
237 utc_maps_item_hashtable_set_n, i);
238 __test_add_func_load("/api/item_hashtable/set_macro_p",
239 utc_maps_item_hashtable_set_macro_p, i);
240 __test_add_func_load("/api/item_hashtable/set_macro_n",
241 utc_maps_item_hashtable_set_macro_n, i);
242 __test_add_func_load("/api/item_hashtable/set_overwrited_macro_p",
243 utc_maps_item_hashtable_set_overwrited_macro_p, i);
244 __test_add_func_load("/api/item_hashtable/foreach_p",
245 utc_maps_item_hashtable_foreach_p, i);
246 __test_add_func_load("/api/item_hashtable/foreach_n",
247 utc_maps_item_hashtable_foreach_n, i);
251 static void __add_maps_data_structure_tests(int i)
253 #ifndef SUPPRESS_VALGRIND_WARNINGS /* Valgrind warnings!!! */
254 /* API: Data Structures: Coordinates */
255 __test_add_func_load("/api/coordinates/create_p",
256 utc_maps_coordinates_create_p, i);
257 __test_add_func_load("/api/coordinates/create_n",
258 utc_maps_coordinates_create_n, i);
259 __test_add_func_load("/api/coordinates/destroy_p",
260 utc_maps_coordinates_destroy_p, i);
261 __test_add_func_load("/api/coordinates/destroy_n",
262 utc_maps_coordinates_destroy_n, i);
263 __test_add_func_load("/api/coordinates/clone_p",
264 utc_maps_coordinates_clone_p, i);
265 __test_add_func_load("/api/coordinates/clone_n",
266 utc_maps_coordinates_clone_n, i);
267 __test_add_func_load("/api/coordinates/latitude_p",
268 utc_maps_coordinates_latitude_p, i);
269 __test_add_func_load("/api/coordinates/latitude_n",
270 utc_maps_coordinates_latitude_n, i);
271 __test_add_func_load("/api/coordinates/longitude_p",
272 utc_maps_coordinates_longitude_p, i);
273 __test_add_func_load("/api/coordinates/longitude_n",
274 utc_maps_coordinates_longitude_n, i);
277 __test_add_func_load("/api/coordinates/altitude_p",
278 utc_maps_coordinates_altitude_p, i);
279 __test_add_func_load("/api/coordinates/altitude_n",
280 utc_maps_coordinates_altitude_n, i);
283 /* API: Data Structures: Area */
284 __test_add_func_load("/api/area/create_rectangle_p",
285 utc_maps_area_create_rectangle_p, i);
286 __test_add_func_load("/api/area/create_rectangle_n",
287 utc_maps_area_create_rectangle_n, i);
288 __test_add_func_load("/api/area/create_circle_p",
289 utc_maps_area_create_circle_p, i);
290 __test_add_func_load("/api/area/create_circle_n",
291 utc_maps_area_create_circle_n, i);
292 __test_add_func_load("/api/area/destroy_p", utc_maps_area_destroy_p, i);
293 __test_add_func_load("/api/area/destroy_n", utc_maps_area_destroy_n, i);
294 __test_add_func_load("/api/area/clone_p", utc_maps_area_clone_p, i);
295 __test_add_func_load("/api/area/clone_n", utc_maps_area_clone_n, i);
299 static void __add_geocode_data_structure_tests(int i)
301 #ifndef SUPPRESS_VALGRIND_WARNINGS /* Valgrind warnings!!! */
302 /* API: Data Structures: Address */
303 __test_add_func_load("/api/maps_address/new_p",
304 utc_maps_address_create_p, i);
305 __test_add_func_load("/api/maps_address/new_n",
306 utc_maps_address_create_n, i);
307 __test_add_func_load("/api/maps_address/clone_p",
308 utc_maps_address_clone_p, i);
309 __test_add_func_load("/api/maps_address/clone_n",
310 utc_maps_address_clone_n, i);
311 __test_add_func_load("/api/maps_address/building_number_p",
312 utc_maps_address_building_number_p, i);
313 __test_add_func_load("/api/maps_address/building_number_n",
314 utc_maps_address_building_number_n, i);
315 __test_add_func_load("/api/maps_address/street_p",
316 utc_maps_address_street_p, i);
317 __test_add_func_load("/api/maps_address/street_n",
318 utc_maps_address_street_n, i);
319 __test_add_func_load("/api/maps_address/district_p",
320 utc_maps_address_district_p, i);
321 __test_add_func_load("/api/maps_address/district_n",
322 utc_maps_address_district_n, i);
323 __test_add_func_load("/api/maps_address/city_p",
324 utc_maps_address_city_p, i);
325 __test_add_func_load("/api/maps_address/city_n",
326 utc_maps_address_city_n, i);
327 __test_add_func_load("/api/maps_address/state_p",
328 utc_maps_address_state_p, i);
329 __test_add_func_load("/api/maps_address/state_n",
330 utc_maps_address_state_n, i);
331 __test_add_func_load("/api/maps_address/country_p",
332 utc_maps_address_country_p, i);
333 __test_add_func_load("/api/maps_address/country_n",
334 utc_maps_address_country_n, i);
335 __test_add_func_load("/api/maps_address/country_code_p",
336 utc_maps_address_country_code_p, i);
337 __test_add_func_load("/api/maps_address/country_code_n",
338 utc_maps_address_country_code_n, i);
339 __test_add_func_load("/api/maps_address/county_p",
340 utc_maps_address_county_p, i);
341 __test_add_func_load("/api/maps_address/county_n",
342 utc_maps_address_county_n, i);
343 __test_add_func_load("/api/maps_address/postal_code_p",
344 utc_maps_address_postal_code_p, i);
345 __test_add_func_load("/api/maps_address/postal_code_n",
346 utc_maps_address_postal_code_n, i);
347 __test_add_func_load("/api/maps_address/freetext_p",
348 utc_maps_address_destroytext_p, i);
349 __test_add_func_load("/api/maps_address/freetext_n",
350 utc_maps_address_destroytext_n, i);
354 static void __add_place_data_structure_tests(int i)
356 #ifndef SUPPRESS_VALGRIND_WARNINGS /* Valgrind warnings!!! */
357 /* API: Data Structures: Place: Category */
358 __test_add_func_load("/api/place/category/create_p",
359 utc_maps_place_category_create_p, i);
360 __test_add_func_load("/api/place/category/create_n",
361 utc_maps_place_category_create_n, i);
362 __test_add_func_load("/api/place/category/clone_p",
363 utc_maps_place_category_clone_p, i);
364 __test_add_func_load("/api/place/category/clone_n",
365 utc_maps_place_category_clone_n, i);
366 __test_add_func_load("/api/place/category/name_p",
367 utc_maps_place_category_name_p, i);
368 __test_add_func_load("/api/place/category/name_n",
369 utc_maps_place_category_name_n, i);
370 __test_add_func_load("/api/place/category/id_p",
371 utc_maps_place_category_id_p, i);
372 __test_add_func_load("/api/place/category/id_n",
373 utc_maps_place_category_id_n, i);
374 __test_add_func_load("/api/place/category/url_p",
375 utc_maps_place_category_url_p, i);
376 __test_add_func_load("/api/place/category/url_n",
377 utc_maps_place_category_url_n, i);
379 /* API: Data Structures: Place: Attribute */
380 __test_add_func_load("/api/place/attribute/create_p",
381 utc_maps_place_attribute_create_p, i);
382 __test_add_func_load("/api/place/attribute/create_n",
383 utc_maps_place_attribute_create_n, i);
384 __test_add_func_load("/api/place/attribute/clone_p",
385 utc_maps_place_attribute_clone_p, i);
386 __test_add_func_load("/api/place/attribute/clone_n",
387 utc_maps_place_attribute_clone_n, i);
388 __test_add_func_load("/api/place/attribute/id_p",
389 utc_maps_place_attribute_id_p, i);
390 __test_add_func_load("/api/place/attribute/id_n",
391 utc_maps_place_attribute_id_n, i);
392 __test_add_func_load("/api/place/attribute/label_p",
393 utc_maps_place_attribute_label_p, i);
394 __test_add_func_load("/api/place/attribute/label_n",
395 utc_maps_place_attribute_label_n, i);
396 __test_add_func_load("/api/place/attribute/text_p",
397 utc_maps_place_attribute_text_p, i);
398 __test_add_func_load("/api/place/attribute/text_n",
399 utc_maps_place_attribute_text_n, i);
401 /* API: Data Structures: Place: Contact */
402 __test_add_func_load("/api/place/contact/create_p",
403 utc_maps_place_contact_create_p, i);
404 __test_add_func_load("/api/place/contact/create_n",
405 utc_maps_place_contact_create_n, i);
406 __test_add_func_load("/api/place/contact/clone_p",
407 utc_maps_place_contact_clone_p, i);
408 __test_add_func_load("/api/place/contact/clone_n",
409 utc_maps_place_contact_clone_n, i);
410 __test_add_func_load("/api/place/contact/label_p",
411 utc_maps_place_contact_label_p, i);
412 __test_add_func_load("/api/place/contact/label_n",
413 utc_maps_place_contact_label_n, i);
414 __test_add_func_load("/api/place/contact/type_p",
415 utc_maps_place_contact_type_p, i);
416 __test_add_func_load("/api/place/contact/type_n",
417 utc_maps_place_contact_type_n, i);
418 __test_add_func_load("/api/place/contact/value_p",
419 utc_maps_place_contact_value_p, i);
420 __test_add_func_load("/api/place/contact/value_n",
421 utc_maps_place_contact_value_n, i);
423 /* API: Data Structures: Place: Editorial */
424 __test_add_func_load("/api/place/editorial/create_p",
425 utc_maps_place_editorial_create_p, i);
426 __test_add_func_load("/api/place/editorial/create_n",
427 utc_maps_place_editorial_create_n, i);
428 __test_add_func_load("/api/place/editorial/clone_p",
429 utc_maps_place_editorial_clone_p, i);
430 __test_add_func_load("/api/place/editorial/clone_n",
431 utc_maps_place_editorial_clone_n, i);
432 __test_add_func_load("/api/place/editorial/description_p",
433 utc_maps_place_editorial_description_p, i);
434 __test_add_func_load("/api/place/editorial/description_n",
435 utc_maps_place_editorial_description_n, i);
436 __test_add_func_load("/api/place/editorial/language_p",
437 utc_maps_place_editorial_language_p, i);
438 __test_add_func_load("/api/place/editorial/language_n",
439 utc_maps_place_editorial_language_n, i);
440 __test_add_func_load("/api/place/editorial/media_p",
441 utc_maps_place_editorial_media_p, i);
442 __test_add_func_load("/api/place/editorial/media_n",
443 utc_maps_place_editorial_media_n, i);
445 /* API: Data Structures: Place: Link Object */
446 __test_add_func_load("/api/place/link_object/create_p",
447 utc_maps_place_link_object_create_p, i);
448 __test_add_func_load("/api/place/link_object/create_n",
449 utc_maps_place_link_object_create_n, i);
450 __test_add_func_load("/api/place/link_object/clone_p",
451 utc_maps_place_link_object_clone_p, i);
452 __test_add_func_load("/api/place/link_object/clone_n",
453 utc_maps_place_link_object_clone_n, i);
454 __test_add_func_load("/api/place/link_object/id_p",
455 utc_maps_place_link_object_id_p, i);
456 __test_add_func_load("/api/place/link_object/id_n",
457 utc_maps_place_link_object_id_n, i);
458 __test_add_func_load("/api/place/link_object/name_p",
459 utc_maps_place_link_object_name_p, i);
460 __test_add_func_load("/api/place/link_object/name_n",
461 utc_maps_place_link_object_name_n, i);
462 __test_add_func_load("/api/place/link_object/type_p",
463 utc_maps_place_link_object_type_p, i);
464 __test_add_func_load("/api/place/link_object/type_n",
465 utc_maps_place_link_object_type_n, i);
466 __test_add_func_load("/api/place/link_object/string_p",
467 utc_maps_place_link_object_string_p, i);
468 __test_add_func_load("/api/place/link_object/string_n",
469 utc_maps_place_link_object_string_n, i);
471 /* API: Data Structures: Place: Media */
472 __test_add_func_load("/api/place/media/create_p",
473 utc_maps_place_media_create_p, i);
474 __test_add_func_load("/api/place/media/create_n",
475 utc_maps_place_media_create_n, i);
476 __test_add_func_load("/api/place/media/clone_p",
477 utc_maps_place_media_clone_p, i);
478 __test_add_func_load("/api/place/media/clone_n",
479 utc_maps_place_media_clone_n, i);
480 __test_add_func_load("/api/place/media/attribution_p",
481 utc_maps_place_media_attribution_p, i);
482 __test_add_func_load("/api/place/media/attribution_n",
483 utc_maps_place_media_attribution_n, i);
484 __test_add_func_load("/api/place/media/supplier_p",
485 utc_maps_place_media_supplier_p, i);
486 __test_add_func_load("/api/place/media/supplier_n",
487 utc_maps_place_media_supplier_n, i);
488 __test_add_func_load("/api/place/media/via_p",
489 utc_maps_place_media_via_p, i);
490 __test_add_func_load("/api/place/media/via_n",
491 utc_maps_place_media_via_n, i);
493 /* API: Data Structures: Place: URL */
494 __test_add_func_load("/api/place/URL/create_p",
495 utc_maps_place_url_create_p, i);
496 __test_add_func_load("/api/place/URL/create_n",
497 utc_maps_place_url_create_n, i);
498 __test_add_func_load("/api/place/URL/clone_p",
499 utc_maps_place_url_clone_p, i);
500 __test_add_func_load("/api/place/URL/clone_n",
501 utc_maps_place_url_clone_n, i);
502 __test_add_func_load("/api/place/URL/path_p", utc_maps_place_url_path_p,
504 __test_add_func_load("/api/place/URL/path_n", utc_maps_place_url_path_n,
506 __test_add_func_load("/api/place/URL/description_p",
507 utc_maps_place_url_description_p, i);
508 __test_add_func_load("/api/place/URL/description_n",
509 utc_maps_place_url_description_n, i);
511 /* API: Data Structures: Place: Review */
512 __test_add_func_load("/api/place/review/create_p",
513 utc_maps_place_review_create_p, i);
514 __test_add_func_load("/api/place/review/create_n",
515 utc_maps_place_review_create_n, i);
516 __test_add_func_load("/api/place/review/clone_p",
517 utc_maps_place_review_clone_p, i);
518 __test_add_func_load("/api/place/review/clone_n",
519 utc_maps_place_review_clone_n, i);
520 __test_add_func_load("/api/place/review/date_p",
521 utc_maps_place_review_date_p, i);
522 __test_add_func_load("/api/place/review/date_n",
523 utc_maps_place_review_date_n, i);
524 __test_add_func_load("/api/place/review/title_p",
525 utc_maps_place_review_title_p, i);
526 __test_add_func_load("/api/place/review/title_n",
527 utc_maps_place_review_title_n, i);
528 __test_add_func_load("/api/place/review/rating_p",
529 utc_maps_place_review_rating_p, i);
530 __test_add_func_load("/api/place/review/rating_n",
531 utc_maps_place_review_rating_n, i);
532 __test_add_func_load("/api/place/review/description_p",
533 utc_maps_place_review_description_p, i);
534 __test_add_func_load("/api/place/review/description_n",
535 utc_maps_place_review_description_n, i);
536 __test_add_func_load("/api/place/review/language_p",
537 utc_maps_place_review_language_p, i);
538 __test_add_func_load("/api/place/review/language_n",
539 utc_maps_place_review_language_n, i);
540 __test_add_func_load("/api/place/review/media_p",
541 utc_maps_place_review_media_p, i);
542 __test_add_func_load("/api/place/review/media_n",
543 utc_maps_place_review_media_n, i);
544 __test_add_func_load("/api/place/review/user_link_p",
545 utc_maps_place_review_user_link_p, i);
546 __test_add_func_load("/api/place/review/user_link_n",
547 utc_maps_place_review_user_link_n, i);
549 /* API: Data Structures: Place: Rating */
550 __test_add_func_load("/api/place/rating/create_p",
551 utc_maps_place_rating_create_p, i);
552 __test_add_func_load("/api/place/rating/create_n",
553 utc_maps_place_rating_create_n, i);
554 __test_add_func_load("/api/place/rating/clone_p",
555 utc_maps_place_rating_clone_p, i);
556 __test_add_func_load("/api/place/rating/clone_n",
557 utc_maps_place_rating_clone_n, i);
558 __test_add_func_load("/api/place/rating/count_p",
559 utc_maps_place_rating_count_p, i);
560 __test_add_func_load("/api/place/rating/count_n",
561 utc_maps_place_rating_count_n, i);
562 __test_add_func_load("/api/place/rating/average_p",
563 utc_maps_place_rating_average_p, i);
564 __test_add_func_load("/api/place/rating/average_n",
565 utc_maps_place_rating_average_n, i);
567 /* API: Data Structures: Place: Image */
568 __test_add_func_load("/api/place/image/create_p",
569 utc_maps_place_image_create_p, i);
570 __test_add_func_load("/api/place/image/create_n",
571 utc_maps_place_image_create_n, i);
572 __test_add_func_load("/api/place/image/clone_p",
573 utc_maps_place_image_clone_p, i);
574 __test_add_func_load("/api/place/image/clone_n",
575 utc_maps_place_image_clone_n, i);
576 __test_add_func_load("/api/place/image/id_p", utc_maps_place_image_id_p,
578 __test_add_func_load("/api/place/image/id_n", utc_maps_place_image_id_n,
580 __test_add_func_load("/api/place/image/url_p",
581 utc_maps_place_image_url_p, i);
582 __test_add_func_load("/api/place/image/url_n",
583 utc_maps_place_image_url_n, i);
584 __test_add_func_load("/api/place/image/width_p",
585 utc_maps_place_image_width_p, i);
586 __test_add_func_load("/api/place/image/width_n",
587 utc_maps_place_image_width_n, i);
588 __test_add_func_load("/api/place/image/height_p",
589 utc_maps_place_image_height_p, i);
590 __test_add_func_load("/api/place/image/height_n",
591 utc_maps_place_image_height_n, i);
592 __test_add_func_load("/api/place/image/user_link_p",
593 utc_maps_place_image_user_link_p, i);
594 __test_add_func_load("/api/place/image/user_link_n",
595 utc_maps_place_image_user_link_n, i);
596 __test_add_func_load("/api/place/image/media_p",
597 utc_maps_place_image_media_p, i);
598 __test_add_func_load("/api/place/image/media_n",
599 utc_maps_place_image_media_n, i);
601 /* API: Data Structures: Maps: Place: Filter */
602 __test_add_func_load("/api/place/filter/create_p",
603 utc_maps_place_filter_create_p, i);
604 __test_add_func_load("/api/place/filter/create_n",
605 utc_maps_place_filter_create_n, i);
606 __test_add_func_load("/api/place/filter/clone_p",
607 utc_maps_place_filter_clone_p, i);
608 __test_add_func_load("/api/place/filter/clone_n",
609 utc_maps_place_filter_clone_n, i);
610 __test_add_func_load("/api/place/filter/set_p",
611 utc_maps_place_filter_set_p, i);
612 __test_add_func_load("/api/place/filter/set_n",
613 utc_maps_place_filter_set_n, i);
615 /* API: Data Structures: Place */
616 __test_add_func_load("/api/place/create_p", utc_maps_place_create_p, i);
617 __test_add_func_load("/api/place/create_n", utc_maps_place_create_n, i);
618 __test_add_func_load("/api/place/clone_p", utc_maps_place_clone_p, i);
619 __test_add_func_load("/api/place/clone_n", utc_maps_place_clone_n, i);
620 __test_add_func_load("/api/place/set_id_p", utc_maps_place_set_id_p, i);
621 __test_add_func_load("/api/place/set_id_n", utc_maps_place_set_id_n, i);
622 __test_add_func_load("/api/place/set_name_p", utc_maps_place_set_name_p,
624 __test_add_func_load("/api/place/set_name_n", utc_maps_place_set_name_n,
626 __test_add_func_load("/api/place/set_uri_p", utc_maps_place_set_uri_p,
628 __test_add_func_load("/api/place/set_uri_n", utc_maps_place_set_uri_n,
630 __test_add_func_load("/api/place/set_location_p",
631 utc_maps_place_set_location_p, i);
632 __test_add_func_load("/api/place/set_location_n",
633 utc_maps_place_set_location_n, i);
634 __test_add_func_load("/api/place/set_category_p",
635 utc_maps_place_set_category_p, i);
636 __test_add_func_load("/api/place/set_category_n",
637 utc_maps_place_set_category_n, i);
638 __test_add_func_load("/api/place/set_attribute_p",
639 utc_maps_place_set_attribute_p, i);
640 __test_add_func_load("/api/place/set_attribute_n",
641 utc_maps_place_set_attribute_n, i);
642 __test_add_func_load("/api/place/set_contact_p",
643 utc_maps_place_set_contacts_p, i);
644 __test_add_func_load("/api/place/set_contact_n",
645 utc_maps_place_set_contacts_n, i);
646 __test_add_func_load("/api/place/set_editorial_p",
647 utc_maps_place_set_editorial_p, i);
648 __test_add_func_load("/api/place/set_editorial_n",
649 utc_maps_place_set_editorial_n, i);
650 __test_add_func_load("/api/place/set_image_p",
651 utc_maps_place_set_image_p, i);
652 __test_add_func_load("/api/place/set_image_n",
653 utc_maps_place_set_image_n, i);
654 __test_add_func_load("/api/place/set_review_p",
655 utc_maps_place_set_review_p, i);
656 __test_add_func_load("/api/place/set_review_n",
657 utc_maps_place_set_review_n, i);
658 __test_add_func_load("/api/place/set_properties_p",
659 utc_maps_place_set_properties_p, i);
660 __test_add_func_load("/api/place/set_properties_n",
661 utc_maps_place_set_properties_n, i);
662 __test_add_func_load("/api/place/set_rating_p",
663 utc_maps_place_set_rating_p, i);
664 __test_add_func_load("/api/place/set_rating_n",
665 utc_maps_place_set_rating_n, i);
666 __test_add_func_load("/api/place/set_supplier_link_p",
667 utc_maps_place_set_supplier_link_p, i);
668 __test_add_func_load("/api/place/set_supplier_link_n",
669 utc_maps_place_set_supplier_link_n, i);
670 __test_add_func_load("/api/place/set_related_link_p",
671 utc_maps_place_set_related_link_p, i);
672 __test_add_func_load("/api/place/set_related_link_n",
673 utc_maps_place_set_related_link_n, i);
674 __test_add_func_load("/api/place/foreach_property_p",
675 utc_maps_place_foreach_property_p, i);
676 __test_add_func_load("/api/place/foreach_property_n",
677 utc_maps_place_foreach_property_n, i);
681 static void __add_route_data_structure_tests(int i)
683 #ifndef SUPPRESS_VALGRIND_WARNINGS /* Valgrind warnings!!! */
684 /* API: Data Structures: Route: Maneuver */
685 __test_add_func_load("/api/route/maneuver/create_p",
686 utc_maps_route_maneuver_create_p, i);
687 __test_add_func_load("/api/route/maneuver/create_n",
688 utc_maps_route_maneuver_create_n, i);
689 __test_add_func_load("/api/route/maneuver/clone_p",
690 utc_maps_route_maneuver_clone_p, i);
691 __test_add_func_load("/api/route/maneuver/clone_n",
692 utc_maps_route_maneuver_clone_n, i);
693 __test_add_func_load("/api/route/maneuver/direction_p",
694 utc_maps_route_maneuver_direction_id_p, i);
695 __test_add_func_load("/api/route/maneuver/direction_n",
696 utc_maps_route_maneuver_direction_id_n, i);
697 __test_add_func_load("/api/route/maneuver/turn_type_p",
698 utc_maps_route_maneuver_turn_type_p, i);
699 __test_add_func_load("/api/route/maneuver/turn_type_n",
700 utc_maps_route_maneuver_turn_type_n, i);
701 __test_add_func_load("/api/route/maneuver/position_p",
702 utc_maps_route_maneuver_position_p, i);
703 __test_add_func_load("/api/route/maneuver/position_n",
704 utc_maps_route_maneuver_position_n, i);
705 __test_add_func_load("/api/route/maneuver/road_name_p",
706 utc_maps_route_maneuver_road_name_p, i);
707 __test_add_func_load("/api/route/maneuver/road_name_n",
708 utc_maps_route_maneuver_road_name_n, i);
709 __test_add_func_load("/api/route/maneuver/locale_p",
710 utc_maps_route_maneuver_locale_p, i);
711 __test_add_func_load("/api/route/maneuver/locale_n",
712 utc_maps_route_maneuver_locale_n, i);
713 __test_add_func_load("/api/route/maneuver/time_to_next_instruction_p",
714 utc_maps_route_maneuver_time_to_next_instruction_p, i);
715 __test_add_func_load("/api/route/maneuver/time_to_next_instruction_n",
716 utc_maps_route_maneuver_time_to_next_instruction_n, i);
718 ("/api/route/maneuver/distance_to_next_instruction_p",
719 utc_maps_route_maneuver_distance_to_next_instruction_p, i);
721 ("/api/route/maneuver/distance_to_next_instruction_n",
722 utc_maps_route_maneuver_distance_to_next_instruction_n, i);
723 __test_add_func_load("/api/route/maneuver/instruction_text_p",
724 utc_maps_route_maneuver_instruction_text_p, i);
725 __test_add_func_load("/api/route/maneuver/instruction_text_n",
726 utc_maps_route_maneuver_instruction_text_n, i);
728 /* API: Data Structures: Route: Segment */
729 __test_add_func_load("/api/route/segment/create_p",
730 utc_maps_route_segment_create_p, i);
731 __test_add_func_load("/api/route/segment/create_n",
732 utc_maps_route_segment_create_n, i);
733 __test_add_func_load("/api/route/segment/clone_p",
734 utc_maps_route_segment_clone_p, i);
735 __test_add_func_load("/api/route/segment/clone_n",
736 utc_maps_route_segment_clone_n, i);
737 __test_add_func_load("/api/route/segment/origin_p",
738 utc_maps_route_segment_origin_p, i);
739 __test_add_func_load("/api/route/segment/origin_n",
740 utc_maps_route_segment_origin_n, i);
741 __test_add_func_load("/api/route/segment/destination_p",
742 utc_maps_route_segment_destination_p, i);
743 __test_add_func_load("/api/route/segment/destination_n",
744 utc_maps_route_segment_destination_n, i);
745 __test_add_func_load("/api/route/segment/bounding_box_p",
746 utc_maps_route_segment_bounding_box_p, i);
747 __test_add_func_load("/api/route/segment/bounding_box_n",
748 utc_maps_route_segment_bounding_box_n, i);
749 __test_add_func_load("/api/route/segment/distance_p",
750 utc_maps_route_segment_distance_p, i);
751 __test_add_func_load("/api/route/segment/distance_n",
752 utc_maps_route_segment_distance_n, i);
753 __test_add_func_load("/api/route/segment/duration_p",
754 utc_maps_route_segment_duration_p, i);
755 __test_add_func_load("/api/route/segment/duration_n",
756 utc_maps_route_segment_duration_n, i);
757 __test_add_func_load("/api/route/segment/path_p",
758 utc_maps_route_segment_path_p, i);
759 __test_add_func_load("/api/route/segment/path_n",
760 utc_maps_route_segment_path_n, i);
761 __test_add_func_load("/api/route/segment/maneuvers_p",
762 utc_maps_route_segment_maneuvers_p, i);
763 __test_add_func_load("/api/route/segment/maneuvers_n",
764 utc_maps_route_segment_maneuvers_n, i);
766 /* API: Data Structures: Route */
767 __test_add_func_load("/api/route/create_p", utc_maps_route_create_p, i);
768 __test_add_func_load("/api/route/create_n", utc_maps_route_create_n, i);
769 __test_add_func_load("/api/route/clone_p", utc_maps_route_clone_p, i);
770 __test_add_func_load("/api/route/clone_n", utc_maps_route_clone_n, i);
771 __test_add_func_load("/api/route/route_id_p", utc_maps_route_route_id_p,
773 __test_add_func_load("/api/route/route_id_n", utc_maps_route_route_id_n,
775 __test_add_func_load("/api/route/origin_p", utc_maps_route_origin_p, i);
776 __test_add_func_load("/api/route/origin_n", utc_maps_route_origin_n, i);
777 __test_add_func_load("/api/route/destination_p",
778 utc_maps_route_destination_p, i);
779 __test_add_func_load("/api/route/destination_n",
780 utc_maps_route_destination_n, i);
781 __test_add_func_load("/api/route/bounding_box_p",
782 utc_maps_route_bounding_box_p, i);
783 __test_add_func_load("/api/route/bounding_box_n",
784 utc_maps_route_bounding_box_n, i);
785 __test_add_func_load("/api/route/transport_mode_p",
786 utc_maps_route_transport_mode_p, i);
787 __test_add_func_load("/api/route/transport_mode_n",
788 utc_maps_route_transport_mode_n, i);
789 __test_add_func_load("/api/route/total_distance_p",
790 utc_maps_route_total_distance_p, i);
791 __test_add_func_load("/api/route/total_distance_n",
792 utc_maps_route_total_distance_n, i);
793 __test_add_func_load("/api/route/total_duration_p",
794 utc_maps_route_total_duration_p, i);
795 __test_add_func_load("/api/route/total_duration_n",
796 utc_maps_route_total_duration_n, i);
797 __test_add_func_load("/api/route/distance_unit_p",
798 utc_maps_route_distance_unit_p, i);
799 __test_add_func_load("/api/route/distance_unit_n",
800 utc_maps_route_distance_unit_n, i);
801 __test_add_func_load("/api/route/path_p", utc_maps_route_path_p, i);
802 __test_add_func_load("/api/route/path_n", utc_maps_route_path_n, i);
803 __test_add_func_load("/api/route/segments_p", utc_maps_route_segments_p,
805 __test_add_func_load("/api/route/segments_n", utc_maps_route_segments_n,
807 __test_add_func_load("/api/route/properties_p",
808 utc_maps_route_properties_p, i);
809 __test_add_func_load("/api/route/properties_n",
810 utc_maps_route_properties_n, i);
814 static void __add_preference_data_structure_tests(int i)
816 #ifndef SUPPRESS_VALGRIND_WARNINGS /* Valgrind warnings!!! */
817 /* API: Data Structures: Route: Maneuver */
818 __test_add_func_load("/api/preference/create_p",
819 utc_maps_preference_create_p, i);
820 __test_add_func_load("/api/preference/create_n",
821 utc_maps_preference_create_n, i);
822 __test_add_func_load("/api/preference/clone_p",
823 utc_maps_preference_clone_p, i);
824 __test_add_func_load("/api/preference/clone_n",
825 utc_maps_preference_clone_n, i);
826 __test_add_func_load("/api/preference/distance_unit_p",
827 utc_maps_preference_distance_unit_p, i);
828 __test_add_func_load("/api/preference/distance_unit_n",
829 utc_maps_preference_distance_unit_n, i);
830 __test_add_func_load("/api/preference/language_p",
831 utc_maps_preference_language_p, i);
832 __test_add_func_load("/api/preference/language_n",
833 utc_maps_preference_language_n, i);
834 __test_add_func_load("/api/preference/max_results_p",
835 utc_maps_preference_max_results_p, i);
836 __test_add_func_load("/api/preference/max_results_n",
837 utc_maps_preference_max_results_n, i);
838 __test_add_func_load("/api/preference/country_code_p",
839 utc_maps_preference_country_code_p, i);
840 __test_add_func_load("/api/preference/country_code_n",
841 utc_maps_preference_country_code_n, i);
842 __test_add_func_load("/api/preference/route_optimization_p",
843 utc_maps_preference_route_optimization_p, i);
844 __test_add_func_load("/api/preference/route_optimization_n",
845 utc_maps_preference_route_optimization_n, i);
846 __test_add_func_load("/api/preference/route_transport_mode_p",
847 utc_maps_preference_route_transport_mode_p, i);
848 __test_add_func_load("/api/preference/route_transport_mode_n",
849 utc_maps_preference_route_transport_mode_n, i);
850 __test_add_func_load("/api/preference/route_feature_weight_p",
851 utc_maps_preference_route_feature_weight_p, i);
852 __test_add_func_load("/api/preference/route_feature_weight_n",
853 utc_maps_preference_route_feature_weight_n, i);
854 __test_add_func_load("/api/preference/route_feature_p",
855 utc_maps_preference_route_feature_p, i);
856 __test_add_func_load("/api/preference/route_feature_n",
857 utc_maps_preference_route_feature_n, i);
858 __test_add_func_load("/api/preference/property_p",
859 utc_maps_preference_property_p, i);
860 __test_add_func_load("/api/preference/property_n",
861 utc_maps_preference_property_n, i);
862 __test_add_func_load("/api/preference/clone_p",
863 utc_maps_preference_clone_p, i);
864 __test_add_func_load("/api/preference/clone_n",
865 utc_maps_preference_clone_n, i);
866 __test_add_func_load("/api/preference/clone_p",
867 utc_maps_preference_clone_p, i);
868 __test_add_func_load("/api/preference/clone_n",
869 utc_maps_preference_clone_n, i);
874 static void __add_maps_api_tests(int i)
876 #ifndef SUPPRESS_VALGRIND_WARNINGS /* Valgrind warnings!!! */
878 if (1) { /* Create and destroy Maps Service */
879 __test_add_func_load("/api/maps_service/create_destroy_p",
880 utc_maps_service_create_destroy_p, i);
883 if (1) { /* API: Preferences and Capabilities */
884 __test_add_func_load("/api/provider_key/set_get_p",
885 utc_maps_provider_key_p, i);
886 __test_add_func_load("/api/provider_key/set_get_n",
887 utc_maps_provider_key_n, i);
888 __test_add_func_load("/api/preference/set_p",
889 utc_maps_service_set_preference_p, i);
890 __test_add_func_load("/api/preference/set_n",
891 utc_maps_service_set_preference_n, i);
892 __test_add_func_load("/api/get_provider_capabilities_p",
893 utc_maps_service_provider_is_service_supported_p, i);
894 __test_add_func_load("/api/get_provider_capabilities_n",
895 utc_maps_service_provider_is_service_supported_n, i);
896 __test_add_func_load("/api/service_support_feature_p",
897 utc_maps_service_provider_is_data_supported_p, i);
898 __test_add_func_load("/api/service_support_feature_n",
899 utc_maps_service_provider_is_data_supported_n, i);
902 if (1) { /* API: Geocode */
903 __test_add_func_load("/api/geocode_p",
904 utc_maps_service_geocode_p, i);
905 __test_add_func_load("/api/geocode_n",
906 utc_maps_service_geocode_n, i);
907 __test_add_func_load("/api/geocode_inside_bounds_p",
908 utc_maps_service_geocode_inside_area_p, i);
909 __test_add_func_load("/api/geocode_inside_bounds_n",
910 utc_maps_service_geocode_inside_area_n, i);
911 __test_add_func_load("/api/geocode_by_structured_address_p",
912 utc_maps_service_geocode_by_structured_address_p, i);
913 __test_add_func_load("/api/geocode_by_structured_address_n",
914 utc_maps_service_geocode_by_structured_address_n, i);
915 __test_add_func_load("/api/reverse_geocode_p",
916 utc_maps_service_reverse_geocode_p, i);
917 __test_add_func_load("/api/reverse_geocode_n",
918 utc_maps_service_reverse_geocode_n, i);
919 __test_add_func_load("/api/cancel_geocode_p",
920 utc_maps_cancel_geocode_p, i);
921 __test_add_func_load("/api/cancel_geocode_p02",
922 utc_maps_cancel_geocode_p02, i);
923 __test_add_func_load("/api/cancel_geocode_n",
924 utc_maps_cancel_geocode_n, i);
925 __test_add_func_load("/api/cancel_reverse_geocode_p",
926 utc_maps_cancel_reverse_geocode_p, i);
927 __test_add_func_load("/api/cancel_reverse_geocode_n",
928 utc_maps_cancel_reverse_geocode_n, i);
931 if (1) { /* API: Place */
932 __test_add_func_load("/api/place/search_p",
933 utc_maps_service_search_place_p, i);
934 __test_add_func_load("/api/place/search_p",
935 utc_maps_service_search_place_p, i);
936 __test_add_func_load("/api/place/search_n",
937 utc_maps_service_search_place_n, i);
938 __test_add_func_load("/api/place/search_by_area_p",
939 utc_maps_service_search_place_by_area_p, i);
940 __test_add_func_load("/api/place/search_by_area_n",
941 utc_maps_service_search_place_by_area_n, i);
942 __test_add_func_load("/api/place/search_by_address_p",
943 utc_maps_service_search_place_by_address_p, i);
944 __test_add_func_load("/api/place/search_by_address_n",
945 utc_maps_service_search_place_by_address_n, i);
946 __test_add_func_load("/api/place/cancel_search_p",
947 utc_maps_cancel_place_p, i);
948 __test_add_func_load("/api/place/cancel_search_n",
949 utc_maps_cancel_place_n, i);
952 if (1) { /* API: Route */
953 __test_add_func_load("/api/route/search_p",
954 utc_maps_service_search_route_p, i);
955 __test_add_func_load("/api/route/search_n",
956 utc_maps_service_search_route_n, i);
957 __test_add_func_load("/api/route/search_waypoints_p",
958 utc_maps_service_search_route_waypoints_p, i);
959 __test_add_func_load("/api/route/search_waypoints_n",
960 utc_maps_service_search_route_waypoints_n, i);
961 __test_add_func_load("/api/route/cancel_search_p",
962 utc_maps_cancel_route_p, i);
963 __test_add_func_load("/api/route/cancel_search_n",
964 utc_maps_cancel_route_n, i);
968 __test_add_func_load("/api/route/search_realistic_p",
969 utc_maps_service_search_route_real_p, i);
972 __test_add_func_load("/api/serial_p",
973 utc_maps_service_serial_p, i);
979 int main(int argc, char **argv)
981 /* Testing the tutorial */
982 _maps_service_main_tutorial();
985 g_print("***********************************************\n");
986 g_print("* Maps Service Unit Test Cases\n");
987 g_print("***********************************************\n");
990 #ifdef MAPS_SERVICE_CORRECTNESS_TEST
991 g_test_init(&argc, &argv, NULL);
992 #endif /*MAPS_SERVICE_CORRECTNESS_TEST */
994 #ifndef MAPS_SERVICE_LOAD_TEST
995 iterations = 1; /* No needed too much iterations for correctness
996 of memory leak tests */
997 #endif /* MAPS_SERVICE_LOAD_TEST */
1000 while (iterations-- > 0) {
1004 __test_add_func_load("/techno/simple_test",
1005 __utc_simple_test, i);
1007 /* Plugin Management */
1009 __add_plugin_tests(i);
1011 /* Session Management */
1013 __add_session_tests(i);
1015 /* API: Extra Data Structures: List */
1017 __add_extra_data_structure_tests(i);
1019 /* API: Maps Data Structures: Coordinates, Area */
1021 __add_maps_data_structure_tests(i);
1023 /* API: Geocode Data Structures: Address */
1025 __add_geocode_data_structure_tests(i);
1027 /* API: Place Data Structures: Category, Attribute, Contact,
1028 * Editorial, Link Object, Media, URL, Review, Rating, Image,
1031 __add_place_data_structure_tests(i);
1033 /* API: Route Data Structures: Maneuver, Segment, Route */
1035 __add_route_data_structure_tests(i);
1037 /* API: Preference Data Structure */
1039 __add_preference_data_structure_tests(i);
1041 /* API: Preference and Capabilities, Geocode, Place, Route */
1043 __add_maps_api_tests(i);
1047 #ifdef MAPS_SERVICE_LOAD_TEST
1048 if (sleep_microseconds > 0)
1049 usleep(sleep_microseconds);
1050 #endif /* MAPS_SERVICE_LOAD_TEST */
1053 #ifdef MAPS_SERVICE_CORRECTNESS_TEST
1054 return g_test_run();
1057 #endif /* MAPS_SERVICE_CORRECTNESS_TEST */