diff options
author | Minjune Kim <sena06.kim@samsung.com> | 2012-08-21 18:10:16 +0900 |
---|---|---|
committer | Minjune Kim <sena06.kim@samsung.com> | 2012-08-21 18:10:16 +0900 |
commit | 924a071a70171da7d2512199f777020a55ae9056 (patch) | |
tree | 949e0f38cfa178c08006c206580ded405a4b9bca /TC | |
parent | b9a903e9aa68c84fd8afa728d137e081ab298bc2 (diff) | |
download | location-manager-924a071a70171da7d2512199f777020a55ae9056.tar.gz location-manager-924a071a70171da7d2512199f777020a55ae9056.tar.bz2 location-manager-924a071a70171da7d2512199f777020a55ae9056.zip |
Release Tizen2.0 betaHEADsubmit/master/20120920.1510252.0_alphamaster2.0alpha
Diffstat (limited to 'TC')
-rwxr-xr-x | TC/_export_env.sh | 8 | ||||
-rwxr-xr-x | TC/_export_target_env.sh | 7 | ||||
-rwxr-xr-x | TC/build.sh | 16 | ||||
-rwxr-xr-x | TC/clean.sh | 11 | ||||
-rw-r--r-- | TC/config | 2 | ||||
-rwxr-xr-x | TC/execute.sh | 15 | ||||
-rw-r--r-- | TC/testcase/Makefile | 25 | ||||
-rw-r--r-- | TC/testcase/tslist | 4 | ||||
-rwxr-xr-x | TC/testcase/utc_location_gps_status.c | 399 | ||||
-rwxr-xr-x | TC/testcase/utc_location_location_manager.c | 1627 | ||||
-rw-r--r-- | TC/testcase/utc_location_location_manager_callback.c | 466 | ||||
-rw-r--r-- | TC/testcase/utc_location_preference.c | 334 | ||||
-rwxr-xr-x | TC/tet_scen | 7 | ||||
-rw-r--r-- | TC/tetbuild.cfg | 5 | ||||
-rw-r--r-- | TC/tetclean.cfg | 5 | ||||
-rw-r--r-- | TC/tetexec.cfg | 5 |
16 files changed, 2936 insertions, 0 deletions
diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..72a11ec --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..5ddaa53 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..72aad6c --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +RESULT_DIR=results + +tcc -c -p ./ # executing tcc, with clean option (-c) +rm -r $RESULT_DIR +rm -r tet_tmp_dir +rm testcase/tet_captured diff --git a/TC/config b/TC/config new file mode 100644 index 0000000..04684f0 --- /dev/null +++ b/TC/config @@ -0,0 +1,2 @@ +TET_INSTALL_HOST_PATH=/home/rookiejava/dts_tool/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/dts_tool/TETware diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..a4f6095 --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. ./_export_target_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100644 index 0000000..6aadb01 --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,25 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-location-manager dlog glib-2.0 gthread-2.0 capi-location-geocoder + +LDFLAGS = `pkg-config --libs $(PKGS)` +LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +#TARGETS = $(C_FILES:%.c=tc-%) +TCS := $(shell ls -1 *.c | cut -d. -f1) + +all: $(TCS) + +%: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TCS) diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100644 index 0000000..f7426d5 --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1,4 @@ +/testcase/utc_location_location_manager +/testcase/utc_location_gps_status +/testcase/utc_location_location_manager_callback +/testcase/utc_location_preference diff --git a/TC/testcase/utc_location_gps_status.c b/TC/testcase/utc_location_gps_status.c new file mode 100755 index 0000000..38d698a --- /dev/null +++ b/TC/testcase/utc_location_gps_status.c @@ -0,0 +1,399 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <locations.h> +#include <glib.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +static void startup(void); +static void cleanup(void); + +void (*tet_startup) (void) = startup; +void (*tet_cleanup) (void) = cleanup; + +static void utc_location_gps_status_get_nmea_p(void); +static void utc_location_gps_status_get_nmea_n(void); +static void utc_location_gps_status_get_nmea_n_02(void); +static void utc_location_gps_status_get_nmea_n_03(void); +static void utc_location_gps_status_get_satellite_p(void); +static void utc_location_gps_status_get_satellite_n(void); +static void utc_location_gps_status_get_satellite_n_02(void); +static void utc_location_gps_status_get_satellite_n_03(void); +static void utc_location_gps_status_get_satellite_n_04(void); +static void utc_location_gps_status_get_satellite_n_05(void); +static void utc_location_gps_status_get_satellite_n_06(void); +static void utc_location_gps_status_foreach_satellites_in_view_p(void); +static void utc_location_gps_status_foreach_satellites_in_view_n(void); +static void utc_location_gps_status_foreach_satellites_in_view_n_02(void); +static void utc_location_gps_status_foreach_satellites_in_view_n_03(void); +static void utc_location_gps_status_foreach_last_satellites_in_view_p(void); +static void utc_location_gps_status_foreach_last_satellites_in_view_n(void); +static void utc_location_gps_status_foreach_last_satellites_in_view_n_02(void); +static void utc_location_gps_status_get_last_satellite_p(void); +static void utc_location_gps_status_get_last_satellite_n(void); +static void utc_location_gps_status_get_last_satellite_n_02(void); +static void utc_location_gps_status_get_last_satellite_n_03(void); +static void utc_location_gps_status_get_last_satellite_n_04(void); + + + +struct tet_testlist tet_testlist[] = { + {utc_location_gps_status_get_nmea_p, POSITIVE_TC_IDX}, + {utc_location_gps_status_get_nmea_n, NEGATIVE_TC_IDX}, + {utc_location_gps_status_get_nmea_n_02, NEGATIVE_TC_IDX}, +// {utc_location_gps_status_get_nmea_n_03, NEGATIVE_TC_IDX}, //Can't check created location_manager_h + {utc_location_gps_status_get_satellite_p, POSITIVE_TC_IDX}, + {utc_location_gps_status_get_satellite_n, NEGATIVE_TC_IDX}, + {utc_location_gps_status_get_satellite_n_02, NEGATIVE_TC_IDX}, +// {utc_location_gps_status_get_satellite_n_03, NEGATIVE_TC_IDX}, //Can't check created location_manager_h + {utc_location_gps_status_get_satellite_n_04, NEGATIVE_TC_IDX}, + {utc_location_gps_status_get_satellite_n_05, NEGATIVE_TC_IDX}, + {utc_location_gps_status_get_satellite_n_06, NEGATIVE_TC_IDX}, + {utc_location_gps_status_foreach_satellites_in_view_p, POSITIVE_TC_IDX}, + {utc_location_gps_status_foreach_satellites_in_view_n, NEGATIVE_TC_IDX}, + {utc_location_gps_status_foreach_satellites_in_view_n_02, NEGATIVE_TC_IDX}, +// {utc_location_gps_status_foreach_satellites_in_view_n_03, NEGATIVE_TC_IDX }, //Can't check created location_manager_h + {utc_location_gps_status_foreach_last_satellites_in_view_p, POSITIVE_TC_IDX}, + {utc_location_gps_status_foreach_last_satellites_in_view_n, NEGATIVE_TC_IDX}, + {utc_location_gps_status_foreach_last_satellites_in_view_n_02, NEGATIVE_TC_IDX}, + {utc_location_gps_status_get_last_satellite_p, POSITIVE_TC_IDX}, + {utc_location_gps_status_get_last_satellite_n, NEGATIVE_TC_IDX}, + {utc_location_gps_status_get_last_satellite_n_02, NEGATIVE_TC_IDX}, + {utc_location_gps_status_get_last_satellite_n_03, NEGATIVE_TC_IDX}, + {utc_location_gps_status_get_last_satellite_n_04, NEGATIVE_TC_IDX}, + {NULL, 0}, +}; + +static GMainLoop *g_mainloop = NULL; +static GThread *event_thread; + +gpointer GmainThread(gpointer data) +{ + g_mainloop = g_main_loop_new(NULL, 0); + g_main_loop_run(g_mainloop); + + return NULL; +} + +static bool service_enabled = false; + +static void validate_and_next(char *api_name, int act_ret, int ext_ret, char *fail_msg) +{ + dts_message(api_name, "Actual Result : %d, Expected Result : %d", act_ret, ext_ret); + if (act_ret != ext_ret) { + dts_message(api_name, "Fail Message: %s", fail_msg); + dts_fail(api_name); + } +} + +static void validate_eq(char *api_name, int act_ret, int ext_ret) +{ + dts_message(api_name, "Actual Result : %d, Expected Result : %d", act_ret, ext_ret); + if (act_ret == ext_ret) { + dts_pass(api_name); + } else { + dts_fail(api_name); + } +} + +static void unprepare(location_manager_h manager) +{ + location_manager_unset_service_state_changed_cb(manager); + location_manager_destroy(manager); + service_enabled = false; +} + +static void wait_for_service(char *api_name) +{ + int timeout = 0; + for (timeout; timeout < 30; timeout++) { + if (service_enabled) { + dts_message(api_name, "Location Service Enabled!!!!"); + break; + } else { + dts_message(api_name, "Location Service Disabled!!!!"); + sleep(1); + } + } +} + +static void capi_state_changed_cb(location_service_state_e state, void *user_data) +{ + switch (state) { + case LOCATIONS_SERVICE_ENABLED: + service_enabled = true; + break; + case LOCATIONS_SERVICE_DISABLED: + service_enabled = false; + break; + default: + break; + } +} + +static location_manager_h manager; + +static void startup(void) +{ + g_setenv("PKG_NAME", "com.samsung.capi-location-gps-status-test", 1); + g_setenv("LOCATION_TEST_ENABLE", "1", 1); + +#if !GLIB_CHECK_VERSION (2, 31, 0) + if (!g_thread_supported()) { + g_thread_init(NULL); + } +#endif + + GError *gerr = NULL; + event_thread = g_thread_create(GmainThread, NULL, 1, &gerr); + + int ret; + ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed"); + + /* You don't need it + ret = location_manager_set_service_state_changed_cb(manager, capi_state_changed_cb, NULL); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed"); + */ + + ret = location_manager_start(manager); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed"); + + wait_for_service(__func__); +} + +static void cleanup(void) +{ + unprepare(manager); + g_main_loop_quit(g_mainloop); + g_thread_join(event_thread); +} + +static void utc_location_gps_status_get_nmea_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + char *nmea; + ret = gps_status_get_nmea(manager, &nmea); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_gps_status_get_nmea_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = gps_status_get_nmea(manager, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_nmea_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + char *nmea; + ret = gps_status_get_nmea(NULL, &nmea); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_gps_status_get_nmea_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + char *nmea; + location_manager_h manager_02; + ret = gps_status_get_nmea(manager_02, &nmea); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_gps_status_get_satellite_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + int num_of_active, num_of_inview; + time_t timestamp; + ret = gps_status_get_satellite(manager, &num_of_active, &num_of_inview, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_gps_status_get_satellite_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = gps_status_get_satellite(manager, NULL, NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_satellite_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + int num_of_active, num_of_inview; + time_t timestamp; + ret = gps_status_get_satellite(NULL, &num_of_active, &num_of_inview, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_satellite_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + int num_of_active, num_of_inview; + time_t timestamp; + location_manager_h manager_02; + ret = gps_status_get_satellite(manager_02, &num_of_active, &num_of_inview, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_satellite_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + int num_of_inview; + time_t timestamp; + ret = gps_status_get_satellite(manager, NULL, &num_of_inview, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_satellite_n_05(void) +{ + int ret = LOCATIONS_ERROR_NONE; + int num_of_active; + time_t timestamp; + ret = gps_status_get_satellite(manager, &num_of_active, NULL, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_satellite_n_06(void) +{ + int ret = LOCATIONS_ERROR_NONE; + int num_of_active, num_of_inview; + ret = gps_status_get_satellite(manager, &num_of_active, &num_of_inview, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static bool capi_gps_status_get_satellites_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, + bool is_in_use, void *user_data) +{ + return true; +} + +static void utc_location_gps_status_foreach_satellites_in_view_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = gps_status_foreach_satellites_in_view(manager, capi_gps_status_get_satellites_cb, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_gps_status_foreach_satellites_in_view_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = gps_status_foreach_satellites_in_view(manager, NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_foreach_satellites_in_view_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = gps_status_foreach_satellites_in_view(NULL, capi_gps_status_get_satellites_cb, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_foreach_satellites_in_view_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + ret = gps_status_foreach_satellites_in_view(manager_02, capi_gps_status_get_satellites_cb, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static bool capi_last_satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, + void *user_data) +{ + printf("[Last Satellite information] azimuth : %d, elevation : %d, prn :%d, snr : %d, used: %d\n", azimuth, elevation, + prn, snr, is_in_use); + return true; +} + +static void utc_location_gps_status_foreach_last_satellites_in_view_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = gps_status_foreach_last_satellites_in_view(manager, capi_last_satellites_foreach_cb, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_gps_status_foreach_last_satellites_in_view_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = gps_status_foreach_last_satellites_in_view(manager, NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_foreach_last_satellites_in_view_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = gps_status_foreach_last_satellites_in_view(NULL, capi_last_satellites_foreach_cb, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_last_satellite_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + time_t timestamp; + int num_of_inview, num_of_active; + ret = gps_status_get_last_satellite(manager, &num_of_active, &num_of_inview, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_gps_status_get_last_satellite_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + time_t timestamp; + int num_of_inview, num_of_active; + ret = gps_status_get_last_satellite(NULL, &num_of_active, &num_of_inview, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_last_satellite_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + time_t timestamp; + int num_of_inview; + ret = gps_status_get_last_satellite(manager, NULL, &num_of_inview, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_last_satellite_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + time_t timestamp; + int num_of_active; + ret = gps_status_get_last_satellite(manager, &num_of_active, NULL, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_gps_status_get_last_satellite_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int num_of_inview, num_of_active; + ret = gps_status_get_last_satellite(manager, &num_of_active, &num_of_inview, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + + diff --git a/TC/testcase/utc_location_location_manager.c b/TC/testcase/utc_location_location_manager.c new file mode 100755 index 0000000..ccc22e3 --- /dev/null +++ b/TC/testcase/utc_location_location_manager.c @@ -0,0 +1,1627 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <locations.h> +#include <glib.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +static void startup(void); +static void cleanup(void); + +void (*tet_startup) (void) = startup; +void (*tet_cleanup) (void) = cleanup; + +static void utc_location_location_manager_create_p(void); +static void utc_location_location_manager_create_p_02(void); +static void utc_location_location_manager_create_p_03(void); +static void utc_location_location_manager_create_p_04(void); +static void utc_location_location_manager_create_p_05(void); +static void utc_location_location_manager_create_n(void); +static void utc_location_location_manager_create_n_02(void); +static void utc_location_location_manager_create_n_03(void); +static void utc_location_location_manager_create_n_04(void); +static void utc_location_location_manager_create_n_05(void); +static void utc_location_location_manager_create_n_06(void); +static void utc_location_location_manager_add_boundary_p(void); +static void utc_location_location_manager_add_boundary_n(void); +static void utc_location_location_manager_add_boundary_n_02(void); +static void utc_location_location_manager_add_boundary_n_03(void); +static void utc_location_location_manager_add_boundary_n_04(void); +static void utc_location_location_manager_foreach_boundary_p(void); +static void utc_location_location_manager_foreach_boundary_n(void); +static void utc_location_location_manager_foreach_boundary_n_02(void); +static void utc_location_location_manager_foreach_boundary_n_03(void); +static void utc_location_location_manager_foreach_boundary_n_04(void); +static void utc_location_location_manager_remove_boundary_p(void); +static void utc_location_location_manager_remove_boundary_n(void); +static void utc_location_location_manager_remove_boundary_n_02(void); +static void utc_location_location_manager_remove_boundary_n_03(void); +static void utc_location_location_manager_remove_boundary_n_04(void); +static void utc_location_location_manager_get_method_p(void); +static void utc_location_location_manager_get_method_n(void); +static void utc_location_location_manager_get_method_n_02(void); +static void utc_location_location_manager_get_method_n_03(void); +static void utc_location_location_manager_get_method_n_04(void); +static void utc_location_location_manager_get_position_p(void); +static void utc_location_location_manager_get_position_n(void); +static void utc_location_location_manager_get_position_n_02(void); +static void utc_location_location_manager_get_position_n_03(void); +static void utc_location_location_manager_get_position_n_04(void); +static void utc_location_location_manager_get_position_n_05(void); +static void utc_location_location_manager_get_position_n_06(void); +static void utc_location_location_manager_get_velocity_p(void); +static void utc_location_location_manager_get_velocity_n(void); +static void utc_location_location_manager_get_velocity_n_02(void); +static void utc_location_location_manager_get_velocity_n_03(void); +static void utc_location_location_manager_get_velocity_n_04(void); +static void utc_location_location_manager_get_velocity_n_05(void); +static void utc_location_location_manager_get_velocity_n_06(void); +static void utc_location_location_manager_get_accuracy_p(void); +static void utc_location_location_manager_get_accuracy_n(void); +static void utc_location_location_manager_get_accuracy_n_02(void); +static void utc_location_location_manager_get_accuracy_n_03(void); +static void utc_location_location_manager_get_accuracy_n_04(void); +static void utc_location_location_manager_get_accuracy_n_05(void); +static void utc_location_location_manager_get_accuracy_n_06(void); +static void utc_location_location_bounds_foreach_polygon_coords_p(void); +static void utc_location_location_bounds_foreach_polygon_coords_n(void); +static void utc_location_location_bounds_foreach_polygon_coords_n_02(void); +static void utc_location_location_bounds_get_circle_coords_p(void); +static void utc_location_location_bounds_get_circle_coords_n(void); +static void utc_location_location_bounds_get_circle_coords_n_02(void); +static void utc_location_location_bounds_get_circle_coords_n_03(void); +static void utc_location_location_bounds_get_rect_coords_p(void); +static void utc_location_location_bounds_get_rect_coords_n(void); +static void utc_location_location_bounds_get_rect_coords_n_02(void); +static void utc_location_location_bounds_get_rect_coords_n_03(void); +static void utc_location_location_bounds_contains_coordinates_p(void); +static void utc_location_location_bounds_contains_coordinates_p_02(void); +static void utc_location_location_bounds_contains_coordinates_n(void); +static void utc_location_location_bounds_contains_coordinates_n_02(void); +static void utc_location_location_manager_get_last_accuracy_p(void); +static void utc_location_location_manager_get_last_accuracy_n(void); +static void utc_location_location_manager_get_last_accuracy_n_02(void); +static void utc_location_location_manager_get_last_accuracy_n_03(void); +static void utc_location_location_manager_get_last_accuracy_n_04(void); +static void utc_location_location_manager_get_last_position_p(void); +static void utc_location_location_manager_get_last_position_n(void); +static void utc_location_location_manager_get_last_position_n_02(void); +static void utc_location_location_manager_get_last_position_n_03(void); +static void utc_location_location_manager_get_last_position_n_04(void); +static void utc_location_location_manager_get_last_position_n_05(void); +static void utc_location_location_manager_get_last_velocity_p(void); +static void utc_location_location_manager_get_last_velocity_n(void); +static void utc_location_location_manager_get_last_velocity_n_02(void); +static void utc_location_location_manager_get_last_velocity_n_03(void); +static void utc_location_location_manager_get_last_velocity_n_04(void); +static void utc_location_location_manager_get_last_velocity_n_05(void); +static void utc_location_location_manager_is_supported_method_p(void); +static void utc_location_location_manager_is_supported_method_p_02(void); +static void utc_location_location_manager_is_supported_method_p_03(void); +static void utc_location_location_manager_is_supported_method_p_04(void); +static void utc_location_location_manager_is_supported_method_n(void); +static void utc_location_location_manager_is_supported_method_n_02(void); +static void utc_location_location_manager_send_command_p(void); +static void utc_location_location_manager_send_command_n(void); +static void utc_location_location_manager_destroy_p(void); +static void utc_location_location_manager_destroy_n(void); +static void utc_location_location_manager_destroy_n_02(void); + +struct tet_testlist tet_testlist[] = { + {utc_location_location_manager_create_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_create_p_02, POSITIVE_TC_IDX}, + {utc_location_location_manager_create_p_03, POSITIVE_TC_IDX}, + { utc_location_location_manager_create_p_04, POSITIVE_TC_IDX }, +// { utc_location_location_manager_create_p_05, POSITIVE_TC_IDX }, // LOCATIONS_METHOD_NONE is a negative TC. + {utc_location_location_manager_create_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_create_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_manager_create_n_03, NEGATIVE_TC_IDX}, + {utc_location_location_manager_create_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_create_n_05, NEGATIVE_TC_IDX}, + {utc_location_location_manager_create_n_06, NEGATIVE_TC_IDX}, + {utc_location_location_manager_add_boundary_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_add_boundary_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_add_boundary_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_manager_add_boundary_n_03, NEGATIVE_TC_IDX}, + {utc_location_location_manager_add_boundary_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_foreach_boundary_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_foreach_boundary_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_foreach_boundary_n_02, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_foreach_boundary_n_03, NEGATIVE_TC_IDX }, // Can't check created location_manager_h + {utc_location_location_manager_foreach_boundary_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_remove_boundary_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_remove_boundary_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_remove_boundary_n_02, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_remove_boundary_n_03, NEGATIVE_TC_IDX }, // Can't check created location_manager_h + {utc_location_location_manager_remove_boundary_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_method_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_get_method_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_method_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_method_n_03, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_get_method_n_04, NEGATIVE_TC_IDX }, // Can't check created location_manager_h + {utc_location_location_manager_get_position_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_get_position_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_position_n_02, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_get_position_n_03, NEGATIVE_TC_IDX }, // Can't check created location_manager_h + {utc_location_location_manager_get_position_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_position_n_05, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_position_n_06, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_velocity_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_get_velocity_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_velocity_n_02, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_get_velocity_n_03, NEGATIVE_TC_IDX }, // Can't check created location_manager_h + {utc_location_location_manager_get_velocity_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_velocity_n_05, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_velocity_n_06, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_accuracy_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_get_accuracy_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_accuracy_n_02, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_get_accuracy_n_03, NEGATIVE_TC_IDX }, // Can't check created location_manager_h + {utc_location_location_manager_get_accuracy_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_accuracy_n_05, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_accuracy_n_06, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_foreach_polygon_coords_p, POSITIVE_TC_IDX}, + {utc_location_location_bounds_foreach_polygon_coords_n, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_foreach_polygon_coords_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_get_circle_coords_p, POSITIVE_TC_IDX}, + {utc_location_location_bounds_get_circle_coords_n, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_get_circle_coords_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_get_circle_coords_n_03, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_get_rect_coords_p, POSITIVE_TC_IDX}, + {utc_location_location_bounds_get_rect_coords_n, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_get_rect_coords_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_get_rect_coords_n_03, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_contains_coordinates_p, POSITIVE_TC_IDX}, + {utc_location_location_bounds_contains_coordinates_p_02, POSITIVE_TC_IDX}, + {utc_location_location_bounds_contains_coordinates_n, NEGATIVE_TC_IDX}, + {utc_location_location_bounds_contains_coordinates_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_accuracy_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_get_last_accuracy_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_accuracy_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_accuracy_n_03, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_accuracy_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_position_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_get_last_position_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_position_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_position_n_03, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_position_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_position_n_05, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_velocity_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_get_last_velocity_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_velocity_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_velocity_n_03, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_velocity_n_04, NEGATIVE_TC_IDX}, + {utc_location_location_manager_get_last_velocity_n_05, NEGATIVE_TC_IDX}, + {utc_location_location_manager_is_supported_method_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_is_supported_method_p_02, POSITIVE_TC_IDX}, + {utc_location_location_manager_is_supported_method_p_03, POSITIVE_TC_IDX}, + {utc_location_location_manager_is_supported_method_p_04, POSITIVE_TC_IDX}, + {utc_location_location_manager_is_supported_method_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_is_supported_method_n_02, NEGATIVE_TC_IDX}, + {utc_location_location_manager_destroy_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_destroy_n, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_destroy_n_02, NEGATIVE_TC_IDX }, // Can't check created location_manager_h + {NULL, 0}, +}; + +static bool service_enabled = false; +static bool touch_foreach_bounds = false; + +static GMainLoop *g_mainloop = NULL; +static GThread *event_thread; + +gpointer GmainThread(gpointer data) +{ + g_mainloop = g_main_loop_new(NULL, 0); + g_main_loop_run(g_mainloop); + return NULL; +} + +static void validate_and_next(char *api_name, int act_ret, int ext_ret, char *fail_msg) +{ + dts_message(api_name, "Actual Result : %d, Expected Result : %d", act_ret, ext_ret); + if (act_ret != ext_ret) { + dts_message(api_name, "Fail Message: %s", fail_msg); + dts_fail(api_name); + } +} + +static void validate_eq(char *api_name, int act_ret, int ext_ret) +{ + dts_message(api_name, "Actual Result : %d, Expected Result : %d", act_ret, ext_ret); + if (act_ret == ext_ret) { + dts_pass(api_name); + } else { + dts_fail(api_name); + } +} + +static void wait_for_service(char *api_name) +{ + int timeout = 0; + for (timeout; timeout < 60; timeout++) { + if (service_enabled) { + dts_message(api_name, "Location Service Enabled!!!!"); + break; + } else { + dts_message(api_name, "Location Service Disabled!!!!"); + sleep(1); + } + } +} + +static void wait_for_bounds_foreach(char *api_name) +{ + int timeout = 0; + for (timeout; timeout < 30; timeout++) { + if (touch_foreach_bounds) { + dts_message(api_name, "bound foreach called!!!!"); + break; + } else { + dts_message(api_name, "No bound foreach!!!!"); + sleep(1); + } + } +} + +static void __state_changed_cb(location_service_state_e state, void *user_data) +{ + switch (state) { + case LOCATIONS_SERVICE_ENABLED: + service_enabled = true; + break; + case LOCATIONS_SERVICE_DISABLED: + service_enabled = false; + break; + default: + break; + } +} + +static bool __location_bounds_cb(location_bounds_h bounds, void *user_data) +{ + if (bounds == NULL) + printf("bounds ==NULL\n"); + else { + location_bounds_type_e type; + location_bounds_get_type(bounds, &type); + dts_message(__func__, "__location_bounds_cb - type : %d!!!!", type); + touch_foreach_bounds = TRUE; + } + return TRUE; +} + +static location_manager_h manager; +static location_bounds_h bounds_rect; +static location_bounds_h bounds_circle; +static location_bounds_h bounds_poly; + +static void startup(void) +{ + g_setenv("PKG_NAME", "com.samsung.capi-location-manager-test", 1); + g_setenv("LOCATION_TEST_ENABLE", "1", 1); + +#if !GLIB_CHECK_VERSION (2, 31, 0) + if (!g_thread_supported()) { + g_thread_init(NULL); + } +#endif + + event_thread = g_thread_create(GmainThread, NULL, 1, NULL); +} + +static void cleanup(void) +{ + if (manager) { + location_manager_unset_service_state_changed_cb(manager); + location_manager_stop(manager); + location_manager_destroy(manager); + manager = NULL; + } + + service_enabled = false; + touch_foreach_bounds = false; + g_main_loop_quit(g_mainloop); + g_thread_join(event_thread); +} + +static void utc_location_location_manager_create_p(void) +{ + int ret; + + ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed"); + + ret = location_manager_set_service_state_changed_cb(manager, __state_changed_cb, NULL); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed"); + + ret = location_manager_start(manager); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed"); + + wait_for_service(__func__); + + /* + location_manager_stop(manager); //If you call start() and then stop(), service_enabled always set false. + location_manager_unset_service_state_changed_cb(manager); + */ + + validate_eq(__func__, service_enabled, true); +} + +static void utc_location_location_manager_create_p_02(void) +{ + int ret; + location_manager_h manager_02; + + ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager_02); + + /* We don't need it + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed"); + + ret = location_manager_set_service_state_changed_cb(manager_02, __state_changed_cb, NULL); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed"); + + ret = location_manager_start(manager_02); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed"); + + wait_for_service(__func__); + + location_manager_stop(manager_02); + location_manager_unset_service_state_changed_cb(manager_02); + */ + + location_manager_destroy(manager_02); + + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_create_p_03(void) +{ + int ret; + location_manager_h manager_02; + + ret = location_manager_create(LOCATIONS_METHOD_WPS, &manager_02); + + /* We don't need it + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed"); + + ret = location_manager_set_service_state_changed_cb(manager_02, __state_changed_cb, NULL); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed"); + + ret = location_manager_start(manager_02); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed"); + + wait_for_service(__func__); + + location_manager_stop(manager_02); + location_manager_unset_service_state_changed_cb(manager_02); + */ + + location_manager_destroy(manager_02); + + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_create_p_04(void) +{ + int ret; + location_manager_h manager_02; + + ret = location_manager_create(LOCATIONS_METHOD_CPS, &manager_02); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed"); + + ret = location_manager_set_service_state_changed_cb(manager_02, __state_changed_cb, NULL); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed"); + + ret = location_manager_start(manager_02); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed"); + + wait_for_service(__func__); + + location_manager_stop(manager_02); + location_manager_unset_service_state_changed_cb(manager_02); + location_manager_destroy(manager_02); + + validate_eq(__func__, service_enabled, TRUE); +} + +static void utc_location_location_manager_create_p_05(void) +{ + int ret; + location_manager_h manager_02; + + ret = location_manager_create(LOCATIONS_METHOD_NONE, &manager_02); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed"); + + ret = location_manager_set_service_state_changed_cb(manager_02, __state_changed_cb, NULL); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed"); + + ret = location_manager_start(manager_02); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed"); + + wait_for_service(__func__); + + location_manager_stop(manager_02); + location_manager_unset_service_state_changed_cb(manager_02); + location_manager_destroy(manager_02); + + validate_eq(__func__, service_enabled, TRUE); +} + +static void utc_location_location_manager_create_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_create(LOCATIONS_METHOD_HYBRID, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_create_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_create(LOCATIONS_METHOD_NONE, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_create_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_create(LOCATIONS_METHOD_GPS, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_create_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_create(LOCATIONS_METHOD_WPS, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_create_n_05(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_create(LOCATIONS_METHOD_CPS, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_create_n_06(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + + ret = location_manager_create(LOCATIONS_METHOD_CPS + 1, &manager_02); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_add_boundary_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the circle bounds + location_coords_s center; + center.latitude = 37.258; + center.longitude = 127.056; + double radius = 30; + ret = location_bounds_create_circle(center, radius, &bounds_circle); + validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_circle() is failed"); + + ret = location_manager_add_boundary(manager, bounds_circle); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_add_boundary() is failed"); + + //Add the rect bounds + location_coords_s left_top; + left_top.latitude = 30; + left_top.longitude = 30; + + location_coords_s right_bottom; + right_bottom.latitude = 10; + right_bottom.longitude = 50; + + ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect); + validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_rect() is failed"); + + ret = location_manager_add_boundary(manager, bounds_rect); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_add_boundary() is failed"); + + //Add the polygon bounds + + int poly_size = 3; + location_coords_s coord_list[poly_size]; + + coord_list[0].latitude = 10; + coord_list[0].longitude = 10; + coord_list[1].latitude = 20; + coord_list[1].longitude = 20; + coord_list[2].latitude = 30; + coord_list[2].longitude = 30; + + ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly); + validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_polygon() is failed"); + + ret = location_manager_add_boundary(manager, bounds_poly); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_add_boundary_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_add_boundary(NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_add_boundary_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_add_boundary(manager, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_add_boundary_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the circle bounds + location_coords_s center; + center.latitude = 37.258; + center.longitude = 127.056; + double radius = 30; + ret = location_bounds_create_circle(center, radius, &bounds_circle); + validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_circle() is failed"); + + ret = location_manager_add_boundary(NULL, bounds_circle); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_add_boundary_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + + //Add the circle bounds + location_coords_s center; + center.latitude = 37.258; + center.longitude = 127.056; + double radius = 30; + ret = location_bounds_create_circle(center, radius, &bounds_circle); + validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_bounds_create_circle() is failed"); + + ret = location_manager_add_boundary(manager_02, bounds_circle); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_foreach_boundary_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_foreach_boundary(manager, __location_bounds_cb, (void *)manager); + validate_and_next(__func__, ret, LOCATION_BOUNDS_ERROR_NONE, "location_manager_foreach_boundary() is failed"); + wait_for_bounds_foreach(__func__); + validate_eq(__func__, touch_foreach_bounds, TRUE); +} + +static void utc_location_location_manager_foreach_boundary_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_foreach_boundary(NULL, NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_foreach_boundary_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_foreach_boundary(NULL, __location_bounds_cb, (void *)manager); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_foreach_boundary_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + ret = location_manager_foreach_boundary(manager_02, __location_bounds_cb, (void *)manager); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_foreach_boundary_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + ret = location_manager_foreach_boundary(manager, NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_remove_boundary_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_remove_boundary(manager, bounds_rect); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_remove_boundary(rect) is failed"); + ret = location_manager_remove_boundary(manager, bounds_circle); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_remove_boundary(circle) is failed"); + ret = location_manager_remove_boundary(manager, bounds_poly); + location_bounds_destroy(bounds_rect); + location_bounds_destroy(bounds_circle); + location_bounds_destroy(bounds_poly); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_remove_boundary_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_remove_boundary(NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_remove_boundary_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_remove_boundary(NULL, bounds_rect); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_remove_boundary_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + ret = location_manager_remove_boundary(manager_02, bounds_rect); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_remove_boundary_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_remove_boundary(manager, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_method_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_method_e method; + ret = location_manager_get_method(manager, &method); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_get_method_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_get_method(NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_get_method_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_get_method(manager, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_get_method_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_method_e method; + ret = location_manager_get_method(NULL, &method); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_get_method_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + location_method_e method; + ret = location_manager_get_method(manager_02, &method); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_get_position_p(void) +{ + + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + double longitude; + time_t timestamp; + + ret = location_manager_get_position(manager, &altitude, &latitude, &longitude, ×tamp); + dts_message(__func__, "altitude : %lf, latitude : %lf, longitude : %lf, timestamp:%d", latitude, latitude, longitude, + timestamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_get_position_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double latitude; + double longitude; + time_t timestamp; + + ret = location_manager_get_position(manager, NULL, &latitude, &longitude, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_position_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + double longitude; + time_t timestamp; + + ret = location_manager_get_position(NULL, &altitude, &latitude, &longitude, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_position_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + double longitude; + time_t timestamp; + location_manager_h manager_02; + + ret = location_manager_get_position(manager_02, &altitude, &latitude, &longitude, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_position_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double longitude; + time_t timestamp; + + ret = location_manager_get_position(manager, &altitude, NULL, &longitude, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_position_n_05(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + time_t timestamp; + + ret = location_manager_get_position(manager, &altitude, &latitude, NULL, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_position_n_06(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + double longitude; + + ret = location_manager_get_position(manager, &altitude, &latitude, &longitude, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_velocity_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + int speed; + time_t timestamp; + + ret = location_manager_get_velocity(manager, &climb, &direction, &speed, ×tamp); + dts_message(__func__, "climb : %lf, direction : %lf, speed : %lf, timestamp:%d", climb, direction, speed, timestamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_get_velocity_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int direction; + int speed; + time_t timestamp; + + ret = location_manager_get_velocity(manager, NULL, &direction, &speed, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_velocity_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + int speed; + time_t timestamp; + + ret = location_manager_get_velocity(NULL, &climb, &direction, &speed, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_velocity_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + int speed; + time_t timestamp; + location_manager_h manager_02; + + ret = location_manager_get_velocity(manager_02, &climb, &direction, &speed, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_velocity_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int speed; + time_t timestamp; + + ret = location_manager_get_velocity(manager, &climb, NULL, &speed, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_velocity_n_05(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + time_t timestamp; + + ret = location_manager_get_velocity(manager, &climb, &direction, NULL, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_velocity_n_06(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + int speed; + + ret = location_manager_get_velocity(manager, &climb, &direction, &speed, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_accuracy_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_accuracy_level_e level; + double horizontal; + double vertical; + + ret = location_manager_get_accuracy(manager, &level, &horizontal, &vertical); + dts_message(__func__, "Level : %lf, horizontal : %lf, vertical : %lf", level, horizontal, vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_get_accuracy_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_get_accuracy(manager, NULL, NULL, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_accuracy_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_accuracy_level_e level; + double horizontal; + double vertical; + + ret = location_manager_get_accuracy(NULL, &level, &horizontal, &vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_accuracy_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_accuracy_level_e level; + double horizontal; + double vertical; + location_manager_h manager_02; + + ret = location_manager_get_accuracy(manager_02, &level, &horizontal, &vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_accuracy_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double horizontal; + double vertical; + + ret = location_manager_get_accuracy(manager, NULL, &horizontal, &vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_accuracy_n_05(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_accuracy_level_e level; + double vertical; + + ret = location_manager_get_accuracy(manager, &level, NULL, &vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_accuracy_n_06(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_accuracy_level_e level; + double horizontal; + + ret = location_manager_get_accuracy(manager, &level, &horizontal, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static bool capi_poly_coords_cb(location_coords_s coords, void *user_data) +{ + printf("location_bounds_foreach_rect_coords(latitude : %lf, longitude: %lf) \n", coords.latitude, coords.longitude); + return TRUE; +} + +static void utc_location_location_bounds_foreach_polygon_coords_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the polygon bounds + int poly_size = 3; + location_coords_s coord_list[poly_size]; + + coord_list[0].latitude = 10; + coord_list[0].longitude = 10; + coord_list[1].latitude = 20; + coord_list[1].longitude = 20; + coord_list[2].latitude = 30; + coord_list[2].longitude = 30; + + location_bounds_h bounds_poly; + ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed"); + + ret = location_bounds_foreach_polygon_coords(bounds_poly, capi_poly_coords_cb, NULL); + + location_bounds_destroy(bounds_poly); + + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_bounds_foreach_polygon_coords_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_bounds_foreach_polygon_coords(NULL, capi_poly_coords_cb, NULL); + + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_bounds_foreach_polygon_coords_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the polygon bounds + int poly_size = 3; + location_coords_s coord_list[poly_size]; + + coord_list[0].latitude = 10; + coord_list[0].longitude = 10; + coord_list[1].latitude = 20; + coord_list[1].longitude = 20; + coord_list[2].latitude = 30; + coord_list[2].longitude = 30; + + location_bounds_h bounds_poly; + ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed"); + + ret = location_bounds_foreach_polygon_coords(bounds_poly, NULL, NULL); + + location_bounds_destroy(bounds_poly); + + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_bounds_get_circle_coords_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_coords_s center; + center.latitude = 37.258; + center.longitude = 127.056; + double radius = 30; + location_bounds_h bounds_circle; + ret = location_bounds_create_circle(center, radius, &bounds_circle); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_circle() is failed"); + + location_coords_s center2; + double radius2; + ret = location_bounds_get_circle_coords(bounds_circle, ¢er2, &radius2); + + location_bounds_destroy(bounds_circle); + + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_bounds_get_circle_coords_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_coords_s center2; + double radius2; + ret = location_bounds_get_circle_coords(NULL, ¢er2, &radius2); + + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_bounds_get_circle_coords_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_coords_s center; + center.latitude = 37.258; + center.longitude = 127.056; + double radius = 30; + location_bounds_h bounds_circle; + ret = location_bounds_create_circle(center, radius, &bounds_circle); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_circle() is failed"); + + double radius2; + ret = location_bounds_get_circle_coords(bounds_circle, NULL, &radius2); + + location_bounds_destroy(bounds_circle); + + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_bounds_get_circle_coords_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_coords_s center; + center.latitude = 37.258; + center.longitude = 127.056; + double radius = 30; + location_bounds_h bounds_circle; + ret = location_bounds_create_circle(center, radius, &bounds_circle); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_circle() is failed"); + + location_coords_s center2; + ret = location_bounds_get_circle_coords(bounds_circle, ¢er2, NULL); + + location_bounds_destroy(bounds_circle); + + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_bounds_get_rect_coords_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the rect bounds + location_coords_s left_top; + left_top.latitude = 30; + left_top.longitude = 30; + + location_coords_s right_bottom; + right_bottom.latitude = 10; + right_bottom.longitude = 50; + + location_bounds_h bounds_rect; + ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_rect() is failed"); + + location_coords_s left_top2; + location_coords_s right_bottom2; + ret = location_bounds_get_rect_coords(bounds_rect, &left_top2, &right_bottom2); + + location_bounds_destroy(bounds_rect); + + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_bounds_get_rect_coords_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_coords_s left_top2; + location_coords_s right_bottom2; + ret = location_bounds_get_rect_coords(NULL, &left_top2, &right_bottom2); + + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_bounds_get_rect_coords_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the rect bounds + location_coords_s left_top; + left_top.latitude = 30; + left_top.longitude = 30; + + location_coords_s right_bottom; + right_bottom.latitude = 10; + right_bottom.longitude = 50; + + location_bounds_h bounds_rect; + ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_rect() is failed"); + + location_coords_s right_bottom2; + ret = location_bounds_get_rect_coords(bounds_rect, NULL, &right_bottom2); + + location_bounds_destroy(bounds_rect); + + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_bounds_get_rect_coords_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the rect bounds + location_coords_s left_top; + left_top.latitude = 30; + left_top.longitude = 30; + + location_coords_s right_bottom; + right_bottom.latitude = 10; + right_bottom.longitude = 50; + + location_bounds_h bounds_rect; + ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_rect() is failed"); + + location_coords_s left_top2; + ret = location_bounds_get_rect_coords(bounds_rect, &left_top2, NULL); + + location_bounds_destroy(bounds_rect); + + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_bounds_contains_coordinates_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the polygon bounds + int poly_size = 3; + location_coords_s coord_list[poly_size]; + + coord_list[0].latitude = 10; + coord_list[0].longitude = 10; + coord_list[1].latitude = 20; + coord_list[1].longitude = 20; + coord_list[2].latitude = 30; + coord_list[2].longitude = 10; + + location_bounds_h bounds_poly; + ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed"); + + location_coords_s test_coords; + test_coords.latitude = 20; + test_coords.longitude = 12; + bool contained = FALSE; + contained = location_bounds_contains_coordinates(bounds_poly, test_coords); + + location_bounds_destroy(bounds_poly); + + validate_eq(__func__, contained, TRUE); +} + +static void utc_location_location_bounds_contains_coordinates_p_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the polygon bounds + int poly_size = 3; + location_coords_s coord_list[poly_size]; + + coord_list[0].latitude = 10; + coord_list[0].longitude = 10; + coord_list[1].latitude = 20; + coord_list[1].longitude = 20; + coord_list[2].latitude = 30; + coord_list[2].longitude = 10; + + location_bounds_h bounds_poly; + ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed"); + + location_coords_s test_coords; + test_coords.latitude = 50; + test_coords.longitude = 50; + bool contained = FALSE; + contained = location_bounds_contains_coordinates(bounds_poly, test_coords); + + location_bounds_destroy(bounds_poly); + + validate_eq(__func__, contained, FALSE); +} + + +static void utc_location_location_bounds_contains_coordinates_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_coords_s test_coords; + test_coords.latitude = 12; + test_coords.longitude = 12; + ret = location_bounds_contains_coordinates(NULL, test_coords); + + validate_eq(__func__, ret, FALSE); +} + +static void utc_location_location_bounds_contains_coordinates_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + //Add the polygon bounds + int poly_size = 3; + location_coords_s coord_list[poly_size]; + + coord_list[0].latitude = 10; + coord_list[0].longitude = 10; + coord_list[1].latitude = 20; + coord_list[1].longitude = 20; + coord_list[2].latitude = 30; + coord_list[2].longitude = 10; + + location_bounds_h bounds_poly; + ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_bounds_create_polygon() is failed"); + + location_coords_s coord_test; + coord_test.latitude = -91; + coord_test.longitude = 181; + ret = location_bounds_contains_coordinates(bounds_poly, coord_test); + + location_bounds_destroy(bounds_poly); + + validate_eq(__func__, ret, FALSE); +} + +static void utc_location_location_manager_get_last_accuracy_p(void) +{ + + int ret = LOCATIONS_ERROR_NONE; + + double horizontal, vertical; + location_accuracy_level_e level; + + ret = location_manager_get_last_accuracy(manager, &level, &horizontal, &vertical); + dts_message(__func__, "Level : %d, horizontal: %g, vertical : %g\n", level, horizontal, vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_get_last_accuracy_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double horizontal, vertical; + location_accuracy_level_e level; + + ret = location_manager_get_last_accuracy(NULL, &level, &horizontal, &vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_accuracy_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double horizontal, vertical; + + ret = location_manager_get_last_accuracy(manager, NULL, &horizontal, &vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_accuracy_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double vertical; + location_accuracy_level_e level; + + ret = location_manager_get_last_accuracy(manager, &level, NULL, &vertical); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_accuracy_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double horizontal; + location_accuracy_level_e level; + + ret = location_manager_get_last_accuracy(manager, &level, &horizontal, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_position_p(void) +{ + + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + double longitude; + time_t timestamp; + + ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, ×tamp); + dts_message(__func__, "altitude : %lf, latitude : %lf, longitude : %lf, timestamp:%d", latitude, latitude, longitude, + timestamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_get_last_position_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + double longitude; + time_t timestamp; + + ret = location_manager_get_last_position(NULL, &altitude, &latitude, &longitude, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_position_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double latitude; + double longitude; + time_t timestamp; + + ret = location_manager_get_last_position(manager, NULL, &latitude, &longitude, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_position_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double longitude; + time_t timestamp; + + ret = location_manager_get_last_position(manager, &altitude, NULL, &longitude, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_position_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + time_t timestamp; + + ret = location_manager_get_last_position(manager, &altitude, &latitude, NULL, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_position_n_05(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + double altitude; + double latitude; + double longitude; + + ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_velocity_p(void) +{ + + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + int speed; + time_t timestamp; + + ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, ×tamp); + dts_message(__func__, "climb : %lf, direction : %lf, speed : %lf, timestamp:%d", climb, direction, speed, timestamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_get_last_velocity_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + int speed; + time_t timestamp; + + ret = location_manager_get_last_velocity(NULL, &climb, &direction, &speed, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_velocity_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int direction; + int speed; + time_t timestamp; + + ret = location_manager_get_last_velocity(manager, NULL, &direction, &speed, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_velocity_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int speed; + time_t timestamp; + + ret = location_manager_get_last_velocity(manager, &climb, NULL, &speed, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_velocity_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + time_t timestamp; + + ret = location_manager_get_last_velocity(manager, &climb, &direction, NULL, ×tamp); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_get_last_velocity_n_05(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + int climb; + int direction; + int speed; + + ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_is_supported_method_p(void) +{ + bool supported = FALSE; + supported = location_manager_is_supported_method(LOCATIONS_METHOD_HYBRID); + validate_eq(__func__, supported, TRUE); +} + +static void utc_location_location_manager_is_supported_method_p_02(void) +{ + bool supported = FALSE; + supported = location_manager_is_supported_method(LOCATIONS_METHOD_GPS); + validate_eq(__func__, supported, TRUE); +} + +static void utc_location_location_manager_is_supported_method_p_03(void) +{ + bool supported = FALSE; + supported = location_manager_is_supported_method(LOCATIONS_METHOD_WPS); + validate_eq(__func__, supported, TRUE); +} + +static void utc_location_location_manager_is_supported_method_p_04(void) +{ + bool supported = FALSE; + supported = location_manager_is_supported_method(LOCATIONS_METHOD_CPS); + validate_eq(__func__, supported, TRUE); +} + +static void utc_location_location_manager_is_supported_method_n(void) +{ + bool supported = FALSE; + supported = location_manager_is_supported_method(LOCATIONS_METHOD_NONE); + validate_eq(__func__, supported, FALSE); +} + +static void utc_location_location_manager_is_supported_method_n_02(void) +{ + bool supported = FALSE; + supported = location_manager_is_supported_method(LOCATIONS_METHOD_CPS + 1); + validate_eq(__func__, supported, FALSE); +} + +static void utc_location_location_manager_send_command_p(void) +{ + + int ret = LOCATIONS_ERROR_NONE; + + const *str = "command"; + ret = location_manager_send_command(str); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_send_command_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_send_command(NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_destroy_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_destroy(manager); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); + +} + +static void utc_location_location_manager_destroy_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_destroy(NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} + +static void utc_location_location_manager_destroy_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_manager_h manager_02; + + ret = location_manager_destroy(manager_02); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); + +} diff --git a/TC/testcase/utc_location_location_manager_callback.c b/TC/testcase/utc_location_location_manager_callback.c new file mode 100644 index 0000000..7d4c70d --- /dev/null +++ b/TC/testcase/utc_location_location_manager_callback.c @@ -0,0 +1,466 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <locations.h> +#include <glib.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +static void startup(void); +static void cleanup(void); + +void (*tet_startup) (void) = startup; +void (*tet_cleanup) (void) = cleanup; + +static void utc_location_location_manager_start_p(void); +static void utc_location_location_manager_start_n(void); +static void utc_location_location_manager_start_n_02(void); +static void utc_location_location_manager_set_position_updated_callback_p(void); +static void utc_location_location_manager_set_position_updated_callback_n(void); +static void utc_location_location_manager_set_position_updated_callback_n_02(void); +static void utc_location_location_manager_set_position_updated_callback_n_03(void); +static void utc_location_location_manager_set_position_updated_callback_n_04(void); +static void utc_location_location_manager_set_position_updated_callback_n_05(void); +static void utc_location_location_manager_unset_position_updated_callback_p(void); +static void utc_location_location_manager_unset_position_updated_callback_n(void); +static void utc_location_location_manager_set_velocity_updated_callback_p(void); +static void utc_location_location_manager_set_velocity_updated_callback_n(void); +static void utc_location_location_manager_set_velocity_updated_callback_n_02(void); +static void utc_location_location_manager_set_velocity_updated_callback_n_03(void); +static void utc_location_location_manager_unset_velocity_updated_callback_p(void); +static void utc_location_location_manager_unset_velocity_updated_callback_n(void); +static void utc_location_location_manager_set_service_state_changed_callback_p(void); +static void utc_location_location_manager_set_service_state_changed_callback_n(void); +static void utc_location_location_manager_set_service_state_changed_callback_n_02(void); +static void utc_location_location_manager_set_service_state_changed_callback_n_03(void); +static void utc_location_location_manager_unset_service_state_changed_callback_p(void); +static void utc_location_location_manager_unset_service_state_changed_callback_n(void); +static void utc_location_location_manager_set_zone_changed_callback_p(void); +static void utc_location_location_manager_set_zone_changed_callback_n(void); +static void utc_location_location_manager_set_zone_changed_callback_n_02(void); +static void utc_location_location_manager_set_zone_changed_callback_n_03(void); +static void utc_location_location_manager_unset_zone_changed_callback_p(void); +static void utc_location_location_manager_unset_zone_changed_callback_n(void); +static void utc_location_location_manager_stop_p(void); +static void utc_location_location_manager_stop_n(void); +static void utc_location_location_manager_stop_n_02(void); + +struct tet_testlist tet_testlist[] = { + {utc_location_location_manager_start_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_start_n, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_start_n_02, NEGATIVE_TC_IDX }, //Can't check address of created location_manager_h + {utc_location_location_manager_set_position_updated_callback_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_set_position_updated_callback_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_unset_position_updated_callback_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_unset_position_updated_callback_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_set_velocity_updated_callback_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_set_velocity_updated_callback_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_set_velocity_updated_callback_n_02, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_set_velocity_updated_callback_n_03, NEGATIVE_TC_IDX }, //Can't check address of created location_manager_h + {utc_location_location_manager_unset_velocity_updated_callback_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_unset_velocity_updated_callback_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_set_service_state_changed_callback_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_set_service_state_changed_callback_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_set_service_state_changed_callback_n_02, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_set_service_state_changed_callback_n_03, NEGATIVE_TC_IDX }, // Can't check address of created location_manager_h + {utc_location_location_manager_unset_service_state_changed_callback_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_unset_service_state_changed_callback_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_set_zone_changed_callback_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_set_zone_changed_callback_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_set_zone_changed_callback_n_02, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_set_zone_changed_callback_n_03, NEGATIVE_TC_IDX }, // Can't check address of created location_manager_h + {utc_location_location_manager_unset_zone_changed_callback_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_unset_zone_changed_callback_n, NEGATIVE_TC_IDX}, + {utc_location_location_manager_stop_p, POSITIVE_TC_IDX}, + {utc_location_location_manager_stop_n, NEGATIVE_TC_IDX}, +// { utc_location_location_manager_stop_n_02, NEGATIVE_TC_IDX }, //Can't check address of created location_manager_h + {NULL, 0}, +}; + +static bool service_enabled = false; + +static void validate_and_next(char *api_name, int act_ret, int ext_ret, char *fail_msg) +{ + dts_message(api_name, "Actual Result : %d, Expected Result : %d", act_ret, ext_ret); + if (act_ret != ext_ret) { + dts_message(api_name, "Fail Message: %s", fail_msg); + dts_fail(api_name); + } +} + +static void validate_eq(char *api_name, int act_ret, int ext_ret) +{ + dts_message(api_name, "Actual Result : %d, Expected Result : %d", act_ret, ext_ret); + if (act_ret == ext_ret) { + dts_pass(api_name); + } else { + dts_fail(api_name); + } +} + +static void validate_neq(char *api_name, int act_ret, int ext_ret) +{ + dts_message(api_name, "Actual Result : %d, N-Expected Result : %d", act_ret, ext_ret); + if (act_ret != ext_ret) { + dts_pass(api_name); + } else { + dts_fail(api_name); + } +} + +static void unprepare(location_manager_h manager) +{ + location_manager_unset_service_state_changed_cb(manager); + location_manager_destroy(manager); + service_enabled = false; +} + +static void wait_for_service(char *api_name) +{ + int timeout = 0; + for (timeout; timeout < 30; timeout++) { + if (service_enabled) { + dts_message(api_name, "Location Service Enabled!!!!"); + break; + } else { + dts_message(api_name, "Location Service Disabled!!!!"); + sleep(1); + } + } +} + +static void capi_state_changed_cb(location_service_state_e state, void *user_data) +{ + switch (state) { + case LOCATIONS_SERVICE_ENABLED: + service_enabled = true; + break; + case LOCATIONS_SERVICE_DISABLED: + service_enabled = false; + break; + default: + break; + } +} + +static GMainLoop *g_mainloop = NULL; +static GThread *event_thread; + +gpointer GmainThread(gpointer data) +{ + g_mainloop = g_main_loop_new(NULL, 0); + g_main_loop_run(g_mainloop); + return NULL; +} + +static location_manager_h manager; + +static void startup(void) +{ + g_setenv("PKG_NAME", "com.samsung.capi-location-manager-callback-test", 1); + g_setenv("LOCATION_TEST_ENABLE", "1", 1); + +#if !GLIB_CHECK_VERSION (2, 31, 0) + if (!g_thread_supported()) { + g_thread_init(NULL); + } +#endif + + GError *gerr = NULL; + event_thread = g_thread_create(GmainThread, NULL, 1, &gerr); + +} + +static void cleanup(void) +{ + unprepare(manager); + g_main_loop_quit(g_mainloop); + g_thread_join(event_thread); +} + +static void capi_position_updated_cb(double latitude, double longitude, double altitude, time_t timestamp, void *user_data) +{ +} + +static void capi_zone_changed_cb(location_boundary_state_e state, double latitude, double longitude, double altitude, + time_t timestamp, void *user_data) +{ +} + +static void capi_velocity_updated_cb(double speed, double direction, double climb, time_t timestamp, void *user_data) +{ +} + +static bool capi_geocoder_get_position_cb(double latitude, double longitude, void *user_data) +{ + return true; +} + +static void utc_location_location_manager_start_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_create() is failed"); + + ret = location_manager_set_service_state_changed_cb(manager, capi_state_changed_cb, NULL); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_set_service_state_changed_cb() is failed"); + + ret = location_manager_start(manager); + validate_and_next(__func__, ret, LOCATIONS_ERROR_NONE, "location_manager_start() is failed"); + wait_for_service(__func__); + + validate_eq(__func__, service_enabled, true); + +} + +static void utc_location_location_manager_start_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_start(NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_start_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + location_manager_h manager_02; + + ret = location_manager_start(manager_02); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_set_position_updated_callback_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_position_updated_cb(manager, capi_position_updated_cb, 1, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_position_updated_callback_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_position_updated_cb(manager, NULL, 1, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_position_updated_callback_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_position_updated_cb(NULL, capi_position_updated_cb, 1, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_position_updated_callback_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + ret = location_manager_set_position_updated_cb(manager_02, capi_position_updated_cb, 1, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_position_updated_callback_n_04(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_position_updated_cb(manager, capi_position_updated_cb, 0, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_position_updated_callback_n_05(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_position_updated_cb(manager, capi_position_updated_cb, 121, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_unset_position_updated_callback_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_unset_position_updated_cb(manager); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_unset_position_updated_callback_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_unset_position_updated_cb(NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_velocity_updated_callback_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_velocity_updated_cb(manager, capi_velocity_updated_cb, 1, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_velocity_updated_callback_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_velocity_updated_cb(manager, NULL, 1, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); + +} + +static void utc_location_location_manager_set_velocity_updated_callback_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_velocity_updated_cb(NULL, capi_velocity_updated_cb, 1, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); + +} + +static void utc_location_location_manager_set_velocity_updated_callback_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + ret = location_manager_set_velocity_updated_cb(manager_02, capi_velocity_updated_cb, 1, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); + +} + +static void utc_location_location_manager_unset_velocity_updated_callback_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_unset_velocity_updated_cb(manager); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_unset_velocity_updated_callback_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_unset_velocity_updated_cb(NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_service_state_changed_callback_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_service_state_changed_cb(manager, capi_state_changed_cb, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_service_state_changed_callback_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_service_state_changed_cb(manager, NULL, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_service_state_changed_callback_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_service_state_changed_cb(NULL, capi_state_changed_cb, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_service_state_changed_callback_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + ret = location_manager_set_service_state_changed_cb(manager_02, capi_state_changed_cb, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_unset_service_state_changed_callback_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_unset_service_state_changed_cb(manager); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_unset_service_state_changed_callback_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_unset_service_state_changed_cb(NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); + +} + +static void utc_location_location_manager_set_zone_changed_callback_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_zone_changed_cb(manager, capi_zone_changed_cb, NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); + +} + +static void utc_location_location_manager_set_zone_changed_callback_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_zone_changed_cb(manager, NULL, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_zone_changed_callback_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_set_zone_changed_cb(NULL, capi_zone_changed_cb, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_set_zone_changed_callback_n_03(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + ret = location_manager_set_zone_changed_cb(manager_02, capi_zone_changed_cb, NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_unset_zone_changed_callback_p(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_unset_zone_changed_cb(manager); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_unset_zone_changed_callback_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_unset_zone_changed_cb(NULL); + validate_neq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_stop_p(void) +{ + + int ret = LOCATIONS_ERROR_NONE; + ret = location_manager_stop(manager); + validate_eq(__func__, ret, LOCATIONS_ERROR_NONE); +} + +static void utc_location_location_manager_stop_n(void) +{ + int ret = LOCATIONS_ERROR_NONE; + + ret = location_manager_stop(NULL); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} + +static void utc_location_location_manager_stop_n_02(void) +{ + int ret = LOCATIONS_ERROR_NONE; + location_manager_h manager_02; + + ret = location_manager_stop(manager_02); + validate_eq(__func__, ret, LOCATIONS_ERROR_INVALID_PARAMETER); +} diff --git a/TC/testcase/utc_location_preference.c b/TC/testcase/utc_location_preference.c new file mode 100644 index 0000000..63f5bb7 --- /dev/null +++ b/TC/testcase/utc_location_preference.c @@ -0,0 +1,334 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <location_preference.h> +#include <geocoder.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +static void startup(void); +static void cleanup(void); + +void (*tet_startup) (void) = startup; +void (*tet_cleanup) (void) = cleanup; + +static void utc_location_location_preference_foreach_available_property_keys_p(void); +static void utc_location_location_preference_foreach_available_property_keys_n(void); +static void utc_location_location_preference_foreach_available_property_values_p(void); +static void utc_location_location_preference_foreach_available_property_values_n(void); +static void utc_location_location_preference_foreach_available_languages_p(void); +static void utc_location_location_preference_foreach_available_languages_n(void); +static void utc_location_location_preference_foreach_properties_p(void); +static void utc_location_location_preference_foreach_properties_n(void); +static void utc_location_location_preference_set_p(void); +static void utc_location_location_preference_set_n(void); +static void utc_location_location_preference_get_p(void); +static void utc_location_location_preference_get_n(void); +static void utc_location_location_preference_get_provider_name_p(void); +static void utc_location_location_preference_get_provider_name_n(void); +static void utc_location_location_preference_get_distance_unit_p(void); +static void utc_location_location_preference_get_distance_unit_n(void); +static void utc_location_location_preference_set_distance_unit_p(void); +static void utc_location_location_preference_set_distance_unit_n(void); +static void utc_location_location_preference_get_language_p(void); +static void utc_location_location_preference_get_language_n(void); +static void utc_location_location_preference_set_language_p(void); +static void utc_location_location_preference_set_language_n(void); + +struct tet_testlist tet_testlist[] = { +// { utc_location_location_preference_foreach_available_property_keys_p, POSITIVE_TC_IDX }, + {utc_location_location_preference_foreach_available_property_keys_n, NEGATIVE_TC_IDX}, +// { utc_location_location_preference_foreach_available_property_values_p, POSITIVE_TC_IDX }, + {utc_location_location_preference_foreach_available_property_values_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_foreach_available_languages_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_foreach_available_languages_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_set_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_set_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_foreach_properties_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_foreach_properties_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_get_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_get_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_get_provider_name_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_get_provider_name_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_set_distance_unit_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_set_distance_unit_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_get_distance_unit_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_get_distance_unit_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_set_language_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_set_language_n, NEGATIVE_TC_IDX}, + {utc_location_location_preference_get_language_p, POSITIVE_TC_IDX}, + {utc_location_location_preference_get_language_n, NEGATIVE_TC_IDX}, + {NULL, 0}, +}; + +static geocoder_h geocoder; +static char *available_language; +static char *available_key; +static char *available_value; + +static void startup(void) +{ + g_setenv("PKG_NAME", "com.samsung.capi-location-preference", 1); + g_setenv("LOCATION_TEST_ENABLE", "1", 1); + + tet_printf("TC start"); + + int ret = geocoder_create(&geocoder); + available_language = NULL; + available_key = NULL; + available_value = NULL; + if (ret != GEOCODER_ERROR_NONE) { + tet_printf("Creating the handle of geocoder failed"); + return; + } else { + tet_printf("Creating the handle of geocoder succeeded"); + } +} + +static void cleanup(void) +{ + geocoder_destroy(geocoder); +} + +bool location_preference_available_property_key_cb_impl(const char *key, void *user_data) +{ + tet_printf("key : %s", key); + available_key = strdup(key); + return false; +} + +bool location_preference_available_property_value_cb_impl(const char *value, void *user_data) +{ + tet_printf("value : %s", value); + available_value = strdup(value); + return false; +} + +bool location_preference_available_language_cb_impl(const char *language, void *user_data) +{ + available_language = strdup(language); + tet_printf("available language : %s", available_language); + return false; +} + +bool location_preference_property_cb_impl(const char *key, const char *value, void *user_data) +{ + tet_printf("key : %s", key); + tet_printf("value : %s", value); + return false; +} + +static void utc_location_location_preference_foreach_available_property_keys_p(void) +{ + int ret = location_preference_foreach_available_property_keys(GET_LOCATION_SERVICE(geocoder), + location_preference_available_property_key_cb_impl, NULL); + if (ret == LOCATION_PREFERENCE_ERROR_NONE) { + dts_pass(__func__, "location_preference_foreach_available_property_keys passed"); + } else { + dts_fail(__func__, "location_preference_foreach_available_property_keys failed"); + } +} + +static void utc_location_location_preference_foreach_available_property_keys_n(void) +{ + int ret = location_preference_foreach_available_property_keys(GET_LOCATION_SERVICE(geocoder), NULL, NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_foreach_available_property_values_p(void) +{ + int ret = location_preference_foreach_available_property_values(GET_LOCATION_SERVICE(geocoder), available_key, + location_preference_available_property_value_cb_impl, + NULL); + if (ret == LOCATION_PREFERENCE_ERROR_NONE) { + dts_pass(__func__, "location_preference_foreach_available_property_values passed"); + } else { + dts_fail(__func__, "location_preference_foreach_available_property_values failed"); + } +} + +static void utc_location_location_preference_foreach_available_property_values_n(void) +{ + int ret = location_preference_foreach_available_property_values(GET_LOCATION_SERVICE(geocoder), NULL, NULL, NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_foreach_available_languages_p(void) +{ + int ret = location_preference_foreach_available_languages(GET_LOCATION_SERVICE(geocoder), + location_preference_available_language_cb_impl, NULL); + if (ret == LOCATION_PREFERENCE_ERROR_NONE) { + dts_pass(__func__, "location_preference_foreach_available_languages passed"); + } else { + dts_fail(__func__, "location_preference_foreach_available_languages failed"); + } +} + +static void utc_location_location_preference_foreach_available_languages_n(void) +{ + int ret = location_preference_foreach_available_languages(GET_LOCATION_SERVICE(geocoder), NULL, NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_foreach_properties_p(void) +{ + int ret = + location_preference_foreach_properties(GET_LOCATION_SERVICE(geocoder), location_preference_property_cb_impl, NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_foreach_properties failed."); +} + +static void utc_location_location_preference_foreach_properties_n(void) +{ + int ret = location_preference_foreach_properties(GET_LOCATION_SERVICE(geocoder), NULL, NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_set_p(void) +{ + if (available_key == NULL) { + available_key = strdup("test_key"); + available_value = strdup("test_value"); + } + int ret = location_preference_set(GET_LOCATION_SERVICE(geocoder), available_key, available_value); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_set failed."); +} + +static void utc_location_location_preference_set_n(void) +{ + int ret = location_preference_set(GET_LOCATION_SERVICE(geocoder), NULL, NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_get_p(void) +{ + int ret = 0; + char *value = NULL; + + ret = location_preference_get(GET_LOCATION_SERVICE(geocoder), available_key, &value); + if (value != NULL) { + tet_printf("value: %s", value); + } + + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_get failed."); +} + +static void utc_location_location_preference_get_n(void) +{ + int ret = location_preference_get(GET_LOCATION_SERVICE(geocoder), NULL, NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_get_provider_name_p(void) +{ + int ret = 0; + char *name = NULL; + + ret = location_preference_get_provider_name(GET_LOCATION_SERVICE(geocoder), &name); + + if (ret == LOCATION_PREFERENCE_ERROR_NONE) { + if (name != NULL) { + tet_printf("provider name: %s", name); + } + dts_pass(__func__, "location_preference_get_provider_name passed"); + } else + dts_fail(__func__, "location_preference_get_provider_name failed"); +} + +static void utc_location_location_preference_get_provider_name_n(void) +{ + int ret = location_preference_get_provider_name(GET_LOCATION_SERVICE(geocoder), NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_set_distance_unit_p(void) +{ + int ret = location_preference_set_distance_unit(GET_LOCATION_SERVICE(geocoder), LOCATION_PREFERENCE_DISTANCE_UNIT_FT); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_set_distance_unit failed."); +} + +static void utc_location_location_preference_set_distance_unit_n(void) +{ + int ret = location_preference_set_distance_unit(GET_LOCATION_SERVICE(geocoder), -1); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_get_distance_unit_p(void) +{ + int ret = 0; + location_preference_distance_unit_e unit = LOCATION_PREFERENCE_DISTANCE_UNIT_FT; + + ret = location_preference_get_distance_unit(GET_LOCATION_SERVICE(geocoder), &unit); + if (ret == LOCATION_PREFERENCE_ERROR_NONE) { + dts_pass(__func__, "location_preference_get_distance_unit passed"); + } else { + dts_fail(__func__, "location_preference_get_distance_unit failed"); + } +} + +static void utc_location_location_preference_get_distance_unit_n(void) +{ + int ret = location_preference_get_distance_unit(GET_LOCATION_SERVICE(geocoder), NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_set_language_p(void) +{ + if (available_language == NULL) { + available_language = strdup("KR"); + } + int ret = location_preference_set_language(GET_LOCATION_SERVICE(geocoder), available_language); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_NONE, "location_preference_set_language_unit failed."); +} + +static void utc_location_location_preference_set_language_n(void) +{ + int ret = location_preference_set_language(GET_LOCATION_SERVICE(geocoder), NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} + +static void utc_location_location_preference_get_language_p(void) +{ + int ret = 0; + char *language = NULL; + + ret = location_preference_get_language(GET_LOCATION_SERVICE(geocoder), &language); + if (ret == LOCATION_PREFERENCE_ERROR_NONE) { + dts_pass(__func__, "location_preference_get_distance_unit passed"); + } else { + dts_fail(__func__, "location_preference_get_distance_unit failed"); + } +} + +static void utc_location_location_preference_get_language_n(void) +{ + int ret = location_preference_get_language(GET_LOCATION_SERVICE(geocoder), NULL); + dts_check_eq(__func__, ret, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, + "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER was not returned."); +} diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..03f029a --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100644 index 0000000..f7eda55 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option for build operation checking +TET_BUILD_TOOL=make # build with using make command +TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build +TET_API_COMPLIANT=True # use TET API in Test Case ? +TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100644 index 0000000..02d7030 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option +TET_CLEAN_TOOL= make clean # clean tool +TET_CLEAN_FILE= Makefile # file for clean +TET_API_COMPLIANT=True # TET API useage +TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100644 index 0000000..ef3e452 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capturing execution or not +TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional +TET_EXEC_FILE= # ex) exectool : execution file/ Optional +TET_API_COMPLIANT=True # Test case or Tool usesTET API? +TET_PASS_TC_NAME=True # showing Passed TC name ? |