testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/SystestFilestoreSuiteServer.cpp
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2 * Copyright (c) 2009 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 #include "SystestFilestoreSuiteServer.h"
       
    18 #include "TestFSCreateFile.h"
       
    19 #include "TestFSReadFile.h"
       
    20 #include "TestFSPanicExample.h"
       
    21 
       
    22 _LIT(KServerName,"TEFSTEPFileStore");//SystestFilestoreSuite
       
    23 CSystestFilestoreSuite* CSystestFilestoreSuite::NewL()
       
    24 /**
       
    25  * @return - Instance of the test server
       
    26  * Same code for Secure and non-secure variants
       
    27  * Called inside the MainL() function to create and start the
       
    28  * CTestServer derived server.
       
    29  */
       
    30     {
       
    31     CSystestFilestoreSuite * server = new (ELeave) CSystestFilestoreSuite();
       
    32     CleanupStack::PushL(server);
       
    33 
       
    34     server->ConstructL(KServerName);
       
    35     CleanupStack::Pop(server);
       
    36     return server;
       
    37     }
       
    38 
       
    39 // Secure variants much simpler
       
    40 // For EKA2, just an E32Main and a MainL()
       
    41 LOCAL_C void MainL()
       
    42 /**
       
    43  * Secure variant
       
    44  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    45  */
       
    46     {
       
    47     // Leave the hooks in for platform security
       
    48 #if (defined __DATA_CAGING__)
       
    49     RProcess().DataCaging(RProcess::EDataCagingOn);
       
    50     RProcess().DataCaging(RProcess::ESecureApiOn);
       
    51 #endif
       
    52     CActiveScheduler* sched = NULL;
       
    53     sched = new (ELeave) CActiveScheduler;
       
    54     CActiveScheduler::Install(sched);
       
    55     CSystestFilestoreSuite* server = NULL;
       
    56     // Create the CTestServer derived server
       
    57     TRAPD(err,server = CSystestFilestoreSuite::NewL());
       
    58     if (!err)
       
    59         {
       
    60         // Sync with the client and enter the active scheduler
       
    61         RProcess::Rendezvous(KErrNone);
       
    62         sched->Start();
       
    63         }
       
    64     delete server;
       
    65     delete sched;
       
    66     }
       
    67 
       
    68 GLDEF_C TInt E32Main()
       
    69 /**
       
    70  * @return - Standard Epoc error code on process exit
       
    71  * Secure variant only
       
    72  * Process entry point. Called by client using RProcess API
       
    73  */
       
    74     {
       
    75     __UHEAP_MARK;
       
    76     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    77     if (cleanup == NULL)
       
    78         {
       
    79         return KErrNoMemory;
       
    80         }
       
    81     TRAPD(err,MainL());
       
    82     delete cleanup;
       
    83     __UHEAP_MARKEND;
       
    84     return err;
       
    85     }
       
    86 
       
    87 CTestStep* CSystestFilestoreSuite::CreateTestStep(const TDesC& aStepName)
       
    88 /**
       
    89  * @return - A CTestStep derived instance
       
    90  * Secure and non-secure variants
       
    91  * Implementation of CTestServer pure virtual
       
    92  */
       
    93     {
       
    94     CTestStep* testStep = NULL;
       
    95 
       
    96 
       
    97     if (aStepName == KCreateFile)
       
    98         {
       
    99         testStep = new CTestFSCreateFile();
       
   100         }
       
   101     else if(aStepName == KTestFSReadFile)
       
   102         {
       
   103          testStep = new CTestFSReadFile();   
       
   104         }
       
   105     else if(aStepName == KPanicExample)
       
   106         {
       
   107         testStep = new CTestFSPanicExample();
       
   108         }
       
   109     
       
   110     return testStep;
       
   111     }