|
1 // Copyright (c) 2002-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 // CBoundCLPushStep_xyz derived implementations |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include "WapBoundCLPushSteps.h" |
|
24 #include "WapStackSuiteDefs.h" |
|
25 #include <simtsy.h> |
|
26 #include <wapmsgerr.h> |
|
27 #include <ecom/ecom.h> |
|
28 |
|
29 |
|
30 CBoundCLPushStepBase::CBoundCLPushStepBase() |
|
31 /** |
|
32 * Constructor |
|
33 */ |
|
34 { |
|
35 } |
|
36 |
|
37 CBoundCLPushStepBase::~CBoundCLPushStepBase() |
|
38 /** |
|
39 * Destructor |
|
40 */ |
|
41 { |
|
42 if(iImp) |
|
43 { |
|
44 UnloadInterface(); |
|
45 } |
|
46 } |
|
47 |
|
48 // Load CWapBoundCLPushService Interface |
|
49 CWapBoundCLPushService* CBoundCLPushStepBase::LoadInterface() |
|
50 { |
|
51 TInt trapValue; |
|
52 CWapBoundCLPushService* implementation = NULL; |
|
53 // UID {0x101FBB39} - SWS implementation |
|
54 TUid KInterfaceUid = {0x101FBB39}; |
|
55 INFO_PRINTF2(_L("Calling new NewL(0x%08X) method"), KInterfaceUid); |
|
56 TRAP(trapValue, implementation = CWapBoundCLPushService::NewL(KInterfaceUid)); |
|
57 if(!trapValue) |
|
58 { |
|
59 INFO_PRINTF2(_L("Interface is loaded: implementation.addr = 0x%08x"), implementation); |
|
60 return implementation; |
|
61 } |
|
62 else return NULL; |
|
63 } |
|
64 |
|
65 void CBoundCLPushStepBase::UnloadInterface() |
|
66 { |
|
67 INFO_PRINTF2(_L("Interface at implementation.addr = 0x%08x is deleted"), iImp); |
|
68 delete iImp; |
|
69 iImp = NULL; |
|
70 REComSession::FinalClose(); |
|
71 } |
|
72 |
|
73 CBoundCLPushStep_1::~CBoundCLPushStep_1() |
|
74 /** |
|
75 * Destructor |
|
76 */ |
|
77 { |
|
78 } |
|
79 |
|
80 CBoundCLPushStep_1::CBoundCLPushStep_1() |
|
81 /** |
|
82 * Constructor |
|
83 */ |
|
84 { |
|
85 } |
|
86 |
|
87 TVerdict CBoundCLPushStep_1::doTestStepL() |
|
88 /** |
|
89 * @return - TVerdict code |
|
90 * Override of base class pure virtual |
|
91 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
92 * not leave. That being the case, the current test result value will be EPass. |
|
93 */ |
|
94 { |
|
95 // |
|
96 // CWapBoundCLPushService |
|
97 // |
|
98 INFO_PRINTF1(_L("CreateImplementation - CWapBoundCLPushService")); |
|
99 INFO_PRINTF1(_L("Calling old NewL() method")); |
|
100 |
|
101 TInt trapValue; |
|
102 |
|
103 SetTestStepResult(EFail); |
|
104 TRAP(trapValue, iImp = CWapBoundCLPushService::NewL()); |
|
105 if(!trapValue) |
|
106 { |
|
107 INFO_PRINTF2(_L("Interface is loaded: implementation.addr = 0x%08x"), iImp); |
|
108 UnloadInterface(); |
|
109 iImp = LoadInterface(); |
|
110 if(iImp) |
|
111 { |
|
112 INFO_PRINTF1(_L("CreateImplementation - OK")); |
|
113 SetTestStepResult(EPass); |
|
114 UnloadInterface(); |
|
115 } |
|
116 } |
|
117 return TestStepResult(); |
|
118 } |
|
119 |
|
120 CBoundCLPushStep_2::CBoundCLPushStep_2() |
|
121 /** |
|
122 * Constructor |
|
123 */ |
|
124 { |
|
125 } |
|
126 |
|
127 CBoundCLPushStep_2::~CBoundCLPushStep_2() |
|
128 /** |
|
129 * Destructor |
|
130 */ |
|
131 { |
|
132 } |
|
133 |
|
134 TVerdict CBoundCLPushStep_2::doTestStepL() |
|
135 /** |
|
136 * Test Connect methoths |
|
137 * @return - TVerdict code |
|
138 * |
|
139 */ |
|
140 { |
|
141 INFO_PRINTF1(_L("BOUNDCL-PUSH: Testing Connect")); |
|
142 if(TestStepResult() == EPass ) |
|
143 { |
|
144 SetTestStepResult(EFail); |
|
145 iImp = LoadInterface(); |
|
146 if(iImp) |
|
147 { |
|
148 TInt bearer, port; |
|
149 TInt error = KErrNone; |
|
150 TBool secure= EFalse; |
|
151 TBool reconnect= EFalse; |
|
152 SetLastError(KErrNone); |
|
153 TBool delay = EFalse; |
|
154 |
|
155 if(GetIntFromConfig(ConfigSection(), KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer; |
|
156 if(GetIntFromConfig(ConfigSection(), KWapLocalPort, port)) iLocalPort = (Wap::TPort)port; |
|
157 if(GetIntFromConfig(ConfigSection(), KWapExError, error)) SetExpectedError(error); |
|
158 if(GetBoolFromConfig(ConfigSection(), KWapSecure, secure)) iSecure = secure; |
|
159 if(GetBoolFromConfig(ConfigSection(),_L("Reconnect"), reconnect)) iReconnect = reconnect; |
|
160 if(GetBoolFromConfig(ConfigSection(),KWapDelayPortClosure, delay)) iDelayPortClosure = delay; |
|
161 |
|
162 if(UseSimTsy()) |
|
163 { |
|
164 GetIntFromConfig(ConfigSection(), KWapSIMTSYState, iSimTsyState); |
|
165 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, iSimTsyState)); |
|
166 } |
|
167 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
168 |
|
169 SetState(EConnect); |
|
170 iControl->ReStart(); |
|
171 ShowConnectionInfo(); |
|
172 |
|
173 StartScheduler(); |
|
174 UnloadInterface(); |
|
175 } |
|
176 } |
|
177 return TestStepResult(); |
|
178 } |
|
179 |
|
180 TInt CBoundCLPushStep_2::CallStateMachine() |
|
181 { |
|
182 TInt err = KErrNone; |
|
183 INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State()); |
|
184 switch(iState) |
|
185 { |
|
186 case EConnect: |
|
187 INFO_PRINTF1(_L("EConnect")); |
|
188 err = iImp->Connect(iBearer, (Wap::TPort)iLocalPort, iSecure); |
|
189 INFO_PRINTF2(_L("Connection completed with code = %d"), err); |
|
190 if( err == KErrNone) |
|
191 { |
|
192 if(iReconnect) |
|
193 { |
|
194 INFO_PRINTF1(_L("Second connect")); |
|
195 iControl->ReStart(); |
|
196 break; |
|
197 } |
|
198 } |
|
199 SetState(EFinish); |
|
200 SetLastError(err); |
|
201 iControl->ReStart(); |
|
202 break; |
|
203 |
|
204 case EFinish: |
|
205 // it's necessary to delay port closure, let the other concurrent test step |
|
206 // can fail opening the same port with expected error EPortAlreadyBound (-5498) |
|
207 if (iDelayPortClosure) |
|
208 User::After(5000000); |
|
209 |
|
210 INFO_PRINTF1(_L("EFinish")); |
|
211 if(GetLastError() == GetExpectedError()) |
|
212 SetTestStepResult(EPass); |
|
213 else |
|
214 SetTestStepResult(EFail); |
|
215 SetState(EIdle); |
|
216 StopScheduler(); |
|
217 break; |
|
218 |
|
219 case EIdle: |
|
220 default: |
|
221 INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State()); |
|
222 SetTestStepResult(EFail); |
|
223 StopScheduler(); |
|
224 break; |
|
225 } |
|
226 return (0); |
|
227 } |
|
228 |
|
229 CBoundCLPushStep_3::CBoundCLPushStep_3() |
|
230 /** |
|
231 * Constructor |
|
232 */ |
|
233 { |
|
234 } |
|
235 |
|
236 CBoundCLPushStep_3::~CBoundCLPushStep_3() |
|
237 /** |
|
238 * Destructor |
|
239 */ |
|
240 { |
|
241 } |
|
242 |
|
243 TVerdict CBoundCLPushStep_3::doTestStepL() |
|
244 /* |
|
245 * Test the BoundCLPush APIs in unconnected state. |
|
246 */ |
|
247 { |
|
248 INFO_PRINTF1(_L("BoundCLPush. Requests without connection")); |
|
249 // check preamble result |
|
250 TVerdict verdict = TestStepResult(); |
|
251 if (verdict==EPass) |
|
252 { |
|
253 TInt err, ret; |
|
254 iImp = LoadInterface(); |
|
255 if (!iImp) |
|
256 { |
|
257 ERR_PRINTF1(_L("Unable to load BoundCLPush Interface")); |
|
258 verdict = EFail; |
|
259 } |
|
260 else |
|
261 { |
|
262 GetIntFromConfig(ConfigSection(),KWapExError,(TInt&)iExError); |
|
263 ShowConnectionInfo(); |
|
264 TRequestStatus reqStatus; |
|
265 iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, reqStatus); |
|
266 TRAP(ret, TEST_CHECKL(reqStatus.Int(), iExError, _L("AwaitPush Fails not as expected"))) |
|
267 if (ret) |
|
268 verdict = EFail; |
|
269 else |
|
270 { |
|
271 Wap::TPort port; |
|
272 err=iImp->GetLocalPort(port); |
|
273 TRAP(ret, TEST_CHECKL(err, iExError, _L("GetLocalPort Fails not as expected"))) |
|
274 if (ret) |
|
275 verdict = EFail; |
|
276 else |
|
277 { |
|
278 HBufC8* localHost; |
|
279 err=iImp->GetLocalAddress(localHost); |
|
280 TRAP(ret, TEST_CHECKL(err, iExError, _L("GetLocalAddress Fails not as expected"))) |
|
281 if (ret) |
|
282 verdict = EFail; |
|
283 else |
|
284 { |
|
285 err=iImp->GetBearer(iBearer); |
|
286 TRAP(ret, TEST_CHECKL(err, iExError, _L("GetBearer Fails not as expected"))) |
|
287 if (ret) |
|
288 verdict = EFail; |
|
289 else |
|
290 { |
|
291 HBufC8* host; |
|
292 err=iImp->GetServerAddress(host); |
|
293 TRAP(ret, TEST_CHECKL(err, iExError, _L("GetServerAddress Fails not as expected"))) |
|
294 if (ret) |
|
295 verdict = EFail; |
|
296 } |
|
297 } |
|
298 } |
|
299 } |
|
300 UnloadInterface(); |
|
301 } |
|
302 } |
|
303 if (verdict==EPass) |
|
304 { |
|
305 INFO_PRINTF1(_L("BoundCLPush. Requests Fail as expected")); |
|
306 } |
|
307 SetTestStepResult(verdict); |
|
308 return TestStepResult(); |
|
309 } |
|
310 |
|
311 TInt CBoundCLPushStep_3::CallStateMachine() |
|
312 { |
|
313 return (0); |
|
314 } |
|
315 |
|
316 |
|
317 CBoundCLPushStep_4::CBoundCLPushStep_4() |
|
318 /** |
|
319 * Constructor |
|
320 */ |
|
321 { |
|
322 } |
|
323 |
|
324 CBoundCLPushStep_4::~CBoundCLPushStep_4() |
|
325 /** |
|
326 * Destructor |
|
327 */ |
|
328 { |
|
329 } |
|
330 |
|
331 TVerdict CBoundCLPushStep_4::doTestStepL() |
|
332 /** |
|
333 * Test Connect methoths |
|
334 * @return - TVerdict code |
|
335 * |
|
336 */ |
|
337 { |
|
338 INFO_PRINTF1(_L("BOUND-CLPUSH: Connect-AwaitPush")); |
|
339 if(TestStepResult() == EPass ) |
|
340 { |
|
341 SetTestStepResult(EFail); |
|
342 iImp = LoadInterface(); |
|
343 if(iImp) |
|
344 { |
|
345 SetLastError(KErrNone); |
|
346 |
|
347 TInt bearer, port; |
|
348 TInt error = KErrNone; |
|
349 |
|
350 if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) |
|
351 { |
|
352 iBearer = static_cast<Wap::TBearer>(bearer); |
|
353 } |
|
354 if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) |
|
355 { |
|
356 iLocalPort = static_cast<Wap::TPort>(port); |
|
357 } |
|
358 if(GetIntFromConfig(ConfigSection(),KWapExError, error)) |
|
359 { |
|
360 SetExpectedError(error); |
|
361 } |
|
362 GetBoolFromConfig(ConfigSection(), KMiddleCancel, iMiddleCancel); |
|
363 GetBoolFromConfig(ConfigSection(), KMultiReadCancel, iMultiReadCancel); |
|
364 TInt headerLength, bufLength; |
|
365 if(GetIntFromConfig(ConfigSection(),KWapWSPRecvHeaderLength, headerLength)) |
|
366 { |
|
367 iHeaderRecvBufLength=static_cast<TUint16>(headerLength); |
|
368 } |
|
369 if(GetIntFromConfig(ConfigSection(),KWapWSPRecvBodyLength, bufLength)) |
|
370 { |
|
371 iBodyRecvBufLength=static_cast<TUint16>(bufLength); |
|
372 } |
|
373 iRecvHeaders = HBufC8::NewL(iHeaderRecvBufLength); |
|
374 iRecvBody = HBufC8::NewL(iBodyRecvBufLength); |
|
375 |
|
376 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
377 |
|
378 |
|
379 if(UseSimTsy()) |
|
380 { |
|
381 GetIntFromConfig(ConfigSection(),KWapSIMTSYState, iSimTsyState); |
|
382 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, iSimTsyState)); |
|
383 } |
|
384 |
|
385 |
|
386 SetState(EConnect); |
|
387 iControl->ReStart(); |
|
388 ShowConnectionInfo(); |
|
389 |
|
390 StartScheduler(); |
|
391 delete iRecvBody; |
|
392 iRecvBody=NULL; |
|
393 delete iRecvHeaders; |
|
394 iRecvHeaders=NULL; |
|
395 UnloadInterface(); |
|
396 } |
|
397 } |
|
398 return TestStepResult(); |
|
399 } |
|
400 |
|
401 TInt CBoundCLPushStep_4::CallStateMachine() |
|
402 { |
|
403 TVerdict verdict = EFail; |
|
404 TInt err = KErrNone; |
|
405 TInt activate = 0; |
|
406 |
|
407 INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State()); |
|
408 switch(iState) |
|
409 { |
|
410 case EConnect: |
|
411 INFO_PRINTF1(_L("EConnect")); |
|
412 err = iImp->Connect(iBearer, iLocalPort, EFalse); |
|
413 INFO_PRINTF2(_L("Connection completed with code = %d"), err); |
|
414 if( err == KErrNone) |
|
415 { |
|
416 if(iBearer != Wap::EIP) |
|
417 { |
|
418 TRAP(err, WaitForInitializeL()); |
|
419 } |
|
420 iRecvHeadersBuf.Set(iRecvHeaders->Des()); |
|
421 iRecvBodyBuf.Set(iRecvBody->Des()); |
|
422 iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, *iStatus); |
|
423 INFO_PRINTF1(_L("Start AwaitingPush.....")); |
|
424 activate = 1; |
|
425 if (!iMiddleCancel) |
|
426 { |
|
427 SetState(EAwaitPush); |
|
428 } |
|
429 else |
|
430 { |
|
431 INFO_PRINTF1(_L("Cancel AwaitPush")); |
|
432 iImp->CancelAwaitPush(); |
|
433 SetState(EFinish); |
|
434 } |
|
435 } |
|
436 else |
|
437 { |
|
438 SetState(EFinish); |
|
439 iControl->ReStart(); |
|
440 } |
|
441 SetLastError(err); |
|
442 break; |
|
443 |
|
444 case EAwaitPush: |
|
445 |
|
446 INFO_PRINTF1(_L("EAwaitPush")); |
|
447 if(iStatus->Int() != KErrNone && iStatus->Int()!=Wap::EMoreData) |
|
448 // AwaitPush failed |
|
449 { |
|
450 INFO_PRINTF1(_L("AwaitPush failed")); |
|
451 SetLastError(iStatus->Int()); |
|
452 SetState(EFinish); |
|
453 iControl->ReStart(); |
|
454 } |
|
455 else |
|
456 { |
|
457 iMaxWspHeaderRecvBuffer.Append(iRecvHeadersBuf); |
|
458 iMaxWspDataRecvBuffer.Append(iRecvBodyBuf); |
|
459 if (iStatus->Int()==Wap::EMoreData) |
|
460 { |
|
461 iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, *iStatus); |
|
462 activate = 1; |
|
463 if (!iMultiReadCancel) |
|
464 { |
|
465 SetState(EAwaitPush); |
|
466 } |
|
467 else |
|
468 { |
|
469 INFO_PRINTF1(_L("Cancel Receive in EMutipleReceive state")); |
|
470 iImp->CancelAwaitPush(); |
|
471 SetState(EFinish); |
|
472 } |
|
473 } |
|
474 else |
|
475 { |
|
476 SetLastError(iStatus->Int()); |
|
477 iControl->ReStart(); |
|
478 SetState(EFinish); |
|
479 } |
|
480 } |
|
481 break; |
|
482 |
|
483 case EFinish: |
|
484 |
|
485 INFO_PRINTF1(_L("EFinish")); |
|
486 if(iStatus->Int() != KErrNone) |
|
487 { |
|
488 SetLastError(iStatus->Int()); |
|
489 } |
|
490 verdict = (GetLastError() == GetExpectedError())?EPass:EFail; |
|
491 if (verdict==EPass && !iMiddleCancel && !iMultiReadCancel) |
|
492 { |
|
493 iImp->CancelAwaitPush(); |
|
494 INFO_PRINTF1(_L("Headers:")); |
|
495 DumpBuf(iMaxWspHeaderRecvBuffer); |
|
496 INFO_PRINTF1(_L("Body")); |
|
497 DumpBuf(iMaxWspDataRecvBuffer); |
|
498 if (verdict==EPass) |
|
499 { |
|
500 HBufC8* buf; |
|
501 iImp->GetServerAddress(buf); |
|
502 verdict = (buf->Match(iRemoteHost)!=KErrNotFound)?EPass:EFail; |
|
503 delete buf; |
|
504 } |
|
505 if (verdict==EPass) |
|
506 { |
|
507 Wap::TPort port; |
|
508 iImp->GetLocalPort(port); |
|
509 verdict = (port == iLocalPort)?EPass:EFail; |
|
510 } |
|
511 if (verdict==EPass) |
|
512 { |
|
513 Wap::TBearer bearer; |
|
514 iImp->GetBearer(bearer); |
|
515 verdict = (bearer == iBearer)?EPass:EFail; |
|
516 } |
|
517 if (verdict==EPass) |
|
518 { |
|
519 //This test can not perform. |
|
520 HBufC8* buf; |
|
521 iImp->GetLocalAddress(buf); |
|
522 delete buf; |
|
523 } |
|
524 } |
|
525 SetTestStepResult(verdict); |
|
526 SetState(EIdle); |
|
527 StopScheduler(); |
|
528 break; |
|
529 |
|
530 case EIdle: |
|
531 default: |
|
532 INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State()); |
|
533 SetTestStepResult(verdict); |
|
534 StopScheduler(); |
|
535 |
|
536 break; |
|
537 } |
|
538 return (activate); |
|
539 } |
|
540 |
|
541 CBoundCLPushStep_5::CBoundCLPushStep_5() |
|
542 /** |
|
543 * Constructor |
|
544 */ |
|
545 { |
|
546 } |
|
547 |
|
548 CBoundCLPushStep_5::~CBoundCLPushStep_5() |
|
549 /** |
|
550 * Destructor |
|
551 */ |
|
552 { |
|
553 } |
|
554 |
|
555 TVerdict CBoundCLPushStep_5::doTestStepL() |
|
556 /** |
|
557 * Test Cancel |
|
558 * @return - TVerdict code |
|
559 * |
|
560 */ |
|
561 { |
|
562 INFO_PRINTF1(_L("BOUNDCL-PUSH: Testing Cancel")); |
|
563 if(TestStepResult() == EPass ) |
|
564 { |
|
565 SetTestStepResult(EFail); |
|
566 iImp = LoadInterface(); |
|
567 if(iImp) |
|
568 { |
|
569 TInt bearer, port; |
|
570 TInt error = KErrNone; |
|
571 TBool secure= EFalse; |
|
572 TBool reconnect= EFalse; |
|
573 SetLastError(KErrNone); |
|
574 |
|
575 if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer; |
|
576 if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) iLocalPort = (Wap::TPort)port; |
|
577 if(GetIntFromConfig(ConfigSection(), KWapExError, error)) SetExpectedError(error); |
|
578 if(GetBoolFromConfig(ConfigSection(), KWapSecure, secure)) iSecure = secure; |
|
579 if(GetBoolFromConfig(ConfigSection(),_L("Reconnect"), reconnect)) iReconnect = reconnect; |
|
580 |
|
581 ShowConnectionInfo(); |
|
582 error = iImp->Connect(iBearer, iLocalPort, iSecure); |
|
583 INFO_PRINTF2(_L("Connection completed with code = %d"), error); |
|
584 if( error == KErrNone) |
|
585 { |
|
586 TBuf8<100> header, body; |
|
587 TPckgBuf<TUint8> pushIdPckg; |
|
588 TRequestStatus reqStatus; |
|
589 iImp->AwaitPush(header, body, pushIdPckg, reqStatus); |
|
590 SetState(EAwaitPush); |
|
591 StartScheduler(); |
|
592 iControl->ReStart(); |
|
593 if(reqStatus==KErrCancel) |
|
594 { |
|
595 SetTestStepResult(EPass); |
|
596 } |
|
597 } |
|
598 |
|
599 } |
|
600 } |
|
601 return TestStepResult(); |
|
602 } |
|
603 |
|
604 TInt CBoundCLPushStep_5::CallStateMachine() |
|
605 { |
|
606 INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State()); |
|
607 switch(iState) |
|
608 { |
|
609 case EAwaitPush: |
|
610 INFO_PRINTF1(_L("EAwaitPush")); |
|
611 iImp->CancelAwaitPush(); |
|
612 SetState(EFinish); |
|
613 iControl->ReStart(); |
|
614 break; |
|
615 case EFinish: |
|
616 INFO_PRINTF1(_L("EFinish")); |
|
617 SetState(EIdle); |
|
618 StopScheduler(); |
|
619 break; |
|
620 case EIdle: |
|
621 default: |
|
622 INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State()); |
|
623 SetTestStepResult(EFail); |
|
624 StopScheduler(); |
|
625 break; |
|
626 } |
|
627 return (0); |
|
628 } |
|
629 |
|
630 |
|
631 CBoundCLPushStep_6::CBoundCLPushStep_6() |
|
632 { |
|
633 } |
|
634 CBoundCLPushStep_6::~CBoundCLPushStep_6() |
|
635 { |
|
636 } |
|
637 TVerdict CBoundCLPushStep_6::doTestStepL() |
|
638 { |
|
639 return TestStepResult(); |
|
640 } |
|
641 TInt CBoundCLPushStep_6::CallStateMachine() |
|
642 { |
|
643 return (0); |
|
644 } |
|
645 |
|
646 CBoundCLPushStep_7::CBoundCLPushStep_7() |
|
647 { |
|
648 } |
|
649 CBoundCLPushStep_7::~CBoundCLPushStep_7() |
|
650 { |
|
651 } |
|
652 TVerdict CBoundCLPushStep_7::doTestStepL() |
|
653 { |
|
654 INFO_PRINTF1(_L("BOUND-CLPUSH: Connect-AwaitPush-AwaitPush")); |
|
655 if(TestStepResult() == EPass ) |
|
656 { |
|
657 SetTestStepResult(EFail); |
|
658 iImp = LoadInterface(); |
|
659 if(iImp) |
|
660 { |
|
661 SetLastError(KErrNone); |
|
662 |
|
663 TInt bearer, port; |
|
664 TInt error = KErrNone; |
|
665 |
|
666 if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) |
|
667 { |
|
668 iBearer = static_cast<Wap::TBearer>(bearer); |
|
669 } |
|
670 if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) |
|
671 { |
|
672 iLocalPort = static_cast<Wap::TPort>(port); |
|
673 } |
|
674 if(GetIntFromConfig(ConfigSection(),KWapExError, error)) |
|
675 { |
|
676 SetExpectedError(error); |
|
677 } |
|
678 TInt headerLength, bufLength; |
|
679 if(GetIntFromConfig(ConfigSection(),KWapWSPRecvHeaderLength, headerLength)) |
|
680 { |
|
681 iHeaderRecvBufLength=static_cast<TUint16>(headerLength); |
|
682 } |
|
683 if(GetIntFromConfig(ConfigSection(),KWapWSPRecvBodyLength, bufLength)) |
|
684 { |
|
685 iBodyRecvBufLength=static_cast<TUint16>(bufLength); |
|
686 } |
|
687 iRecvHeaders = HBufC8::NewL(iHeaderRecvBufLength); |
|
688 iRecvBody = HBufC8::NewL(iBodyRecvBufLength); |
|
689 SetState(EConnect); |
|
690 iControl->ReStart(); |
|
691 ShowConnectionInfo(); |
|
692 |
|
693 StartScheduler(); |
|
694 delete iRecvBody; |
|
695 iRecvBody=NULL; |
|
696 delete iRecvHeaders; |
|
697 iRecvHeaders=NULL; |
|
698 UnloadInterface(); |
|
699 } |
|
700 } |
|
701 return TestStepResult(); |
|
702 } |
|
703 TInt CBoundCLPushStep_7::CallStateMachine() |
|
704 { |
|
705 TVerdict verdict = EFail; |
|
706 TInt err = KErrNone; |
|
707 TInt activate = 0; |
|
708 |
|
709 INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State()); |
|
710 switch(iState) |
|
711 { |
|
712 case EConnect: |
|
713 |
|
714 INFO_PRINTF1(_L("EConnect")); |
|
715 err = iImp->Connect(iBearer, iLocalPort, EFalse); |
|
716 INFO_PRINTF2(_L("Connection completed with code = %d"), err); |
|
717 if( err == KErrNone) |
|
718 { |
|
719 iRecvHeadersBuf.Set(iRecvHeaders->Des()); |
|
720 iRecvBodyBuf.Set(iRecvBody->Des()); |
|
721 TRequestStatus reqStatus; |
|
722 iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, reqStatus); |
|
723 iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, *iStatus); |
|
724 INFO_PRINTF1(_L("AwaitPush")); |
|
725 activate = 1; |
|
726 } |
|
727 else |
|
728 { |
|
729 iControl->ReStart(); |
|
730 } |
|
731 SetLastError(err); |
|
732 SetState(EFinish); |
|
733 break; |
|
734 |
|
735 case EFinish: |
|
736 |
|
737 INFO_PRINTF1(_L("EFinish")); |
|
738 iImp->CancelAwaitPush(); |
|
739 if(iStatus->Int() != KErrNone) |
|
740 { |
|
741 SetLastError(iStatus->Int()); |
|
742 } |
|
743 verdict = (GetLastError() == GetExpectedError())?EPass:EFail; |
|
744 SetTestStepResult(verdict); |
|
745 SetState(EIdle); |
|
746 StopScheduler(); |
|
747 break; |
|
748 |
|
749 case EIdle: |
|
750 default: |
|
751 INFO_PRINTF2(_L("Error: EIdle or unknown state [%d]"), State()); |
|
752 SetTestStepResult(verdict); |
|
753 StopScheduler(); |
|
754 break; |
|
755 } |
|
756 return (activate); |
|
757 } |
|
758 |
|
759 CBoundCLPushStep_8::CBoundCLPushStep_8() |
|
760 { |
|
761 } |
|
762 CBoundCLPushStep_8::~CBoundCLPushStep_8() |
|
763 { |
|
764 } |
|
765 TVerdict CBoundCLPushStep_8::doTestStepL() |
|
766 /** |
|
767 * @return - TVerdict code |
|
768 * Wrong parameter values for Bound CL Push API: |
|
769 * - Wrong TUid on construction |
|
770 * - Connect to wrong bearer (already implemented in test 2) |
|
771 */ |
|
772 { |
|
773 INFO_PRINTF1(_L("CreateImplementation with wrong Uid- CWapBoundCLPushService")); |
|
774 if(TestStepResult() == EPass ) |
|
775 { |
|
776 TInt error; |
|
777 if(GetIntFromConfig(ConfigSection(),KWapExError2, error)) |
|
778 { |
|
779 iExError2=error; |
|
780 } |
|
781 TInt trapValue; |
|
782 |
|
783 TUid invalidInterfaceUid = {0x00000000}; |
|
784 |
|
785 INFO_PRINTF2(_L("Calling new NewL(0x%08X) method"), invalidInterfaceUid); |
|
786 TRAP(trapValue, iImp = CWapBoundCLPushService::NewL(invalidInterfaceUid)); |
|
787 TVerdict verdict = (trapValue == iExError2)?EPass:EFail; |
|
788 if (verdict==EPass) |
|
789 { |
|
790 INFO_PRINTF2(_L("CreateImplementation with wrong Uid- Failed as expected with error %d"),trapValue); |
|
791 } |
|
792 SetTestStepResult(verdict); |
|
793 } |
|
794 return TestStepResult(); |
|
795 } |
|
796 TInt CBoundCLPushStep_8::CallStateMachine() |
|
797 { |
|
798 return (0); |
|
799 } |
|
800 |
|
801 CBoundCLPushStep_9::CBoundCLPushStep_9() |
|
802 { |
|
803 } |
|
804 CBoundCLPushStep_9::~CBoundCLPushStep_9() |
|
805 { |
|
806 } |
|
807 TVerdict CBoundCLPushStep_9::doTestStepL() |
|
808 { |
|
809 INFO_PRINTF1(_L("BOUND-CLPUSH: Sending Push Message")); |
|
810 if(TestStepResult() == EPass ) |
|
811 { |
|
812 User::After(20000000); |
|
813 SetTestStepResult(EFail); |
|
814 SetLastError(KErrNone); |
|
815 TInt error = KErrNone; |
|
816 /** |
|
817 Getting information from config file |
|
818 Local port |
|
819 Remote port |
|
820 Local address |
|
821 Remote address |
|
822 */ |
|
823 GetIntFromConfig(ConfigSection(),KLocalPort, iLclPort); |
|
824 GetIntFromConfig(ConfigSection(),KRemotePort, iRmtPort); |
|
825 TPtrC temp; |
|
826 if(GetStringFromConfig(ConfigSection(),KWapLocalHost, temp)) |
|
827 { |
|
828 error = iLocalAddr.Input(temp); |
|
829 if(error) |
|
830 { |
|
831 User::Leave(error); |
|
832 } |
|
833 } |
|
834 if(GetStringFromConfig(ConfigSection(),KWapRemoteHost, temp )) |
|
835 { |
|
836 error = iRemoteAddr.Input(temp); |
|
837 if(error) |
|
838 { |
|
839 User::Leave(error); |
|
840 } |
|
841 } |
|
842 // error = GetStringFromConfig(ConfigSection(),KWapData, temp); |
|
843 |
|
844 RFs fS; |
|
845 RFile file; |
|
846 User::LeaveIfError(fS.Connect()); |
|
847 _LIT(KPduFilename,"z:\\testdata\\configs\\pushpdu.bin"); |
|
848 User::LeaveIfError(file.Open(fS, KPduFilename , EFileStream | EFileRead)); |
|
849 /* Read PDU from the file */ |
|
850 |
|
851 iSendBuffPtr = HBufC8::NewL(1024); |
|
852 TPtr8 tmpbuf = iSendBuffPtr->Des(); |
|
853 User::LeaveIfError(file.Read(tmpbuf)); |
|
854 |
|
855 file.Close(); |
|
856 fS.Close(); |
|
857 /** |
|
858 Settings |
|
859 */ |
|
860 iLocalAddr.SetPort(iLclPort); |
|
861 iRemoteAddr.SetPort(iRmtPort); |
|
862 // iSendBuffPtr = HBufC8::NewL(temp.Length()); |
|
863 // TPtr8 tmp = iSendBuffPtr->Des(); |
|
864 // tmp.Copy(temp); |
|
865 |
|
866 /** |
|
867 socket server |
|
868 */ |
|
869 RSocketServ socketServer; |
|
870 User::LeaveIfError(socketServer.Connect()); |
|
871 CleanupClosePushL(socketServer); |
|
872 RSocket sock; |
|
873 User::LeaveIfError(sock.Open(socketServer, KAfInet, KSockDatagram, KProtocolInetUdp)); |
|
874 CleanupClosePushL(sock); |
|
875 TRequestStatus status; |
|
876 sock.SendTo(iSendBuffPtr->Des(),iRemoteAddr , 0, status); |
|
877 User::WaitForRequest(status); |
|
878 INFO_PRINTF2(_L("Send Push Message - status = %d"), status.Int()); |
|
879 User::LeaveIfError(status.Int()); |
|
880 sock.Close(); |
|
881 socketServer.Close(); |
|
882 CleanupStack::PopAndDestroy(&sock); |
|
883 CleanupStack::Pop(&socketServer); |
|
884 TVerdict verdict = (status.Int() == KErrNone)?EPass:EFail; |
|
885 SetTestStepResult(verdict); |
|
886 } |
|
887 return TestStepResult(); |
|
888 } |
|
889 TInt CBoundCLPushStep_9::CallStateMachine() |
|
890 { |
|
891 return (0); |
|
892 } |
|
893 |
|
894 |
|
895 |
|
896 |