serviceproviders/sapi_location/tsrc/dev/tlocservicetest/src/tloctestblocks.cpp
changeset 22 fc9cf246af83
parent 19 989d2f495d90
child 33 50974a8b132e
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
    75         ENTRY("StraySignal" , CTLocTest :: StraySignal),
    75         ENTRY("StraySignal" , CTLocTest :: StraySignal),
    76         ENTRY("StraySignalGetLoc" , CTLocTest :: StraySignalGetLoc),
    76         ENTRY("StraySignalGetLoc" , CTLocTest :: StraySignalGetLoc),
    77         ENTRY("ConcurrentCallsGetLoc" , CTLocTest:: ConcurrentCallsGetLoc),
    77         ENTRY("ConcurrentCallsGetLoc" , CTLocTest:: ConcurrentCallsGetLoc),
    78         ENTRY("ConcurrentCallsTrace" , CTLocTest:: ConcurrentCallsTrace),
    78         ENTRY("ConcurrentCallsTrace" , CTLocTest:: ConcurrentCallsTrace),
    79         ENTRY("EmptyCancelTrace" , CTLocTest:: EmptyCancelTrace),
    79         ENTRY("EmptyCancelTrace" , CTLocTest:: EmptyCancelTrace),
    80         ENTRY("EmptyCancelLocAsynch" , CTLocTest:: EmptyCancelLocAsynch)
    80             ENTRY("EmptyCancelLocAsynch" , CTLocTest:: EmptyCancelLocAsynch),
       
    81             ENTRY("TraceTimeOut" , CTLocTest:: TraceTimeOut)
    81         
    82         
    82 
    83 
    83         };
    84         };
    84 
    85 
    85     const TInt count = sizeof( KFunctions ) / 
    86     const TInt count = sizeof( KFunctions ) / 
    97 //
    98 //
    98 TInt CTLocTest::GetLocation( CStifItemParser& /*aItem*/ )
    99 TInt CTLocTest::GetLocation( CStifItemParser& /*aItem*/ )
    99     {
   100     {
   100 
   101 
   101     // Print to UI
   102     // Print to UI
       
   103     __UHEAP_MARK ;
   102     _LIT( KTLocTest, "TLocTest" );
   104     _LIT( KTLocTest, "TLocTest" );
   103     _LIT( KExample, "GetLocation" );
   105     _LIT( KExample, "GetLocation" );
   104     iLog->Log(KTLocTest) ;
   106     iLog->Log(KTLocTest) ;
   105    // iLog->Log(KExample) ;
   107    // iLog->Log(KExample) ;
   106     //TestModuleIf().Printf( 0, KTLocTest, KExample );
   108     //TestModuleIf().Printf( 0, KTLocTest, KExample );
   120     infostack.Append(identityInfo);
   122     infostack.Append(identityInfo);
   121     CoreObj->SetRequestorIdentityL(infostack);*/
   123     CoreObj->SetRequestorIdentityL(infostack);*/
   122     
   124     
   123     
   125     
   124     
   126     
   125     TInt Result =CoreObj->GetLocationL(&position) ;
   127     TRAPD(Result,CoreObj->GetLocationL(&position)) ;
   126     TPosition pos ;
   128     TPosition pos ;
   127     
   129     
   128     position.GetPosition(pos) ;
   130     position.GetPosition(pos) ;
   129     TReal64 aLatitude  = pos.Latitude();
   131     TReal64 aLatitude  = pos.Latitude();
   130     TReal64 aLongitude = pos.Longitude() ;
   132     TReal64 aLongitude = pos.Longitude() ;
   131     TReal32 aAltitude  = pos.Altitude() ;
   133     TReal32 aAltitude  = pos.Altitude() ;
   132     delete CoreObj ;
   134     delete CoreObj ;
   133 
   135 
   134 
   136     __UHEAP_MARKEND ;
   135     return Result ;
   137     return Result ;
   136 
   138 
   137     }
   139     }
   138  
   140  
   139    
   141    
   169 
   171 
   170 TInt CTLocTest :: LastKnownLoc(CStifItemParser& /*aItem*/)
   172 TInt CTLocTest :: LastKnownLoc(CStifItemParser& /*aItem*/)
   171 	{
   173 	{
   172 	_LIT(KTLocTest , "TLocTest") ;
   174 	_LIT(KTLocTest , "TLocTest") ;
   173 	iLog->Log(KTLocTest) ;
   175 	iLog->Log(KTLocTest) ;
   174 //	CLocationService *CoreObj = CLocationService :: NewL();
   176     CLocationService *CoreObj = CLocationService :: NewL();
   175 //	TPosition LastKnownPos ;
   177     TPosition LastKnownPos ;
   176 	
   178 
   177 //	CoreObj->GetLastKnownLoc(LastKnownPos) ;
   179     TInt err = CoreObj->GetLastKnownLoc(LastKnownPos) ;
   178 	return KErrNone ;
   180     delete CoreObj;
       
   181     return err;
   179 	}
   182 	}
   180 	
   183 	
   181 	
   184 	
   182 TInt  CTLocTest ::GetLocationAsynch(CStifItemParser& /*aItem*/)
   185 TInt  CTLocTest ::GetLocationAsynch(CStifItemParser& /*aItem*/)
   183 	{
   186 	{
   208 	 
   211 	 
   209 	
   212 	
   210 	
   213 	
   211 TInt CTLocTest :: FindDistance(CStifItemParser& /*aItem*/)
   214 TInt CTLocTest :: FindDistance(CStifItemParser& /*aItem*/)
   212 {
   215 {
       
   216     __UHEAP_MARK ;
   213   		CLocationService *CoreObj = CLocationService :: NewL();
   217   		CLocationService *CoreObj = CLocationService :: NewL();
   214   
   218   
   215   
   219   
   216   		TReal32 distance;
   220   		TReal32 distance;
   217   		TTime systemtime;
   221   		TTime systemtime;
   411  		
   415  		
   412  		//scenario 4: ends here
   416  		//scenario 4: ends here
   413  		
   417  		
   414   		
   418   		
   415   		delete CoreObj;
   419   		delete CoreObj;
       
   420     __UHEAP_MARKEND ;
   416   		return KErrNone ;
   421   		return KErrNone ;
   417 }
   422 }
   418   
   423   
   419 /** Manual test case for findbearingto
   424 /** Manual test case for findbearingto
   420  */
   425  */
   421 TInt CTLocTest :: FindBearingTo(CStifItemParser& /*aItem*/)  
   426 TInt CTLocTest :: FindBearingTo(CStifItemParser& /*aItem*/)  
   422 	{
   427 	{
       
   428     __UHEAP_MARK ;
   423 	CLocationService *CoreObj = CLocationService :: NewL();
   429 	CLocationService *CoreObj = CLocationService :: NewL();
   424 
   430 
   425 
   431 
   426 	TReal32 bearingTo;
   432 	TReal32 bearingTo;
   427 	
   433 	
   619 	
   625 	
   620 	//scenario 4: ends here
   626 	//scenario 4: ends here
   621 	
   627 	
   622 	
   628 	
   623 	delete CoreObj;
   629 	delete CoreObj;
       
   630     __UHEAP_MARKEND ;
   624 	return KErrNone ;	
   631 	return KErrNone ;	
   625 	}
   632 	}
   626 
   633 
   627 
   634 
   628 
   635 
   629 /**
   636 /**
   630  * Manual test case for MathOperation Move
   637  * Manual test case for MathOperation Move
   631  */
   638  */
   632  TInt CTLocTest :: MoveCoordinates(CStifItemParser& /*aItem*/)  
   639  TInt CTLocTest :: MoveCoordinates(CStifItemParser& /*aItem*/)  
   633 	{
   640 	{
       
   641     __UHEAP_MARK ;
   634 	CLocationService *CoreObj = CLocationService :: NewL();
   642 	CLocationService *CoreObj = CLocationService :: NewL();
   635 
   643 
   636 
   644 
   637 	
   645 	
   638 	
   646 	
   703 	
   711 	
   704 	
   712 	
   705 	LogFile.Close() ;
   713 	LogFile.Close() ;
   706 	LogSession.Close() ;
   714 	LogSession.Close() ;
   707 	delete CoreObj;
   715 	delete CoreObj;
       
   716     __UHEAP_MARKEND ;
   708 	return KErrNone ;
   717 	return KErrNone ;
   709 	}
   718 	}
   710 /*
   719 /*
   711  * This is a manual test case were the service was available when the 
   720  * This is a manual test case were the service was available when the 
   712  * request was made and then   Lost the service (Contact to location servier lost
   721  * request was made and then   Lost the service (Contact to location servier lost
   784 {
   793 {
   785 	/*_LIT(KTLocTest ,"TLocTest");
   794 	/*_LIT(KTLocTest ,"TLocTest");
   786 	iLog->Log(KTLocTest) ;
   795 	iLog->Log(KTLocTest) ;
   787 	_LIT(KLog , "EmptyCanceltest ") ;
   796 	_LIT(KLog , "EmptyCanceltest ") ;
   788 	iLog->Log(KTLocTest) ;*/
   797 	iLog->Log(KTLocTest) ;*/
   789 	
   798     __UHEAP_MARK ;
   790 	CLocationService *CoreObj = CLocationService ::NewL() ;
   799 	CLocationService *CoreObj = CLocationService ::NewL() ;
   791 	//not needed any more
   800 	//not needed any more
   792 	/*RRequestorStack infostack;
   801 	/*RRequestorStack infostack;
   793     
   802     
   794     const CRequestor* identityInfo = CRequestor::NewL(CRequestor::ERequestorService,CRequestor::EFormatApplication,
   803     const CRequestor* identityInfo = CRequestor::NewL(CRequestor::ERequestorService,CRequestor::EFormatApplication,
   797     CoreObj->SetRequestorIdentityL(infostack);*/
   806     CoreObj->SetRequestorIdentityL(infostack);*/
   798     TInt error= CoreObj->CancelOnGoingService(ECancelTrace);
   807     TInt error= CoreObj->CancelOnGoingService(ECancelTrace);
   799     if( error==KErrNotFound ) 
   808     if( error==KErrNotFound ) 
   800     {
   809     {
   801     delete CoreObj;
   810     delete CoreObj;
       
   811         __UHEAP_MARKEND ;
   802     return KErrNone;	
   812     return KErrNone;	
   803     }
   813     }
   804     
   814     
   805     delete CoreObj;
   815     delete CoreObj;
       
   816     __UHEAP_MARKEND ;
   806 }
   817 }
   807 
   818 
   808 TInt CTLocTest :: EmptyCancelLocAsynch(CStifItemParser& /*aItem*/)
   819 TInt CTLocTest :: EmptyCancelLocAsynch(CStifItemParser& /*aItem*/)
   809 {
   820 {
   810 	_LIT(KTLocTest ,"TLocTest");
   821 	_LIT(KTLocTest ,"TLocTest");
   830     delete CoreObj;
   841     delete CoreObj;
   831     return KErrGeneral;
   842     return KErrGeneral;
   832 }
   843 }
   833 
   844 
   834 
   845 
       
   846 TInt CTLocTest :: TraceTimeOut(CStifItemParser& /*aItem*/)
       
   847     {
       
   848     _LIT(KTLocTest ,"TLocTest");
       
   849     iLog->Log(KTLocTest) ;
       
   850     _LIT(KLog , "TraceTimeOut ") ;
       
   851     iLog->Log(KTLocTest) ;
       
   852 
       
   853     TRequestStatus Status = KRequestPending  ;
       
   854     RThread FunctionThread ;
       
   855 
       
   856     TInt ret =  FunctionThread.Create(_L("TraceTimeOut Test") , TraceTimeOutFunc ,KDefaultStackSize , 
       
   857             KMinHeapSize , 0x5000 ,(TAny *) NULL);;
       
   858 
       
   859             if(!ret)
       
   860                 {
       
   861 
       
   862                 _LIT(Klog , "thread created ") ;
       
   863                 iLog->Log(Klog) ;
       
   864                 FunctionThread.Logon(Status)    ;
       
   865                 FunctionThread.Resume() ;
       
   866 
       
   867                 User :: WaitForRequest (Status) ;               
       
   868                 FunctionThread.Close();
       
   869 
       
   870                 ret = Status.Int() ;
       
   871                 }
       
   872 
       
   873 
       
   874             return ret;  
       
   875     }
       
   876 
       
   877 
       
   878 TInt CTLocTest:: ConcurrentCallsGetLoc(CStifItemParser& /*aItem*/)
       
   879     {
       
   880     _LIT(KTLocTest ,"TLocTest");
       
   881     iLog->Log(KTLocTest) ;
       
   882 
       
   883     TRequestStatus Status = KRequestPending  ;
       
   884     RThread FunctionThread ;
       
   885 
       
   886     TInt ret = FunctionThread.Create(_L(" ConcurrentCallsGetLoc Thread") , ConcurrentGetLocationCalls ,KDefaultStackSize , 
       
   887             KMinHeapSize , 0x5000 ,(TAny *) NULL);
       
   888 
       
   889     if(ret == KErrNone)
       
   890         {
       
   891         FunctionThread.Logon(Status)    ;
       
   892         FunctionThread.Resume() ;
       
   893 
       
   894         User :: WaitForRequest (Status) ;               
       
   895 
       
   896 
       
   897         ret = Status.Int() ;
       
   898         }
       
   899     FunctionThread.Close();  
       
   900 
       
   901 
       
   902     return ret;  
       
   903     }
       
   904 
       
   905 
       
   906 TInt CTLocTest:: ConcurrentCallsTrace(CStifItemParser& /*aItem*/)
       
   907     {
       
   908     _LIT(KTLocTest ,"TLocTest");
       
   909     iLog->Log(KTLocTest) ;
       
   910 
       
   911     TRequestStatus Status = KRequestPending  ;
       
   912     RThread FunctionThread ;
       
   913 
       
   914     TInt ret = FunctionThread.Create(_L(" ConcurrentCallsGetLoc Thread") , ConcurrentTraceCalls ,KDefaultStackSize , 
       
   915             KMinHeapSize , 0x5000 ,(TAny *) NULL);
       
   916 
       
   917     if(ret == KErrNone)
       
   918         {
       
   919         FunctionThread.Logon(Status)    ;
       
   920         FunctionThread.Resume() ;
       
   921 
       
   922         User :: WaitForRequest (Status) ;               
       
   923 
       
   924 
       
   925         ret = Status.Int() ;
       
   926         }
       
   927     FunctionThread.Close();  
       
   928 
       
   929 
       
   930     return ret;  
       
   931     }