|
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 // |
|
15 |
|
16 // LBS includes. |
|
17 #include <lbs.h> |
|
18 #include <lbs/lbsnetcommon.h> |
|
19 #include <lbs/lbsnetprotocolbase.h> |
|
20 #include <lbs/lbsloccommon.h> |
|
21 #include <lbs/lbsx3p.h> |
|
22 #include <lbs/lbsassistancedatabuilderset.h> |
|
23 |
|
24 // LBS test includes. |
|
25 #include "ctlbshybridueassistedx3pgpsfutile.h" |
|
26 #include <lbs/test/tlbsutils.h> |
|
27 #include <lbs/test/lbsnetprotocolproxy.h> |
|
28 #include "argutils.h" |
|
29 |
|
30 /** |
|
31 Static Constructor |
|
32 */ |
|
33 CT_LbsHybridUEAssistedX3PGPSFutile* CT_LbsHybridUEAssistedX3PGPSFutile::New(CT_LbsHybridX3PServer& aParent) |
|
34 { |
|
35 // Note the lack of ELeave. |
|
36 // This means that having insufficient memory will return NULL; |
|
37 CT_LbsHybridUEAssistedX3PGPSFutile* testStep = new CT_LbsHybridUEAssistedX3PGPSFutile(aParent); |
|
38 if (testStep) |
|
39 { |
|
40 TInt err = KErrNone; |
|
41 |
|
42 TRAP(err, testStep->ConstructL()); |
|
43 if (err) |
|
44 { |
|
45 delete testStep; |
|
46 testStep = NULL; |
|
47 } |
|
48 } |
|
49 return testStep; |
|
50 } |
|
51 |
|
52 |
|
53 /** |
|
54 * Constructor |
|
55 */ |
|
56 CT_LbsHybridUEAssistedX3PGPSFutile::CT_LbsHybridUEAssistedX3PGPSFutile(CT_LbsHybridX3PServer& aParent) : CT_LbsHybridX3PStep(aParent) |
|
57 { |
|
58 SetTestStepName(KLbsHybridUEAssistedX3PGPSFutile); |
|
59 } |
|
60 |
|
61 |
|
62 void CT_LbsHybridUEAssistedX3PGPSFutile::ConstructL() |
|
63 { |
|
64 // Create the base class objects. |
|
65 CT_LbsHybridX3PStep::ConstructL(); |
|
66 User::LeaveIfError(iServer.Connect()); |
|
67 User::LeaveIfError(iTransmitter.Open(iServer)); |
|
68 iProxy = CNetProtocolProxy::NewL(); |
|
69 } |
|
70 |
|
71 |
|
72 /** |
|
73 * Destructor |
|
74 */ |
|
75 CT_LbsHybridUEAssistedX3PGPSFutile::~CT_LbsHybridUEAssistedX3PGPSFutile() |
|
76 { |
|
77 iTransmitter.Close(); |
|
78 iServer.Close(); |
|
79 delete iProxy; |
|
80 } |
|
81 |
|
82 |
|
83 |
|
84 TVerdict CT_LbsHybridUEAssistedX3PGPSFutile::doTestStepL() |
|
85 { |
|
86 // Generic test step used to test the LBS Client Notify position update API. |
|
87 INFO_PRINTF1(_L("CT_LbsHybridUEAssistedX3PGPSFutile::doTestStepL()")); |
|
88 |
|
89 // Stop the test if the preamble failed |
|
90 TESTL(TestStepResult() == EPass); |
|
91 |
|
92 const TInt KTimeOut = 30*1000*1000; |
|
93 const TInt KAdviceSystemStatusTimeout = 40*1000*1000; |
|
94 const TInt KSmallTimeOut = 3*1000*1000; |
|
95 |
|
96 // >> AdviceSystemStatus(0) |
|
97 TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse); |
|
98 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
99 TInt cleanupCnt; |
|
100 cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
101 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
102 CleanupStack::PopAndDestroy(cleanupCnt); |
|
103 |
|
104 //Initiate X3P start |
|
105 // TransmitPosition() |
|
106 _LIT(KThirdParty,"+4407463842101"); |
|
107 const TInt KPriority= 6; |
|
108 TLbsTransmitPositionOptions options(TTimeIntervalMicroSeconds(50*1000*1000)); |
|
109 TRequestStatus refPosStatus=KRequestPending; |
|
110 TRequestStatus transPosStatus=KRequestPending; |
|
111 TPositionInfo refPosInfo; |
|
112 TPositionInfo transPosInfo; |
|
113 iTransmitter.SetTransmitOptions(options); |
|
114 iTransmitter.TransmitPosition(KThirdParty, KPriority, refPosStatus, refPosInfo, transPosStatus, transPosInfo); |
|
115 |
|
116 // RequestTransmitLocation() |
|
117 TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestTransmitLocation); |
|
118 TBufC16<14> thirdParty(KThirdParty); |
|
119 TPtr16 ptr = thirdParty.Des(); |
|
120 HBufC16* getThirdParty = NULL; |
|
121 TLbsNetSessionId* getSessionId = NULL; |
|
122 TInt getPriority(0); |
|
123 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority); |
|
124 TESTL(ptr.Compare(*getThirdParty)==KErrNone); |
|
125 TESTL(getPriority == KPriority); |
|
126 iSessionId = *getSessionId; //session ID is initialised by LBS |
|
127 CleanupStack::PopAndDestroy(cleanupCnt); |
|
128 |
|
129 // ProcessStatusUpdate() |
|
130 const MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceTransmitThirdParty; |
|
131 iProxy->CallL(ENetMsgProcessStatusUpdate, &service); |
|
132 //End Initiate |
|
133 |
|
134 //Reference Position Notification Start |
|
135 // ProcessLocationUpdate() |
|
136 refPosInfo = ArgUtils::ReferencePositionInfo(); |
|
137 iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); |
|
138 //Reference Position Notification End |
|
139 |
|
140 |
|
141 //Assistance Data Notification Start |
|
142 // ProcessAssistanceData() |
|
143 TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; |
|
144 RLbsAssistanceDataBuilderSet assistanceData; |
|
145 ArgUtils::PopulateLC(assistanceData); |
|
146 TInt reason = KErrNone; |
|
147 iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); |
|
148 CleanupStack::PopAndDestroy(1); //assistanceData |
|
149 // Assistance Data Notification End |
|
150 |
|
151 // Network Location Request Start |
|
152 // ProcessLocationRequest() |
|
153 const TBool emergency(EFalse); |
|
154 TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); |
|
155 TLbsNetPosRequestMethod method = ArgUtils::RequestHybridMethod(); |
|
156 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
157 // Network Location Request Stop |
|
158 |
|
159 //Start the timer |
|
160 TTime timerStart; |
|
161 timerStart.HomeTime(); |
|
162 |
|
163 // RequestAssistanceData(0) |
|
164 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
165 TLbsAsistanceDataGroup dataGroup; |
|
166 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
167 TESTL(dataGroup == EAssistanceDataNone); // NOTE : dataGroup has not been pushed on the CleanupStack by iProxy. Misleading LC suffix in this case. |
|
168 CleanupStack::PopAndDestroy(cleanupCnt); |
|
169 |
|
170 // here we wait for either of the asynchrnous requestst to complete |
|
171 User::WaitForRequest(refPosStatus, transPosStatus); |
|
172 // but now we do expect that only the REF position asyn request to complete |
|
173 TESTL(refPosStatus==KErrNone); |
|
174 TESTL(transPosStatus.Int() == KRequestPending); |
|
175 |
|
176 |
|
177 //Find the time elapsed from timer |
|
178 TTimeIntervalMicroSeconds microseconds; |
|
179 TTime timerStop; |
|
180 timerStop.HomeTime(); |
|
181 microseconds = timerStop.MicroSecondsFrom(timerStart); |
|
182 TInt64 timeElapsed = microseconds.Int64(); |
|
183 |
|
184 /*** NRH's Alpha2 timer expires. We enter Hybrid mode.***/ |
|
185 //Test that we do not get response before alpha2 has expired |
|
186 TESTL(iProxy->WaitForResponse(KAlpha2Timeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); |
|
187 TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest); |
|
188 getSessionId = NULL; |
|
189 TInt getReason = KErrNone; |
|
190 TPositionSatelliteInfo* getPositionInfo = NULL; |
|
191 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
192 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
193 TESTL(getReason==KErrNone); |
|
194 CleanupStack::PopAndDestroy(cleanupCnt); |
|
195 |
|
196 quality = ArgUtils::Quality(); |
|
197 iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); |
|
198 |
|
199 // RequestAssistanceData(0) |
|
200 TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); |
|
201 cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); |
|
202 TESTL(dataGroup == EAssistanceDataNone); |
|
203 CleanupStack::PopAndDestroy(cleanupCnt); |
|
204 |
|
205 TESTL(iProxy->WaitForResponse(KTTimeout) == ENetMsgRespondLocationRequest); |
|
206 getSessionId = NULL; |
|
207 getReason = KErrNone; |
|
208 getPositionInfo = NULL; |
|
209 cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); |
|
210 TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); |
|
211 TESTL(getReason==KPositionCalculationFutile); |
|
212 CleanupStack::PopAndDestroy(cleanupCnt); |
|
213 |
|
214 // Network Result Notification Start |
|
215 // ProcessLocationUpdate() |
|
216 //Final Network Position = ref position |
|
217 refPosInfo.SetPositionMode(TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted); |
|
218 iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); |
|
219 // Network Result Notification Stop |
|
220 |
|
221 // Session Complete Start |
|
222 reason = KErrNone; |
|
223 iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
224 |
|
225 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone; |
|
226 iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask); |
|
227 // Session Complete Stop |
|
228 |
|
229 // the REF position request has completed, so now, after injecting the FNP and Session Complete |
|
230 // we expect that the other request to complete with KErrNone |
|
231 User::WaitForRequest(transPosStatus); |
|
232 |
|
233 TESTL(transPosStatus==KPositionQualityLoss); |
|
234 return TestStepResult(); |
|
235 } |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |