|
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 #include "tpacketservicetsytesthelper.h" |
|
17 #include "cctsyinidata.h" |
|
18 |
|
19 #include "pcktcs.h" |
|
20 |
|
21 /** |
|
22 * Constructor |
|
23 */ |
|
24 TPacketServiceTsyTestHelper::TPacketServiceTsyTestHelper(CCTSYIntegrationTestSuiteStepBase& aTestStep) |
|
25 : TTsyTestHelperBase( aTestStep ) |
|
26 { |
|
27 } |
|
28 /** |
|
29 * Notify reset for RPacketContext::NotifyConnectionSpeedChange |
|
30 */ |
|
31 void TPacketServiceTsyTestHelper::WaitForPacketContextNotifyConnectionSpeedChange( |
|
32 RPacketContext& aPacketContext, |
|
33 TEtelRequestBase& aRequestStatus, |
|
34 TUint& aRate, |
|
35 TUint aExpectedRate, |
|
36 TInt aWantedStatus ) |
|
37 |
|
38 { |
|
39 // Wait for the request to complete |
|
40 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
41 ASSERT_EQUALS(err, KErrNone, _L("RPacketContext::NotifyConnectionSpeedChange did not complete")) |
|
42 |
|
43 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
44 && aRate != aExpectedRate ) |
|
45 { |
|
46 // Request has completed with incorrect result. Consume any outstanding |
|
47 // Repost notification until timeout or we get the right result. |
|
48 |
|
49 aPacketContext.NotifyConnectionSpeedChange(aRequestStatus, aRate); |
|
50 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
51 } |
|
52 |
|
53 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketContext::NotifyConnectionSpeedChange Wrong completion status")) |
|
54 ASSERT_EQUALS(aRate, aExpectedRate, |
|
55 _L("RPacketContext::NotifyConnectionSpeedChange Wrong result")) |
|
56 |
|
57 // Cancel request if it is still pending |
|
58 if (aRequestStatus.Int() == KRequestPending) |
|
59 { |
|
60 aRequestStatus.Cancel(); |
|
61 } |
|
62 } |
|
63 |
|
64 |
|
65 /** |
|
66 * Notify reset for RPacketContext::NotifyStatusChange |
|
67 */ |
|
68 void TPacketServiceTsyTestHelper::WaitForPacketContextNotifyStatusChange( |
|
69 RPacketContext& aPacketContext, |
|
70 TEtelRequestBase& aRequestStatus, |
|
71 RPacketContext::TContextStatus& aContextStatus, |
|
72 RPacketContext::TContextStatus aExpectedContextStatus, |
|
73 TInt aWantedStatus ) |
|
74 |
|
75 { |
|
76 // Wait for the request to complete |
|
77 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeVeryLong); |
|
78 ASSERT_EQUALS(err, KErrNone, _L("RPacketContext::NotifyStatusChange did not complete")) |
|
79 |
|
80 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
81 && aContextStatus != aExpectedContextStatus ) |
|
82 { |
|
83 // Request has completed with incorrect result. Consume any outstanding |
|
84 // Repost notification until timeout or we get the right result. |
|
85 |
|
86 aPacketContext.NotifyStatusChange(aRequestStatus, aContextStatus); |
|
87 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeVeryLong); |
|
88 } |
|
89 |
|
90 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketContext::NotifyStatusChange Wrong completion status")) |
|
91 ASSERT_EQUALS(aContextStatus, aExpectedContextStatus, |
|
92 _L("RPacketContext::NotifyStatusChange Wrong result")) |
|
93 |
|
94 // Cancel request if it is still pending |
|
95 if (aRequestStatus.Int() == KRequestPending) |
|
96 { |
|
97 aRequestStatus.Cancel(); |
|
98 } |
|
99 } |
|
100 |
|
101 |
|
102 /** |
|
103 * Notify reset for RPacketContext::NotifyConfigChanged |
|
104 */ |
|
105 /*DOES NOT COMPILE |
|
106 void TPacketServiceTsyTestHelper::WaitForPacketContextNotifyConfigChanged( |
|
107 RPacketContext& aPacketContext, |
|
108 TEtelRequestBase& aRequestStatus, |
|
109 TCmpBase<RPacketContext::TContextConfigGPRS> &aContextConfigGPRS, |
|
110 TInt aWantedStatus ) |
|
111 |
|
112 { |
|
113 // Wait for the request to complete |
|
114 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
115 ASSERT_EQUALS(err, KErrNone, _L("RPacketContext::NotifyConfigChanged did not complete")) |
|
116 |
|
117 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
118 && !aContextConfigGPRS.IsEqual(ENoLogError) ) |
|
119 { |
|
120 // Request has completed with incorrect result. Consume any outstanding |
|
121 // Repost notification until timeout or we get the right result. |
|
122 RPacketContext::TContextConfigGPRSPckg pkgParam( aContextConfigGPRS.GetValue() ); |
|
123 aPacketContext.NotifyConfigChanged(aRequestStatus, pkgParam); |
|
124 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
125 } |
|
126 |
|
127 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketContext::NotifyConfigChanged Wrong completion status")) |
|
128 ASSERT_TRUE(aContextConfigGPRS.IsEqual(ELogError), |
|
129 _L("RPacketContext::NotifyConfigChanged Wrong result")) |
|
130 |
|
131 // Cancel request if it is still pending |
|
132 if (aRequestStatus.Int() == KRequestPending) |
|
133 { |
|
134 aRequestStatus.Cancel(); |
|
135 } |
|
136 } |
|
137 */ |
|
138 /** |
|
139 * Notify reset for RPacketContext::NotifyConfigChanged |
|
140 */ |
|
141 /*DOES NOT COMPILE |
|
142 void TPacketServiceTsyTestHelper::WaitForPacketContextNotifyConfigChanged( |
|
143 RPacketContext& aPacketContext, |
|
144 TEtelRequestBase& aRequestStatus, |
|
145 TCmpBase<RPacketContext::TContextConfigR99_R4> &aContextConfigR99_R4, |
|
146 TInt aWantedStatus ) |
|
147 |
|
148 { |
|
149 // Wait for the request to complete |
|
150 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
151 ASSERT_EQUALS(err, KErrNone, _L("RPacketContext::NotifyConfigChanged did not complete")) |
|
152 |
|
153 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
154 && !aContextConfigR99_R4.IsEqual(ENoLogError) ) |
|
155 { |
|
156 // Request has completed with incorrect result. Consume any outstanding |
|
157 // Repost notification until timeout or we get the right result. |
|
158 RPacketContext::TContextConfigR99_R4Pckg pkgParam( aContextConfigR99_R4.GetValue() ); |
|
159 aPacketContext.NotifyConfigChanged(aRequestStatus, pkgParam); |
|
160 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
161 } |
|
162 |
|
163 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketContext::NotifyConfigChanged Wrong completion status")) |
|
164 ASSERT_TRUE(aContextConfigR99_R4.IsEqual(ELogError), |
|
165 _L("RPacketContext::NotifyConfigChanged Wrong result")) |
|
166 |
|
167 // Cancel request if it is still pending |
|
168 if (aRequestStatus.Int() == KRequestPending) |
|
169 { |
|
170 aRequestStatus.Cancel(); |
|
171 } |
|
172 } |
|
173 */ |
|
174 /** |
|
175 * Notify reset for RPacketContext::NotifyConfigChanged |
|
176 */ |
|
177 /*DOES NOT COMPILE |
|
178 void TPacketServiceTsyTestHelper::WaitForPacketContextNotifyConfigChanged( |
|
179 RPacketContext& aPacketContext, |
|
180 TEtelRequestBase& aRequestStatus, |
|
181 TCmpBase<RPacketContext::TContextConfig_R5> &aContextConfig_R5, |
|
182 TInt aWantedStatus ) |
|
183 |
|
184 { |
|
185 // Wait for the request to complete |
|
186 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
187 ASSERT_EQUALS(err, KErrNone, _L("RPacketContext::NotifyConfigChanged did not complete")) |
|
188 |
|
189 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
190 && !aContextConfig_R5.IsEqual(ENoLogError) ) |
|
191 { |
|
192 // Request has completed with incorrect result. Consume any outstanding |
|
193 // Repost notification until timeout or we get the right result. |
|
194 RPacketContext::TContextConfig_R5Pckg pkgParam( aContextConfig_R5.GetValue() ); |
|
195 aPacketContext.NotifyConfigChanged(aRequestStatus, pkgParam); |
|
196 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
197 } |
|
198 |
|
199 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketContext::NotifyConfigChanged Wrong completion status")) |
|
200 ASSERT_TRUE(aContextConfig_R5.IsEqual(ELogError), |
|
201 _L("RPacketContext::NotifyConfigChanged Wrong result")) |
|
202 |
|
203 // Cancel request if it is still pending |
|
204 if (aRequestStatus.Int() == KRequestPending) |
|
205 { |
|
206 aRequestStatus.Cancel(); |
|
207 } |
|
208 } |
|
209 */ |
|
210 /** |
|
211 * Notify reset for RPacketContext::NotifyDataTransferred |
|
212 */ |
|
213 void TPacketServiceTsyTestHelper::WaitForPacketContextNotifyDataTransferred( |
|
214 RPacketContext& aPacketContext, |
|
215 TEtelRequestBase& aRequestStatus, |
|
216 RPacketContext::TDataVolume& aVolume, |
|
217 RPacketContext::TDataVolume& aExpectedVolume, |
|
218 TUint &aRcvdGranularity, |
|
219 TUint &aSentGranularity, |
|
220 TInt aWantedStatus ) |
|
221 |
|
222 { |
|
223 // Wait for the request to complete |
|
224 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
225 ASSERT_EQUALS(err, KErrNone, _L("RPacketContext::NotifyDataTransferred did not complete")) |
|
226 |
|
227 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
228 && (0 == memcmp(&aVolume, &aExpectedVolume, sizeof(aVolume))) ) |
|
229 { |
|
230 // Request has completed with incorrect result. Consume any outstanding |
|
231 // Repost notification until timeout or we get the right result. |
|
232 |
|
233 aPacketContext.NotifyDataTransferred(aRequestStatus, aVolume, aRcvdGranularity,aSentGranularity); |
|
234 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
235 } |
|
236 |
|
237 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketContext::NotifyDataTransferred Wrong completion status")) |
|
238 ASSERT_TRUE((0 == memcmp(&aVolume, &aExpectedVolume, sizeof(aVolume))), |
|
239 _L("RPacketContext::NotifyDataTransferred Wrong result")) |
|
240 |
|
241 // Cancel request if it is still pending |
|
242 if (aRequestStatus.Int() == KRequestPending) |
|
243 { |
|
244 aRequestStatus.Cancel(); |
|
245 } |
|
246 } |
|
247 |
|
248 |
|
249 /** |
|
250 * Notify reset for RPacketQoS::NotifyProfileChanged |
|
251 */ |
|
252 /*DOES NOT COMPILE |
|
253 void TPacketServiceTsyTestHelper::WaitForPacketQoSNotifyProfileChanged( |
|
254 RPacketQoS& aPacketQoS, |
|
255 TEtelRequestBase& aRequestStatus, |
|
256 TCmpBase<RPacketQoS::TQoSGPRSNegotiated> &aQoSGPRSNegotiated, |
|
257 TInt aWantedStatus ) |
|
258 |
|
259 { |
|
260 // Wait for the request to complete |
|
261 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
262 ASSERT_EQUALS(err, KErrNone, _L("RPacketQoS::NotifyProfileChanged did not complete")) |
|
263 |
|
264 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
265 && !aQoSGPRSNegotiated.IsEqual(ENoLogError) ) |
|
266 { |
|
267 // Request has completed with incorrect result. Consume any outstanding |
|
268 // Repost notification until timeout or we get the right result. |
|
269 RPacketQoS::TQoSGPRSNegotiatedPckg pkgParam( aQoSGPRSNegotiated.GetValue() ); |
|
270 aPacketQoS.NotifyProfileChanged(aRequestStatus, pkgParam); |
|
271 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
272 } |
|
273 |
|
274 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketQoS::NotifyProfileChanged Wrong completion status")) |
|
275 ASSERT_TRUE(aQoSGPRSNegotiated.IsEqual(ELogError), |
|
276 _L("RPacketQoS::NotifyProfileChanged Wrong result")) |
|
277 |
|
278 // Cancel request if it is still pending |
|
279 if (aRequestStatus.Int() == KRequestPending) |
|
280 { |
|
281 aRequestStatus.Cancel(); |
|
282 } |
|
283 } |
|
284 */ |
|
285 /** |
|
286 * Notify reset for RPacketQoS::NotifyProfileChanged |
|
287 */ |
|
288 /*DOES NOT COMPILE |
|
289 void TPacketServiceTsyTestHelper::WaitForPacketQoSNotifyProfileChanged( |
|
290 RPacketQoS& aPacketQoS, |
|
291 TEtelRequestBase& aRequestStatus, |
|
292 TCmpBase<RPacketQoS::TQoSR99_R4Negotiated> &aQoSR99_R4Negotiated, |
|
293 TInt aWantedStatus ) |
|
294 |
|
295 { |
|
296 // Wait for the request to complete |
|
297 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
298 ASSERT_EQUALS(err, KErrNone, _L("RPacketQoS::NotifyProfileChanged did not complete")) |
|
299 |
|
300 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
301 && !aQoSR99_R4Negotiated.IsEqual(ENoLogError) ) |
|
302 { |
|
303 // Request has completed with incorrect result. Consume any outstanding |
|
304 // Repost notification until timeout or we get the right result. |
|
305 RPacketQoS::TQoSR99_R4NegotiatedPckg pkgParam( aQoSR99_R4Negotiated.GetValue() ); |
|
306 aPacketQoS.NotifyProfileChanged(aRequestStatus, pkgParam); |
|
307 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
308 } |
|
309 |
|
310 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketQoS::NotifyProfileChanged Wrong completion status")) |
|
311 ASSERT_TRUE(aQoSR99_R4Negotiated.IsEqual(ELogError), |
|
312 _L("RPacketQoS::NotifyProfileChanged Wrong result")) |
|
313 |
|
314 // Cancel request if it is still pending |
|
315 if (aRequestStatus.Int() == KRequestPending) |
|
316 { |
|
317 aRequestStatus.Cancel(); |
|
318 } |
|
319 } |
|
320 */ |
|
321 /** |
|
322 * Notify reset for RPacketQoS::NotifyProfileChanged |
|
323 */ |
|
324 /*DOES NOT COMPILE |
|
325 void TPacketServiceTsyTestHelper::WaitForPacketQoSNotifyProfileChanged( |
|
326 RPacketQoS& aPacketQoS, |
|
327 TEtelRequestBase& aRequestStatus, |
|
328 TCmpBase<RPacketQoS::TQoSR5Negotiated> &aQoSR5Negotiated, |
|
329 TInt aWantedStatus ) |
|
330 |
|
331 { |
|
332 // Wait for the request to complete |
|
333 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
334 ASSERT_EQUALS(err, KErrNone, _L("RPacketQoS::NotifyProfileChanged did not complete")) |
|
335 |
|
336 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
337 && !aQoSR5Negotiated.IsEqual(ENoLogError) ) |
|
338 { |
|
339 // Request has completed with incorrect result. Consume any outstanding |
|
340 // Repost notification until timeout or we get the right result. |
|
341 RPacketQoS::TQoSR5NegotiatedPckg pkgParam( aQoSR5Negotiated.GetValue() ); |
|
342 aPacketQoS.NotifyProfileChanged(aRequestStatus, pkgParam); |
|
343 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
344 } |
|
345 |
|
346 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketQoS::NotifyProfileChanged Wrong completion status")) |
|
347 ASSERT_TRUE(aQoSR5Negotiated.IsEqual(ELogError), |
|
348 _L("RPacketQoS::NotifyProfileChanged Wrong result")) |
|
349 |
|
350 // Cancel request if it is still pending |
|
351 if (aRequestStatus.Int() == KRequestPending) |
|
352 { |
|
353 aRequestStatus.Cancel(); |
|
354 } |
|
355 } |
|
356 */ |
|
357 /** |
|
358 * Notify reset for RPacketService::NotifyAttachModeChange |
|
359 */ |
|
360 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyAttachModeChange( |
|
361 RPacketService& aPacketService, |
|
362 TEtelRequestBase& aRequestStatus, |
|
363 RPacketService::TAttachMode& aMode, |
|
364 RPacketService::TAttachMode aExpectedMode, |
|
365 TInt aWantedStatus ) |
|
366 |
|
367 { |
|
368 // Wait for the request to complete |
|
369 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
370 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyAttachModeChange did not complete")) |
|
371 |
|
372 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
373 && aMode != aExpectedMode ) |
|
374 { |
|
375 // Request has completed with incorrect result. Consume any outstanding |
|
376 // Repost notification until timeout or we get the right result. |
|
377 |
|
378 aPacketService.NotifyAttachModeChange(aRequestStatus, aMode); |
|
379 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
380 } |
|
381 |
|
382 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyAttachModeChange Wrong completion status")) |
|
383 ASSERT_EQUALS(aMode, aExpectedMode, |
|
384 _L("RPacketService::NotifyAttachModeChange Wrong result")) |
|
385 |
|
386 // Cancel request if it is still pending |
|
387 if (aRequestStatus.Int() == KRequestPending) |
|
388 { |
|
389 aRequestStatus.Cancel(); |
|
390 } |
|
391 } |
|
392 |
|
393 |
|
394 /** |
|
395 * Notify reset for RPacketService::NotifyChangeOfNtwkRegStatus |
|
396 */ |
|
397 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyChangeOfNtwkRegStatus( |
|
398 RPacketService& aPacketService, |
|
399 TEtelRequestBase& aRequestStatus, |
|
400 RPacketService::TRegistrationStatus& aRegistrationStatus, |
|
401 RPacketService::TRegistrationStatus aExpectedRegistrationStatus, |
|
402 TInt aWantedStatus ) |
|
403 |
|
404 { |
|
405 // Wait for the request to complete |
|
406 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
407 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyChangeOfNtwkRegStatus did not complete")) |
|
408 |
|
409 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
410 && aRegistrationStatus != aExpectedRegistrationStatus ) |
|
411 { |
|
412 // Request has completed with incorrect result. Consume any outstanding |
|
413 // Repost notification until timeout or we get the right result. |
|
414 |
|
415 aPacketService.NotifyChangeOfNtwkRegStatus(aRequestStatus, aRegistrationStatus); |
|
416 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
417 } |
|
418 |
|
419 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyChangeOfNtwkRegStatus Wrong completion status")) |
|
420 ASSERT_EQUALS(aRegistrationStatus, aExpectedRegistrationStatus, |
|
421 _L("RPacketService::NotifyChangeOfNtwkRegStatus Wrong result")) |
|
422 |
|
423 // Cancel request if it is still pending |
|
424 if (aRequestStatus.Int() == KRequestPending) |
|
425 { |
|
426 aRequestStatus.Cancel(); |
|
427 } |
|
428 } |
|
429 |
|
430 |
|
431 /** |
|
432 * Notify reset for RPacketService::NotifyContextActivationRequested |
|
433 */ |
|
434 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyContextActivationRequested( |
|
435 RPacketService& aPacketService, |
|
436 TEtelRequestBase& aRequestStatus, |
|
437 TPckg<RPacketContext::TContextConfigGPRS> &aContextConfigGPRSPkg, |
|
438 TInt aWantedStatus ) |
|
439 |
|
440 { |
|
441 // Wait for the request to complete |
|
442 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
443 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyContextActivationRequested did not complete")) |
|
444 |
|
445 while ( err == KErrNone && aRequestStatus.Int() == KErrNone ) |
|
446 { |
|
447 // Request has completed with incorrect result. Consume any outstanding |
|
448 // Repost notification until timeout or we get the right result. |
|
449 aPacketService.NotifyContextActivationRequested(aRequestStatus, aContextConfigGPRSPkg); |
|
450 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeMedium); |
|
451 } |
|
452 |
|
453 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyContextActivationRequested Wrong completion status")) |
|
454 |
|
455 // Cancel request if it is still pending |
|
456 if (aRequestStatus.Int() == KRequestPending) |
|
457 { |
|
458 aRequestStatus.Cancel(); |
|
459 } |
|
460 } |
|
461 |
|
462 /** |
|
463 * Notify reset for RPacketService::NotifyContextActivationRequested |
|
464 */ |
|
465 /*DOES NOT COMPILE |
|
466 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyContextActivationRequested( |
|
467 RPacketService& aPacketService, |
|
468 TEtelRequestBase& aRequestStatus, |
|
469 TCmpBase<RPacketContext::TContextConfigR99_R4> &aContextConfigR99_R4, |
|
470 TInt aWantedStatus ) |
|
471 |
|
472 { |
|
473 // Wait for the request to complete |
|
474 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
475 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyContextActivationRequested did not complete")) |
|
476 |
|
477 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
478 && !aContextConfigR99_R4.IsEqual(ENoLogError) ) |
|
479 { |
|
480 // Request has completed with incorrect result. Consume any outstanding |
|
481 // Repost notification until timeout or we get the right result. |
|
482 RPacketContext::TContextConfigR99_R4Pckg pkgParam( aContextConfigR99_R4.GetValue() ); |
|
483 aPacketService.NotifyContextActivationRequested(aRequestStatus, pkgParam); |
|
484 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
485 } |
|
486 |
|
487 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyContextActivationRequested Wrong completion status")) |
|
488 ASSERT_TRUE(aContextConfigR99_R4.IsEqual(ELogError), |
|
489 _L("RPacketService::NotifyContextActivationRequested Wrong result")) |
|
490 |
|
491 // Cancel request if it is still pending |
|
492 if (aRequestStatus.Int() == KRequestPending) |
|
493 { |
|
494 aRequestStatus.Cancel(); |
|
495 } |
|
496 } |
|
497 */ |
|
498 /** |
|
499 * Notify reset for RPacketService::NotifyContextActivationRequested |
|
500 */ |
|
501 /*DOES NOT COMPILE |
|
502 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyContextActivationRequested( |
|
503 RPacketService& aPacketService, |
|
504 TEtelRequestBase& aRequestStatus, |
|
505 TCmpBase<RPacketContext::TContextConfig_R5> &aContextConfig_R5, |
|
506 TInt aWantedStatus ) |
|
507 |
|
508 { |
|
509 // Wait for the request to complete |
|
510 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
511 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyContextActivationRequested did not complete")) |
|
512 |
|
513 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
514 && !aContextConfig_R5.IsEqual(ENoLogError) ) |
|
515 { |
|
516 // Request has completed with incorrect result. Consume any outstanding |
|
517 // Repost notification until timeout or we get the right result. |
|
518 RPacketContext::TContextConfig_R5Pckg pkgParam( aContextConfig_R5.GetValue() ); |
|
519 aPacketService.NotifyContextActivationRequested(aRequestStatus, pkgParam); |
|
520 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
521 } |
|
522 |
|
523 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyContextActivationRequested Wrong completion status")) |
|
524 ASSERT_TRUE(aContextConfig_R5.IsEqual(ELogError), |
|
525 _L("RPacketService::NotifyContextActivationRequested Wrong result")) |
|
526 |
|
527 // Cancel request if it is still pending |
|
528 if (aRequestStatus.Int() == KRequestPending) |
|
529 { |
|
530 aRequestStatus.Cancel(); |
|
531 } |
|
532 } |
|
533 */ |
|
534 /** |
|
535 * Notify reset for RPacketService::NotifyContextAdded |
|
536 */ |
|
537 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyContextAdded( |
|
538 RPacketService& aPacketService, |
|
539 TEtelRequestBase& aRequestStatus, |
|
540 TDes& aContextId, |
|
541 TDes aExpectedContextId, |
|
542 TInt aWantedStatus ) |
|
543 |
|
544 { |
|
545 // Wait for the request to complete |
|
546 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
547 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyContextAdded did not complete")) |
|
548 |
|
549 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
550 && aContextId != aExpectedContextId ) |
|
551 { |
|
552 // Request has completed with incorrect result. Consume any outstanding |
|
553 // Repost notification until timeout or we get the right result. |
|
554 |
|
555 aPacketService.NotifyContextAdded(aRequestStatus, aContextId); |
|
556 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
557 } |
|
558 |
|
559 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyContextAdded Wrong completion status")) |
|
560 ASSERT_EQUALS_DES16(aContextId, aExpectedContextId, |
|
561 _L("RPacketService::NotifyContextAdded Wrong result")) |
|
562 |
|
563 // Cancel request if it is still pending |
|
564 if (aRequestStatus.Int() == KRequestPending) |
|
565 { |
|
566 aRequestStatus.Cancel(); |
|
567 } |
|
568 } |
|
569 |
|
570 |
|
571 /** |
|
572 * Notify reset for RPacketService::NotifyDynamicCapsChange |
|
573 */ |
|
574 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyDynamicCapsChange( |
|
575 RPacketService& aPacketService, |
|
576 TEtelRequestBase& aRequestStatus, |
|
577 RPacketService::TDynamicCapsFlags& aCaps, |
|
578 RPacketService::TDynamicCapsFlags aWantedCaps, |
|
579 RPacketService::TDynamicCapsFlags aUnwantedCaps, |
|
580 TInt aWantedStatus ) |
|
581 |
|
582 { |
|
583 // Wait for the request to complete |
|
584 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
585 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyDynamicCapsChange did not complete")) |
|
586 |
|
587 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
588 && ( ((aCaps & aWantedCaps) != aWantedCaps) |
|
589 || ((aCaps & aUnwantedCaps) != 0) ) ) |
|
590 { |
|
591 // Request has completed with incorrect result. Consume any outstanding |
|
592 // Repost notification until timeout or we get the right result. |
|
593 aPacketService.NotifyDynamicCapsChange(aRequestStatus, aCaps); |
|
594 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
595 } |
|
596 |
|
597 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, |
|
598 _L("RPacketService::NotifyDynamicCapsChange Wrong completion status")) |
|
599 ASSERT_BITS_SET(aCaps, aWantedCaps, aUnwantedCaps, |
|
600 _L("RPacketService::NotifyDynamicCapsChange Wrong caps")) |
|
601 |
|
602 // Cancel request if it is still pending |
|
603 if (aRequestStatus.Int() == KRequestPending) |
|
604 { |
|
605 aRequestStatus.Cancel(); |
|
606 } |
|
607 } |
|
608 |
|
609 |
|
610 /** |
|
611 * Notify reset for RPacketService::NotifyMSClassChange |
|
612 */ |
|
613 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyMSClassChange( |
|
614 RPacketService& aPacketService, |
|
615 TEtelRequestBase& aRequestStatus, |
|
616 RPacketService::TMSClass& aNewClass, |
|
617 RPacketService::TMSClass aExpectedNewClass, |
|
618 TInt aWantedStatus ) |
|
619 |
|
620 { |
|
621 // Wait for the request to complete |
|
622 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
623 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyMSClassChange did not complete")) |
|
624 |
|
625 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
626 && aNewClass != aExpectedNewClass ) |
|
627 { |
|
628 // Request has completed with incorrect result. Consume any outstanding |
|
629 // Repost notification until timeout or we get the right result. |
|
630 |
|
631 aPacketService.NotifyMSClassChange(aRequestStatus, aNewClass); |
|
632 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
633 } |
|
634 |
|
635 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyMSClassChange Wrong completion status")) |
|
636 ASSERT_EQUALS(aNewClass, aExpectedNewClass, |
|
637 _L("RPacketService::NotifyMSClassChange Wrong result")) |
|
638 |
|
639 // Cancel request if it is still pending |
|
640 if (aRequestStatus.Int() == KRequestPending) |
|
641 { |
|
642 aRequestStatus.Cancel(); |
|
643 } |
|
644 } |
|
645 |
|
646 |
|
647 /** |
|
648 * Notify reset for RPacketService::NotifyReleaseModeChange |
|
649 */ |
|
650 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyReleaseModeChange( |
|
651 RPacketService& aPacketService, |
|
652 TEtelRequestBase& aRequestStatus, |
|
653 RPacketService::TPacketReleaseMode& aReleaseMode, |
|
654 RPacketService::TPacketReleaseMode aExpectedReleaseMode, |
|
655 TInt aWantedStatus ) |
|
656 |
|
657 { |
|
658 // Wait for the request to complete |
|
659 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
660 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyReleaseModeChange did not complete")) |
|
661 |
|
662 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
663 && aReleaseMode != aExpectedReleaseMode ) |
|
664 { |
|
665 // Request has completed with incorrect result. Consume any outstanding |
|
666 // Repost notification until timeout or we get the right result. |
|
667 |
|
668 aPacketService.NotifyReleaseModeChange(aRequestStatus, aReleaseMode); |
|
669 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
670 } |
|
671 |
|
672 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyReleaseModeChange Wrong completion status")) |
|
673 ASSERT_EQUALS(aReleaseMode, aExpectedReleaseMode, |
|
674 _L("RPacketService::NotifyReleaseModeChange Wrong result")) |
|
675 |
|
676 // Cancel request if it is still pending |
|
677 if (aRequestStatus.Int() == KRequestPending) |
|
678 { |
|
679 aRequestStatus.Cancel(); |
|
680 } |
|
681 } |
|
682 |
|
683 |
|
684 /** |
|
685 * Notify reset for RPacketService::NotifyStatusChange |
|
686 */ |
|
687 void TPacketServiceTsyTestHelper::WaitForPacketServiceNotifyStatusChange( |
|
688 RPacketService& aPacketService, |
|
689 TEtelRequestBase& aRequestStatus, |
|
690 RPacketService::TStatus& aPacketStatus, |
|
691 RPacketService::TStatus aExpectedPacketStatus, |
|
692 TInt aWantedStatus ) |
|
693 |
|
694 { |
|
695 // Wait for the request to complete |
|
696 TInt err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeVeryLong); |
|
697 ASSERT_EQUALS(err, KErrNone, _L("RPacketService::NotifyStatusChange did not complete")) |
|
698 |
|
699 while ( err == KErrNone && aRequestStatus.Int() == KErrNone |
|
700 && aPacketStatus != aExpectedPacketStatus ) |
|
701 { |
|
702 // Request has completed with incorrect result. Consume any outstanding |
|
703 // Repost notification until timeout or we get the right result. |
|
704 |
|
705 aPacketService.NotifyStatusChange(aRequestStatus, aPacketStatus); |
|
706 err = iTestStep.WaitForRequestWithTimeOut(aRequestStatus, ETimeShort); |
|
707 } |
|
708 |
|
709 ASSERT_EQUALS(aRequestStatus.Int(), aWantedStatus, _L("RPacketService::NotifyStatusChange Wrong completion status")) |
|
710 ASSERT_EQUALS(aPacketStatus, aExpectedPacketStatus, |
|
711 _L("RPacketService::NotifyStatusChange Wrong result")) |
|
712 |
|
713 // Cancel request if it is still pending |
|
714 if (aRequestStatus.Int() == KRequestPending) |
|
715 { |
|
716 aRequestStatus.Cancel(); |
|
717 } |
|
718 } |
|
719 |
|
720 |
|
721 /** |
|
722 * Gets the GPRS info for the supplied network by reading from the data ini file |
|
723 */ |
|
724 void TPacketServiceTsyTestHelper::GetGprsSettings(RMobilePhone::TMobilePhoneNetworkInfoV1 aInfo, TPtrC& aAccessPoint, TPtrC& aUser, TPtrC& aPassword,TUint aNumber) |
|
725 { |
|
726 TBuf<200> section; |
|
727 if(aInfo.iShortName.Find(_L("voda")) != KErrNotFound) //vodafone |
|
728 { |
|
729 section.Copy(KIniSectionVodafoneGprs); |
|
730 DEBUG_PRINTF1(_L("Retrieving Vodafone GPRS settings")); |
|
731 } |
|
732 else if(aInfo.iShortName.Find(_L("O2")) != KErrNotFound)//O2 |
|
733 { |
|
734 DEBUG_PRINTF1(_L("Retrieving O2 GPRS settings")); |
|
735 section.Copy(KIniSectionO2Gprs); |
|
736 } |
|
737 else if(aInfo.iShortName.Find(_L("Orange"))!= KErrNotFound) //Orange |
|
738 { |
|
739 DEBUG_PRINTF1(_L("Retrieving Orange GPRS settings")); |
|
740 section.Copy(KIniSectionOrangeGprs); |
|
741 } |
|
742 else if((aInfo.iShortName.Find(_L("one2one")) != KErrNotFound)||(aInfo.iShortName.Find(_L("T-Mobile")) != KErrNotFound))//TMobile |
|
743 { |
|
744 DEBUG_PRINTF1(_L("Retrieving TMobile GPRS settings")); |
|
745 section.Copy(KIniSectionTMobileGprs); |
|
746 } |
|
747 else if(aInfo.iShortName.Find(_L("Elisa"))!= KErrNotFound) //Elisa |
|
748 { |
|
749 DEBUG_PRINTF1(_L("Retrieving Elisa GPRS settings")); |
|
750 section.Copy(KIniSectionElisaGprs); |
|
751 } |
|
752 else if(aInfo.iShortName.Find(_L("dna"))!= KErrNotFound) //DNA |
|
753 { |
|
754 DEBUG_PRINTF1(_L("Retrieving DNA GPRS settings")); |
|
755 section.Copy(KIniSectionDNAGprs); |
|
756 } |
|
757 else if(aInfo.iShortName.Find(_L("SONERA"))!= KErrNotFound) //SONERA |
|
758 { |
|
759 DEBUG_PRINTF1(_L("Retrieving Sonera GPRS settings")); |
|
760 section.Copy(KIniSectionSoneraGprs); |
|
761 |
|
762 } |
|
763 else if(aInfo.iShortName.Find(_L("3 UK")) != KErrNotFound) // Three |
|
764 { |
|
765 DEBUG_PRINTF1(_L("Retrieving Three GPRS settings")); |
|
766 section.Copy(KIniSectionThreeGprs); |
|
767 } |
|
768 else if( (aInfo.iShortName.Find(_L("01")) >=0) || |
|
769 (aInfo.iShortName.Find(_L("ANITE")) >=0) ) // Anite |
|
770 { |
|
771 DEBUG_PRINTF1(_L("Retrieving Anite GPRS settings")); |
|
772 section.Copy(KIniSectionVodafoneGprs); // Using vodafone GRPS settings, since Anite should accept any kind |
|
773 } |
|
774 else |
|
775 { |
|
776 DEBUG_PRINTF2(_L("Unable to retrieve network name \"%S\". Using defaults"),&(aInfo.iShortName)); |
|
777 section.Copy(KIniSectionDefaultGprs); |
|
778 } |
|
779 if(aNumber!=1) |
|
780 { |
|
781 TBuf<200> temp; |
|
782 temp.Copy(section); |
|
783 section.Format(_L("%S %d"),&temp,aNumber); |
|
784 } |
|
785 iTestStep.GetStringFromConfig(section, KIniApnName, aAccessPoint); |
|
786 iTestStep.GetStringFromConfig(section, KIniUsername, aUser); |
|
787 iTestStep.GetStringFromConfig(section, KIniPassword, aPassword); |
|
788 } |
|
789 |
|
790 void TPacketServiceTsyTestHelper::ActivatePrimaryPacketContextL(RMobilePhone& aMobilePhone, |
|
791 RPacketContext& aPacketContext, |
|
792 TInt aNum) |
|
793 /** |
|
794 * Activates a primary packet context with a GPRS config. |
|
795 * |
|
796 * @param aMobilePhone Reference to an RMobilePhone subsession. |
|
797 * @param aPacketService Reference to an RPacketService |
|
798 * subsession. |
|
799 * @param aPacketContext Reference to an RPacketContext |
|
800 * subsession representing the primary |
|
801 * packet context. |
|
802 * @param aNum The number of the context. |
|
803 */ |
|
804 { |
|
805 // Get network info from phone |
|
806 TExtEtelRequestStatus getNetworkStatus(aMobilePhone, EMobilePhoneGetCurrentNetwork); |
|
807 CleanupStack::PushL(getNetworkStatus); |
|
808 RMobilePhone::TMobilePhoneNetworkInfoV1 info; |
|
809 RMobilePhone::TMobilePhoneNetworkInfoV1Pckg infopckg(info); |
|
810 aMobilePhone.GetCurrentNetwork(getNetworkStatus, infopckg); |
|
811 |
|
812 ASSERT_EQUALS(iTestStep.WaitForRequestWithTimeOut(getNetworkStatus, ETimeLong), |
|
813 KErrNone, _L("RMobilePhone::GetCurrentNetwork timed out")); |
|
814 ASSERT_EQUALS(getNetworkStatus.Int(), |
|
815 KErrNone, _L("RMobilePhone::GetCurrentNetwork returned an error")); |
|
816 |
|
817 // Currenlty there are three context configs types: TContextConfigGPRS, TContextConfigCDMA, TContextConfigR99_R4 |
|
818 // A suitable config should be chosen accoriding to the baseband's capability. |
|
819 |
|
820 // Get the context config using network info |
|
821 // Using Gprs config for now... |
|
822 RPacketContext::TContextConfigGPRS config; |
|
823 TPtrC apn, user, pwd; |
|
824 GetGprsSettings(info, apn, user, pwd, aNum); |
|
825 config.iAccessPointName.Copy(apn); |
|
826 config.iProtocolConfigOption.iAuthInfo.iUsername.Copy(user); |
|
827 config.iProtocolConfigOption.iAuthInfo.iPassword.Copy(pwd); |
|
828 TPckg<RPacketContext::TContextConfigGPRS> configPk(config); |
|
829 |
|
830 // Set the context. |
|
831 TExtEtelRequestStatus setConfigStatus(aPacketContext, EPacketContextSetConfig); |
|
832 CleanupStack::PushL(setConfigStatus); |
|
833 aPacketContext.SetConfig(setConfigStatus, configPk); |
|
834 |
|
835 ASSERT_EQUALS(iTestStep.WaitForRequestWithTimeOut(setConfigStatus, ETimeLong), KErrNone, |
|
836 _L("RPacketContext::SetConfig timed out")); |
|
837 ASSERT_EQUALS(setConfigStatus.Int(), KErrNone, |
|
838 _L("RPacketContext::SetConfig returned with error status.")); |
|
839 |
|
840 // === Activate packet context === |
|
841 |
|
842 // Post notification for context's status change |
|
843 TExtEtelRequestStatus notifyContextStChStatus(aPacketContext, EPacketContextNotifyStatusChange); |
|
844 CleanupStack::PushL(notifyContextStChStatus); |
|
845 RPacketContext::TContextStatus packetContextStatus; |
|
846 aPacketContext.NotifyStatusChange(notifyContextStChStatus, packetContextStatus); |
|
847 |
|
848 // Activate packet context with RPacketContext::Activate |
|
849 TExtEtelRequestStatus contextActivateStatus(aPacketContext, EPacketContextActivate); |
|
850 CleanupStack::PushL(contextActivateStatus); |
|
851 aPacketContext.Activate(contextActivateStatus); |
|
852 |
|
853 ASSERT_EQUALS(iTestStep.WaitForRequestWithTimeOut(contextActivateStatus, ETimeLong), KErrNone, |
|
854 _L("RPacketContext::Activate timed out.")); |
|
855 ASSERT_EQUALS(contextActivateStatus.Int(), KErrNone, |
|
856 _L("RPacketContext::Activate returned with error status.")); |
|
857 |
|
858 // Check RPacketContext::NotifyStatusChange completes with EStatusActive |
|
859 RPacketContext::TContextStatus expectedPacketContextStatus = RPacketContext::EStatusActive; |
|
860 WaitForPacketContextNotifyStatusChange( |
|
861 aPacketContext, |
|
862 notifyContextStChStatus, |
|
863 packetContextStatus, |
|
864 expectedPacketContextStatus, |
|
865 KErrNone); |
|
866 ASSERT_EQUALS(packetContextStatus, RPacketContext::EStatusActive, _L("Packet Context's status expected to be EStatusActive but is not.")); |
|
867 |
|
868 CleanupStack::PopAndDestroy(4, &getNetworkStatus); |
|
869 } |
|
870 |