Release Tizen2.0 beta
[framework/api/location-manager.git] / TC / testcase / utc_location_location_manager.c
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <tet_api.h>
18 #include <locations.h>
19 #include <glib.h>
20
21 enum {
22         POSITIVE_TC_IDX = 0x01,
23         NEGATIVE_TC_IDX,
24 };
25
26 static void startup(void);
27 static void cleanup(void);
28
29 void (*tet_startup) (void) = startup;
30 void (*tet_cleanup) (void) = cleanup;
31
32 static void utc_location_location_manager_create_p(void);
33 static void utc_location_location_manager_create_p_02(void);
34 static void utc_location_location_manager_create_p_03(void);
35 static void utc_location_location_manager_create_p_04(void);
36 static void utc_location_location_manager_create_p_05(void);
37 static void utc_location_location_manager_create_n(void);
38 static void utc_location_location_manager_create_n_02(void);
39 static void utc_location_location_manager_create_n_03(void);
40 static void utc_location_location_manager_create_n_04(void);
41 static void utc_location_location_manager_create_n_05(void);
42 static void utc_location_location_manager_create_n_06(void);
43 static void utc_location_location_manager_add_boundary_p(void);
44 static void utc_location_location_manager_add_boundary_n(void);
45 static void utc_location_location_manager_add_boundary_n_02(void);
46 static void utc_location_location_manager_add_boundary_n_03(void);
47 static void utc_location_location_manager_add_boundary_n_04(void);
48 static void utc_location_location_manager_foreach_boundary_p(void);
49 static void utc_location_location_manager_foreach_boundary_n(void);
50 static void utc_location_location_manager_foreach_boundary_n_02(void);
51 static void utc_location_location_manager_foreach_boundary_n_03(void);
52 static void utc_location_location_manager_foreach_boundary_n_04(void);
53 static void utc_location_location_manager_remove_boundary_p(void);
54 static void utc_location_location_manager_remove_boundary_n(void);
55 static void utc_location_location_manager_remove_boundary_n_02(void);
56 static void utc_location_location_manager_remove_boundary_n_03(void);
57 static void utc_location_location_manager_remove_boundary_n_04(void);
58 static void utc_location_location_manager_get_method_p(void);
59 static void utc_location_location_manager_get_method_n(void);
60 static void utc_location_location_manager_get_method_n_02(void);
61 static void utc_location_location_manager_get_method_n_03(void);
62 static void utc_location_location_manager_get_method_n_04(void);
63 static void utc_location_location_manager_get_position_p(void);
64 static void utc_location_location_manager_get_position_n(void);
65 static void utc_location_location_manager_get_position_n_02(void);
66 static void utc_location_location_manager_get_position_n_03(void);
67 static void utc_location_location_manager_get_position_n_04(void);
68 static void utc_location_location_manager_get_position_n_05(void);
69 static void utc_location_location_manager_get_position_n_06(void);
70 static void utc_location_location_manager_get_velocity_p(void);
71 static void utc_location_location_manager_get_velocity_n(void);
72 static void utc_location_location_manager_get_velocity_n_02(void);
73 static void utc_location_location_manager_get_velocity_n_03(void);
74 static void utc_location_location_manager_get_velocity_n_04(void);
75 static void utc_location_location_manager_get_velocity_n_05(void);
76 static void utc_location_location_manager_get_velocity_n_06(void);
77 static void utc_location_location_manager_get_accuracy_p(void);
78 static void utc_location_location_manager_get_accuracy_n(void);
79 static void utc_location_location_manager_get_accuracy_n_02(void);
80 static void utc_location_location_manager_get_accuracy_n_03(void);
81 static void utc_location_location_manager_get_accuracy_n_04(void);
82 static void utc_location_location_manager_get_accuracy_n_05(void);
83 static void utc_location_location_manager_get_accuracy_n_06(void);
84 static void utc_location_location_bounds_foreach_polygon_coords_p(void);
85 static void utc_location_location_bounds_foreach_polygon_coords_n(void);
86 static void utc_location_location_bounds_foreach_polygon_coords_n_02(void);
87 static void utc_location_location_bounds_get_circle_coords_p(void);
88 static void utc_location_location_bounds_get_circle_coords_n(void);
89 static void utc_location_location_bounds_get_circle_coords_n_02(void);
90 static void utc_location_location_bounds_get_circle_coords_n_03(void);
91 static void utc_location_location_bounds_get_rect_coords_p(void);
92 static void utc_location_location_bounds_get_rect_coords_n(void);
93 static void utc_location_location_bounds_get_rect_coords_n_02(void);
94 static void utc_location_location_bounds_get_rect_coords_n_03(void);
95 static void utc_location_location_bounds_contains_coordinates_p(void);
96 static void utc_location_location_bounds_contains_coordinates_p_02(void);
97 static void utc_location_location_bounds_contains_coordinates_n(void);
98 static void utc_location_location_bounds_contains_coordinates_n_02(void);
99 static void utc_location_location_manager_get_last_accuracy_p(void);
100 static void utc_location_location_manager_get_last_accuracy_n(void);
101 static void utc_location_location_manager_get_last_accuracy_n_02(void);
102 static void utc_location_location_manager_get_last_accuracy_n_03(void);
103 static void utc_location_location_manager_get_last_accuracy_n_04(void);
104 static void utc_location_location_manager_get_last_position_p(void);
105 static void utc_location_location_manager_get_last_position_n(void);
106 static void utc_location_location_manager_get_last_position_n_02(void);
107 static void utc_location_location_manager_get_last_position_n_03(void);
108 static void utc_location_location_manager_get_last_position_n_04(void);
109 static void utc_location_location_manager_get_last_position_n_05(void);
110 static void utc_location_location_manager_get_last_velocity_p(void);
111 static void utc_location_location_manager_get_last_velocity_n(void);
112 static void utc_location_location_manager_get_last_velocity_n_02(void);
113 static void utc_location_location_manager_get_last_velocity_n_03(void);
114 static void utc_location_location_manager_get_last_velocity_n_04(void);
115 static void utc_location_location_manager_get_last_velocity_n_05(void);
116 static void utc_location_location_manager_is_supported_method_p(void);
117 static void utc_location_location_manager_is_supported_method_p_02(void);
118 static void utc_location_location_manager_is_supported_method_p_03(void);
119 static void utc_location_location_manager_is_supported_method_p_04(void);
120 static void utc_location_location_manager_is_supported_method_n(void);
121 static void utc_location_location_manager_is_supported_method_n_02(void);
122 static void utc_location_location_manager_send_command_p(void);
123 static void utc_location_location_manager_send_command_n(void);
124 static void utc_location_location_manager_destroy_p(void);
125 static void utc_location_location_manager_destroy_n(void);
126 static void utc_location_location_manager_destroy_n_02(void);
127
128 struct tet_testlist tet_testlist[] = {
129         {utc_location_location_manager_create_p, POSITIVE_TC_IDX},
130         {utc_location_location_manager_create_p_02, POSITIVE_TC_IDX},
131         {utc_location_location_manager_create_p_03, POSITIVE_TC_IDX},
132       { utc_location_location_manager_create_p_04, POSITIVE_TC_IDX },
133 //      { utc_location_location_manager_create_p_05, POSITIVE_TC_IDX }, // LOCATIONS_METHOD_NONE is a negative TC.
134         {utc_location_location_manager_create_n, NEGATIVE_TC_IDX},
135         {utc_location_location_manager_create_n_02, NEGATIVE_TC_IDX},
136         {utc_location_location_manager_create_n_03, NEGATIVE_TC_IDX},
137         {utc_location_location_manager_create_n_04, NEGATIVE_TC_IDX},
138         {utc_location_location_manager_create_n_05, NEGATIVE_TC_IDX},
139         {utc_location_location_manager_create_n_06, NEGATIVE_TC_IDX},
140         {utc_location_location_manager_add_boundary_p, POSITIVE_TC_IDX},
141         {utc_location_location_manager_add_boundary_n, NEGATIVE_TC_IDX},
142         {utc_location_location_manager_add_boundary_n_02, NEGATIVE_TC_IDX},
143         {utc_location_location_manager_add_boundary_n_03, NEGATIVE_TC_IDX},
144         {utc_location_location_manager_add_boundary_n_04, NEGATIVE_TC_IDX},
145         {utc_location_location_manager_foreach_boundary_p, POSITIVE_TC_IDX},
146         {utc_location_location_manager_foreach_boundary_n, NEGATIVE_TC_IDX},
147         {utc_location_location_manager_foreach_boundary_n_02, NEGATIVE_TC_IDX},
148 //      { utc_location_location_manager_foreach_boundary_n_03, NEGATIVE_TC_IDX }, // Can't check created location_manager_h
149         {utc_location_location_manager_foreach_boundary_n_04, NEGATIVE_TC_IDX},
150         {utc_location_location_manager_remove_boundary_p, POSITIVE_TC_IDX},
151         {utc_location_location_manager_remove_boundary_n, NEGATIVE_TC_IDX},
152         {utc_location_location_manager_remove_boundary_n_02, NEGATIVE_TC_IDX},
153 //      { utc_location_location_manager_remove_boundary_n_03, NEGATIVE_TC_IDX },  // Can't check created location_manager_h
154         {utc_location_location_manager_remove_boundary_n_04, NEGATIVE_TC_IDX},
155         {utc_location_location_manager_get_method_p, POSITIVE_TC_IDX},
156         {utc_location_location_manager_get_method_n, NEGATIVE_TC_IDX},
157         {utc_location_location_manager_get_method_n_02, NEGATIVE_TC_IDX},
158         {utc_location_location_manager_get_method_n_03, NEGATIVE_TC_IDX},
159 //      { utc_location_location_manager_get_method_n_04, NEGATIVE_TC_IDX }, // Can't check created location_manager_h
160         {utc_location_location_manager_get_position_p, POSITIVE_TC_IDX},
161         {utc_location_location_manager_get_position_n, NEGATIVE_TC_IDX},
162         {utc_location_location_manager_get_position_n_02, NEGATIVE_TC_IDX},
163 //      { utc_location_location_manager_get_position_n_03, NEGATIVE_TC_IDX },  // Can't check created location_manager_h
164         {utc_location_location_manager_get_position_n_04, NEGATIVE_TC_IDX},
165         {utc_location_location_manager_get_position_n_05, NEGATIVE_TC_IDX},
166         {utc_location_location_manager_get_position_n_06, NEGATIVE_TC_IDX},
167         {utc_location_location_manager_get_velocity_p, POSITIVE_TC_IDX},
168         {utc_location_location_manager_get_velocity_n, NEGATIVE_TC_IDX},
169         {utc_location_location_manager_get_velocity_n_02, NEGATIVE_TC_IDX},
170 //      { utc_location_location_manager_get_velocity_n_03, NEGATIVE_TC_IDX }, // Can't check created location_manager_h
171         {utc_location_location_manager_get_velocity_n_04, NEGATIVE_TC_IDX},
172         {utc_location_location_manager_get_velocity_n_05, NEGATIVE_TC_IDX},
173         {utc_location_location_manager_get_velocity_n_06, NEGATIVE_TC_IDX},
174         {utc_location_location_manager_get_accuracy_p, POSITIVE_TC_IDX},
175         {utc_location_location_manager_get_accuracy_n, NEGATIVE_TC_IDX},
176         {utc_location_location_manager_get_accuracy_n_02, NEGATIVE_TC_IDX},
177 //      { utc_location_location_manager_get_accuracy_n_03, NEGATIVE_TC_IDX }, // Can't check created location_manager_h
178         {utc_location_location_manager_get_accuracy_n_04, NEGATIVE_TC_IDX},
179         {utc_location_location_manager_get_accuracy_n_05, NEGATIVE_TC_IDX},
180         {utc_location_location_manager_get_accuracy_n_06, NEGATIVE_TC_IDX},
181         {utc_location_location_bounds_foreach_polygon_coords_p, POSITIVE_TC_IDX},
182         {utc_location_location_bounds_foreach_polygon_coords_n, NEGATIVE_TC_IDX},
183         {utc_location_location_bounds_foreach_polygon_coords_n_02, NEGATIVE_TC_IDX},
184         {utc_location_location_bounds_get_circle_coords_p, POSITIVE_TC_IDX},
185         {utc_location_location_bounds_get_circle_coords_n, NEGATIVE_TC_IDX},
186         {utc_location_location_bounds_get_circle_coords_n_02, NEGATIVE_TC_IDX},
187         {utc_location_location_bounds_get_circle_coords_n_03, NEGATIVE_TC_IDX},
188         {utc_location_location_bounds_get_rect_coords_p, POSITIVE_TC_IDX},
189         {utc_location_location_bounds_get_rect_coords_n, NEGATIVE_TC_IDX},
190         {utc_location_location_bounds_get_rect_coords_n_02, NEGATIVE_TC_IDX},
191         {utc_location_location_bounds_get_rect_coords_n_03, NEGATIVE_TC_IDX},
192         {utc_location_location_bounds_contains_coordinates_p, POSITIVE_TC_IDX},
193         {utc_location_location_bounds_contains_coordinates_p_02, POSITIVE_TC_IDX},
194         {utc_location_location_bounds_contains_coordinates_n, NEGATIVE_TC_IDX},
195         {utc_location_location_bounds_contains_coordinates_n_02, NEGATIVE_TC_IDX},
196         {utc_location_location_manager_get_last_accuracy_p, POSITIVE_TC_IDX},
197         {utc_location_location_manager_get_last_accuracy_n, NEGATIVE_TC_IDX},
198         {utc_location_location_manager_get_last_accuracy_n_02, NEGATIVE_TC_IDX},
199         {utc_location_location_manager_get_last_accuracy_n_03, NEGATIVE_TC_IDX},
200         {utc_location_location_manager_get_last_accuracy_n_04, NEGATIVE_TC_IDX},
201         {utc_location_location_manager_get_last_position_p, POSITIVE_TC_IDX},
202         {utc_location_location_manager_get_last_position_n, NEGATIVE_TC_IDX},
203         {utc_location_location_manager_get_last_position_n_02, NEGATIVE_TC_IDX},
204         {utc_location_location_manager_get_last_position_n_03, NEGATIVE_TC_IDX},
205         {utc_location_location_manager_get_last_position_n_04, NEGATIVE_TC_IDX},
206         {utc_location_location_manager_get_last_position_n_05, NEGATIVE_TC_IDX},
207         {utc_location_location_manager_get_last_velocity_p, POSITIVE_TC_IDX},
208         {utc_location_location_manager_get_last_velocity_n, NEGATIVE_TC_IDX},
209         {utc_location_location_manager_get_last_velocity_n_02, NEGATIVE_TC_IDX},
210         {utc_location_location_manager_get_last_velocity_n_03, NEGATIVE_TC_IDX},
211         {utc_location_location_manager_get_last_velocity_n_04, NEGATIVE_TC_IDX},
212         {utc_location_location_manager_get_last_velocity_n_05, NEGATIVE_TC_IDX},
213         {utc_location_location_manager_is_supported_method_p, POSITIVE_TC_IDX},
214         {utc_location_location_manager_is_supported_method_p_02, POSITIVE_TC_IDX},
215         {utc_location_location_manager_is_supported_method_p_03, POSITIVE_TC_IDX},
216         {utc_location_location_manager_is_supported_method_p_04, POSITIVE_TC_IDX},
217         {utc_location_location_manager_is_supported_method_n, NEGATIVE_TC_IDX},
218         {utc_location_location_manager_is_supported_method_n_02, NEGATIVE_TC_IDX},
219         {utc_location_location_manager_destroy_p, POSITIVE_TC_IDX},
220         {utc_location_location_manager_destroy_n, NEGATIVE_TC_IDX},
221 //      { utc_location_location_manager_destroy_n_02, NEGATIVE_TC_IDX }, // Can't check created location_manager_h
222         {NULL, 0},
223 };
224
225 static bool service_enabled = false;
226 static bool touch_foreach_bounds = false;
227
228 static GMainLoop *g_mainloop = NULL;
229 static GThread *event_thread;
230
231 gpointer GmainThread(gpointer data)
232 {
233         g_mainloop = g_main_loop_new(NULL, 0);
234         g_main_loop_run(g_mainloop);
235         return NULL;
236 }
237
238 static void validate_and_next(char *api_name, int act_ret, int ext_ret, char *fail_msg)
239 {
240         dts_message(api_name, "Actual Result : %d, Expected Result : %d", act_ret, ext_ret);
241         if (act_ret != ext_ret) {
242                 dts_message(api_name, "Fail Message: %s", fail_msg);
243                 dts_fail(api_name);
244         }
245 }
246
247 static void validate_eq(char *api_name, int act_ret, int ext_ret)
248 {
249         dts_message(api_name, "Actual Result : %d, Expected Result : %d", act_ret, ext_ret);
250         if (act_ret == ext_ret) {
251                 dts_pass(api_name);
252         } else {
253                 dts_fail(api_name);
254         }
255 }
256
257 static void wait_for_service(char *api_name)
258 {
259         int timeout = 0;
260         for (timeout; timeout < 60; timeout++) {
261                 if (service_enabled) {
262                         dts_message(api_name, "Location Service Enabled!!!!");
263                         break;
264                 } else {
265                         dts_message(api_name, "Location Service Disabled!!!!");
266                         sleep(1);
267                 }
268         }
269 }
270
271 static void wait_for_bounds_foreach(char *api_name)
272 {
273         int timeout = 0;
274         for (timeout; timeout < 30; timeout++) {
275                 if (touch_foreach_bounds) {
276                         dts_message(api_name, "bound foreach called!!!!");
277                         break;
278                 } else {
279                         dts_message(api_name, "No bound foreach!!!!");
280                         sleep(1);
281                 }
282         }
283 }
284
285 static void __state_changed_cb(location_service_state_e state, void *user_data)
286 {
287         switch (state) {
288         case LOCATIONS_SERVICE_ENABLED:
289                 service_enabled = true;
290                 break;
291         case LOCATIONS_SERVICE_DISABLED:
292                 service_enabled = false;
293                 break;
294         default:
295                 break;
296         }
297 }
298
299 static bool __location_bounds_cb(location_bounds_h bounds, void *user_data)
300 {
301         if (bounds == NULL)
302                 printf("bounds ==NULL\n");
303         else {
304                 location_bounds_type_e type;
305                 location_bounds_get_type(bounds, &type);
306                 dts_message(__func__, "__location_bounds_cb - type : %d!!!!", type);
307                 touch_foreach_bounds = TRUE;
308         }
309         return TRUE;
310 }
311
312 static location_manager_h manager;
313 static location_bounds_h bounds_rect;
314 static location_bounds_h bounds_circle;
315 static location_bounds_h bounds_poly;
316
317 static void startup(void)
318 {
319         g_setenv("PKG_NAME", "com.samsung.capi-location-manager-test", 1);
320         g_setenv("LOCATION_TEST_ENABLE", "1", 1);
321
322 #if !GLIB_CHECK_VERSION (2, 31, 0)
323         if (!g_thread_supported()) {
324                 g_thread_init(NULL);
325         }
326 #endif
327
328         event_thread = g_thread_create(GmainThread, NULL, 1, NULL);
329 }
330
331 static void cleanup(void)
332 {
333         if (manager) {
334                 location_manager_unset_service_state_changed_cb(manager);
335                 location_manager_stop(manager);
336                 location_manager_destroy(manager);
337                 manager = NULL;
338         }
339
340         service_enabled = false;
341         touch_foreach_bounds = false;
342         g_main_loop_quit(g_mainloop);
343         g_thread_join(event_thread);
344 }
345
346 static void utc_location_location_manager_create_p(void)
347 {
348         int ret;
349
350         ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager);
351         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed");
352
353         ret = location_manager_set_service_state_changed_cb(manager, __state_changed_cb, NULL);
354         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed");
355
356         ret = location_manager_start(manager);
357         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed");
358
359         wait_for_service(__func__);
360
361         /*
362            location_manager_stop(manager); //If you call start() and then stop(), service_enabled always set false.
363            location_manager_unset_service_state_changed_cb(manager);
364          */
365
366         validate_eq(__func__, service_enabled, true);
367 }
368
369 static void utc_location_location_manager_create_p_02(void)
370 {
371         int ret;
372         location_manager_h manager_02;
373
374         ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager_02);
375
376         /* We don't need it
377            validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed");
378
379            ret = location_manager_set_service_state_changed_cb(manager_02, __state_changed_cb, NULL);
380            validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed");
381
382            ret = location_manager_start(manager_02);
383            validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed");
384
385            wait_for_service(__func__);
386
387            location_manager_stop(manager_02);
388            location_manager_unset_service_state_changed_cb(manager_02);
389          */
390
391         location_manager_destroy(manager_02);
392
393         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
394 }
395
396 static void utc_location_location_manager_create_p_03(void)
397 {
398         int ret;
399         location_manager_h manager_02;
400
401         ret = location_manager_create(LOCATIONS_METHOD_WPS, &manager_02);
402
403         /* We don't need it
404            validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed");
405
406            ret = location_manager_set_service_state_changed_cb(manager_02, __state_changed_cb, NULL);
407            validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed");
408
409            ret = location_manager_start(manager_02);
410            validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed");
411
412            wait_for_service(__func__);
413
414            location_manager_stop(manager_02);
415            location_manager_unset_service_state_changed_cb(manager_02);
416          */
417
418         location_manager_destroy(manager_02);
419
420         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
421 }
422
423 static void utc_location_location_manager_create_p_04(void)
424 {
425         int ret;
426         location_manager_h manager_02;
427
428         ret = location_manager_create(LOCATIONS_METHOD_CPS, &manager_02);
429         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed");
430
431         ret = location_manager_set_service_state_changed_cb(manager_02, __state_changed_cb, NULL);
432         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed");
433
434         ret = location_manager_start(manager_02);
435         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed");
436
437         wait_for_service(__func__);
438
439         location_manager_stop(manager_02);
440         location_manager_unset_service_state_changed_cb(manager_02);
441         location_manager_destroy(manager_02);
442
443         validate_eq(__func__, service_enabled, TRUE);
444 }
445
446 static void utc_location_location_manager_create_p_05(void)
447 {
448         int ret;
449         location_manager_h manager_02;
450
451         ret = location_manager_create(LOCATIONS_METHOD_NONE, &manager_02);
452         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed");
453
454         ret = location_manager_set_service_state_changed_cb(manager_02, __state_changed_cb, NULL);
455         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed");
456
457         ret = location_manager_start(manager_02);
458         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed");
459
460         wait_for_service(__func__);
461
462         location_manager_stop(manager_02);
463         location_manager_unset_service_state_changed_cb(manager_02);
464         location_manager_destroy(manager_02);
465
466         validate_eq(__func__, service_enabled, TRUE);
467 }
468
469 static void utc_location_location_manager_create_n(void)
470 {
471         int ret = LOCATIONS_ERROR_NONE;
472
473         ret = location_manager_create(LOCATIONS_METHOD_HYBRID, NULL);
474         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
475
476 }
477
478 static void utc_location_location_manager_create_n_02(void)
479 {
480         int ret = LOCATIONS_ERROR_NONE;
481
482         ret = location_manager_create(LOCATIONS_METHOD_NONE, NULL);
483         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
484
485 }
486
487 static void utc_location_location_manager_create_n_03(void)
488 {
489         int ret = LOCATIONS_ERROR_NONE;
490
491         ret = location_manager_create(LOCATIONS_METHOD_GPS, NULL);
492         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
493
494 }
495
496 static void utc_location_location_manager_create_n_04(void)
497 {
498         int ret = LOCATIONS_ERROR_NONE;
499
500         ret = location_manager_create(LOCATIONS_METHOD_WPS, NULL);
501         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
502
503 }
504
505 static void utc_location_location_manager_create_n_05(void)
506 {
507         int ret = LOCATIONS_ERROR_NONE;
508
509         ret = location_manager_create(LOCATIONS_METHOD_CPS, NULL);
510         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
511
512 }
513
514 static void utc_location_location_manager_create_n_06(void)
515 {
516         int ret = LOCATIONS_ERROR_NONE;
517         location_manager_h manager_02;
518
519         ret = location_manager_create(LOCATIONS_METHOD_CPS + 1, &manager_02);
520         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
521
522 }
523
524 static void utc_location_location_manager_add_boundary_p(void)
525 {
526         int ret = LOCATIONS_ERROR_NONE;
527
528         //Add the circle bounds
529         location_coords_s center;
530         center.latitude = 37.258;
531         center.longitude = 127.056;
532         double radius = 30;
533         ret = location_bounds_create_circle(center, radius, &bounds_circle);
534         validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_circle() is failed");
535
536         ret = location_manager_add_boundary(manager, bounds_circle);
537         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_add_boundary() is failed");
538
539         //Add the rect bounds
540         location_coords_s left_top;
541         left_top.latitude = 30;
542         left_top.longitude = 30;
543
544         location_coords_s right_bottom;
545         right_bottom.latitude = 10;
546         right_bottom.longitude = 50;
547
548         ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect);
549         validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_rect() is failed");
550
551         ret = location_manager_add_boundary(manager, bounds_rect);
552         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_add_boundary() is failed");
553
554         //Add the polygon bounds
555
556         int poly_size = 3;
557         location_coords_s coord_list[poly_size];
558
559         coord_list[0].latitude = 10;
560         coord_list[0].longitude = 10;
561         coord_list[1].latitude = 20;
562         coord_list[1].longitude = 20;
563         coord_list[2].latitude = 30;
564         coord_list[2].longitude = 30;
565
566         ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
567         validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_polygon() is failed");
568
569         ret = location_manager_add_boundary(manager, bounds_poly);
570         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
571 }
572
573 static void utc_location_location_manager_add_boundary_n(void)
574 {
575         int ret = LOCATIONS_ERROR_NONE;
576         ret = location_manager_add_boundary(NULL, NULL);
577         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
578 }
579
580 static void utc_location_location_manager_add_boundary_n_02(void)
581 {
582         int ret = LOCATIONS_ERROR_NONE;
583         ret = location_manager_add_boundary(manager, NULL);
584         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
585 }
586
587 static void utc_location_location_manager_add_boundary_n_03(void)
588 {
589         int ret = LOCATIONS_ERROR_NONE;
590
591         //Add the circle bounds
592         location_coords_s center;
593         center.latitude = 37.258;
594         center.longitude = 127.056;
595         double radius = 30;
596         ret = location_bounds_create_circle(center, radius, &bounds_circle);
597         validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_circle() is failed");
598
599         ret = location_manager_add_boundary(NULL, bounds_circle);
600         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
601 }
602
603 static void utc_location_location_manager_add_boundary_n_04(void)
604 {
605         int ret = LOCATIONS_ERROR_NONE;
606         location_manager_h manager_02;
607
608         //Add the circle bounds
609         location_coords_s center;
610         center.latitude = 37.258;
611         center.longitude = 127.056;
612         double radius = 30;
613         ret = location_bounds_create_circle(center, radius, &bounds_circle);
614         validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_circle() is failed");
615
616         ret = location_manager_add_boundary(manager_02, bounds_circle);
617         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
618 }
619
620 static void utc_location_location_manager_foreach_boundary_p(void)
621 {
622         int ret = LOCATIONS_ERROR_NONE;
623         ret = location_manager_foreach_boundary(manager, __location_bounds_cb, (void *)manager);
624         validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_manager_foreach_boundary() is failed");
625         wait_for_bounds_foreach(__func__);
626         validate_eq(__func__, touch_foreach_bounds, TRUE);
627 }
628
629 static void utc_location_location_manager_foreach_boundary_n(void)
630 {
631         int ret = LOCATIONS_ERROR_NONE;
632         ret = location_manager_foreach_boundary(NULL, NULL, NULL);
633         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
634 }
635
636 static void utc_location_location_manager_foreach_boundary_n_02(void)
637 {
638         int ret = LOCATIONS_ERROR_NONE;
639         ret = location_manager_foreach_boundary(NULL, __location_bounds_cb, (void *)manager);
640         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
641 }
642
643 static void utc_location_location_manager_foreach_boundary_n_03(void)
644 {
645         int ret = LOCATIONS_ERROR_NONE;
646         location_manager_h manager_02;
647         ret = location_manager_foreach_boundary(manager_02, __location_bounds_cb, (void *)manager);
648         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
649 }
650
651 static void utc_location_location_manager_foreach_boundary_n_04(void)
652 {
653         int ret = LOCATIONS_ERROR_NONE;
654         location_manager_h manager_02;
655         ret = location_manager_foreach_boundary(manager, NULL, NULL);
656         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
657 }
658
659 static void utc_location_location_manager_remove_boundary_p(void)
660 {
661         int ret = LOCATIONS_ERROR_NONE;
662         ret = location_manager_remove_boundary(manager, bounds_rect);
663         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_remove_boundary(rect) is failed");
664         ret = location_manager_remove_boundary(manager, bounds_circle);
665         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_remove_boundary(circle) is failed");
666         ret = location_manager_remove_boundary(manager, bounds_poly);
667         location_bounds_destroy(bounds_rect);
668         location_bounds_destroy(bounds_circle);
669         location_bounds_destroy(bounds_poly);
670         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
671 }
672
673 static void utc_location_location_manager_remove_boundary_n(void)
674 {
675         int ret = LOCATIONS_ERROR_NONE;
676         ret = location_manager_remove_boundary(NULL, NULL);
677         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
678 }
679
680 static void utc_location_location_manager_remove_boundary_n_02(void)
681 {
682         int ret = LOCATIONS_ERROR_NONE;
683         ret = location_manager_remove_boundary(NULL, bounds_rect);
684         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
685 }
686
687 static void utc_location_location_manager_remove_boundary_n_03(void)
688 {
689         int ret = LOCATIONS_ERROR_NONE;
690         location_manager_h manager_02;
691         ret = location_manager_remove_boundary(manager_02, bounds_rect);
692         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
693 }
694
695 static void utc_location_location_manager_remove_boundary_n_04(void)
696 {
697         int ret = LOCATIONS_ERROR_NONE;
698         ret = location_manager_remove_boundary(manager, NULL);
699         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
700 }
701
702 static void utc_location_location_manager_get_method_p(void)
703 {
704         int ret = LOCATIONS_ERROR_NONE;
705         location_method_e method;
706         ret = location_manager_get_method(manager, &method);
707         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
708 }
709
710 static void utc_location_location_manager_get_method_n(void)
711 {
712         int ret = LOCATIONS_ERROR_NONE;
713         ret = location_manager_get_method(NULL, NULL);
714         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
715
716 }
717
718 static void utc_location_location_manager_get_method_n_02(void)
719 {
720         int ret = LOCATIONS_ERROR_NONE;
721         ret = location_manager_get_method(manager, NULL);
722         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
723
724 }
725
726 static void utc_location_location_manager_get_method_n_03(void)
727 {
728         int ret = LOCATIONS_ERROR_NONE;
729         location_method_e method;
730         ret = location_manager_get_method(NULL, &method);
731         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
732
733 }
734
735 static void utc_location_location_manager_get_method_n_04(void)
736 {
737         int ret = LOCATIONS_ERROR_NONE;
738         location_manager_h manager_02;
739         location_method_e method;
740         ret = location_manager_get_method(manager_02, &method);
741         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
742
743 }
744
745 static void utc_location_location_manager_get_position_p(void)
746 {
747
748         int ret = LOCATIONS_ERROR_NONE;
749
750         double altitude;
751         double latitude;
752         double longitude;
753         time_t timestamp;
754
755         ret = location_manager_get_position(manager, &altitude, &latitude, &longitude, &timestamp);
756         dts_message(__func__, "altitude : %lf, latitude : %lf, longitude : %lf, timestamp:%d", latitude, latitude, longitude,
757                     timestamp);
758         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
759 }
760
761 static void utc_location_location_manager_get_position_n(void)
762 {
763         int ret = LOCATIONS_ERROR_NONE;
764
765         double latitude;
766         double longitude;
767         time_t timestamp;
768
769         ret = location_manager_get_position(manager, NULL, &latitude, &longitude, &timestamp);
770         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
771 }
772
773 static void utc_location_location_manager_get_position_n_02(void)
774 {
775         int ret = LOCATIONS_ERROR_NONE;
776
777         double altitude;
778         double latitude;
779         double longitude;
780         time_t timestamp;
781
782         ret = location_manager_get_position(NULL, &altitude, &latitude, &longitude, &timestamp);
783         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
784 }
785
786 static void utc_location_location_manager_get_position_n_03(void)
787 {
788         int ret = LOCATIONS_ERROR_NONE;
789
790         double altitude;
791         double latitude;
792         double longitude;
793         time_t timestamp;
794         location_manager_h manager_02;
795
796         ret = location_manager_get_position(manager_02, &altitude, &latitude, &longitude, &timestamp);
797         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
798 }
799
800 static void utc_location_location_manager_get_position_n_04(void)
801 {
802         int ret = LOCATIONS_ERROR_NONE;
803
804         double altitude;
805         double longitude;
806         time_t timestamp;
807
808         ret = location_manager_get_position(manager, &altitude, NULL, &longitude, &timestamp);
809         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
810 }
811
812 static void utc_location_location_manager_get_position_n_05(void)
813 {
814         int ret = LOCATIONS_ERROR_NONE;
815
816         double altitude;
817         double latitude;
818         time_t timestamp;
819
820         ret = location_manager_get_position(manager, &altitude, &latitude, NULL, &timestamp);
821         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
822 }
823
824 static void utc_location_location_manager_get_position_n_06(void)
825 {
826         int ret = LOCATIONS_ERROR_NONE;
827
828         double altitude;
829         double latitude;
830         double longitude;
831
832         ret = location_manager_get_position(manager, &altitude, &latitude, &longitude, NULL);
833         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
834 }
835
836 static void utc_location_location_manager_get_velocity_p(void)
837 {
838         int ret = LOCATIONS_ERROR_NONE;
839
840         int climb;
841         int direction;
842         int speed;
843         time_t timestamp;
844
845         ret = location_manager_get_velocity(manager, &climb, &direction, &speed, &timestamp);
846         dts_message(__func__, "climb : %lf, direction : %lf, speed : %lf, timestamp:%d", climb, direction, speed, timestamp);
847         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
848 }
849
850 static void utc_location_location_manager_get_velocity_n(void)
851 {
852         int ret = LOCATIONS_ERROR_NONE;
853
854         int direction;
855         int speed;
856         time_t timestamp;
857
858         ret = location_manager_get_velocity(manager, NULL, &direction, &speed, &timestamp);
859         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
860 }
861
862 static void utc_location_location_manager_get_velocity_n_02(void)
863 {
864         int ret = LOCATIONS_ERROR_NONE;
865
866         int climb;
867         int direction;
868         int speed;
869         time_t timestamp;
870
871         ret = location_manager_get_velocity(NULL, &climb, &direction, &speed, &timestamp);
872         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
873 }
874
875 static void utc_location_location_manager_get_velocity_n_03(void)
876 {
877         int ret = LOCATIONS_ERROR_NONE;
878
879         int climb;
880         int direction;
881         int speed;
882         time_t timestamp;
883         location_manager_h manager_02;
884
885         ret = location_manager_get_velocity(manager_02, &climb, &direction, &speed, &timestamp);
886         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
887 }
888
889 static void utc_location_location_manager_get_velocity_n_04(void)
890 {
891         int ret = LOCATIONS_ERROR_NONE;
892
893         int climb;
894         int speed;
895         time_t timestamp;
896
897         ret = location_manager_get_velocity(manager, &climb, NULL, &speed, &timestamp);
898         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
899 }
900
901 static void utc_location_location_manager_get_velocity_n_05(void)
902 {
903         int ret = LOCATIONS_ERROR_NONE;
904
905         int climb;
906         int direction;
907         time_t timestamp;
908
909         ret = location_manager_get_velocity(manager, &climb, &direction, NULL, &timestamp);
910         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
911 }
912
913 static void utc_location_location_manager_get_velocity_n_06(void)
914 {
915         int ret = LOCATIONS_ERROR_NONE;
916
917         int climb;
918         int direction;
919         int speed;
920
921         ret = location_manager_get_velocity(manager, &climb, &direction, &speed, NULL);
922         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
923 }
924
925 static void utc_location_location_manager_get_accuracy_p(void)
926 {
927         int ret = LOCATIONS_ERROR_NONE;
928
929         location_accuracy_level_e level;
930         double horizontal;
931         double vertical;
932
933         ret = location_manager_get_accuracy(manager, &level, &horizontal, &vertical);
934         dts_message(__func__, "Level : %lf, horizontal : %lf, vertical : %lf", level, horizontal, vertical);
935         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
936 }
937
938 static void utc_location_location_manager_get_accuracy_n(void)
939 {
940         int ret = LOCATIONS_ERROR_NONE;
941
942         ret = location_manager_get_accuracy(manager, NULL, NULL, NULL);
943         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
944 }
945
946 static void utc_location_location_manager_get_accuracy_n_02(void)
947 {
948         int ret = LOCATIONS_ERROR_NONE;
949
950         location_accuracy_level_e level;
951         double horizontal;
952         double vertical;
953
954         ret = location_manager_get_accuracy(NULL, &level, &horizontal, &vertical);
955         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
956 }
957
958 static void utc_location_location_manager_get_accuracy_n_03(void)
959 {
960         int ret = LOCATIONS_ERROR_NONE;
961
962         location_accuracy_level_e level;
963         double horizontal;
964         double vertical;
965         location_manager_h manager_02;
966
967         ret = location_manager_get_accuracy(manager_02, &level, &horizontal, &vertical);
968         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
969 }
970
971 static void utc_location_location_manager_get_accuracy_n_04(void)
972 {
973         int ret = LOCATIONS_ERROR_NONE;
974
975         double horizontal;
976         double vertical;
977
978         ret = location_manager_get_accuracy(manager, NULL, &horizontal, &vertical);
979         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
980 }
981
982 static void utc_location_location_manager_get_accuracy_n_05(void)
983 {
984         int ret = LOCATIONS_ERROR_NONE;
985
986         location_accuracy_level_e level;
987         double vertical;
988
989         ret = location_manager_get_accuracy(manager, &level, NULL, &vertical);
990         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
991 }
992
993 static void utc_location_location_manager_get_accuracy_n_06(void)
994 {
995         int ret = LOCATIONS_ERROR_NONE;
996
997         location_accuracy_level_e level;
998         double horizontal;
999
1000         ret = location_manager_get_accuracy(manager, &level, &horizontal, NULL);
1001         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1002 }
1003
1004 static bool capi_poly_coords_cb(location_coords_s coords, void *user_data)
1005 {
1006         printf("location_bounds_foreach_rect_coords(latitude : %lf, longitude: %lf) \n", coords.latitude, coords.longitude);
1007         return TRUE;
1008 }
1009
1010 static void utc_location_location_bounds_foreach_polygon_coords_p(void)
1011 {
1012         int ret = LOCATIONS_ERROR_NONE;
1013
1014         //Add the polygon bounds
1015         int poly_size = 3;
1016         location_coords_s coord_list[poly_size];
1017
1018         coord_list[0].latitude = 10;
1019         coord_list[0].longitude = 10;
1020         coord_list[1].latitude = 20;
1021         coord_list[1].longitude = 20;
1022         coord_list[2].latitude = 30;
1023         coord_list[2].longitude = 30;
1024
1025         location_bounds_h bounds_poly;
1026         ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
1027         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed");
1028
1029         ret = location_bounds_foreach_polygon_coords(bounds_poly, capi_poly_coords_cb, NULL);
1030
1031         location_bounds_destroy(bounds_poly);
1032
1033         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
1034 }
1035
1036 static void utc_location_location_bounds_foreach_polygon_coords_n(void)
1037 {
1038         int ret = LOCATIONS_ERROR_NONE;
1039
1040         ret = location_bounds_foreach_polygon_coords(NULL, capi_poly_coords_cb, NULL);
1041
1042         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1043 }
1044
1045 static void utc_location_location_bounds_foreach_polygon_coords_n_02(void)
1046 {
1047         int ret = LOCATIONS_ERROR_NONE;
1048
1049         //Add the polygon bounds
1050         int poly_size = 3;
1051         location_coords_s coord_list[poly_size];
1052
1053         coord_list[0].latitude = 10;
1054         coord_list[0].longitude = 10;
1055         coord_list[1].latitude = 20;
1056         coord_list[1].longitude = 20;
1057         coord_list[2].latitude = 30;
1058         coord_list[2].longitude = 30;
1059
1060         location_bounds_h bounds_poly;
1061         ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
1062         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed");
1063
1064         ret = location_bounds_foreach_polygon_coords(bounds_poly, NULL, NULL);
1065
1066         location_bounds_destroy(bounds_poly);
1067
1068         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1069 }
1070
1071 static void utc_location_location_bounds_get_circle_coords_p(void)
1072 {
1073         int ret = LOCATIONS_ERROR_NONE;
1074
1075         location_coords_s center;
1076         center.latitude = 37.258;
1077         center.longitude = 127.056;
1078         double radius = 30;
1079         location_bounds_h bounds_circle;
1080         ret = location_bounds_create_circle(center, radius, &bounds_circle);
1081         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_circle() is failed");
1082
1083         location_coords_s center2;
1084         double radius2;
1085         ret = location_bounds_get_circle_coords(bounds_circle, &center2, &radius2);
1086
1087         location_bounds_destroy(bounds_circle);
1088
1089         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
1090 }
1091
1092 static void utc_location_location_bounds_get_circle_coords_n(void)
1093 {
1094         int ret = LOCATIONS_ERROR_NONE;
1095
1096         location_coords_s center2;
1097         double radius2;
1098         ret = location_bounds_get_circle_coords(NULL, &center2, &radius2);
1099
1100         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1101 }
1102
1103 static void utc_location_location_bounds_get_circle_coords_n_02(void)
1104 {
1105         int ret = LOCATIONS_ERROR_NONE;
1106
1107         location_coords_s center;
1108         center.latitude = 37.258;
1109         center.longitude = 127.056;
1110         double radius = 30;
1111         location_bounds_h bounds_circle;
1112         ret = location_bounds_create_circle(center, radius, &bounds_circle);
1113         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_circle() is failed");
1114
1115         double radius2;
1116         ret = location_bounds_get_circle_coords(bounds_circle, NULL, &radius2);
1117
1118         location_bounds_destroy(bounds_circle);
1119
1120         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1121 }
1122
1123 static void utc_location_location_bounds_get_circle_coords_n_03(void)
1124 {
1125         int ret = LOCATIONS_ERROR_NONE;
1126
1127         location_coords_s center;
1128         center.latitude = 37.258;
1129         center.longitude = 127.056;
1130         double radius = 30;
1131         location_bounds_h bounds_circle;
1132         ret = location_bounds_create_circle(center, radius, &bounds_circle);
1133         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_circle() is failed");
1134
1135         location_coords_s center2;
1136         ret = location_bounds_get_circle_coords(bounds_circle, &center2, NULL);
1137
1138         location_bounds_destroy(bounds_circle);
1139
1140         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1141 }
1142
1143 static void utc_location_location_bounds_get_rect_coords_p(void)
1144 {
1145         int ret = LOCATIONS_ERROR_NONE;
1146
1147         //Add the rect bounds
1148         location_coords_s left_top;
1149         left_top.latitude = 30;
1150         left_top.longitude = 30;
1151
1152         location_coords_s right_bottom;
1153         right_bottom.latitude = 10;
1154         right_bottom.longitude = 50;
1155
1156         location_bounds_h bounds_rect;
1157         ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect);
1158         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_rect() is failed");
1159
1160         location_coords_s left_top2;
1161         location_coords_s right_bottom2;
1162         ret = location_bounds_get_rect_coords(bounds_rect, &left_top2, &right_bottom2);
1163
1164         location_bounds_destroy(bounds_rect);
1165
1166         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
1167 }
1168
1169 static void utc_location_location_bounds_get_rect_coords_n(void)
1170 {
1171         int ret = LOCATIONS_ERROR_NONE;
1172
1173         location_coords_s left_top2;
1174         location_coords_s right_bottom2;
1175         ret = location_bounds_get_rect_coords(NULL, &left_top2, &right_bottom2);
1176
1177         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1178 }
1179
1180 static void utc_location_location_bounds_get_rect_coords_n_02(void)
1181 {
1182         int ret = LOCATIONS_ERROR_NONE;
1183
1184         //Add the rect bounds
1185         location_coords_s left_top;
1186         left_top.latitude = 30;
1187         left_top.longitude = 30;
1188
1189         location_coords_s right_bottom;
1190         right_bottom.latitude = 10;
1191         right_bottom.longitude = 50;
1192
1193         location_bounds_h bounds_rect;
1194         ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect);
1195         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_rect() is failed");
1196
1197         location_coords_s right_bottom2;
1198         ret = location_bounds_get_rect_coords(bounds_rect, NULL, &right_bottom2);
1199
1200         location_bounds_destroy(bounds_rect);
1201
1202         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1203 }
1204
1205 static void utc_location_location_bounds_get_rect_coords_n_03(void)
1206 {
1207         int ret = LOCATIONS_ERROR_NONE;
1208
1209         //Add the rect bounds
1210         location_coords_s left_top;
1211         left_top.latitude = 30;
1212         left_top.longitude = 30;
1213
1214         location_coords_s right_bottom;
1215         right_bottom.latitude = 10;
1216         right_bottom.longitude = 50;
1217
1218         location_bounds_h bounds_rect;
1219         ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect);
1220         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_rect() is failed");
1221
1222         location_coords_s left_top2;
1223         ret = location_bounds_get_rect_coords(bounds_rect, &left_top2, NULL);
1224
1225         location_bounds_destroy(bounds_rect);
1226
1227         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1228 }
1229
1230 static void utc_location_location_bounds_contains_coordinates_p(void)
1231 {
1232         int ret = LOCATIONS_ERROR_NONE;
1233
1234         //Add the polygon bounds
1235         int poly_size = 3;
1236         location_coords_s coord_list[poly_size];
1237
1238         coord_list[0].latitude = 10;
1239         coord_list[0].longitude = 10;
1240         coord_list[1].latitude = 20;
1241         coord_list[1].longitude = 20;
1242         coord_list[2].latitude = 30;
1243         coord_list[2].longitude = 10;
1244
1245         location_bounds_h bounds_poly;
1246         ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
1247         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed");
1248
1249         location_coords_s test_coords;
1250         test_coords.latitude = 20;
1251         test_coords.longitude = 12;
1252         bool contained = FALSE;
1253         contained = location_bounds_contains_coordinates(bounds_poly, test_coords);
1254
1255         location_bounds_destroy(bounds_poly);
1256
1257         validate_eq(__func__, contained, TRUE);
1258 }
1259
1260 static void utc_location_location_bounds_contains_coordinates_p_02(void)
1261 {
1262         int ret = LOCATIONS_ERROR_NONE;
1263
1264         //Add the polygon bounds
1265         int poly_size = 3;
1266         location_coords_s coord_list[poly_size];
1267
1268         coord_list[0].latitude = 10;
1269         coord_list[0].longitude = 10;
1270         coord_list[1].latitude = 20;
1271         coord_list[1].longitude = 20;
1272         coord_list[2].latitude = 30;
1273         coord_list[2].longitude = 10;
1274
1275         location_bounds_h bounds_poly;
1276         ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
1277         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed");
1278
1279         location_coords_s test_coords;
1280         test_coords.latitude = 50;
1281         test_coords.longitude = 50;
1282         bool contained = FALSE;
1283         contained = location_bounds_contains_coordinates(bounds_poly, test_coords);
1284
1285         location_bounds_destroy(bounds_poly);
1286
1287         validate_eq(__func__, contained, FALSE);
1288 }
1289
1290
1291 static void utc_location_location_bounds_contains_coordinates_n(void)
1292 {
1293         int ret = LOCATIONS_ERROR_NONE;
1294
1295         location_coords_s test_coords;
1296         test_coords.latitude = 12;
1297         test_coords.longitude = 12;
1298         ret = location_bounds_contains_coordinates(NULL, test_coords);
1299
1300         validate_eq(__func__, ret, FALSE);
1301 }
1302
1303 static void utc_location_location_bounds_contains_coordinates_n_02(void)
1304 {
1305         int ret = LOCATIONS_ERROR_NONE;
1306
1307         //Add the polygon bounds
1308         int poly_size = 3;
1309         location_coords_s coord_list[poly_size];
1310
1311         coord_list[0].latitude = 10;
1312         coord_list[0].longitude = 10;
1313         coord_list[1].latitude = 20;
1314         coord_list[1].longitude = 20;
1315         coord_list[2].latitude = 30;
1316         coord_list[2].longitude = 10;
1317
1318         location_bounds_h bounds_poly;
1319         ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
1320         validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed");
1321
1322         location_coords_s coord_test;
1323         coord_test.latitude = -91;
1324         coord_test.longitude = 181;
1325         ret = location_bounds_contains_coordinates(bounds_poly, coord_test);
1326
1327         location_bounds_destroy(bounds_poly);
1328
1329         validate_eq(__func__, ret, FALSE);
1330 }
1331
1332 static void utc_location_location_manager_get_last_accuracy_p(void)
1333 {
1334
1335         int ret = LOCATIONS_ERROR_NONE;
1336
1337         double horizontal, vertical;
1338         location_accuracy_level_e level;
1339
1340         ret = location_manager_get_last_accuracy(manager, &level, &horizontal, &vertical);
1341         dts_message(__func__, "Level : %d, horizontal: %g, vertical : %g\n", level, horizontal, vertical);
1342         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
1343 }
1344
1345 static void utc_location_location_manager_get_last_accuracy_n(void)
1346 {
1347         int ret = LOCATIONS_ERROR_NONE;
1348
1349         double horizontal, vertical;
1350         location_accuracy_level_e level;
1351
1352         ret = location_manager_get_last_accuracy(NULL, &level, &horizontal, &vertical);
1353         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1354 }
1355
1356 static void utc_location_location_manager_get_last_accuracy_n_02(void)
1357 {
1358         int ret = LOCATIONS_ERROR_NONE;
1359
1360         double horizontal, vertical;
1361
1362         ret = location_manager_get_last_accuracy(manager, NULL, &horizontal, &vertical);
1363         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1364 }
1365
1366 static void utc_location_location_manager_get_last_accuracy_n_03(void)
1367 {
1368         int ret = LOCATIONS_ERROR_NONE;
1369
1370         double vertical;
1371         location_accuracy_level_e level;
1372
1373         ret = location_manager_get_last_accuracy(manager, &level, NULL, &vertical);
1374         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1375 }
1376
1377 static void utc_location_location_manager_get_last_accuracy_n_04(void)
1378 {
1379         int ret = LOCATIONS_ERROR_NONE;
1380
1381         double horizontal;
1382         location_accuracy_level_e level;
1383
1384         ret = location_manager_get_last_accuracy(manager, &level, &horizontal, NULL);
1385         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1386 }
1387
1388 static void utc_location_location_manager_get_last_position_p(void)
1389 {
1390
1391         int ret = LOCATIONS_ERROR_NONE;
1392
1393         double altitude;
1394         double latitude;
1395         double longitude;
1396         time_t timestamp;
1397
1398         ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, &timestamp);
1399         dts_message(__func__, "altitude : %lf, latitude : %lf, longitude : %lf, timestamp:%d", latitude, latitude, longitude,
1400                     timestamp);
1401         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
1402 }
1403
1404 static void utc_location_location_manager_get_last_position_n(void)
1405 {
1406         int ret = LOCATIONS_ERROR_NONE;
1407
1408         double altitude;
1409         double latitude;
1410         double longitude;
1411         time_t timestamp;
1412
1413         ret = location_manager_get_last_position(NULL, &altitude, &latitude, &longitude, &timestamp);
1414         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1415 }
1416
1417 static void utc_location_location_manager_get_last_position_n_02(void)
1418 {
1419         int ret = LOCATIONS_ERROR_NONE;
1420
1421         double latitude;
1422         double longitude;
1423         time_t timestamp;
1424
1425         ret = location_manager_get_last_position(manager, NULL, &latitude, &longitude, &timestamp);
1426         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1427 }
1428
1429 static void utc_location_location_manager_get_last_position_n_03(void)
1430 {
1431         int ret = LOCATIONS_ERROR_NONE;
1432
1433         double altitude;
1434         double longitude;
1435         time_t timestamp;
1436
1437         ret = location_manager_get_last_position(manager, &altitude, NULL, &longitude, &timestamp);
1438         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1439 }
1440
1441 static void utc_location_location_manager_get_last_position_n_04(void)
1442 {
1443         int ret = LOCATIONS_ERROR_NONE;
1444
1445         double altitude;
1446         double latitude;
1447         time_t timestamp;
1448
1449         ret = location_manager_get_last_position(manager, &altitude, &latitude, NULL, &timestamp);
1450         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1451 }
1452
1453 static void utc_location_location_manager_get_last_position_n_05(void)
1454 {
1455         int ret = LOCATIONS_ERROR_NONE;
1456
1457         double altitude;
1458         double latitude;
1459         double longitude;
1460
1461         ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, NULL);
1462         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1463 }
1464
1465 static void utc_location_location_manager_get_last_velocity_p(void)
1466 {
1467
1468         int ret = LOCATIONS_ERROR_NONE;
1469
1470         int climb;
1471         int direction;
1472         int speed;
1473         time_t timestamp;
1474
1475         ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, &timestamp);
1476         dts_message(__func__, "climb : %lf, direction : %lf, speed : %lf, timestamp:%d", climb, direction, speed, timestamp);
1477         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
1478 }
1479
1480 static void utc_location_location_manager_get_last_velocity_n(void)
1481 {
1482         int ret = LOCATIONS_ERROR_NONE;
1483
1484         int climb;
1485         int direction;
1486         int speed;
1487         time_t timestamp;
1488
1489         ret = location_manager_get_last_velocity(NULL, &climb, &direction, &speed, &timestamp);
1490         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1491 }
1492
1493 static void utc_location_location_manager_get_last_velocity_n_02(void)
1494 {
1495         int ret = LOCATIONS_ERROR_NONE;
1496
1497         int direction;
1498         int speed;
1499         time_t timestamp;
1500
1501         ret = location_manager_get_last_velocity(manager, NULL, &direction, &speed, &timestamp);
1502         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1503 }
1504
1505 static void utc_location_location_manager_get_last_velocity_n_03(void)
1506 {
1507         int ret = LOCATIONS_ERROR_NONE;
1508
1509         int climb;
1510         int speed;
1511         time_t timestamp;
1512
1513         ret = location_manager_get_last_velocity(manager, &climb, NULL, &speed, &timestamp);
1514         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1515 }
1516
1517 static void utc_location_location_manager_get_last_velocity_n_04(void)
1518 {
1519         int ret = LOCATIONS_ERROR_NONE;
1520
1521         int climb;
1522         int direction;
1523         time_t timestamp;
1524
1525         ret = location_manager_get_last_velocity(manager, &climb, &direction, NULL, &timestamp);
1526         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1527 }
1528
1529 static void utc_location_location_manager_get_last_velocity_n_05(void)
1530 {
1531         int ret = LOCATIONS_ERROR_NONE;
1532
1533         int climb;
1534         int direction;
1535         int speed;
1536
1537         ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, NULL);
1538         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1539 }
1540
1541 static void utc_location_location_manager_is_supported_method_p(void)
1542 {
1543         bool supported = FALSE;
1544         supported = location_manager_is_supported_method(LOCATIONS_METHOD_HYBRID);
1545         validate_eq(__func__, supported, TRUE);
1546 }
1547
1548 static void utc_location_location_manager_is_supported_method_p_02(void)
1549 {
1550         bool supported = FALSE;
1551         supported = location_manager_is_supported_method(LOCATIONS_METHOD_GPS);
1552         validate_eq(__func__, supported, TRUE);
1553 }
1554
1555 static void utc_location_location_manager_is_supported_method_p_03(void)
1556 {
1557         bool supported = FALSE;
1558         supported = location_manager_is_supported_method(LOCATIONS_METHOD_WPS);
1559         validate_eq(__func__, supported, TRUE);
1560 }
1561
1562 static void utc_location_location_manager_is_supported_method_p_04(void)
1563 {
1564         bool supported = FALSE;
1565         supported = location_manager_is_supported_method(LOCATIONS_METHOD_CPS);
1566         validate_eq(__func__, supported, TRUE);
1567 }
1568
1569 static void utc_location_location_manager_is_supported_method_n(void)
1570 {
1571         bool supported = FALSE;
1572         supported = location_manager_is_supported_method(LOCATIONS_METHOD_NONE);
1573         validate_eq(__func__, supported, FALSE);
1574 }
1575
1576 static void utc_location_location_manager_is_supported_method_n_02(void)
1577 {
1578         bool supported = FALSE;
1579         supported = location_manager_is_supported_method(LOCATIONS_METHOD_CPS + 1);
1580         validate_eq(__func__, supported, FALSE);
1581 }
1582
1583 static void utc_location_location_manager_send_command_p(void)
1584 {
1585
1586         int ret = LOCATIONS_ERROR_NONE;
1587
1588         const *str = "command";
1589         ret = location_manager_send_command(str);
1590         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
1591 }
1592
1593 static void utc_location_location_manager_send_command_n(void)
1594 {
1595         int ret = LOCATIONS_ERROR_NONE;
1596
1597         ret = location_manager_send_command(NULL);
1598         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1599 }
1600
1601 static void utc_location_location_manager_destroy_p(void)
1602 {
1603         int ret = LOCATIONS_ERROR_NONE;
1604         ret = location_manager_destroy(manager);
1605         validate_eq(__func__, ret, LOCATIONS_ERROR_NONE);
1606
1607 }
1608
1609 static void utc_location_location_manager_destroy_n(void)
1610 {
1611         int ret = LOCATIONS_ERROR_NONE;
1612
1613         ret = location_manager_destroy(NULL);
1614         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1615
1616 }
1617
1618 static void utc_location_location_manager_destroy_n_02(void)
1619 {
1620         int ret = LOCATIONS_ERROR_NONE;
1621
1622         location_manager_h manager_02;
1623
1624         ret = location_manager_destroy(manager_02);
1625         validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER);
1626
1627 }