|
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 // |
|
15 |
|
16 /** |
|
17 @file etel0Step.cpp |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include <simtsy.h> |
|
22 #include "lbsdevloggermacros.h" |
|
23 |
|
24 #include "etel0Step.h" |
|
25 |
|
26 #include "te_suplprotocolsuitedefs.h" |
|
27 #include "suplposinit.h" |
|
28 #include "lbssystemcontroller.h" |
|
29 |
|
30 const TInt KInitializationTimeout = 2000000; //2sec |
|
31 const TInt KPropogationTimeout = 5000000; //5sec |
|
32 |
|
33 CEtel0Step::CEtel0Step() |
|
34 { |
|
35 SetTestStepName(KEtel0Step); |
|
36 } |
|
37 |
|
38 CEtel0Step::~CEtel0Step() |
|
39 { |
|
40 } |
|
41 |
|
42 /** |
|
43 * @return - TVerdict code |
|
44 * Override of base class virtual |
|
45 */ |
|
46 TVerdict CEtel0Step::doTestStepPreambleL() |
|
47 { |
|
48 LBSLOG(ELogP1,"CEtel0Step::doTestStepPreambleL - Start"); |
|
49 |
|
50 RLbsSystemController lbsSysController; |
|
51 lbsSysController.OpenL(KLbsSuplTestUid); |
|
52 //Start the LBS sub-system if it is not running |
|
53 if(lbsSysController.RequestSystemStartup()!= ELbsStartupSuccess) |
|
54 { |
|
55 lbsSysController.Close(); |
|
56 User::Leave(KErrNotReady); |
|
57 } |
|
58 |
|
59 //We do not need Lbs to be running - not to interfere with our tests |
|
60 //User::LeaveIfError(lbsSysController.RequestCompleteCloseDown()); |
|
61 |
|
62 lbsSysController.Close(); |
|
63 |
|
64 |
|
65 // Call base class method for pre test actions |
|
66 CTe_suplprotocolSuiteStepBase::doTestStepPreambleL(); |
|
67 |
|
68 TLbsNetProtocolModuleParams param(*iGatewayObserver); |
|
69 iModule = CSuplGatewayInterface::NewL(reinterpret_cast<TAny*>(¶m)); |
|
70 |
|
71 iSchedulerWait = new(ELeave) CActiveSchedulerWait; |
|
72 iTimer = CLbsCallbackTimer::NewL(*this); |
|
73 |
|
74 //Start active scheduler for a while to complete the async initialization calls |
|
75 iTimer->EventAfter(TTimeIntervalMicroSeconds32(KInitializationTimeout), 0); |
|
76 iSchedulerWait->Start(); |
|
77 |
|
78 LBSLOG(ELogP1,"CEtel0Step::doTestStepPreambleL - End"); |
|
79 return TestStepResult(); |
|
80 } |
|
81 |
|
82 |
|
83 /** Perform etel0Step test step. |
|
84 This test verifies that the SUPL Protocol Module correctly handles the etel network information such as |
|
85 Mobile Country Code, Mobile Network Code, cell id, timing advance, IMSI. |
|
86 @return TVerdict test result code |
|
87 */ |
|
88 TVerdict CEtel0Step::doTestStepL() |
|
89 { |
|
90 LBSLOG(ELogP1,"CEtel0Step::doTestStepL - Start"); |
|
91 |
|
92 INFO_PRINTF1(_L("\t********************************************************************")); |
|
93 INFO_PRINTF1(_L("\tTest of ETEL params on MOLR")); |
|
94 INFO_PRINTF1(_L("\tFor this test Watchers MUST be turned off!")); |
|
95 INFO_PRINTF1(_L("\t********************************************************************")); |
|
96 INFO_PRINTF1(_L("- START -")); |
|
97 |
|
98 |
|
99 RTelServer server; |
|
100 User::LeaveIfError(server.Connect()); |
|
101 CleanupClosePushL(server); |
|
102 |
|
103 RTelServer::TPhoneInfo phoneInfo; |
|
104 User::LeaveIfError(server.GetPhoneInfo(0, phoneInfo)); |
|
105 |
|
106 RMobilePhone phone; |
|
107 User::LeaveIfError(phone.Open(server, phoneInfo.iName)); |
|
108 CleanupClosePushL(phone); |
|
109 |
|
110 RMobilePhone::TMobilePhoneNetworkInfoV1 networkInfo; |
|
111 RMobilePhone::TMobilePhoneNetworkInfoV1Pckg networkInfoPckg(networkInfo); |
|
112 RMobilePhone::TMobilePhoneLocationAreaV1 area; |
|
113 |
|
114 for (TUint i = 0; i < 8; i++) |
|
115 { |
|
116 TUint sectionNumber = i; |
|
117 TBuf<16> configSection; |
|
118 _LIT(KSectionName, "Section%d"); |
|
119 configSection.AppendFormat(KSectionName, sectionNumber); |
|
120 |
|
121 phone.NotifyCurrentNetworkChange(iStatus, networkInfoPckg, area); |
|
122 User::WaitForRequest(iStatus); |
|
123 |
|
124 INFO_PRINTF2(_L("Section: %d ********************************************************************"),i); |
|
125 |
|
126 if (4 == i) |
|
127 { |
|
128 INFO_PRINTF1(_L("This one tests the case where the CountryCode is out of range")); |
|
129 INFO_PRINTF1(_L("The values expected are those set by the previous step (section=3)")); |
|
130 } |
|
131 else if (5 == i) |
|
132 { |
|
133 INFO_PRINTF1(_L("This one tests the case where the NetworkId is out of range")); |
|
134 INFO_PRINTF1(_L("The values expected are those set by a previous step (section=3)")); |
|
135 } |
|
136 |
|
137 |
|
138 INFO_PRINTF4(_L("etel: phone.NotifyCurrentNetworkChange: AreaKnown[%d] LocatuionAreaCode[%d] CellId[%d]"),area.iAreaKnown ,area.iLocationAreaCode,area.iCellId ); |
|
139 |
|
140 // Make the request a tracking one |
|
141 INFO_PRINTF1(_L("\tLBS -> AdviceSystemStatus (Tracking ON)")); |
|
142 iModule->AdviceSystemStatus(CLbsNetworkProtocolBase::ESystemStatusClientTracking); |
|
143 |
|
144 // Initiate MO-LR |
|
145 TLbsNetSessionId sessionId1(TUid::Uid(0x87654321), 0x1111); |
|
146 TLbsNetPosRequestOptionsAssistance options1; |
|
147 options1.SetNewClientConnected(ETrue); |
|
148 TLbsNetPosRequestQuality quality1; |
|
149 options1.SetRequestQuality(quality1); |
|
150 TLbsAsistanceDataGroup dataRequestMask1 = EAssistanceDataBadSatList; |
|
151 options1.SetDataRequestMask(dataRequestMask1); |
|
152 INFO_PRINTF1(_L("\tLBS -> RequestSelfLocation")); |
|
153 iModule->RequestSelfLocation(sessionId1, options1); |
|
154 |
|
155 // Check Connection Manager receives a request for connecting |
|
156 if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq)) |
|
157 { |
|
158 SetTestStepResult(EFail); |
|
159 return TestStepResult(); |
|
160 } |
|
161 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET")); |
|
162 |
|
163 // Simulate the connection is up (inject that event) |
|
164 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET")); |
|
165 iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId()); |
|
166 |
|
167 // Check Connection Manager receives a request to send a SUPL START |
|
168 if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESuplStartSendReq)) |
|
169 { |
|
170 SetTestStepResult(EFail); |
|
171 return TestStepResult(); |
|
172 } |
|
173 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL START -> NET")); |
|
174 |
|
175 // Inject a SUPL RESPONSE |
|
176 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL RESPONSE <- NET")); |
|
177 CSuplMessageBase* resp = BuildSuplResponseL(TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted); |
|
178 iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), resp); |
|
179 |
|
180 // Check gateway receives Location Request |
|
181 INFO_PRINTF1(_L("\tLBS <- ProcessLocationRequest()")); |
|
182 if (EFail == CheckGatewayCallbackL( |
|
183 CSuplGatewayObserver::EProcessLocationRequest) || |
|
184 MLbsNetworkProtocolObserver::EServiceSelfLocation != iGatewayObserver->LocType()) |
|
185 { |
|
186 SetTestStepResult(EFail); |
|
187 return TestStepResult(); |
|
188 } |
|
189 |
|
190 // LBS Requests assistance data |
|
191 INFO_PRINTF1(_L("\tLBS -> RequestAssistanceData ()")); |
|
192 TLbsNetSessionIdArray dummyIdArray; |
|
193 iModule->RequestAssistanceData(dataRequestMask1, dummyIdArray); |
|
194 |
|
195 // Check Connection Manager receives a request to send a SUPL POS INIT |
|
196 // with the assistance data mask requested by the gateway |
|
197 User::LeaveIfNull(iNetworkObserver); |
|
198 |
|
199 // Wait for network observer callback |
|
200 iNetworkObserver->WaitForCallBack(); |
|
201 |
|
202 // Check that callback matches the expected type |
|
203 if((CSuplNetworkTestObserver::ESendSuplPosInitSendReq != iNetworkObserver->CallBackResult()) || |
|
204 !iNetworkObserver->WasObserverCalled()) |
|
205 { |
|
206 SetTestStepResult(EFail); |
|
207 } |
|
208 |
|
209 |
|
210 TInt type = ESuplLocationTypeGsm; |
|
211 GetIntFromConfig(configSection, _L("Type"), type); |
|
212 |
|
213 TInt mcc = 0; |
|
214 GetIntFromConfig(configSection, _L("MCC"), mcc); |
|
215 |
|
216 TInt mnc = 0; |
|
217 GetIntFromConfig(configSection, _L("MNC"), mnc); |
|
218 |
|
219 TInt lac = 0; |
|
220 GetIntFromConfig(configSection, _L("LAC"), lac); |
|
221 |
|
222 TInt cellId = 0; |
|
223 GetIntFromConfig(configSection, _L("CellId"), cellId); |
|
224 |
|
225 TInt ta = 0; |
|
226 GetIntFromConfig(configSection, _L("TA"), ta); |
|
227 |
|
228 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL POS INIT -> NET")); |
|
229 |
|
230 CSuplPosInit* msg = static_cast<CSuplPosInit*>(iNetworkObserver->ReceivedMessage()); |
|
231 CSuplLocationId& locId = msg->GetLocationId(); |
|
232 switch(locId.iStatus) |
|
233 { |
|
234 case ESuplLocStatusStale: |
|
235 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Location id status=[Stale]")); |
|
236 break; |
|
237 case ESuplLocStatusCurrent: |
|
238 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Location id status=[Current]")); |
|
239 break; |
|
240 case ESuplLocStatusUnknown: |
|
241 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Location id status=[Unknown]")); |
|
242 break; |
|
243 } |
|
244 |
|
245 switch(locId.iType) |
|
246 { |
|
247 case ESuplLocationTypeGsm: |
|
248 { |
|
249 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Location id type=[GSM]")); |
|
250 CSuplGsmCellInfo* cellInfo = locId.iGsmCellInfo; |
|
251 INFO_PRINTF6(_L("\t\t\t\t\t\t\t\t Cell info MCC=[%d] MNC=[%d] LAC=[%d] CellId=[%d] TA=[%d]"), |
|
252 cellInfo->iRefMCC, cellInfo->iRefMNC, cellInfo->iRefLAC, cellInfo->iRefCI, cellInfo->iTA); |
|
253 if(type!=locId.iType || mcc!=cellInfo->iRefMCC || mnc!=cellInfo->iRefMNC || lac!=cellInfo->iRefLAC || |
|
254 cellId!=cellInfo->iRefCI || ta!=cellInfo->iTA) |
|
255 { |
|
256 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Fail!")); |
|
257 |
|
258 SetTestStepResult(EFail); |
|
259 } |
|
260 break; |
|
261 } |
|
262 case ESuplLocationTypeWcdma: |
|
263 { |
|
264 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Location id type=[WCDMA]")); |
|
265 CSuplWcdmaCellInfo* cellInfo = locId.iWcdmaCellInfo; |
|
266 INFO_PRINTF4(_L("\t\t\t\t\t\t\t\t Cell info MCC=[%d] MNC=[%d] CellId=[%d]"), |
|
267 cellInfo->iRefMCC, cellInfo->iRefMNC, cellInfo->iRefUC); |
|
268 if(type!=locId.iType || mcc!=cellInfo->iRefMCC || mnc!=cellInfo->iRefMNC || cellId!=cellInfo->iRefUC) |
|
269 { |
|
270 SetTestStepResult(EFail); |
|
271 } |
|
272 break; |
|
273 } |
|
274 default: |
|
275 INFO_PRINTF2(_L("\t\t\t\t\t\t\t\t Wrong location id type=[%d]"), locId.iType); |
|
276 SetTestStepResult(EFail); |
|
277 break; |
|
278 } |
|
279 |
|
280 |
|
281 |
|
282 ResetNetworkObserverL(); |
|
283 |
|
284 if(TestStepResult()!=EPass) |
|
285 { |
|
286 return TestStepResult(); |
|
287 } |
|
288 |
|
289 // Inject a SUPL END (with position) |
|
290 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET")); |
|
291 CSuplMessageBase* suplEnd = BuildSuplEndL(ETrue); |
|
292 |
|
293 iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd); |
|
294 |
|
295 // Check gateway receives Location Update |
|
296 INFO_PRINTF1(_L("\tLBS <- ProcessLocationUpdate()")); |
|
297 if (EFail == CheckGatewayCallbackL( |
|
298 CSuplGatewayObserver::EProcessLocationUpdate)) |
|
299 { |
|
300 SetTestStepResult(EFail); |
|
301 return TestStepResult(); |
|
302 } |
|
303 |
|
304 // Check gateway receives a session complete indication |
|
305 if (EFail == CheckGatewayCallbackL( |
|
306 CSuplGatewayObserver::EProcessSessionComplete)) |
|
307 { |
|
308 SetTestStepResult(EFail); |
|
309 return TestStepResult(); |
|
310 } |
|
311 INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete")); |
|
312 |
|
313 INFO_PRINTF1(_L("\tLBS -> AdviceSystemStatus (Tracking OFF)")); |
|
314 iModule->AdviceSystemStatus(CLbsNetworkProtocolBase::ESystemStatusNone); |
|
315 |
|
316 // Check Connection Manager receives a disconnection request |
|
317 if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq)) |
|
318 { |
|
319 SetTestStepResult(EFail); |
|
320 return TestStepResult(); |
|
321 } |
|
322 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET")); |
|
323 |
|
324 // Check if more observer activity takes place |
|
325 if (iGatewayObserver->IsMoreObserverActivity() || |
|
326 iNetworkObserver->IsMoreObserverActivity()) |
|
327 { |
|
328 SetTestStepResult(EFail); |
|
329 return TestStepResult(); |
|
330 } |
|
331 INFO_PRINTF1(_L("- END -")); |
|
332 |
|
333 SetTestStepResult(EPass); |
|
334 } |
|
335 |
|
336 |
|
337 CleanupStack::PopAndDestroy(&phone); |
|
338 CleanupStack::PopAndDestroy(&server); |
|
339 |
|
340 |
|
341 |
|
342 LBSLOG(ELogP1,"CEtel0Step::doTestStepL - End"); |
|
343 return TestStepResult(); |
|
344 |
|
345 } |
|
346 |
|
347 TVerdict CEtel0Step::doTestStepPostambleL() |
|
348 { |
|
349 LBSLOG(ELogP1,"CEtel0Step::doTestStepPostambleL - Start"); |
|
350 delete iTimer; |
|
351 iTimer=0; |
|
352 |
|
353 delete iSchedulerWait; |
|
354 iSchedulerWait = 0; |
|
355 |
|
356 delete iModule; |
|
357 iModule=0; |
|
358 |
|
359 CTe_suplprotocolSuiteStepBase::doTestStepPostambleL(); |
|
360 LBSLOG(ELogP1,"CEtel0Step::doTestStepPostambleL - End"); |
|
361 return TestStepResult(); |
|
362 } |
|
363 |
|
364 void CEtel0Step::OnTimerEventL(TInt /*aTimerId*/) |
|
365 { |
|
366 iSchedulerWait->AsyncStop(); |
|
367 } |
|
368 |
|
369 TInt CEtel0Step::OnTimerError(TInt /*aTimerId*/, TInt /*aError*/) |
|
370 { |
|
371 iSchedulerWait->AsyncStop(); |
|
372 return KErrNone; |
|
373 } |
|
374 |
|
375 |