|
1 // Copyright (c) 2006-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 SubConnections.TestSteps.cpp |
|
18 */ |
|
19 |
|
20 |
|
21 #include <nifman.h> |
|
22 #include <cs_subconevents.h> |
|
23 |
|
24 #include "SubConnections.TestSteps.h" |
|
25 #include "SocketServer.TestSteps.h" |
|
26 #include "Connections.TestSteps.h" |
|
27 |
|
28 |
|
29 #ifdef _DEBUG |
|
30 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
31 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
32 _LIT(KSpecAssert_ESockTestSbCnctn, "ESockTestSbCnctn"); |
|
33 #endif |
|
34 |
|
35 |
|
36 // Create SubConnection |
|
37 //--------------------- |
|
38 |
|
39 CCreateRSubConnectionStep::CCreateRSubConnectionStep(CCEsockTestBase*& aEsockTest) |
|
40 : CTe_EsockStepBase(aEsockTest) |
|
41 { |
|
42 SetTestStepName(KCreateRSubConnectionStep); |
|
43 } |
|
44 |
|
45 TVerdict CCreateRSubConnectionStep::doTestStepPreambleL() |
|
46 { |
|
47 SetTestStepResult(EFail); |
|
48 |
|
49 if (iEsockTest==NULL) |
|
50 iEsockTest = new (ELeave) CCEsockTestBase; |
|
51 |
|
52 SetTestStepResult(EPass); |
|
53 return TestStepResult(); |
|
54 } |
|
55 |
|
56 TInt CCreateRSubConnectionStep::ConfigureFromIni() |
|
57 { |
|
58 iParams.Reset(); |
|
59 |
|
60 //try reading the next socket's name |
|
61 if (GetStringFromConfig(iSection,KTe_SubConnectionName,iParams.iSubConnectionName)!=1 |
|
62 || iParams.iSubConnectionName.Length()==0) |
|
63 return KErrNotFound; |
|
64 |
|
65 // All ok if we got this far |
|
66 return KErrNone; |
|
67 } |
|
68 |
|
69 TVerdict CCreateRSubConnectionStep::doSingleTestStep() |
|
70 { |
|
71 TInt error = iEsockTest->CreateSubConnection(iParams.iSubConnectionName); |
|
72 if (error!=KErrNone) |
|
73 { |
|
74 INFO_PRINTF2(_L("Could not create subconnection (%S)."),&iParams.iSubConnectionName); |
|
75 INFO_PRINTF2(_L("Error: %d."),error); |
|
76 return EFail; |
|
77 } |
|
78 return EPass; |
|
79 } |
|
80 |
|
81 |
|
82 // Open SubConnection |
|
83 //------------------- |
|
84 |
|
85 COpenRSubConnectionStep::COpenRSubConnectionStep(CCEsockTestBase*& aEsockTest) |
|
86 : CTe_EsockStepBase(aEsockTest) |
|
87 { |
|
88 SetTestStepName(KOpenRSubConnectionStep); |
|
89 } |
|
90 |
|
91 TInt COpenRSubConnectionStep::ConfigureFromIni() |
|
92 { |
|
93 iParams.Reset(); |
|
94 |
|
95 // Read in appropriate fields |
|
96 if((GetStringFromConfig(iSection, KTe_SubConnectionName, iParams.iSubConnectionName) != 1) |
|
97 || (iParams.iSubConnectionName.Length() == 0)) |
|
98 { |
|
99 INFO_PRINTF1(_L("Couldn't find appropriate field in config file")); |
|
100 return KErrNotFound; |
|
101 } |
|
102 |
|
103 if (GetStringFromConfig(iSection,KTe_SocketServName,iParams.iSockServName)!=1) |
|
104 { |
|
105 INFO_PRINTF2(_L("%S: Socket server name missing."),&iParams.iSubConnectionName); |
|
106 return KErrNotFound; |
|
107 } |
|
108 |
|
109 if (GetStringFromConfig(iSection,KTe_ConnectionName,iParams.iConnectionName)!=1) |
|
110 { |
|
111 INFO_PRINTF2(_L("%S: Connection name missing."),&iParams.iSubConnectionName); |
|
112 return KErrNotFound; |
|
113 } |
|
114 |
|
115 TPtrC subConnTypeName; |
|
116 if (GetStringFromConfig(iSection,KTe_SubConnectionTypeName,subConnTypeName)!=1) |
|
117 { |
|
118 INFO_PRINTF2(_L("%S: SubConnection type missing."),&iParams.iSubConnectionName); |
|
119 return KErrNotFound; |
|
120 } |
|
121 |
|
122 if (subConnTypeName.Compare(KTe_SubConnectionTypeAttach)==0) |
|
123 { iParams.iSubConnType = RSubConnection::EAttachToDefault; } |
|
124 else if (subConnTypeName.Compare(KTe_SubConnectionTypeNew)==0) |
|
125 { iParams.iSubConnType = RSubConnection::ECreateNew; } |
|
126 else |
|
127 { |
|
128 INFO_PRINTF3(_L("%S: SubConnection type (%S) not recognised."),&iParams.iSubConnectionName,&subConnTypeName); |
|
129 return KErrNotFound; |
|
130 } |
|
131 |
|
132 if (!GetIntFromConfig(iSection, KExpectedError, iExpectedError)) |
|
133 { |
|
134 iExpectedError = KErrNone; |
|
135 } |
|
136 |
|
137 else |
|
138 { |
|
139 INFO_PRINTF2(_L("Error to be expected: %d"),iExpectedError); |
|
140 } |
|
141 |
|
142 // All ok if we got this far |
|
143 return KErrNone; |
|
144 } |
|
145 |
|
146 TVerdict COpenRSubConnectionStep::doSingleTestStep() |
|
147 { |
|
148 TInt error = iEsockTest->OpenSubConnection(iParams); |
|
149 |
|
150 if (error!=KErrNone) |
|
151 { |
|
152 INFO_PRINTF2(_L("Could not open subconnection (%S)."),&iParams.iSubConnectionName); |
|
153 INFO_PRINTF2(_L("Error: %d."),error); |
|
154 } |
|
155 |
|
156 if (error!=iExpectedError) |
|
157 { |
|
158 INFO_PRINTF3(_L("Returned error (%d) differs from expected (%d)."), error, iExpectedError); |
|
159 return EFail; |
|
160 } |
|
161 |
|
162 return EPass; |
|
163 } |
|
164 |
|
165 |
|
166 // Open SubConnection (OOM) |
|
167 //------------------------- |
|
168 |
|
169 COpenRSubConnectionOOMStep::COpenRSubConnectionOOMStep(CCEsockTestBase*& aEsockTest) |
|
170 : CTe_EsockStepBase(aEsockTest) |
|
171 { |
|
172 SetTestStepName(KOpenRSubConnectionOOMStep); |
|
173 } |
|
174 |
|
175 TInt COpenRSubConnectionOOMStep::ConfigureFromIni() |
|
176 { |
|
177 iParams.Reset(); |
|
178 |
|
179 // Read in appropriate fields |
|
180 if((GetStringFromConfig(iSection, KTe_SubConnectionName, iParams.iSubConnectionName) != 1) |
|
181 || (iParams.iSubConnectionName.Length() == 0)) |
|
182 { |
|
183 INFO_PRINTF1(_L("Couldn't find appropriate field in config file")); |
|
184 return KErrNotFound; |
|
185 } |
|
186 |
|
187 if (GetStringFromConfig(iSection,KTe_SocketServName,iParams.iSockServName)!=1) |
|
188 { |
|
189 INFO_PRINTF2(_L("%S: Socket server name missing."),&iParams.iSubConnectionName); |
|
190 return KErrNotFound; |
|
191 } |
|
192 |
|
193 if (GetStringFromConfig(iSection,KTe_ConnectionName,iParams.iConnectionName)!=1) |
|
194 { |
|
195 INFO_PRINTF2(_L("%S: Connection name missing."),&iParams.iSubConnectionName); |
|
196 return KErrNotFound; |
|
197 } |
|
198 |
|
199 TPtrC subConnTypeName; |
|
200 if (GetStringFromConfig(iSection,KTe_SubConnectionTypeName,subConnTypeName)!=1) |
|
201 { |
|
202 INFO_PRINTF2(_L("%S: SubConnection type missing."),&iParams.iSubConnectionName); |
|
203 return KErrNotFound; |
|
204 } |
|
205 |
|
206 if (subConnTypeName.Compare(KTe_SubConnectionTypeAttach)==0) |
|
207 { iParams.iSubConnType = RSubConnection::EAttachToDefault; } |
|
208 else if (subConnTypeName.Compare(KTe_SubConnectionTypeNew)==0) |
|
209 { iParams.iSubConnType = RSubConnection::ECreateNew; } |
|
210 else |
|
211 { |
|
212 INFO_PRINTF3(_L("%S: SubConnection type (%S) not recognised."),&iParams.iSubConnectionName,&subConnTypeName); |
|
213 return KErrNotFound; |
|
214 } |
|
215 |
|
216 // All ok if we got this far |
|
217 return KErrNone; |
|
218 } |
|
219 |
|
220 TInt COpenRSubConnectionOOMStep::OpenSubConnectionOOM() |
|
221 { |
|
222 #ifndef _DEBUG |
|
223 return KErrNone; |
|
224 #else |
|
225 |
|
226 |
|
227 //disable idle timers for the duration of the test - they occassionally kick in. |
|
228 RConnection* c = iEsockTest->iConns.Find(iParams.iConnectionName); |
|
229 if (c==NULL) |
|
230 return KErrNotFound; |
|
231 TInt error = c->SetOpt(KCOLProvider, KConnDisableTimers, ETrue); |
|
232 if (error != KErrNone) |
|
233 return error; |
|
234 |
|
235 error = KErrNoMemory; |
|
236 for (TInt j = 1; !iEsockTest->__DbgCheckFailNext(iParams.iSockServName); j++) |
|
237 { |
|
238 iEsockTest->__DbgFailNext(iParams.iSockServName, j); |
|
239 iEsockTest->CloseSubConnection(iParams.iSubConnectionName); |
|
240 error = iEsockTest->OpenSubConnection(iParams); |
|
241 INFO_PRINTF3(_L("RSubCbconnection::Open() returned (%d) in OOM loop (%d)!.."),error, j); |
|
242 } |
|
243 iEsockTest->__DbgFailNext(iParams.iSockServName, -1); |
|
244 iEsockTest->CloseSubConnection(iParams.iSubConnectionName); |
|
245 |
|
246 //re-enable idle timers. |
|
247 error = c->SetOpt(KCOLProvider, KConnDisableTimers, EFalse); |
|
248 |
|
249 return error; |
|
250 |
|
251 #endif // _DEBUG |
|
252 } |
|
253 |
|
254 TVerdict COpenRSubConnectionOOMStep::doSingleTestStep() |
|
255 { |
|
256 TInt error = OpenSubConnectionOOM(); |
|
257 if (error!=KErrNone) |
|
258 { |
|
259 INFO_PRINTF2(_L("Could not open subconnection (%S)."),&iParams.iSubConnectionName); |
|
260 INFO_PRINTF2(_L("Error: %d."),error); |
|
261 return EFail; |
|
262 } |
|
263 return EPass; |
|
264 } |
|
265 |
|
266 |
|
267 // Close SubConnection |
|
268 //-------------------- |
|
269 |
|
270 CCloseRSubConnectionStep::CCloseRSubConnectionStep(CCEsockTestBase*& aEsockTest) |
|
271 : CTe_EsockStepBase(aEsockTest) |
|
272 { |
|
273 SetTestStepName(KCloseRSubConnectionStep); |
|
274 } |
|
275 |
|
276 TInt CCloseRSubConnectionStep::ConfigureFromIni() |
|
277 { |
|
278 iParams.Reset(); |
|
279 |
|
280 // Read in appropriate fields |
|
281 if((GetStringFromConfig(iSection, KTe_SubConnectionName, iParams.iSubConnectionName) != 1) |
|
282 || (iParams.iSubConnectionName.Length() == 0)) |
|
283 { |
|
284 INFO_PRINTF1(_L("Couldn't find appropriate field in config file")); |
|
285 return KErrNotFound; |
|
286 } |
|
287 |
|
288 // All ok if we got this far |
|
289 return KErrNone; |
|
290 } |
|
291 |
|
292 TVerdict CCloseRSubConnectionStep::doSingleTestStep() |
|
293 { |
|
294 TInt error = iEsockTest->CloseSubConnection(iParams.iSubConnectionName); |
|
295 if (error!=KErrNone) |
|
296 { |
|
297 INFO_PRINTF2(_L("Could not close subconnection (%S)."),&iParams.iSubConnectionName); |
|
298 INFO_PRINTF2(_L("Error: %d."),error); |
|
299 return EFail; |
|
300 } |
|
301 return EPass; |
|
302 } |
|
303 |
|
304 |
|
305 // Register for SubConnection Events |
|
306 //---------------------------------- |
|
307 |
|
308 CRegisterForRSubConnectionEventsStep::CRegisterForRSubConnectionEventsStep(CCEsockTestBase*& aEsockTest) |
|
309 : CTe_EsockStepBase(aEsockTest) |
|
310 { |
|
311 SetTestStepName(KRegisterForRSubConnectionEventsStep); |
|
312 } |
|
313 |
|
314 TInt CRegisterForRSubConnectionEventsStep::ConfigureFromIni() |
|
315 { |
|
316 //clean parameters from previous runs |
|
317 iParams.Reset(); |
|
318 |
|
319 //try reading the next event container's name |
|
320 if (GetStringFromConfig(iSection,KTe_SubConnectionEventsName,iParams.iEventName)!=1 |
|
321 || iParams.iEventName.Length()==0) |
|
322 return KErrNotFound; |
|
323 |
|
324 if (GetStringFromConfig(iSection,KTe_SubConnectionName,iParams.iSubConnectionName)!=1) |
|
325 { |
|
326 INFO_PRINTF2(_L("%S: Subconnection name missing."),&iParams.iEventName); |
|
327 return KErrNotFound; |
|
328 } |
|
329 |
|
330 TPtrC eventName; |
|
331 if (GetStringFromConfig(iSection,KTe_Register,eventName)==1) |
|
332 { |
|
333 //first check, maybe someone wants to register for all events? |
|
334 if (eventName.Compare(KTe_All)==0) |
|
335 { |
|
336 iParams.iAllEvents = ETrue; |
|
337 INFO_PRINTF2(_L("%S: Events to be registered: All"),&iParams.iEventName); |
|
338 return KErrNone; |
|
339 } |
|
340 //secondly, someone could be interested in the generic events only.. |
|
341 if (eventName.Compare(KTe_Generic)==0) |
|
342 { |
|
343 iParams.iGenericEvents = ETrue; |
|
344 INFO_PRINTF2(_L("%S: Events to be registered: Generic"),&iParams.iEventName); |
|
345 return KErrNone; |
|
346 } |
|
347 } |
|
348 |
|
349 //thirdly.. |
|
350 //go through the list of particular events to register. |
|
351 //there may be more than one expected event kind, register all of them |
|
352 TBool desciptionFound = ETrue; |
|
353 for (TInt idx = 0; desciptionFound; idx++) |
|
354 { |
|
355 TBuf<KMaxTestExecuteNameLength> fieldName(KTe_Register); |
|
356 fieldName.AppendNum(idx); |
|
357 if (GetStringFromConfig(iSection,fieldName,eventName)==1) |
|
358 { |
|
359 if (eventName.Compare(KTe_EventTypeParamsGranted)==0) |
|
360 { iParams.iEventMask |= KSubConGenericEventParamsGranted; } |
|
361 else if (eventName.Compare(KTe_EventTypeDataClientJoined)==0) |
|
362 { iParams.iEventMask |= KSubConGenericEventDataClientJoined; } |
|
363 else if (eventName.Compare(KTe_EventTypeDataClientLeft)==0) |
|
364 { iParams.iEventMask |= KSubConGenericEventDataClientLeft; } |
|
365 else if (eventName.Compare(KTe_EventTypeSubConDown)==0) |
|
366 { iParams.iEventMask |= KSubConGenericEventSubConDown; } |
|
367 else if (eventName.Compare(KTe_EventTypeParamsChanged)==0) |
|
368 { iParams.iEventMask |= KSubConGenericEventParamsChanged; } |
|
369 else if (eventName.Compare(KTe_EventTypeParamsRejected)==0) |
|
370 { iParams.iEventMask |= KSubConGenericEventParamsRejected; } |
|
371 else |
|
372 { |
|
373 INFO_PRINTF3(_L("%S: Event type (%S) not recognised."),&iParams.iEventName,&eventName); |
|
374 return KErrNotFound; |
|
375 } |
|
376 } |
|
377 else |
|
378 { |
|
379 //at least one event type must be present |
|
380 if (idx==0) |
|
381 { |
|
382 INFO_PRINTF2(_L("%S: Event type missing."),&iParams.iEventName); |
|
383 return KErrNotFound; |
|
384 } |
|
385 else |
|
386 { |
|
387 desciptionFound = EFalse; |
|
388 } |
|
389 } |
|
390 } |
|
391 |
|
392 INFO_PRINTF3(_L("%S: Events to be registered: 0x%x"),&iParams.iEventName,iParams.iEventMask); |
|
393 return KErrNone; |
|
394 } |
|
395 |
|
396 TVerdict CRegisterForRSubConnectionEventsStep::doSingleTestStep() |
|
397 { |
|
398 TInt error = iEsockTest->RegisterForRSubConnectionEvent(iParams); |
|
399 if (error!=KErrNone) |
|
400 { |
|
401 INFO_PRINTF2(_L("Could not register for rsubconnection events (%S)."),&iParams.iEventName); |
|
402 INFO_PRINTF2(_L("Error: %d"),error); |
|
403 return EFail; |
|
404 } |
|
405 |
|
406 return EPass; |
|
407 } |
|
408 |
|
409 |
|
410 // Check for SubConnection Events |
|
411 //------------------------------- |
|
412 |
|
413 CCheckRSubConnectionEventsStep::CCheckRSubConnectionEventsStep(CCEsockTestBase*& aEsockTest) |
|
414 : CTe_EsockStepBase(aEsockTest) |
|
415 { |
|
416 SetTestStepName(KCheckRSubConnectionEventsStep); |
|
417 } |
|
418 |
|
419 TInt CCheckRSubConnectionEventsStep::ConfigureFromIni() |
|
420 { |
|
421 iParams.Reset(); |
|
422 |
|
423 // Read in appropriate fields |
|
424 if((GetStringFromConfig(iSection, KTe_SubConnectionEventsName, iParams.iEventName) != 1) |
|
425 || (iParams.iEventName.Length() == 0)) |
|
426 { |
|
427 INFO_PRINTF1(_L("Couldn't find appropriate field in config file")); |
|
428 return KErrNotFound; |
|
429 } |
|
430 |
|
431 //there may be more than one expected event kind, register all of them |
|
432 TInt desciptionFound = ETrue; |
|
433 for (TInt idx = 0; desciptionFound; idx++) |
|
434 { |
|
435 TBuf<KMaxTestExecuteNameLength> fieldName(KTe_Expected); |
|
436 fieldName.AppendNum(idx); |
|
437 |
|
438 TPtrC eventName; |
|
439 if (GetStringFromConfig(iSection,fieldName,eventName)==1) |
|
440 { |
|
441 if (eventName.Compare(KTe_EventTypeParamsGranted)==0) |
|
442 { iParams.iEventMask |= KSubConGenericEventParamsGranted; } |
|
443 else if (eventName.Compare(KTe_EventTypeDataClientJoined)==0) |
|
444 { iParams.iEventMask |= KSubConGenericEventDataClientJoined; } |
|
445 else if (eventName.Compare(KTe_EventTypeDataClientLeft)==0) |
|
446 { iParams.iEventMask |= KSubConGenericEventDataClientLeft; } |
|
447 else if (eventName.Compare(KTe_EventTypeSubConDown)==0) |
|
448 { iParams.iEventMask |= KSubConGenericEventSubConDown; } |
|
449 else if (eventName.Compare(KTe_EventTypeParamsChanged)==0) |
|
450 { iParams.iEventMask |= KSubConGenericEventParamsChanged; } |
|
451 else if (eventName.Compare(KTe_EventTypeParamsRejected)==0) |
|
452 { iParams.iEventMask |= KSubConGenericEventParamsRejected; } |
|
453 else |
|
454 { |
|
455 INFO_PRINTF3(_L("%S: Event type (%S) not recognised."),&iParams.iEventName,&eventName); |
|
456 return KErrNotFound; |
|
457 } |
|
458 } |
|
459 else |
|
460 { |
|
461 //at least one event type must be present |
|
462 if (idx==0) |
|
463 { |
|
464 INFO_PRINTF2(_L("%S: Event name missing."),&iParams.iEventName); |
|
465 return KErrNotFound; |
|
466 } |
|
467 else |
|
468 { |
|
469 desciptionFound = EFalse; |
|
470 } |
|
471 } |
|
472 |
|
473 |
|
474 if (!GetIntFromConfig(iSection, KExpectedError, iExpectedError)) |
|
475 { |
|
476 iExpectedError = KExpectedErrorNotUsed; |
|
477 } |
|
478 |
|
479 } |
|
480 |
|
481 INFO_PRINTF3(_L("%S: Events to be expected: 0x%x"),&iParams.iEventName,iParams.iEventMask); |
|
482 |
|
483 if (iExpectedError != KExpectedErrorNotUsed) |
|
484 { |
|
485 INFO_PRINTF2(_L("Error to be expected: %d"),iExpectedError); |
|
486 } |
|
487 |
|
488 // All ok if we got this far |
|
489 return KErrNone; |
|
490 } |
|
491 |
|
492 |
|
493 TVerdict CCheckRSubConnectionEventsStep::doSingleTestStep() |
|
494 { |
|
495 // Need to test the initialisation of TNotificationEventBuf |
|
496 TNotificationEventBuf eventTest; |
|
497 |
|
498 if (eventTest.GroupId() != 0) |
|
499 { |
|
500 return EFail; |
|
501 } |
|
502 if (eventTest.Id() != 0) |
|
503 { |
|
504 return EFail; |
|
505 } |
|
506 |
|
507 TNotificationEventBuf* event = NULL; |
|
508 TInt err = KErrNone; |
|
509 |
|
510 |
|
511 TInt error = iEsockTest->ReceiveRSubConnectionEvent(event, iParams.iEventName); |
|
512 |
|
513 |
|
514 // CSubConNotificationEvent* setparaevent = CSubConNotificationEvent::NewL(*event); |
|
515 |
|
516 if (event == NULL) |
|
517 { |
|
518 INFO_PRINTF2(_L("%S: Did not receive any event!"),&iParams.iEventName); |
|
519 INFO_PRINTF2(_L("The error code returned was %d."),error); |
|
520 return EFail; |
|
521 } |
|
522 |
|
523 |
|
524 TInt eventId = event->Id(); |
|
525 CSubConNotificationEvent* setparaevent; |
|
526 if (eventId == KSubConGenericEventParamsGranted ) |
|
527 { |
|
528 setparaevent = CSubConNotificationEvent::NewL(*event); |
|
529 __ASSERT_DEBUG(setparaevent->IsGeneric(), User::Panic(KSpecAssert_ESockTestSbCnctn, 1)); |
|
530 INFO_PRINTF1(_L("Received event: KSubConGenericEventParamsGranted")); |
|
531 } |
|
532 else if (eventId == KSubConGenericEventDataClientJoined ) |
|
533 { |
|
534 setparaevent = CSubConNotificationEvent::NewL(*event); |
|
535 __ASSERT_DEBUG(setparaevent->IsGeneric(), User::Panic(KSpecAssert_ESockTestSbCnctn, 2)); |
|
536 INFO_PRINTF1(_L("Received event: KSubConGenericEventDataClientJoined")); |
|
537 } |
|
538 else if (eventId == KSubConGenericEventDataClientLeft ) |
|
539 { |
|
540 setparaevent = CSubConNotificationEvent::NewL(*event); |
|
541 __ASSERT_DEBUG(setparaevent->IsGeneric(), User::Panic(KSpecAssert_ESockTestSbCnctn, 3)); |
|
542 INFO_PRINTF1(_L("Received event: KSubConGenericEventDataClientLeft")); |
|
543 } |
|
544 else if (eventId == KSubConGenericEventSubConDown ) |
|
545 { |
|
546 setparaevent = CSubConNotificationEvent::NewL(*event); |
|
547 __ASSERT_DEBUG(setparaevent->IsGeneric(), User::Panic(KSpecAssert_ESockTestSbCnctn, 4)); |
|
548 INFO_PRINTF1(_L("Received event: KSubConGenericEventSubConDown")); |
|
549 } |
|
550 else if (eventId == KSubConGenericEventParamsChanged ) |
|
551 { |
|
552 setparaevent = CSubConNotificationEvent::NewL(*event); |
|
553 __ASSERT_DEBUG(setparaevent->IsGeneric(), User::Panic(KSpecAssert_ESockTestSbCnctn, 5)); |
|
554 INFO_PRINTF1(_L("Received event: KSubConGenericEventParamsChanged")); |
|
555 } |
|
556 else if (eventId == KSubConGenericEventParamsRejected ) |
|
557 { |
|
558 setparaevent = CSubConNotificationEvent::NewL(*event); |
|
559 __ASSERT_DEBUG(setparaevent->IsGeneric(), User::Panic(KSpecAssert_ESockTestSbCnctn, 6)); |
|
560 CSubConGenEventParamsRejected* eventreason = static_cast<CSubConGenEventParamsRejected*>(setparaevent); |
|
561 err = eventreason->Error(); |
|
562 INFO_PRINTF1(_L("Received event: KSubConGenericEventParamsRejected")); |
|
563 } |
|
564 else |
|
565 { |
|
566 INFO_PRINTF2(_L("Received event: Unknown (%d)"),eventId); |
|
567 } |
|
568 |
|
569 delete setparaevent; |
|
570 if ((eventId & iParams.iEventMask) == 0) |
|
571 { |
|
572 INFO_PRINTF2(_L("Did not receive an expected event with %S."),&iParams.iEventName); |
|
573 return EFail; |
|
574 } |
|
575 |
|
576 |
|
577 if(iExpectedError != err && iExpectedError < KExpectedErrorNotUsed) |
|
578 { |
|
579 INFO_PRINTF3(_L("Expected Error %d does not match returned Error %d"), iExpectedError, err); |
|
580 return EFail; |
|
581 } |
|
582 |
|
583 else if (iExpectedError != KExpectedErrorNotUsed) |
|
584 { |
|
585 INFO_PRINTF3(_L("Expected Error %d matched returned Error %d"), iExpectedError, err); |
|
586 } |
|
587 |
|
588 |
|
589 return EPass; |
|
590 } |
|
591 |
|
592 |
|
593 // Control SubConnection |
|
594 //---------------------- |
|
595 |
|
596 CControlRSubConnectionStep::CControlRSubConnectionStep(CCEsockTestBase*& aEsockTest) |
|
597 : CTe_EsockStepBase(aEsockTest) |
|
598 { |
|
599 SetTestStepName(KControlRSubConnectionStep); |
|
600 } |
|
601 |
|
602 TInt CControlRSubConnectionStep::ConfigureFromIni() |
|
603 { |
|
604 iParams.Reset(); |
|
605 |
|
606 // All ok if we got this far |
|
607 return KErrNone; |
|
608 } |
|
609 |
|
610 TVerdict CControlRSubConnectionStep::doSingleTestStep() |
|
611 { |
|
612 return TestStepResult(); |
|
613 } |
|
614 |
|
615 |
|
616 // Enumerate subconnections |
|
617 //------------------------- |
|
618 |
|
619 CEnumerateSubConnectionsStep::CEnumerateSubConnectionsStep(CCEsockTestBase*& aEsockTest) |
|
620 : CTe_EsockStepBase(aEsockTest) |
|
621 { |
|
622 SetTestStepName(KEnumerateSubConnectionsStep); |
|
623 } |
|
624 |
|
625 TInt CEnumerateSubConnectionsStep::ConfigureFromIni() |
|
626 { |
|
627 // Read in appropriate fields |
|
628 if((GetStringFromConfig(iSection, KTe_ConnectionName, iParams.iConnectionName) != 1) |
|
629 || (iParams.iConnectionName.Length() == 0)) |
|
630 { |
|
631 INFO_PRINTF2(KErrString_MissingConfigFileField, &KTe_ConnectionName); |
|
632 return KErrNotFound; |
|
633 } |
|
634 |
|
635 // Get the expected connection count to validate against |
|
636 if(GetIntFromConfig(iSection, KExpectedSubConnectionCount, iParams.iExpectedSubConnCount) != 1) |
|
637 { |
|
638 INFO_PRINTF2(KErrString_MissingConfigFileField, &KExpectedSubConnectionCount); |
|
639 return KErrNotFound; |
|
640 } |
|
641 |
|
642 // All ok if we got this far |
|
643 return KErrNone; |
|
644 } |
|
645 |
|
646 TVerdict CEnumerateSubConnectionsStep::doSingleTestStep() |
|
647 { |
|
648 TUint subConnectionCount; |
|
649 |
|
650 // Find the connection to apply the enumerate call to |
|
651 RConnection* connection = iEsockTest->FindConnection(iParams.iConnectionName); |
|
652 |
|
653 // Enumerate the current connection count |
|
654 if(connection) |
|
655 { |
|
656 // Fetch the connection count |
|
657 TInt err = connection->EnumerateSubConnections(subConnectionCount); |
|
658 |
|
659 if (err != KErrNone) |
|
660 { |
|
661 INFO_PRINTF2(_L("Error when enumerating connections (%d)."), &err); |
|
662 return EFail; |
|
663 } |
|
664 |
|
665 // Compare the connection count with that expected |
|
666 if (subConnectionCount == iParams.iExpectedSubConnCount) |
|
667 { |
|
668 INFO_PRINTF3(_L("Current subconnection count (%d) equal to that expected (%d)."), &subConnectionCount, &iParams.iExpectedSubConnCount); |
|
669 } |
|
670 else |
|
671 { |
|
672 INFO_PRINTF3(_L("Current subconnection count (%d) not equal to expected count. (%d)"), &subConnectionCount, &iParams.iExpectedSubConnCount); |
|
673 return EFail; |
|
674 } |
|
675 } |
|
676 else |
|
677 { |
|
678 INFO_PRINTF2(_L("Could not find connection (%S)."), &iParams.iConnectionName); |
|
679 return EFail; |
|
680 } |
|
681 |
|
682 // Test passed if we got this far |
|
683 return EPass; |
|
684 } |
|
685 |
|
686 |
|
687 |