|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "WapFullySpecWSPSteps.h" |
|
22 #include "WapStackSuiteDefs.h" |
|
23 #include <simtsy.h> |
|
24 #include <ecom/ecom.h> |
|
25 |
|
26 CFullySpecWSPStepBase::CFullySpecWSPStepBase() |
|
27 /** |
|
28 * Constructor |
|
29 */ |
|
30 { |
|
31 } |
|
32 |
|
33 CFullySpecWSPStepBase::~CFullySpecWSPStepBase() |
|
34 /** |
|
35 * Destructor |
|
36 */ |
|
37 { |
|
38 if(iImp) |
|
39 { |
|
40 UnloadInterface(); |
|
41 } |
|
42 } |
|
43 |
|
44 // Load CWapBoundDatagramService Interface |
|
45 CWapFullySpecCLWSPService* CFullySpecWSPStepBase::LoadInterface() |
|
46 { |
|
47 TInt trapValue; |
|
48 CWapFullySpecCLWSPService* implementation = NULL; |
|
49 // UID {0x101FBB3E} - SWS implementation |
|
50 TUid KInterfaceUid = {0x101FBB3E}; |
|
51 INFO_PRINTF2(_L("Calling new NewL(0x%08X) method"), KInterfaceUid); |
|
52 TRAP(trapValue, implementation = CWapFullySpecCLWSPService::NewL(KInterfaceUid)); |
|
53 if(!trapValue) |
|
54 { |
|
55 INFO_PRINTF2(_L("Interface is loaded: implementation.addr = 0x%08x"), implementation); |
|
56 return implementation; |
|
57 } |
|
58 else return NULL; |
|
59 } |
|
60 |
|
61 void CFullySpecWSPStepBase::UnloadInterface() |
|
62 { |
|
63 INFO_PRINTF2(_L("Interface at implementation.addr = 0x%08x is deleted"), iImp); |
|
64 delete iImp; |
|
65 iImp = NULL; |
|
66 REComSession::FinalClose(); |
|
67 } |
|
68 |
|
69 CFullySpecWSPStep_1::~CFullySpecWSPStep_1() |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 { |
|
74 } |
|
75 |
|
76 CFullySpecWSPStep_1::CFullySpecWSPStep_1() |
|
77 /** |
|
78 * Constructor |
|
79 */ |
|
80 { |
|
81 } |
|
82 |
|
83 TVerdict CFullySpecWSPStep_1::doTestStepL() |
|
84 /** |
|
85 * @return - TVerdict code |
|
86 * Override of base class pure virtual |
|
87 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
88 * not leave. That being the case, the current test result value will be EPass. |
|
89 */ |
|
90 { |
|
91 // |
|
92 // CWapFullySpecCLWSPService |
|
93 // |
|
94 INFO_PRINTF1(_L("CreateImplementation - CWapFullySpecCLWSPService")); |
|
95 INFO_PRINTF1(_L("Calling old NewL() method")); |
|
96 |
|
97 TInt trapValue; |
|
98 |
|
99 SetTestStepResult(EFail); |
|
100 TRAP(trapValue, iImp = CWapFullySpecCLWSPService::NewL()); |
|
101 if(!trapValue) |
|
102 { |
|
103 // interface is loaded |
|
104 INFO_PRINTF2(_L("Interface is loaded: implementation.addr = 0x%08x"), iImp); |
|
105 UnloadInterface(); |
|
106 iImp = LoadInterface(); |
|
107 if(iImp) |
|
108 { |
|
109 INFO_PRINTF1(_L("CreateImplementation - OK")); |
|
110 SetTestStepResult(EPass); |
|
111 UnloadInterface(); |
|
112 } |
|
113 } |
|
114 return TestStepResult(); |
|
115 } |
|
116 |
|
117 CFullySpecWSPStep_2::CFullySpecWSPStep_2() |
|
118 /** |
|
119 * Constructor |
|
120 */ |
|
121 { |
|
122 } |
|
123 |
|
124 CFullySpecWSPStep_2::~CFullySpecWSPStep_2() |
|
125 /** |
|
126 * Destructor |
|
127 */ |
|
128 { |
|
129 } |
|
130 |
|
131 TVerdict CFullySpecWSPStep_2::doTestStepL() |
|
132 /** |
|
133 * Test Connect methoths |
|
134 * @return - TVerdict code |
|
135 * |
|
136 */ |
|
137 { |
|
138 INFO_PRINTF1(_L("FULLYSPEC-WSP: Testing Connect")); |
|
139 if(TestStepResult() == EPass ) |
|
140 { |
|
141 SetTestStepResult(EFail); |
|
142 iImp = LoadInterface(); |
|
143 if(iImp) |
|
144 { |
|
145 TInt bearer = 0; |
|
146 TInt error = KErrNone; |
|
147 TBool secure= EFalse; |
|
148 TBool reconnect= EFalse; |
|
149 SetLastError(KErrNone); |
|
150 |
|
151 if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer; |
|
152 if(GetIntFromConfig(ConfigSection(), KWapExError, error)) SetExpectedError(error); |
|
153 if(GetBoolFromConfig(ConfigSection(), KWapSecure, secure)) iSecure = secure; |
|
154 if(GetBoolFromConfig(ConfigSection(),_L("Reconnect"), reconnect)) iReconnect = reconnect; |
|
155 |
|
156 if(UseSimTsy()) |
|
157 { |
|
158 GetIntFromConfig(ConfigSection(), KWapSIMTSYState, iSimTsyState); |
|
159 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, iSimTsyState)); |
|
160 } |
|
161 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
162 |
|
163 SetState(EConnect); |
|
164 iControl->ReStart(); |
|
165 ShowConnectionInfo(); |
|
166 // Start state machine |
|
167 StartScheduler(); |
|
168 UnloadInterface(); |
|
169 } |
|
170 } |
|
171 return TestStepResult(); |
|
172 } |
|
173 |
|
174 TInt CFullySpecWSPStep_2::CallStateMachine() |
|
175 { |
|
176 TInt err = KErrNone; |
|
177 INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State()); |
|
178 switch(State()) |
|
179 { |
|
180 case EConnect: |
|
181 INFO_PRINTF1(_L("EConnect")); |
|
182 err = iImp->Connect(iRemoteHost, iRemotePort, iBearer, iSecure); |
|
183 INFO_PRINTF2(_L("Connection completed with code = %d"), err); |
|
184 if( err == KErrNone) |
|
185 { |
|
186 if(iReconnect) |
|
187 { |
|
188 INFO_PRINTF1(_L("Reconnection")); |
|
189 iControl->ReStart(); |
|
190 break; |
|
191 } |
|
192 } |
|
193 SetState(EFinish); |
|
194 SetLastError(err); |
|
195 iControl->ReStart(); |
|
196 break; |
|
197 |
|
198 case EFinish: |
|
199 INFO_PRINTF1(_L("EFinish")); |
|
200 if(GetLastError() == GetExpectedError()) |
|
201 { |
|
202 SetTestStepResult(EPass); |
|
203 } |
|
204 else |
|
205 { |
|
206 SetTestStepResult(EFail); |
|
207 } |
|
208 SetState(EIdle); |
|
209 StopScheduler(); |
|
210 break; |
|
211 |
|
212 case EIdle: |
|
213 default: |
|
214 INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State()); |
|
215 SetTestStepResult(EFail); |
|
216 StopScheduler(); |
|
217 break; |
|
218 } |
|
219 return (0); |
|
220 } |
|
221 |
|
222 CFullySpecWSPStep_3::CFullySpecWSPStep_3() |
|
223 /** |
|
224 * Constructor |
|
225 */ |
|
226 { |
|
227 } |
|
228 |
|
229 CFullySpecWSPStep_3::~CFullySpecWSPStep_3() |
|
230 /** |
|
231 * Destructor |
|
232 */ |
|
233 { |
|
234 } |
|
235 |
|
236 TVerdict CFullySpecWSPStep_3::doTestStepL() |
|
237 /** |
|
238 * Test Connect methoths |
|
239 * @return - TVerdict code |
|
240 * |
|
241 */ |
|
242 { |
|
243 INFO_PRINTF1(_L("FullySpecWSP. Requests without connection")); |
|
244 // check preamble result |
|
245 TVerdict verdict = TestStepResult(); |
|
246 if (verdict==EPass) |
|
247 { |
|
248 TInt err, ret; |
|
249 iImp = LoadInterface(); |
|
250 if (!iImp) |
|
251 { |
|
252 ERR_PRINTF1(_L("Unable to load FullySpecWSP Interface")); |
|
253 verdict = EFail; |
|
254 } |
|
255 else |
|
256 { |
|
257 GetIntFromConfig(ConfigSection(),KWapExError,(TInt&)iExError); |
|
258 ShowConnectionInfo(); |
|
259 TBuf8<100> header, body; |
|
260 TPckgBuf<TUint8> idPckg; |
|
261 TWSPStatus wspStatus; |
|
262 TRequestStatus reqStatus; |
|
263 TUint32 timeout = 0; |
|
264 ShowConnectionInfo(); |
|
265 iImp->MethodResult(header, body, idPckg, wspStatus, reqStatus, timeout); |
|
266 TRAP(ret, TEST_CHECKL(reqStatus.Int(), iExError, _L("MethodResult 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 TBuf<100> uri; |
|
286 TUint8 id = 0; |
|
287 err=iImp->MethodInvoke(0x40, uri, header, body, id); |
|
288 TRAP(ret, TEST_CHECKL(err, iExError, _L("MethodInvoke Fails not as expected"))) |
|
289 if (ret) |
|
290 verdict = EFail; |
|
291 } |
|
292 } |
|
293 } |
|
294 UnloadInterface(); |
|
295 } |
|
296 } |
|
297 if (verdict==EPass) |
|
298 { |
|
299 INFO_PRINTF1(_L("FullySpecWSP. Requests Fail as expected")); |
|
300 } |
|
301 SetTestStepResult(verdict); |
|
302 return TestStepResult(); |
|
303 } |
|
304 |
|
305 TInt CFullySpecWSPStep_3::CallStateMachine() |
|
306 { |
|
307 return (0); |
|
308 } |
|
309 |
|
310 CFullySpecWSPStep_4::CFullySpecWSPStep_4() |
|
311 /** |
|
312 * Constructor |
|
313 */ |
|
314 { |
|
315 } |
|
316 |
|
317 CFullySpecWSPStep_4::~CFullySpecWSPStep_4() |
|
318 /** |
|
319 * Destructor |
|
320 */ |
|
321 { |
|
322 } |
|
323 |
|
324 TVerdict CFullySpecWSPStep_4::doTestStepL() |
|
325 /** |
|
326 * Test Connect methoths |
|
327 * @return - TVerdict code |
|
328 * |
|
329 */ |
|
330 { |
|
331 INFO_PRINTF1(_L("FULLYSPEC-WSP: UnitInvoke-UnitResult")); |
|
332 if(TestStepResult() == EPass ) |
|
333 { |
|
334 SetTestStepResult(EFail); |
|
335 iImp = LoadInterface(); |
|
336 if(iImp) |
|
337 { |
|
338 SetLastError(KErrNone); |
|
339 |
|
340 TInt bearer, port, repeat, method; |
|
341 TInt error = KErrNone; |
|
342 TPtrC headers; |
|
343 TPtrC body; |
|
344 TPtrC uri; |
|
345 |
|
346 if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer; |
|
347 if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) iLocalPort = (Wap::TPort)port; |
|
348 if(GetIntFromConfig(ConfigSection(),KWapExError, error)) SetExpectedError(error); |
|
349 if(GetIntFromConfig(ConfigSection(),KWapWSPMethod, method)) iMethod = method; |
|
350 if(GetIntFromConfig(ConfigSection(), KWapRepeat, repeat)) iRepeat = repeat; |
|
351 |
|
352 if(!GetStringFromConfig(ConfigSection(),KWapURI, uri)) |
|
353 { |
|
354 User::Leave(KErrNoMemory); |
|
355 } |
|
356 GetStringFromConfig(ConfigSection(),KWapWSPHeaders, headers); |
|
357 GetStringFromConfig(ConfigSection(),KWapWSPBody, body); |
|
358 |
|
359 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
360 |
|
361 if(UseSimTsy()) |
|
362 { |
|
363 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, 41)); |
|
364 } |
|
365 |
|
366 |
|
367 iURI = HBufC16::NewL(uri.Length()); |
|
368 |
|
369 iSendHeaders = HBufC8::NewL(headers.Length()); |
|
370 |
|
371 iSendBody = HBufC8::NewL(body.Length()); |
|
372 |
|
373 iRecvHeaders = HBufC8::NewL(KMaxWapWspHeaderBufferLength); |
|
374 iRecvBody = HBufC8::NewL(KMaxWapWspDataBufferLength); |
|
375 |
|
376 TPtr16 tmp16 = iURI->Des(); |
|
377 tmp16.Copy(uri); |
|
378 TPtr8 tmp1 = iSendHeaders->Des(); |
|
379 tmp1.Copy(headers); |
|
380 TPtr8 tmp2 = iSendBody->Des(); |
|
381 tmp2.Copy(body); |
|
382 |
|
383 iRecvHeadersBuf.Set(iRecvHeaders->Des()); |
|
384 iRecvHeadersBuf.Zero(); |
|
385 iRecvBodyBuf.Set(iRecvBody->Des()); |
|
386 iRecvBodyBuf.Zero(); |
|
387 |
|
388 SetState(EConnect); |
|
389 iControl->ReStart(); |
|
390 ShowConnectionInfo(); |
|
391 |
|
392 StartScheduler(); |
|
393 |
|
394 delete iRecvBody; |
|
395 iRecvBody=NULL; |
|
396 delete iRecvHeaders; |
|
397 iRecvHeaders=NULL; |
|
398 |
|
399 delete iSendBody; |
|
400 iSendBody=NULL; |
|
401 delete iSendHeaders; |
|
402 iSendHeaders=NULL; |
|
403 delete iURI; |
|
404 iURI=NULL; |
|
405 |
|
406 UnloadInterface(); |
|
407 } |
|
408 } |
|
409 return TestStepResult(); |
|
410 } |
|
411 |
|
412 TInt CFullySpecWSPStep_4::CallStateMachine() |
|
413 { |
|
414 TVerdict verdict = EFail; |
|
415 TInt err = KErrNone; |
|
416 TInt activate = 0; |
|
417 TPtr8 tmp = iSendBody->Des(); |
|
418 |
|
419 static TUint total_headers = 0; |
|
420 static TUint total_body = 0; |
|
421 static TUint repeat = 0; |
|
422 |
|
423 INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State()); |
|
424 |
|
425 switch(iState) |
|
426 { |
|
427 case EConnect: |
|
428 INFO_PRINTF1(_L("EConnect")); |
|
429 total_headers = 0; |
|
430 total_body = 0; |
|
431 err = iImp->Connect(iRemoteHost, iRemotePort, iBearer, EFalse); |
|
432 INFO_PRINTF2(_L("Connection completed with code = %d"), err); |
|
433 if( err == KErrNone) |
|
434 { |
|
435 SetState(EUnitInvoke); |
|
436 } |
|
437 else |
|
438 { |
|
439 SetState(EFinish); |
|
440 } |
|
441 SetLastError(err); |
|
442 INFO_PRINTF2(_L("Connection completed with code = %d"), err); |
|
443 iControl->ReStart(); |
|
444 break; |
|
445 |
|
446 case EUnitInvoke: |
|
447 INFO_PRINTF2(_L("EUnitInvoke: Method - 0x%02x"), iMethod); |
|
448 if(iBearer != Wap::EIP) |
|
449 { |
|
450 TRAP(err, WaitForInitializeL()); |
|
451 } |
|
452 if(tmp.Length() != 0) |
|
453 { |
|
454 INFO_PRINTF1(_L("Data to send:")); |
|
455 DumpBuf(tmp); |
|
456 } |
|
457 err = iImp->MethodInvoke(iMethod, iURI->Des(), iSendHeaders->Des(), iSendBody->Des(), iTransactionId); |
|
458 INFO_PRINTF3(_L("MethodInvoke() retcode: - dec: %d hex: 0x%08x"), err, err); |
|
459 if(err == KErrNone) |
|
460 { |
|
461 SetState(EUnitResult); |
|
462 } |
|
463 else |
|
464 { |
|
465 SetState(EFinish); |
|
466 } |
|
467 SetLastError(err); |
|
468 iControl->ReStart(); |
|
469 break; |
|
470 |
|
471 case EUnitResult: |
|
472 |
|
473 iRecvHeadersBuf.Set(iRecvHeaders->Des()); |
|
474 iRecvHeadersBuf.Zero(); |
|
475 iRecvBodyBuf.Set(iRecvBody->Des()); |
|
476 iRecvBodyBuf.Zero(); |
|
477 iImp->MethodResult(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, iWspStatus, *iStatus, iTimeout); |
|
478 INFO_PRINTF2(_L("EUnitResult: status 0x%08x"), iStatus->Int()); |
|
479 activate = 1; |
|
480 SetLastError(err); |
|
481 SetState(EFinish); |
|
482 break; |
|
483 |
|
484 case EFinish: |
|
485 |
|
486 INFO_PRINTF4(_L("EFinish: Status: %d, WSP status: %d (0x%02x)"), iStatus->Int(), iWspStatus, iWspStatus); |
|
487 |
|
488 if(iRecvHeadersBuf.Length() != 0) |
|
489 { |
|
490 INFO_PRINTF1(_L("Headers")); |
|
491 total_headers += iRecvHeadersBuf.Length(); |
|
492 DumpBuf(iRecvHeadersBuf); |
|
493 } |
|
494 |
|
495 if(iRecvBodyBuf.Length() != 0) |
|
496 { |
|
497 INFO_PRINTF1(_L("Body")); |
|
498 total_body += iRecvBodyBuf.Length(); |
|
499 DumpBuf(iRecvBodyBuf); |
|
500 } |
|
501 |
|
502 if(iStatus->Int() != KErrNone) |
|
503 { |
|
504 SetLastError(iStatus->Int()); |
|
505 if(iStatus->Int() == Wap::EMoreData) |
|
506 { |
|
507 INFO_PRINTF1(_L("NOTE: More data... calling MethodResult()")); |
|
508 SetState(EUnitResult); |
|
509 iControl->ReStart(); |
|
510 break; |
|
511 } |
|
512 } |
|
513 |
|
514 INFO_PRINTF3(_L("Data received: headers - %d bytes, body - %d bytes"), total_headers, total_body); |
|
515 total_headers = 0; |
|
516 total_body = 0; |
|
517 if((--iRepeat != 0) && (iStatus->Int() == KErrNone)) |
|
518 { |
|
519 ++repeat; |
|
520 INFO_PRINTF2(_L("REPEAT TEST - %d"), repeat); |
|
521 if(err == KErrNone) |
|
522 { |
|
523 SetState(EUnitInvoke); |
|
524 iControl->ReStart(); |
|
525 break; |
|
526 } |
|
527 } |
|
528 |
|
529 verdict = (GetLastError() == GetExpectedError())?EPass:EFail; |
|
530 SetTestStepResult(verdict); |
|
531 SetState(EIdle); |
|
532 StopScheduler(); |
|
533 break; |
|
534 |
|
535 case EIdle: |
|
536 default: |
|
537 INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State()); |
|
538 SetTestStepResult(verdict); |
|
539 StopScheduler(); |
|
540 break; |
|
541 } |
|
542 return (activate); |
|
543 } |
|
544 |
|
545 |
|
546 CFullySpecWSPStep_5::CFullySpecWSPStep_5() |
|
547 /** |
|
548 * Constructor |
|
549 */ |
|
550 { |
|
551 } |
|
552 |
|
553 CFullySpecWSPStep_5::~CFullySpecWSPStep_5() |
|
554 /** |
|
555 * Destructor |
|
556 */ |
|
557 { |
|
558 } |
|
559 |
|
560 TVerdict CFullySpecWSPStep_5::doTestStepL() |
|
561 /** |
|
562 * Test Cancel Request |
|
563 * @return - TVerdict code |
|
564 * |
|
565 */ |
|
566 { |
|
567 INFO_PRINTF1(_L("BoundCLPush. Testing Cancel Request")); |
|
568 if(TestStepResult() == EPass ) |
|
569 { |
|
570 SetTestStepResult(EFail); |
|
571 iImp = LoadInterface(); |
|
572 if(iImp) |
|
573 { |
|
574 TInt bearer = 0; |
|
575 TInt error = KErrNone; |
|
576 TBool secure= EFalse; |
|
577 TBool reconnect= EFalse; |
|
578 SetLastError(KErrNone); |
|
579 |
|
580 if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer; |
|
581 if(GetIntFromConfig(ConfigSection(), KWapExError, error)) SetExpectedError(error); |
|
582 if(GetBoolFromConfig(ConfigSection(), KWapSecure, secure)) iSecure = secure; |
|
583 if(GetBoolFromConfig(ConfigSection(),_L("Reconnect"), reconnect)) iReconnect = reconnect; |
|
584 |
|
585 ShowConnectionInfo(); |
|
586 |
|
587 error = iImp->Connect(iRemoteHost, iRemotePort, iBearer, iSecure); |
|
588 INFO_PRINTF2(_L("Connection completed with code = %d"), error); |
|
589 if( error == KErrNone) |
|
590 { |
|
591 TBuf8<100> header, body; |
|
592 TPckgBuf<TUint8> idPckg; |
|
593 TWSPStatus wspStatus; |
|
594 TRequestStatus reqStatus; |
|
595 TUint32 timeout=0; |
|
596 iImp->MethodResult(header, body, idPckg, wspStatus, reqStatus, timeout); |
|
597 SetState(EUnitResult); |
|
598 StartScheduler(); |
|
599 iControl->ReStart(); |
|
600 if(reqStatus==KErrCancel) |
|
601 { |
|
602 SetTestStepResult(EPass); |
|
603 } |
|
604 |
|
605 } |
|
606 } |
|
607 } |
|
608 return TestStepResult(); |
|
609 } |
|
610 |
|
611 TInt CFullySpecWSPStep_5::CallStateMachine() |
|
612 { |
|
613 INFO_PRINTF2(_L("CallStateMachine: step [%d]"), State()); |
|
614 switch(iState) |
|
615 { |
|
616 case EUnitResult: |
|
617 INFO_PRINTF1(_L("EUnitResult")); |
|
618 iImp->CancelReq(); |
|
619 SetState(EFinish); |
|
620 iControl->ReStart(); |
|
621 break; |
|
622 |
|
623 case EFinish: |
|
624 INFO_PRINTF1(_L("EFinish")); |
|
625 SetState(EIdle); |
|
626 StopScheduler(); |
|
627 break; |
|
628 |
|
629 case EIdle: |
|
630 default: |
|
631 INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State()); |
|
632 SetTestStepResult(EFail); |
|
633 StopScheduler(); |
|
634 break; |
|
635 } |
|
636 return (0); |
|
637 } |
|
638 |
|
639 |
|
640 CFullySpecWSPStep_6::CFullySpecWSPStep_6() |
|
641 { |
|
642 } |
|
643 |
|
644 CFullySpecWSPStep_6::~CFullySpecWSPStep_6() |
|
645 { |
|
646 } |
|
647 |
|
648 TVerdict CFullySpecWSPStep_6::doTestStepL() |
|
649 /* |
|
650 * Test receive time out |
|
651 */ |
|
652 { |
|
653 INFO_PRINTF1(_L("BOUND-WSP: Connect-UnitResult-TimeOut")); |
|
654 if(TestStepResult() == EPass ) |
|
655 { |
|
656 SetTestStepResult(EFail); |
|
657 iImp = LoadInterface(); |
|
658 if(iImp) |
|
659 { |
|
660 SetLastError(KErrNone); |
|
661 TInt bearer, port; |
|
662 TInt error = KErrNone; |
|
663 if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) |
|
664 { |
|
665 iBearer = static_cast<Wap::TBearer>(bearer); |
|
666 } |
|
667 if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) |
|
668 { |
|
669 iLocalPort = static_cast<Wap::TPort>(port); |
|
670 } |
|
671 if(GetIntFromConfig(ConfigSection(),KWapExError, error)) |
|
672 { |
|
673 SetExpectedError(error); |
|
674 } |
|
675 TInt headerLength, bufLength, timeOut; |
|
676 if(GetIntFromConfig(ConfigSection(),KWapWSPRecvHeaderLength, headerLength)) |
|
677 { |
|
678 iHeaderRecvBufLength=static_cast<TUint16>(headerLength); |
|
679 } |
|
680 if(GetIntFromConfig(ConfigSection(),KWapWSPRecvBodyLength, bufLength)) |
|
681 { |
|
682 iBodyRecvBufLength=static_cast<TUint16>(bufLength); |
|
683 } |
|
684 if(GetIntFromConfig(ConfigSection(),KWapTimeOut, timeOut)) |
|
685 { |
|
686 iTimeout=timeOut; |
|
687 } |
|
688 iRecvHeaders = HBufC8::NewL(iHeaderRecvBufLength); |
|
689 iRecvBody = HBufC8::NewL(iBodyRecvBufLength); |
|
690 SetState(EConnect); |
|
691 iControl->ReStart(); |
|
692 ShowConnectionInfo(); |
|
693 // Start state machine |
|
694 StartScheduler(); |
|
695 delete iRecvBody; |
|
696 iRecvBody=NULL; |
|
697 delete iRecvHeaders; |
|
698 iRecvHeaders=NULL; |
|
699 UnloadInterface(); |
|
700 } |
|
701 } |
|
702 return TestStepResult(); |
|
703 } |
|
704 |
|
705 TInt CFullySpecWSPStep_6::CallStateMachine() |
|
706 { |
|
707 TVerdict verdict = EFail; |
|
708 TInt err = KErrNone; |
|
709 TInt activate = 0; |
|
710 |
|
711 INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State()); |
|
712 switch(iState) |
|
713 { |
|
714 case EConnect: |
|
715 INFO_PRINTF1(_L("EConnect")); |
|
716 err = iImp->Connect(iRemoteHost, iRemotePort, iBearer, EFalse); |
|
717 INFO_PRINTF2(_L("Connection completed with code = %d"), err); |
|
718 if( err == KErrNone) |
|
719 { |
|
720 // WaitForInitializeL(); |
|
721 iRecvHeadersBuf.Set(iRecvHeaders->Des()); |
|
722 iRecvBodyBuf.Set(iRecvBody->Des()); |
|
723 iImp->MethodResult(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, iWspStatus, *iStatus, iTimeout); |
|
724 INFO_PRINTF1(_L("MethodResult")); |
|
725 activate = 1; |
|
726 } |
|
727 else |
|
728 { |
|
729 iControl->ReStart(); |
|
730 } |
|
731 SetLastError(err); |
|
732 SetState(EFinish); |
|
733 break; |
|
734 |
|
735 case EFinish: |
|
736 INFO_PRINTF1(_L("EFinish")); |
|
737 if(iStatus->Int() != KErrNone) |
|
738 { |
|
739 SetLastError(iStatus->Int()); |
|
740 } |
|
741 verdict = (GetLastError() == GetExpectedError())?EPass:EFail; |
|
742 SetTestStepResult(verdict); |
|
743 SetState(EIdle); |
|
744 StopScheduler(); |
|
745 break; |
|
746 |
|
747 case EIdle: |
|
748 default: |
|
749 INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State()); |
|
750 SetTestStepResult(verdict); |
|
751 StopScheduler(); |
|
752 break; |
|
753 } |
|
754 return (activate); |
|
755 } |
|
756 |
|
757 CFullySpecWSPStep_7::CFullySpecWSPStep_7() |
|
758 { |
|
759 } |
|
760 CFullySpecWSPStep_7::~CFullySpecWSPStep_7() |
|
761 { |
|
762 } |
|
763 TVerdict CFullySpecWSPStep_7::doTestStepL() |
|
764 { |
|
765 INFO_PRINTF1(_L("FULLYSPEC-WSP: Connect-UnitResult-TimeOut")); |
|
766 if(TestStepResult() == EPass ) |
|
767 { |
|
768 SetTestStepResult(EFail); |
|
769 iImp = LoadInterface(); |
|
770 if(iImp) |
|
771 { |
|
772 SetLastError(KErrNone); |
|
773 TInt bearer, port; |
|
774 TInt error = KErrNone; |
|
775 if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) |
|
776 { |
|
777 iBearer = static_cast<Wap::TBearer>(bearer); |
|
778 } |
|
779 if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) |
|
780 { |
|
781 iLocalPort = static_cast<Wap::TPort>(port); |
|
782 } |
|
783 if(GetIntFromConfig(ConfigSection(),KWapExError, error)) |
|
784 { |
|
785 SetExpectedError(error); |
|
786 } |
|
787 TInt headerLength, bufLength; |
|
788 if(GetIntFromConfig(ConfigSection(),KWapWSPRecvHeaderLength, headerLength)) |
|
789 { |
|
790 iHeaderRecvBufLength=static_cast<TUint16>(headerLength); |
|
791 } |
|
792 if(GetIntFromConfig(ConfigSection(),KWapWSPRecvBodyLength, bufLength)) |
|
793 { |
|
794 iBodyRecvBufLength=static_cast<TUint16>(bufLength); |
|
795 } |
|
796 iRecvHeaders = HBufC8::NewL(iHeaderRecvBufLength); |
|
797 iRecvBody = HBufC8::NewL(iBodyRecvBufLength); |
|
798 SetState(EConnect); |
|
799 iControl->ReStart(); |
|
800 ShowConnectionInfo(); |
|
801 |
|
802 StartScheduler(); |
|
803 delete iRecvBody; |
|
804 iRecvBody=NULL; |
|
805 delete iRecvHeaders; |
|
806 iRecvHeaders=NULL; |
|
807 UnloadInterface(); |
|
808 } |
|
809 } |
|
810 return TestStepResult(); |
|
811 } |
|
812 |
|
813 TInt CFullySpecWSPStep_7::CallStateMachine() |
|
814 { |
|
815 TVerdict verdict = EFail; |
|
816 TInt err = KErrNone; |
|
817 TInt activate = 0; |
|
818 TDes8 headers = iRecvHeaders->Des(); |
|
819 TDes8 body = iRecvBody->Des(); |
|
820 |
|
821 INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State()); |
|
822 switch(iState) |
|
823 { |
|
824 case EConnect: |
|
825 INFO_PRINTF1(_L("EConnect")); |
|
826 err = iImp->Connect(iRemoteHost, iRemotePort, iBearer, EFalse); |
|
827 INFO_PRINTF2(_L("Connection completed with code = %d"), err); |
|
828 if( err == KErrNone) |
|
829 { |
|
830 // WaitForInitializeL(); |
|
831 TRequestStatus reqStatus; |
|
832 iImp->MethodResult(headers, body, iTransactionIdPckg, iWspStatus, reqStatus, iTimeout); |
|
833 iImp->MethodResult(headers, body, iTransactionIdPckg, iWspStatus, *iStatus, iTimeout); |
|
834 INFO_PRINTF1(_L("MethodResult")); |
|
835 activate = 1; |
|
836 } |
|
837 else |
|
838 { |
|
839 iControl->ReStart(); |
|
840 } |
|
841 SetLastError(err); |
|
842 SetState(EFinish); |
|
843 break; |
|
844 |
|
845 case EFinish: |
|
846 INFO_PRINTF1(_L("EFinish")); |
|
847 if(iStatus->Int() != KErrNone) |
|
848 { |
|
849 SetLastError(iStatus->Int()); |
|
850 } |
|
851 verdict = (GetLastError() == GetExpectedError())?EPass:EFail; |
|
852 SetTestStepResult(verdict); |
|
853 SetState(EIdle); |
|
854 StopScheduler(); |
|
855 break; |
|
856 |
|
857 case EIdle: |
|
858 default: |
|
859 INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State()); |
|
860 SetTestStepResult(verdict); |
|
861 StopScheduler(); |
|
862 |
|
863 break; |
|
864 } |
|
865 return (activate); |
|
866 } |
|
867 |
|
868 CFullySpecWSPStep_8::CFullySpecWSPStep_8() |
|
869 { |
|
870 } |
|
871 CFullySpecWSPStep_8::~CFullySpecWSPStep_8() |
|
872 { |
|
873 } |
|
874 TVerdict CFullySpecWSPStep_8::doTestStepL() |
|
875 /* |
|
876 * Using invalid values for API parameters: |
|
877 * - Invalid TUid on construction |
|
878 * - Invalid method for MethodInvoke |
|
879 * - Invalid timeout for MethodResult |
|
880 * Note: wrong bearer value has already been implemented as part of test 2 |
|
881 */ |
|
882 { |
|
883 INFO_PRINTF1(_L("FullySpec-WSP: Wrong parameters testing")); |
|
884 if(TestStepResult() == EPass ) |
|
885 { |
|
886 TInt error; |
|
887 if(GetIntFromConfig(ConfigSection(),KWapExError2, error)) |
|
888 { |
|
889 iExError2=error; |
|
890 } |
|
891 TInt trapValue; |
|
892 TUid invalidInterfaceUid = {0x00000000}; |
|
893 INFO_PRINTF2(_L("Calling new NewL(0x%08X) method"), invalidInterfaceUid); |
|
894 TRAP(trapValue, iImp = CWapFullySpecCLWSPService::NewL(invalidInterfaceUid)); |
|
895 TVerdict verdict = (trapValue == iExError2)?EPass:EFail; |
|
896 if (verdict==EFail) |
|
897 { |
|
898 SetTestStepResult(EFail); |
|
899 return TestStepResult(); |
|
900 } |
|
901 else |
|
902 { |
|
903 INFO_PRINTF2(_L("CreateImplementation with wrong Uid- Failed as expected with error %d"),trapValue); |
|
904 |
|
905 // Now use the correct Uid |
|
906 iImp = LoadInterface(); |
|
907 if(iImp) |
|
908 { |
|
909 SetLastError(KErrNone); |
|
910 TInt error = KErrNone; |
|
911 TInt method; |
|
912 TPtrC headers; |
|
913 TPtrC body; |
|
914 TPtrC uri; |
|
915 |
|
916 if (GetIntFromConfig(ConfigSection(),KWapWSPMethod, method)) |
|
917 { |
|
918 iMethod=method; |
|
919 } |
|
920 |
|
921 if(GetIntFromConfig(ConfigSection(), KWapExError, error)) |
|
922 { |
|
923 SetExpectedError(error); |
|
924 } |
|
925 |
|
926 if(!GetStringFromConfig(ConfigSection(),KWapURI, uri) || \ |
|
927 !GetStringFromConfig(ConfigSection(),KWapWSPHeaders, headers) || \ |
|
928 !GetStringFromConfig(ConfigSection(),KWapWSPBody, body)) |
|
929 { |
|
930 User::Leave(KErrNoMemory); |
|
931 } |
|
932 |
|
933 iURI = HBufC16::NewL(uri.Length()); |
|
934 |
|
935 iSendHeaders = HBufC8::NewL(headers.Length()); |
|
936 |
|
937 iSendBody = HBufC8::NewL(body.Length()); |
|
938 |
|
939 TPtr16 tmp16 = iURI->Des(); |
|
940 tmp16.Copy(uri); |
|
941 TPtr8 tmp = iSendHeaders->Des(); |
|
942 tmp.Copy(headers); |
|
943 TPtr8 tmp1 = iSendBody->Des(); |
|
944 tmp1.Copy(body); |
|
945 |
|
946 ShowConnectionInfo(); |
|
947 error = iImp->Connect(iRemoteHost, iRemotePort, iBearer, EFalse); |
|
948 INFO_PRINTF2(_L("Connection completed with code = %d"), error); |
|
949 if( error == KErrNone) |
|
950 { |
|
951 error =iImp->MethodInvoke(iMethod, iURI->Des(), iSendHeaders->Des(), iSendBody->Des(), iTransactionId); |
|
952 } |
|
953 TVerdict verdict = (error == GetExpectedError())?EPass:EFail; |
|
954 SetTestStepResult(verdict); |
|
955 delete iSendBody; |
|
956 iSendBody=NULL; |
|
957 delete iSendHeaders; |
|
958 iSendHeaders=NULL; |
|
959 delete iURI; |
|
960 iURI=NULL; |
|
961 UnloadInterface(); |
|
962 } |
|
963 } |
|
964 } |
|
965 return TestStepResult(); |
|
966 } |
|
967 |
|
968 TInt CFullySpecWSPStep_8::CallStateMachine() |
|
969 { |
|
970 return (0); |
|
971 } |
|
972 |
|
973 CFullySpecWSPStep_9::CFullySpecWSPStep_9() {} |
|
974 CFullySpecWSPStep_9::~CFullySpecWSPStep_9() {} |
|
975 TVerdict CFullySpecWSPStep_9::doTestStepL() |
|
976 { |
|
977 return TestStepResult(); |
|
978 } |
|
979 |
|
980 TInt CFullySpecWSPStep_9::CallStateMachine() |
|
981 { |
|
982 return (0); |
|
983 } |