44
|
1 |
// Copyright (c) 2002-2010 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 receiving PDU data over UDP
|
|
334 |
* The test is run concurently with CBoundCLPushStep_9 test. CBoundCLPushStep_4 waits for push message whilst
|
|
335 |
* CBoundCLPushStep_9 sends a push message over UDP using loopback.
|
|
336 |
* The test pair is used to test two cases (dependent on configuration read for CBoundCLPushStep_9):
|
|
337 |
* - sending PDU data that is smaller than the allocated buffer on the receiving side (<=1024)
|
|
338 |
* - sending PDU data that is larger than the allocated buffer on the receiving side and needs reallocation (>1024)
|
|
339 |
* @return - TVerdict code
|
|
340 |
*
|
|
341 |
*/
|
|
342 |
{
|
|
343 |
INFO_PRINTF1(_L("BOUND-CLPUSH: Connect-AwaitPush"));
|
|
344 |
INFO_PRINTF1(_L("Receiving PDU over UDP from a concurrent test... "));
|
|
345 |
if(TestStepResult() == EPass )
|
|
346 |
{
|
|
347 |
SetTestStepResult(EFail);
|
|
348 |
iImp = LoadInterface();
|
|
349 |
if(iImp)
|
|
350 |
{
|
|
351 |
SetLastError(KErrNone);
|
|
352 |
|
|
353 |
TInt bearer, port;
|
|
354 |
TInt error = KErrNone;
|
|
355 |
|
|
356 |
if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer))
|
|
357 |
{
|
|
358 |
iBearer = static_cast<Wap::TBearer>(bearer);
|
|
359 |
}
|
|
360 |
if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port))
|
|
361 |
{
|
|
362 |
iLocalPort = static_cast<Wap::TPort>(port);
|
|
363 |
}
|
|
364 |
if(GetIntFromConfig(ConfigSection(),KWapExError, error))
|
|
365 |
{
|
|
366 |
SetExpectedError(error);
|
|
367 |
}
|
|
368 |
GetBoolFromConfig(ConfigSection(), KMiddleCancel, iMiddleCancel);
|
|
369 |
GetBoolFromConfig(ConfigSection(), KMultiReadCancel, iMultiReadCancel);
|
|
370 |
TInt headerLength, bufLength;
|
|
371 |
if(GetIntFromConfig(ConfigSection(),KWapWSPRecvHeaderLength, headerLength))
|
|
372 |
{
|
|
373 |
iHeaderRecvBufLength=static_cast<TUint16>(headerLength);
|
|
374 |
}
|
|
375 |
if(GetIntFromConfig(ConfigSection(),KWapWSPRecvBodyLength, bufLength))
|
|
376 |
{
|
|
377 |
iBodyRecvBufLength=static_cast<TUint16>(bufLength);
|
|
378 |
}
|
|
379 |
iRecvHeaders = HBufC8::NewL(iHeaderRecvBufLength);
|
|
380 |
iRecvBody = HBufC8::NewL(iBodyRecvBufLength);
|
|
381 |
|
|
382 |
User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn));
|
|
383 |
|
|
384 |
|
|
385 |
if(UseSimTsy())
|
|
386 |
{
|
|
387 |
GetIntFromConfig(ConfigSection(),KWapSIMTSYState, iSimTsyState);
|
|
388 |
User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, iSimTsyState));
|
|
389 |
}
|
|
390 |
|
|
391 |
|
|
392 |
SetState(EConnect);
|
|
393 |
iControl->ReStart();
|
|
394 |
ShowConnectionInfo();
|
|
395 |
|
|
396 |
StartScheduler();
|
|
397 |
delete iRecvBody;
|
|
398 |
iRecvBody=NULL;
|
|
399 |
delete iRecvHeaders;
|
|
400 |
iRecvHeaders=NULL;
|
|
401 |
UnloadInterface();
|
|
402 |
}
|
|
403 |
}
|
|
404 |
return TestStepResult();
|
|
405 |
}
|
|
406 |
|
|
407 |
TInt CBoundCLPushStep_4::CallStateMachine()
|
|
408 |
{
|
|
409 |
TVerdict verdict = EFail;
|
|
410 |
TInt err = KErrNone;
|
|
411 |
TInt activate = 0;
|
|
412 |
|
|
413 |
INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State());
|
|
414 |
switch(iState)
|
|
415 |
{
|
|
416 |
case EConnect:
|
|
417 |
INFO_PRINTF1(_L("EConnect"));
|
|
418 |
err = iImp->Connect(iBearer, iLocalPort, EFalse);
|
|
419 |
INFO_PRINTF2(_L("Connection completed with code = %d"), err);
|
|
420 |
if( err == KErrNone)
|
|
421 |
{
|
|
422 |
if(iBearer != Wap::EIP)
|
|
423 |
{
|
|
424 |
TRAP(err, WaitForInitializeL());
|
|
425 |
}
|
|
426 |
iRecvHeadersBuf.Set(iRecvHeaders->Des());
|
|
427 |
iRecvBodyBuf.Set(iRecvBody->Des());
|
|
428 |
iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, *iStatus);
|
|
429 |
INFO_PRINTF1(_L("Start AwaitingPush....."));
|
|
430 |
activate = 1;
|
|
431 |
if (!iMiddleCancel)
|
|
432 |
{
|
|
433 |
SetState(EAwaitPush);
|
|
434 |
}
|
|
435 |
else
|
|
436 |
{
|
|
437 |
INFO_PRINTF1(_L("Cancel AwaitPush"));
|
|
438 |
iImp->CancelAwaitPush();
|
|
439 |
SetState(EFinish);
|
|
440 |
}
|
|
441 |
}
|
|
442 |
else
|
|
443 |
{
|
|
444 |
SetState(EFinish);
|
|
445 |
iControl->ReStart();
|
|
446 |
}
|
|
447 |
SetLastError(err);
|
|
448 |
break;
|
|
449 |
|
|
450 |
case EAwaitPush:
|
|
451 |
|
|
452 |
INFO_PRINTF1(_L("EAwaitPush"));
|
|
453 |
if(iStatus->Int() != KErrNone && iStatus->Int()!=Wap::EMoreData)
|
|
454 |
// AwaitPush failed
|
|
455 |
{
|
|
456 |
INFO_PRINTF1(_L("AwaitPush failed"));
|
|
457 |
SetLastError(iStatus->Int());
|
|
458 |
SetState(EFinish);
|
|
459 |
iControl->ReStart();
|
|
460 |
}
|
|
461 |
else
|
|
462 |
{
|
|
463 |
iMaxWspHeaderRecvBuffer.Append(iRecvHeadersBuf);
|
|
464 |
iMaxWspDataRecvBuffer.Append(iRecvBodyBuf);
|
|
465 |
if (iStatus->Int()==Wap::EMoreData)
|
|
466 |
{
|
|
467 |
iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, *iStatus);
|
|
468 |
activate = 1;
|
|
469 |
if (!iMultiReadCancel)
|
|
470 |
{
|
|
471 |
SetState(EAwaitPush);
|
|
472 |
}
|
|
473 |
else
|
|
474 |
{
|
|
475 |
INFO_PRINTF1(_L("Cancel Receive in EMutipleReceive state"));
|
|
476 |
iImp->CancelAwaitPush();
|
|
477 |
SetState(EFinish);
|
|
478 |
}
|
|
479 |
}
|
|
480 |
else
|
|
481 |
{
|
|
482 |
SetLastError(iStatus->Int());
|
|
483 |
iControl->ReStart();
|
|
484 |
SetState(EFinish);
|
|
485 |
}
|
|
486 |
}
|
|
487 |
break;
|
|
488 |
|
|
489 |
case EFinish:
|
|
490 |
|
|
491 |
INFO_PRINTF1(_L("EFinish"));
|
|
492 |
if(iStatus->Int() != KErrNone)
|
|
493 |
{
|
|
494 |
SetLastError(iStatus->Int());
|
|
495 |
}
|
|
496 |
verdict = (GetLastError() == GetExpectedError())?EPass:EFail;
|
|
497 |
if (verdict==EPass && !iMiddleCancel && !iMultiReadCancel)
|
|
498 |
{
|
|
499 |
iImp->CancelAwaitPush();
|
|
500 |
INFO_PRINTF1(_L("Headers:"));
|
|
501 |
DumpBuf(iMaxWspHeaderRecvBuffer);
|
|
502 |
INFO_PRINTF1(_L("Body"));
|
|
503 |
DumpBuf(iMaxWspDataRecvBuffer);
|
|
504 |
if (verdict==EPass)
|
|
505 |
{
|
|
506 |
HBufC8* buf;
|
|
507 |
iImp->GetServerAddress(buf);
|
|
508 |
verdict = (buf->Match(iRemoteHost)!=KErrNotFound)?EPass:EFail;
|
|
509 |
delete buf;
|
|
510 |
}
|
|
511 |
if (verdict==EPass)
|
|
512 |
{
|
|
513 |
Wap::TPort port;
|
|
514 |
iImp->GetLocalPort(port);
|
|
515 |
verdict = (port == iLocalPort)?EPass:EFail;
|
|
516 |
}
|
|
517 |
if (verdict==EPass)
|
|
518 |
{
|
|
519 |
Wap::TBearer bearer;
|
|
520 |
iImp->GetBearer(bearer);
|
|
521 |
verdict = (bearer == iBearer)?EPass:EFail;
|
|
522 |
}
|
|
523 |
if (verdict==EPass)
|
|
524 |
{
|
|
525 |
//This test can not perform.
|
|
526 |
HBufC8* buf;
|
|
527 |
iImp->GetLocalAddress(buf);
|
|
528 |
delete buf;
|
|
529 |
}
|
|
530 |
}
|
|
531 |
SetTestStepResult(verdict);
|
|
532 |
SetState(EIdle);
|
|
533 |
StopScheduler();
|
|
534 |
break;
|
|
535 |
|
|
536 |
case EIdle:
|
|
537 |
default:
|
|
538 |
INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State());
|
|
539 |
SetTestStepResult(verdict);
|
|
540 |
StopScheduler();
|
|
541 |
|
|
542 |
break;
|
|
543 |
}
|
|
544 |
return (activate);
|
|
545 |
}
|
|
546 |
|
|
547 |
CBoundCLPushStep_5::CBoundCLPushStep_5()
|
|
548 |
/**
|
|
549 |
* Constructor
|
|
550 |
*/
|
|
551 |
{
|
|
552 |
}
|
|
553 |
|
|
554 |
CBoundCLPushStep_5::~CBoundCLPushStep_5()
|
|
555 |
/**
|
|
556 |
* Destructor
|
|
557 |
*/
|
|
558 |
{
|
|
559 |
}
|
|
560 |
|
|
561 |
TVerdict CBoundCLPushStep_5::doTestStepL()
|
|
562 |
/**
|
|
563 |
* Test Cancel
|
|
564 |
* @return - TVerdict code
|
|
565 |
*
|
|
566 |
*/
|
|
567 |
{
|
|
568 |
INFO_PRINTF1(_L("BOUNDCL-PUSH: Testing Cancel"));
|
|
569 |
if(TestStepResult() == EPass )
|
|
570 |
{
|
|
571 |
SetTestStepResult(EFail);
|
|
572 |
iImp = LoadInterface();
|
|
573 |
if(iImp)
|
|
574 |
{
|
|
575 |
TInt bearer, port;
|
|
576 |
TInt error = KErrNone;
|
|
577 |
TBool secure= EFalse;
|
|
578 |
TBool reconnect= EFalse;
|
|
579 |
SetLastError(KErrNone);
|
|
580 |
|
|
581 |
if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer)) iBearer = (Wap::TBearer)bearer;
|
|
582 |
if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port)) iLocalPort = (Wap::TPort)port;
|
|
583 |
if(GetIntFromConfig(ConfigSection(), KWapExError, error)) SetExpectedError(error);
|
|
584 |
if(GetBoolFromConfig(ConfigSection(), KWapSecure, secure)) iSecure = secure;
|
|
585 |
if(GetBoolFromConfig(ConfigSection(),_L("Reconnect"), reconnect)) iReconnect = reconnect;
|
|
586 |
|
|
587 |
ShowConnectionInfo();
|
|
588 |
error = iImp->Connect(iBearer, iLocalPort, iSecure);
|
|
589 |
INFO_PRINTF2(_L("Connection completed with code = %d"), error);
|
|
590 |
if( error == KErrNone)
|
|
591 |
{
|
|
592 |
TBuf8<100> header, body;
|
|
593 |
TPckgBuf<TUint8> pushIdPckg;
|
|
594 |
TRequestStatus reqStatus;
|
|
595 |
iImp->AwaitPush(header, body, pushIdPckg, reqStatus);
|
|
596 |
SetState(EAwaitPush);
|
|
597 |
StartScheduler();
|
|
598 |
iControl->ReStart();
|
|
599 |
if(reqStatus==KErrCancel)
|
|
600 |
{
|
|
601 |
SetTestStepResult(EPass);
|
|
602 |
}
|
|
603 |
}
|
|
604 |
|
|
605 |
}
|
|
606 |
}
|
|
607 |
return TestStepResult();
|
|
608 |
}
|
|
609 |
|
|
610 |
TInt CBoundCLPushStep_5::CallStateMachine()
|
|
611 |
{
|
|
612 |
INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State());
|
|
613 |
switch(iState)
|
|
614 |
{
|
|
615 |
case EAwaitPush:
|
|
616 |
INFO_PRINTF1(_L("EAwaitPush"));
|
|
617 |
iImp->CancelAwaitPush();
|
|
618 |
SetState(EFinish);
|
|
619 |
iControl->ReStart();
|
|
620 |
break;
|
|
621 |
case EFinish:
|
|
622 |
INFO_PRINTF1(_L("EFinish"));
|
|
623 |
SetState(EIdle);
|
|
624 |
StopScheduler();
|
|
625 |
break;
|
|
626 |
case EIdle:
|
|
627 |
default:
|
|
628 |
INFO_PRINTF2(_L("Error: EIdle or unknown state %d"), State());
|
|
629 |
SetTestStepResult(EFail);
|
|
630 |
StopScheduler();
|
|
631 |
break;
|
|
632 |
}
|
|
633 |
return (0);
|
|
634 |
}
|
|
635 |
|
|
636 |
|
|
637 |
CBoundCLPushStep_6::CBoundCLPushStep_6()
|
|
638 |
{
|
|
639 |
}
|
|
640 |
CBoundCLPushStep_6::~CBoundCLPushStep_6()
|
|
641 |
{
|
|
642 |
}
|
|
643 |
TVerdict CBoundCLPushStep_6::doTestStepL()
|
|
644 |
{
|
|
645 |
return TestStepResult();
|
|
646 |
}
|
|
647 |
TInt CBoundCLPushStep_6::CallStateMachine()
|
|
648 |
{
|
|
649 |
return (0);
|
|
650 |
}
|
|
651 |
|
|
652 |
CBoundCLPushStep_7::CBoundCLPushStep_7()
|
|
653 |
{
|
|
654 |
}
|
|
655 |
CBoundCLPushStep_7::~CBoundCLPushStep_7()
|
|
656 |
{
|
|
657 |
}
|
|
658 |
TVerdict CBoundCLPushStep_7::doTestStepL()
|
|
659 |
{
|
|
660 |
INFO_PRINTF1(_L("BOUND-CLPUSH: Connect-AwaitPush-AwaitPush"));
|
|
661 |
if(TestStepResult() == EPass )
|
|
662 |
{
|
|
663 |
SetTestStepResult(EFail);
|
|
664 |
iImp = LoadInterface();
|
|
665 |
if(iImp)
|
|
666 |
{
|
|
667 |
SetLastError(KErrNone);
|
|
668 |
|
|
669 |
TInt bearer, port;
|
|
670 |
TInt error = KErrNone;
|
|
671 |
|
|
672 |
if(GetIntFromConfig(ConfigSection(),KWapBearer, bearer))
|
|
673 |
{
|
|
674 |
iBearer = static_cast<Wap::TBearer>(bearer);
|
|
675 |
}
|
|
676 |
if(GetIntFromConfig(ConfigSection(),KWapLocalPort, port))
|
|
677 |
{
|
|
678 |
iLocalPort = static_cast<Wap::TPort>(port);
|
|
679 |
}
|
|
680 |
if(GetIntFromConfig(ConfigSection(),KWapExError, error))
|
|
681 |
{
|
|
682 |
SetExpectedError(error);
|
|
683 |
}
|
|
684 |
TInt headerLength, bufLength;
|
|
685 |
if(GetIntFromConfig(ConfigSection(),KWapWSPRecvHeaderLength, headerLength))
|
|
686 |
{
|
|
687 |
iHeaderRecvBufLength=static_cast<TUint16>(headerLength);
|
|
688 |
}
|
|
689 |
if(GetIntFromConfig(ConfigSection(),KWapWSPRecvBodyLength, bufLength))
|
|
690 |
{
|
|
691 |
iBodyRecvBufLength=static_cast<TUint16>(bufLength);
|
|
692 |
}
|
|
693 |
iRecvHeaders = HBufC8::NewL(iHeaderRecvBufLength);
|
|
694 |
iRecvBody = HBufC8::NewL(iBodyRecvBufLength);
|
|
695 |
SetState(EConnect);
|
|
696 |
iControl->ReStart();
|
|
697 |
ShowConnectionInfo();
|
|
698 |
|
|
699 |
StartScheduler();
|
|
700 |
delete iRecvBody;
|
|
701 |
iRecvBody=NULL;
|
|
702 |
delete iRecvHeaders;
|
|
703 |
iRecvHeaders=NULL;
|
|
704 |
UnloadInterface();
|
|
705 |
}
|
|
706 |
}
|
|
707 |
return TestStepResult();
|
|
708 |
}
|
|
709 |
TInt CBoundCLPushStep_7::CallStateMachine()
|
|
710 |
{
|
|
711 |
TVerdict verdict = EFail;
|
|
712 |
TInt err = KErrNone;
|
|
713 |
TInt activate = 0;
|
|
714 |
|
|
715 |
INFO_PRINTF2(_L("CallStateMachine: state [%d]"), State());
|
|
716 |
switch(iState)
|
|
717 |
{
|
|
718 |
case EConnect:
|
|
719 |
|
|
720 |
INFO_PRINTF1(_L("EConnect"));
|
|
721 |
err = iImp->Connect(iBearer, iLocalPort, EFalse);
|
|
722 |
INFO_PRINTF2(_L("Connection completed with code = %d"), err);
|
|
723 |
if( err == KErrNone)
|
|
724 |
{
|
|
725 |
iRecvHeadersBuf.Set(iRecvHeaders->Des());
|
|
726 |
iRecvBodyBuf.Set(iRecvBody->Des());
|
|
727 |
TRequestStatus reqStatus;
|
|
728 |
iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, reqStatus);
|
|
729 |
iImp->AwaitPush(iRecvHeadersBuf, iRecvBodyBuf, iTransactionIdPckg, *iStatus);
|
|
730 |
INFO_PRINTF1(_L("AwaitPush"));
|
|
731 |
activate = 1;
|
|
732 |
}
|
|
733 |
else
|
|
734 |
{
|
|
735 |
iControl->ReStart();
|
|
736 |
}
|
|
737 |
SetLastError(err);
|
|
738 |
SetState(EFinish);
|
|
739 |
break;
|
|
740 |
|
|
741 |
case EFinish:
|
|
742 |
|
|
743 |
INFO_PRINTF1(_L("EFinish"));
|
|
744 |
iImp->CancelAwaitPush();
|
|
745 |
if(iStatus->Int() != KErrNone)
|
|
746 |
{
|
|
747 |
SetLastError(iStatus->Int());
|
|
748 |
}
|
|
749 |
verdict = (GetLastError() == GetExpectedError())?EPass:EFail;
|
|
750 |
SetTestStepResult(verdict);
|
|
751 |
SetState(EIdle);
|
|
752 |
StopScheduler();
|
|
753 |
break;
|
|
754 |
|
|
755 |
case EIdle:
|
|
756 |
default:
|
|
757 |
INFO_PRINTF2(_L("Error: EIdle or unknown state [%d]"), State());
|
|
758 |
SetTestStepResult(verdict);
|
|
759 |
StopScheduler();
|
|
760 |
break;
|
|
761 |
}
|
|
762 |
return (activate);
|
|
763 |
}
|
|
764 |
|
|
765 |
CBoundCLPushStep_8::CBoundCLPushStep_8()
|
|
766 |
{
|
|
767 |
}
|
|
768 |
CBoundCLPushStep_8::~CBoundCLPushStep_8()
|
|
769 |
{
|
|
770 |
}
|
|
771 |
TVerdict CBoundCLPushStep_8::doTestStepL()
|
|
772 |
/**
|
|
773 |
* @return - TVerdict code
|
|
774 |
* Wrong parameter values for Bound CL Push API:
|
|
775 |
* - Wrong TUid on construction
|
|
776 |
* - Connect to wrong bearer (already implemented in test 2)
|
|
777 |
*/
|
|
778 |
{
|
|
779 |
INFO_PRINTF1(_L("CreateImplementation with wrong Uid- CWapBoundCLPushService"));
|
|
780 |
if(TestStepResult() == EPass )
|
|
781 |
{
|
|
782 |
TInt error;
|
|
783 |
if(GetIntFromConfig(ConfigSection(),KWapExError2, error))
|
|
784 |
{
|
|
785 |
iExError2=error;
|
|
786 |
}
|
|
787 |
TInt trapValue;
|
|
788 |
|
|
789 |
TUid invalidInterfaceUid = {0x00000000};
|
|
790 |
|
|
791 |
INFO_PRINTF2(_L("Calling new NewL(0x%08X) method"), invalidInterfaceUid);
|
|
792 |
TRAP(trapValue, iImp = CWapBoundCLPushService::NewL(invalidInterfaceUid));
|
|
793 |
TVerdict verdict = (trapValue == iExError2)?EPass:EFail;
|
|
794 |
if (verdict==EPass)
|
|
795 |
{
|
|
796 |
INFO_PRINTF2(_L("CreateImplementation with wrong Uid- Failed as expected with error %d"),trapValue);
|
|
797 |
}
|
|
798 |
SetTestStepResult(verdict);
|
|
799 |
}
|
|
800 |
return TestStepResult();
|
|
801 |
}
|
|
802 |
TInt CBoundCLPushStep_8::CallStateMachine()
|
|
803 |
{
|
|
804 |
return (0);
|
|
805 |
}
|
|
806 |
|
|
807 |
CBoundCLPushStep_9::CBoundCLPushStep_9()
|
|
808 |
{
|
|
809 |
}
|
|
810 |
CBoundCLPushStep_9::~CBoundCLPushStep_9()
|
|
811 |
{
|
|
812 |
}
|
|
813 |
TVerdict CBoundCLPushStep_9::doTestStepL()
|
|
814 |
/**
|
|
815 |
* Test sending PDU data over UDP
|
|
816 |
* Test should be run concurently with CBoundCLPushStep_4 test. CBoundCLPushStep_4 waits for push message whilst
|
|
817 |
* CBoundCLPushStep_9 sends a push message over UDP using loopback.
|
|
818 |
* The test pair is used to test two cases (dependent on configuration read for CBoundCLPushStep_9):
|
|
819 |
* - sending PDU data that is smaller than the allocated buffer on the receiving side (<=1024)
|
|
820 |
* - sending PDU data that is larger than the allocated buffer on the receiving side and needs reallocation (>1024)
|
|
821 |
* @return - TVerdict code
|
|
822 |
*/
|
|
823 |
{
|
|
824 |
INFO_PRINTF1(_L("BOUND-CLPUSH: Sending Push Message"));
|
|
825 |
|
|
826 |
if(TestStepResult() == EPass )
|
|
827 |
{
|
|
828 |
User::After(20000000);
|
|
829 |
SetTestStepResult(EFail);
|
|
830 |
SetLastError(KErrNone);
|
|
831 |
TInt error = KErrNone;
|
|
832 |
/**
|
|
833 |
Getting information from config file
|
|
834 |
Local port
|
|
835 |
Remote port
|
|
836 |
Local address
|
|
837 |
Remote address
|
|
838 |
Size of data to be sent
|
|
839 |
*/
|
|
840 |
GetIntFromConfig(ConfigSection(),KLocalPort, iLclPort);
|
|
841 |
GetIntFromConfig(ConfigSection(),KRemotePort, iRmtPort);
|
|
842 |
TPtrC temp;
|
|
843 |
if(GetStringFromConfig(ConfigSection(),KWapLocalHost, temp))
|
|
844 |
{
|
|
845 |
error = iLocalAddr.Input(temp);
|
|
846 |
if(error)
|
|
847 |
{
|
|
848 |
User::Leave(error);
|
|
849 |
}
|
|
850 |
}
|
|
851 |
if(GetStringFromConfig(ConfigSection(),KWapRemoteHost, temp ))
|
|
852 |
{
|
|
853 |
error = iRemoteAddr.Input(temp);
|
|
854 |
if(error)
|
|
855 |
{
|
|
856 |
User::Leave(error);
|
|
857 |
}
|
|
858 |
}
|
|
859 |
// error = GetStringFromConfig(ConfigSection(),KWapData, temp);
|
|
860 |
|
|
861 |
RFs fS;
|
|
862 |
RFile file;
|
|
863 |
User::LeaveIfError(fS.Connect());
|
|
864 |
_LIT(KPduFilename,"z:\\testdata\\configs\\pushpdu.bin");
|
|
865 |
_LIT(KPDUDataSize,"Data_Size");
|
|
866 |
|
|
867 |
User::LeaveIfError(file.Open(fS, KPduFilename , EFileStream | EFileRead));
|
|
868 |
/* Read PDU from the file */
|
|
869 |
|
|
870 |
TInt dataSize(1024);
|
|
871 |
GetIntFromConfig(ConfigSection(),KPDUDataSize, dataSize);
|
|
872 |
iSendBuffPtr = HBufC8::NewL(dataSize);
|
|
873 |
TPtr8 tmpbuf = iSendBuffPtr->Des();
|
|
874 |
User::LeaveIfError(file.Read(tmpbuf));
|
|
875 |
|
|
876 |
file.Close();
|
|
877 |
fS.Close();
|
|
878 |
/**
|
|
879 |
Settings
|
|
880 |
*/
|
|
881 |
iLocalAddr.SetPort(iLclPort);
|
|
882 |
iRemoteAddr.SetPort(iRmtPort);
|
|
883 |
// iSendBuffPtr = HBufC8::NewL(temp.Length());
|
|
884 |
// TPtr8 tmp = iSendBuffPtr->Des();
|
|
885 |
// tmp.Copy(temp);
|
|
886 |
INFO_PRINTF2(_L("Sending PDU of size %d over UDP to a concurrent test... "), dataSize);
|
|
887 |
/**
|
|
888 |
socket server
|
|
889 |
*/
|
|
890 |
RSocketServ socketServer;
|
|
891 |
User::LeaveIfError(socketServer.Connect());
|
|
892 |
CleanupClosePushL(socketServer);
|
|
893 |
RSocket sock;
|
|
894 |
User::LeaveIfError(sock.Open(socketServer, KAfInet, KSockDatagram, KProtocolInetUdp));
|
|
895 |
CleanupClosePushL(sock);
|
|
896 |
TRequestStatus status;
|
|
897 |
sock.SendTo(iSendBuffPtr->Des(),iRemoteAddr , 0, status);
|
|
898 |
User::WaitForRequest(status);
|
|
899 |
INFO_PRINTF2(_L("Send Push Message - status = %d"), status.Int());
|
|
900 |
User::LeaveIfError(status.Int());
|
|
901 |
sock.Close();
|
|
902 |
socketServer.Close();
|
|
903 |
CleanupStack::PopAndDestroy(&sock);
|
|
904 |
CleanupStack::Pop(&socketServer);
|
|
905 |
TVerdict verdict = (status.Int() == KErrNone)?EPass:EFail;
|
|
906 |
SetTestStepResult(verdict);
|
|
907 |
}
|
|
908 |
return TestStepResult();
|
|
909 |
}
|
|
910 |
TInt CBoundCLPushStep_9::CallStateMachine()
|
|
911 |
{
|
|
912 |
return (0);
|
|
913 |
}
|
|
914 |
|
|
915 |
|
|
916 |
|
|
917 |
|