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