Git init
[framework/location/libslp-location.git] / TC / unit / utc_properties_boundary.c
1 /*
2  * libslp-location
3  *
4  * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7  *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #include <tet_api.h>
23 #include <glib.h>
24 #include <location.h>
25
26 static void startup(), cleanup();
27 void (*tet_startup) () = startup;
28 void (*tet_cleanup) () = cleanup;
29
30 static void utc_set_boundary_in_suwonHQ();
31 static void utc_get_boundary_in_suwonHQ();
32
33 struct tet_testlist tet_testlist[] = {
34         {utc_set_boundary_in_suwonHQ,1},
35         {utc_get_boundary_in_suwonHQ,2},
36         {NULL,0},
37 };      
38
39 int ret;
40 LocationObject* loc;
41
42 static void startup()
43 {       
44         location_init();
45         loc = location_new(LOCATION_METHOD_GPS);
46         location_start(loc);
47         tet_printf("\n TC startup");
48 }
49
50 static void cleanup()
51 {       
52         location_stop(loc);
53         location_free(loc);
54         tet_printf("\n TC End");
55 }
56
57 static void
58 utc_set_boundary_in_suwonHQ()
59 {
60         LocationPosition *rb = location_position_new(0, 37.258, 127.056, 0, LOCATION_STATUS_2D_FIX);
61         LocationPosition *lt = location_position_new(0, 37.260, 127.054, 0, LOCATION_STATUS_2D_FIX);
62         LocationBoundary* bound = location_boundary_new_for_rect(lt, rb);
63         g_object_set(loc, "boundary", bound, NULL);
64         location_position_free (rb);
65         location_position_free (lt);
66         location_boundary_free(bound);
67         if (loc) {
68                 tet_result(TET_PASS);           
69         } else tet_result(TET_FAIL);
70 }
71
72 static void
73 utc_get_boundary_in_suwonHQ()
74 {
75         LocationBoundary* bound = NULL; 
76         g_object_get(loc, "boundary", &bound, NULL);
77         if ( bound && 
78                 bound->type == LOCATION_BOUNDARY_RECT &&
79                 bound->rect.right_bottom->latitude == 37.258 &&
80                 bound->rect.right_bottom->longitude == 127.056 &&
81                 bound->rect.left_top->latitude == 37.260 &&
82                 bound->rect.left_top->longitude == 127.054 ){           
83                 tet_result(TET_PASS);
84                 location_boundary_free (bound);
85         } else tet_result(TET_FAIL);
86 }