apploader/Src/TestAppLoaderServer.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2004-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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This main DLL entry point for the Smoketest_AppLoader.dll
       
    15 // 
       
    16 //
       
    17 
       
    18 // USER includes
       
    19 #include "TestAppLoaderServer.h"
       
    20 #include "TestAppLoaderAppStart.h"
       
    21 #include "TestAppLoaderKeyEvents.h"
       
    22 #include "TestAppLoaderKillProcess.h"
       
    23 #include "TestAppLoaderEndTask.h"
       
    24 #include "TestAppLoaderTaskRunning.h"
       
    25 
       
    26 /*@{*/
       
    27 _LIT(KServerName,	"smoketest_apploader");
       
    28 /*@}*/
       
    29 
       
    30 CTestAppLoaderServer* CTestAppLoaderServer::NewL()
       
    31 /**
       
    32  * @return - Instance of the test server
       
    33  * Same code for Secure and non-secure variants
       
    34  * Called inside the MainL() function to create and start the
       
    35  * CTestServer derived server.
       
    36  */
       
    37 	{
       
    38 	CTestAppLoaderServer*	server = new (ELeave) CTestAppLoaderServer();
       
    39 	CleanupStack::PushL(server);
       
    40 	// CServer base class call
       
    41 	server->ConstructL();
       
    42 	server->StartL(KServerName);
       
    43 	CleanupStack::Pop(server);
       
    44 	return server;
       
    45 	}
       
    46 
       
    47 CTestAppLoaderServer::CTestAppLoaderServer()
       
    48 	:	CTestServer()
       
    49 	{
       
    50 	}
       
    51 
       
    52 void CTestAppLoaderServer::ConstructL()
       
    53 	{
       
    54 	}
       
    55 
       
    56 CTestAppLoaderServer::~CTestAppLoaderServer()
       
    57 	{
       
    58 	}
       
    59 
       
    60 LOCAL_C void MainL()
       
    61 /**
       
    62  * Secure variant
       
    63  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    64  */
       
    65 	{
       
    66 #if (defined __DATA_CAGING__)
       
    67 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    68 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    69 #endif
       
    70 	CActiveScheduler*		sched=NULL;
       
    71 	sched=new(ELeave) CActiveScheduler;
       
    72 	CActiveScheduler::Install(sched);
       
    73 	CTestAppLoaderServer*	server = NULL;
       
    74 	// Create the CTestServer derived server
       
    75 	TRAPD(err,server = CTestAppLoaderServer::NewL());
       
    76 	if(!err)
       
    77 		{
       
    78 		// Sync with the client and enter the active scheduler
       
    79 		RProcess::Rendezvous(KErrNone);
       
    80 		sched->Start();
       
    81 		}
       
    82 	delete server;
       
    83 	delete sched;
       
    84 	}
       
    85 
       
    86 
       
    87 GLDEF_C TInt E32Main()
       
    88 /**
       
    89  * @return - Standard Epoc error code on process exit
       
    90  * Secure variant only
       
    91  * Process entry point. Called by client using RProcess API
       
    92  */
       
    93 	{
       
    94 	__UHEAP_MARK;
       
    95 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    96 	if(cleanup == NULL)
       
    97 		{
       
    98 		return KErrNoMemory;
       
    99 		}
       
   100 	TRAPD(err,MainL());
       
   101 	delete cleanup;
       
   102 	__UHEAP_MARKEND;
       
   103 	return err;
       
   104     }
       
   105 
       
   106 
       
   107 CTestStep* CTestAppLoaderServer::CreateTestStep(const TDesC& aStepName)
       
   108 /**
       
   109  * @return - A CTestStep derived instance
       
   110  * Secure and non-secure variants
       
   111  * Implementation of CTestServer pure virtual
       
   112  */
       
   113 	{
       
   114 	CTestStep*	testStep = NULL;
       
   115 
       
   116 	if(aStepName == _L("AppStart"))
       
   117 		{
       
   118 		testStep = new CTestAppLoaderAppStart();
       
   119 		}
       
   120 	else if(aStepName == _L("KeyEvents"))
       
   121 		{
       
   122 		testStep = new CTestAppLoaderKeyEvents();
       
   123 		}
       
   124 	else if(aStepName == _L("KillProcess"))
       
   125 		{
       
   126 		testStep = new CTestAppLoaderKillProcess();
       
   127 		}
       
   128 	else if(aStepName == _L("EndTask"))
       
   129 		{
       
   130 		testStep = new CTestAppLoaderEndTask();
       
   131 		}
       
   132 	else if(aStepName == _L("TaskRunning"))
       
   133 		{
       
   134 		testStep = new CTestAppLoaderTaskRunning();
       
   135 		}
       
   136 	return testStep;
       
   137 	}