|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <ss_glob.h> |
|
19 #include <comms-infras/ss_nodemessages_factory.h> |
|
20 #include <comms-infras/ss_nodemessages_dataclient.h> |
|
21 //#include <elements/nm_messages_child.h> |
|
22 |
|
23 #include "pudpclienttests.h" |
|
24 #include "upnp_cf_msgs.h" |
|
25 #include "upnpflowbase.h" |
|
26 #include "upnpflowfactory.h" |
|
27 #include "httpudpflow.h" |
|
28 |
|
29 //const TUint16 KActivityNull = 0; |
|
30 |
|
31 //Add Blocks of 64 |
|
32 static const TInt KBlockSize1 = 64; |
|
33 static const TInt KMinGrowth1 = 30; |
|
34 static const TInt KThresholdGrowth1 = 30; |
|
35 static const TInt KInitialAllocation1 = 128; |
|
36 |
|
37 static const TInt KHeapSize = 1024 * 1024; //1MB |
|
38 |
|
39 using namespace Messages; |
|
40 |
|
41 |
|
42 //------------------------------------------------------------------------------------------------- |
|
43 // CUdpClientTestBase |
|
44 //------------------------------------------------------------------------------------------------- |
|
45 |
|
46 #define BEGIN_TESTLIST |
|
47 |
|
48 #define ADD_TEST(name) \ |
|
49 if (aTestName == _L(#name))\ |
|
50 {\ |
|
51 return CUdpClient ## name::NewL(aProvd);\ |
|
52 } |
|
53 |
|
54 #define END_TESTLIST \ |
|
55 User::Leave(KErrNotSupported);\ |
|
56 return NULL; |
|
57 |
|
58 CUdpClientTestBase* CUdpClientTestBase::CreateTestL(const TDesC& aTestName, CProxyProvd* aProvd) |
|
59 { |
|
60 BEGIN_TESTLIST |
|
61 ADD_TEST(TestUPnP) |
|
62 ADD_TEST(TestUPnP1) |
|
63 ADD_TEST(TestUPnP2) |
|
64 ADD_TEST(TestUPnP3) |
|
65 ADD_TEST(TestUPnP4) |
|
66 ADD_TEST(TestUPnP5) |
|
67 ADD_TEST(TestUPnP6) |
|
68 ADD_TEST(TestUPnP7) |
|
69 ADD_TEST(TestUPnP8) |
|
70 ADD_TEST(TestUPnP9) |
|
71 ADD_TEST(TestUPnP10) |
|
72 ADD_TEST(TestUPnP11) |
|
73 ADD_TEST(TestUPnP12) |
|
74 |
|
75 END_TESTLIST |
|
76 } |
|
77 |
|
78 |
|
79 void CUdpClientTestBase::StartTestL(const TDesC& aTestName, CProxyProvd* aProvd) |
|
80 { |
|
81 CUdpClientTestBase* test = CreateTestL(aTestName,aProvd); |
|
82 CleanupStack::PushL(test); |
|
83 test->CUdpClientTestBase::ConstructL(); |
|
84 CActiveScheduler::Add(test); |
|
85 CleanupStack::Pop(test); |
|
86 TRequestStatus* stat = &test->iStatus; |
|
87 test->SetActive(); |
|
88 User::RequestComplete(stat,KErrNone); |
|
89 } |
|
90 |
|
91 CUdpClientTestBase::CUdpClientTestBase(CProxyProvd* aProvd) : |
|
92 CActive(EPriorityNormal), |
|
93 iProvd(aProvd) |
|
94 {} |
|
95 |
|
96 void CUdpClientTestBase::ConstructL() |
|
97 { |
|
98 //Create the Chunk Manager |
|
99 CChunkManager* chkmgr = CChunkManager::NewL ( KHeapSize ); |
|
100 if ( chkmgr ) |
|
101 { |
|
102 chkmgr->AddPoolL ( KBlockSize1, KInitialAllocation1, KMinGrowth1, KThresholdGrowth1 ); |
|
103 } |
|
104 |
|
105 iChunkManager = chkmgr; |
|
106 iAllocator.SetChunkManager(iChunkManager); |
|
107 SetLoggerL(); |
|
108 } |
|
109 |
|
110 CUdpClientTestBase::~CUdpClientTestBase() |
|
111 { |
|
112 iLogger.Close(); |
|
113 delete iChunkManager; |
|
114 } |
|
115 |
|
116 /** Override this function if you want cleanup to happen before the completion of |
|
117 the test case. This function is called before the test is completed |
|
118 */ |
|
119 void CUdpClientTestBase::Cleanup() |
|
120 {} |
|
121 |
|
122 /** Sets the test case as active again and prevents the object from being destroyed |
|
123 when the RunL completes. |
|
124 |
|
125 Note: The active object is not complete the request again automatically, if this behaviour is |
|
126 desired the user must call User::RequestComplete |
|
127 */ |
|
128 void CUdpClientTestBase::Reschedule() |
|
129 { |
|
130 SetActive(); |
|
131 iReschedule = TRUE; |
|
132 } |
|
133 |
|
134 void CUdpClientTestBase::CompleteSelf ( TInt aError ) |
|
135 { |
|
136 TRequestStatus* pStat = &iStatus; |
|
137 User::RequestComplete ( pStat, aError ); |
|
138 } |
|
139 |
|
140 /** Attaches the iLogger variable to the TestExecute Log Server. This enable this prt to write to |
|
141 the testexecute logs as if it were running directly from TestExecute |
|
142 */ |
|
143 // SetLoggerL() is taken directly from CTestServer::StartLoggerL() in the TEF src TestServerBase.Cpp |
|
144 |
|
145 |
|
146 void CUdpClientTestBase::SetLoggerL() |
|
147 { |
|
148 // Create a cinidata object for parsing the testexecute.ini |
|
149 CTestExecuteIniData* parseTestExecuteIni = NULL; |
|
150 TBuf<KMaxTestExecuteNameLength> resultFilePath; |
|
151 TBuf<KMaxTestExecuteNameLength> xmlFilePath; |
|
152 TInt logMode; |
|
153 TInt logLevel; |
|
154 |
|
155 TRAPD(err,parseTestExecuteIni = CTestExecuteIniData::NewL()); |
|
156 if (err == KErrNone) |
|
157 { |
|
158 CleanupStack::PushL(parseTestExecuteIni); |
|
159 parseTestExecuteIni->ExtractValuesFromIni(); |
|
160 parseTestExecuteIni->GetKeyValueFromIni(KTEFHtmlKey, resultFilePath); |
|
161 parseTestExecuteIni->GetKeyValueFromIni(KTEFXmlKey, xmlFilePath); |
|
162 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogMode, logMode); |
|
163 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogSeverityKey, logLevel); |
|
164 } |
|
165 else |
|
166 { |
|
167 resultFilePath.Copy(KTestExecuteLogPath); |
|
168 xmlFilePath.Copy(KTestExecuteLogPath); |
|
169 logMode = TLoggerOptions(ELogHTMLOnly); |
|
170 logLevel = RFileFlogger::TLogSeverity(ESevrAll); |
|
171 } |
|
172 Logger().SetLoggerOptions(logMode); |
|
173 |
|
174 // Initialise a handle to the file logger |
|
175 User::LeaveIfError(Logger().Connect()); |
|
176 RFs fS; |
|
177 User::LeaveIfError(fS.Connect()); |
|
178 CleanupClosePushL(fS); |
|
179 RFile file; |
|
180 TBuf<KMaxTestExecuteNameLength> xmlLogFile(xmlFilePath); |
|
181 TBuf<KMaxTestExecuteNameLength> logFile; |
|
182 TBuf<KMaxTestExecuteNameLength> logFileNameFile(resultFilePath); |
|
183 logFileNameFile.Append(KTestExecuteScheduleTestLogCompatibilityNameFile); |
|
184 if(file.Open(fS,logFileNameFile,EFileRead | EFileShareAny) != KErrNone) |
|
185 { |
|
186 // For the old flogger we have to create an individual file |
|
187 _LIT(KTxtLog,"TEIntSock.txt"); |
|
188 logFile.Copy(KTxtLog); |
|
189 logMode = TLoggerOptions(0); |
|
190 Logger().SetLoggerOptions(logMode); |
|
191 } |
|
192 else |
|
193 { |
|
194 CleanupClosePushL(file); |
|
195 TBuf8<KMaxTestExecuteNameLength> logFile8; |
|
196 TInt fileSize; |
|
197 User::LeaveIfError(file.Size(fileSize)); |
|
198 User::LeaveIfError(file.Read(logFile8,fileSize)); |
|
199 logFile.Copy(logFile8); |
|
200 xmlLogFile.Append(logFile); |
|
201 _LIT(KXmlExtension,".xml"); |
|
202 xmlLogFile.Append(KXmlExtension); |
|
203 _LIT(KHtmExtension,".htm"); |
|
204 logFile.Append(KHtmExtension); |
|
205 CleanupStack::Pop(&file); |
|
206 file.Close(); |
|
207 } |
|
208 TBuf<KMaxTestExecuteLogFilePath> logFilePath(resultFilePath); |
|
209 logFilePath.Append(logFile); |
|
210 CleanupStack::Pop(&fS); |
|
211 fS.Close(); |
|
212 |
|
213 if (logMode == 0 || logMode == 2) |
|
214 { |
|
215 User::LeaveIfError(Logger().HtmlLogger().CreateLog(logFilePath, RTestExecuteLogServ::ELogModeAppend)); |
|
216 } |
|
217 if (logMode == 1 || logMode == 2) |
|
218 { |
|
219 User::LeaveIfError(Logger().XmlLogger().CreateLog(xmlLogFile,RFileFlogger::ELogModeAppend)); |
|
220 Logger().XmlLogger().SetLogLevel(RFileFlogger::TLogSeverity(logLevel)); |
|
221 } |
|
222 if (parseTestExecuteIni != NULL) |
|
223 { |
|
224 CleanupStack::PopAndDestroy(parseTestExecuteIni); |
|
225 } |
|
226 } |
|
227 |
|
228 |
|
229 |
|
230 /** Called by the active scheduler in order to run the test |
|
231 */ |
|
232 void CUdpClientTestBase::RunL() |
|
233 { |
|
234 iReschedule = EFalse; |
|
235 TVerdict res = RunTestL(); |
|
236 if (!iReschedule) |
|
237 { |
|
238 Cleanup(); |
|
239 FinishTest(res); |
|
240 delete this; |
|
241 return; |
|
242 } |
|
243 } |
|
244 |
|
245 void CUdpClientTestBase::FinishTest(TVerdict aResult) |
|
246 { |
|
247 iProvd->TestComplete(aResult); |
|
248 } |
|
249 |
|
250 void CUdpClientTestBase::DoCancel() |
|
251 { |
|
252 Cleanup(); |
|
253 } |
|
254 |
|
255 //------------------------------------------------------------// |
|
256 /////////////////// CUdpClientTestUPnP ///////////////////////// |
|
257 ////// Testcase: Send the test data from the test client///////// |
|
258 //------------------------------------------------------------// |
|
259 |
|
260 CUdpClientTestUPnP* CUdpClientTestUPnP::NewL ( CProxyProvd* aProvd ) |
|
261 { |
|
262 CUdpClientTestUPnP* ret = new ( ELeave ) CUdpClientTestUPnP ( aProvd ); |
|
263 CleanupStack::PushL ( ret ); |
|
264 ret->ConstructL (); |
|
265 CleanupStack::Pop ( ret ); |
|
266 return ret; |
|
267 } |
|
268 |
|
269 CUdpClientTestUPnP::CUdpClientTestUPnP ( CProxyProvd* aProvd ) : |
|
270 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
271 { |
|
272 } |
|
273 |
|
274 CUdpClientTestUPnP::~CUdpClientTestUPnP () |
|
275 { |
|
276 iTimer.Close (); |
|
277 } |
|
278 |
|
279 void CUdpClientTestUPnP::ConstructL() |
|
280 { |
|
281 iTimer.CreateLocal (); |
|
282 } |
|
283 |
|
284 TVerdict CUdpClientTestUPnP::RunTestL() |
|
285 {//This part of the class creates a dummy server and client |
|
286 //The client sends a m-search request to the server |
|
287 //and the server responds with a Discovery Responses...this is the point where the test cases come into play |
|
288 //every test case send an invalid request to the client using udpflow |
|
289 //the client validates these responses |
|
290 const TUint16 KActivityNull = 0; |
|
291 switch ( iState ) |
|
292 { |
|
293 case ECreateTestServer: |
|
294 { |
|
295 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
296 |
|
297 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
298 |
|
299 iState = ECreateTestClient; |
|
300 iStatus = KRequestPending; |
|
301 Reschedule(); |
|
302 return EPass; |
|
303 } |
|
304 |
|
305 case ECreateTestClient: |
|
306 { |
|
307 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
308 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
309 |
|
310 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
311 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
312 |
|
313 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
314 |
|
315 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
316 |
|
317 iState = ESendRequestData; |
|
318 iStatus = KRequestPending; |
|
319 Reschedule(); |
|
320 return EPass; |
|
321 } |
|
322 |
|
323 case ESendRequestData: |
|
324 { |
|
325 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
326 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
327 |
|
328 RMemChunk st; |
|
329 st.CreateL ( KTestCase1, iAllocator ); //KTestCase1 = "testcase1" |
|
330 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
331 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
332 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
333 |
|
334 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
335 |
|
336 iState = ECleanup; |
|
337 iStatus = KRequestPending; |
|
338 Reschedule (); |
|
339 return EPass; |
|
340 } |
|
341 |
|
342 case ECleanup: |
|
343 { |
|
344 delete iTestServer; |
|
345 // cleanup udp client flow |
|
346 TEChild::TDestroy msg; |
|
347 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
348 return EPass; |
|
349 } |
|
350 |
|
351 case EFailed: |
|
352 { |
|
353 delete iTestServer; |
|
354 // cleanup udp client flow |
|
355 TEChild::TDestroy msg; |
|
356 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
357 |
|
358 FinishTest ( EFail ); |
|
359 delete this; |
|
360 return EFail; |
|
361 } |
|
362 |
|
363 default: |
|
364 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
365 ASSERT(0); |
|
366 return EFail; |
|
367 } |
|
368 } |
|
369 |
|
370 void CUdpClientTestUPnP::OnTestServerEventL ( TInt aError ) |
|
371 { |
|
372 CompleteSelf ( aError ); |
|
373 } |
|
374 |
|
375 void CUdpClientTestUPnP::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
376 { |
|
377 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
378 { |
|
379 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
380 iClientId = msg.iNodeId; |
|
381 CompleteSelf ( KErrNone ); |
|
382 } |
|
383 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
384 { |
|
385 iTimer.Cancel (); |
|
386 iState = EFailed; |
|
387 RunTestL (); |
|
388 } |
|
389 } |
|
390 |
|
391 |
|
392 CUdpClientTestUPnP1* CUdpClientTestUPnP1::NewL ( CProxyProvd* aProvd ) |
|
393 { |
|
394 CUdpClientTestUPnP1* ret = new ( ELeave ) CUdpClientTestUPnP1 ( aProvd ); |
|
395 CleanupStack::PushL ( ret ); |
|
396 ret->ConstructL (); |
|
397 CleanupStack::Pop ( ret ); |
|
398 return ret; |
|
399 } |
|
400 |
|
401 CUdpClientTestUPnP1::CUdpClientTestUPnP1 ( CProxyProvd* aProvd ) : |
|
402 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
403 { |
|
404 } |
|
405 |
|
406 CUdpClientTestUPnP1::~CUdpClientTestUPnP1 () |
|
407 { |
|
408 iTimer.Close (); |
|
409 } |
|
410 |
|
411 void CUdpClientTestUPnP1::ConstructL() |
|
412 { |
|
413 iTimer.CreateLocal (); |
|
414 } |
|
415 |
|
416 TVerdict CUdpClientTestUPnP1::RunTestL() |
|
417 { |
|
418 const TUint16 KActivityNull = 0; |
|
419 switch ( iState ) |
|
420 { |
|
421 case ECreateTestServer: |
|
422 { |
|
423 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
424 |
|
425 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
426 |
|
427 iState = ECreateTestClient; |
|
428 iStatus = KRequestPending; |
|
429 Reschedule(); |
|
430 return EPass; |
|
431 } |
|
432 |
|
433 case ECreateTestClient: |
|
434 { |
|
435 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
436 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
437 |
|
438 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
439 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
440 |
|
441 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
442 |
|
443 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
444 |
|
445 iState = ESendRequestData; |
|
446 iStatus = KRequestPending; |
|
447 Reschedule(); |
|
448 return EPass; |
|
449 } |
|
450 |
|
451 case ESendRequestData: |
|
452 { |
|
453 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
454 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
455 |
|
456 RMemChunk st; |
|
457 st.CreateL ( KTestCase2, iAllocator ); //KTestCase2 = "testcase2" |
|
458 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
459 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
460 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
461 |
|
462 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
463 |
|
464 iState = ECleanup; |
|
465 iStatus = KRequestPending; |
|
466 Reschedule (); |
|
467 return EPass; |
|
468 } |
|
469 |
|
470 case ECleanup: |
|
471 { |
|
472 delete iTestServer; |
|
473 // cleanup udp client flow |
|
474 TEChild::TDestroy msg; |
|
475 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
476 |
|
477 return EPass; |
|
478 } |
|
479 |
|
480 case EFailed: |
|
481 { |
|
482 delete iTestServer; |
|
483 // cleanup udp client flow |
|
484 TEChild::TDestroy msg; |
|
485 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
486 |
|
487 FinishTest ( EFail ); |
|
488 delete this; |
|
489 return EFail; |
|
490 } |
|
491 |
|
492 default: |
|
493 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
494 ASSERT(0); |
|
495 return EFail; |
|
496 } |
|
497 } |
|
498 |
|
499 void CUdpClientTestUPnP1::OnTestServerEventL ( TInt aError ) |
|
500 { |
|
501 CompleteSelf ( aError ); |
|
502 } |
|
503 |
|
504 void CUdpClientTestUPnP1::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
505 { |
|
506 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
507 { |
|
508 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
509 iClientId = msg.iNodeId; |
|
510 CompleteSelf ( KErrNone ); |
|
511 } |
|
512 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
513 { |
|
514 iTimer.Cancel (); |
|
515 iState = EFailed; |
|
516 RunTestL (); |
|
517 } |
|
518 } |
|
519 |
|
520 |
|
521 |
|
522 //--------------------------------------------------------------------------------------------------------------------------------- |
|
523 |
|
524 |
|
525 |
|
526 CUdpClientTestUPnP2* CUdpClientTestUPnP2::NewL ( CProxyProvd* aProvd ) |
|
527 { |
|
528 CUdpClientTestUPnP2* ret = new ( ELeave ) CUdpClientTestUPnP2 ( aProvd ); |
|
529 CleanupStack::PushL ( ret ); |
|
530 ret->ConstructL (); |
|
531 CleanupStack::Pop ( ret ); |
|
532 return ret; |
|
533 } |
|
534 |
|
535 CUdpClientTestUPnP2::CUdpClientTestUPnP2 ( CProxyProvd* aProvd ) : |
|
536 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
537 { |
|
538 } |
|
539 |
|
540 CUdpClientTestUPnP2::~CUdpClientTestUPnP2 () |
|
541 { |
|
542 iTimer.Close (); |
|
543 } |
|
544 |
|
545 void CUdpClientTestUPnP2::ConstructL() |
|
546 { |
|
547 iTimer.CreateLocal (); |
|
548 } |
|
549 |
|
550 TVerdict CUdpClientTestUPnP2::RunTestL() |
|
551 { |
|
552 const TUint16 KActivityNull = 0; |
|
553 switch ( iState ) |
|
554 { |
|
555 case ECreateTestServer: |
|
556 { |
|
557 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
558 |
|
559 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
560 |
|
561 iState = ECreateTestClient; |
|
562 iStatus = KRequestPending; |
|
563 Reschedule(); |
|
564 return EPass; |
|
565 } |
|
566 |
|
567 case ECreateTestClient: |
|
568 { |
|
569 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
570 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
571 |
|
572 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
573 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
574 |
|
575 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
576 |
|
577 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
578 |
|
579 iState = ESendRequestData; |
|
580 iStatus = KRequestPending; |
|
581 Reschedule(); |
|
582 return EPass; |
|
583 } |
|
584 |
|
585 case ESendRequestData: |
|
586 { |
|
587 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
588 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
589 |
|
590 RMemChunk st; |
|
591 st.CreateL ( KTestCase3, iAllocator ); //KTestCase2 = "testcase2" |
|
592 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
593 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
594 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
595 |
|
596 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
597 |
|
598 iState = ECleanup; |
|
599 iStatus = KRequestPending; |
|
600 Reschedule (); |
|
601 return EPass; |
|
602 } |
|
603 |
|
604 case ECleanup: |
|
605 { |
|
606 delete iTestServer; |
|
607 // cleanup udp client flow |
|
608 TEChild::TDestroy msg; |
|
609 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
610 |
|
611 return EPass; |
|
612 } |
|
613 |
|
614 case EFailed: |
|
615 { |
|
616 delete iTestServer; |
|
617 // cleanup udp client flow |
|
618 TEChild::TDestroy msg; |
|
619 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
620 |
|
621 FinishTest ( EFail ); |
|
622 delete this; |
|
623 return EFail; |
|
624 } |
|
625 |
|
626 default: |
|
627 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
628 ASSERT(0); |
|
629 return EFail; |
|
630 } |
|
631 } |
|
632 |
|
633 void CUdpClientTestUPnP2::OnTestServerEventL ( TInt aError ) |
|
634 { |
|
635 CompleteSelf ( aError ); |
|
636 } |
|
637 |
|
638 void CUdpClientTestUPnP2::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
639 { |
|
640 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
641 { |
|
642 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
643 iClientId = msg.iNodeId; |
|
644 CompleteSelf ( KErrNone ); |
|
645 } |
|
646 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
647 { |
|
648 iTimer.Cancel (); |
|
649 iState = EFailed; |
|
650 RunTestL (); |
|
651 } |
|
652 } |
|
653 |
|
654 |
|
655 //--------------------------------------------------------------------------------------------------------------------------------- |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 CUdpClientTestUPnP3* CUdpClientTestUPnP3::NewL ( CProxyProvd* aProvd ) |
|
661 { |
|
662 CUdpClientTestUPnP3* ret = new ( ELeave ) CUdpClientTestUPnP3 ( aProvd ); |
|
663 CleanupStack::PushL ( ret ); |
|
664 ret->ConstructL (); |
|
665 CleanupStack::Pop ( ret ); |
|
666 return ret; |
|
667 } |
|
668 |
|
669 CUdpClientTestUPnP3::CUdpClientTestUPnP3 ( CProxyProvd* aProvd ) : |
|
670 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
671 { |
|
672 } |
|
673 |
|
674 CUdpClientTestUPnP3::~CUdpClientTestUPnP3 () |
|
675 { |
|
676 iTimer.Close (); |
|
677 } |
|
678 |
|
679 void CUdpClientTestUPnP3::ConstructL() |
|
680 { |
|
681 iTimer.CreateLocal (); |
|
682 } |
|
683 |
|
684 TVerdict CUdpClientTestUPnP3::RunTestL() |
|
685 { |
|
686 const TUint16 KActivityNull = 0; |
|
687 switch ( iState ) |
|
688 { |
|
689 case ECreateTestServer: |
|
690 { |
|
691 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
692 |
|
693 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
694 |
|
695 iState = ECreateTestClient; |
|
696 iStatus = KRequestPending; |
|
697 Reschedule(); |
|
698 return EPass; |
|
699 } |
|
700 |
|
701 case ECreateTestClient: |
|
702 { |
|
703 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
704 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
705 |
|
706 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
707 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
708 |
|
709 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
710 |
|
711 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
712 |
|
713 iState = ESendRequestData; |
|
714 iStatus = KRequestPending; |
|
715 Reschedule(); |
|
716 return EPass; |
|
717 } |
|
718 |
|
719 case ESendRequestData: |
|
720 { |
|
721 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
722 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
723 |
|
724 RMemChunk st; |
|
725 st.CreateL ( KTestCase4, iAllocator ); //KTestCase2 = "testcase2" |
|
726 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
727 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
728 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
729 |
|
730 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
731 |
|
732 iState = ECleanup; |
|
733 iStatus = KRequestPending; |
|
734 Reschedule (); |
|
735 return EPass; |
|
736 } |
|
737 |
|
738 case ECleanup: |
|
739 { |
|
740 delete iTestServer; |
|
741 // cleanup udp client flow |
|
742 TEChild::TDestroy msg; |
|
743 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
744 |
|
745 return EPass; |
|
746 } |
|
747 |
|
748 case EFailed: |
|
749 { |
|
750 delete iTestServer; |
|
751 // cleanup udp client flow |
|
752 TEChild::TDestroy msg; |
|
753 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
754 |
|
755 FinishTest ( EFail ); |
|
756 delete this; |
|
757 return EFail; |
|
758 } |
|
759 |
|
760 default: |
|
761 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
762 ASSERT(0); |
|
763 return EFail; |
|
764 } |
|
765 } |
|
766 |
|
767 void CUdpClientTestUPnP3::OnTestServerEventL ( TInt aError ) |
|
768 { |
|
769 CompleteSelf ( aError ); |
|
770 } |
|
771 |
|
772 void CUdpClientTestUPnP3::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
773 { |
|
774 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
775 { |
|
776 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
777 iClientId = msg.iNodeId; |
|
778 CompleteSelf ( KErrNone ); |
|
779 } |
|
780 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
781 { |
|
782 iTimer.Cancel (); |
|
783 iState = EFailed; |
|
784 RunTestL (); |
|
785 } |
|
786 } |
|
787 |
|
788 |
|
789 //---------------------------------------------------------------------------------------------------------------------------- |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 CUdpClientTestUPnP4* CUdpClientTestUPnP4::NewL ( CProxyProvd* aProvd ) |
|
796 { |
|
797 CUdpClientTestUPnP4* ret = new ( ELeave ) CUdpClientTestUPnP4 ( aProvd ); |
|
798 CleanupStack::PushL ( ret ); |
|
799 ret->ConstructL (); |
|
800 CleanupStack::Pop ( ret ); |
|
801 return ret; |
|
802 } |
|
803 |
|
804 CUdpClientTestUPnP4::CUdpClientTestUPnP4 ( CProxyProvd* aProvd ) : |
|
805 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
806 { |
|
807 } |
|
808 |
|
809 CUdpClientTestUPnP4::~CUdpClientTestUPnP4 () |
|
810 { |
|
811 iTimer.Close (); |
|
812 } |
|
813 |
|
814 void CUdpClientTestUPnP4::ConstructL() |
|
815 { |
|
816 iTimer.CreateLocal (); |
|
817 } |
|
818 |
|
819 TVerdict CUdpClientTestUPnP4::RunTestL() |
|
820 { |
|
821 const TUint16 KActivityNull = 0; |
|
822 switch ( iState ) |
|
823 { |
|
824 case ECreateTestServer: |
|
825 { |
|
826 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
827 |
|
828 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
829 |
|
830 iState = ECreateTestClient; |
|
831 iStatus = KRequestPending; |
|
832 Reschedule(); |
|
833 return EPass; |
|
834 } |
|
835 |
|
836 case ECreateTestClient: |
|
837 { |
|
838 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
839 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
840 |
|
841 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
842 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
843 |
|
844 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
845 |
|
846 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
847 |
|
848 iState = ESendRequestData; |
|
849 iStatus = KRequestPending; |
|
850 Reschedule(); |
|
851 return EPass; |
|
852 } |
|
853 |
|
854 case ESendRequestData: |
|
855 { |
|
856 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
857 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
858 |
|
859 RMemChunk st; |
|
860 st.CreateL ( KTestCase5, iAllocator ); |
|
861 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
862 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
863 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
864 |
|
865 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
866 |
|
867 iState = ECleanup; |
|
868 iStatus = KRequestPending; |
|
869 Reschedule (); |
|
870 return EPass; |
|
871 } |
|
872 |
|
873 case ECleanup: |
|
874 { |
|
875 delete iTestServer; |
|
876 // cleanup udp client flow |
|
877 TEChild::TDestroy msg; |
|
878 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
879 |
|
880 return EPass; |
|
881 } |
|
882 |
|
883 case EFailed: |
|
884 { |
|
885 delete iTestServer; |
|
886 // cleanup udp client flow |
|
887 TEChild::TDestroy msg; |
|
888 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
889 |
|
890 FinishTest ( EFail ); |
|
891 delete this; |
|
892 return EFail; |
|
893 } |
|
894 |
|
895 default: |
|
896 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
897 ASSERT(0); |
|
898 return EFail; |
|
899 } |
|
900 } |
|
901 |
|
902 void CUdpClientTestUPnP4::OnTestServerEventL ( TInt aError ) |
|
903 { |
|
904 CompleteSelf ( aError ); |
|
905 } |
|
906 |
|
907 void CUdpClientTestUPnP4::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
908 { |
|
909 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
910 { |
|
911 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
912 iClientId = msg.iNodeId; |
|
913 CompleteSelf ( KErrNone ); |
|
914 } |
|
915 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
916 { |
|
917 iTimer.Cancel (); |
|
918 iState = EFailed; |
|
919 RunTestL (); |
|
920 } |
|
921 } |
|
922 |
|
923 |
|
924 //---------------------------------------------------------------------------------------------------------------------------- |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 CUdpClientTestUPnP5* CUdpClientTestUPnP5::NewL ( CProxyProvd* aProvd ) |
|
930 { |
|
931 CUdpClientTestUPnP5* ret = new ( ELeave ) CUdpClientTestUPnP5 ( aProvd ); |
|
932 CleanupStack::PushL ( ret ); |
|
933 ret->ConstructL (); |
|
934 CleanupStack::Pop ( ret ); |
|
935 return ret; |
|
936 } |
|
937 |
|
938 CUdpClientTestUPnP5::CUdpClientTestUPnP5 ( CProxyProvd* aProvd ) : |
|
939 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
940 { |
|
941 } |
|
942 |
|
943 CUdpClientTestUPnP5::~CUdpClientTestUPnP5 () |
|
944 { |
|
945 iTimer.Close (); |
|
946 } |
|
947 |
|
948 void CUdpClientTestUPnP5::ConstructL() |
|
949 { |
|
950 iTimer.CreateLocal (); |
|
951 } |
|
952 |
|
953 TVerdict CUdpClientTestUPnP5::RunTestL() |
|
954 { |
|
955 const TUint16 KActivityNull = 0; |
|
956 switch ( iState ) |
|
957 { |
|
958 case ECreateTestServer: |
|
959 { |
|
960 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
961 |
|
962 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
963 |
|
964 iState = ECreateTestClient; |
|
965 iStatus = KRequestPending; |
|
966 Reschedule(); |
|
967 return EPass; |
|
968 } |
|
969 |
|
970 case ECreateTestClient: |
|
971 { |
|
972 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
973 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
974 |
|
975 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
976 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
977 |
|
978 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
979 |
|
980 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
981 |
|
982 iState = ESendRequestData; |
|
983 iStatus = KRequestPending; |
|
984 Reschedule(); |
|
985 return EPass; |
|
986 } |
|
987 |
|
988 case ESendRequestData: |
|
989 { |
|
990 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
991 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
992 |
|
993 RMemChunk st; |
|
994 st.CreateL ( KTestCase6, iAllocator ); |
|
995 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
996 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
997 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
998 |
|
999 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
1000 |
|
1001 iState = ECleanup; |
|
1002 iStatus = KRequestPending; |
|
1003 Reschedule (); |
|
1004 return EPass; |
|
1005 } |
|
1006 |
|
1007 case ECleanup: |
|
1008 { |
|
1009 delete iTestServer; |
|
1010 // cleanup udp client flow |
|
1011 TEChild::TDestroy msg; |
|
1012 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1013 |
|
1014 return EPass; |
|
1015 } |
|
1016 |
|
1017 case EFailed: |
|
1018 { |
|
1019 delete iTestServer; |
|
1020 // cleanup udp client flow |
|
1021 TEChild::TDestroy msg; |
|
1022 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1023 |
|
1024 FinishTest ( EFail ); |
|
1025 delete this; |
|
1026 return EFail; |
|
1027 } |
|
1028 |
|
1029 default: |
|
1030 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
1031 ASSERT(0); |
|
1032 return EFail; |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 void CUdpClientTestUPnP5::OnTestServerEventL ( TInt aError ) |
|
1037 { |
|
1038 CompleteSelf ( aError ); |
|
1039 } |
|
1040 |
|
1041 void CUdpClientTestUPnP5::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
1042 { |
|
1043 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
1044 { |
|
1045 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
1046 iClientId = msg.iNodeId; |
|
1047 CompleteSelf ( KErrNone ); |
|
1048 } |
|
1049 /* |
|
1050 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
1051 { |
|
1052 iTimer.Cancel (); |
|
1053 iState = EFailed; |
|
1054 RunTestL (); |
|
1055 } |
|
1056 */ |
|
1057 } |
|
1058 |
|
1059 |
|
1060 //------------------------------------------------------------------------------------------------------------------------------- |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 CUdpClientTestUPnP6* CUdpClientTestUPnP6::NewL ( CProxyProvd* aProvd ) |
|
1066 { |
|
1067 CUdpClientTestUPnP6* ret = new ( ELeave ) CUdpClientTestUPnP6 ( aProvd ); |
|
1068 CleanupStack::PushL ( ret ); |
|
1069 ret->ConstructL (); |
|
1070 CleanupStack::Pop ( ret ); |
|
1071 return ret; |
|
1072 } |
|
1073 |
|
1074 CUdpClientTestUPnP6::CUdpClientTestUPnP6 ( CProxyProvd* aProvd ) : |
|
1075 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
1076 { |
|
1077 } |
|
1078 |
|
1079 CUdpClientTestUPnP6::~CUdpClientTestUPnP6 () |
|
1080 { |
|
1081 iTimer.Close (); |
|
1082 } |
|
1083 |
|
1084 void CUdpClientTestUPnP6::ConstructL() |
|
1085 { |
|
1086 iTimer.CreateLocal (); |
|
1087 } |
|
1088 |
|
1089 TVerdict CUdpClientTestUPnP6::RunTestL() |
|
1090 { |
|
1091 const TUint16 KActivityNull = 0; |
|
1092 switch ( iState ) |
|
1093 { |
|
1094 case ECreateTestServer: |
|
1095 { |
|
1096 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
1097 |
|
1098 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
1099 |
|
1100 iState = ECreateTestClient; |
|
1101 iStatus = KRequestPending; |
|
1102 Reschedule(); |
|
1103 return EPass; |
|
1104 } |
|
1105 |
|
1106 case ECreateTestClient: |
|
1107 { |
|
1108 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
1109 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
1110 |
|
1111 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
1112 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
1113 |
|
1114 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
1115 |
|
1116 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
1117 |
|
1118 iState = ESendRequestData; |
|
1119 iStatus = KRequestPending; |
|
1120 Reschedule(); |
|
1121 return EPass; |
|
1122 } |
|
1123 |
|
1124 case ESendRequestData: |
|
1125 { |
|
1126 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
1127 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
1128 |
|
1129 RMemChunk st; |
|
1130 st.CreateL ( KTestCase7, iAllocator ); |
|
1131 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
1132 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
1133 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
1134 |
|
1135 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
1136 |
|
1137 iState = ECleanup; |
|
1138 iStatus = KRequestPending; |
|
1139 Reschedule (); |
|
1140 return EPass; |
|
1141 } |
|
1142 |
|
1143 case ECleanup: |
|
1144 { |
|
1145 delete iTestServer; |
|
1146 // cleanup udp client flow |
|
1147 TEChild::TDestroy msg; |
|
1148 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1149 |
|
1150 return EPass; |
|
1151 } |
|
1152 |
|
1153 case EFailed: |
|
1154 { |
|
1155 delete iTestServer; |
|
1156 // cleanup udp client flow |
|
1157 TEChild::TDestroy msg; |
|
1158 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1159 |
|
1160 FinishTest ( EFail ); |
|
1161 delete this; |
|
1162 return EFail; |
|
1163 } |
|
1164 |
|
1165 default: |
|
1166 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
1167 ASSERT(0); |
|
1168 return EFail; |
|
1169 } |
|
1170 } |
|
1171 |
|
1172 void CUdpClientTestUPnP6::OnTestServerEventL ( TInt aError ) |
|
1173 { |
|
1174 CompleteSelf ( aError ); |
|
1175 } |
|
1176 |
|
1177 void CUdpClientTestUPnP6::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
1178 { |
|
1179 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
1180 { |
|
1181 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
1182 iClientId = msg.iNodeId; |
|
1183 CompleteSelf ( KErrNone ); |
|
1184 } |
|
1185 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
1186 { |
|
1187 iTimer.Cancel (); |
|
1188 iState = EFailed; |
|
1189 RunTestL (); |
|
1190 } |
|
1191 } |
|
1192 |
|
1193 |
|
1194 |
|
1195 //------------------------------------------------------------------------------------------------------------------------------- |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 CUdpClientTestUPnP7* CUdpClientTestUPnP7::NewL ( CProxyProvd* aProvd ) |
|
1201 { |
|
1202 CUdpClientTestUPnP7* ret = new ( ELeave ) CUdpClientTestUPnP7 ( aProvd ); |
|
1203 CleanupStack::PushL ( ret ); |
|
1204 ret->ConstructL (); |
|
1205 CleanupStack::Pop ( ret ); |
|
1206 return ret; |
|
1207 } |
|
1208 |
|
1209 CUdpClientTestUPnP7::CUdpClientTestUPnP7 ( CProxyProvd* aProvd ) : |
|
1210 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
1211 { |
|
1212 } |
|
1213 |
|
1214 CUdpClientTestUPnP7::~CUdpClientTestUPnP7 () |
|
1215 { |
|
1216 iTimer.Close (); |
|
1217 } |
|
1218 |
|
1219 void CUdpClientTestUPnP7::ConstructL() |
|
1220 { |
|
1221 iTimer.CreateLocal (); |
|
1222 } |
|
1223 |
|
1224 TVerdict CUdpClientTestUPnP7::RunTestL() |
|
1225 { |
|
1226 const TUint16 KActivityNull = 0; |
|
1227 switch ( iState ) |
|
1228 { |
|
1229 case ECreateTestServer: |
|
1230 { |
|
1231 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
1232 |
|
1233 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
1234 |
|
1235 iState = ECreateTestClient; |
|
1236 iStatus = KRequestPending; |
|
1237 Reschedule(); |
|
1238 return EPass; |
|
1239 } |
|
1240 |
|
1241 case ECreateTestClient: |
|
1242 { |
|
1243 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
1244 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
1245 |
|
1246 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
1247 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
1248 |
|
1249 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
1250 |
|
1251 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
1252 |
|
1253 iState = ESendRequestData; |
|
1254 iStatus = KRequestPending; |
|
1255 Reschedule(); |
|
1256 return EPass; |
|
1257 } |
|
1258 |
|
1259 case ESendRequestData: |
|
1260 { |
|
1261 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
1262 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
1263 |
|
1264 RMemChunk st; |
|
1265 st.CreateL ( KTestCase8, iAllocator ); |
|
1266 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
1267 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
1268 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
1269 |
|
1270 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
1271 |
|
1272 iState = ECleanup; |
|
1273 iStatus = KRequestPending; |
|
1274 Reschedule (); |
|
1275 return EPass; |
|
1276 } |
|
1277 |
|
1278 case ECleanup: |
|
1279 { |
|
1280 delete iTestServer; |
|
1281 // cleanup udp client flow |
|
1282 TEChild::TDestroy msg; |
|
1283 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1284 |
|
1285 return EPass; |
|
1286 } |
|
1287 |
|
1288 case EFailed: |
|
1289 { |
|
1290 delete iTestServer; |
|
1291 // cleanup udp client flow |
|
1292 TEChild::TDestroy msg; |
|
1293 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1294 |
|
1295 FinishTest ( EFail ); |
|
1296 delete this; |
|
1297 return EFail; |
|
1298 } |
|
1299 |
|
1300 default: |
|
1301 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
1302 ASSERT(0); |
|
1303 return EFail; |
|
1304 } |
|
1305 } |
|
1306 |
|
1307 void CUdpClientTestUPnP7::OnTestServerEventL ( TInt aError ) |
|
1308 { |
|
1309 CompleteSelf ( aError ); |
|
1310 } |
|
1311 |
|
1312 void CUdpClientTestUPnP7::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
1313 { |
|
1314 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
1315 { |
|
1316 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
1317 iClientId = msg.iNodeId; |
|
1318 CompleteSelf ( KErrNone ); |
|
1319 } |
|
1320 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
1321 { |
|
1322 iTimer.Cancel (); |
|
1323 iState = EFailed; |
|
1324 RunTestL (); |
|
1325 } |
|
1326 } |
|
1327 |
|
1328 |
|
1329 |
|
1330 //------------------------------------------------------------------------------------------------------------------------------- |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 CUdpClientTestUPnP8* CUdpClientTestUPnP8::NewL ( CProxyProvd* aProvd ) |
|
1336 { |
|
1337 CUdpClientTestUPnP8* ret = new ( ELeave ) CUdpClientTestUPnP8 ( aProvd ); |
|
1338 CleanupStack::PushL ( ret ); |
|
1339 ret->ConstructL (); |
|
1340 CleanupStack::Pop ( ret ); |
|
1341 return ret; |
|
1342 } |
|
1343 |
|
1344 CUdpClientTestUPnP8::CUdpClientTestUPnP8 ( CProxyProvd* aProvd ) : |
|
1345 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
1346 { |
|
1347 } |
|
1348 |
|
1349 CUdpClientTestUPnP8::~CUdpClientTestUPnP8 () |
|
1350 { |
|
1351 iTimer.Close (); |
|
1352 } |
|
1353 |
|
1354 void CUdpClientTestUPnP8::ConstructL() |
|
1355 { |
|
1356 iTimer.CreateLocal (); |
|
1357 } |
|
1358 |
|
1359 TVerdict CUdpClientTestUPnP8::RunTestL() |
|
1360 { |
|
1361 const TUint16 KActivityNull = 0; |
|
1362 switch ( iState ) |
|
1363 { |
|
1364 case ECreateTestServer: |
|
1365 { |
|
1366 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
1367 |
|
1368 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
1369 |
|
1370 iState = ECreateTestClient; |
|
1371 iStatus = KRequestPending; |
|
1372 Reschedule(); |
|
1373 return EPass; |
|
1374 } |
|
1375 |
|
1376 case ECreateTestClient: |
|
1377 { |
|
1378 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
1379 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
1380 |
|
1381 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
1382 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
1383 |
|
1384 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
1385 |
|
1386 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
1387 |
|
1388 iState = ESendRequestData; |
|
1389 iStatus = KRequestPending; |
|
1390 Reschedule(); |
|
1391 return EPass; |
|
1392 } |
|
1393 |
|
1394 case ESendRequestData: |
|
1395 { |
|
1396 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
1397 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
1398 |
|
1399 RMemChunk st; |
|
1400 st.CreateL ( KTestCase9, iAllocator ); |
|
1401 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
1402 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
1403 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
1404 |
|
1405 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
1406 |
|
1407 iState = ECleanup; |
|
1408 iStatus = KRequestPending; |
|
1409 Reschedule (); |
|
1410 return EPass; |
|
1411 } |
|
1412 |
|
1413 case ECleanup: |
|
1414 { |
|
1415 delete iTestServer; |
|
1416 // cleanup udp client flow |
|
1417 TEChild::TDestroy msg; |
|
1418 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1419 |
|
1420 return EPass; |
|
1421 } |
|
1422 |
|
1423 case EFailed: |
|
1424 { |
|
1425 delete iTestServer; |
|
1426 // cleanup udp client flow |
|
1427 TEChild::TDestroy msg; |
|
1428 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1429 |
|
1430 FinishTest ( EFail ); |
|
1431 delete this; |
|
1432 return EFail; |
|
1433 } |
|
1434 |
|
1435 default: |
|
1436 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
1437 ASSERT(0); |
|
1438 return EFail; |
|
1439 } |
|
1440 } |
|
1441 |
|
1442 void CUdpClientTestUPnP8::OnTestServerEventL ( TInt aError ) |
|
1443 { |
|
1444 CompleteSelf ( aError ); |
|
1445 } |
|
1446 |
|
1447 void CUdpClientTestUPnP8::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
1448 { |
|
1449 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
1450 { |
|
1451 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
1452 iClientId = msg.iNodeId; |
|
1453 CompleteSelf ( KErrNone ); |
|
1454 } |
|
1455 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
1456 { |
|
1457 iTimer.Cancel (); |
|
1458 iState = EFailed; |
|
1459 RunTestL (); |
|
1460 } |
|
1461 } |
|
1462 |
|
1463 |
|
1464 |
|
1465 //------------------------------------------------------------------------------------------------------------------------------- |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 CUdpClientTestUPnP9* CUdpClientTestUPnP9::NewL ( CProxyProvd* aProvd ) |
|
1471 { |
|
1472 CUdpClientTestUPnP9* ret = new ( ELeave ) CUdpClientTestUPnP9 ( aProvd ); |
|
1473 CleanupStack::PushL ( ret ); |
|
1474 ret->ConstructL (); |
|
1475 CleanupStack::Pop ( ret ); |
|
1476 return ret; |
|
1477 } |
|
1478 |
|
1479 CUdpClientTestUPnP9::CUdpClientTestUPnP9 ( CProxyProvd* aProvd ) : |
|
1480 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
1481 { |
|
1482 } |
|
1483 |
|
1484 CUdpClientTestUPnP9::~CUdpClientTestUPnP9 () |
|
1485 { |
|
1486 iTimer.Close (); |
|
1487 } |
|
1488 |
|
1489 void CUdpClientTestUPnP9::ConstructL() |
|
1490 { |
|
1491 iTimer.CreateLocal (); |
|
1492 } |
|
1493 |
|
1494 TVerdict CUdpClientTestUPnP9::RunTestL() |
|
1495 { |
|
1496 const TUint16 KActivityNull = 0; |
|
1497 switch ( iState ) |
|
1498 { |
|
1499 case ECreateTestServer: |
|
1500 { |
|
1501 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
1502 |
|
1503 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
1504 |
|
1505 iState = ECreateTestClient; |
|
1506 iStatus = KRequestPending; |
|
1507 Reschedule(); |
|
1508 return EPass; |
|
1509 } |
|
1510 |
|
1511 case ECreateTestClient: |
|
1512 { |
|
1513 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
1514 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
1515 |
|
1516 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
1517 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
1518 |
|
1519 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
1520 |
|
1521 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
1522 |
|
1523 iState = ESendRequestData; |
|
1524 iStatus = KRequestPending; |
|
1525 Reschedule(); |
|
1526 return EPass; |
|
1527 } |
|
1528 |
|
1529 case ESendRequestData: |
|
1530 { |
|
1531 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
1532 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
1533 |
|
1534 RMemChunk st; |
|
1535 st.CreateL ( KTestCase10, iAllocator ); |
|
1536 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
1537 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
1538 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
1539 |
|
1540 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
1541 |
|
1542 iState = ECleanup; |
|
1543 iStatus = KRequestPending; |
|
1544 Reschedule (); |
|
1545 return EPass; |
|
1546 } |
|
1547 |
|
1548 case ECleanup: |
|
1549 { |
|
1550 delete iTestServer; |
|
1551 // cleanup udp client flow |
|
1552 TEChild::TDestroy msg; |
|
1553 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1554 |
|
1555 return EPass; |
|
1556 } |
|
1557 |
|
1558 case EFailed: |
|
1559 { |
|
1560 delete iTestServer; |
|
1561 // cleanup udp client flow |
|
1562 TEChild::TDestroy msg; |
|
1563 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1564 |
|
1565 FinishTest ( EFail ); |
|
1566 delete this; |
|
1567 return EFail; |
|
1568 } |
|
1569 |
|
1570 default: |
|
1571 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
1572 ASSERT(0); |
|
1573 return EFail; |
|
1574 } |
|
1575 } |
|
1576 |
|
1577 void CUdpClientTestUPnP9::OnTestServerEventL ( TInt aError ) |
|
1578 { |
|
1579 CompleteSelf ( aError ); |
|
1580 } |
|
1581 |
|
1582 void CUdpClientTestUPnP9::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
1583 { |
|
1584 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
1585 { |
|
1586 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
1587 iClientId = msg.iNodeId; |
|
1588 CompleteSelf ( KErrNone ); |
|
1589 } |
|
1590 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
1591 { |
|
1592 iTimer.Cancel (); |
|
1593 iState = EFailed; |
|
1594 RunTestL (); |
|
1595 } |
|
1596 } |
|
1597 |
|
1598 |
|
1599 //------------------------------------------------------------------------------------------------------------------------------- |
|
1600 |
|
1601 |
|
1602 |
|
1603 |
|
1604 CUdpClientTestUPnP10* CUdpClientTestUPnP10::NewL ( CProxyProvd* aProvd ) |
|
1605 { |
|
1606 CUdpClientTestUPnP10* ret = new ( ELeave ) CUdpClientTestUPnP10 ( aProvd ); |
|
1607 CleanupStack::PushL ( ret ); |
|
1608 ret->ConstructL (); |
|
1609 CleanupStack::Pop ( ret ); |
|
1610 return ret; |
|
1611 } |
|
1612 |
|
1613 CUdpClientTestUPnP10::CUdpClientTestUPnP10 ( CProxyProvd* aProvd ) : |
|
1614 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
1615 { |
|
1616 } |
|
1617 |
|
1618 CUdpClientTestUPnP10::~CUdpClientTestUPnP10 () |
|
1619 { |
|
1620 iTimer.Close (); |
|
1621 } |
|
1622 |
|
1623 void CUdpClientTestUPnP10::ConstructL() |
|
1624 { |
|
1625 iTimer.CreateLocal (); |
|
1626 } |
|
1627 |
|
1628 TVerdict CUdpClientTestUPnP10::RunTestL() |
|
1629 { |
|
1630 const TUint16 KActivityNull = 0; |
|
1631 switch ( iState ) |
|
1632 { |
|
1633 case ECreateTestServer: |
|
1634 { |
|
1635 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
1636 |
|
1637 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
1638 |
|
1639 iState = ECreateTestClient; |
|
1640 iStatus = KRequestPending; |
|
1641 Reschedule(); |
|
1642 return EPass; |
|
1643 } |
|
1644 |
|
1645 case ECreateTestClient: |
|
1646 { |
|
1647 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
1648 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
1649 |
|
1650 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
1651 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
1652 |
|
1653 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
1654 |
|
1655 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
1656 |
|
1657 iState = ESendRequestData; |
|
1658 iStatus = KRequestPending; |
|
1659 Reschedule(); |
|
1660 return EPass; |
|
1661 } |
|
1662 |
|
1663 case ESendRequestData: |
|
1664 { |
|
1665 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
1666 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
1667 |
|
1668 RMemChunk st; |
|
1669 st.CreateL ( KTestCase11, iAllocator ); |
|
1670 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
1671 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
1672 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
1673 |
|
1674 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
1675 |
|
1676 iState = ECleanup; |
|
1677 iStatus = KRequestPending; |
|
1678 Reschedule (); |
|
1679 return EPass; |
|
1680 } |
|
1681 |
|
1682 case ECleanup: |
|
1683 { |
|
1684 delete iTestServer; |
|
1685 // cleanup udp client flow |
|
1686 TEChild::TDestroy msg; |
|
1687 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1688 |
|
1689 return EPass; |
|
1690 } |
|
1691 |
|
1692 case EFailed: |
|
1693 { |
|
1694 delete iTestServer; |
|
1695 // cleanup udp client flow |
|
1696 TEChild::TDestroy msg; |
|
1697 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1698 |
|
1699 FinishTest ( EFail ); |
|
1700 delete this; |
|
1701 return EFail; |
|
1702 } |
|
1703 |
|
1704 default: |
|
1705 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
1706 ASSERT(0); |
|
1707 return EFail; |
|
1708 } |
|
1709 } |
|
1710 |
|
1711 void CUdpClientTestUPnP10::OnTestServerEventL ( TInt aError ) |
|
1712 { |
|
1713 CompleteSelf ( aError ); |
|
1714 } |
|
1715 |
|
1716 void CUdpClientTestUPnP10::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
1717 { |
|
1718 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
1719 { |
|
1720 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
1721 iClientId = msg.iNodeId; |
|
1722 CompleteSelf ( KErrNone ); |
|
1723 } |
|
1724 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
1725 { |
|
1726 iTimer.Cancel (); |
|
1727 iState = EFailed; |
|
1728 RunTestL (); |
|
1729 } |
|
1730 } |
|
1731 |
|
1732 |
|
1733 //------------------------------------------------------------------------------------------------------------------------------- |
|
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 CUdpClientTestUPnP11* CUdpClientTestUPnP11::NewL ( CProxyProvd* aProvd ) |
|
1739 { |
|
1740 CUdpClientTestUPnP11* ret = new ( ELeave ) CUdpClientTestUPnP11 ( aProvd ); |
|
1741 CleanupStack::PushL ( ret ); |
|
1742 ret->ConstructL (); |
|
1743 CleanupStack::Pop ( ret ); |
|
1744 return ret; |
|
1745 } |
|
1746 |
|
1747 CUdpClientTestUPnP11::CUdpClientTestUPnP11 ( CProxyProvd* aProvd ) : |
|
1748 CUdpClientTestBase(aProvd), iTestServer(NULL), iState ( ECreateTestServer ) |
|
1749 { |
|
1750 } |
|
1751 |
|
1752 CUdpClientTestUPnP11::~CUdpClientTestUPnP11 () |
|
1753 { |
|
1754 iTimer.Close (); |
|
1755 } |
|
1756 |
|
1757 void CUdpClientTestUPnP11::ConstructL() |
|
1758 { |
|
1759 iTimer.CreateLocal (); |
|
1760 } |
|
1761 |
|
1762 TVerdict CUdpClientTestUPnP11::RunTestL() |
|
1763 { |
|
1764 const TUint16 KActivityNull = 0; |
|
1765 switch ( iState ) |
|
1766 { |
|
1767 case ECreateTestServer: |
|
1768 { |
|
1769 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
1770 |
|
1771 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
1772 |
|
1773 iState = ECreateTestClient; |
|
1774 iStatus = KRequestPending; |
|
1775 Reschedule(); |
|
1776 return EPass; |
|
1777 } |
|
1778 |
|
1779 case ECreateTestClient: |
|
1780 { |
|
1781 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
1782 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
1783 |
|
1784 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
1785 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
1786 |
|
1787 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
1788 |
|
1789 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
1790 |
|
1791 iState = ESendRequestData; |
|
1792 iStatus = KRequestPending; |
|
1793 Reschedule(); |
|
1794 return EPass; |
|
1795 } |
|
1796 |
|
1797 case ESendRequestData: |
|
1798 { |
|
1799 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
1800 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
1801 |
|
1802 RMemChunk st; |
|
1803 st.CreateL ( KTestCase12, iAllocator ); |
|
1804 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
1805 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
1806 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
1807 |
|
1808 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
1809 |
|
1810 iState = ECleanup; |
|
1811 iStatus = KRequestPending; |
|
1812 Reschedule (); |
|
1813 return EPass; |
|
1814 } |
|
1815 |
|
1816 case ECleanup: |
|
1817 { |
|
1818 delete iTestServer; |
|
1819 // cleanup udp client flow |
|
1820 TEChild::TDestroy msg; |
|
1821 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1822 |
|
1823 return EPass; |
|
1824 } |
|
1825 |
|
1826 case EFailed: |
|
1827 { |
|
1828 delete iTestServer; |
|
1829 // cleanup udp client flow |
|
1830 TEChild::TDestroy msg; |
|
1831 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1832 |
|
1833 FinishTest ( EFail ); |
|
1834 delete this; |
|
1835 return EFail; |
|
1836 } |
|
1837 |
|
1838 default: |
|
1839 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
1840 ASSERT(0); |
|
1841 return EFail; |
|
1842 } |
|
1843 } |
|
1844 |
|
1845 void CUdpClientTestUPnP11::OnTestServerEventL ( TInt aError ) |
|
1846 { |
|
1847 CompleteSelf ( aError ); |
|
1848 } |
|
1849 |
|
1850 void CUdpClientTestUPnP11::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
1851 { |
|
1852 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
1853 { |
|
1854 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
1855 iClientId = msg.iNodeId; |
|
1856 CompleteSelf ( KErrNone ); |
|
1857 } |
|
1858 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
1859 { |
|
1860 iTimer.Cancel (); |
|
1861 iState = EFailed; |
|
1862 RunTestL (); |
|
1863 } |
|
1864 } |
|
1865 |
|
1866 |
|
1867 //------------------------------------------------------------------------------------------------------------------------------- |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 CUdpClientTestUPnP12* CUdpClientTestUPnP12::NewL ( CProxyProvd* aProvd ) |
|
1873 { |
|
1874 CUdpClientTestUPnP12* ret = new ( ELeave ) CUdpClientTestUPnP12 ( aProvd ); |
|
1875 CleanupStack::PushL ( ret ); |
|
1876 ret->ConstructL (); |
|
1877 CleanupStack::Pop ( ret ); |
|
1878 return ret; |
|
1879 } |
|
1880 |
|
1881 CUdpClientTestUPnP12::CUdpClientTestUPnP12 ( CProxyProvd* aProvd ) : |
|
1882 CUdpClientTestBase(aProvd), iTestServer(NULL),iState ( ECreateTestServer ), iSocketHandler ( *this ), iPort(1025) |
|
1883 { |
|
1884 } |
|
1885 |
|
1886 CUdpClientTestUPnP12::~CUdpClientTestUPnP12 () |
|
1887 { |
|
1888 iTimer.Close (); |
|
1889 |
|
1890 delete iSocketOpener; |
|
1891 iSocketHandler.CancelAll (); |
|
1892 |
|
1893 iSocketArray.Close(); |
|
1894 } |
|
1895 |
|
1896 void CUdpClientTestUPnP12::ConstructL() |
|
1897 { |
|
1898 iTimer.CreateLocal (); |
|
1899 |
|
1900 } |
|
1901 |
|
1902 TVerdict CUdpClientTestUPnP12::RunTestL() |
|
1903 { |
|
1904 const TUint16 KActivityNull = 0; |
|
1905 switch ( iState ) |
|
1906 { |
|
1907 case ECreateTestServer: |
|
1908 { |
|
1909 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
1910 |
|
1911 iTestServer = CTestMUdpServer::NewL ( *this ); |
|
1912 |
|
1913 iState = EOpenTestSocket; |
|
1914 iStatus = KRequestPending; |
|
1915 Reschedule(); |
|
1916 return EPass; |
|
1917 } |
|
1918 case EOpenTestSocket: |
|
1919 { |
|
1920 iSocketOpener = CSocketOpener::NewL ( *this ); |
|
1921 iSocketOpener->MakeSocket ( KAfInet, KSockDatagram, KProtocolInetUdp ); |
|
1922 |
|
1923 iState = ECreateTestClient; |
|
1924 iStatus = KRequestPending; |
|
1925 Reschedule(); |
|
1926 return EPass; |
|
1927 } |
|
1928 case ECreateTestClient: |
|
1929 { |
|
1930 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
1931 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
1932 |
|
1933 THttpUdpFlowQuery flowQuery ( Id (), EHttpUdpFlow, iChunkManager); |
|
1934 const TUid requestedUid = { CUPnPFlowFactory::iUid }; |
|
1935 |
|
1936 TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); |
|
1937 |
|
1938 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); |
|
1939 iState = ESendRequestData; |
|
1940 iStatus = KRequestPending; |
|
1941 Reschedule(); |
|
1942 return EPass; |
|
1943 } |
|
1944 |
|
1945 case ESendRequestData: |
|
1946 { |
|
1947 iLogger.WriteFormat(_L("<i>Client is Created</i>")); |
|
1948 iLogger.WriteFormat(_L("<i>Send data..... </i>")); |
|
1949 |
|
1950 RMemChunk st; |
|
1951 st.CreateL ( KTestCase12, iAllocator ); |
|
1952 TSsdpInfo searchInfo ( 5, st ); // MX , ST |
|
1953 TUpnpMessage::TUPnPSearchRequest msg ( searchInfo ); |
|
1954 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg ); |
|
1955 |
|
1956 iTimer.After ( iStatus, 5000000 ); // 5secs |
|
1957 |
|
1958 iState = ECleanup; |
|
1959 iStatus = KRequestPending; |
|
1960 Reschedule (); |
|
1961 return EPass; |
|
1962 } |
|
1963 |
|
1964 case ECleanup: |
|
1965 { |
|
1966 delete iTestServer; |
|
1967 // cleanup udp client flow |
|
1968 TEChild::TDestroy msg; |
|
1969 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1970 |
|
1971 return EPass; |
|
1972 } |
|
1973 |
|
1974 case EFailed: |
|
1975 { |
|
1976 delete iTestServer; |
|
1977 // cleanup udp client flow |
|
1978 TEChild::TDestroy msg; |
|
1979 iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg); |
|
1980 |
|
1981 FinishTest ( EFail ); |
|
1982 delete this; |
|
1983 return EFail; |
|
1984 } |
|
1985 |
|
1986 default: |
|
1987 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
1988 ASSERT(0); |
|
1989 return EFail; |
|
1990 } |
|
1991 } |
|
1992 |
|
1993 void CUdpClientTestUPnP12::OnTestServerEventL ( TInt aError ) |
|
1994 { |
|
1995 CompleteSelf ( aError ); |
|
1996 } |
|
1997 |
|
1998 void CUdpClientTestUPnP12::ReceivedL ( const TRuntimeCtxId& /*aSender*/, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage ) |
|
1999 { |
|
2000 if ( aMessage.IsMessage<TCFFactory::TPeerFoundOrCreated> () ) |
|
2001 { |
|
2002 const TCFFactory::TPeerFoundOrCreated& msg = message_cast < const TCFFactory::TPeerFoundOrCreated > ( aMessage ); |
|
2003 iClientId = msg.iNodeId; |
|
2004 CompleteSelf ( KErrNone ); |
|
2005 } |
|
2006 else if ( aMessage.IsMessage<TUpnpMessage::TUPnPSearchResponse > () ) |
|
2007 { |
|
2008 iTimer.Cancel (); |
|
2009 iState = EFailed; |
|
2010 RunTestL (); |
|
2011 } |
|
2012 } |
|
2013 |
|
2014 void CUdpClientTestUPnP12::OpenComplete ( RInternalSocket& aSocket ) |
|
2015 { |
|
2016 |
|
2017 TInetAddr addr ( iPort ); |
|
2018 addr.SetAddress ( KInetAddrAny ); |
|
2019 |
|
2020 aSocket.Bind( addr ); |
|
2021 iSocketHandler.Attach ( aSocket ); |
|
2022 iSocketArray.Append(&aSocket); |
|
2023 iPort++; |
|
2024 |
|
2025 CompleteSelf ( KErrNone ); |
|
2026 } |
|
2027 |
|
2028 |
|
2029 |
|
2030 |