locationmgmt/agpslocationmgr/test/te_man/src/man14Step.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2007-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 // AGPS Manager test 14
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file man14Step.cpp
       
    20 */
       
    21  
       
    22 #include "man14step.h"
       
    23 #include "Te_manSuiteDefs.h"
       
    24 #include "LbsInternalInterface.h"
       
    25 #include <lbs/lbslocdatasourcegpsbase.h>
       
    26 #include <lbs/lbsextendedsatellite.h>
       
    27 
       
    28 Cman14Step::~Cman14Step()
       
    29 	{
       
    30 	}
       
    31 
       
    32 Cman14Step::Cman14Step()
       
    33 	{
       
    34 	SetTestStepName(Kman14Step);
       
    35 	}
       
    36 
       
    37 TVerdict Cman14Step::doTestStepPreambleL()
       
    38 /**
       
    39  * @return - TVerdict code
       
    40  * Override of base class virtual
       
    41  */
       
    42 	{
       
    43 	SetTestStepResult(EPass);
       
    44 	return TestStepResult();
       
    45 	}
       
    46 
       
    47 // Simulate location server sending early completion update
       
    48 // The manager must publish the received position for the NRH
       
    49 // Check that location published by manager is correct
       
    50 TVerdict Cman14Step::doTestStepL()
       
    51 /**
       
    52  * @return - TVerdict code
       
    53  * Override of base class pure virtual
       
    54  */
       
    55 	{
       
    56 	if (TestStepResult()==EPass)
       
    57 		{
       
    58 		
       
    59 		const RLbsPositionUpdateRequests::TChannelIdentifer KChannelIdentifierLocServer = 
       
    60 			{
       
    61 				{KLbsGpsLocManagerUidValue},{KLbsLocServerUidValue}
       
    62 			};
       
    63 		const RLbsPositionUpdateRequests::TChannelIdentifer KChannelIdentifierNRH = 
       
    64 			{
       
    65 				{KLbsGpsLocManagerUidValue},{KLbsNetRequestHandlerUidValue}
       
    66 		    };
       
    67 		    
       
    68 		    
       
    69 		// Cancel requests from LocServer and NRH so there is no effect from previous tests
       
    70 		
       
    71 	    RLbsPositionUpdateRequests posUpdateReqLocSrv;
       
    72 		posUpdateReqLocSrv.OpenL(KChannelIdentifierLocServer);
       
    73 		CleanupClosePushL(posUpdateReqLocSrv);
       
    74 		
       
    75 		RLbsPositionUpdateRequests posUpdateReqNRH;
       
    76 		posUpdateReqNRH.OpenL(KChannelIdentifierNRH);
       
    77 		CleanupClosePushL(posUpdateReqNRH);
       
    78 		
       
    79 		// Simulate the NRH subscribing to the Position Update Bus
       
    80 		RLbsPositionUpdates posUpdateNRH;
       
    81 		posUpdateNRH.OpenL(KLbsGpsLocManagerUid);
       
    82 		CleanupClosePushL(posUpdateNRH);
       
    83 		
       
    84 		// Simulate the Loc Server opening the early completion updates bus
       
    85 		RLbsPositionUpdates earlyCompletionPosUpdates;
       
    86 		earlyCompletionPosUpdates.OpenL(KLbsLocServerUid);
       
    87 		CleanupClosePushL(earlyCompletionPosUpdates);
       
    88 				
       
    89 		// Simulate the Location Server sending a location update request
       
    90 		//
       
    91 		TLbsPositionUpdateRequest locRequest;
       
    92 		TLbsLocRequestQualityInt quality;
       
    93 		quality.SetMaxFixTime(5000000);
       
    94 		quality.SetMinHorizontalAccuracy(0.1);
       
    95 		quality.SetMinVerticalAccuracy(0.1);
       
    96 		TTime targetTime;
       
    97 		targetTime.UniversalTime(); // target time is now and try for 5 seconds!
       
    98     	locRequest.RequestQuality() = quality;
       
    99 		locRequest.TargetTime() = targetTime;
       
   100 		
       
   101 		
       
   102 		TLbsNetPosRequestMethodInt methods;
       
   103 		TLbsNetPosMethodInt posMethods[1];
       
   104 		posMethods[0].SetPosMethod(KLbsRootUid, (TPositionModuleInfo::ETechnologyTerminal|TPositionModuleInfo::ETechnologyAssisted));
       
   105 		methods.SetPosMethods(posMethods, 1);
       
   106 		locRequest.RequestMethod() = methods;
       
   107 		
       
   108 		INFO_PRINTF1(_L("Loc server sends a location request to integration module"));
       
   109 		User::LeaveIfError(posUpdateReqLocSrv.SetPositionUpdateRequest(locRequest));
       
   110 
       
   111 		User::After(1000000);
       
   112 		
       
   113 		// Build a location update with some non-default data in it
       
   114 		// and with KPositionEarlyComplete as error code.
       
   115 		TPositionExtendedSatelliteInfo satInfo;
       
   116 		satInfo.SetSatelliteTime(TTime(500));
       
   117 		TInt error=KPositionEarlyComplete;
       
   118 		targetTime = 100;
       
   119 		TTime actualTime(200);
       
   120 		TBool conflictControl=EFalse;
       
   121 
       
   122 		INFO_PRINTF1(_L("LocServer Early Completion Update -> AGPS Manager"));
       
   123 		//Simulate the Location Server publishing the above position
       
   124 		earlyCompletionPosUpdates.SetPositionInfo(error, conflictControl, &satInfo, sizeof(satInfo), targetTime, actualTime);
       
   125 
       
   126 		// Wait a bit...
       
   127 		INFO_PRINTF1(_L("AGPS Manager Early Completion Update -> GPS Location Bus"));
       
   128 		User::After(2000000);
       
   129 		
       
   130 		// ...and expect the position to show up on the Position Update Bus
       
   131 		TPositionExtendedSatelliteInfo satInfoNrh;
       
   132 		INFO_PRINTF1(_L("NRH retrieves update <- GPS Location Bus"));
       
   133 		error = posUpdateNRH.GetPositionInfo(conflictControl, &satInfoNrh, sizeof(satInfoNrh),targetTime, actualTime);
       
   134 
       
   135 		// Check that the error code is no other than KPositionEarlyComplete
       
   136 		if(error != KPositionEarlyComplete)
       
   137 			{
       
   138 			INFO_PRINTF1(_L("Unexpected error code"));
       
   139 			User::Leave(KErrGeneral);
       
   140 			}
       
   141 		INFO_PRINTF1(_L("Completion code is KPositionEarlyComplete as expected"));
       
   142 
       
   143 			
       
   144 		// Check that the satellite data received by NRH is the same as published by LocServer		
       
   145 		if(satInfoNrh.SatelliteTime() != satInfo.SatelliteTime())
       
   146 			{
       
   147 			INFO_PRINTF1(_L("Unexpected satellite data"));
       
   148 			User::Leave(KErrGeneral);
       
   149 			}
       
   150 		INFO_PRINTF1(_L("Location Update received by NRH is the same as the one published by LocServer"));
       
   151 	
       
   152 	
       
   153 		// Cancel requests so there is no effect on later tests
       
   154 	//	User::LeaveIfError(posUpdateReqLocSrv.SetPositionUpdateRequest(cancel));
       
   155 	//	User::LeaveIfError(posUpdateReqNRH.SetPositionUpdateRequest(cancel));
       
   156 	//	User::After(1000000); // Allow one second for the cancel to take effect	
       
   157 		
       
   158 	//	WaitAndValidateNgMsg(TLbsNetInternalMsgBase::EAssistanceDataRequest);
       
   159 	//	WaitAndValidateNgMsg(TLbsNetInternalMsgBase::ESelfLocationCancel);
       
   160 
       
   161 		const TLbsNetSessionIdInt KDummySessionId;
       
   162 		const TLbsNetSessionCompleteAgpsMsg KSessionCompleteKErrNone(KDummySessionId, KErrNone);
       
   163 		SendNgMsg(KSessionCompleteKErrNone);
       
   164 
       
   165 		CleanupStack::PopAndDestroy(&earlyCompletionPosUpdates);
       
   166 		CleanupStack::PopAndDestroy(&posUpdateNRH);
       
   167 	    CleanupStack::PopAndDestroy(&posUpdateReqNRH);
       
   168 		CleanupStack::PopAndDestroy(&posUpdateReqLocSrv);
       
   169 	
       
   170     	SetTestStepResult(EPass);
       
   171 		}
       
   172 	  return TestStepResult();
       
   173 	}
       
   174 
       
   175 TVerdict Cman14Step::doTestStepPostambleL()
       
   176 /**
       
   177  * @return - TVerdict code
       
   178  * Override of base class virtual
       
   179  */
       
   180 	{
       
   181 	return TestStepResult();
       
   182 	}
       
   183