lbstest/lbstestproduct/lbssisinstall/src/checkbtpsyfromserverstep.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2008-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 // Example CTestStep derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file checkbtpsyfromserverstep.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23 #include "checkbtpsyfromserverstep.h"
       
    24 
       
    25 CCheckBTPSYFromServerStep::~CCheckBTPSYFromServerStep()
       
    26 /**
       
    27  * Destructor
       
    28  */
       
    29 	{
       
    30 	delete iScheduler;
       
    31 	}
       
    32 
       
    33 CCheckBTPSYFromServerStep::CCheckBTPSYFromServerStep()
       
    34 /**
       
    35  * Constructor
       
    36  */
       
    37 	{
       
    38 	SetTestStepName(KCheckBTPSYFromServerStep);
       
    39 	}
       
    40 
       
    41 TVerdict CCheckBTPSYFromServerStep::doTestStepPreambleL()
       
    42 /**
       
    43  * @return - TVerdict code
       
    44  * Override of base class virtual
       
    45  */
       
    46 	{
       
    47 	CTe_LbsSisInstallStepBase::doTestStepPreambleL();
       
    48 	iScheduler = new(ELeave) CActiveScheduler();
       
    49 	CActiveScheduler::Install(iScheduler);	
       
    50 	return TestStepResult();
       
    51 	}
       
    52 
       
    53 TVerdict CCheckBTPSYFromServerStep::doTestStepL()
       
    54 /**
       
    55  * @return - TVerdict code
       
    56  * Override of base class pure virtual
       
    57  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    58  * not leave. That being the case, the current test result value will be EPass.
       
    59  */
       
    60 	{
       
    61 	if (TestStepResult()==EPass)
       
    62 		{
       
    63 		GetIntFromConfig(ConfigSection(), KTe_BTExpected, iExpectToFindBTPsy);
       
    64 		LocationRequestTestL();
       
    65 		}
       
    66 	return TestStepResult();
       
    67 	}
       
    68 
       
    69 TVerdict CCheckBTPSYFromServerStep::doTestStepPostambleL()
       
    70 /**
       
    71  * @return - TVerdict code
       
    72  * Override of base class virtual
       
    73  */
       
    74 	{
       
    75 	return TestStepResult();
       
    76 	}
       
    77 
       
    78 void CCheckBTPSYFromServerStep::LocationRequestTestL()
       
    79 	{
       
    80 	TInt err = KErrNone;
       
    81 	TPositionModuleInfo modInfo;
       
    82 	RPositionServer posServer;
       
    83 	TBool foundBTPsy = EFalse;
       
    84 
       
    85 	INFO_PRINTF1(KOpenMLFWTxt);
       
    86 	err = posServer.Connect();
       
    87 	AssertTrueSecL(err == KErrNone, KMLFWNotOpenTxt, err);
       
    88 	CleanupClosePushL(posServer);
       
    89 
       
    90 	CPosModules* modules = CPosModules::OpenL();
       
    91 	CleanupStack::PushL(modules);
       
    92 	CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
       
    93 
       
    94 	CPosModuleIdList* idList = modules->ModuleIdListLC();
       
    95 	for (TInt i = 0; i < idList->Count(); i++)
       
    96 		{
       
    97 		TPositionModuleInfo info;
       
    98 		modules->GetModuleInfoL((*idList)[i], info);
       
    99 		INFO_PRINTF2(_L("Module 0x%x"),info.ModuleId().iUid);
       
   100 
       
   101 		if(info.ModuleId().iUid == btGPSPsyIdInt)
       
   102 			{
       
   103 			foundBTPsy = ETrue;
       
   104 			if (!info.IsAvailable())
       
   105 				{
       
   106 				moduleUpdate->SetUpdateAvailability(ETrue);
       
   107 				modules->UpdateModuleL(info.ModuleId(), *moduleUpdate);
       
   108 				}
       
   109 			continue;			
       
   110 			}
       
   111 		}
       
   112 	
       
   113 	if(iExpectToFindBTPsy && foundBTPsy)
       
   114 		{
       
   115 		INFO_PRINTF1(_L("Found BT GPS PSY, as expected. Getting module info\n"));
       
   116 		err = posServer.GetModuleInfoById(btGPSPsyModuleId, modInfo);
       
   117 		if(err == KErrNone)
       
   118 			{
       
   119 			CheckBTPSYModuleInfoL(modInfo);
       
   120 			}
       
   121 		else
       
   122 			{
       
   123 			INFO_PRINTF2(_L("Failed. GetModuleInfoById returned %d\n"), err);
       
   124 			SetTestStepResult(EFail);
       
   125 			}
       
   126 		}
       
   127 	else if(!iExpectToFindBTPsy && !foundBTPsy)
       
   128 		{
       
   129 		INFO_PRINTF1(_L("Did not find BT GPS PSY, as expected\n"));
       
   130 		}
       
   131 	else
       
   132 		{
       
   133 		INFO_PRINTF3(_L("Failed. Expect to find BT? %d. Found BT? %d\n"), iExpectToFindBTPsy, foundBTPsy);
       
   134 		SetTestStepResult(EFail);
       
   135 		}
       
   136 
       
   137 	if (err!=KErrNone)
       
   138 		{
       
   139 		SetTestStepError(err);
       
   140 		}
       
   141 
       
   142 	CleanupStack::PopAndDestroy(4, &posServer); // posServer
       
   143 	}
       
   144 
       
   145 void CCheckBTPSYFromServerStep::AssertTrueSecL(TBool aCondition, const TDesC& aErrorMsg, TInt aErrorCode)
       
   146 	{
       
   147 	if (!aCondition)
       
   148 		{
       
   149 		TBuf<KMaxLogBuffer> buf;
       
   150 		buf.Format(aErrorMsg, aErrorCode);
       
   151 		ERR_PRINTF1(buf);
       
   152 		SetTestStepResult(EFail);
       
   153 		User::LeaveIfError(aErrorCode);
       
   154 		}
       
   155 	}
       
   156 
       
   157 void CCheckBTPSYFromServerStep::CheckBTPSYModuleInfoL(TPositionModuleInfo aInfo)
       
   158 	{
       
   159 	TBuf<KMaxLogBuffer> name;
       
   160 
       
   161 	aInfo.GetModuleName(name);
       
   162 
       
   163 	INFO_PRINTF1( name );
       
   164 
       
   165 	AssertTrueSecL(KErrNone == name.Compare( _L( "Bluetooth GPS" )), _L( "Wrong name for PSY" ), KErrNone);
       
   166 
       
   167 	AssertTrueSecL(aInfo.ModuleId() == btGPSPsyModuleId, _L( "Wrong module id: %d" ), aInfo.ModuleId().iUid);
       
   168 	AssertTrueSecL(aInfo.IsAvailable(), _L("Not available"), KErrNone);
       
   169 	AssertTrueSecL(aInfo.Version().iMajor == 60, _L("Wrong version should be 60 is %d"), aInfo.Version().iMajor);
       
   170 	AssertTrueSecL(aInfo.TechnologyType()
       
   171 			== TPositionModuleInfo::ETechnologyTerminal, 
       
   172 	_L("Not a terminal, but: %d"), aInfo.TechnologyType() );
       
   173 	AssertTrueSecL(aInfo.DeviceLocation()
       
   174 			== TPositionModuleInfo::EDeviceExternal, 
       
   175 	_L("Not external"), aInfo.DeviceLocation() );
       
   176 	AssertTrueSecL(aInfo.ClassesSupported(EPositionInfoFamily)
       
   177 			== (EPositionInfoClass | EPositionGenericInfoClass
       
   178 					| EPositionCourseInfoClass | EPositionSatelliteInfoClass ),
       
   179 			_L("Not expected classes supported: %d"),
       
   180 			aInfo.ClassesSupported(EPositionInfoFamily) );
       
   181 	TPositionModuleInfo::TCapabilities capability =
       
   182 			(TPositionModuleInfo::ECapabilityHorizontal
       
   183 					| TPositionModuleInfo::ECapabilityVertical
       
   184 					| TPositionModuleInfo::ECapabilitySpeed
       
   185 					| TPositionModuleInfo::ECapabilityDirection
       
   186 					| TPositionModuleInfo::ECapabilitySatellite
       
   187 					| TPositionModuleInfo::ECapabilityNmea );
       
   188 	AssertTrueSecL(aInfo.Capabilities() == capability, _L("No correct capabilities: %d"), aInfo.Capabilities() );
       
   189 
       
   190 	TPositionQuality modQ;
       
   191 	aInfo.GetPositionQuality(modQ);
       
   192 
       
   193 	TInt32 hAcc = 0;
       
   194 	TInt32 vAcc = 0;
       
   195 	Math::Int(hAcc, modQ.HorizontalAccuracy() );
       
   196 	Math::Int(vAcc, modQ.VerticalAccuracy() );
       
   197 
       
   198 	AssertTrueSecL(
       
   199 			modQ.TimeToFirstFix() == TTimeIntervalMicroSeconds(80000000), _L("Wrong TTFF value %d, wanted 80"),
       
   200 			(TInt) modQ.TimeToFirstFix().Int64());
       
   201 	AssertTrueSecL(modQ.TimeToNextFix() == TTimeIntervalMicroSeconds(1000000),
       
   202 			_L("Wrong TTNF value %d, wanted 1"), modQ.TimeToNextFix().Int64());
       
   203 	AssertTrueSecL(modQ.HorizontalAccuracy() == 10.0, _L(""), hAcc);
       
   204 	AssertTrueSecL(modQ.VerticalAccuracy() == 30.0, _L(""), vAcc);
       
   205 	AssertTrueSecL(modQ.CostIndicator() == TPositionQuality::ECostZero, _L(""), modQ.CostIndicator() );
       
   206 	AssertTrueSecL(modQ.PowerConsumption() == TPositionQuality::EPowerMedium,
       
   207 			_L(""), modQ.PowerConsumption() );
       
   208 	}
       
   209 
       
   210 // End of file