lbstest/lbstestproduct/lbsclock/inc/ctlbsclockstepmain.h
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2006-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 // @file ctlbsclockstepmain.h
       
    15 // This contains the header file for Clock Tests
       
    16 // 
       
    17 //
       
    18 
       
    19 #ifndef __CT_LBS_CLOCK_MAIN_STEP_H__
       
    20 #define __CT_LBS_CLOCK_MAIN_STEP_H__
       
    21 
       
    22 // EPOC includes.
       
    23 #include <e32base.h>
       
    24 
       
    25 // LBS includes.
       
    26 #include <lbs.h>
       
    27 #include <lbscommon.h>
       
    28 #include <lbs/lbsadmin.h>
       
    29 
       
    30 // LBS test includes.
       
    31 #include <lbs/test/tlbsutils.h>
       
    32 #include <lbs/test/ctlbstimerutils.h>
       
    33 #include "ctlbsclockstep.h"
       
    34 #include "ctlbsclockserver.h"
       
    35 #include "ctlbsclockplugindata.h"
       
    36 
       
    37 
       
    38 // Literals used
       
    39 _LIT(KLbsClockStep_Main, "LbsClockStep_Main");
       
    40 
       
    41 /** Callback flags held as bits in a 32 bit word.
       
    42 */
       
    43 typedef TUint32 TLbsClockCallbackFlags;
       
    44 
       
    45 const TLbsClockCallbackFlags KLbsClockCallback_Got_AdjustClock_Stage1	= 0x0001;
       
    46 const TLbsClockCallbackFlags KLbsClockCallback_Got_AdjustClock_Stage2	= 0x0002;
       
    47 const TLbsClockCallbackFlags KLbsClockCallback_Got_TimerNotification	= 0x0004;
       
    48 const TLbsClockCallbackFlags KLbsClockCallback_Got_AdminNotification	= 0x0008;
       
    49 const TLbsClockCallbackFlags KLbsClockCallback_Got_ClockPluginInUse		= 0x0010; /** Clock Plugin was used to carry out clock adjust. */
       
    50 
       
    51 class CT_LbsClockStep_Main :	public CT_LbsClockStep,
       
    52 								public CActive,
       
    53 								public MLbsAdminObserver,
       
    54 								public MT_LbsTimerUtilsObserver,
       
    55 								public MT_LbsClockPluginDataBusObserver
       
    56 	{
       
    57 public:
       
    58 	~CT_LbsClockStep_Main();
       
    59 
       
    60 	static CT_LbsClockStep_Main* New(CT_LbsClockServer& aParent);
       
    61 	virtual TVerdict doTestStepL();
       
    62 
       
    63 
       
    64 protected:
       
    65 	//Function from MT_LbsDoPosUpdateObserver - Module out data bus updated.
       
    66 //	void HandleDataBusUpdateL(const TModuleDataOut& aModuleDataOut);
       
    67 
       
    68 	//	Functions from CActive.
       
    69 	virtual void DoCancel();
       
    70 	virtual void RunL();
       
    71 	virtual TInt RunError(TInt aError);
       
    72 
       
    73 	// Function from MLbsAdminObserver.
       
    74 	virtual void OnSettingUpdateEvent(TInt aError, const TLbsAdminSetting& aSetting);
       
    75 
       
    76 	// Function from MT_LbsTimerUtilsObserver.
       
    77 	virtual void HandleTimerL(TInt aTimerId, const TTime& aTargetTime);
       
    78 
       
    79 	// Function from MT_lbsClockpluginDataBusObserver.
       
    80 	virtual void HandleDataBusUpdateL(const TClockPluginDataOut& aClockPluginDataOut);
       
    81 	
       
    82 private:
       
    83 	CT_LbsClockStep_Main(CT_LbsClockServer& aParent);
       
    84 	void ConstructL();
       
    85 
       
    86 	void SetCallbackFlag(TLbsClockCallbackFlags aCallbackFlag);
       
    87 
       
    88 	void SetTimeOffsetL();
       
    89 	void SetModuleTimeoutL(TTimeIntervalMicroSeconds aTimeout);
       
    90 	void SetAutoAdjustOnL();
       
    91 
       
    92 	void DetermineModuleTimeToFirstFixL();
       
    93 
       
    94 	void CheckForTestHalt();
       
    95 
       
    96 	void StartAutoAdjustTesting();
       
    97 
       
    98 	void AdjustClock(TBool aUseTimeout, TTimeIntervalMicroSeconds aTimeoutValue);
       
    99 
       
   100 	TBool CompareTimes(T_LbsUtils::TComparisonAccuracyType aCmpAccuracy);
       
   101 
       
   102 	void SetClientTimeout();
       
   103 	TBool ValidateTimeout(const TTimeIntervalMicroSeconds aTimeoutValue);
       
   104 
       
   105 	enum 	{
       
   106 				EWaitingAdminNotify,
       
   107 				EWaiting,
       
   108 				ESoakRefPos,
       
   109 				EClockPluginComplete,
       
   110 				EClockPluginTimeout,
       
   111 				EClockAdjustPending_Stage1,
       
   112 				EClockAdjustPending_Stage2,
       
   113 				EDone
       
   114 			};
       
   115 
       
   116 	/** State machine variable for the test step.
       
   117 	*/
       
   118 	TInt iState;
       
   119 
       
   120 
       
   121 	/** Used to keep a record off all the callback events.
       
   122 	*/
       
   123 	TLbsClockCallbackFlags iCallbackFlags;
       
   124 	
       
   125 
       
   126 	/** Expected callback flags at test end.
       
   127 	*/
       
   128 	TLbsClockCallbackFlags iFlagsToHaltOn;
       
   129 
       
   130 
       
   131 	
       
   132 	/** Current test case being executed.
       
   133 	*/
       
   134 	TInt iTestCaseId;
       
   135 
       
   136 
       
   137 	/** Plugin data bus monitor, to allow the plugin to inform the test harness it was called.
       
   138 	*/
       
   139 	CT_LbsClockPluginDataBusMonitor* iPluginDataBusMonitor;
       
   140 
       
   141 	/** The AGPS mode used by the AGPS module. Set to ETrue for prefered terminal, EFalse for
       
   142 		all others.
       
   143 	*/
       
   144 	TBool iUseGpsPreferTerminalBased;
       
   145 
       
   146 	/** Self locate server - used to invoke the automatic clock adjust.
       
   147 	*/
       
   148 	RPositionServer iServer;
       
   149 	RPositioner iPositioner;
       
   150 
       
   151 
       
   152 	/** Admin data base.
       
   153 	*/
       
   154 	CLbsAdmin* iAdmin;
       
   155 		
       
   156 
       
   157 	/** Network reference position.
       
   158 	
       
   159 		Used for auto adjust tests when AGPS module is request assistance data, which will
       
   160 		result in an additional position be returned when calling NoiftyPositionUpdate.
       
   161 	*/
       
   162 	TPositionInfo iRefPosInfo;
       
   163 
       
   164 
       
   165 	CT_LbsTimerUtils* iVerifyTimer;
       
   166 	TTime iVerifyTime;
       
   167 
       
   168 	/** The offset to alter the current time by.
       
   169 	*/
       
   170 	TTimeIntervalMicroSeconds iTimeStampOffset;
       
   171 
       
   172 	/** The current system time when the client adjust clock was called.
       
   173 		Used to allow timeout verification.
       
   174 	*/	
       
   175 	TTime iAdjustClockCallTime;
       
   176 	
       
   177 	/** The client timeout value to used when calling adjust clock.
       
   178 	*/
       
   179 	TTimeIntervalMicroSeconds iClientTimeout;
       
   180 	
       
   181 	/** Time to first fix of the A-GPS module.
       
   182 	*/
       
   183 	TTimeIntervalMicroSeconds iGpsTimeToFirstFix;
       
   184 	};
       
   185 
       
   186 #endif //__CT_LBS_CLOCK_MAIN_STEP_H__