servicediscoveryandcontrol/pnp/test/upnp/unittests/upnpmessagetest/src/cupnpmessagetest.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-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 #include "cupnpmessagetest.h"
       
    17 #include "cupnpresponseparsertest.h"
       
    18 #include "cupnprequestcomposertest.h"
       
    19 #include "cupnprequestparsertest.h"
       
    20 #include "cupnpresponsecomposertest.h"
       
    21 #include "ccodecdecodetest.h"
       
    22 #include "ccodecencodetest.h"
       
    23 #include <e32base.h>
       
    24 #include <e32std.h>
       
    25 #include <f32file.h>
       
    26 
       
    27 
       
    28 #if (!defined EKA2)
       
    29 // The system-wide unique name for the test-server
       
    30 _LIT(KServerName, "upnpmessagetest");
       
    31 #endif
       
    32 
       
    33 
       
    34 CUpnpMessageTest*  CUpnpMessageTest::NewL()
       
    35 	{
       
    36 	CUpnpMessageTest* server = new(ELeave) CUpnpMessageTest();
       
    37 	CleanupStack::PushL(server);
       
    38 
       
    39 	server->StartL(server->ServerName());
       
    40 
       
    41 	CleanupStack::Pop(server);
       
    42 	return server;
       
    43 	}
       
    44 
       
    45 CUpnpMessageTest::CUpnpMessageTest()
       
    46 	{
       
    47 	}
       
    48 
       
    49 CUpnpMessageTest::~CUpnpMessageTest()
       
    50 	{
       
    51 	delete iTestStep;
       
    52 	}
       
    53 
       
    54 const TPtrC CUpnpMessageTest::ServerName()
       
    55 	{
       
    56 #if (!defined EKA2)
       
    57 	return KServerName();
       
    58 #else
       
    59 	TParsePtrC serverName(RProcess().FileName());
       
    60 	return serverName.Name();
       
    61 #endif
       
    62 	}
       
    63 
       
    64 CTestStep* CUpnpMessageTest::CreateTestStep(const TDesC& aStepName)
       
    65 	{
       
    66 	if (aStepName == KResponseParserTest)
       
    67 		{
       
    68 		iTestStep = new CUpnpResponseParserTest();
       
    69 		}
       
    70 
       
    71 	else if(aStepName == KRequestComposerTest)
       
    72 		{
       
    73 		iTestStep = new CUpnpRequestComposerTest();
       
    74 		}
       
    75 
       
    76 	else if(aStepName == KRequestParserTest)
       
    77 		{
       
    78 		iTestStep = new CUpnpRequestParserTest();
       
    79 		}
       
    80 
       
    81 	else if(aStepName == KResponseComposerTest)
       
    82 		{
       
    83 		iTestStep = new CUpnpResponseComposerTest();
       
    84 		}
       
    85 
       
    86 	else if(aStepName == KCodecDecodeTest)
       
    87 		{
       
    88 		iTestStep = new CCodecDecodeTest();
       
    89 		}
       
    90 
       
    91 	else if(aStepName == KCodecEncodeTest)
       
    92 		{
       
    93 		iTestStep = new CCodecEncodeTest();
       
    94 		}
       
    95 
       
    96 	return iTestStep;
       
    97 	}
       
    98 
       
    99 
       
   100 LOCAL_C void MainL()
       
   101 	{
       
   102 	// For platform security
       
   103 #if (defined __DATA_CAGING__)
       
   104 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
   105 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
   106 #endif
       
   107 	CActiveScheduler* sched = NULL;
       
   108 	sched = new(ELeave) CActiveScheduler;
       
   109 	CActiveScheduler::Install(sched);
       
   110 	CUpnpMessageTest* server = NULL;
       
   111 
       
   112 	// Create the test-server
       
   113 	TRAPD(err, server = CUpnpMessageTest::NewL());
       
   114 
       
   115 	if(!err)
       
   116 		{
       
   117 		// Sync with the client and enter the active scheduler
       
   118 		RProcess::Rendezvous(KErrNone);
       
   119 		sched->Start();
       
   120 		}
       
   121 	delete server;
       
   122 	delete sched;
       
   123 	}
       
   124 
       
   125 GLDEF_C TInt E32Main()
       
   126 	{
       
   127 	__UHEAP_MARK;
       
   128 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   129 	if (cleanup == NULL)
       
   130 		{
       
   131 		return KErrNoMemory;
       
   132 		}
       
   133 	TInt err = KErrNone;
       
   134 	TRAP(err, MainL());
       
   135 	delete cleanup;
       
   136 	__UHEAP_MARKEND;
       
   137 	return KErrNone;
       
   138 	}
       
   139 
       
   140 
       
   141