lbstest/lbstestproduct/lbssimulationpsy/src/ctlbssimulationpsypostp256.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 //  INCLUDES
       
    19 #include "ctlbssimulationpsypostp256.h"
       
    20 
       
    21 // CONSTANTS
       
    22 
       
    23 // ================= MEMBER FUNCTIONS =======================
       
    24   
       
    25 // ---------------------------------------------------------
       
    26 // Constructor.
       
    27 // ---------------------------------------------------------
       
    28 CT_LbsSimulationPSYPosTp256::CT_LbsSimulationPSYPosTp256(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
       
    29 	{
       
    30 	_LIT(KTestName, "TP256 - Measure TimeToFix for SimPSY (ESLI-65KCDT)");
       
    31 	SetTestStepName(KTestName);
       
    32 	}
       
    33 
       
    34 // ---------------------------------------------------------
       
    35 // Destructor.
       
    36 // ---------------------------------------------------------
       
    37 CT_LbsSimulationPSYPosTp256::~CT_LbsSimulationPSYPosTp256()
       
    38 	{
       
    39 	}
       
    40 
       
    41 // ---------------------------------------------------------
       
    42 // CT_LbsSimulationPSYPosTp256::StartL
       
    43 //
       
    44 // (other items were commented in a header).
       
    45 // ---------------------------------------------------------
       
    46 //
       
    47 void CT_LbsSimulationPSYPosTp256::StartL()
       
    48     {
       
    49 	// Setup test environment
       
    50     ConnectL();
       
    51     SetupPsyL(iUidSimulationPsy);
       
    52 
       
    53 	TestTimeToFixL();
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------
       
    57 // CT_LbsSimulationPSYPosTp256::CloseTest()
       
    58 //
       
    59 // (other items were commented in a header).
       
    60 // ---------------------------------------------------------
       
    61 //
       
    62 void CT_LbsSimulationPSYPosTp256::CloseTest()
       
    63 	{
       
    64     iPositioner.Close();
       
    65 	iPosServer.Close();
       
    66 	}
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------
       
    70 // CT_LbsSimulationPSYPosTp256::TestTimeToFixL
       
    71 //
       
    72 // (other items were commented in a header).
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 void CT_LbsSimulationPSYPosTp256::TestTimeToFixL()
       
    76     {
       
    77     _LIT(KFunctionName, "We are inside TestTimeToFixL()");
       
    78 	INFO_PRINTF1(KFunctionName);
       
    79 
       
    80 #ifdef __WINS__
       
    81     _LIT(KSimulationSource, "z:\\system\\test\\testdata\\simulationTTF.sps");
       
    82 #else
       
    83     _LIT(KSimulationSource, "c:\\system\\test\\testdata\\simulationTTF.sps");
       
    84 #endif
       
    85 
       
    86 	_LIT(KService, "service");
       
    87 
       
    88 	const TInt KAcceptedDiff = 200000; // Accepted difference is 200000 us
       
    89 	// Do testing five times
       
    90 	const TInt KNrOfFixes=5;
       
    91     _LIT(KError1, "Error when requesting position");
       
    92     _LIT(KStart, "Testing TestTimeToFixL()");
       
    93     _LIT(KEnd, "TestTimeToFixL() passed");
       
    94     INFO_PRINTF1(KStart);
       
    95 
       
    96 	// Update registry to point to correct simulation data file
       
    97     SetSimDataFileL(KSimulationSource);
       
    98     User::LeaveIfError(OpenPositionerByName(iUidSimulationPsy));
       
    99 
       
   100     TTime requestStart;
       
   101     // Request a pos. fix
       
   102     TPositionInfo posInfo = TPositionInfo();
       
   103 
       
   104 	for (TInt i=0; i<KNrOfFixes; i++)
       
   105 		{
       
   106 		requestStart.UniversalTime();
       
   107 		TInt err = PerformSyncRequest(KService, &posInfo);
       
   108 		if (err != KErrNone)
       
   109 			{
       
   110 			LogErrorAndLeaveL(KError1);
       
   111 			}
       
   112 		
       
   113 		// Measure power-up time
       
   114 		TTime requestFinished;
       
   115 		requestFinished.UniversalTime();
       
   116 		TTimeIntervalMicroSeconds requestTime = 
       
   117 			requestFinished.MicroSecondsFrom(requestStart);
       
   118 
       
   119 		TBuf<150> buf;
       
   120 		_LIT(KDebug, "Request time = %d us");
       
   121 			buf.Format(KDebug, requestTime.Int64());
       
   122 
       
   123 			INFO_PRINTF1(buf);
       
   124 
       
   125 		TPosition tmp;
       
   126 		posInfo.GetPosition(tmp);
       
   127 		TTime reqTime = tmp.Time();
       
   128 
       
   129 		TTimeIntervalMicroSeconds requestTime2 = 
       
   130 			reqTime.MicroSecondsFrom(requestStart);
       
   131 
       
   132 		_LIT(KDebug2, "Request time2 = %d us");
       
   133 		buf.Format(KDebug2, requestTime2.Int64());
       
   134 
       
   135 		INFO_PRINTF1(buf);
       
   136 
       
   137 		// Verify that the timestamp of the positionInfo object is set when 
       
   138 		// the position is returned and not when the position request is made
       
   139 		// Accept a minor difference between the two
       
   140 		if (Abs(requestTime.Int64()-requestTime2.Int64())>KAcceptedDiff )
       
   141 			{
       
   142 			_LIT(KErrorAndLeave, "Timestamp not correctly set");
       
   143 			LogErrorAndLeaveL(KErrorAndLeave);
       
   144 			}
       
   145 		}
       
   146 
       
   147     ClosePositioner();
       
   148     INFO_PRINTF1(KEnd);
       
   149     }
       
   150 
       
   151 //  End of File