installationservices/swcomponentregistry/test/tscr/source/tscrserver.cpp
changeset 24 84a16765cd86
child 25 98b66e4fb0be
equal deleted inserted replaced
6:aba6b8104af3 24:84a16765cd86
       
     1 /*
       
     2 * Copyright (c) 2008-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 the License "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 * Implements the test server of the Software Component Registry test harness
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "tscrserver.h" 			// TEF Test Server
       
    21 #include "tscrstep.h" 				// TEF Steps Test Code
       
    22 #include "componentmanagementsteps.h"
       
    23 #include "componentquerysteps.h"
       
    24 #include "transactionmanagementsteps.h"
       
    25 #include "subsessionsteps.h"
       
    26 #include "sifsteps.h"
       
    27 #include "appmanagersteps.h"
       
    28 #include "deletescrdbstep.h"
       
    29 #include "pluginmanagementsteps.h"
       
    30 #include "installloghistorysteps.h"
       
    31 
       
    32 CScrTestServer* CScrTestServer::NewL()
       
    33 /**
       
    34 	Called inside the MainL() function to create and start the CTestServer derived server.
       
    35 	@return Instance of the test server
       
    36  */
       
    37 	{	
       
    38 	CScrTestServer* server = new (ELeave) CScrTestServer();
       
    39 	CleanupStack::PushL(server);
       
    40 	User::LeaveIfError(server->iFs.Connect());
       
    41 	User::LeaveIfError(server->iFs.ShareProtected());
       
    42 	User::LeaveIfError(server->iFs.CreatePrivatePath(server->iFs.GetSystemDrive()));
       
    43 	server->ConstructL(KScrTestServerName);
       
    44 	CleanupStack::Pop(server);
       
    45 	return server;
       
    46 	}
       
    47 	
       
    48 	
       
    49 CScrTestServer::~CScrTestServer()
       
    50 /**
       
    51  	Destructor.
       
    52  */
       
    53 	{
       
    54 	iFs.Close();	
       
    55 	}
       
    56 
       
    57 
       
    58 LOCAL_C void MainL()
       
    59 	{
       
    60 	
       
    61 	CActiveScheduler *scheduler = new(ELeave) CActiveScheduler;
       
    62 	CActiveScheduler::Install(scheduler);
       
    63 
       
    64 	CScrTestServer* server = NULL;
       
    65 	
       
    66 	// Create the CTestServer derived server
       
    67 	TRAPD(err,server = CScrTestServer::NewL());
       
    68 	if(!err)
       
    69 		{
       
    70 		// Sync with the client and enter the active scheduler
       
    71 		RProcess::Rendezvous(KErrNone);
       
    72 		scheduler->Start();
       
    73 		}
       
    74 		
       
    75 	delete server;
       
    76 	delete scheduler;
       
    77 	}
       
    78 
       
    79 
       
    80 GLDEF_C TInt E32Main()
       
    81 /**
       
    82  * @return - Standard Epoc error code on process exit
       
    83  * Process entry point. Called by client using RProcess API
       
    84  */
       
    85 	{
       
    86 	__UHEAP_MARK;
       
    87 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    88 	if(cleanup == NULL)
       
    89 		{
       
    90 		return KErrNoMemory;
       
    91 		}
       
    92 	TRAPD(err,MainL());
       
    93 	delete cleanup;
       
    94 	__UHEAP_MARKEND;
       
    95 	return err;
       
    96     }
       
    97 
       
    98 TBool CScrTestServer::IsPerformanceTestStep(const TDesC& aStepName, TPtrC& aStrippedName)
       
    99 	{
       
   100 	_LIT(KPerformanceStepKeyWord, "Performance-");
       
   101 	if (KErrNotFound == aStepName.FindF(KPerformanceStepKeyWord()))
       
   102 		{
       
   103 		aStrippedName.Set(aStepName);
       
   104 		return EFalse;
       
   105 		}
       
   106 	
       
   107 	TInt len = KPerformanceStepKeyWord().Length();
       
   108 	aStrippedName.Set(aStepName.Mid(len));
       
   109 	return ETrue;
       
   110 	}
       
   111 
       
   112 CTestStep* CScrTestServer::CreateTestStep(const TDesC& aStepName)
       
   113 /**
       
   114 	Creates a new test step.
       
   115 	@param aStepName The name of the requested test step.
       
   116 	@return A pointer to the object of the requested test step.
       
   117  */
       
   118 	{
       
   119 	TBool performanceStep = EFalse;
       
   120 	TPtrC strippedStepName;
       
   121 	performanceStep = IsPerformanceTestStep(aStepName, strippedStepName);
       
   122 	
       
   123 	// Initialise test step object to NULL if no TEF steps are assigned
       
   124 	CTestStep* testStep = NULL;
       
   125 	
       
   126 	if (strippedStepName == KScrAddComponentStep)
       
   127 		testStep = new CScrAddComponentStep(*this);
       
   128 	else if (strippedStepName == KScrSetComponentPropertyStep)
       
   129 		testStep = new CScrSetComponentPropertyStep(*this);
       
   130 	else if (strippedStepName == KScrRegisterFileStep)
       
   131 		testStep = new CScrRegisterFileStep(*this);
       
   132 	else if (strippedStepName == KScrAddFilePropertyStep)
       
   133 		testStep = new CScrAddFilePropertyStep(*this);
       
   134 	else if (strippedStepName == KScrSetCommonPropertyStep)
       
   135 		testStep = new CScrSetCommonPropertyStep(*this);
       
   136 	else if (strippedStepName == KScrDeleteComponentPropertyStep)
       
   137 		testStep = new CScrDeleteComponentPropertyStep(*this);	
       
   138 	else if (strippedStepName == KScrDeleteFilePropertyStep)
       
   139 		testStep = new CScrDeleteFilePropertyStep(*this);	
       
   140 	else if (strippedStepName == KScrUnregisterFileStep)
       
   141 		testStep = new CScrUnregisterFileStep(*this);
       
   142 	else if (strippedStepName == KScrDeleteComponentStep)
       
   143 		testStep = new CScrDeleteComponentStep(*this);
       
   144 	else if (strippedStepName == KScrDeleteAllComponentsStep)
       
   145 		testStep = new CScrDeleteAllComponentsStep(*this);
       
   146 	else if (strippedStepName == KScrApplyTransactionStep)
       
   147 		testStep = new CScrApplyTransactionStep(*this);
       
   148 	else if (strippedStepName == KScrCreateTransactionStep)
       
   149 		testStep = new CScrCreateTransactionStep(*this);
       
   150 	else if (strippedStepName == KScrManageAnotherTransactionStep)
       
   151 		testStep = new CScrManageAnotherTransactionStep(*this);	
       
   152 	else if (strippedStepName == KScrGetComponentStep)
       
   153 		testStep = new CScrGetComponentStep(*this);
       
   154 	else if (strippedStepName == KScrGetComponentLocalizedStep)
       
   155 	        testStep = new CScrGetComponentLocalizedStep(*this);
       
   156 	else if (strippedStepName == KScrGetFilePropertiesStep)
       
   157 		testStep = new CScrGetFilePropertiesStep(*this);	
       
   158 	else if (strippedStepName == KScrGetFilePropertyStep)
       
   159 		testStep = new CScrGetFilePropertyStep(*this);	
       
   160 	else if (strippedStepName == KScrGetFileComponentsStep)
       
   161 		testStep = new CScrGetFileComponentsStep(*this);
       
   162 	else if (strippedStepName == KScrGetComponentPropertiesStep)
       
   163 		testStep = new CScrGetComponentPropertiesStep(*this);
       
   164 	else if (strippedStepName == KScrGetComponentIdsStep)
       
   165 		testStep = new CScrGetComponentIdsStep(*this);
       
   166 	else if (strippedStepName == KScrGetComponentPropertyStep)
       
   167 		testStep = new CScrGetComponentPropertyStep(*this);
       
   168 	else if (strippedStepName == KScrComponentRegistrySubsessionStep)
       
   169 		testStep = new CScrComponentRegistrySubsessionStep(*this);
       
   170 	else if (strippedStepName == KScrFileListSubsessionStep)
       
   171 		testStep = new CScrFileListSubsessionStep(*this);
       
   172 	else if (strippedStepName == KScrGetPluginStep)
       
   173 		testStep = new CScrGetPluginStep(*this);
       
   174 	else if (strippedStepName == KScrSetScomoStateStep)
       
   175 		testStep = new CScrSetScomoStateStep(*this);	
       
   176 	else if (strippedStepName == KScrIsMediaPresentStep)
       
   177 		testStep = new CScrIsMediaPresentStep(*this);		
       
   178 	else if (strippedStepName == KScrInstallComponentStep)
       
   179 		testStep = new CScrInstallComponentStep(*this);
       
   180 	else if (strippedStepName == KScrGetComponentFilesCountStep)
       
   181 		testStep = new CScrGetComponentFilesCountStep(*this);
       
   182 	else if (strippedStepName == KScrAddComponentDependencyStep)
       
   183 		testStep = new CScrAddComponentDependencyStep(*this);
       
   184 	else if (strippedStepName == KScrDeleteComponentDependencyStep)
       
   185 		testStep = new CScrDeleteComponentDependencyStep(*this);
       
   186 	else if (strippedStepName == KScrGetComponentWithGlobalIdStep)
       
   187 		testStep = new CScrGetComponentWithGlobalIdStep(*this);
       
   188 	else if (strippedStepName == KScrGetComponentIdStep)
       
   189 		testStep = new CScrGetComponentIdStep(*this);
       
   190 	else if (strippedStepName == KScrGetGlobalIdList)
       
   191 		testStep = new CScrGetGlobalIdListStep(*this);	
       
   192 	else if (strippedStepName == KScrDeleteDbFileStep)
       
   193 		testStep = new CScrDeleteDbFileStep(*this);
       
   194 	else if (strippedStepName == KScrAddSoftwareTypeStep)
       
   195 		testStep = new CScrAddSoftwareTypeStep(*this);
       
   196 	else if (strippedStepName == KScrDeleteSoftwareTypeStep)
       
   197 		testStep = new CScrDeleteSoftwareTypeStep(*this);
       
   198 	else if (strippedStepName == KScrIsComponentOrphaned)
       
   199 		testStep = new CScrIsComponentOrphanedStep(*this);
       
   200 	else if (strippedStepName == KScrCopyDbFileStep)
       
   201 		testStep = new CScrCopyDbFileStep(*this);
       
   202 	else if (strippedStepName == KScrGetLogEntriesStep)
       
   203 		testStep = new CScrGetLogEntriesStep(*this);
       
   204 	else if (strippedStepName == KScrSetLogFileReadOnlyAttrStep)
       
   205 		testStep = new CScrSetLogFileReadOnlyAttrStep(*this);
       
   206 	else if (strippedStepName == KScrCreateLogFileStep)
       
   207 		testStep = new CScrCreateLogFileStep(*this);
       
   208 	else if (strippedStepName == KScrCompareVersions)
       
   209 		testStep = new CScrCompareVersionsStep(*this);
       
   210 	else if (strippedStepName == KScrIsComponentOnReadOnlyDrive)
       
   211 		testStep = new CScrIsComponentOnReadOnlyDriveStep(*this);
       
   212 	else if (strippedStepName == KScrComponentPresence)
       
   213 		testStep = new CScrComponentPresenceStep(*this);
       
   214   	else if (strippedStepName == KScrValuesNegativeStep)
       
   215   		testStep = new CScrValuesNegativeStep(*this);		
       
   216   	else if (strippedStepName == KScrOutOfMemoryStep)
       
   217   		testStep = new SCROufOfMemory(*this);
       
   218 	
       
   219 	if(performanceStep)
       
   220 		{
       
   221 		CScrTestStep *scrTestStep = dynamic_cast<CScrTestStep*>(testStep);
       
   222 		scrTestStep->MarkAsPerformanceStep();
       
   223 		}
       
   224 	
       
   225 	return testStep;
       
   226 	}