serviceproviders/sapi_location/tsrc/dev/tlocmanualtest/src/tlocmanualtestblocks.cpp
changeset 22 fc9cf246af83
parent 19 989d2f495d90
child 33 50974a8b132e
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
    82 	
    82 	
    83 
    83 
    84 	
    84 	
    85 TInt  CTLocManualTest ::GetLocationTimedOut(CStifItemParser& /*aItem*/)
    85 TInt  CTLocManualTest ::GetLocationTimedOut(CStifItemParser& /*aItem*/)
    86 	{
    86 	{
       
    87     __UHEAP_MARK ;
    87 	    // Print to UI
    88 	    // Print to UI
    88     _LIT( KTLocManualTest, "TLocTest" );
    89     _LIT( KTLocManualTest, "TLocTest" );
    89     _LIT( KGetLocationTimeout , "Time out test" );
    90     _LIT( KGetLocationTimeout , "Time out test" );
    90     
    91     
    91     iLog->Log(KTLocManualTest) ;
    92     iLog->Log(KTLocManualTest) ;
    94     // Print to log file
    95     // Print to log file
    95     
    96     
    96     TPositionInfo position;
    97     TPositionInfo position;
    97     TPositionUpdateOptions Updateopts ;
    98     TPositionUpdateOptions Updateopts ;
    98     
    99     
    99     Updateopts.SetUpdateTimeOut(TTimeIntervalMicroSeconds(KUpdatetimeOut));
   100     Updateopts.SetUpdateTimeOut(TTimeIntervalMicroSeconds(100000));
   100 
   101 
   101     
   102     
   102     CLocationService *CoreObj = CLocationService :: NewL();
   103     CLocationService *CoreObj = CLocationService :: NewL();
   103     //not required any more
   104     //not required any more
   104     /*RRequestorStack infostack;
   105     /*RRequestorStack infostack;
   106     const CRequestor* identityInfo = CRequestor::NewL(CRequestor::ERequestorService,CRequestor::EFormatApplication,
   107     const CRequestor* identityInfo = CRequestor::NewL(CRequestor::ERequestorService,CRequestor::EFormatApplication,
   107     												KRequestor) ;
   108     												KRequestor) ;
   108     infostack.Append(identityInfo);
   109     infostack.Append(identityInfo);
   109     CoreObj->SetRequestorIdentityL(infostack);*/
   110     CoreObj->SetRequestorIdentityL(infostack);*/
   110     
   111     
   111     TInt Result =CoreObj->GetLocationL(&position , &Updateopts) ;
   112     TRAPD( Result ,CoreObj->GetLocationL(&position , &Updateopts) );
   112     
   113     
   113     
   114     
   114 
   115 
   115     delete 	CoreObj ;
   116     delete 	CoreObj ;
       
   117     __UHEAP_MARKEND ;
   116     if(Result == KErrTimedOut)
   118     if(Result == KErrTimedOut)
   117     {
   119     {
   118     	return KErrNone ;
   120     	return KErrNone ;
   119     }
   121     }
   120     
   122     
   128 	 * Construction of the object should fail
   130 	 * Construction of the object should fail
   129 	 */
   131 	 */
   130 	
   132 	
   131 TInt  CTLocManualTest ::ServiceNotAvailable(CStifItemParser& /*aItem*/)
   133 TInt  CTLocManualTest ::ServiceNotAvailable(CStifItemParser& /*aItem*/)
   132 	{
   134 	{
       
   135     __UHEAP_MARK ;
   133 	  CLocationService *CoreObj ;
   136 	  CLocationService *CoreObj ;
   134 	  TInt result = 0 ;
   137 	  TInt result = 0 ;
   135 	  TPositionInfo pos ;
   138 	  TPositionInfo pos ;
   136 	  
   139 	  
   137 	  TRAPD(err , (CoreObj = CLocationService :: NewL())) ;
   140 	  TRAPD(err , (CoreObj = CLocationService :: NewL())) ;
   143     
   146     
   144 	    const CRequestor* identityInfo = CRequestor::NewL(CRequestor::ERequestorService,CRequestor::EFormatApplication,
   147 	    const CRequestor* identityInfo = CRequestor::NewL(CRequestor::ERequestorService,CRequestor::EFormatApplication,
   145 	    												KRequestor) ;
   148 	    												KRequestor) ;
   146 	    infostack.Append(identityInfo);
   149 	    infostack.Append(identityInfo);
   147 	    CoreObj->SetRequestorIdentityL(infostack);*/
   150 	    CoreObj->SetRequestorIdentityL(infostack);*/
   148 	  	result = CoreObj->GetLocationL(&pos) ;    //Synchronous getlocation test 
   151         TRAP(result , CoreObj->GetLocationL(&pos)) ;    //Synchronous getlocation test 
   149 	  	}
   152 	  	}
   150 	  
   153 	  
   151 	  delete CoreObj ;
   154 	  delete CoreObj ;
   152 	  
   155     __UHEAP_MARKEND ;
   153 	  if((result == KErrNotFound  ) || (result == KPositionQualityLoss))
   156 	  if((result == KErrNotFound  ) || (result == KPositionQualityLoss))
   154 	  	{
   157 	  	{
   155 	  	_LIT(KLog , "positioning  technology not available") ;
   158 	  	_LIT(KLog , "positioning  technology not available") ;
   156 	  	 iLog->Log(KLog) ;
   159 	  	 iLog->Log(KLog) ;
   157 	  	 return KErrNone ;
   160 	  	 return KErrNone ;
   163 	
   166 	
   164 class LocUpdateCallBack : public MLocationCallBack
   167 class LocUpdateCallBack : public MLocationCallBack
   165  {
   168  {
   166    TInt iCount ;
   169    TInt iCount ;
   167    TInt iRetStatus ;
   170    TInt iRetStatus ;
       
   171     TInt iRequestType;
       
   172     TInt iTransactionId;
   168     public :
   173     public :
   169     	TInt HandleNotifyL(HPositionGenericInfo *posinfo , TInt aError) ;
   174     	TInt HandleNotifyL(HPositionGenericInfo *posinfo , TInt aError) ;
   170     
   175     
   171     	LocUpdateCallBack() :iCount(0) , iRetStatus(KErrGeneral)  //Default constructor 
   176         LocUpdateCallBack(TInt transId,TInt req) :iCount(0) , iRetStatus(KErrGeneral)  //Default constructor 
   172     	{
   177     	    {
   173     		;
   178     	    iRequestType = req;
   174     	}
   179 
       
   180     	    iTransactionId = transId;;
       
   181     	    }
       
   182 
       
   183         inline TUint GetRequestType(void) 
       
   184             {
       
   185             return iRequestType ;
       
   186             }
       
   187 
       
   188 
       
   189         /**
       
   190          * GetTransactionId function returns transcation id associated with current async object
       
   191          *
       
   192          */
       
   193         inline TInt32 GetTransactionId(void)
       
   194             {
       
   195             return iTransactionId ;
       
   196             }
   175   };
   197   };
   176   
   198   
   177   
   199   
   178   
   200   
   179 TInt LocUpdateCallBack :: HandleNotifyL(HPositionGenericInfo *posinfo , TInt aError)
   201 TInt LocUpdateCallBack :: HandleNotifyL(HPositionGenericInfo *posinfo , TInt aError)
   246   return KErrNone ;	
   268   return KErrNone ;	
   247 }
   269 }
   248 	
   270 	
   249 TInt ServiceFailedFunctionL()
   271 TInt ServiceFailedFunctionL()
   250 {
   272 {
   251 		
   273     __UHEAP_MARK ;
   252 		CActiveScheduler *Scheduler = new CActiveScheduler ;
   274 		CActiveScheduler *Scheduler = new CActiveScheduler ;
   253 		CActiveScheduler :: Install(Scheduler) ;
   275 		CActiveScheduler :: Install(Scheduler) ;
   254 		CLocationService *CoreObj = CLocationService ::NewL() ;
   276 		CLocationService *CoreObj = CLocationService ::NewL() ;
   255 		
   277 		
   256 		/*RRequestorStack infostack;
   278 		/*RRequestorStack infostack;
   258 	    const CRequestor* identityInfo = CRequestor::NewL(CRequestor::ERequestorService,CRequestor::EFormatApplication,
   280 	    const CRequestor* identityInfo = CRequestor::NewL(CRequestor::ERequestorService,CRequestor::EFormatApplication,
   259 	    												KRequestor) ;
   281 	    												KRequestor) ;
   260 	    infostack.Append(identityInfo);
   282 	    infostack.Append(identityInfo);
   261 	    CoreObj->SetRequestorIdentityL(infostack);*/
   283 	    CoreObj->SetRequestorIdentityL(infostack);*/
   262 		
   284 		
   263 		LocUpdateCallBack MyUpdates ;
   285     LocUpdateCallBack MyUpdates(12,1) ;
   264     
   286     
   265     	CoreObj->TraceL(&MyUpdates,EBasicInfo) ;
   287     	CoreObj->TraceL(&MyUpdates,EBasicInfo) ;
   266     	CActiveScheduler :: Start() ; 
   288     	CActiveScheduler :: Start() ; 
       
   289     delete Scheduler;
       
   290     delete CoreObj;
       
   291     __UHEAP_MARKEND ;
   267     	return  0 ;
   292     	return  0 ;
   268     	
   293     	
   269     	
   294     	
   270 
   295 
   271 }
   296 }