tizen beta release
[framework/location/libslp-location.git] / TC / unit / utc_location_get_satellite.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_location_get_satellite_01();
31 static void utc_location_get_satellite_02();
32 static void utc_location_get_satellite_03();
33
34 struct tet_testlist tet_testlist[] = {
35         {utc_location_get_satellite_01,1},
36         {utc_location_get_satellite_02,2},
37         {utc_location_get_satellite_03,3},
38         {NULL,0},
39 };
40
41 static GMainLoop *loop = NULL;
42 int ret;
43 LocationObject* loc;
44
45 static gboolean
46 exit_loop (gpointer data)
47 {
48         g_main_loop_quit (loop);
49         tet_result(TET_FAIL);
50         return FALSE;
51 }
52
53 static void startup()
54 {
55         location_init();
56         loc = location_new(LOCATION_METHOD_GPS);
57         location_start(loc);
58         loop = g_main_loop_new(NULL,FALSE);
59         tet_printf("\n TC startup");
60 }
61
62 static void cleanup()
63 {
64         location_stop(loc);
65         location_free(loc);
66         tet_printf("\n TC End");
67 }
68
69 static void
70 _get_satellite (GObject *self,
71                                 guint _status,
72                     gpointer userdata)
73 {
74         LocationSatellite *sat = NULL;
75         LocationObject *loc = (LocationObject*)userdata;
76
77         ret = location_get_satellite (loc, &sat);
78         tet_printf("Returned value: %d", ret);
79         if (ret == LOCATION_ERROR_NONE) {
80                 location_satellite_free(sat);
81                 tet_result(TET_PASS);
82         } else tet_result(TET_FAIL);
83         g_main_loop_quit (loop);
84 }
85
86 static void
87 utc_location_get_satellite_01()
88 {
89         g_signal_connect (loc, "service-enabled", G_CALLBACK(_get_satellite), loc);
90         g_timeout_add_seconds(60, exit_loop, loop);
91         g_main_loop_run (loop);
92 }
93
94 static void
95 utc_location_get_satellite_02()
96 {
97         LocationSatellite *sat = NULL;
98         ret = location_get_satellite (NULL, &sat);
99         tet_printf("Returned value: %d", ret);
100         if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
101         else tet_result(TET_FAIL);
102 }
103
104 static void
105 utc_location_get_satellite_03()
106 {
107         LocationSatellite *sat = NULL;
108         ret = location_get_satellite (loc, NULL);
109         tet_printf("Returned value: %d", ret);
110         if (ret == LOCATION_ERROR_PARAMETER) tet_result(TET_PASS);
111         else tet_result(TET_FAIL);
112 }