locationmgmt/agpslocationmgr/test/te_man/src/man1Step.cpp
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 // Example CTestStep derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file man1Step.cpp
       
    20 */
       
    21 #include "man1Step.h"
       
    22 #include "Te_manSuiteDefs.h"
       
    23 #include "LbsInternalInterface.h"
       
    24 
       
    25 
       
    26 
       
    27 Cman1Step::~Cman1Step()
       
    28 /**
       
    29  * Destructor
       
    30  */
       
    31 	{
       
    32 	}
       
    33 
       
    34 Cman1Step::Cman1Step()
       
    35 /**
       
    36  * Constructor
       
    37  */
       
    38 	{
       
    39 	// **MUST** call SetTestStepName in the constructor as the controlling
       
    40 	// framework uses the test step name immediately following construction to set
       
    41 	// up the step's unique logging ID.
       
    42 	SetTestStepName(Kman1Step);
       
    43 	}
       
    44 
       
    45 TVerdict Cman1Step::doTestStepPreambleL()
       
    46 /**
       
    47  * @return - TVerdict code
       
    48  * Override of base class virtual
       
    49  */
       
    50 	{
       
    51 	//INFO_PRINTF1(_L("Please delete this line or modify it. I am in Test Step Preamble in Class Cman1Step"));
       
    52 	// uncomment the following 3 lines if you have common pre setting to all the test steps in there
       
    53 	// CTe_manSuiteStepBase::doTestStepPreambleL();
       
    54 	// if (TestStepResult()!=EPass)
       
    55 	//    return   TestStepResult();
       
    56 	// process some pre setting to this test step then set SetTestStepResult to EFail or Epass.
       
    57 	SetTestStepResult(EPass);
       
    58 	return TestStepResult();
       
    59 	}
       
    60 
       
    61 
       
    62 TVerdict Cman1Step::doTestStepL()
       
    63 /**
       
    64  * @return - TVerdict code
       
    65  * Override of base class pure virtual
       
    66  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    67  * not leave. That being the case, the current test result value will be EPass.
       
    68  */
       
    69 	{
       
    70 	
       
    71  	if (TestStepResult()==EPass)
       
    72 		{
       
    73 		
       
    74 		INFO_PRINTF1(_L("Simulate location server sending a location update cancel request"));
       
    75 		INFO_PRINTF1(_L("Check that the test integration module receives the cancel and responds accordingly"));
       
    76 			
       
    77 		const RLbsPositionUpdateRequests::TChannelIdentifer KChannelIdentifier = 
       
    78 			{
       
    79 				{KLbsGpsLocManagerUidValue},{KLbsLocServerUidValue}
       
    80 			};
       
    81 		
       
    82 		const TUint KLbsGpsLocManagerUidValue		= 0x10281D44;
       
    83 		const TUid 	KLbsGpsLocManagerUid			= {KLbsGpsLocManagerUidValue};
       
    84 
       
    85 		RLbsPositionUpdateRequests posUpdateReq;
       
    86 		posUpdateReq.OpenL(KChannelIdentifier);
       
    87 		CleanupClosePushL(posUpdateReq);
       
    88 		
       
    89 		RLbsModuleStatus modStatus;
       
    90 		modStatus.OpenL(KLbsGpsLocManagerUid);
       
    91 		CleanupClosePushL(modStatus);
       
    92 		TRequestStatus stat;
       
    93 		modStatus.NotifyModuleStatusChange(stat);
       
    94 		
       
    95 		// first send a status, in case a cancel was sent before since the AGPS manager doesn't handle 
       
    96 		// more than one cancel if cancels follow one after the other
       
    97 		TLbsPositionUpdateRequestStatus initialStatus;
       
    98 		initialStatus.SetPowerAdvice(TLbsPositionUpdateRequestBase::EPowerAdviceOn);
       
    99 		User::LeaveIfError(posUpdateReq.SetPositionUpdateRequest(initialStatus));
       
   100 		User::WaitForRequest(stat);
       
   101 		modStatus.NotifyModuleStatusChange(stat);
       
   102 
       
   103 		// simulate what is done by Location Server when it wants to cancel
       
   104 		TLbsPositionUpdateRequestCancel cancel;
       
   105 		cancel.SetPowerAdvice(TLbsPositionUpdateRequestBase::EPowerAdviceStandby);
       
   106 		User::LeaveIfError(posUpdateReq.SetPositionUpdateRequest(cancel));
       
   107 			
       
   108 		INFO_PRINTF1(_L("Send cancel location request to integration module"));
       
   109 
       
   110 	    // the test version of the integration module is hardwired to now send
       
   111 	    // a device status change EDeviceStandBy - as confirmation of getting the cancel!
       
   112 		User::WaitForRequest(stat);
       
   113 		if(stat.Int()!=KErrNone) User::Leave(KErrGeneral);
       
   114 
       
   115 		TPositionModuleStatus status;
       
   116 		TPositionModuleStatusEventBase::TModuleEvent occurredEvents =
       
   117 				TPositionModuleStatusEventBase::EEventNone;
       
   118 		User::LeaveIfError(modStatus.GetModuleStatus(&status, sizeof(status),occurredEvents));
       
   119 
       
   120 		if(status.DeviceStatus() != TPositionModuleStatus::EDeviceStandBy)
       
   121 			{
       
   122 			User::Leave(KErrNotFound);
       
   123 			}
       
   124 		INFO_PRINTF1(_L("Test integration module correctly responds with EDeviceStandBy"));
       
   125 	
       
   126 		SendNgMsg(KSessionCompleteKErrNone);
       
   127 
       
   128 		CleanupStack::PopAndDestroy(&modStatus);
       
   129 		CleanupStack::PopAndDestroy(&posUpdateReq);
       
   130 	
       
   131 
       
   132 	 		//  **************   Block end ****************
       
   133 
       
   134 		SetTestStepResult(EPass);
       
   135 		}
       
   136 	  return TestStepResult();
       
   137 	}
       
   138 
       
   139 
       
   140 
       
   141 
       
   142 TVerdict Cman1Step::doTestStepPostambleL()
       
   143 /**
       
   144  * @return - TVerdict code
       
   145  * Override of base class virtual
       
   146  */
       
   147 	{
       
   148 	//INFO_PRINTF1(_L("Please delete this line or modify it. I am in Test Step Postamble in Class Cman1Step"));
       
   149 	// process something post setting to the test step
       
   150 	// uncomment the following line if you have common post setting to all the test steps in there
       
   151 	// CTe_manSuiteStepBase::doTestStepPostambleL();
       
   152 	// uncomment the following line if you have post process or remove the following line if no post process
       
   153 	// SetTestStepResult(EPass);		// or EFail
       
   154 	return TestStepResult();
       
   155 	}