serviceproviders/sapi_location/tsrc/dev/tlocservicetest/src/loccancel.cpp
changeset 22 fc9cf246af83
parent 19 989d2f495d90
child 33 50974a8b132e
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:   contains test case implementation for CancelOngoingService location-SAPI
    14 * Description:   contains test case implementation for CancelOngoingService location-SAPI
    15 *  V	ersion     : %version: 4 % << Don't touch! Updated by Synergy at check-out.
    15 *  V	ersion     : %version: 5 % << Don't touch! Updated by Synergy at check-out.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 #include "TLocTest.h"
    20 #include "TLocTest.h"
    21 #include "locationservice.h"
    21 #include "locationservice.h"
    22 #include <f32file.h>
    22 #include <f32file.h>
    23 #include <e32const.h>
    23 #include <e32const.h>
    24 class CGetLoc ; //Forward declaration
    24 class CGetLoc ; //Forward declaration
    25 
    25 
       
    26 #define GETLOCATION 0
       
    27 #define TRACE 1
    26 
    28 
    27 _LIT(LogFileName , "C:\\Notificationscan.txt") ;
    29 _LIT(LogFileName , "C:\\Notificationscan.txt") ;
    28 _LIT(KRequestor,"testapp");
    30 _LIT(KRequestor,"testapp");
    29 
    31 
    30 // INCLUDE FILES
    32 // INCLUDE FILES
    49  {
    51  {
    50    TInt iCount ;
    52    TInt iCount ;
    51    TInt iRetStatus ;
    53    TInt iRetStatus ;
    52    TInt iServiceId;
    54    TInt iServiceId;
    53    CLocationService* iServicePtr;
    55    CLocationService* iServicePtr;
       
    56     TInt iTransactionId;
       
    57     TInt iRequestType;
    54     public :
    58     public :
    55     	TInt HandleNotifyL(HPositionGenericInfo *aInfo , TInt aError) ;
    59     	TInt HandleNotifyL(HPositionGenericInfo *aInfo , TInt aError) ;
    56     
    60     
    57     	CancelLocUpdateCallBack(CLocationService *CoreObj) :iCount(0) , iRetStatus(KErrGeneral),iServicePtr(CoreObj)  //Default constructor 
    61     CancelLocUpdateCallBack(TInt trans,TInt req,CLocationService *CoreObj) :iCount(0) , iRetStatus(KErrGeneral),iServicePtr(CoreObj)  //Default constructor 
    58     	{
    62     	    {
    59     		;
    63     	    iTransactionId = trans;
    60     	}
    64     	    iRequestType = req;
    61     
    65     	    }
       
    66     inline TUint GetRequestType(void) 
       
    67         {
       
    68         return iRequestType ;
       
    69         }
       
    70 
       
    71 
       
    72     /**
       
    73      * GetTransactionId function returns transcation id associated with current async object
       
    74      *
       
    75      */
       
    76     inline TInt32 GetTransactionId(void)
       
    77         {
       
    78         return iTransactionId ;
       
    79         }    
    62   };
    80   };
    63 
    81 
    64 
    82 
    65 TInt CancelLocUpdateCallBack :: HandleNotifyL(HPositionGenericInfo *aInfo , TInt aError)
    83 TInt CancelLocUpdateCallBack :: HandleNotifyL(HPositionGenericInfo *aInfo , TInt aError)
    66 {
    84 {
   134    
   152    
   135 TInt CancelLocFunctionAL()
   153 TInt CancelLocFunctionAL()
   136 {
   154 {
   137    
   155    
   138     	
   156     	
   139     
   157     __UHEAP_MARK ;
   140     
   158     
   141     CActiveScheduler *Scheduler = new CActiveScheduler ;
   159     CActiveScheduler *Scheduler = new CActiveScheduler ;
   142     
   160     
   143     CActiveScheduler :: Install(Scheduler) ;
   161     CActiveScheduler :: Install(Scheduler) ;
   144     CLocationService *CoreObj = CLocationService ::NewL() ;
   162     CLocationService *CoreObj = CLocationService ::NewL() ;
   145     CancelLocUpdateCallBack MyUpdates(CoreObj)  ;
   163     CancelLocUpdateCallBack MyUpdates(10,TRACE,CoreObj)  ;
   146  
   164  
   147    
   165    
   148     CoreObj->TraceL((&MyUpdates),EBasicInfo) ;
   166     CoreObj->TraceL((&MyUpdates),EBasicInfo) ;
   149     CoreObj->CancelOnGoingService(ECancelTrace);
   167     CoreObj->CancelOnGoingService(ECancelTrace);
   150     
   168     
   151     
   169     delete CoreObj;
   152     
   170     delete Scheduler;
       
   171 
       
   172     __UHEAP_MARKEND ;
   153     return 0 ; 
   173     return 0 ; 
   154 }	
   174 }	
   155 TInt CancelLocUpdatesA(TAny */*Arg*/)
   175 TInt CancelLocUpdatesA(TAny */*Arg*/)
   156 {
   176 {
   157 	CTrapCleanup* cleanup = CTrapCleanup::New();
   177 	CTrapCleanup* cleanup = CTrapCleanup::New();
   190 
   210 
   191 TInt CancelLocFunctionBL()
   211 TInt CancelLocFunctionBL()
   192 {
   212 {
   193    
   213    
   194     	
   214     	
   195     
   215     __UHEAP_MARK ;
   196    
   216    
   197     CActiveScheduler *Scheduler = new CActiveScheduler ;
   217     CActiveScheduler *Scheduler = new CActiveScheduler ;
   198     
   218     
   199     CActiveScheduler :: Install(Scheduler) ;
   219     CActiveScheduler :: Install(Scheduler) ;
   200     CLocationService *CoreObj = CLocationService ::NewL() ;
   220     CLocationService *CoreObj = CLocationService ::NewL() ;
   201      CancelLocUpdateCallBack MyUpdates(CoreObj)  ;
   221     CancelLocUpdateCallBack MyUpdates(11,TRACE,CoreObj)  ;
   202  
   222  
   203    
   223    
   204     CoreObj->TraceL((&MyUpdates),EBasicInfo) ;
   224     CoreObj->TraceL((&MyUpdates),EBasicInfo) ;
   205     
   225     
   206     CActiveScheduler :: Start() ;
   226     CActiveScheduler :: Start() ;
   207     
   227     delete CoreObj;
   208     
   228     delete Scheduler;
       
   229     __UHEAP_MARKEND ;
   209     
   230     
   210     
   231     
   211     return 0 ; 
   232     return 0 ; 
   212 }	
   233 }	
   213 TInt CancelLocUpdatesB(TAny */*Arg*/)
   234 TInt CancelLocUpdatesB(TAny */*Arg*/)
   246 
   267 
   247 TInt CancelLocAsynchFunctionL()
   268 TInt CancelLocAsynchFunctionL()
   248 {
   269 {
   249    
   270    
   250     	
   271     	
   251     
   272     __UHEAP_MARK ;
   252     
   273     
   253     CActiveScheduler *Scheduler = new CActiveScheduler ;
   274     CActiveScheduler *Scheduler = new CActiveScheduler ;
   254     
   275     
   255     CActiveScheduler :: Install(Scheduler) ;
   276     CActiveScheduler :: Install(Scheduler) ;
   256     CLocationService *CoreObj = CLocationService ::NewL() ;
   277     CLocationService *CoreObj = CLocationService ::NewL() ;
   257     CancelLocUpdateCallBack MyUpdates(CoreObj)  ;
   278     CancelLocUpdateCallBack MyUpdates(12,GETLOCATION,CoreObj)  ;
   258    
   279    
   259     CoreObj->GetLocationL((&MyUpdates),EBasicInfo) ;
   280     CoreObj->GetLocationL((&MyUpdates),EBasicInfo) ;
   260     CoreObj->CancelOnGoingService(ECancelGetLocation);
   281     CoreObj->CancelOnGoingService(ECancelGetLocation);
   261     
   282     
   262     
   283     delete CoreObj;
   263     
   284     delete Scheduler;
       
   285 
       
   286     __UHEAP_MARKEND ;
   264     return 0 ; 
   287     return 0 ; 
   265 }	
   288 }	
   266 TInt CancelLocAsynch(TAny */*Arg*/)
   289 TInt CancelLocAsynch(TAny */*Arg*/)
   267 {
   290 {
   268 	CTrapCleanup* cleanup = CTrapCleanup::New();
   291 	CTrapCleanup* cleanup = CTrapCleanup::New();