tzservices/tzserver/test/Unit/src/DstUnitTestServer.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2002-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 "DstUnitServer.h"
       
    17 
       
    18 // Test step include files
       
    19 #include "dstdatabasemanagerstep.h"
       
    20 #include "encodedrulesstep.h"
       
    21 #include "StepSetLocation.h"
       
    22 #include "tzupdatenotification.h"
       
    23 #include "TzCachingTestStep.h"
       
    24 #include "IsDaylightSavingsOn.h"
       
    25 #include "actualisedrules.h"
       
    26 #include "tzrulesteststep.h"
       
    27 
       
    28 
       
    29 _LIT(KServerName,"DstUnitTestServer");
       
    30 _LIT(KTzUserDataDb, "c:\\private\\1020383e\\SQLite__tzuserdata.db");
       
    31 
       
    32 
       
    33 //static RFs fsSession;
       
    34 
       
    35 
       
    36 /**
       
    37 Called inside the MainL() function to create and start the CTestServer derived
       
    38 server.
       
    39 
       
    40 @return - Instance of the test server
       
    41 */
       
    42 CDstUnitServer* CDstUnitServer::NewL()
       
    43 	{
       
    44 	CDstUnitServer * server = new (ELeave) CDstUnitServer();
       
    45 	CleanupStack::PushL(server);
       
    46 	server-> ConstructL(KServerName);
       
    47 	CleanupStack::Pop(server);
       
    48 	return server;
       
    49 	}
       
    50 
       
    51 
       
    52 LOCAL_C void MainL()
       
    53 	{
       
    54 	RFs fsSession;
       
    55 	
       
    56 	User::LeaveIfError(fsSession.Connect());
       
    57 	TInt ret = fsSession.Delete(KTzUserDataDb);
       
    58 	if(ret != KErrNotFound)
       
    59 		{
       
    60 		User::LeaveIfError(ret);
       
    61 		}
       
    62 	fsSession.Close();
       
    63 	
       
    64 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    65 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    66 
       
    67 	CActiveScheduler* sched = NULL;
       
    68 	sched = new(ELeave) CActiveScheduler;
       
    69 	CActiveScheduler::Install(sched);
       
    70 	CDstUnitServer* server = NULL;
       
    71 
       
    72 	// Create the CTestServer derived server.
       
    73 	TRAPD(err, server = CDstUnitServer::NewL());
       
    74 
       
    75 	if(!err)
       
    76 		{
       
    77 		// Sync with the client and enter the active scheduler.
       
    78 		RProcess::Rendezvous(KErrNone);
       
    79 		sched->Start();
       
    80 		}
       
    81 
       
    82 	delete server;
       
    83 	delete sched;
       
    84 
       
    85 	User::LeaveIfError(fsSession.Connect());
       
    86 	ret = fsSession.Delete(KTzUserDataDb);
       
    87 	if(ret != KErrNotFound)
       
    88 		{
       
    89 		User::LeaveIfError(ret);
       
    90 		}
       
    91 	fsSession.Close();
       
    92 	}
       
    93 
       
    94 
       
    95 /**
       
    96 @return Standard Epoc error code on exit.
       
    97 */
       
    98 GLDEF_C TInt E32Main()
       
    99 	{
       
   100 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   101 
       
   102 	if(cleanup == NULL)
       
   103 		{
       
   104 		return KErrNoMemory;
       
   105 		}
       
   106 
       
   107 	TRAP_IGNORE(MainL());
       
   108 
       
   109 	delete cleanup;
       
   110 
       
   111 	return KErrNone;
       
   112     }
       
   113 
       
   114 
       
   115 /**
       
   116 Implementation of CTestServer pure virtual method.
       
   117 
       
   118 @param aStepName Name of the test step.
       
   119 
       
   120 @return A CTestStep derived instance.
       
   121 */
       
   122 CTestStep* CDstUnitServer::CreateTestStep(const TDesC& aStepName)
       
   123 	{
       
   124 	CTestStep* testStep = NULL;
       
   125 
       
   126 	if(aStepName == KDstDatabaseManagerStep)
       
   127     	{
       
   128 		testStep = new CDstDatabaseManagerStep(*this);
       
   129     	}
       
   130 	else if (aStepName == KStepTZConfigAgent)
       
   131         {
       
   132 		testStep = new CTZConfigAgentTest(*this);
       
   133         }
       
   134 	else if (aStepName == KStepSetLocation)
       
   135         {
       
   136 		testStep = new CSetLocation(*this);
       
   137         }
       
   138 	else if (aStepName == KStepConvertTime)
       
   139         {
       
   140 		testStep = new CConvertTime(*this);
       
   141         }
       
   142 	else if (aStepName == KEncodedRulesStep)
       
   143         {
       
   144 		testStep = new CEncodedRulesStep(*this);
       
   145         }
       
   146 	else if (aStepName == KTzUpdateNotification)
       
   147         {
       
   148 		testStep = new CTzUpdateNotification(*this);
       
   149         }
       
   150 	else if (aStepName == KStepGetOffsets)
       
   151         {
       
   152 		testStep = new CGetOffsetsTest(*this);
       
   153         }
       
   154 	else if (aStepName == KTimezoneCacheTestName)
       
   155         {
       
   156 		testStep = new CTzCachingTestStep(*this);
       
   157         }
       
   158 	else if (aStepName == KDaylightSavingsStep)
       
   159         {
       
   160         testStep = new CDaylightSavingsTest( *this );
       
   161         }
       
   162 	else if(aStepName == KActualisedRules)
       
   163 	    {
       
   164 		testStep = new CActualisedRules();
       
   165 	    }
       
   166 	else if(aStepName == KTzRules)
       
   167 	    {
       
   168 		testStep = new CTzRulesTestStep();
       
   169 	    }
       
   170 
       
   171 	return testStep;
       
   172 	}