[UTC][location-manager][ACR-656][Location Batch APIs]
authorkj7.sung <kj7.sung@samsung.com>
Fri, 17 Jun 2016 07:40:25 +0000 (16:40 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Fri, 17 Jun 2016 07:40:52 +0000 (16:40 +0900)
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
Change-Id: I7a9586bbe4bcbcb2a4650b052f27812c7a480d3c

src/utc/location-manager/CMakeLists.txt
src/utc/location-manager/public.list
src/utc/location-manager/tct-location-manager-core_mobile.h
src/utc/location-manager/tct-location-manager-core_wearable.h
src/utc/location-manager/utc-location-manager-batch.c [new file with mode: 0755]
src/utc/location-manager/utc-location-manager-common.h

index bb87572..759f064 100755 (executable)
@@ -7,6 +7,7 @@ SET(CAPI_LIB "capi-location-manager")
 SET(TC_SOURCES
        utc-location-manager.c
        utc-location-manager-cb.c
+       utc-location-manager-batch.c
        utc-location-gps-status.c
        utc-location-bound.c
 )
index 215b62e..83034f0 100755 (executable)
@@ -50,4 +50,8 @@ location_manager_unset_service_state_changed_cb
 location_manager_unset_setting_changed_cb
 location_manager_unset_velocity_updated_cb
 location_manager_unset_zone_changed_cb
-
+location_manager_start_batch
+location_manager_stop_batch
+location_manager_foreach_location_batch
+location_manager_set_location_batch_cb
+location_manager_unset_location_batch_cb
index b4893a5..0cfd5cb 100755 (executable)
@@ -27,6 +27,8 @@ extern void utc_location_manager_cb_startup(void);
 extern void utc_location_manager_cb_cleanup(void);
 extern void utc_location_manager_startup(void);
 extern void utc_location_manager_cleanup(void);
+extern void utc_location_manager_batch_startup(void);
+extern void utc_location_manager_batch_cleanup(void);
 
 extern int utc_location_gps_status_get_nmea_p(void);
 extern int utc_location_gps_status_get_nmea_n(void);
@@ -168,7 +170,30 @@ extern int utc_location_manager_set_mock_location_n(void);
 extern int utc_location_manager_clear_mock_location_p(void);
 extern int utc_location_manager_clear_mock_location_n(void);
 
+extern int utc_location_manager_start_batch_p(void);
+extern int utc_location_manager_start_batch_n(void);
+extern int utc_location_manager_stop_batch_p(void);
+extern int utc_location_manager_stop_batch_n(void);
+extern int utc_location_manager_foreach_location_batch_p(void);
+extern int utc_location_manager_foreach_location_batch_n(void);
+extern int utc_location_manager_foreach_location_batch_n2(void);
+extern int utc_location_manager_set_location_batch_cb_p(void);
+extern int utc_location_manager_set_location_batch_cb_n(void);
+extern int utc_location_manager_unset_location_batch_cb_p(void);
+extern int utc_location_manager_unset_location_batch_cb_n(void);
+
 testcase tc_array[] = {
+    {"utc_location_manager_start_batch_p", utc_location_manager_start_batch_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_start_batch_n", utc_location_manager_start_batch_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_stop_batch_p", utc_location_manager_stop_batch_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_stop_batch_n", utc_location_manager_stop_batch_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_foreach_location_batch_p", utc_location_manager_foreach_location_batch_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_foreach_location_batch_n", utc_location_manager_foreach_location_batch_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_foreach_location_batch_n2", utc_location_manager_foreach_location_batch_n2, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_set_location_batch_cb_p", utc_location_manager_set_location_batch_cb_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_set_location_batch_cb_n", utc_location_manager_set_location_batch_cb_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_unset_location_batch_cb_p", utc_location_manager_unset_location_batch_cb_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_unset_location_batch_cb_n", utc_location_manager_unset_location_batch_cb_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
     {"utc_location_gps_status_get_nmea_p", utc_location_gps_status_get_nmea_p, utc_location_gps_status_startup, utc_location_gps_status_cleanup},
     {"utc_location_gps_status_get_nmea_n", utc_location_gps_status_get_nmea_n, utc_location_gps_status_startup, utc_location_gps_status_cleanup},
     {"utc_location_gps_status_get_nmea_n2", utc_location_gps_status_get_nmea_n2, utc_location_gps_status_startup, utc_location_gps_status_cleanup},
index b4893a5..0cfd5cb 100755 (executable)
@@ -27,6 +27,8 @@ extern void utc_location_manager_cb_startup(void);
 extern void utc_location_manager_cb_cleanup(void);
 extern void utc_location_manager_startup(void);
 extern void utc_location_manager_cleanup(void);
+extern void utc_location_manager_batch_startup(void);
+extern void utc_location_manager_batch_cleanup(void);
 
 extern int utc_location_gps_status_get_nmea_p(void);
 extern int utc_location_gps_status_get_nmea_n(void);
@@ -168,7 +170,30 @@ extern int utc_location_manager_set_mock_location_n(void);
 extern int utc_location_manager_clear_mock_location_p(void);
 extern int utc_location_manager_clear_mock_location_n(void);
 
+extern int utc_location_manager_start_batch_p(void);
+extern int utc_location_manager_start_batch_n(void);
+extern int utc_location_manager_stop_batch_p(void);
+extern int utc_location_manager_stop_batch_n(void);
+extern int utc_location_manager_foreach_location_batch_p(void);
+extern int utc_location_manager_foreach_location_batch_n(void);
+extern int utc_location_manager_foreach_location_batch_n2(void);
+extern int utc_location_manager_set_location_batch_cb_p(void);
+extern int utc_location_manager_set_location_batch_cb_n(void);
+extern int utc_location_manager_unset_location_batch_cb_p(void);
+extern int utc_location_manager_unset_location_batch_cb_n(void);
+
 testcase tc_array[] = {
+    {"utc_location_manager_start_batch_p", utc_location_manager_start_batch_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_start_batch_n", utc_location_manager_start_batch_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_stop_batch_p", utc_location_manager_stop_batch_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_stop_batch_n", utc_location_manager_stop_batch_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_foreach_location_batch_p", utc_location_manager_foreach_location_batch_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_foreach_location_batch_n", utc_location_manager_foreach_location_batch_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_foreach_location_batch_n2", utc_location_manager_foreach_location_batch_n2, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_set_location_batch_cb_p", utc_location_manager_set_location_batch_cb_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_set_location_batch_cb_n", utc_location_manager_set_location_batch_cb_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_unset_location_batch_cb_p", utc_location_manager_unset_location_batch_cb_p, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
+    {"utc_location_manager_unset_location_batch_cb_n", utc_location_manager_unset_location_batch_cb_n, utc_location_manager_batch_startup, utc_location_manager_batch_cleanup},
     {"utc_location_gps_status_get_nmea_p", utc_location_gps_status_get_nmea_p, utc_location_gps_status_startup, utc_location_gps_status_cleanup},
     {"utc_location_gps_status_get_nmea_n", utc_location_gps_status_get_nmea_n, utc_location_gps_status_startup, utc_location_gps_status_cleanup},
     {"utc_location_gps_status_get_nmea_n2", utc_location_gps_status_get_nmea_n2, utc_location_gps_status_startup, utc_location_gps_status_cleanup},
diff --git a/src/utc/location-manager/utc-location-manager-batch.c b/src/utc/location-manager/utc-location-manager-batch.c
new file mode 100755 (executable)
index 0000000..db2acde
--- /dev/null
@@ -0,0 +1,285 @@
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// 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 <locations.h>
+#include <glib.h>
+#include "assert.h"
+#include <string.h>
+#include <unistd.h>
+#include <system_info.h>
+#include "utc-location-manager-common.h"
+
+//& set: LocationManager
+static GMainLoop *g_mainloop = NULL;
+static location_manager_h manager = NULL;
+static bool __location_batch = false;
+static bool __get_batch = false;
+static int interval = 1;
+static int batch_period = 5;
+
+
+static void wait_for_service()
+{
+       g_mainloop = g_main_loop_new(NULL, 0);
+       g_main_loop_run(g_mainloop);
+}
+
+static void wait_for_callback()
+{
+       g_mainloop = g_main_loop_new(NULL, 0);
+       g_main_loop_run(g_mainloop);
+}
+
+static void __location_batch_cb(int num_of_location, void *user_data)
+{
+       __location_batch = true;
+       if (g_mainloop) {
+               g_main_loop_quit(g_mainloop);
+               g_mainloop = NULL;
+       }
+
+}
+
+static bool __get_batch_cb(double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data)
+{
+       __get_batch = true;
+}
+
+void utc_location_manager_batch_startup(void)
+{
+       system_info_get_platform_bool(WPS_FEATURE, &is_wps_supported);
+       system_info_get_platform_bool(BATCH_FEATURE, &is_batch_supported);
+
+       if(manager == NULL) {
+               location_manager_create(LOCATIONS_METHOD_GPS, &manager);
+       }
+}
+
+void utc_location_manager_batch_cleanup(void)
+{
+       if(manager) {
+               location_manager_destroy(manager);
+               manager = NULL;
+       }
+
+       if (g_mainloop) {
+               g_main_loop_quit(g_mainloop);
+               g_mainloop = NULL;
+       }
+}
+
+
+int utc_location_manager_start_batch_p(void)
+{
+       __location_batch = false;
+
+       if(is_batch_supported) {
+               ret = location_manager_set_location_batch_cb(manager, __location_batch_cb, interval, batch_period, NULL);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_start_batch(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               wait_for_service();
+               assert(__location_batch);
+
+               ret = location_manager_stop_batch(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_unset_location_batch_cb(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+       } else {
+               ret = location_manager_start_batch(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
+int utc_location_manager_start_batch_n(void)
+{
+       ret = location_manager_start_batch(NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+
+       if(is_wps_supported) {
+               location_manager_h manager2 = NULL;
+               ret = location_manager_create(LOCATIONS_METHOD_WPS, &manager2);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_start_batch(manager2);
+               assert_eq(ret, LOCATIONS_ERROR_INCORRECT_METHOD);
+
+               if (manager2) {
+                       ret = location_manager_destroy(manager2);
+                       assert_eq(ret, LOCATIONS_ERROR_NONE);
+                       manager2 = NULL;
+               }
+       }
+
+       return 0;
+}
+
+int utc_location_manager_stop_batch_p(void)
+{
+       __get_batch = false;
+       __location_batch = false;
+
+       if(is_batch_supported) {
+               ret = location_manager_set_location_batch_cb(manager, __location_batch_cb, interval, batch_period, NULL);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_start_batch(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               wait_for_service();
+               assert(__location_batch);
+
+               ret = location_manager_stop_batch(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_unset_location_batch_cb(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+       } else {
+               ret = location_manager_stop_batch(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
+int utc_location_manager_stop_batch_n(void)
+{
+       ret = location_manager_stop_batch(NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+       return 0;
+}
+
+int utc_location_manager_foreach_location_batch_p(void)
+{
+       __get_batch = false;
+       __location_batch = false;
+
+       if(is_batch_supported) {
+               ret = location_manager_set_location_batch_cb(manager, __location_batch_cb, interval, batch_period, NULL);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_start_batch(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               wait_for_service();
+               assert(__location_batch);
+
+               ret = location_manager_foreach_location_batch(manager, __get_batch_cb, NULL);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               wait_for_callback();
+               assert(__get_batch);
+
+               ret = location_manager_stop_batch(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_unset_location_batch_cb(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+       } else {
+               ret = location_manager_foreach_location_batch(manager, __get_batch_cb, NULL);
+               assert_eq(ret, LOCATIONS_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
+int utc_location_manager_foreach_location_batch_n(void)
+{
+       ret = location_manager_foreach_location_batch(manager, NULL, NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+
+       ret = location_manager_foreach_location_batch(NULL, __get_batch_cb, NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+
+       return 0;
+}
+
+int utc_location_manager_foreach_location_batch_n2(void)
+{
+       ret = location_manager_foreach_location_batch(manager, __get_batch_cb, NULL);
+       if(is_batch_supported) {
+               assert_eq(ret, LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE);
+       } else {
+               assert_eq(ret, LOCATIONS_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
+int utc_location_manager_set_location_batch_cb_p(void)
+{
+       ret = location_manager_set_location_batch_cb(manager, __location_batch_cb, interval, batch_period, NULL);
+       if(is_batch_supported) {
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_unset_location_batch_cb(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+       } else {
+               assert_eq(ret, LOCATIONS_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
+int utc_location_manager_set_location_batch_cb_n(void)
+{
+       ret = location_manager_set_location_batch_cb(NULL, __location_batch_cb, interval, batch_period, NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+
+       ret = location_manager_set_location_batch_cb(manager, NULL, interval, batch_period, NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+
+       ret = location_manager_set_location_batch_cb(manager, __location_batch_cb, 0, batch_period, NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+
+       ret = location_manager_set_location_batch_cb(manager, __location_batch_cb, interval, 60001, NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+
+       ret = location_manager_set_location_batch_cb(manager, __location_batch_cb, 5, 3, NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+
+       return 0;
+}
+
+int utc_location_manager_unset_location_batch_cb_p(void)
+{
+       if(is_batch_supported) {
+               ret = location_manager_set_location_batch_cb(manager, __location_batch_cb, interval, batch_period, NULL);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+
+               ret = location_manager_unset_location_batch_cb(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NONE);
+       } else {
+               ret = location_manager_unset_location_batch_cb(manager);
+               assert_eq(ret, LOCATIONS_ERROR_NOT_SUPPORTED);
+       }
+
+       return 0;
+}
+
+int utc_location_manager_unset_location_batch_cb_n(void)
+{
+       ret = location_manager_unset_location_batch_cb(NULL);
+       CHECK_INVALID_PARAMETER(is_batch_supported, ret);
+       return 0;
+}
+
+
index 1c374d8..a53d93a 100755 (executable)
 #define GPS_FEATURE                            "http://tizen.org/feature/location.gps"
 #define GPS_SATELLITE_FEATURE  "http://tizen.org/feature/location.gps.satellite"
 #define WPS_FEATURE                            "http://tizen.org/feature/location.wps"
+#define BATCH_FEATURE                  "http://tizen.org/feature/location.batch"
 
 int ret;
 bool service_enabled;
 bool is_gps_supported;
 bool is_gps_satellite_supported;
 bool is_wps_supported;
+bool is_batch_supported;
 bool is_location_supported;