[ITC][location-manager][ACR-656][Implemented testcase for location batch services]
authorSameer Gautam <sameer.g1@samsung.com>
Tue, 28 Jun 2016 12:37:46 +0000 (18:07 +0530)
committerAmritanshu Pandia <a.pandia1@samsung.com>
Thu, 30 Jun 2016 04:23:57 +0000 (21:23 -0700)
Change-Id: I8d08ee72794248b3647e14aed4e24af2a80af5de
Signed-off-by: Sameer Gautam <sameer.g1@samsung.com>
src/itc/location-manager/CMakeLists.txt
src/itc/location-manager/ITs-location-batch.c [new file with mode: 0644]
src/itc/location-manager/ITs-location-manager-common.h
src/itc/location-manager/tct-location-manager-native_mobile.h

index 0858c99..5485ce7 100755 (executable)
@@ -9,6 +9,7 @@ SET(TC_SOURCES
        ITs-location-manager.c
        ITs-location-bounds.c
        ITs-location-gps-status.c
+       ITs-location-batch.c
 )
 
 PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
diff --git a/src/itc/location-manager/ITs-location-batch.c b/src/itc/location-manager/ITs-location-batch.c
new file mode 100644 (file)
index 0000000..5119c08
--- /dev/null
@@ -0,0 +1,287 @@
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "ITs-location-manager-common.h"
+
+/** @addtogroup itc-location-manager
+*  @ingroup itc
+*  @{
+*/
+
+/**
+* @function            Location_batch_cb
+* @description         when the batch interval is expired.
+* @parameter           int num_of_location, void *user_data
+* @return                      void
+*/
+static void Location_batch_cb(int num_of_location, void *user_data)
+{
+       FPRINTF("[Line : %d][%s] Location_batch_cb callback called\\n", __LINE__, API_NAMESPACE);
+       g_bCallbackHit = true;
+       if ( g_pLocationManagerMainLoop )
+       {
+               g_main_loop_quit(g_pLocationManagerMainLoop);
+       }
+
+       FPRINTF("[Line : %d][%s] The number of location :  %d \\n", __LINE__, API_NAMESPACE , num_of_location );
+       return;
+}
+
+/**
+* @function            location_batch_get_location_cb
+* @description         Gets iteratively to receive location batch data.
+* @parameter           double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data
+* @return                      bool    // To retrieve all location otherwise can set false
+*
+*/
+static bool Location_batch_get_location_cb (double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data)
+{
+       FPRINTF("[Line : %d][%s] Location_batch_get_location_cb callback called\\n", __LINE__, API_NAMESPACE);
+       FPRINTF("[Line : %d][%s] latitude : %lf , longitude : %lf , altitude : %lf , speed : %lf , direction : %lf , horizontal : %lf , vertical : %lf , time_t : %ld \\n", __LINE__, API_NAMESPACE , latitude, longitude, altitude, speed, direction, horizontal, vertical, timestamp);
+       g_bCallbackHit = true;
+       if ( g_pLocationManagerMainLoop )
+       {
+               g_main_loop_quit(g_pLocationManagerMainLoop);
+       }
+
+       // To retrieve all location otherwise can set false
+       return true;
+}
+
+/**
+* @function            ITs_location_batch_startup
+* @description         Called before each test, set the service boolean true
+* @parameter           NA
+* @return                      NA
+*/
+void ITs_location_batch_startup(void)
+{
+       struct stat stBuff;
+       if ( stat(ERR_LOG, &stBuff) == 0 )
+       {
+               remove(ERR_LOG);
+       }
+#if DEBUG
+       FPRINTF("[Line : %d][%s] TEST SUIT start-up: ITs_Location_Manager_p\\n", __LINE__, API_NAMESPACE);
+#endif
+       g_bIsLocationBatchSupported = TCTCheckSystemInfoFeatureSupported(LOCATION_BATCH, API_NAMESPACE);
+       g_bIsLocationFeatureSupported = TCTCheckSystemInfoFeatureSupported(LOCATION_FEATURE, API_NAMESPACE);
+       g_bIsWpsFeatureSupported = TCTCheckSystemInfoFeatureSupported(LOCATION_WPS_FEATURE, API_NAMESPACE);
+       g_bIsGpsFeatureSupported = TCTCheckSystemInfoFeatureSupported(LOCATION_GPS_FEATURE, API_NAMESPACE);
+
+       //Feature check for group of apis
+       g_bIsLocationManagerSupported = g_bIsLocationFeatureSupported && (g_bIsGpsFeatureSupported  || g_bIsWpsFeatureSupported );
+
+       //Instance of location manager
+       LocationManagerCreateStart(&g_stManager);
+}
+
+/**
+* @function            ITs_location_batch_cleanup
+* @description         Called after each test
+* @parameter           NA
+* @return                      NA
+*/
+void ITs_location_batch_cleanup(void)
+{
+#if DEBUG
+       FPRINTF("[Line : %d][%s] TEST SUIT clean-up: ITs_Location_Manager_p\\n", __LINE__, API_NAMESPACE);
+#endif
+
+       LocationManagerStopDestroy(&g_stManager);
+       return;
+}
+
+
+/** @addtogroup itc-location-batch-testcases
+*  @brief              Integration testcases for module location-batch
+*  @ingroup    itc-location-batch
+*  @{
+*/
+
+//& purpose: To check start and stop of location batch service
+//& type: auto
+/**
+* @testcase                    ITc_location_start_stop_batch_p
+* @since_tizen                 3.0
+* @author              SRID(sameer.g1)
+* @reviewer            SRID(shobhit.v)
+* @type                                auto
+* @description                 To check start and stop of location batch service
+* @scenario                            check start and stop of location batch service
+*                                              start location batch service
+*                                              stop location service
+* @apicovered                  location_manager_start_batch, location_manager_stop_batch
+* @passcase                            When both apis are successful
+* @failcase                            If targeted APIs fails
+* @precondition                        The location service state must be LOCATIONS_SERVICE_ENABLED with location_manager_start
+* @postcondition               None
+*/
+int ITc_location_start_stop_batch_p(void)
+{
+       START_TEST_MANAGER ;
+
+       int nRet = location_manager_start_batch ( g_stManager ); // Target API
+       if ( !g_bIsLocationBatchSupported )
+       {
+               if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
+               {
+                       FPRINTF("[Line : %d][%s] Feature support as returned by TCTCheckSystemInfoFeatureSupported() and error code as returned by location_manager_start_batch() mismatched, Leaving test\\n", __LINE__, API_NAMESPACE);
+                       return 1;
+               }
+               else
+               {
+                       FPRINTF("[Line : %d][%s] feature not supported, Leaving test\\n", __LINE__, API_NAMESPACE);
+                       return 0;
+               }
+       }
+       PRINT_RESULT(LOCATIONS_ERROR_NONE, nRet, "location_manager_start_batch", LocationBoundsGetError(nRet));
+
+       nRet = location_manager_stop_batch ( g_stManager ); // Target API
+       PRINT_RESULT(LOCATIONS_ERROR_NONE, nRet, "location_manager_stop_batch", LocationBoundsGetError(nRet));
+
+       return 0;
+}
+
+//& purpose: To check all location information by invoking a specific callback for each location data.
+//& type: auto
+/**
+* @testcase                    ITc_location_manager_foreach_location_batch_p
+* @since_tizen                 3.0
+* @author              SRID(sameer.g1)
+* @reviewer            SRID(shobhit.v)
+* @type                                auto
+* @description                 To check all location information by invoking a specific callback for each location data.
+* @scenario                            checked start location batch service \n
+*                                              register location_manager_foreach_location_batch callback \n
+*                                              checked stop location batch service \n
+* @apicovered                  location_manager_start_batch, location_manager_stop_batch ,
+* @passcase                            When targeted and supporting APIs are passed.
+* @failcase                            If target API or supporting APIs fails
+* @precondition                        None
+* @postcondition               None
+*/
+int ITc_location_manager_foreach_location_batch_p(void)
+{
+       START_TEST_MANAGER ;
+
+       int nTimeoutId = 0;
+       int nRet = location_manager_start_batch ( g_stManager );
+       if (!g_bIsLocationBatchSupported )
+       {
+               if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
+               {
+                       FPRINTF("[Line : %d][%s] Feature support as returned by TCTCheckSystemInfoFeatureSupported() and error code as returned by location_manager_start_batch() mismatched, Leaving test\\n", __LINE__, API_NAMESPACE);
+                       return 1;
+               }
+               else
+               {
+                       FPRINTF("[Line : %d][%s] feature not supported, Leaving test\\n", __LINE__, API_NAMESPACE);
+                       return 0;
+               }
+       }
+       PRINT_RESULT(LOCATIONS_ERROR_NONE, nRet, "location_manager_start_batch", LocationBoundsGetError(nRet));
+
+       // pre-initialization callback response
+       g_bCallbackHit = false;
+
+       nRet = location_manager_foreach_location_batch(g_stManager, Location_batch_get_location_cb , NULL); // Target API
+       PRINT_RESULT_CLEANUP(LOCATIONS_ERROR_NONE, nRet, "location_manager_foreach_location_batch", LocationBoundsGetError(nRet) , location_manager_stop_batch ( g_stManager ));
+
+       RUN_POLLING_LOOP;
+
+       if ( !g_bCallbackHit)
+       {
+               FPRINTF("[Line : %d][%s] location_manager_foreach_location_batch unable to invoke callback function\\n", __LINE__, API_NAMESPACE);
+               location_manager_stop_batch ( g_stManager );
+               return 1;
+       }       // To retrieve all location otherwise can set false
+
+
+       nRet = location_manager_stop_batch ( g_stManager );
+       PRINT_RESULT_NORETURN(LOCATIONS_ERROR_NONE, nRet, "location_manager_stop_batch", LocationBoundsGetError(nRet));
+
+       return 0;
+}
+
+//& purpose: To check a callback function to be invoked when batch_period is expired.
+//& type: auto
+/**
+* @testcase                    ITc_location_manager_set_location_batch_cb_p
+* @since_tizen                 3.0
+* @author              SRID(sameer.g1)
+* @reviewer            SRID(shobhit.v)
+* @type                                auto
+* @description                 To check a callback function to be invoked when batch_period is expired.
+* @scenario                            checked start location batch service \n
+*                                              register location_manager_set_location_batch_cb callback \n
+*                                              unregister callback from handler \n
+*                                              checked stop location batch service \n
+* @apicovered                  location_manager_start_batch, location_manager_stop_batch, location_manager_set_location_batch_cb, location_manager_unset_location_batch_cb
+* @passcase                            When targeted and supporting APIs are passed.
+* @failcase                            If target API or supporting APIs fails
+* @precondition                        None
+* @postcondition               None
+*/
+int ITc_location_manager_set_unset_location_batch_cb_p(void)
+{
+       START_TEST_MANAGER ;
+       int nTimeoutId = 0;
+       int nRet = 0;
+       int nInterval = 1;
+       int nDuration = 60;
+
+       nRet = location_manager_start_batch ( g_stManager );
+       if (!g_bIsLocationBatchSupported )
+       {
+               if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
+               {
+                       FPRINTF("[Line : %d][%s] Feature support as returned by TCTCheckSystemInfoFeatureSupported() and error code as returned by location_manager_start_batch() mismatched, Leaving test\\n", __LINE__, API_NAMESPACE);
+                       return 1;
+               }
+               else
+               {
+                       FPRINTF("[Line : %d][%s] feature not supported, Leaving test\\n", __LINE__, API_NAMESPACE);
+                       return 0;
+               }
+       }
+       PRINT_RESULT(LOCATIONS_ERROR_NONE, nRet, "location_manager_start_batch", LocationBoundsGetError(nRet));
+
+       // pre-initialization callback response
+       g_bCallbackHit = false;
+
+       nRet = location_manager_set_location_batch_cb(g_stManager, Location_batch_cb , nInterval, nDuration , NULL); // Target API
+       PRINT_RESULT_CLEANUP(LOCATIONS_ERROR_NONE, nRet, "location_manager_set_location_batch_cb", LocationBoundsGetError(nRet) , location_manager_stop_batch ( g_stManager ));
+       RUN_POLLING_LOOP;
+
+       if ( !g_bCallbackHit)
+       {
+               FPRINTF("[Line : %d][%s] location_manager_set_location_batch_cb unable to invoke callback function\\n", __LINE__, API_NAMESPACE);
+               location_manager_stop_batch ( g_stManager );
+               return 1;
+       }
+
+
+       nRet = location_manager_unset_location_batch_cb(g_stManager); // Target API
+       PRINT_RESULT_CLEANUP(LOCATIONS_ERROR_NONE, nRet, "location_manager_unset_location_batch_cb", LocationBoundsGetError(nRet) , location_manager_stop_batch ( g_stManager ));
+
+       nRet = location_manager_stop_batch ( g_stManager );
+       PRINT_RESULT_NORETURN(LOCATIONS_ERROR_NONE, nRet, "location_manager_stop_batch", LocationBoundsGetError(nRet));
+
+       return 0;
+}
+/** @} */
+/** @} */
index b529113..e580099 100755 (executable)
@@ -38,6 +38,7 @@ bool g_bIsGpsFeatureSupported;
 bool g_bIsLocationFeatureSupported;
 bool g_bIsLocationManagerSupported;
 bool g_bIsGPSSatelliteSupported;
+bool g_bIsLocationBatchSupported;
 
 bool g_bLocationMismatch;
 bool g_bLocationNotSupported;
@@ -57,6 +58,7 @@ bool g_bCleanupNotRequired;
 #define LOCATION_WPS_FEATURE   "http://tizen.org/feature/location.wps"
 #define LOCATION_GPS_FEATURE   "http://tizen.org/feature/location.gps"
 #define LOCATION_GPS_SATELLITE  "http://tizen.org/feature/location.gps.satellite"
+#define LOCATION_BATCH                 "http://tizen.org/feature/location.batch"
 
 
 #define START_TEST {\
index 3a9ed3b..5e51020 100755 (executable)
@@ -25,6 +25,8 @@ extern void ITs_location_gps_status_startup(void);
 extern void ITs_location_gps_status_cleanup(void);
 extern void ITs_location_manager_startup(void);
 extern void ITs_location_manager_cleanup(void);
+extern void ITs_location_batch_startup(void);
+extern void ITs_location_batch_cleanup(void);
 
 extern int ITc_location_bounds_create_destory_rect_p(void);
 extern int ITc_location_bounds_get_rect_coords_p(void);
@@ -44,6 +46,9 @@ extern int ITc_gps_status_set_unset_satellite_updated_cb_p(void);
 extern int ITc_location_manager_start_stop_p(void);
 extern int ITc_location_manager_create_destroy_p(void);
 extern int ITc_location_manager_set_unset_service_state_changed_cb_p(void);
+extern int ITc_location_start_stop_batch_p(void);
+extern int ITc_location_manager_foreach_location_batch_p(void);
+extern int ITc_location_manager_set_unset_location_batch_cb_p(void);
 
 extern int ITc_location_manager_get_accuracy_p(void);
 extern int ITc_location_manager_get_distance_p(void);
@@ -113,6 +118,9 @@ testcase tc_array[] = {
     {"ITc_location_manager_set_unset_distance_based_location_changed_cb_p", ITc_location_manager_set_unset_distance_based_location_changed_cb_p, ITs_location_manager_startup, ITs_location_manager_cleanup},
     {"ITc_location_manager_enable_mock_location_p", ITc_location_manager_enable_mock_location_p, ITs_location_manager_startup, ITs_location_manager_cleanup},
     {"ITc_location_manager_set_clear_mock_location_p", ITc_location_manager_set_clear_mock_location_p, ITs_location_manager_startup, ITs_location_manager_cleanup},
+    {"ITc_location_start_stop_batch_p", ITc_location_start_stop_batch_p, ITs_location_batch_startup, ITs_location_batch_cleanup},
+    {"ITc_location_manager_foreach_location_batch_p", ITc_location_manager_foreach_location_batch_p, ITs_location_batch_startup, ITs_location_batch_cleanup},
+    {"ITc_location_manager_set_unset_location_batch_cb_p", ITc_location_manager_set_unset_location_batch_cb_p, ITs_location_batch_startup, ITs_location_batch_cleanup},
     {NULL, NULL}
 };