summaryrefslogtreecommitdiff
path: root/TC/unit/utc_signals_zone_out.c
diff options
context:
space:
mode:
authorKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:48:36 +0900
committerKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:48:36 +0900
commit898d84180c87e006fbea489673129b129756e2bd (patch)
tree6cf5d2bff7fb9dc725cf91a0bd16449b577676b5 /TC/unit/utc_signals_zone_out.c
parenta1587a945a0ed4e72ad4fffd3de37ed6e6ccc2d6 (diff)
downloadlibslp-location-898d84180c87e006fbea489673129b129756e2bd.tar.gz
libslp-location-898d84180c87e006fbea489673129b129756e2bd.tar.bz2
libslp-location-898d84180c87e006fbea489673129b129756e2bd.zip
Git init
Diffstat (limited to 'TC/unit/utc_signals_zone_out.c')
-rw-r--r--TC/unit/utc_signals_zone_out.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/TC/unit/utc_signals_zone_out.c b/TC/unit/utc_signals_zone_out.c
new file mode 100644
index 0000000..5070a66
--- /dev/null
+++ b/TC/unit/utc_signals_zone_out.c
@@ -0,0 +1,93 @@
+/*
+ * libslp-location
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
+ * Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <tet_api.h>
+#include <glib.h>
+#include <location.h>
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+static void utc_zone_out();
+
+struct tet_testlist tet_testlist[] = {
+ {utc_zone_out,1},
+ {NULL,0},
+};
+
+static GMainLoop *loop = NULL;
+int ret;
+LocationObject* loc;
+
+gboolean
+exit_loop (gpointer data)
+{
+ g_main_loop_quit (loop);
+ tet_result(TET_FAIL);
+ return FALSE;
+}
+
+static void startup()
+{
+ location_init();
+ loc = location_new(LOCATION_METHOD_GPS);
+ location_start(loc);
+ loop = g_main_loop_new(NULL,FALSE);
+
+ LocationPosition *rb = location_position_new(0, 36.395, 25.41, 0, LOCATION_STATUS_2D_FIX);
+ LocationPosition *lt = location_position_new(0, 36.413, 25.388, 0, LOCATION_STATUS_2D_FIX);
+ LocationBoundary* bound = location_boundary_new_for_rect(lt, rb);
+ location_position_free (rb);
+ location_position_free (lt);
+ g_object_set(loc, "boundary", bound, NULL);
+ location_boundary_free (bound);
+ tet_printf("\n TC startup");
+}
+
+static void cleanup()
+{
+ location_stop(loc);
+ location_free(loc);
+ tet_printf("\n TC End");
+}
+
+static void
+_cb_zone_out(LocationObject *self,
+ guint type,
+ gpointer position,
+ gpointer accuracy)
+{
+ LocationPosition *pos = (LocationPosition*) position;
+
+ if( (37.255 <= pos->latitude && pos->latitude <= 37.265) &&
+ (27.052 <= pos->longitude && pos->longitude <= 127.060) ) tet_result(TET_PASS); // I am in Suwon HQ
+ else tet_result(TET_FAIL);
+ g_main_loop_quit(loop);
+}
+
+
+static void
+utc_zone_out()
+{
+ g_signal_connect (loc, "zone-out", G_CALLBACK(_cb_zone_out), loc);
+ g_timeout_add_seconds(60, exit_loop, NULL);
+ g_main_loop_run (loop);
+}