os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistrarTest/t_registrar.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistrarTest/t_registrar.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1857 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This file contains test classes and their implementations
    1.18 +// to test production class CRegistrar. Where necessary stubs
    1.19 +// are implemented to help in writing test harness using RTest.
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +#include "RegistryData.h"
    1.24 +#include "EComErrorCodes.h"
    1.25 +#include "EComUidCodes.h"
    1.26 +#include "ImplementationInformation.h"
    1.27 +#include "RegistryData.h"
    1.28 +#include "Registrar.h"
    1.29 +#include "RegistrarObserver.h"
    1.30 +#include "../EcomTestUtils/EcomTestUtils.h"
    1.31 +#include "EComEntryBase.h"
    1.32 +#include "DriveInfo.h"
    1.33 +
    1.34 +#include <e32test.h>
    1.35 +#include <f32file.h>
    1.36 +#include <bautils.h>
    1.37 +#include <startup.hrh>
    1.38 +
    1.39 +#include "baspi.h"
    1.40 +
    1.41 +_LIT (KDataDir, "C:\\private\\10009D8F\\ECom*");
    1.42 +
    1.43 +//We need two different entry RSC and the SPI to fully test CRegistrar
    1.44 +//------------------------------NEW TYPE----------------------------------------
    1.45 +const TUid NewDllUid={0x101F847B};
    1.46 +_LIT(KNewResourceFileNameOnly,"EComExample5.rsc");
    1.47 +_LIT(KNewResourceFileNameC, "C:\\resource\\plugins\\EComExample5.rsc");
    1.48 +_LIT(KNewDllFileNameC, "C:\\sys\\bin\\EComExample5.dll");
    1.49 +_LIT(KNewResourceFileNameZ, "z:\\RAMOnly\\EComExample5.rsc");
    1.50 +_LIT(KNewDllFileNameZ,"z:\\RAMOnly\\EComExample5.dll");
    1.51 +
    1.52 +//We need IIC type 3 RSC to fully test CRegistrar
    1.53 +//------------------------------IIC TYPE 3----------------------------------------
    1.54 +const TUid Type3DllUid = {0x10009E3E};
    1.55 +_LIT(KType3ResourceFileNameOnly,"EComExample12.rsc");
    1.56 +_LIT(KType3ResourceFileNameC, "C:\\resource\\plugins\\EComExample12.rsc");
    1.57 +_LIT(KType3DllFileNameC, "C:\\sys\\bin\\EComExample12.dll");
    1.58 +_LIT(KType3ResourceFileNameZ, "z:\\RAMOnly\\EComExample12.rsc");
    1.59 +_LIT(KType3DllFileNameZ,"z:\\RAMOnly\\EComExample12.dll");
    1.60 +
    1.61 +//We need IIC type 3 RSC with data exceed maximum to fully test CRegistrar
    1.62 +//------------------------------IIC TYPE 3----------------------------------------
    1.63 +_LIT(KType3BadDataResourceFileNameOnly,"EComExampleBadData.rsc");
    1.64 +_LIT(KType3BadDataResourceFileNameC, "C:\\resource\\plugins\\EComExampleBadData.rsc");
    1.65 +_LIT(KType3BadDataDllFileNameC, "C:\\sys\\bin\\EComExampleBadData.dll");
    1.66 +_LIT(KType3BadDataResourceFileNameZ, "z:\\RAMOnly\\EComExampleBadData.rsc");
    1.67 +_LIT(KType3BadDataDllFileNameZ,"z:\\RAMOnly\\EComExampleBadData.dll");
    1.68 +
    1.69 +_LIT(KType3BadData1ResourceFileNameOnly,"EComExampleBadData1.rsc");
    1.70 +_LIT(KType3BadData1ResourceFileNameC, "C:\\resource\\plugins\\EComExampleBadData1.rsc");
    1.71 +_LIT(KType3BadData1DllFileNameC, "C:\\sys\\bin\\EComExampleBadData1.dll");
    1.72 +_LIT(KType3BadData1ResourceFileNameZ, "z:\\RAMOnly\\EComExampleBadData1.rsc");
    1.73 +_LIT(KType3BadData1DllFileNameZ,"z:\\RAMOnly\\EComExampleBadData1.dll");
    1.74 +
    1.75 +_LIT(KType3BadData2ResourceFileNameOnly,"EComExampleBadData2.rsc");
    1.76 +_LIT(KType3BadData2ResourceFileNameC, "C:\\resource\\plugins\\EComExampleBadData2.rsc");
    1.77 +_LIT(KType3BadData2DllFileNameC, "C:\\sys\\bin\\EComExampleBadData2.dll");
    1.78 +_LIT(KType3BadData2ResourceFileNameZ, "z:\\RAMOnly\\EComExampleBadData2.rsc");
    1.79 +_LIT(KType3BadData2DllFileNameZ,"z:\\RAMOnly\\EComExampleBadData2.dll");
    1.80 +
    1.81 +//We need IIC type 2 RSC to fully test CRegistrar
    1.82 +//------------------------------IIC TYPE 2----------------------------------------
    1.83 +_LIT(KType2ResourceFileNameOnly,"EComExample14.rsc");
    1.84 +_LIT(KType2ResourceFileNameC, "C:\\resource\\plugins\\EComExample14.rsc");
    1.85 +_LIT(KType2DllFileNameC, "C:\\sys\\bin\\EComExample14.dll");
    1.86 +_LIT(KType2ResourceFileNameZ, "z:\\RAMOnly\\EComExample14.rsc");
    1.87 +_LIT(KType2DllFileNameZ,"z:\\RAMOnly\\EComExample14.dll");
    1.88 +
    1.89 +//------------------------------LEGACY TYPE-------------------------------------
    1.90 +
    1.91 +// spi test file
    1.92 +_LIT(KEComSpiTestFilePathAndName, "Z:\\Test\\Data\\EcomTest.spi");
    1.93 +// spi test file for testing IIC Type3
    1.94 +_LIT(KEComSpiTestFileType3PathAndName, "Z:\\Test\\Data\\ecomtesttype3.spi");
    1.95 +
    1.96 +const TInt KOneSecond = 1000000;
    1.97 +
    1.98 +const TUid interfaceUidExample12 = {0x10009E36};
    1.99 +const TUid extendedInterfaceUid1 = {0x10009E44};
   1.100 +const TUid extendedInterfaceUid2 = {0x10009E45};
   1.101 +const TUid extendedInterfaceUid3 = {0x10009E46};
   1.102 +
   1.103 +
   1.104 +LOCAL_D RTest test(_L("t_Registrar.exe"));
   1.105 +
   1.106 +LOCAL_D RFs					TheFs;
   1.107 +
   1.108 +LOCAL_D CTrapCleanup* 		TheTrapCleanup 		= NULL;
   1.109 +
   1.110 +LOCAL_D CActiveScheduler*	TheActiveScheduler	= NULL;
   1.111 +
   1.112 +// Used for supressing warning in OOM tests
   1.113 +#define __UNUSED_VAR(var) var = var
   1.114 +
   1.115 +//It is used by some test methods which are called two times:
   1.116 +//from normal test and from OOM test.
   1.117 +static void LeaveIfErrNoMemory(TInt aError)
   1.118 +	{
   1.119 +	if(aError == KErrNoMemory)
   1.120 +		{
   1.121 +		User::Leave(aError);
   1.122 +		}
   1.123 +	}
   1.124 +
   1.125 +/**
   1.126 +TRegistrar_StateAccessor class allows access to private and protected
   1.127 +members of production code class CRegistrar, as its a friend class.
   1.128 +*/
   1.129 +class TRegistrar_StateAccessor
   1.130 +	{
   1.131 +public:
   1.132 +	void DiscoveriesBegin(CRegistrar& aRegistrar);
   1.133 +
   1.134 +	void DiscoveriesComplete(CRegistrar& aRegistrar, TBool aSuccessful);
   1.135 +
   1.136 +	void DriveRemovedL(CRegistrar& aRegistrar, TDriveUnit aDriveUnit);
   1.137 +
   1.138 +	void DriveReinstatedL(CRegistrar& aRegistrar, TDriveUnit aDriveUnit);
   1.139 +
   1.140 +	void RegisterDiscoveryL(CRegistrar& aRegistrar,const TDriveName& aDrive, CPluginBase*& aEntry,TBool aDatFileExists);
   1.141 +
   1.142 +	void ParseL(CRegistrar& aRegistrar,
   1.143 +				CPluginBase*& aEntry,
   1.144 +				CRegistryData::CDllData& aDll);
   1.145 +
   1.146 +	void ParseRegistrationDataL(CRegistrar& aRegistrar,
   1.147 +				CPluginBase*& aEntry,
   1.148 +				TDriveUnit& aDriveUnit,
   1.149 +				TBool aUpdate,
   1.150 +				TInt aRegistryDriveIndex,
   1.151 +				CRegistryData::CDriveData* aDriveData);
   1.152 +
   1.153 +	CRegistrar::TRegistrarState State(CRegistrar& aRegistrar);
   1.154 +	};
   1.155 +
   1.156 +/**
   1.157 +Parses the resource file associated with an
   1.158 +Interface Implementation Collection for the plugin entry.
   1.159 +
   1.160 +@param		aRegistrar The CRegistrar class object under test
   1.161 +@param		aEntry an ecom entry discovered
   1.162 +@param		aDll CRegistrar::CDllData object in which parsed data needs to be stored
   1.163 +@pre 		CRegistrar should be fully constructed.
   1.164 +@post		The resource file is parsed and the data is added to 'aDll'.
   1.165 + */
   1.166 +void TRegistrar_StateAccessor::ParseL(CRegistrar& aRegistrar,
   1.167 +									  CPluginBase*& aEntry,
   1.168 +									  CRegistryData::CDllData& aDll)
   1.169 +
   1.170 +	{
   1.171 +	aRegistrar.ParseL(aEntry,aDll);
   1.172 +	}
   1.173 +
   1.174 +/**
   1.175 +Determines if the directory entry for an Interface Implementation
   1.176 +Collection requires registration. Parses and registers the plugin entry
   1.177 +associated with the resource file if entry is not already registered.
   1.178 +
   1.179 +@param		aRegistrar The CRegistrar class object under test
   1.180 +@param		aEntry Directory entry for the Interface Impplementation Collection.
   1.181 +@param		aRscFileName Resource file from which to extract the data
   1.182 +@param		aDrive Drive on which registry data has been found on
   1.183 +@param		aUpdate Flag indicating if this is an update, or new entry.
   1.184 +@param		aRegistryDriveIndex Index within the registry data
   1.185 +			for the branch that the registry entry was found within.
   1.186 +@pre 		CRegistrar is fully constructed.
   1.187 +@post		The Interface Implementation Collection entry has been processed appropriately.
   1.188 +*/
   1.189 +void TRegistrar_StateAccessor::ParseRegistrationDataL(CRegistrar& aRegistrar,
   1.190 +														CPluginBase*& aEntry,
   1.191 +														TDriveUnit& aDrive,
   1.192 +														TBool aUpdate,
   1.193 +														TInt aRegistryDriveIndex,
   1.194 +														CRegistryData::CDriveData* aDriveData)
   1.195 +	{
   1.196 +	aRegistrar.ParseRegistrationDataL(aEntry, aDrive,aUpdate, aRegistryDriveIndex, aDriveData);
   1.197 +	}
   1.198 +
   1.199 +/**
   1.200 +Overload of the MDiscovererObserver callback method.
   1.201 +The cue that a registry update is about to occur.
   1.202 +
   1.203 +@param		aRegistrar The CRegistrar class object under test
   1.204 +@pre 		CRegistrar is fully constructed
   1.205 +@post		The Registry data manager has been informed that its internal
   1.206 +			data is out of date.
   1.207 +*/
   1.208 +void TRegistrar_StateAccessor::DiscoveriesBegin(CRegistrar& aRegistrar)
   1.209 +	{
   1.210 +	aRegistrar.DiscoveriesBegin();
   1.211 +	}
   1.212 +
   1.213 +/**
   1.214 +Overload of the MDiscovererObserver callback method.
   1.215 +The cue that a registry update is done.
   1.216 +
   1.217 +@param		aRegistrar The CRegistrar class object under test
   1.218 +@param		aSuccessful The registry data has been updated successfully
   1.219 +@pre 		CRegistrar is fully constructed
   1.220 +@post		The current registry data and the internal access indexes have been rebuilt.
   1.221 +*/
   1.222 +void TRegistrar_StateAccessor::DiscoveriesComplete(CRegistrar& aRegistrar,
   1.223 +												   TBool aSuccessful)
   1.224 +	{
   1.225 +	aRegistrar.DiscoveriesComplete(aSuccessful, EPluginProcessingTypeAll);
   1.226 +	}
   1.227 +
   1.228 +/**
   1.229 +Overload of the MDiscovererObserver callback method.
   1.230 +Signals registry that the registered Interface Implementation
   1.231 +Collections stored upon the specified drive are no
   1.232 +longer available for use.
   1.233 +
   1.234 +@param		aRegistrar The CRegistrar class object under test
   1.235 +@param		aDrive	The drive identifier.
   1.236 +@pre 		CRegistrar is fully constructed.
   1.237 +@post		The registered Interface Implementation Collections
   1.238 +			stored upon the specified drive are no
   1.239 +			longer available for use.
   1.240 +*/
   1.241 +void TRegistrar_StateAccessor::DriveRemovedL(CRegistrar& aRegistrar,
   1.242 +											 TDriveUnit aDrive)
   1.243 +	{
   1.244 +	aRegistrar.DriveRemovedL(aDrive);
   1.245 +	}
   1.246 +
   1.247 +/**
   1.248 +Overload of the MDiscovererObserver callback method.
   1.249 +Signals registry that the registered Interface
   1.250 +Implementation Collections stored upon the specified drive are again
   1.251 +available for use.
   1.252 +
   1.253 +@param		aRegistrar The CRegistrar class object under test
   1.254 +@param		aDrive	The drive identifier.
   1.255 +@pre 		CRegistrar is fully constructed.
   1.256 +@post		The registered Interface Implementation Collections
   1.257 +			stored upon the specified drive are again
   1.258 +			made available for use.
   1.259 +*/
   1.260 +void TRegistrar_StateAccessor::DriveReinstatedL(CRegistrar& aRegistrar,
   1.261 +												   TDriveUnit aDrive)
   1.262 +	{
   1.263 +	aRegistrar.DriveReinstatedL(aDrive);
   1.264 +	}
   1.265 +
   1.266 +/**
   1.267 +Overload of the MDiscovererObserver callback method.
   1.268 +Adds the specified Interface Implementation Collection Entry to the registry.
   1.269 +
   1.270 +@param		aRegistrar The CRegistrar class object under test
   1.271 +@param		aDirEntry The plugin entry to register.
   1.272 +@pre 		CRegistrar is fully constructed
   1.273 +@post		The plugin entry is registered.
   1.274 +*/
   1.275 +void TRegistrar_StateAccessor::RegisterDiscoveryL(CRegistrar& aRegistrar,
   1.276 +												  const TDriveName& aDrive,
   1.277 +												  CPluginBase*& aEntry,
   1.278 +												  TBool aDatFileExists )
   1.279 +	{
   1.280 +	aRegistrar.RegisterDiscoveryL(aDrive,aEntry,aDatFileExists);
   1.281 +	}
   1.282 +
   1.283 +/**
   1.284 +Retrieves the object's current state.
   1.285 +
   1.286 +@return 	TCRegistarState the CRegistrar's current state.
   1.287 +@pre		CRegistrar is fully constructed.
   1.288 +@post 		the CRegistrar's current state has been returned.
   1.289 +*/
   1.290 +CRegistrar::TRegistrarState TRegistrar_StateAccessor::State(CRegistrar& aRegistrar)
   1.291 +	{
   1.292 +	return aRegistrar.State();
   1.293 +	}
   1.294 +
   1.295 +/**
   1.296 +TRegistryData_StateAccessor class allows access to private and protected
   1.297 +members of production code class CRegistryData, as its a friend class.
   1.298 +*/
   1.299 +class TRegistryData_StateAccessor
   1.300 +	{
   1.301 +public:
   1.302 +	TInt FindImplementation(CRegistryData& aRegistryData,
   1.303 +				const TUid aImplUid,
   1.304 +				const TUid aInterfaceUid,
   1.305 +				CRegistryData::CImplementationData*& aImplData) const;
   1.306 +	};
   1.307 +
   1.308 +/**
   1.309 +@return		KErrNone if found otherwise KErrNotFound
   1.310 +@param		aRegistryData The CRegistryData class object
   1.311 +@param		aImplUid The implementation to find.
   1.312 +@param		aInterfaceUid If greater than 0 the interface associated with the
   1.313 +			implementation to find.
   1.314 +@param		aImplData The found implementation data.
   1.315 +@pre 		CRegistrar is fully constructed
   1.316 +*/
   1.317 +TInt TRegistryData_StateAccessor::FindImplementation(CRegistryData& aRegistryData,
   1.318 +												const TUid aImplUid,
   1.319 +												const TUid aInterfaceUid,
   1.320 +												CRegistryData::CImplementationData*& aImplData) const
   1.321 +	{
   1.322 +	return aRegistryData.FindImplementation(aImplUid, aInterfaceUid, aImplData);
   1.323 +	}
   1.324 +
   1.325 +
   1.326 +/**
   1.327 +The implementation of the abstract Registrar Observer class,
   1.328 +used for recieving notifications of registry changes.
   1.329 +Stub class(for CEComServer) used for the creation of CRegistrar class object.
   1.330 +CEComServer class acts as observer for CRegistrar.
   1.331 +*/
   1.332 +class CTestRegistrarObserver : public MRegistrarObserver // codescanner::missingcclass
   1.333 +	{
   1.334 +public:
   1.335 +	// This function is used by RegistrarObserver (i.e.CEComServer) to notify its
   1.336 +	// clients(REComSession objects) that some change has happened in Registry.
   1.337 +	// Here we have no clients to notify, so no implementaion.
   1.338 +	void Notification( TInt /*aNotification*/ ) {}
   1.339 +	};
   1.340 +
   1.341 +/**
   1.342 +Test class for object CRegistrar.
   1.343 +This class provides the parameters and behaviour that
   1.344 +allows this class to behave normally under a test
   1.345 +scenario.
   1.346 +*/
   1.347 +class CRegistrarTest : public CBase
   1.348 +	{
   1.349 +public:
   1.350 +
   1.351 +	static CRegistrarTest* NewL(TBool aIsFullDiscovery);
   1.352 +	virtual ~CRegistrarTest();
   1.353 +	const CImplementationInformation * GetImplementationDataL();
   1.354 +
   1.355 +	void EnableDisableTestL();
   1.356 +	void ResumeSuspendTestL();
   1.357 +	void DiscoveriesBegin_Register_CompleteTestL();
   1.358 +	void DriveRemovedReinstatedTestL();
   1.359 +	void ParseTestL();
   1.360 +	void ParseType2TestL();
   1.361 +	void ParseType3TestL();
   1.362 +	void ParseType3BadDataTestL();
   1.363 +	void ParseRegistrationDataTestL();
   1.364 +	void ParseRegistrationDataType3TestL();
   1.365 +	void StateTransitionTestL();
   1.366 +	void ParseSpiRegistrationDataTestL();
   1.367 +	void ParseSpiRegistrationDataType3TestL();
   1.368 +	void ParseSpiTestL();
   1.369 +	void ParseSpiType3TestL();
   1.370 +
   1.371 +private:
   1.372 +	CRegistrarTest();
   1.373 +	void ConstructL(TBool aIsFullDiscovery);
   1.374 +	void ParseBadDataTestL(const TDesC& aRscFullName, const TDesC& aRscNameOnly);
   1.375 +public:
   1.376 +	/** The instance of the class under test */
   1.377 +	CRegistrar* iRegistrar;
   1.378 +
   1.379 +	/** The instance of the State Accessor class */
   1.380 +	TRegistrar_StateAccessor* iStateAccessor;
   1.381 +
   1.382 +	/** The registry data instance required to construct a CRegistrar object */
   1.383 +	CRegistryData* iRegistryData;
   1.384 +
   1.385 +	/** The instance of the Registry Data State Accessor class */
   1.386 +	TRegistryData_StateAccessor* iRegistryDataStateAccessor;
   1.387 +
   1.388 +	/** The instance of the observer of CRegistrar class */
   1.389 +	MRegistrarObserver* iRegistrarObserver;
   1.390 +
   1.391 +	/** The destination for the data discovered during a parse */
   1.392 +	CRegistryData::CDllData* iDllData;
   1.393 +
   1.394 +	/** Unique Id of the ECOM dll */
   1.395 +	TUid    iDllUid;
   1.396 +
   1.397 +	/** Unique Id of an interface implementation */
   1.398 +	TUid	iImplementationUid;
   1.399 +
   1.400 +	/** Unique Id of an interface */
   1.401 +	TUid	iInterfaceUid;
   1.402 +
   1.403 +	/** The drive on which interface implementations can be found */
   1.404 +	TDriveUnit	iDriveUnit;
   1.405 +
   1.406 +	/** Ecom plugin which contains interface implementations. Used in Registration APIs.*/
   1.407 +	TEntry		iDllEntry;
   1.408 +	};
   1.409 +
   1.410 +/**
   1.411 +Standardised safe construction which
   1.412 +leaves nothing on the cleanup stack.
   1.413 +
   1.414 +@param		aIsFullDiscovery whether the constructor make full discovery
   1.415 +@post		CRegistrarTest is fully constructed and initialised.
   1.416 +*/
   1.417 +CRegistrarTest* CRegistrarTest::NewL(TBool aIsFullDiscovery)
   1.418 +	{
   1.419 +	CRegistrarTest* self = new (ELeave) CRegistrarTest();
   1.420 +	CleanupStack::PushL(self);
   1.421 +	self->ConstructL(aIsFullDiscovery);
   1.422 +	CleanupStack::Pop(self);
   1.423 +	return self;
   1.424 +	}
   1.425 +
   1.426 +/**
   1.427 +Standardized default c'tor
   1.428 +
   1.429 +@post		CRegistrarTest is fully constructed.
   1.430 +*/
   1.431 +CRegistrarTest::CRegistrarTest()
   1.432 +:	CBase(),
   1.433 +	iDriveUnit(EDriveC)
   1.434 +	{
   1.435 +	iDllUid.iUid			= 0x101F847B; // Dlluid for Ecom plugin EComExample5.dll
   1.436 +	iInterfaceUid.iUid		= 0x10009DC0; // Interface uid for interface contained in above plugin
   1.437 +	iImplementationUid.iUid = 0x101f847C; // Implementaion uid for above interface
   1.438 +	TUid uid1 = {0};
   1.439 +	TUid uid2 = {0};
   1.440 +	iDllEntry.iType = TUidType(uid1, uid2, iDllUid);//Setting Dlluid to plugin entry
   1.441 +	}
   1.442 +
   1.443 +/**
   1.444 +Destructor.
   1.445 +
   1.446 +@post		This object is properly destroyed.
   1.447 +*/
   1.448 +CRegistrarTest::~CRegistrarTest()
   1.449 +	{
   1.450 +	delete iDllData;
   1.451 +	delete iRegistrar;
   1.452 +	delete iRegistryData;
   1.453 +	delete iRegistrarObserver;
   1.454 +	delete iStateAccessor;
   1.455 +	delete iRegistryDataStateAccessor;
   1.456 +	}
   1.457 +
   1.458 +/**
   1.459 +Standardized 2nd(Initialization) phase of two phase construction.
   1.460 +
   1.461 +@param		aIsFullDiscovery whether the constructor make full discovery
   1.462 +@post		CRegistrarTest is fully constructed.
   1.463 +*/
   1.464 +void CRegistrarTest::ConstructL(TBool aIsFullDiscovery)
   1.465 +	{
   1.466 +	CRegistryData::CDriveData* driveData=NULL;
   1.467 +	iRegistrarObserver = new (ELeave) CTestRegistrarObserver;
   1.468 +	iStateAccessor	   = new (ELeave) TRegistrar_StateAccessor;
   1.469 +	iRegistryDataStateAccessor	   = new (ELeave) TRegistryData_StateAccessor;
   1.470 +	iRegistryData	   = CRegistryData::NewL(TheFs);
   1.471 +	iRegistrar		   = CRegistrar::NewL(*iRegistryData, *iRegistrarObserver, TheFs);
   1.472 +	if(aIsFullDiscovery)
   1.473 +		{
   1.474 +		iRegistrar->ProcessSSAEventL(EStartupStateNonCritical);
   1.475 +		}
   1.476 +	iDllData		   = CRegistryData::CDllData::NewLC(driveData);
   1.477 +	CleanupStack::Pop(iDllData);
   1.478 +	}
   1.479 +
   1.480 +
   1.481 +/**
   1.482 +Returns information of a particular interface implementation.
   1.483 +
   1.484 +@return		Information on the requested implementation
   1.485 +@pre 		This object is fully constructed
   1.486 +*/
   1.487 +const CImplementationInformation * CRegistrarTest::GetImplementationDataL()
   1.488 +	{
   1.489 +	CRegistryData::CImplementationData *implementationData=NULL;
   1.490 +	TUid dummyUid;
   1.491 +	dummyUid.iUid = 0;
   1.492 +	User::LeaveIfError(iRegistryDataStateAccessor->FindImplementation(*iRegistryData, iImplementationUid,
   1.493 +																dummyUid, implementationData));
   1.494 +	return implementationData->iImplInfo;
   1.495 +	}
   1.496 +
   1.497 +/**
   1.498 +The test executes by first Disabling the Implementation then by
   1.499 +Enabling it.
   1.500 +
   1.501 +@SYMTestCaseID          SYSLIB-ECOM-CT-0727
   1.502 +@SYMTestCaseDesc	    Tests for enabling and disabling the Implementation
   1.503 +@SYMTestPriority 	    High
   1.504 +@SYMTestActions  	    Fetch the Implementation information for testing for iImplementationUid
   1.505 +                        Disable and enable the implementation for the unique UID
   1.506 +@SYMTestExpectedResults The test must not fail.
   1.507 +@SYMREQ                 REQ0000
   1.508 +*/
   1.509 +void CRegistrarTest::EnableDisableTestL()
   1.510 +	{
   1.511 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0727 "));
   1.512 +	const CImplementationInformation *implimentationInfo = NULL;
   1.513 +
   1.514 +	// Get the Implementation information for testing for iImplementationUid.
   1.515 +	// Implementation for iImplementationUid should be registered to
   1.516 +	// run this test successfully.
   1.517 +	TRAPD(err, implimentationInfo = GetImplementationDataL());
   1.518 +	::LeaveIfErrNoMemory(err);
   1.519 +	test(err == KErrNone);
   1.520 +	test(implimentationInfo != NULL);
   1.521 +
   1.522 +	// Disable the implementaion
   1.523 +	err = iRegistrar->Disable(iImplementationUid);
   1.524 +	::LeaveIfErrNoMemory(err);
   1.525 +	test(KErrNone == err);
   1.526 +	test(implimentationInfo->Disabled());//It should be disabled
   1.527 +
   1.528 +
   1.529 +	// Enable the implementaion
   1.530 +	err = iRegistrar->Enable(iImplementationUid);
   1.531 +	::LeaveIfErrNoMemory(err);
   1.532 +	test(KErrNone == err);
   1.533 +	test(!implimentationInfo->Disabled());//It should be enabled
   1.534 +	}
   1.535 +
   1.536 +/**
   1.537 +The test executes by first suspending the discoverer then by resuming it.
   1.538 +
   1.539 +@SYMTestCaseID          SYSLIB-ECOM-CT-0728
   1.540 +@SYMTestCaseDesc	    Tests for overloaded MBackupNotifierObserver's Suspend and Resume functions
   1.541 +@SYMTestPriority 	    High
   1.542 +@SYMTestActions  	    The test executes by first calling CRegistrar's suspend and then by resume.
   1.543 +@SYMTestExpectedResults The test must not fail.
   1.544 +@SYMREQ                 REQ0000
   1.545 +*/
   1.546 +void CRegistrarTest::ResumeSuspendTestL()
   1.547 +	{
   1.548 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0728 "));
   1.549 +	TInt err = iRegistrar->Suspend();
   1.550 +	::LeaveIfErrNoMemory(err);
   1.551 +	test(err == KErrNone);
   1.552 +
   1.553 +	err = iRegistrar->Resume();
   1.554 +	::LeaveIfErrNoMemory(err);
   1.555 +	test(err == KErrNone);
   1.556 +	}
   1.557 +
   1.558 +/**
   1.559 +The test executes by calling DiscoveriesBegin, RegisterDiscoveryL and
   1.560 +DiscoveriesComplete in sequence to register the plugin.
   1.561 +
   1.562 +@SYMTestCaseID          SYSLIB-ECOM-CT-0729
   1.563 +@SYMTestCaseDesc	    Tests for registering the DLL interfaces
   1.564 +@SYMTestPriority 	    High
   1.565 +@SYMTestActions  	    Calls up DiscoveriesBegin, RegisterDiscoveryL and
   1.566 +						DiscoveriesComplete in sequence to register the plugin and
   1.567 +						verifies that DLL's have been registered succesfully.
   1.568 +@SYMTestExpectedResults The test must not fail.
   1.569 +@SYMREQ                 REQ0000
   1.570 +*/
   1.571 +void CRegistrarTest::DiscoveriesBegin_Register_CompleteTestL()
   1.572 +	{
   1.573 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0729 "));
   1.574 +	// The following three steps need to be executed to successfully
   1.575 +	// register the plugin
   1.576 +	iStateAccessor->DiscoveriesBegin(*iRegistrar);
   1.577 +
   1.578 +//-----------------REGISTRATION PART------------------------------------
   1.579 +	CPluginBase* entryBase=NULL;
   1.580 +	TInt err=KErrNone;
   1.581 +	TBool update = EFalse;
   1.582 +	TInt  driveIndex = KErrNotFound;		//Used as return parameter used below
   1.583 +	TBool isDriveRegistered = EFalse;		//Used as return parameter used below
   1.584 +	CRegistryData::CDriveData* driveData = NULL;
   1.585 +
   1.586 +
   1.587 +	//Testing a RSc based entry using EComExample5.dll and EComExample5.rsc
   1.588 +	TEntry rscBasedEntry;
   1.589 +	rscBasedEntry.iName=KNewResourceFileNameOnly;
   1.590 +	err = TheFs.Modified(KNewResourceFileNameC, rscBasedEntry.iModified);
   1.591 +	test(err==KErrNone);
   1.592 +	TParse rscPath;
   1.593 +	rscPath.Set(KNewResourceFileNameC,NULL,NULL);
   1.594 +	entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
   1.595 +	CleanupStack::PushL(entryBase);
   1.596 +
   1.597 +	//Now register this Rsc Entry with the registrar
   1.598 +	TRAP(err, iStateAccessor->RegisterDiscoveryL(*iRegistrar,rscPath.Drive(), entryBase,ETrue));
   1.599 +	::LeaveIfErrNoMemory(err);
   1.600 +	test(err == KErrNone);
   1.601 +	CleanupStack::PopAndDestroy(entryBase);
   1.602 +	entryBase=NULL;
   1.603 +	TRAP(err, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
   1.604 +	::LeaveIfErrNoMemory(err);
   1.605 +	test(driveIndex != KErrNotFound);
   1.606 +	//Verify weather dll interfaces got registered
   1.607 +	// Check whether Rsc based entry is already registered in CRegistryData
   1.608 +
   1.609 +	TRAP(err, isDriveRegistered = iRegistryData->IsRegisteredWithDate(
   1.610 +																		NewDllUid,
   1.611 +																		rscBasedEntry.iModified,
   1.612 +																		update,
   1.613 +																		driveData));
   1.614 +	::LeaveIfErrNoMemory(err);
   1.615 +	test(err == KErrNone);
   1.616 +	test(isDriveRegistered);
   1.617 +	test(!update);// As plugin is just registered, it does not require update.
   1.618 +
   1.619 +	//THE REASON WHY THIS FUNCTION IS MOVED TO THE BACK AS IT PREVENT THE TESTING
   1.620 +	//OF THE LEGACY PLUGINS BEING REGISTERED AS DURING THE VALIDATE REGISTRY
   1.621 +	//THE LEGACY ENTRY WILL BE WIPED OUT
   1.622 +	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
   1.623 +	test(iRegistrar != NULL);
   1.624 +	}
   1.625 +
   1.626 +/**
   1.627 +@SYMTestCaseID          SYSLIB-ECOM-CT-0730
   1.628 +@SYMTestCaseDesc	    Tests for CRegistrar::DriveRemovedL,DriveReinstatedL functions
   1.629 +@SYMTestPriority 	    High
   1.630 +@SYMTestActions  	    The test executes by first making the test drive uninstall and
   1.631 +						then testing for Install and Uninstall.
   1.632 +@SYMTestExpectedResults The test must not fail.
   1.633 +@SYMREQ                 REQ0000
   1.634 +*/
   1.635 +void CRegistrarTest::DriveRemovedReinstatedTestL()
   1.636 +	{
   1.637 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0730 "));
   1.638 +	// We are checking with F Drive.
   1.639 +	// The test executes by first removing and then reinstalling
   1.640 +	const TTime modified(0); //Dummy parameter...
   1.641 +	TBool update = EFalse;   //Dummy parameter...
   1.642 +	TBool isDriveRegistered = EFalse;
   1.643 +	TInt  driveIndex = KErrNotFound;
   1.644 +	CRegistryData::CDriveData* driveData = NULL;
   1.645 +
   1.646 +	iDriveUnit = EDriveF;
   1.647 +	TInt error = KErrNone;
   1.648 +	TRAP(error, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
   1.649 +	::LeaveIfErrNoMemory(error);
   1.650 +	TInt err = KErrNone;
   1.651 +	if(driveIndex != KErrNotFound)
   1.652 +	{
   1.653 +	TRAP(err, iRegistryData->IsRegisteredWithDate(
   1.654 +													iDllUid,
   1.655 +													modified,
   1.656 +													update,
   1.657 +
   1.658 +													driveData));
   1.659 +
   1.660 +	::LeaveIfErrNoMemory(err);
   1.661 +	}
   1.662 +
   1.663 +	isDriveRegistered = (driveIndex != KErrNotFound);
   1.664 +
   1.665 +	//Remove the drive from registry if registered
   1.666 +	if(isDriveRegistered)
   1.667 +		{
   1.668 +		TRAP(err, iStateAccessor->DriveRemovedL( *iRegistrar, iDriveUnit));
   1.669 +		::LeaveIfErrNoMemory(err);
   1.670 +		test(err == KErrNone);
   1.671 +
   1.672 +		//Call CRegistryData::IsRegisteredWithDate again to check its removed now
   1.673 +		driveIndex = KErrNotFound;
   1.674 +		TRAP(err, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
   1.675 +		//Drive should not be present
   1.676 +		::LeaveIfErrNoMemory(err);
   1.677 +		test(driveIndex == KErrNotFound);
   1.678 +
   1.679 +		}
   1.680 +
   1.681 +
   1.682 +	// Install the drive in registry
   1.683 +	TRAP(err, iStateAccessor->DriveReinstatedL(*iRegistrar, iDriveUnit));
   1.684 +	::LeaveIfErrNoMemory(err);
   1.685 +	test(err == KErrNone);
   1.686 +
   1.687 +	//Call CRegistryData::IsRegisteredWithDate to check its Reinstalled now
   1.688 +	driveIndex = KErrNotFound;
   1.689 +	TRAP(err, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
   1.690 +	::LeaveIfErrNoMemory(err);
   1.691 +	//Drive should be present now
   1.692 +	test(driveIndex != KErrNotFound);
   1.693 +	TRAP(err, iRegistryData->IsRegisteredWithDate(
   1.694 +													iDllUid,
   1.695 +													modified,
   1.696 +													update,
   1.697 +
   1.698 +													driveData));
   1.699 +	::LeaveIfErrNoMemory(err);
   1.700 +	test(err == KErrNone);
   1.701 +
   1.702 +
   1.703 +	//Remove the drive from registry if it was not registered before
   1.704 +	if(!isDriveRegistered)
   1.705 +		{
   1.706 +		TRAP(err, iStateAccessor->DriveRemovedL( *iRegistrar, iDriveUnit));
   1.707 +		::LeaveIfErrNoMemory(err);
   1.708 +		test(err == KErrNone);
   1.709 +
   1.710 +		//Call CRegistryData::IsRegisteredWithDate again to check its removed now
   1.711 +		driveIndex = KErrNotFound;
   1.712 +		TRAP(err, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
   1.713 +		//Drive should not be present
   1.714 +		::LeaveIfErrNoMemory(err);
   1.715 +		test(driveIndex == KErrNotFound);
   1.716 +		}
   1.717 +	}
   1.718 +
   1.719 +/**
   1.720 +The test executes by parsing the Interface implementaion information
   1.721 +from the given resource file.
   1.722 +
   1.723 +@SYMTestCaseID          SYSLIB-ECOM-CT-0731
   1.724 +@SYMTestCaseDesc	    Tests for verification of Interface implementaion information
   1.725 +@SYMTestPriority 	    High
   1.726 +@SYMTestActions  	    Parse the resource information associated with an
   1.727 +					    Interface Implementation Collection for entry into the registry
   1.728 +					    information.Check for OOM error or parse error.
   1.729 +@SYMTestExpectedResults The test must not fail.
   1.730 +@SYMREQ                 REQ0000
   1.731 +*/
   1.732 +void CRegistrarTest::ParseTestL()
   1.733 +	{
   1.734 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0731 "));
   1.735 +	TInt error=KErrNone;
   1.736 +	CPluginBase* entryBase=NULL;
   1.737 +	CRegistryData::CDllData* dllData=NULL;
   1.738 +	CRegistryData::CInterfaceData* ifData =NULL;
   1.739 +	CRegistryData::CDriveData* driveData = NULL;
   1.740 +
   1.741 +	//Testing a RSC based entry using EComExample5.dll and EComExample5.rsc
   1.742 +	//(101F847B.RSS)
   1.743 +	TEntry rscBasedEntry;
   1.744 +	rscBasedEntry.iName=KNewResourceFileNameOnly;
   1.745 +	error = TheFs.Modified(KNewResourceFileNameC, rscBasedEntry.iModified);
   1.746 +	test(error==KErrNone);
   1.747 +	TParse rscPath;
   1.748 +	rscPath.Set(KNewResourceFileNameC,NULL,NULL);
   1.749 +	TDriveUnit driveUnit(rscPath.Drive());
   1.750 +	error=iRegistryData->FindDriveL(driveUnit,driveData);
   1.751 +	test(error!=KErrNotFound);
   1.752 +	entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
   1.753 +	CleanupStack::PushL(entryBase);
   1.754 +	dllData=CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
   1.755 +
   1.756 +	//Now testing the parseL function
   1.757 +	TRAP(error, iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
   1.758 +	::LeaveIfErrNoMemory(error);
   1.759 +	test(error == KErrNone);
   1.760 +	//Now checking the content of the DllData
   1.761 +	test(dllData->iIfList->Count()==1);
   1.762 +	ifData=(*(dllData->iIfList))[0];
   1.763 +	test(ifData->iInterfaceUid.iUid==0x10009DC0);
   1.764 +	test(ifData->iImplementations->Count()==1);
   1.765 +
   1.766 +	CleanupStack::PopAndDestroy(dllData);
   1.767 +	CleanupStack::PopAndDestroy(entryBase);
   1.768 +	entryBase=NULL;
   1.769 +	dllData=NULL;
   1.770 +	ifData=NULL;
   1.771 +	}
   1.772 +
   1.773 +/**
   1.774 +The test executes by parsing the Interface implementation information with type 2 entries
   1.775 +from the given resource file.
   1.776 +
   1.777 +@SYMTestCaseID          SYSLIB-ECOM-UT-3563
   1.778 +@SYMTestCaseDesc	    Tests for verification of Interface implementation information with type 2 entries
   1.779 +@SYMTestPriority 	    High
   1.780 +@SYMTestActions  	    Parse the resource information associated with an
   1.781 +					    Interface Implementation Collection type 2 for entry into the registry
   1.782 +					    information.Check for OOM error or parse error.
   1.783 +@SYMTestExpectedResults CRegistrar::ParseL() function parses resource file without error.
   1.784 +						Data is interpreted correctly.
   1.785 +@SYMEC                  EC43
   1.786 +*/
   1.787 +void CRegistrarTest::ParseType2TestL()
   1.788 +	{
   1.789 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3563 "));
   1.790 +	TInt error = KErrNone;
   1.791 +	CPluginBase* entryBase = NULL;
   1.792 +	CRegistryData::CDllData* dllData = NULL;
   1.793 +	CRegistryData::CInterfaceData* ifData = NULL;
   1.794 +	CRegistryData::CDriveData* driveData = NULL;
   1.795 +	TUid interfaceUidExample14 = {0x10009E36};
   1.796 +
   1.797 +	//Tests an RSC based entry using EComExample14.dll and EComExample14.rsc
   1.798 +	//(EcomExample14.RSS)
   1.799 +	TEntry rscBasedEntry;
   1.800 +	rscBasedEntry.iName = KType2ResourceFileNameOnly;
   1.801 +	error = TheFs.Modified(KType2ResourceFileNameC, rscBasedEntry.iModified);
   1.802 +	test(error == KErrNone);
   1.803 +	TParse rscPath;
   1.804 +	rscPath.Set(KType2ResourceFileNameC,NULL,NULL);
   1.805 +	TDriveUnit driveUnit(rscPath.Drive());
   1.806 +	error = iRegistryData->FindDriveL(driveUnit,driveData);
   1.807 +	test(error != KErrNotFound);
   1.808 +	entryBase = CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
   1.809 +	CleanupStack::PushL(entryBase);
   1.810 +	dllData = CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
   1.811 +
   1.812 +	//tests the parseL function
   1.813 +	TRAP(error, iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
   1.814 +	::LeaveIfErrNoMemory(error);
   1.815 +	test(error == KErrNone);
   1.816 +	//checks the content of the DllData
   1.817 +	test(dllData->iIfList->Count() == 1);
   1.818 +	ifData = (*(dllData->iIfList))[0];
   1.819 +	test(ifData->iInterfaceUid == interfaceUidExample14);
   1.820 +	CleanupStack::PopAndDestroy(dllData);
   1.821 +	CleanupStack::PopAndDestroy(entryBase);
   1.822 +	}
   1.823 +
   1.824 +/**
   1.825 +The test executes by parsing the Interface implementation information with type 3 entries
   1.826 +from the given resource file.
   1.827 +
   1.828 +@SYMTestCaseID          SYSLIB-ECOM-UT-3564
   1.829 +@SYMTestCaseDesc	    Tests for verification of Interface implementation information with type 3 entries
   1.830 +@SYMTestPriority 	    High
   1.831 +@SYMTestActions  	    Parse the resource information associated with an
   1.832 +					    Interface Implementation Collection type 3 for entry into the registry
   1.833 +					    information.Check for OOM error or parse error.
   1.834 +@SYMTestExpectedResults CRegistrar::ParseL() function parses resource file without error.
   1.835 +						Data is interpreted correctly.
   1.836 +@SYMEC                  EC43
   1.837 +*/
   1.838 +void CRegistrarTest::ParseType3TestL()
   1.839 +	{
   1.840 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3564 "));
   1.841 +	TInt error = KErrNone;
   1.842 +	CPluginBase* entryBase = NULL;
   1.843 +	CRegistryData::CDllData* dllData = NULL;
   1.844 +	CRegistryData::CInterfaceData* ifData = NULL;
   1.845 +	CRegistryData::CDriveData* driveData = NULL;
   1.846 +	CRegistryData::CImplementationData* implData = NULL;
   1.847 +	CImplementationInformation* implInfo = NULL;
   1.848 +
   1.849 +	//Tests an RSC based entry using EComExample12.dll and EComExample12.rsc
   1.850 +	//(EcomExample12.RSS)
   1.851 +	TEntry rscBasedEntry;
   1.852 +	rscBasedEntry.iName = KType3ResourceFileNameOnly;
   1.853 +	error = TheFs.Modified(KType3ResourceFileNameC, rscBasedEntry.iModified);
   1.854 +	test(error == KErrNone);
   1.855 +	TParse rscPath;
   1.856 +	rscPath.Set(KType3ResourceFileNameC,NULL,NULL);
   1.857 +	TDriveUnit driveUnit(rscPath.Drive());
   1.858 +	error = iRegistryData->FindDriveL(driveUnit,driveData);
   1.859 +	test(error != KErrNotFound);
   1.860 +	entryBase = CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
   1.861 +	CleanupStack::PushL(entryBase);
   1.862 +	dllData = CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
   1.863 +
   1.864 +	// Tests the parseL function
   1.865 +	TRAP(error, iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
   1.866 +	::LeaveIfErrNoMemory(error);
   1.867 +	test(error == KErrNone);
   1.868 +	// Checks the content of the DllData
   1.869 +	test(dllData->iIfList->Count() == 1);
   1.870 +	ifData = (*(dllData->iIfList))[0];
   1.871 +	test(ifData->iInterfaceUid == interfaceUidExample12);
   1.872 +	//Currently there are 3 implementations for this interface.
   1.873 +	//But the implementation(UID=0x10009E3D) is ROM-only but is actually in RAM will not be created.
   1.874 +	//So, actually number of implementations created for this interface is 2.
   1.875 +	test(ifData->iImplementations->Count() == 2);
   1.876 +	implData = (*(ifData->iImplementations))[0];
   1.877 +	implInfo = implData->iImplInfo;
   1.878 +
   1.879 +	// Fetches the list of extended interfaces for the first implementation
   1.880 +	RArray<TUid>* extendedInterfaceList = implInfo->GetExtendedInterfaceList();
   1.881 +	test(extendedInterfaceList->Count()==3);
   1.882 +	test((*extendedInterfaceList)[0] == extendedInterfaceUid1);
   1.883 +	test((*extendedInterfaceList)[1] == extendedInterfaceUid2);
   1.884 +	test((*extendedInterfaceList)[2] == extendedInterfaceUid3);
   1.885 +	CleanupStack::PopAndDestroy(dllData);
   1.886 +	CleanupStack::PopAndDestroy(entryBase);
   1.887 +	}
   1.888 +
   1.889 +
   1.890 +/** Wrapper function for testing ParseL function with type 3 entries
   1.891 +and data in the resource file exceed maximum
   1.892 +*/
   1.893 +void CRegistrarTest::ParseBadDataTestL(const TDesC& aRscFullName, const TDesC& aRscNameOnly)
   1.894 +	{
   1.895 +	TInt error = KErrNone;
   1.896 +	CPluginBase* entryBase = NULL;
   1.897 +	CRegistryData::CDllData* dllData = NULL;
   1.898 +	CRegistryData::CDriveData* driveData = NULL;
   1.899 +
   1.900 +	TEntry rscBasedEntry;
   1.901 +	rscBasedEntry.iName = aRscNameOnly;
   1.902 +	error = TheFs.Modified(aRscFullName, rscBasedEntry.iModified);
   1.903 +	test(error == KErrNone);
   1.904 +	TParse rscPath;
   1.905 +	rscPath.Set(aRscFullName,NULL,NULL);
   1.906 +	TDriveUnit driveUnit(rscPath.Drive());
   1.907 +	error = iRegistryData->FindDriveL(driveUnit,driveData);
   1.908 +	test(error != KErrNotFound);
   1.909 +	entryBase = CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
   1.910 +	CleanupStack::PushL(entryBase);
   1.911 +	dllData = CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
   1.912 +
   1.913 +	//Tests the parseL function
   1.914 +	TRAP(error, iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
   1.915 +	test(error == KErrNotSupported);
   1.916 +
   1.917 +	CleanupStack::PopAndDestroy(dllData);
   1.918 +	CleanupStack::PopAndDestroy(entryBase);
   1.919 +	}
   1.920 +
   1.921 +
   1.922 +/**
   1.923 +@SYMTestCaseID          SYSLIB-ECOM-UT-3565
   1.924 +@SYMTestCaseDesc	    Tests for verification of Interface implementation information with type 3 entries
   1.925 +						and data in the resource file exceed maximum.
   1.926 +@SYMTestPriority 	    High
   1.927 +@SYMTestActions  	    Parse the resource information associated with an
   1.928 +					    Interface Implementation Collection type 3 for entry into the registry
   1.929 +					    information.
   1.930 +@SYMTestExpectedResults CRegistrar::ParseL() function parses resource file with KErrNotSupported leave occurs.
   1.931 +@SYMEC                  EC43
   1.932 +@SYMDEF                 DEF111196
   1.933 +*/
   1.934 +void CRegistrarTest::ParseType3BadDataTestL()
   1.935 +	{
   1.936 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3565 "));
   1.937 +	// Tests for number of strings of default data exceeds maximum
   1.938 +	// Uses EComExampleBadData.dll and EComExampleBadData.rsc (EcomExampleBadData.RSS)
   1.939 +	ParseBadDataTestL(KType3BadDataResourceFileNameC,KType3BadDataResourceFileNameOnly);
   1.940 +
   1.941 +	// Tests for number of interfaces exceeds maximum
   1.942 +	// Uses EComExampleBadData1.dll and EComExampleBadData1.rsc (EcomExampleBadData1.RSS)
   1.943 +	ParseBadDataTestL(KType3BadData1ResourceFileNameC,KType3BadData1ResourceFileNameOnly);
   1.944 +
   1.945 +	// Tests for number of implementation in one interfaces exceeds maximum
   1.946 +	// Uses EComExampleBadData2.dll and EComExampleBadData2.rsc (EcomExampleBadData2.RSS)
   1.947 +	ParseBadDataTestL(KType3BadData2ResourceFileNameC,KType3BadData2ResourceFileNameOnly);
   1.948 +	}
   1.949 +
   1.950 +/**
   1.951 +@SYMTestCaseID		SYSLIB-ECOM-CT-0089
   1.952 +@SYMTestCaseDesc 	Check that the ParseL for spi data works correctly.
   1.953 +@SYMTestPriority 	High
   1.954 +@SYMTestActions  	Ensure ecomtest.spi can be parsed successfully
   1.955 +					and no leave occurs.
   1.956 +@SYMTestExpectedResults The test must not fail.
   1.957 +@SYMREQ REQ3655
   1.958 +*/
   1.959 +void CRegistrarTest::ParseSpiTestL()
   1.960 +	{
   1.961 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0089 "));
   1.962 +	TEntry spiEntry;
   1.963 +	TParse spiPath;
   1.964 +	if (TheFs.Entry(KEComSpiTestFilePathAndName, spiEntry) != KErrNone)
   1.965 +		return;
   1.966 +
   1.967 +	spiPath.Set(KEComSpiTestFilePathAndName,NULL,NULL);
   1.968 +	RResourceArchive resourceArchive;
   1.969 +	resourceArchive.OpenL(TheFs, KEComSpiTestFilePathAndName);
   1.970 +	CleanupClosePushL(resourceArchive);
   1.971 +
   1.972 +	// Checks SPI file type
   1.973 +	TUid type = resourceArchive.Type();
   1.974 +	test(type == KEcomSpiFileTypeUid);
   1.975 +
   1.976 +	// there is only 1 resource file
   1.977 +	CPluginBase* entryBase=NULL;
   1.978 +	CRegistryData::CDllData* dllData=NULL;
   1.979 +	CRegistryData::CDriveData* driveData = NULL;
   1.980 +
   1.981 +	TDriveUnit driveUnit(spiPath.Drive());
   1.982 +	TInt error=iRegistryData->FindDriveL(driveUnit,driveData);
   1.983 +	test(error!=KErrNotFound);
   1.984 +
   1.985 +	while(!resourceArchive.End())
   1.986 +		{
   1.987 +		entryBase=CSpiPlugin::NewL(resourceArchive);
   1.988 +		CleanupStack::PushL(entryBase);
   1.989 +		dllData=CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
   1.990 +		TRAPD(err,iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
   1.991 +
   1.992 +		::LeaveIfErrNoMemory(err);
   1.993 +		test(err == KErrNone);
   1.994 +		CleanupStack::Pop(dllData);
   1.995 +		CleanupStack::PopAndDestroy(entryBase);
   1.996 +		entryBase=NULL;
   1.997 +		}
   1.998 +
   1.999 +	CleanupStack::PopAndDestroy(&resourceArchive);
  1.1000 +
  1.1001 +	// Currently only one interface definition in the resource file
  1.1002 +	const TInt ifCount = dllData->iIfList->Count();
  1.1003 +	test(ifCount == 1);
  1.1004 +
  1.1005 +	// Currently only one implemention for the above interface in the resource file
  1.1006 +	CRegistryData::CInterfaceData* ifData = (*(dllData->iIfList))[0];
  1.1007 +	const TInt impCount = ifData->iImplementations->Count();
  1.1008 +	test(impCount == 1);
  1.1009 +	// Interface UID verification
  1.1010 +	test(ifData->iInterfaceUid == iInterfaceUid);
  1.1011 +
  1.1012 +	delete dllData;
  1.1013 +	}
  1.1014 +
  1.1015 +/**
  1.1016 +@SYMTestCaseID		SYSLIB-ECOM-UT-3566
  1.1017 +@SYMTestCaseDesc 	Check that the ParseL for spi data with IIC Type 3 entry works correctly.
  1.1018 +@SYMTestPriority 	High
  1.1019 +@SYMTestActions  	Ensure ecomtesttype3.spi can be parsed successfully
  1.1020 +					and no leave occurs.
  1.1021 +@SYMTestExpectedResults CRegistrar::ParseL() function parses SPI file without error.
  1.1022 +						Data is interpreted correctly.
  1.1023 +@SYMEC                  EC43
  1.1024 +*/
  1.1025 +void CRegistrarTest::ParseSpiType3TestL()
  1.1026 +	{
  1.1027 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3566 "));
  1.1028 +	TEntry spiEntry;
  1.1029 +	TParse spiPath;
  1.1030 +	//"Z:\\Test\\Data\\ecomtesttype3.spi" is used for testing. The only resource file included
  1.1031 +	//in the spi file is EComExample12.RSC
  1.1032 +	if (TheFs.Entry(KEComSpiTestFileType3PathAndName, spiEntry) != KErrNone)
  1.1033 +		return;
  1.1034 +
  1.1035 +	spiPath.Set(KEComSpiTestFileType3PathAndName,NULL,NULL);
  1.1036 +	RResourceArchive resourceArchive;
  1.1037 +	resourceArchive.OpenL(TheFs, KEComSpiTestFileType3PathAndName);
  1.1038 +	CleanupClosePushL(resourceArchive);
  1.1039 +
  1.1040 +	// Checks SPI file type
  1.1041 +	TUid type = resourceArchive.Type();
  1.1042 +	test(type == KEcomSpiFileTypeUid);
  1.1043 +
  1.1044 +	CRegistryData::CDriveData* driveData = NULL;
  1.1045 +
  1.1046 +	TDriveUnit driveUnit(spiPath.Drive());
  1.1047 +	TInt error=iRegistryData->FindDriveL(driveUnit,driveData);
  1.1048 +	test(error!=KErrNotFound);
  1.1049 +	// there is only 1 resource file in the spi file
  1.1050 +	while(!resourceArchive.End())
  1.1051 +		{
  1.1052 +		CPluginBase* entryBase = NULL;
  1.1053 +		entryBase=CSpiPlugin::NewL(resourceArchive);
  1.1054 +		CleanupStack::PushL(entryBase);
  1.1055 +		CRegistryData::CDllData* dllData = NULL;
  1.1056 +		dllData = CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
  1.1057 +		TRAPD(err,iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
  1.1058 +		::LeaveIfErrNoMemory(err);
  1.1059 +		test(err == KErrNone);
  1.1060 +		// Currently only one interface definition in the resource file
  1.1061 +		// Checks the content of the DllData
  1.1062 +		test(dllData->iIfList->Count() == 1);
  1.1063 +		CRegistryData::CInterfaceData* ifData = NULL;
  1.1064 +		ifData = (*(dllData->iIfList))[0];
  1.1065 +		//There are 3 implementations for the above interface in the spi file.
  1.1066 +		//Since ecomtesttype3.spi is under Z: drive which is ROM based,
  1.1067 +		//the implementation (UID=0x10009E3D) will be created during Parsing.
  1.1068 +		//So, the total implementations is 3.
  1.1069 +		test(ifData->iImplementations->Count() == 3);
  1.1070 +		// Interface UID verification
  1.1071 +		test(ifData->iInterfaceUid == interfaceUidExample12);
  1.1072 +		// Fetches the list of extended interfaces for the second implementation
  1.1073 +		//Currently we have no extended Interface for the second implementation
  1.1074 +		CRegistryData::CImplementationData* implData = NULL;
  1.1075 +		implData = (*(ifData->iImplementations))[1];
  1.1076 +		CImplementationInformation* implInfo = NULL;
  1.1077 +		implInfo = implData->iImplInfo;
  1.1078 +
  1.1079 +		RArray<TUid>* extendedInterfaceList = implInfo->GetExtendedInterfaceList();
  1.1080 +		test(extendedInterfaceList->Count() == 0);
  1.1081 +		CleanupStack::PopAndDestroy(dllData);
  1.1082 +		CleanupStack::PopAndDestroy(entryBase);
  1.1083 +		}
  1.1084 +	CleanupStack::PopAndDestroy(&resourceArchive);
  1.1085 +	}
  1.1086 +
  1.1087 +/**
  1.1088 +The test executes by registering the Interface implementaion information
  1.1089 +for an plugin entry.
  1.1090 +
  1.1091 +@SYMTestCaseID          SYSLIB-ECOM-CT-0732
  1.1092 +@SYMTestCaseDesc	    Tests for CRegistrar::ParseRegistrationDataL() function
  1.1093 +@SYMTestPriority 	    High
  1.1094 +@SYMTestActions  	    Checks for directory entry for an Interface Implementation
  1.1095 +						Collection entry requires registration.Parses the associated resource file information where necessary
  1.1096 +						Checks for OOM or parsing error.
  1.1097 +@SYMTestExpectedResults The test must not fail.
  1.1098 +@SYMREQ                 REQ0000
  1.1099 +*/
  1.1100 +void CRegistrarTest::ParseRegistrationDataTestL()
  1.1101 +	{
  1.1102 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0732 "));
  1.1103 +	TInt error=KErrNone;
  1.1104 +	TTime modified(0);							//Dummy parameter...
  1.1105 +	TBool update			= EFalse;			//Dummy parameter...
  1.1106 +	TInt  driveIndex		= KErrNotFound;
  1.1107 +	CRegistryData::CImplementationData *implementationData = NULL;
  1.1108 +	CPluginBase* entryBase=NULL;
  1.1109 +	TUid implementationUid;
  1.1110 +	CRegistryData::CDriveData* driveData = NULL;
  1.1111 +
  1.1112 +	// Calling  RegistryData->IsRegisteredWithDate to get the drive index,
  1.1113 +	// that will be used in the ParseRegistrationDataL call
  1.1114 +	// The drive should have been installed before registering any plugin
  1.1115 +	TRAP(error, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
  1.1116 +	::LeaveIfErrNoMemory(error);
  1.1117 +	test(driveIndex != KErrNotFound);
  1.1118 +	TRAP(error, iRegistryData->IsRegisteredWithDate(
  1.1119 +																		NewDllUid,
  1.1120 +																		modified,
  1.1121 +																		update,
  1.1122 +
  1.1123 +																		driveData));
  1.1124 +	::LeaveIfErrNoMemory(error);
  1.1125 +	test(error == KErrNone);
  1.1126 +
  1.1127 +	//Creating the entry
  1.1128 +	TEntry rscBasedEntry;
  1.1129 +	rscBasedEntry.iName=KNewResourceFileNameOnly;
  1.1130 +	error = TheFs.Modified(KNewResourceFileNameC, rscBasedEntry.iModified);
  1.1131 +	test(error==KErrNone);
  1.1132 +	TParse rscPath;
  1.1133 +	rscPath.Set(KNewResourceFileNameC,NULL,NULL);
  1.1134 +	entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), EFalse);
  1.1135 +	CleanupStack::PushL(entryBase);
  1.1136 +
  1.1137 +	//Trying to parse the registration data
  1.1138 +	update=ETrue;
  1.1139 +	TRAP(error,iStateAccessor->ParseRegistrationDataL(*iRegistrar,entryBase,iDriveUnit,update,driveIndex, driveData));
  1.1140 +	::LeaveIfErrNoMemory(error);
  1.1141 +	test(error == KErrNone);
  1.1142 +	CleanupStack::PopAndDestroy(entryBase);
  1.1143 +
  1.1144 +	// Calling DiscoveriesComplete for building the registry indexes
  1.1145 +	// as registration of new plugin has happened.
  1.1146 +	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
  1.1147 +
  1.1148 +	//Now checking whether the implementation is already registered in the CRegistryData
  1.1149 +	//The only implementation Uid in EComExample5. see 101F847B.RSS
  1.1150 +	implementationUid=TUid::Uid(0x101F847C);
  1.1151 +	TUid dummyUid;
  1.1152 +	dummyUid.iUid = 0;
  1.1153 +	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
  1.1154 +	test(error == KErrNone);
  1.1155 +	test(implementationData != NULL);
  1.1156 +
  1.1157 +	}
  1.1158 +
  1.1159 +/**
  1.1160 +The test executes by registering the Interface implementation information
  1.1161 +for an plugin with type 3 entry.
  1.1162 +
  1.1163 +@SYMTestCaseID          SYSLIB-ECOM-UT-3567
  1.1164 +@SYMTestCaseDesc	    Tests for CRegistrar::ParseRegistrationDataL() function
  1.1165 +@SYMTestPriority 	    High
  1.1166 +@SYMTestActions  	    Checks for directory entry for an Interface Implementation
  1.1167 +						Collection with Type 3 entry requires registration.Parses the associated resource file information where necessary
  1.1168 +@SYMTestExpectedResults CRegistrar::ParseRegistrationDataL() function parses resource file and registers
  1.1169 +						implementations correctly.
  1.1170 +@SYMEC                  EC43
  1.1171 +*/
  1.1172 +void CRegistrarTest::ParseRegistrationDataType3TestL()
  1.1173 +	{
  1.1174 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3567 "));
  1.1175 +	TInt error=KErrNone;
  1.1176 +	TTime modified(0);							//Dummy parameter...
  1.1177 +	TBool update			= EFalse;			//Dummy parameter...
  1.1178 +	TInt  driveIndex		= KErrNotFound;
  1.1179 +	CRegistryData::CImplementationData *implementationData = NULL;
  1.1180 +	CPluginBase* entryBase = NULL;
  1.1181 +	TUid implementationUid;
  1.1182 +	CRegistryData::CDriveData* driveData = NULL;
  1.1183 +
  1.1184 +	// Calls iRegistryData->FindDriveL to get the drive index,
  1.1185 +	// that will be used in the ParseRegistrationDataL call.
  1.1186 +	// The drive should have been installed before registering any plugin
  1.1187 +	TRAP(error, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
  1.1188 +	::LeaveIfErrNoMemory(error);
  1.1189 +	test(driveIndex != KErrNotFound);
  1.1190 +	// Calls iRegistryData->IsRegisteredWithDate to determine if the entry in the registry needs an update.
  1.1191 +	iRegistryData->IsRegisteredWithDate(Type3DllUid, modified, update, driveData);
  1.1192 +
  1.1193 +	//Creates the entry
  1.1194 +	TEntry rscBasedEntry;
  1.1195 +	rscBasedEntry.iName = KType3ResourceFileNameOnly;
  1.1196 +	error = TheFs.Modified(KType3ResourceFileNameC, rscBasedEntry.iModified);
  1.1197 +	test(error == KErrNone);
  1.1198 +	TParse rscPath;
  1.1199 +	rscPath.Set(KType3ResourceFileNameC,NULL,NULL);
  1.1200 +	entryBase = CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), EFalse);
  1.1201 +	CleanupStack::PushL(entryBase);
  1.1202 +
  1.1203 +	//Try to parse the registration data
  1.1204 +	TRAP(error,iStateAccessor->ParseRegistrationDataL(*iRegistrar,entryBase,iDriveUnit,update,driveIndex, driveData));
  1.1205 +	::LeaveIfErrNoMemory(error);
  1.1206 +	test(error == KErrNone);
  1.1207 +	CleanupStack::PopAndDestroy(entryBase);
  1.1208 +
  1.1209 +	// Calls DiscoveriesComplete for building the registry indexes
  1.1210 +	// as registration of new plugin has happened.
  1.1211 +	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
  1.1212 +
  1.1213 +	// Checks whether the implementations are already registered in the CRegistryData
  1.1214 +	//The implementation Uids in EComExample12 are 0x10009E39, 0x10009E3C and 0x10009E3D
  1.1215 +	// Checks implementation 0x10009E39
  1.1216 +	implementationUid = TUid::Uid(0x10009E39);
  1.1217 +	TUid dummyUid;
  1.1218 +	dummyUid.iUid = 0;
  1.1219 +	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
  1.1220 +	test(error == KErrNone);
  1.1221 +	test(implementationData != NULL);
  1.1222 +	// Checks implementation 0x10009E3C
  1.1223 +	implementationUid = TUid::Uid(0x10009E3C);
  1.1224 +	dummyUid.iUid = 0;
  1.1225 +	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
  1.1226 +	test(error == KErrNone);
  1.1227 +	test(implementationData != NULL);
  1.1228 +	// Checks implementation 0x10009E3D
  1.1229 +	// This implementation is said it's ROM-only but is actually in RAM.
  1.1230 +	// So, this implementation will not be created.
  1.1231 +	implementationUid = TUid::Uid(0x10009E3D);
  1.1232 +	dummyUid.iUid = 0;
  1.1233 +	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
  1.1234 +	test(error == KErrNotFound);
  1.1235 +	test(implementationData == NULL);
  1.1236 +	}
  1.1237 +
  1.1238 +/**
  1.1239 +@SYMTestCaseID		SYSLIB-ECOM-CT-0090
  1.1240 +@SYMTestCaseDesc 	Check that the ParseL for spi data works correctly.
  1.1241 +@SYMTestPriority 	High
  1.1242 +@SYMTestActions  	Ensure ecomtest.spi can be parsed successfully
  1.1243 +					and no leave occurred.
  1.1244 +@SYMTestExpectedResults The test must not fail.
  1.1245 +@SYMREQ REQ3655
  1.1246 +*/
  1.1247 +void CRegistrarTest::ParseSpiRegistrationDataTestL()
  1.1248 +	{
  1.1249 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0090 "));
  1.1250 +	TDriveUnit driveUnit(EDriveZ);
  1.1251 +	TEntry spiEntry;
  1.1252 +	test(TheFs.Entry(KEComSpiTestFilePathAndName, spiEntry) == KErrNone);
  1.1253 +	TParse spiPath;
  1.1254 +	spiPath.Set(KEComSpiTestFilePathAndName, NULL, NULL);
  1.1255 +
  1.1256 +	RResourceArchive resourceArchive;
  1.1257 +	resourceArchive.OpenL(TheFs, KEComSpiTestFilePathAndName);
  1.1258 +	CleanupClosePushL(resourceArchive);
  1.1259 +
  1.1260 +	// Checks SPI file type
  1.1261 +	TUid type = resourceArchive.Type();
  1.1262 +	test(type == KEcomSpiFileTypeUid);
  1.1263 +
  1.1264 +	CPluginBase* entryBase=NULL;
  1.1265 +	// there is only 1 resource file
  1.1266 +	while(!resourceArchive.End())
  1.1267 +		{
  1.1268 +		const TTime modified(0);					//Dummy parameter...
  1.1269 +		TBool update			= EFalse;			//Dummy parameter...
  1.1270 +		TInt  driveIndex		= KErrNotFound;
  1.1271 +		CRegistryData::CDriveData* driveData = NULL;
  1.1272 +
  1.1273 +		// Calls RegistryData->IsRegisteredWithDate to get the drive index,
  1.1274 +		// that will be used in the ParseRegistrationDataL call
  1.1275 +		// The drive should have been installed before registering any plugin
  1.1276 +		TRAPD(error, driveIndex = iRegistryData->FindDriveL(driveUnit, driveData));
  1.1277 +		::LeaveIfErrNoMemory(error);
  1.1278 +		test(driveIndex != KErrNotFound);
  1.1279 +		TRAPD(err, (void)iRegistryData->IsRegisteredWithDate(
  1.1280 +
  1.1281 +																	iDllUid,
  1.1282 +																	modified,
  1.1283 +																	update,
  1.1284 +
  1.1285 +																	driveData));
  1.1286 +		::LeaveIfErrNoMemory(err);
  1.1287 +		test(err == KErrNone);
  1.1288 +
  1.1289 +
  1.1290 +		entryBase=CSpiPlugin::NewL(resourceArchive);
  1.1291 +		CleanupStack::PushL(entryBase);
  1.1292 +
  1.1293 +		TRAP(err, iStateAccessor->ParseRegistrationDataL(*iRegistrar,
  1.1294 +														 entryBase,
  1.1295 +														 driveUnit,
  1.1296 +														 update,
  1.1297 +														 driveIndex,
  1.1298 +														 driveData));
  1.1299 +		::LeaveIfErrNoMemory(err);
  1.1300 +		test(err == KErrNone);
  1.1301 +		CleanupStack::PopAndDestroy(entryBase);
  1.1302 +		entryBase = NULL;
  1.1303 +		}
  1.1304 +
  1.1305 +	CleanupStack::PopAndDestroy(&resourceArchive);
  1.1306 +
  1.1307 +	// Calls DiscoveriesComplete for building the registry indexes
  1.1308 +	// as registration of new plugin has happened.
  1.1309 +	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
  1.1310 +
  1.1311 +	CRegistryData::CImplementationData *implementationData = NULL;
  1.1312 +	TUid dummyUid;
  1.1313 +	dummyUid.iUid = 0;
  1.1314 +	TInt err = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, iImplementationUid, dummyUid, implementationData);
  1.1315 +	test(err == KErrNone);
  1.1316 +	test(implementationData != NULL);
  1.1317 +	}
  1.1318 +
  1.1319 +/**
  1.1320 +@SYMTestCaseID		SYSLIB-ECOM-UT-3568
  1.1321 +@SYMTestCaseDesc 	Check that the ParseL for spi data works correctly.
  1.1322 +@SYMTestPriority 	High
  1.1323 +@SYMTestActions  	Ensure ecomtesttype3.spi can be parsed successfully
  1.1324 +					and no leave occurs.
  1.1325 +@SYMTestExpectedResults CRegistrar::ParseRegistrationDataL() function parses SPI file and registers
  1.1326 +						implementations correctly.
  1.1327 +@SYMEC                  EC43
  1.1328 +*/
  1.1329 +void CRegistrarTest::ParseSpiRegistrationDataType3TestL()
  1.1330 +	{
  1.1331 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3568 "));
  1.1332 +	TDriveUnit driveUnit(EDriveZ);
  1.1333 +	TEntry spiEntry;
  1.1334 +	//"Z:\\Test\\Data\\ecomtesttype3.spi" is used for testing. The only resource file included
  1.1335 +	//in the spi file is EComExample12.RSC
  1.1336 +	test(TheFs.Entry(KEComSpiTestFileType3PathAndName, spiEntry) == KErrNone);
  1.1337 +	TParse spiPath;
  1.1338 +	spiPath.Set(KEComSpiTestFileType3PathAndName, NULL, NULL);
  1.1339 +
  1.1340 +	RResourceArchive resourceArchive;
  1.1341 +	resourceArchive.OpenL(TheFs, KEComSpiTestFileType3PathAndName);
  1.1342 +	CleanupClosePushL(resourceArchive);
  1.1343 +
  1.1344 +	// Checks SPI file type
  1.1345 +	TUid type = resourceArchive.Type();
  1.1346 +	test(type == KEcomSpiFileTypeUid);
  1.1347 +
  1.1348 +	CPluginBase* entryBase = NULL;
  1.1349 +	// there is only 1 resource file in the spi file
  1.1350 +	while(!resourceArchive.End())
  1.1351 +		{
  1.1352 +		const TTime modified(0);					//Dummy parameter...
  1.1353 +		TBool update			= EFalse;			//Dummy parameter...
  1.1354 +		TInt  driveIndex		= KErrNotFound;
  1.1355 +		CRegistryData::CDriveData* driveData = NULL;
  1.1356 +
  1.1357 +		// Calls RegistryData->FindDriveL to get the drive index,
  1.1358 +		// that will be used in the ParseRegistrationDataL call.
  1.1359 +		// The drive should have been installed before registering any plugin
  1.1360 +		TRAPD(error, driveIndex = iRegistryData->FindDriveL(driveUnit, driveData));
  1.1361 +		::LeaveIfErrNoMemory(error);
  1.1362 +		test(driveIndex != KErrNotFound);
  1.1363 +		iRegistryData->IsRegisteredWithDate(Type3DllUid,modified,update,driveData);
  1.1364 +
  1.1365 +		entryBase=CSpiPlugin::NewL(resourceArchive);
  1.1366 +		CleanupStack::PushL(entryBase);
  1.1367 +
  1.1368 +		TRAPD(err, iStateAccessor->ParseRegistrationDataL(*iRegistrar,
  1.1369 +														 entryBase,
  1.1370 +														 driveUnit,
  1.1371 +														 update,
  1.1372 +														 driveIndex,
  1.1373 +														 driveData));
  1.1374 +		::LeaveIfErrNoMemory(err);
  1.1375 +		test(err == KErrNone);
  1.1376 +		CleanupStack::PopAndDestroy(entryBase);
  1.1377 +		entryBase = NULL;
  1.1378 +		}
  1.1379 +
  1.1380 +	CleanupStack::PopAndDestroy(&resourceArchive);
  1.1381 +
  1.1382 +	// Calls DiscoveriesComplete for building the registry indexes
  1.1383 +	// as registration of new plugin has happened.
  1.1384 +	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
  1.1385 +
  1.1386 +	CRegistryData::CImplementationData *implementationData=NULL;
  1.1387 +	// Checks whether the implementations are already registered in the CRegistryData
  1.1388 +	// The implementation Uids in EComExample12 are 0x10009E39, 0x10009E3C and 0x10009E3D
  1.1389 +	// Checks implementation 0x10009E39
  1.1390 +	TUid implementationUid = TUid::Uid(0x10009E39);
  1.1391 +	TUid dummyUid;
  1.1392 +	dummyUid.iUid = 0;
  1.1393 +	TInt error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
  1.1394 +	test(error == KErrNone);
  1.1395 +	test(implementationData != NULL);
  1.1396 +	// Checks implementation 0x10009E3C
  1.1397 +	implementationUid = TUid::Uid(0x10009E3C);
  1.1398 +	dummyUid.iUid = 0;
  1.1399 +	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
  1.1400 +	test(error == KErrNone);
  1.1401 +	test(implementationData != NULL);
  1.1402 +	// Checks implementation 0x10009E3D
  1.1403 +	// Since ecomtesttype3.spi is under Z: drive which is ROM based,
  1.1404 +	// the implementation (UID=0x10009E3D) will be created during Parsing.
  1.1405 +	implementationUid = TUid::Uid(0x10009E3D);
  1.1406 +	dummyUid.iUid = 0;
  1.1407 +	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
  1.1408 +	test(error == KErrNone);
  1.1409 +	test(implementationData != NULL);
  1.1410 +	}
  1.1411 +
  1.1412 +/**
  1.1413 +@SYMTestCaseID		SYSLIB-ECOM-CT-0184
  1.1414 +@SYMTestCaseDesc 	Check that SSA related states transition as expected when registration is staged
  1.1415 +@SYMTestPriority 	High
  1.1416 +@SYMTestActions  	Use CRegistrar::ProcessSSAEventL to start registration in stages i.e. rom only
  1.1417 +then non rom only. Check that the
  1.1418 +CRegistrar state is transitioning correctly at every step.
  1.1419 +@SYMTestExpectedResults The test must not fail.
  1.1420 +@SYMPREQ PREQ967
  1.1421 +*/
  1.1422 +void CRegistrarTest::StateTransitionTestL()
  1.1423 +	{
  1.1424 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0184 "));
  1.1425 +	//After construction check that initial state is EReg_StartupInProgess
  1.1426 +	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupInProgess);
  1.1427 +
  1.1428 +	//Call ProcessSSAEventL with EStartupStateUndefined. Check that state
  1.1429 +	// is not changed. i.e. still EReg_StartupInProgess
  1.1430 +	iRegistrar->ProcessSSAEventL(EStartupStateUndefined);
  1.1431 +	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupInProgess);
  1.1432 +
  1.1433 +	//Call ProcessSSAEventL with EStartupStateCriticalStatic. Check that state
  1.1434 +	// is not changed. i.e. still EReg_StartupInProgess
  1.1435 +	iRegistrar->ProcessSSAEventL(EStartupStateCriticalStatic);
  1.1436 +	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupInProgess);
  1.1437 +
  1.1438 +	//Call ProcessSSAEventL with EStartupStateCriticalDynamic. Check that state
  1.1439 +	// is not changed. i.e. still EReg_StartupInProgess
  1.1440 +	iRegistrar->ProcessSSAEventL(EStartupStateCriticalDynamic);
  1.1441 +	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupInProgess);
  1.1442 +
  1.1443 +	//Call ProcessSSAEventL with EStartupStateNonCritical. Check that state
  1.1444 +	//is changed to EReg_StartupComplete
  1.1445 +	iRegistrar->ProcessSSAEventL(EStartupStateNonCritical);
  1.1446 +	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupComplete);
  1.1447 +	}
  1.1448 +
  1.1449 +/**
  1.1450 +@SYMTestCaseID          SYSLIB-ECOM-CT-0733
  1.1451 +@SYMTestCaseDesc	    Tests the creation and deletion of CRegistrar
  1.1452 +@SYMTestPriority 	    High
  1.1453 +@SYMTestActions  	    Create and delete CRegistrar object,checks for open handles
  1.1454 +@SYMTestExpectedResults The test must not fail.
  1.1455 +@SYMREQ                 REQ0000
  1.1456 +*/
  1.1457 +LOCAL_C void CreateDeleteTestL()
  1.1458 +	{
  1.1459 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0733 CreateDeleteTestL "));
  1.1460 +	// Set up for heap leak checking
  1.1461 +	__UHEAP_MARK;
  1.1462 +	//Check Thread handles leak
  1.1463 +	TInt startProcessHandleCount = 0;
  1.1464 +	TInt startThreadHandleCount = 0;
  1.1465 +	TInt endProcessHandleCount = 0;
  1.1466 +	TInt endThreadHandleCount = 0;
  1.1467 +
  1.1468 +	RThread rThread;
  1.1469 +	rThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
  1.1470 +
  1.1471 +	//CREATE DELETE TEST START//
  1.1472 +
  1.1473 +	CRegistrarTest* registrarTest = CRegistrarTest::NewL(EFalse);
  1.1474 +
  1.1475 +	test(registrarTest != NULL);
  1.1476 +
  1.1477 +	delete registrarTest;
  1.1478 +
  1.1479 +	//CREATE DELETE TEST END//
  1.1480 +
  1.1481 +	// Check for open handles
  1.1482 +	rThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
  1.1483 +	test(startThreadHandleCount == endThreadHandleCount);
  1.1484 +
  1.1485 +	//Test ends
  1.1486 +	__UHEAP_MARKEND;
  1.1487 +	}
  1.1488 +/*
  1.1489 +LOCAL_C void OOMCreateDeleteTest()
  1.1490 +	{
  1.1491 +	//
  1.1492 +	// Out of memory test
  1.1493 +	// ------------------------------------------------------------------
  1.1494 +	//
  1.1495 +	test.Next(_L("OOM CreateDeleteTest"));
  1.1496 +	TInt err;
  1.1497 +	TInt failAt = 0;
  1.1498 +	__UNUSED_VAR(failAt);
  1.1499 +
  1.1500 +	CRegistrarTest* registrarTest = NULL;
  1.1501 +
  1.1502 +	do
  1.1503 +		{
  1.1504 +		__UHEAP_MARK;
  1.1505 +  		// find out the number of open handles
  1.1506 +		TInt startProcessHandleCount;
  1.1507 +		TInt startThreadHandleCount;
  1.1508 +		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
  1.1509 +
  1.1510 +		// Setting Heap failure for OOM test
  1.1511 +		__UHEAP_SETFAIL(RHeap::EDeterministic, ++failAt);
  1.1512 +
  1.1513 +		TRAP(err, registrarTest = CRegistrarTest::NewL(EFalse));
  1.1514 +
  1.1515 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
  1.1516 +
  1.1517 +		delete registrarTest;
  1.1518 +		registrarTest = NULL;
  1.1519 +
  1.1520 +		// check that no handles have leaked
  1.1521 +		TInt endProcessHandleCount;
  1.1522 +		TInt endThreadHandleCount;
  1.1523 +		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
  1.1524 +
  1.1525 +		test(startProcessHandleCount == endProcessHandleCount);
  1.1526 +		test(startThreadHandleCount  == endThreadHandleCount);
  1.1527 +
  1.1528 +		__UHEAP_MARKEND;
  1.1529 +		}
  1.1530 +	while (err == KErrNoMemory);
  1.1531 +
  1.1532 +	test.Printf(_L("- Succeeded at heap failure rate of %i\n"), failAt);
  1.1533 +	test(err == KErrNone);
  1.1534 +	}
  1.1535 +*/
  1.1536 +// Type definition for pointer to member function.
  1.1537 +// Used in calling the CDiscovererTest member function for testing.
  1.1538 +typedef void (CRegistrarTest::*ClassFuncPtrL) (void);
  1.1539 +
  1.1540 +/**
  1.1541 +@SYMTestCaseID          SYSLIB-ECOM-CT-0735
  1.1542 +@SYMTestCaseDesc	    Wrapper function to call all test functions
  1.1543 +@SYMTestPriority 	    High
  1.1544 +@SYMTestActions  	    Calls up test functions of CRegistrarTest.
  1.1545 +@SYMTestExpectedResults The test must not fail.
  1.1546 +@SYMREQ                 REQ0000
  1.1547 +*/
  1.1548 +/**
  1.1549 +Wrapper function to call all test functions
  1.1550 +
  1.1551 +@param		testFuncL pointer to test function
  1.1552 +@param		aTestDesc test function name
  1.1553 +*/
  1.1554 +LOCAL_C void DoBasicTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc, TBool aIsFullDiscovery)
  1.1555 +	{
  1.1556 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0735 "));
  1.1557 +	test.Next(aTestDesc);
  1.1558 +
  1.1559 +	__UHEAP_MARK;
  1.1560 +  	// find out the number of open handles
  1.1561 +	TInt startProcessHandleCount;
  1.1562 +	TInt startThreadHandleCount;
  1.1563 +	RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
  1.1564 +
  1.1565 +	CRegistrarTest* registrarTest = CRegistrarTest::NewL(aIsFullDiscovery);
  1.1566 +	CleanupStack::PushL(registrarTest);
  1.1567 +
  1.1568 +	(registrarTest->*testFuncL)();
  1.1569 +
  1.1570 +	CleanupStack::PopAndDestroy(registrarTest);
  1.1571 +
  1.1572 +	// check that no handles have leaked
  1.1573 +	TInt endProcessHandleCount;
  1.1574 +	TInt endThreadHandleCount;
  1.1575 +	RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
  1.1576 +
  1.1577 +	test(startProcessHandleCount == endProcessHandleCount);
  1.1578 +	test(startThreadHandleCount  == endThreadHandleCount);
  1.1579 +
  1.1580 +	__UHEAP_MARKEND;
  1.1581 +	}
  1.1582 +
  1.1583 +/**
  1.1584 +@SYMTestCaseID          SYSLIB-ECOM-CT-0736
  1.1585 +@SYMTestCaseDesc	    Function to call all test functions
  1.1586 +@SYMTestPriority 	    High
  1.1587 +@SYMTestActions  	    Calls up all OOM test functions of CRegistrarTest.
  1.1588 +@SYMTestExpectedResults The test must not fail.
  1.1589 +@SYMREQ                 REQ0000
  1.1590 +*/
  1.1591 +/**
  1.1592 +Utility function to continually invoke a test function and cause memory allocation failures
  1.1593 +
  1.1594 +@param		testFuncL pointer to OOM test function
  1.1595 +@param	 	tryCount specifies what value to start memory allocation failures at
  1.1596 +@param		increment how much to increase the point at which memory allocation will fail on each test attempt
  1.1597 +@param		stopCount the value of memory allocation failure to stop testing at
  1.1598 +*/
  1.1599 +TInt RunTestUnderOOMCondition(ClassFuncPtrL testFuncL, TBool aIsFullDiscovery, TInt tryCount, TInt increment, TInt stopCount)
  1.1600 +{
  1.1601 +	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0736 "));
  1.1602 +	TInt err = KErrNone;
  1.1603 +
  1.1604 +	do
  1.1605 +	{
  1.1606 +		__UHEAP_MARK;
  1.1607 +  		// find out the number of open handles
  1.1608 +		TInt startProcessHandleCount;
  1.1609 +		TInt startThreadHandleCount;
  1.1610 +		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
  1.1611 +
  1.1612 +		// Need to create object here as ECom has embedded TRAPs
  1.1613 +		// that will fail the test if memory not available
  1.1614 +		CRegistrarTest* registrarTest = CRegistrarTest::NewL(aIsFullDiscovery);
  1.1615 +		CleanupStack::PushL(registrarTest);
  1.1616 +
  1.1617 +		// Setting Heap failure for OOM test
  1.1618 + 		__UHEAP_SETFAIL(RHeap::EDeterministic, tryCount);
  1.1619 +
  1.1620 +		TRAP(err, (registrarTest->*testFuncL)());
  1.1621 +
  1.1622 +		__UHEAP_SETFAIL(RHeap::ENone, 0);
  1.1623 +
  1.1624 +		CleanupStack::PopAndDestroy(registrarTest);
  1.1625 +		registrarTest = NULL;
  1.1626 +
  1.1627 +		// check that no handles have leaked
  1.1628 +		TInt endProcessHandleCount;
  1.1629 +		TInt endThreadHandleCount;
  1.1630 +		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
  1.1631 +
  1.1632 +		test(startProcessHandleCount == endProcessHandleCount);
  1.1633 +		test(startThreadHandleCount  == endThreadHandleCount);
  1.1634 +
  1.1635 +		__UHEAP_MARKEND;
  1.1636 +		tryCount = tryCount + increment;
  1.1637 +
  1.1638 +	} while((err == KErrNoMemory) && (tryCount != stopCount));
  1.1639 +
  1.1640 +	tryCount = tryCount - increment;
  1.1641 +
  1.1642 +	if (err == KErrNoMemory)
  1.1643 +	{
  1.1644 +		// test has not yet been able to pass due to memory allocation failures.
  1.1645 +		return -1;
  1.1646 +	}
  1.1647 +
  1.1648 +	test(err == KErrNone);
  1.1649 +
  1.1650 +	// If enough memory has finally been allocated for the test to pass then return
  1.1651 +	// the memory allocation counter value.
  1.1652 +	test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
  1.1653 +	return tryCount;
  1.1654 +
  1.1655 +}
  1.1656 +
  1.1657 +/**
  1.1658 +Wrapper function to call all OOM test functions
  1.1659 +
  1.1660 +@param		testFuncL pointer to OOM test function
  1.1661 +@param		aTestDesc test function name
  1.1662 +*/
  1.1663 +LOCAL_C void DoOOMTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc, TBool aIsFullDiscovery)
  1.1664 +	{
  1.1665 +	test.Next(aTestDesc);
  1.1666 +
  1.1667 +	TInt startCount = 1;
  1.1668 +	TInt increment = 1;
  1.1669 +	TInt successRate = -1;
  1.1670 +	TInt stopCount = 256;
  1.1671 +
  1.1672 + 	successRate = RunTestUnderOOMCondition(testFuncL, aIsFullDiscovery, startCount, increment, stopCount);
  1.1673 +
  1.1674 + 	// (INC115057)
  1.1675 + 	// When method CDiscoverer::CDirScanner::DoScanDriveL is encountered in a test hundreds
  1.1676 + 	// of plug-in files will be scanned. It takes in the order of 3-4000 memory allocation failure
  1.1677 + 	// loops (in techview context) before the scan is finished and the test can complete successfully.
  1.1678 + 	// This will take over an hour. Instead determine the approximate failure point by
  1.1679 + 	// testing with large increments between failures. Once a failure rate interval is found test
  1.1680 + 	// for OOM conditions running up to it.
  1.1681 + 	// This in effect means that we are checking OOM at the start and end of tests but skipping
  1.1682 + 	// the scanning of each and every plugin in the middle of the test.
  1.1683 + 	// (Note that CDiscoverer::CDirScanner::DoScanDriveL may return without leaving when it
  1.1684 + 	// can't allocate TFileName. In this case it seems to this function that the test is
  1.1685 + 	// successful. Therefore even if the successRate above indicates a pass the test is still
  1.1686 + 	// re-run below with larger memory allocation failure valued to make sure that the test does
  1.1687 + 	// in fact run to completion.
  1.1688 +
  1.1689 +   	startCount = 256;
  1.1690 + 	increment = 256;
  1.1691 + 	stopCount = -1;
  1.1692 + 		successRate = RunTestUnderOOMCondition(testFuncL, aIsFullDiscovery, startCount, increment, stopCount);
  1.1693 + 	test(successRate > 0);
  1.1694 +
  1.1695 + 	if (successRate > 256)
  1.1696 + 	{
  1.1697 + 		startCount = successRate - 256;
  1.1698 + 		increment = 1;
  1.1699 + 		stopCount = -1;
  1.1700 + 		successRate = RunTestUnderOOMCondition(testFuncL, aIsFullDiscovery, startCount, increment, stopCount);
  1.1701 + 	}
  1.1702 +
  1.1703 + 	test(successRate > 0);
  1.1704 +
  1.1705 +	}
  1.1706 +
  1.1707 +LOCAL_C void DoTestsL()
  1.1708 +	{
  1.1709 +	__UHEAP_MARK;
  1.1710 +
  1.1711 +	// Basic tests
  1.1712 +	CreateDeleteTestL();
  1.1713 +
  1.1714 +	DoBasicTestL(&CRegistrarTest::EnableDisableTestL, _L("EnableDisableTestL"), ETrue);
  1.1715 +	DoBasicTestL(&CRegistrarTest::ResumeSuspendTestL, _L("ResumeSuspendTestL"), ETrue);
  1.1716 +	DoBasicTestL(&CRegistrarTest::DriveRemovedReinstatedTestL, _L("DriveRemovedReinstatedTestL"), ETrue);
  1.1717 +	DoBasicTestL(&CRegistrarTest::DiscoveriesBegin_Register_CompleteTestL, _L("DiscoveriesBegin_Register_CompleteTestL"), ETrue);
  1.1718 +	DoBasicTestL(&CRegistrarTest::ParseTestL, _L("ParseTestL"), ETrue);
  1.1719 +	DoBasicTestL(&CRegistrarTest::ParseType2TestL, _L("ParseType2TestL"), ETrue);
  1.1720 +	DoBasicTestL(&CRegistrarTest::ParseType3TestL, _L("ParseType3TestL"), ETrue);
  1.1721 +	DoBasicTestL(&CRegistrarTest::ParseType3BadDataTestL, _L("ParseType3BadDataTestL"), ETrue);
  1.1722 +	DoBasicTestL(&CRegistrarTest::ParseRegistrationDataTestL, _L("ParseRegistrationDataTestL"), ETrue);
  1.1723 +	DoBasicTestL(&CRegistrarTest::ParseRegistrationDataType3TestL, _L("ParseRegistrationDataType3TestL"), ETrue);
  1.1724 +	DoBasicTestL(&CRegistrarTest::ParseSpiTestL, _L("ParseSpiTestL"), ETrue);
  1.1725 +	DoBasicTestL(&CRegistrarTest::ParseSpiType3TestL, _L("ParseSpiType3TestL"), ETrue);
  1.1726 +	DoBasicTestL(&CRegistrarTest::ParseSpiRegistrationDataTestL, _L("ParseSpiRegistrationDataTestL"), ETrue);
  1.1727 +	DoBasicTestL(&CRegistrarTest::ParseSpiRegistrationDataType3TestL, _L("ParseSpiRegistrationDataType3TestL"), ETrue);
  1.1728 +	DoBasicTestL(&CRegistrarTest::StateTransitionTestL, _L("StateTransitionTestL"), EFalse);
  1.1729 +	// OOM tests
  1.1730 +	// The OOM test for CRegistrar takes nearly 1 hour on hardware as it is reading the entire ecom.spi file
  1.1731 + 	// Since ECOMSERVERTEST OOM test covered the full CRegistar OOM part, we will not run this the following
  1.1732 + 	// test as that means 2 hours for ecom tests.
  1.1733 +	//OOMCreateDeleteTest();
  1.1734 +	DoOOMTestL(&CRegistrarTest::EnableDisableTestL, _L("OOM EnableDisableTestL"), ETrue);
  1.1735 +	DoOOMTestL(&CRegistrarTest::ResumeSuspendTestL, _L("OOM ResumeSuspendTestL"), ETrue);
  1.1736 +	DoOOMTestL(&CRegistrarTest::DriveRemovedReinstatedTestL, _L("OOM DriveRemovedReinstatedTestL"), ETrue);
  1.1737 +	DoOOMTestL(&CRegistrarTest::DiscoveriesBegin_Register_CompleteTestL, _L("OOM DiscoveriesBegin_Register_CompleteTestL"), ETrue);
  1.1738 +	DoOOMTestL(&CRegistrarTest::ParseTestL, _L("OOM ParseTestL"), ETrue);
  1.1739 +	DoOOMTestL(&CRegistrarTest::ParseType2TestL, _L("OOM ParseType2TestL"), ETrue);
  1.1740 +	DoOOMTestL(&CRegistrarTest::ParseType3TestL, _L("OOM ParseType3TestL"), ETrue);
  1.1741 +	DoOOMTestL(&CRegistrarTest::ParseSpiTestL, _L("OOM ParseSpiTestL"), ETrue);
  1.1742 +	DoOOMTestL(&CRegistrarTest::ParseSpiType3TestL, _L("OOM ParseSpiType3TestL"), ETrue);
  1.1743 +	DoOOMTestL(&CRegistrarTest::StateTransitionTestL, _L("OOM StateTransitionTestL"), EFalse);
  1.1744 +	// Not performing the OOM on ParseRegistrationDataL because of TRAPs present inside this function.
  1.1745 +	// The OOM error is trapped inside during the creation of the DllData but this error is not propagated to
  1.1746 +	// the calling funtion. Hence does not give the right results. However the normal test is performed above.
  1.1747 +	//DoOOMTestL(&CRegistrarTest::ParseRegistrationDataTestL,_L("OOM ParseRegistrationDataTestL"));
  1.1748 +	__UHEAP_MARKEND;
  1.1749 +	}
  1.1750 +
  1.1751 +// Copies the Plugins to specific folder for testing purpose
  1.1752 +LOCAL_C void CopyPlugins()
  1.1753 +	{
  1.1754 +	TInt err=KErrNone;
  1.1755 +	TRAP(err, EComTestUtils::FileManCopyFileL(KNewResourceFileNameZ, KNewResourceFileNameC));
  1.1756 +	test(err==KErrNone);
  1.1757 +	TRAP(err, EComTestUtils::FileManCopyFileL(KNewDllFileNameZ, KNewDllFileNameC));
  1.1758 +	test(err==KErrNone);
  1.1759 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType3ResourceFileNameZ, KType3ResourceFileNameC));
  1.1760 +	test(err==KErrNone);
  1.1761 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType3DllFileNameZ, KType3DllFileNameC));
  1.1762 +	test(err==KErrNone);
  1.1763 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadDataResourceFileNameZ, KType3BadDataResourceFileNameC));
  1.1764 +	test(err==KErrNone);
  1.1765 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadDataDllFileNameZ, KType3BadDataDllFileNameC));
  1.1766 +	test(err==KErrNone);
  1.1767 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadData1ResourceFileNameZ, KType3BadData1ResourceFileNameC));
  1.1768 +	test(err==KErrNone);
  1.1769 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadData1DllFileNameZ, KType3BadData1DllFileNameC));
  1.1770 +	test(err==KErrNone);
  1.1771 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadData2ResourceFileNameZ, KType3BadData2ResourceFileNameC));
  1.1772 +	test(err==KErrNone);
  1.1773 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadData2DllFileNameZ, KType3BadData2DllFileNameC));
  1.1774 +	test(err==KErrNone);
  1.1775 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType2ResourceFileNameZ, KType2ResourceFileNameC));
  1.1776 +	test(err==KErrNone);
  1.1777 +	TRAP(err, EComTestUtils::FileManCopyFileL(KType2DllFileNameZ, KType2DllFileNameC));
  1.1778 +	test(err==KErrNone);
  1.1779 +	}
  1.1780 +
  1.1781 +// Deleting plugin from the RAM for cleanup purpose
  1.1782 +inline LOCAL_C void DeleteTestPlugin()
  1.1783 +	{
  1.1784 +	TInt err=KErrNone;
  1.1785 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KNewResourceFileNameC));
  1.1786 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KNewDllFileNameC));
  1.1787 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3ResourceFileNameC));
  1.1788 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3DllFileNameC));
  1.1789 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadDataResourceFileNameC));
  1.1790 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadDataDllFileNameC));
  1.1791 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadData1ResourceFileNameC));
  1.1792 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadData1DllFileNameC));
  1.1793 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadData2ResourceFileNameC));
  1.1794 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadData2DllFileNameC));
  1.1795 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType2ResourceFileNameC));
  1.1796 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KType2DllFileNameC));
  1.1797 +	}
  1.1798 +
  1.1799 +//Initialise the Active Scheduler
  1.1800 +LOCAL_C void SetupL()
  1.1801 +	{
  1.1802 +	// Construct and install the Active Scheduler. The Active Schedular is needed
  1.1803 +	// by components used by this test as they are ActiveObjects.
  1.1804 +	TheActiveScheduler = new(ELeave)CActiveScheduler;
  1.1805 +	CActiveScheduler::Install(TheActiveScheduler);
  1.1806 +	}
  1.1807 +
  1.1808 +GLDEF_C TInt E32Main()
  1.1809 +	{
  1.1810 +	__UHEAP_MARK;
  1.1811 +
  1.1812 +	test.Printf(_L("\n"));
  1.1813 +	test.Title();
  1.1814 +	test.Start( _L("Registrar Tests.") );
  1.1815 +
  1.1816 +	TheTrapCleanup = CTrapCleanup::New();
  1.1817 +
  1.1818 +	// Connect the file server instance
  1.1819 +	User::LeaveIfError(TheFs.Connect());
  1.1820 +
  1.1821 +	TRAPD(err, SetupL());
  1.1822 +	test(err == KErrNone);
  1.1823 +
  1.1824 +	// We need to clean up the registry files to ensure a fresh discovery that
  1.1825 +	// has the effect of taking certain pathways within the code. This
  1.1826 +	// tests the memory cleanup
  1.1827 +	// Delete the prevous data files so we rediscover from scratch
  1.1828 +
  1.1829 +	TRAP(err, EComTestUtils::FileManDeleteFileL(KDataDir));
  1.1830 +	CopyPlugins();
  1.1831 +
  1.1832 +	// The reason for the folowing delay is:
  1.1833 +	// ECOM server could be already started. It means that when we copy some
  1.1834 +	// ECOM plugins from Z: to C: drive - ECOM server should look for and
  1.1835 +	// find the new ECOM plugins. The ECOM server uses for that an active object,
  1.1836 +	// which scans plugin directories. So the discovering service is asynchronous.
  1.1837 +	// We have to wait some time until it finishes.
  1.1838 +	// Otherwise ListImplementationsL could fail to find requested implementations.
  1.1839 +	User::After(KOneSecond * 3);
  1.1840 +
  1.1841 +	// Call the main tests
  1.1842 +	TRAP(err, DoTestsL());
  1.1843 +	test(err == KErrNone);
  1.1844 +
  1.1845 +	// Cleanup files. If the cleanup fails that is no problem,
  1.1846 +	// as any subsequent tests will replace them. The only downside
  1.1847 +	// would be the disk not being tidied
  1.1848 +	DeleteTestPlugin();
  1.1849 +
  1.1850 +	delete TheActiveScheduler;
  1.1851 +	delete TheTrapCleanup;
  1.1852 +
  1.1853 +	TheFs.Close();
  1.1854 +
  1.1855 +	test.End();
  1.1856 +	test.Close();
  1.1857 +
  1.1858 +	__UHEAP_MARKEND;
  1.1859 +	return (KErrNone);
  1.1860 +	}