lowlevellibsandfws/pluginfw/Framework/RegistrarTest/t_registrar.cpp
changeset 0 e4d67989cc36
child 44 97b0fb8a2cc2
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This file contains test classes and their implementations
       
    15 // to test production class CRegistrar. Where necessary stubs
       
    16 // are implemented to help in writing test harness using RTest.
       
    17 // 
       
    18 //
       
    19 
       
    20 #include "RegistryData.h"
       
    21 #include "EComErrorCodes.h"
       
    22 #include "EComUidCodes.h"
       
    23 #include "ImplementationInformation.h"
       
    24 #include "RegistryData.h"
       
    25 #include "Registrar.h"
       
    26 #include "RegistrarObserver.h"
       
    27 #include "../EcomTestUtils/EcomTestUtils.h"
       
    28 #include "EComEntryBase.h"
       
    29 #include "DriveInfo.h"
       
    30 
       
    31 #include <e32test.h>
       
    32 #include <f32file.h>
       
    33 #include <bautils.h>
       
    34 #include <startup.hrh>
       
    35 
       
    36 #include "baspi.h"
       
    37 
       
    38 _LIT (KDataDir, "C:\\private\\10009D8F\\ECom*");
       
    39 
       
    40 //We need two different entry RSC and the SPI to fully test CRegistrar
       
    41 //------------------------------NEW TYPE----------------------------------------
       
    42 const TUid NewDllUid={0x101F847B};
       
    43 _LIT(KNewResourceFileNameOnly,"EComExample5.rsc");
       
    44 _LIT(KNewResourceFileNameC, "C:\\resource\\plugins\\EComExample5.rsc");
       
    45 _LIT(KNewDllFileNameC, "C:\\sys\\bin\\EComExample5.dll");
       
    46 _LIT(KNewResourceFileNameZ, "z:\\RAMOnly\\EComExample5.rsc");
       
    47 _LIT(KNewDllFileNameZ,"z:\\RAMOnly\\EComExample5.dll");
       
    48 
       
    49 //We need IIC type 3 RSC to fully test CRegistrar
       
    50 //------------------------------IIC TYPE 3----------------------------------------
       
    51 const TUid Type3DllUid = {0x10009E3E};
       
    52 _LIT(KType3ResourceFileNameOnly,"EComExample12.rsc");
       
    53 _LIT(KType3ResourceFileNameC, "C:\\resource\\plugins\\EComExample12.rsc");
       
    54 _LIT(KType3DllFileNameC, "C:\\sys\\bin\\EComExample12.dll");
       
    55 _LIT(KType3ResourceFileNameZ, "z:\\RAMOnly\\EComExample12.rsc");
       
    56 _LIT(KType3DllFileNameZ,"z:\\RAMOnly\\EComExample12.dll");
       
    57 
       
    58 //We need IIC type 3 RSC with data exceed maximum to fully test CRegistrar
       
    59 //------------------------------IIC TYPE 3----------------------------------------
       
    60 _LIT(KType3BadDataResourceFileNameOnly,"EComExampleBadData.rsc");
       
    61 _LIT(KType3BadDataResourceFileNameC, "C:\\resource\\plugins\\EComExampleBadData.rsc");
       
    62 _LIT(KType3BadDataDllFileNameC, "C:\\sys\\bin\\EComExampleBadData.dll");
       
    63 _LIT(KType3BadDataResourceFileNameZ, "z:\\RAMOnly\\EComExampleBadData.rsc");
       
    64 _LIT(KType3BadDataDllFileNameZ,"z:\\RAMOnly\\EComExampleBadData.dll");
       
    65 
       
    66 _LIT(KType3BadData1ResourceFileNameOnly,"EComExampleBadData1.rsc");
       
    67 _LIT(KType3BadData1ResourceFileNameC, "C:\\resource\\plugins\\EComExampleBadData1.rsc");
       
    68 _LIT(KType3BadData1DllFileNameC, "C:\\sys\\bin\\EComExampleBadData1.dll");
       
    69 _LIT(KType3BadData1ResourceFileNameZ, "z:\\RAMOnly\\EComExampleBadData1.rsc");
       
    70 _LIT(KType3BadData1DllFileNameZ,"z:\\RAMOnly\\EComExampleBadData1.dll");
       
    71 
       
    72 _LIT(KType3BadData2ResourceFileNameOnly,"EComExampleBadData2.rsc");
       
    73 _LIT(KType3BadData2ResourceFileNameC, "C:\\resource\\plugins\\EComExampleBadData2.rsc");
       
    74 _LIT(KType3BadData2DllFileNameC, "C:\\sys\\bin\\EComExampleBadData2.dll");
       
    75 _LIT(KType3BadData2ResourceFileNameZ, "z:\\RAMOnly\\EComExampleBadData2.rsc");
       
    76 _LIT(KType3BadData2DllFileNameZ,"z:\\RAMOnly\\EComExampleBadData2.dll");
       
    77 
       
    78 //We need IIC type 2 RSC to fully test CRegistrar
       
    79 //------------------------------IIC TYPE 2----------------------------------------
       
    80 _LIT(KType2ResourceFileNameOnly,"EComExample14.rsc");
       
    81 _LIT(KType2ResourceFileNameC, "C:\\resource\\plugins\\EComExample14.rsc");
       
    82 _LIT(KType2DllFileNameC, "C:\\sys\\bin\\EComExample14.dll");
       
    83 _LIT(KType2ResourceFileNameZ, "z:\\RAMOnly\\EComExample14.rsc");
       
    84 _LIT(KType2DllFileNameZ,"z:\\RAMOnly\\EComExample14.dll");
       
    85 
       
    86 //------------------------------LEGACY TYPE-------------------------------------
       
    87 
       
    88 // spi test file
       
    89 _LIT(KEComSpiTestFilePathAndName, "Z:\\Test\\Data\\EcomTest.spi");
       
    90 // spi test file for testing IIC Type3
       
    91 _LIT(KEComSpiTestFileType3PathAndName, "Z:\\Test\\Data\\ecomtesttype3.spi");
       
    92 
       
    93 const TInt KOneSecond = 1000000;
       
    94 
       
    95 const TUid interfaceUidExample12 = {0x10009E36};
       
    96 const TUid extendedInterfaceUid1 = {0x10009E44};
       
    97 const TUid extendedInterfaceUid2 = {0x10009E45};
       
    98 const TUid extendedInterfaceUid3 = {0x10009E46};
       
    99 
       
   100 
       
   101 LOCAL_D RTest test(_L("t_Registrar.exe"));
       
   102 
       
   103 LOCAL_D RFs					TheFs;
       
   104 
       
   105 LOCAL_D CTrapCleanup* 		TheTrapCleanup 		= NULL;
       
   106 
       
   107 LOCAL_D CActiveScheduler*	TheActiveScheduler	= NULL;
       
   108 
       
   109 // Used for supressing warning in OOM tests
       
   110 #define __UNUSED_VAR(var) var = var
       
   111 
       
   112 //It is used by some test methods which are called two times:
       
   113 //from normal test and from OOM test.
       
   114 static void LeaveIfErrNoMemory(TInt aError)
       
   115 	{
       
   116 	if(aError == KErrNoMemory)
       
   117 		{
       
   118 		User::Leave(aError);
       
   119 		}
       
   120 	}
       
   121 
       
   122 /**
       
   123 TRegistrar_StateAccessor class allows access to private and protected
       
   124 members of production code class CRegistrar, as its a friend class.
       
   125 */
       
   126 class TRegistrar_StateAccessor
       
   127 	{
       
   128 public:
       
   129 	void DiscoveriesBegin(CRegistrar& aRegistrar);
       
   130 
       
   131 	void DiscoveriesComplete(CRegistrar& aRegistrar, TBool aSuccessful);
       
   132 
       
   133 	void DriveRemovedL(CRegistrar& aRegistrar, TDriveUnit aDriveUnit);
       
   134 
       
   135 	void DriveReinstatedL(CRegistrar& aRegistrar, TDriveUnit aDriveUnit);
       
   136 
       
   137 	void RegisterDiscoveryL(CRegistrar& aRegistrar,const TDriveName& aDrive, CPluginBase*& aEntry,TBool aDatFileExists);
       
   138 
       
   139 	void ParseL(CRegistrar& aRegistrar,
       
   140 				CPluginBase*& aEntry,
       
   141 				CRegistryData::CDllData& aDll);
       
   142 
       
   143 	void ParseRegistrationDataL(CRegistrar& aRegistrar,
       
   144 				CPluginBase*& aEntry,
       
   145 				TDriveUnit& aDriveUnit,
       
   146 				TBool aUpdate,
       
   147 				TInt aRegistryDriveIndex,
       
   148 				CRegistryData::CDriveData* aDriveData);
       
   149 
       
   150 	CRegistrar::TRegistrarState State(CRegistrar& aRegistrar);
       
   151 	};
       
   152 
       
   153 /**
       
   154 Parses the resource file associated with an
       
   155 Interface Implementation Collection for the plugin entry.
       
   156 
       
   157 @param		aRegistrar The CRegistrar class object under test
       
   158 @param		aEntry an ecom entry discovered
       
   159 @param		aDll CRegistrar::CDllData object in which parsed data needs to be stored
       
   160 @pre 		CRegistrar should be fully constructed.
       
   161 @post		The resource file is parsed and the data is added to 'aDll'.
       
   162  */
       
   163 void TRegistrar_StateAccessor::ParseL(CRegistrar& aRegistrar,
       
   164 									  CPluginBase*& aEntry,
       
   165 									  CRegistryData::CDllData& aDll)
       
   166 
       
   167 	{
       
   168 	aRegistrar.ParseL(aEntry,aDll);
       
   169 	}
       
   170 
       
   171 /**
       
   172 Determines if the directory entry for an Interface Implementation
       
   173 Collection requires registration. Parses and registers the plugin entry
       
   174 associated with the resource file if entry is not already registered.
       
   175 
       
   176 @param		aRegistrar The CRegistrar class object under test
       
   177 @param		aEntry Directory entry for the Interface Impplementation Collection.
       
   178 @param		aRscFileName Resource file from which to extract the data
       
   179 @param		aDrive Drive on which registry data has been found on
       
   180 @param		aUpdate Flag indicating if this is an update, or new entry.
       
   181 @param		aRegistryDriveIndex Index within the registry data
       
   182 			for the branch that the registry entry was found within.
       
   183 @pre 		CRegistrar is fully constructed.
       
   184 @post		The Interface Implementation Collection entry has been processed appropriately.
       
   185 */
       
   186 void TRegistrar_StateAccessor::ParseRegistrationDataL(CRegistrar& aRegistrar,
       
   187 														CPluginBase*& aEntry,
       
   188 														TDriveUnit& aDrive,
       
   189 														TBool aUpdate,
       
   190 														TInt aRegistryDriveIndex,
       
   191 														CRegistryData::CDriveData* aDriveData)
       
   192 	{
       
   193 	aRegistrar.ParseRegistrationDataL(aEntry, aDrive,aUpdate, aRegistryDriveIndex, aDriveData);
       
   194 	}
       
   195 
       
   196 /**
       
   197 Overload of the MDiscovererObserver callback method.
       
   198 The cue that a registry update is about to occur.
       
   199 
       
   200 @param		aRegistrar The CRegistrar class object under test
       
   201 @pre 		CRegistrar is fully constructed
       
   202 @post		The Registry data manager has been informed that its internal
       
   203 			data is out of date.
       
   204 */
       
   205 void TRegistrar_StateAccessor::DiscoveriesBegin(CRegistrar& aRegistrar)
       
   206 	{
       
   207 	aRegistrar.DiscoveriesBegin();
       
   208 	}
       
   209 
       
   210 /**
       
   211 Overload of the MDiscovererObserver callback method.
       
   212 The cue that a registry update is done.
       
   213 
       
   214 @param		aRegistrar The CRegistrar class object under test
       
   215 @param		aSuccessful The registry data has been updated successfully
       
   216 @pre 		CRegistrar is fully constructed
       
   217 @post		The current registry data and the internal access indexes have been rebuilt.
       
   218 */
       
   219 void TRegistrar_StateAccessor::DiscoveriesComplete(CRegistrar& aRegistrar,
       
   220 												   TBool aSuccessful)
       
   221 	{
       
   222 	aRegistrar.DiscoveriesComplete(aSuccessful, EPluginProcessingTypeAll);
       
   223 	}
       
   224 
       
   225 /**
       
   226 Overload of the MDiscovererObserver callback method.
       
   227 Signals registry that the registered Interface Implementation
       
   228 Collections stored upon the specified drive are no
       
   229 longer available for use.
       
   230 
       
   231 @param		aRegistrar The CRegistrar class object under test
       
   232 @param		aDrive	The drive identifier.
       
   233 @pre 		CRegistrar is fully constructed.
       
   234 @post		The registered Interface Implementation Collections
       
   235 			stored upon the specified drive are no
       
   236 			longer available for use.
       
   237 */
       
   238 void TRegistrar_StateAccessor::DriveRemovedL(CRegistrar& aRegistrar,
       
   239 											 TDriveUnit aDrive)
       
   240 	{
       
   241 	aRegistrar.DriveRemovedL(aDrive);
       
   242 	}
       
   243 
       
   244 /**
       
   245 Overload of the MDiscovererObserver callback method.
       
   246 Signals registry that the registered Interface
       
   247 Implementation Collections stored upon the specified drive are again
       
   248 available for use.
       
   249 
       
   250 @param		aRegistrar The CRegistrar class object under test
       
   251 @param		aDrive	The drive identifier.
       
   252 @pre 		CRegistrar is fully constructed.
       
   253 @post		The registered Interface Implementation Collections
       
   254 			stored upon the specified drive are again
       
   255 			made available for use.
       
   256 */
       
   257 void TRegistrar_StateAccessor::DriveReinstatedL(CRegistrar& aRegistrar,
       
   258 												   TDriveUnit aDrive)
       
   259 	{
       
   260 	aRegistrar.DriveReinstatedL(aDrive);
       
   261 	}
       
   262 
       
   263 /**
       
   264 Overload of the MDiscovererObserver callback method.
       
   265 Adds the specified Interface Implementation Collection Entry to the registry.
       
   266 
       
   267 @param		aRegistrar The CRegistrar class object under test
       
   268 @param		aDirEntry The plugin entry to register.
       
   269 @pre 		CRegistrar is fully constructed
       
   270 @post		The plugin entry is registered.
       
   271 */
       
   272 void TRegistrar_StateAccessor::RegisterDiscoveryL(CRegistrar& aRegistrar,
       
   273 												  const TDriveName& aDrive,
       
   274 												  CPluginBase*& aEntry,
       
   275 												  TBool aDatFileExists )
       
   276 	{
       
   277 	aRegistrar.RegisterDiscoveryL(aDrive,aEntry,aDatFileExists);
       
   278 	}
       
   279 
       
   280 /**
       
   281 Retrieves the object's current state.
       
   282 
       
   283 @return 	TCRegistarState the CRegistrar's current state.
       
   284 @pre		CRegistrar is fully constructed.
       
   285 @post 		the CRegistrar's current state has been returned.
       
   286 */
       
   287 CRegistrar::TRegistrarState TRegistrar_StateAccessor::State(CRegistrar& aRegistrar)
       
   288 	{
       
   289 	return aRegistrar.State();
       
   290 	}
       
   291 
       
   292 /**
       
   293 TRegistryData_StateAccessor class allows access to private and protected
       
   294 members of production code class CRegistryData, as its a friend class.
       
   295 */
       
   296 class TRegistryData_StateAccessor
       
   297 	{
       
   298 public:
       
   299 	TInt FindImplementation(CRegistryData& aRegistryData,
       
   300 				const TUid aImplUid,
       
   301 				const TUid aInterfaceUid,
       
   302 				CRegistryData::CImplementationData*& aImplData) const;
       
   303 	};
       
   304 
       
   305 /**
       
   306 @return		KErrNone if found otherwise KErrNotFound
       
   307 @param		aRegistryData The CRegistryData class object
       
   308 @param		aImplUid The implementation to find.
       
   309 @param		aInterfaceUid If greater than 0 the interface associated with the
       
   310 			implementation to find.
       
   311 @param		aImplData The found implementation data.
       
   312 @pre 		CRegistrar is fully constructed
       
   313 */
       
   314 TInt TRegistryData_StateAccessor::FindImplementation(CRegistryData& aRegistryData,
       
   315 												const TUid aImplUid,
       
   316 												const TUid aInterfaceUid,
       
   317 												CRegistryData::CImplementationData*& aImplData) const
       
   318 	{
       
   319 	return aRegistryData.FindImplementation(aImplUid, aInterfaceUid, aImplData);
       
   320 	}
       
   321 
       
   322 
       
   323 /**
       
   324 The implementation of the abstract Registrar Observer class,
       
   325 used for recieving notifications of registry changes.
       
   326 Stub class(for CEComServer) used for the creation of CRegistrar class object.
       
   327 CEComServer class acts as observer for CRegistrar.
       
   328 */
       
   329 class CTestRegistrarObserver : public MRegistrarObserver
       
   330 	{
       
   331 public:
       
   332 	// This function is used by RegistrarObserver (i.e.CEComServer) to notify its
       
   333 	// clients(REComSession objects) that some change has happened in Registry.
       
   334 	// Here we have no clients to notify, so no implementaion.
       
   335 	void Notification( TInt /*aNotification*/ ) {}
       
   336 	};
       
   337 
       
   338 /**
       
   339 Test class for object CRegistrar.
       
   340 This class provides the parameters and behaviour that
       
   341 allows this class to behave normally under a test
       
   342 scenario.
       
   343 */
       
   344 class CRegistrarTest : public CBase
       
   345 	{
       
   346 public:
       
   347 
       
   348 	static CRegistrarTest* NewL(TBool aIsFullDiscovery);
       
   349 	virtual ~CRegistrarTest();
       
   350 	const CImplementationInformation * GetImplementationDataL();
       
   351 
       
   352 	void EnableDisableTestL();
       
   353 	void ResumeSuspendTestL();
       
   354 	void DiscoveriesBegin_Register_CompleteTestL();
       
   355 	void DriveRemovedReinstatedTestL();
       
   356 	void ParseTestL();
       
   357 	void ParseType2TestL();
       
   358 	void ParseType3TestL();
       
   359 	void ParseType3BadDataTestL();
       
   360 	void ParseRegistrationDataTestL();
       
   361 	void ParseRegistrationDataType3TestL();
       
   362 	void StateTransitionTestL();
       
   363 	void ParseSpiRegistrationDataTestL();
       
   364 	void ParseSpiRegistrationDataType3TestL();
       
   365 	void ParseSpiTestL();
       
   366 	void ParseSpiType3TestL();
       
   367 
       
   368 private:
       
   369 	CRegistrarTest();
       
   370 	void ConstructL(TBool aIsFullDiscovery);
       
   371 	void ParseBadDataTestL(const TDesC& aRscFullName, const TDesC& aRscNameOnly);
       
   372 public:
       
   373 	/** The instance of the class under test */
       
   374 	CRegistrar* iRegistrar;
       
   375 
       
   376 	/** The instance of the State Accessor class */
       
   377 	TRegistrar_StateAccessor* iStateAccessor;
       
   378 
       
   379 	/** The registry data instance required to construct a CRegistrar object */
       
   380 	CRegistryData* iRegistryData;
       
   381 
       
   382 	/** The instance of the Registry Data State Accessor class */
       
   383 	TRegistryData_StateAccessor* iRegistryDataStateAccessor;
       
   384 
       
   385 	/** The instance of the observer of CRegistrar class */
       
   386 	MRegistrarObserver* iRegistrarObserver;
       
   387 
       
   388 	/** The destination for the data discovered during a parse */
       
   389 	CRegistryData::CDllData* iDllData;
       
   390 
       
   391 	/** Unique Id of the ECOM dll */
       
   392 	TUid    iDllUid;
       
   393 
       
   394 	/** Unique Id of an interface implementation */
       
   395 	TUid	iImplementationUid;
       
   396 
       
   397 	/** Unique Id of an interface */
       
   398 	TUid	iInterfaceUid;
       
   399 
       
   400 	/** The drive on which interface implementations can be found */
       
   401 	TDriveUnit	iDriveUnit;
       
   402 
       
   403 	/** Ecom plugin which contains interface implementations. Used in Registration APIs.*/
       
   404 	TEntry		iDllEntry;
       
   405 	};
       
   406 
       
   407 /**
       
   408 Standardised safe construction which
       
   409 leaves nothing on the cleanup stack.
       
   410 
       
   411 @param		aIsFullDiscovery whether the constructor make full discovery
       
   412 @post		CRegistrarTest is fully constructed and initialised.
       
   413 */
       
   414 CRegistrarTest* CRegistrarTest::NewL(TBool aIsFullDiscovery)
       
   415 	{
       
   416 	CRegistrarTest* self = new (ELeave) CRegistrarTest();
       
   417 	CleanupStack::PushL(self);
       
   418 	self->ConstructL(aIsFullDiscovery);
       
   419 	CleanupStack::Pop(self);
       
   420 	return self;
       
   421 	}
       
   422 
       
   423 /**
       
   424 Standardized default c'tor
       
   425 
       
   426 @post		CRegistrarTest is fully constructed.
       
   427 */
       
   428 CRegistrarTest::CRegistrarTest()
       
   429 :	CBase(),
       
   430 	iDriveUnit(EDriveC)
       
   431 	{
       
   432 	iDllUid.iUid			= 0x101F847B; // Dlluid for Ecom plugin EComExample5.dll
       
   433 	iInterfaceUid.iUid		= 0x10009DC0; // Interface uid for interface contained in above plugin
       
   434 	iImplementationUid.iUid = 0x101f847C; // Implementaion uid for above interface
       
   435 	TUid uid1 = {0};
       
   436 	TUid uid2 = {0};
       
   437 	iDllEntry.iType = TUidType(uid1, uid2, iDllUid);//Setting Dlluid to plugin entry
       
   438 	}
       
   439 
       
   440 /**
       
   441 Destructor.
       
   442 
       
   443 @post		This object is properly destroyed.
       
   444 */
       
   445 CRegistrarTest::~CRegistrarTest()
       
   446 	{
       
   447 	delete iDllData;
       
   448 	delete iRegistrar;
       
   449 	delete iRegistryData;
       
   450 	delete iRegistrarObserver;
       
   451 	delete iStateAccessor;
       
   452 	delete iRegistryDataStateAccessor;
       
   453 	}
       
   454 
       
   455 /**
       
   456 Standardized 2nd(Initialization) phase of two phase construction.
       
   457 
       
   458 @param		aIsFullDiscovery whether the constructor make full discovery
       
   459 @post		CRegistrarTest is fully constructed.
       
   460 */
       
   461 void CRegistrarTest::ConstructL(TBool aIsFullDiscovery)
       
   462 	{
       
   463 	CRegistryData::CDriveData* driveData=NULL;
       
   464 	iRegistrarObserver = new (ELeave) CTestRegistrarObserver;
       
   465 	iStateAccessor	   = new (ELeave) TRegistrar_StateAccessor;
       
   466 	iRegistryDataStateAccessor	   = new (ELeave) TRegistryData_StateAccessor;
       
   467 	iRegistryData	   = CRegistryData::NewL(TheFs);
       
   468 	iRegistrar		   = CRegistrar::NewL(*iRegistryData, *iRegistrarObserver, TheFs);
       
   469 	if(aIsFullDiscovery)
       
   470 		{
       
   471 		iRegistrar->ProcessSSAEventL(EStartupStateNonCritical);
       
   472 		}
       
   473 	iDllData		   = CRegistryData::CDllData::NewLC(driveData);
       
   474 	CleanupStack::Pop(iDllData);
       
   475 	}
       
   476 
       
   477 
       
   478 /**
       
   479 Returns information of a particular interface implementation.
       
   480 
       
   481 @return		Information on the requested implementation
       
   482 @pre 		This object is fully constructed
       
   483 */
       
   484 const CImplementationInformation * CRegistrarTest::GetImplementationDataL()
       
   485 	{
       
   486 	CRegistryData::CImplementationData *implementationData=NULL;
       
   487 	TUid dummyUid;
       
   488 	dummyUid.iUid = 0;
       
   489 	User::LeaveIfError(iRegistryDataStateAccessor->FindImplementation(*iRegistryData, iImplementationUid,
       
   490 																dummyUid, implementationData));
       
   491 	return implementationData->iImplInfo;
       
   492 	}
       
   493 
       
   494 /**
       
   495 The test executes by first Disabling the Implementation then by
       
   496 Enabling it.
       
   497 
       
   498 @SYMTestCaseID          SYSLIB-ECOM-CT-0727
       
   499 @SYMTestCaseDesc	    Tests for enabling and disabling the Implementation
       
   500 @SYMTestPriority 	    High
       
   501 @SYMTestActions  	    Fetch the Implementation information for testing for iImplementationUid
       
   502                         Disable and enable the implementation for the unique UID
       
   503 @SYMTestExpectedResults The test must not fail.
       
   504 @SYMREQ                 REQ0000
       
   505 */
       
   506 void CRegistrarTest::EnableDisableTestL()
       
   507 	{
       
   508 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0727 "));
       
   509 	const CImplementationInformation *implimentationInfo = NULL;
       
   510 
       
   511 	// Get the Implementation information for testing for iImplementationUid.
       
   512 	// Implementation for iImplementationUid should be registered to
       
   513 	// run this test successfully.
       
   514 	TRAPD(err, implimentationInfo = GetImplementationDataL());
       
   515 	::LeaveIfErrNoMemory(err);
       
   516 	test(err == KErrNone);
       
   517 	test(implimentationInfo != NULL);
       
   518 
       
   519 	// Disable the implementaion
       
   520 	err = iRegistrar->Disable(iImplementationUid);
       
   521 	::LeaveIfErrNoMemory(err);
       
   522 	test(KErrNone == err);
       
   523 	test(implimentationInfo->Disabled());//It should be disabled
       
   524 
       
   525 
       
   526 	// Enable the implementaion
       
   527 	err = iRegistrar->Enable(iImplementationUid);
       
   528 	::LeaveIfErrNoMemory(err);
       
   529 	test(KErrNone == err);
       
   530 	test(!implimentationInfo->Disabled());//It should be enabled
       
   531 	}
       
   532 
       
   533 /**
       
   534 The test executes by first suspending the discoverer then by resuming it.
       
   535 
       
   536 @SYMTestCaseID          SYSLIB-ECOM-CT-0728
       
   537 @SYMTestCaseDesc	    Tests for overloaded MBackupNotifierObserver's Suspend and Resume functions
       
   538 @SYMTestPriority 	    High
       
   539 @SYMTestActions  	    The test executes by first calling CRegistrar's suspend and then by resume.
       
   540 @SYMTestExpectedResults The test must not fail.
       
   541 @SYMREQ                 REQ0000
       
   542 */
       
   543 void CRegistrarTest::ResumeSuspendTestL()
       
   544 	{
       
   545 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0728 "));
       
   546 	TInt err = iRegistrar->Suspend();
       
   547 	::LeaveIfErrNoMemory(err);
       
   548 	test(err == KErrNone);
       
   549 
       
   550 	err = iRegistrar->Resume();
       
   551 	::LeaveIfErrNoMemory(err);
       
   552 	test(err == KErrNone);
       
   553 	}
       
   554 
       
   555 /**
       
   556 The test executes by calling DiscoveriesBegin, RegisterDiscoveryL and
       
   557 DiscoveriesComplete in sequence to register the plugin.
       
   558 
       
   559 @SYMTestCaseID          SYSLIB-ECOM-CT-0729
       
   560 @SYMTestCaseDesc	    Tests for registering the DLL interfaces
       
   561 @SYMTestPriority 	    High
       
   562 @SYMTestActions  	    Calls up DiscoveriesBegin, RegisterDiscoveryL and
       
   563 						DiscoveriesComplete in sequence to register the plugin and
       
   564 						verifies that DLL's have been registered succesfully.
       
   565 @SYMTestExpectedResults The test must not fail.
       
   566 @SYMREQ                 REQ0000
       
   567 */
       
   568 void CRegistrarTest::DiscoveriesBegin_Register_CompleteTestL()
       
   569 	{
       
   570 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0729 "));
       
   571 	// The following three steps need to be executed to successfully
       
   572 	// register the plugin
       
   573 	iStateAccessor->DiscoveriesBegin(*iRegistrar);
       
   574 
       
   575 //-----------------REGISTRATION PART------------------------------------
       
   576 	CPluginBase* entryBase=NULL;
       
   577 	TInt err=KErrNone;
       
   578 	TBool update = EFalse;
       
   579 	TInt  driveIndex = KErrNotFound;		//Used as return parameter used below
       
   580 	TBool isDriveRegistered = EFalse;		//Used as return parameter used below
       
   581 	CRegistryData::CDriveData* driveData = NULL;
       
   582 
       
   583 
       
   584 	//Testing a RSc based entry using EComExample5.dll and EComExample5.rsc
       
   585 	TEntry rscBasedEntry;
       
   586 	rscBasedEntry.iName=KNewResourceFileNameOnly;
       
   587 	err = TheFs.Modified(KNewResourceFileNameC, rscBasedEntry.iModified);
       
   588 	test(err==KErrNone);
       
   589 	TParse rscPath;
       
   590 	rscPath.Set(KNewResourceFileNameC,NULL,NULL);
       
   591 	entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
       
   592 	CleanupStack::PushL(entryBase);
       
   593 
       
   594 	//Now register this Rsc Entry with the registrar
       
   595 	TRAP(err, iStateAccessor->RegisterDiscoveryL(*iRegistrar,rscPath.Drive(), entryBase,ETrue));
       
   596 	::LeaveIfErrNoMemory(err);
       
   597 	test(err == KErrNone);
       
   598 	CleanupStack::PopAndDestroy(entryBase);
       
   599 	entryBase=NULL;
       
   600 	TRAP(err, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
       
   601 	::LeaveIfErrNoMemory(err);
       
   602 	test(driveIndex != KErrNotFound);
       
   603 	//Verify weather dll interfaces got registered
       
   604 	// Check whether Rsc based entry is already registered in CRegistryData
       
   605 
       
   606 	TRAP(err, isDriveRegistered = iRegistryData->IsRegisteredWithDate(
       
   607 																		NewDllUid,
       
   608 																		rscBasedEntry.iModified,
       
   609 																		update,
       
   610 																		driveData));
       
   611 	::LeaveIfErrNoMemory(err);
       
   612 	test(err == KErrNone);
       
   613 	test(isDriveRegistered);
       
   614 	test(!update);// As plugin is just registered, it does not require update.
       
   615 
       
   616 	//THE REASON WHY THIS FUNCTION IS MOVED TO THE BACK AS IT PREVENT THE TESTING
       
   617 	//OF THE LEGACY PLUGINS BEING REGISTERED AS DURING THE VALIDATE REGISTRY
       
   618 	//THE LEGACY ENTRY WILL BE WIPED OUT
       
   619 	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
       
   620 	test(iRegistrar != NULL);
       
   621 	}
       
   622 
       
   623 /**
       
   624 @SYMTestCaseID          SYSLIB-ECOM-CT-0730
       
   625 @SYMTestCaseDesc	    Tests for CRegistrar::DriveRemovedL,DriveReinstatedL functions
       
   626 @SYMTestPriority 	    High
       
   627 @SYMTestActions  	    The test executes by first making the test drive uninstall and
       
   628 						then testing for Install and Uninstall.
       
   629 @SYMTestExpectedResults The test must not fail.
       
   630 @SYMREQ                 REQ0000
       
   631 */
       
   632 void CRegistrarTest::DriveRemovedReinstatedTestL()
       
   633 	{
       
   634 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0730 "));
       
   635 	// We are checking with F Drive.
       
   636 	// The test executes by first removing and then reinstalling
       
   637 	const TTime modified(0); //Dummy parameter...
       
   638 	TBool update = EFalse;   //Dummy parameter...
       
   639 	TBool isDriveRegistered = EFalse;
       
   640 	TInt  driveIndex = KErrNotFound;
       
   641 	CRegistryData::CDriveData* driveData = NULL;
       
   642 
       
   643 	iDriveUnit = EDriveF;
       
   644 	TInt error = KErrNone;
       
   645 	TRAP(error, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
       
   646 	::LeaveIfErrNoMemory(error);
       
   647 	TInt err = KErrNone;
       
   648 	if(driveIndex != KErrNotFound)
       
   649 	{
       
   650 	TRAP(err, iRegistryData->IsRegisteredWithDate(
       
   651 													iDllUid,
       
   652 													modified,
       
   653 													update,
       
   654 
       
   655 													driveData));
       
   656 
       
   657 	::LeaveIfErrNoMemory(err);
       
   658 	}
       
   659 
       
   660 	isDriveRegistered = (driveIndex != KErrNotFound);
       
   661 
       
   662 	//Remove the drive from registry if registered
       
   663 	if(isDriveRegistered)
       
   664 		{
       
   665 		TRAP(err, iStateAccessor->DriveRemovedL( *iRegistrar, iDriveUnit));
       
   666 		::LeaveIfErrNoMemory(err);
       
   667 		test(err == KErrNone);
       
   668 
       
   669 		//Call CRegistryData::IsRegisteredWithDate again to check its removed now
       
   670 		driveIndex = KErrNotFound;
       
   671 		TRAP(err, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
       
   672 		//Drive should not be present
       
   673 		::LeaveIfErrNoMemory(err);
       
   674 		test(driveIndex == KErrNotFound);
       
   675 
       
   676 		}
       
   677 
       
   678 
       
   679 	// Install the drive in registry
       
   680 	TRAP(err, iStateAccessor->DriveReinstatedL(*iRegistrar, iDriveUnit));
       
   681 	::LeaveIfErrNoMemory(err);
       
   682 	test(err == KErrNone);
       
   683 
       
   684 	//Call CRegistryData::IsRegisteredWithDate to check its Reinstalled now
       
   685 	driveIndex = KErrNotFound;
       
   686 	TRAP(err, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
       
   687 	::LeaveIfErrNoMemory(err);
       
   688 	//Drive should be present now
       
   689 	test(driveIndex != KErrNotFound);
       
   690 	TRAP(err, iRegistryData->IsRegisteredWithDate(
       
   691 													iDllUid,
       
   692 													modified,
       
   693 													update,
       
   694 
       
   695 													driveData));
       
   696 	::LeaveIfErrNoMemory(err);
       
   697 	test(err == KErrNone);
       
   698 
       
   699 
       
   700 	//Remove the drive from registry if it was not registered before
       
   701 	if(!isDriveRegistered)
       
   702 		{
       
   703 		TRAP(err, iStateAccessor->DriveRemovedL( *iRegistrar, iDriveUnit));
       
   704 		::LeaveIfErrNoMemory(err);
       
   705 		test(err == KErrNone);
       
   706 
       
   707 		//Call CRegistryData::IsRegisteredWithDate again to check its removed now
       
   708 		driveIndex = KErrNotFound;
       
   709 		TRAP(err, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
       
   710 		//Drive should not be present
       
   711 		::LeaveIfErrNoMemory(err);
       
   712 		test(driveIndex == KErrNotFound);
       
   713 		}
       
   714 	}
       
   715 
       
   716 /**
       
   717 The test executes by parsing the Interface implementaion information
       
   718 from the given resource file.
       
   719 
       
   720 @SYMTestCaseID          SYSLIB-ECOM-CT-0731
       
   721 @SYMTestCaseDesc	    Tests for verification of Interface implementaion information
       
   722 @SYMTestPriority 	    High
       
   723 @SYMTestActions  	    Parse the resource information associated with an
       
   724 					    Interface Implementation Collection for entry into the registry
       
   725 					    information.Check for OOM error or parse error.
       
   726 @SYMTestExpectedResults The test must not fail.
       
   727 @SYMREQ                 REQ0000
       
   728 */
       
   729 void CRegistrarTest::ParseTestL()
       
   730 	{
       
   731 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0731 "));
       
   732 	TInt error=KErrNone;
       
   733 	CPluginBase* entryBase=NULL;
       
   734 	CRegistryData::CDllData* dllData=NULL;
       
   735 	CRegistryData::CInterfaceData* ifData =NULL;
       
   736 	CRegistryData::CDriveData* driveData = NULL;
       
   737 
       
   738 	//Testing a RSC based entry using EComExample5.dll and EComExample5.rsc
       
   739 	//(101F847B.RSS)
       
   740 	TEntry rscBasedEntry;
       
   741 	rscBasedEntry.iName=KNewResourceFileNameOnly;
       
   742 	error = TheFs.Modified(KNewResourceFileNameC, rscBasedEntry.iModified);
       
   743 	test(error==KErrNone);
       
   744 	TParse rscPath;
       
   745 	rscPath.Set(KNewResourceFileNameC,NULL,NULL);
       
   746 	TDriveUnit driveUnit(rscPath.Drive());
       
   747 	error=iRegistryData->FindDriveL(driveUnit,driveData);
       
   748 	test(error!=KErrNotFound);
       
   749 	entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
       
   750 	CleanupStack::PushL(entryBase);
       
   751 	dllData=CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
       
   752 
       
   753 	//Now testing the parseL function
       
   754 	TRAP(error, iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
       
   755 	::LeaveIfErrNoMemory(error);
       
   756 	test(error == KErrNone);
       
   757 	//Now checking the content of the DllData
       
   758 	test(dllData->iIfList->Count()==1);
       
   759 	ifData=(*(dllData->iIfList))[0];
       
   760 	test(ifData->iInterfaceUid.iUid==0x10009DC0);
       
   761 	test(ifData->iImplementations->Count()==1);
       
   762 
       
   763 	CleanupStack::PopAndDestroy(dllData);
       
   764 	CleanupStack::PopAndDestroy(entryBase);
       
   765 	entryBase=NULL;
       
   766 	dllData=NULL;
       
   767 	ifData=NULL;
       
   768 	}
       
   769 
       
   770 /**
       
   771 The test executes by parsing the Interface implementation information with type 2 entries
       
   772 from the given resource file.
       
   773 
       
   774 @SYMTestCaseID          SYSLIB-ECOM-UT-3563
       
   775 @SYMTestCaseDesc	    Tests for verification of Interface implementation information with type 2 entries
       
   776 @SYMTestPriority 	    High
       
   777 @SYMTestActions  	    Parse the resource information associated with an
       
   778 					    Interface Implementation Collection type 2 for entry into the registry
       
   779 					    information.Check for OOM error or parse error.
       
   780 @SYMTestExpectedResults CRegistrar::ParseL() function parses resource file without error.
       
   781 						Data is interpreted correctly.
       
   782 @SYMEC                  EC43
       
   783 */
       
   784 void CRegistrarTest::ParseType2TestL()
       
   785 	{
       
   786 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3563 "));
       
   787 	TInt error = KErrNone;
       
   788 	CPluginBase* entryBase = NULL;
       
   789 	CRegistryData::CDllData* dllData = NULL;
       
   790 	CRegistryData::CInterfaceData* ifData = NULL;
       
   791 	CRegistryData::CDriveData* driveData = NULL;
       
   792 	TUid interfaceUidExample14 = {0x10009E36};
       
   793 
       
   794 	//Tests an RSC based entry using EComExample14.dll and EComExample14.rsc
       
   795 	//(EcomExample14.RSS)
       
   796 	TEntry rscBasedEntry;
       
   797 	rscBasedEntry.iName = KType2ResourceFileNameOnly;
       
   798 	error = TheFs.Modified(KType2ResourceFileNameC, rscBasedEntry.iModified);
       
   799 	test(error == KErrNone);
       
   800 	TParse rscPath;
       
   801 	rscPath.Set(KType2ResourceFileNameC,NULL,NULL);
       
   802 	TDriveUnit driveUnit(rscPath.Drive());
       
   803 	error = iRegistryData->FindDriveL(driveUnit,driveData);
       
   804 	test(error != KErrNotFound);
       
   805 	entryBase = CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
       
   806 	CleanupStack::PushL(entryBase);
       
   807 	dllData = CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
       
   808 
       
   809 	//tests the parseL function
       
   810 	TRAP(error, iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
       
   811 	::LeaveIfErrNoMemory(error);
       
   812 	test(error == KErrNone);
       
   813 	//checks the content of the DllData
       
   814 	test(dllData->iIfList->Count() == 1);
       
   815 	ifData = (*(dllData->iIfList))[0];
       
   816 	test(ifData->iInterfaceUid == interfaceUidExample14);
       
   817 	CleanupStack::PopAndDestroy(dllData);
       
   818 	CleanupStack::PopAndDestroy(entryBase);
       
   819 	}
       
   820 
       
   821 /**
       
   822 The test executes by parsing the Interface implementation information with type 3 entries
       
   823 from the given resource file.
       
   824 
       
   825 @SYMTestCaseID          SYSLIB-ECOM-UT-3564
       
   826 @SYMTestCaseDesc	    Tests for verification of Interface implementation information with type 3 entries
       
   827 @SYMTestPriority 	    High
       
   828 @SYMTestActions  	    Parse the resource information associated with an
       
   829 					    Interface Implementation Collection type 3 for entry into the registry
       
   830 					    information.Check for OOM error or parse error.
       
   831 @SYMTestExpectedResults CRegistrar::ParseL() function parses resource file without error.
       
   832 						Data is interpreted correctly.
       
   833 @SYMEC                  EC43
       
   834 */
       
   835 void CRegistrarTest::ParseType3TestL()
       
   836 	{
       
   837 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3564 "));
       
   838 	TInt error = KErrNone;
       
   839 	CPluginBase* entryBase = NULL;
       
   840 	CRegistryData::CDllData* dllData = NULL;
       
   841 	CRegistryData::CInterfaceData* ifData = NULL;
       
   842 	CRegistryData::CDriveData* driveData = NULL;
       
   843 	CRegistryData::CImplementationData* implData = NULL;
       
   844 	CImplementationInformation* implInfo = NULL;
       
   845 
       
   846 	//Tests an RSC based entry using EComExample12.dll and EComExample12.rsc
       
   847 	//(EcomExample12.RSS)
       
   848 	TEntry rscBasedEntry;
       
   849 	rscBasedEntry.iName = KType3ResourceFileNameOnly;
       
   850 	error = TheFs.Modified(KType3ResourceFileNameC, rscBasedEntry.iModified);
       
   851 	test(error == KErrNone);
       
   852 	TParse rscPath;
       
   853 	rscPath.Set(KType3ResourceFileNameC,NULL,NULL);
       
   854 	TDriveUnit driveUnit(rscPath.Drive());
       
   855 	error = iRegistryData->FindDriveL(driveUnit,driveData);
       
   856 	test(error != KErrNotFound);
       
   857 	entryBase = CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
       
   858 	CleanupStack::PushL(entryBase);
       
   859 	dllData = CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
       
   860 
       
   861 	// Tests the parseL function
       
   862 	TRAP(error, iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
       
   863 	::LeaveIfErrNoMemory(error);
       
   864 	test(error == KErrNone);
       
   865 	// Checks the content of the DllData
       
   866 	test(dllData->iIfList->Count() == 1);
       
   867 	ifData = (*(dllData->iIfList))[0];
       
   868 	test(ifData->iInterfaceUid == interfaceUidExample12);
       
   869 	//Currently there are 3 implementations for this interface.
       
   870 	//But the implementation(UID=0x10009E3D) is ROM-only but is actually in RAM will not be created.
       
   871 	//So, actually number of implementations created for this interface is 2.
       
   872 	test(ifData->iImplementations->Count() == 2);
       
   873 	implData = (*(ifData->iImplementations))[0];
       
   874 	implInfo = implData->iImplInfo;
       
   875 
       
   876 	// Fetches the list of extended interfaces for the first implementation
       
   877 	RArray<TUid>* extendedInterfaceList = implInfo->GetExtendedInterfaceList();
       
   878 	test(extendedInterfaceList->Count()==3);
       
   879 	test((*extendedInterfaceList)[0] == extendedInterfaceUid1);
       
   880 	test((*extendedInterfaceList)[1] == extendedInterfaceUid2);
       
   881 	test((*extendedInterfaceList)[2] == extendedInterfaceUid3);
       
   882 	CleanupStack::PopAndDestroy(dllData);
       
   883 	CleanupStack::PopAndDestroy(entryBase);
       
   884 	}
       
   885 
       
   886 
       
   887 /** Wrapper function for testing ParseL function with type 3 entries
       
   888 and data in the resource file exceed maximum
       
   889 */
       
   890 void CRegistrarTest::ParseBadDataTestL(const TDesC& aRscFullName, const TDesC& aRscNameOnly)
       
   891 	{
       
   892 	TInt error = KErrNone;
       
   893 	CPluginBase* entryBase = NULL;
       
   894 	CRegistryData::CDllData* dllData = NULL;
       
   895 	CRegistryData::CDriveData* driveData = NULL;
       
   896 
       
   897 	TEntry rscBasedEntry;
       
   898 	rscBasedEntry.iName = aRscNameOnly;
       
   899 	error = TheFs.Modified(aRscFullName, rscBasedEntry.iModified);
       
   900 	test(error == KErrNone);
       
   901 	TParse rscPath;
       
   902 	rscPath.Set(aRscFullName,NULL,NULL);
       
   903 	TDriveUnit driveUnit(rscPath.Drive());
       
   904 	error = iRegistryData->FindDriveL(driveUnit,driveData);
       
   905 	test(error != KErrNotFound);
       
   906 	entryBase = CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), ETrue);
       
   907 	CleanupStack::PushL(entryBase);
       
   908 	dllData = CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
       
   909 
       
   910 	//Tests the parseL function
       
   911 	TRAP(error, iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
       
   912 	test(error == KErrNotSupported);
       
   913 
       
   914 	CleanupStack::PopAndDestroy(dllData);
       
   915 	CleanupStack::PopAndDestroy(entryBase);
       
   916 	}
       
   917 
       
   918 
       
   919 /**
       
   920 @SYMTestCaseID          SYSLIB-ECOM-UT-3565
       
   921 @SYMTestCaseDesc	    Tests for verification of Interface implementation information with type 3 entries
       
   922 						and data in the resource file exceed maximum.
       
   923 @SYMTestPriority 	    High
       
   924 @SYMTestActions  	    Parse the resource information associated with an
       
   925 					    Interface Implementation Collection type 3 for entry into the registry
       
   926 					    information.
       
   927 @SYMTestExpectedResults CRegistrar::ParseL() function parses resource file with KErrNotSupported leave occurs.
       
   928 @SYMEC                  EC43
       
   929 @SYMDEF                 DEF111196
       
   930 */
       
   931 void CRegistrarTest::ParseType3BadDataTestL()
       
   932 	{
       
   933 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3565 "));
       
   934 	// Tests for number of strings of default data exceeds maximum
       
   935 	// Uses EComExampleBadData.dll and EComExampleBadData.rsc (EcomExampleBadData.RSS)
       
   936 	ParseBadDataTestL(KType3BadDataResourceFileNameC,KType3BadDataResourceFileNameOnly);
       
   937 
       
   938 	// Tests for number of interfaces exceeds maximum
       
   939 	// Uses EComExampleBadData1.dll and EComExampleBadData1.rsc (EcomExampleBadData1.RSS)
       
   940 	ParseBadDataTestL(KType3BadData1ResourceFileNameC,KType3BadData1ResourceFileNameOnly);
       
   941 
       
   942 	// Tests for number of implementation in one interfaces exceeds maximum
       
   943 	// Uses EComExampleBadData2.dll and EComExampleBadData2.rsc (EcomExampleBadData2.RSS)
       
   944 	ParseBadDataTestL(KType3BadData2ResourceFileNameC,KType3BadData2ResourceFileNameOnly);
       
   945 	}
       
   946 
       
   947 /**
       
   948 @SYMTestCaseID		SYSLIB-ECOM-CT-0089
       
   949 @SYMTestCaseDesc 	Check that the ParseL for spi data works correctly.
       
   950 @SYMTestPriority 	High
       
   951 @SYMTestActions  	Ensure ecomtest.spi can be parsed successfully
       
   952 					and no leave occurs.
       
   953 @SYMTestExpectedResults The test must not fail.
       
   954 @SYMREQ REQ3655
       
   955 */
       
   956 void CRegistrarTest::ParseSpiTestL()
       
   957 	{
       
   958 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0089 "));
       
   959 	TEntry spiEntry;
       
   960 	TParse spiPath;
       
   961 	if (TheFs.Entry(KEComSpiTestFilePathAndName, spiEntry) != KErrNone)
       
   962 		return;
       
   963 
       
   964 	spiPath.Set(KEComSpiTestFilePathAndName,NULL,NULL);
       
   965 	RResourceArchive resourceArchive;
       
   966 	resourceArchive.OpenL(TheFs, KEComSpiTestFilePathAndName);
       
   967 	CleanupClosePushL(resourceArchive);
       
   968 
       
   969 	// Checks SPI file type
       
   970 	TUid type = resourceArchive.Type();
       
   971 	test(type == KEcomSpiFileTypeUid);
       
   972 
       
   973 	// there is only 1 resource file
       
   974 	CPluginBase* entryBase=NULL;
       
   975 	CRegistryData::CDllData* dllData=NULL;
       
   976 	CRegistryData::CDriveData* driveData = NULL;
       
   977 
       
   978 	TDriveUnit driveUnit(spiPath.Drive());
       
   979 	TInt error=iRegistryData->FindDriveL(driveUnit,driveData);
       
   980 	test(error!=KErrNotFound);
       
   981 
       
   982 	while(!resourceArchive.End())
       
   983 		{
       
   984 		entryBase=CSpiPlugin::NewL(resourceArchive);
       
   985 		CleanupStack::PushL(entryBase);
       
   986 		dllData=CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
       
   987 		TRAPD(err,iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
       
   988 
       
   989 		::LeaveIfErrNoMemory(err);
       
   990 		test(err == KErrNone);
       
   991 		CleanupStack::Pop(dllData);
       
   992 		CleanupStack::PopAndDestroy(entryBase);
       
   993 		entryBase=NULL;
       
   994 		}
       
   995 
       
   996 	CleanupStack::PopAndDestroy(&resourceArchive);
       
   997 
       
   998 	// Currently only one interface definition in the resource file
       
   999 	const TInt ifCount = dllData->iIfList->Count();
       
  1000 	test(ifCount == 1);
       
  1001 
       
  1002 	// Currently only one implemention for the above interface in the resource file
       
  1003 	CRegistryData::CInterfaceData* ifData = (*(dllData->iIfList))[0];
       
  1004 	const TInt impCount = ifData->iImplementations->Count();
       
  1005 	test(impCount == 1);
       
  1006 	// Interface UID verification
       
  1007 	test(ifData->iInterfaceUid == iInterfaceUid);
       
  1008 
       
  1009 	delete dllData;
       
  1010 	}
       
  1011 
       
  1012 /**
       
  1013 @SYMTestCaseID		SYSLIB-ECOM-UT-3566
       
  1014 @SYMTestCaseDesc 	Check that the ParseL for spi data with IIC Type 3 entry works correctly.
       
  1015 @SYMTestPriority 	High
       
  1016 @SYMTestActions  	Ensure ecomtesttype3.spi can be parsed successfully
       
  1017 					and no leave occurs.
       
  1018 @SYMTestExpectedResults CRegistrar::ParseL() function parses SPI file without error.
       
  1019 						Data is interpreted correctly.
       
  1020 @SYMEC                  EC43
       
  1021 */
       
  1022 void CRegistrarTest::ParseSpiType3TestL()
       
  1023 	{
       
  1024 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3566 "));
       
  1025 	TEntry spiEntry;
       
  1026 	TParse spiPath;
       
  1027 	//"Z:\\Test\\Data\\ecomtesttype3.spi" is used for testing. The only resource file included
       
  1028 	//in the spi file is EComExample12.RSC
       
  1029 	if (TheFs.Entry(KEComSpiTestFileType3PathAndName, spiEntry) != KErrNone)
       
  1030 		return;
       
  1031 
       
  1032 	spiPath.Set(KEComSpiTestFileType3PathAndName,NULL,NULL);
       
  1033 	RResourceArchive resourceArchive;
       
  1034 	resourceArchive.OpenL(TheFs, KEComSpiTestFileType3PathAndName);
       
  1035 	CleanupClosePushL(resourceArchive);
       
  1036 
       
  1037 	// Checks SPI file type
       
  1038 	TUid type = resourceArchive.Type();
       
  1039 	test(type == KEcomSpiFileTypeUid);
       
  1040 
       
  1041 	CRegistryData::CDriveData* driveData = NULL;
       
  1042 
       
  1043 	TDriveUnit driveUnit(spiPath.Drive());
       
  1044 	TInt error=iRegistryData->FindDriveL(driveUnit,driveData);
       
  1045 	test(error!=KErrNotFound);
       
  1046 	// there is only 1 resource file in the spi file
       
  1047 	while(!resourceArchive.End())
       
  1048 		{
       
  1049 		CPluginBase* entryBase = NULL;
       
  1050 		entryBase=CSpiPlugin::NewL(resourceArchive);
       
  1051 		CleanupStack::PushL(entryBase);
       
  1052 		CRegistryData::CDllData* dllData = NULL;
       
  1053 		dllData = CRegistryData::CDllData::NewLC(*(entryBase->iDllName),entryBase->iDllModifiedTime,entryBase->iDllSecondUid,entryBase->iDllThirdUid,driveData);
       
  1054 		TRAPD(err,iStateAccessor->ParseL(*iRegistrar,entryBase,*dllData));
       
  1055 		::LeaveIfErrNoMemory(err);
       
  1056 		test(err == KErrNone);
       
  1057 		// Currently only one interface definition in the resource file
       
  1058 		// Checks the content of the DllData
       
  1059 		test(dllData->iIfList->Count() == 1);
       
  1060 		CRegistryData::CInterfaceData* ifData = NULL;
       
  1061 		ifData = (*(dllData->iIfList))[0];
       
  1062 		//There are 3 implementations for the above interface in the spi file.
       
  1063 		//Since ecomtesttype3.spi is under Z: drive which is ROM based,
       
  1064 		//the implementation (UID=0x10009E3D) will be created during Parsing.
       
  1065 		//So, the total implementations is 3.
       
  1066 		test(ifData->iImplementations->Count() == 3);
       
  1067 		// Interface UID verification
       
  1068 		test(ifData->iInterfaceUid == interfaceUidExample12);
       
  1069 		// Fetches the list of extended interfaces for the second implementation
       
  1070 		//Currently we have no extended Interface for the second implementation
       
  1071 		CRegistryData::CImplementationData* implData = NULL;
       
  1072 		implData = (*(ifData->iImplementations))[1];
       
  1073 		CImplementationInformation* implInfo = NULL;
       
  1074 		implInfo = implData->iImplInfo;
       
  1075 
       
  1076 		RArray<TUid>* extendedInterfaceList = implInfo->GetExtendedInterfaceList();
       
  1077 		test(extendedInterfaceList->Count() == 0);
       
  1078 		CleanupStack::PopAndDestroy(dllData);
       
  1079 		CleanupStack::PopAndDestroy(entryBase);
       
  1080 		}
       
  1081 	CleanupStack::PopAndDestroy(&resourceArchive);
       
  1082 	}
       
  1083 
       
  1084 /**
       
  1085 The test executes by registering the Interface implementaion information
       
  1086 for an plugin entry.
       
  1087 
       
  1088 @SYMTestCaseID          SYSLIB-ECOM-CT-0732
       
  1089 @SYMTestCaseDesc	    Tests for CRegistrar::ParseRegistrationDataL() function
       
  1090 @SYMTestPriority 	    High
       
  1091 @SYMTestActions  	    Checks for directory entry for an Interface Implementation
       
  1092 						Collection entry requires registration.Parses the associated resource file information where necessary
       
  1093 						Checks for OOM or parsing error.
       
  1094 @SYMTestExpectedResults The test must not fail.
       
  1095 @SYMREQ                 REQ0000
       
  1096 */
       
  1097 void CRegistrarTest::ParseRegistrationDataTestL()
       
  1098 	{
       
  1099 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0732 "));
       
  1100 	TInt error=KErrNone;
       
  1101 	TTime modified(0);							//Dummy parameter...
       
  1102 	TBool update			= EFalse;			//Dummy parameter...
       
  1103 	TInt  driveIndex		= KErrNotFound;
       
  1104 	CRegistryData::CImplementationData *implementationData = NULL;
       
  1105 	CPluginBase* entryBase=NULL;
       
  1106 	TUid implementationUid;
       
  1107 	CRegistryData::CDriveData* driveData = NULL;
       
  1108 
       
  1109 	// Calling  RegistryData->IsRegisteredWithDate to get the drive index,
       
  1110 	// that will be used in the ParseRegistrationDataL call
       
  1111 	// The drive should have been installed before registering any plugin
       
  1112 	TRAP(error, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
       
  1113 	::LeaveIfErrNoMemory(error);
       
  1114 	test(driveIndex != KErrNotFound);
       
  1115 	TRAP(error, iRegistryData->IsRegisteredWithDate(
       
  1116 																		NewDllUid,
       
  1117 																		modified,
       
  1118 																		update,
       
  1119 
       
  1120 																		driveData));
       
  1121 	::LeaveIfErrNoMemory(error);
       
  1122 	test(error == KErrNone);
       
  1123 
       
  1124 	//Creating the entry
       
  1125 	TEntry rscBasedEntry;
       
  1126 	rscBasedEntry.iName=KNewResourceFileNameOnly;
       
  1127 	error = TheFs.Modified(KNewResourceFileNameC, rscBasedEntry.iModified);
       
  1128 	test(error==KErrNone);
       
  1129 	TParse rscPath;
       
  1130 	rscPath.Set(KNewResourceFileNameC,NULL,NULL);
       
  1131 	entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), EFalse);
       
  1132 	CleanupStack::PushL(entryBase);
       
  1133 
       
  1134 	//Trying to parse the registration data
       
  1135 	update=ETrue;
       
  1136 	TRAP(error,iStateAccessor->ParseRegistrationDataL(*iRegistrar,entryBase,iDriveUnit,update,driveIndex, driveData));
       
  1137 	::LeaveIfErrNoMemory(error);
       
  1138 	test(error == KErrNone);
       
  1139 	CleanupStack::PopAndDestroy(entryBase);
       
  1140 
       
  1141 	// Calling DiscoveriesComplete for building the registry indexes
       
  1142 	// as registration of new plugin has happened.
       
  1143 	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
       
  1144 
       
  1145 	//Now checking whether the implementation is already registered in the CRegistryData
       
  1146 	//The only implementation Uid in EComExample5. see 101F847B.RSS
       
  1147 	implementationUid=TUid::Uid(0x101F847C);
       
  1148 	TUid dummyUid;
       
  1149 	dummyUid.iUid = 0;
       
  1150 	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
       
  1151 	test(error == KErrNone);
       
  1152 	test(implementationData != NULL);
       
  1153 
       
  1154 	}
       
  1155 
       
  1156 /**
       
  1157 The test executes by registering the Interface implementation information
       
  1158 for an plugin with type 3 entry.
       
  1159 
       
  1160 @SYMTestCaseID          SYSLIB-ECOM-UT-3567
       
  1161 @SYMTestCaseDesc	    Tests for CRegistrar::ParseRegistrationDataL() function
       
  1162 @SYMTestPriority 	    High
       
  1163 @SYMTestActions  	    Checks for directory entry for an Interface Implementation
       
  1164 						Collection with Type 3 entry requires registration.Parses the associated resource file information where necessary
       
  1165 @SYMTestExpectedResults CRegistrar::ParseRegistrationDataL() function parses resource file and registers
       
  1166 						implementations correctly.
       
  1167 @SYMEC                  EC43
       
  1168 */
       
  1169 void CRegistrarTest::ParseRegistrationDataType3TestL()
       
  1170 	{
       
  1171 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3567 "));
       
  1172 	TInt error=KErrNone;
       
  1173 	TTime modified(0);							//Dummy parameter...
       
  1174 	TBool update			= EFalse;			//Dummy parameter...
       
  1175 	TInt  driveIndex		= KErrNotFound;
       
  1176 	CRegistryData::CImplementationData *implementationData = NULL;
       
  1177 	CPluginBase* entryBase = NULL;
       
  1178 	TUid implementationUid;
       
  1179 	CRegistryData::CDriveData* driveData = NULL;
       
  1180 
       
  1181 	// Calls iRegistryData->FindDriveL to get the drive index,
       
  1182 	// that will be used in the ParseRegistrationDataL call.
       
  1183 	// The drive should have been installed before registering any plugin
       
  1184 	TRAP(error, driveIndex = iRegistryData->FindDriveL(iDriveUnit, driveData));
       
  1185 	::LeaveIfErrNoMemory(error);
       
  1186 	test(driveIndex != KErrNotFound);
       
  1187 	// Calls iRegistryData->IsRegisteredWithDate to determine if the entry in the registry needs an update.
       
  1188 	iRegistryData->IsRegisteredWithDate(Type3DllUid, modified, update, driveData);
       
  1189 
       
  1190 	//Creates the entry
       
  1191 	TEntry rscBasedEntry;
       
  1192 	rscBasedEntry.iName = KType3ResourceFileNameOnly;
       
  1193 	error = TheFs.Modified(KType3ResourceFileNameC, rscBasedEntry.iModified);
       
  1194 	test(error == KErrNone);
       
  1195 	TParse rscPath;
       
  1196 	rscPath.Set(KType3ResourceFileNameC,NULL,NULL);
       
  1197 	entryBase = CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), EFalse);
       
  1198 	CleanupStack::PushL(entryBase);
       
  1199 
       
  1200 	//Try to parse the registration data
       
  1201 	TRAP(error,iStateAccessor->ParseRegistrationDataL(*iRegistrar,entryBase,iDriveUnit,update,driveIndex, driveData));
       
  1202 	::LeaveIfErrNoMemory(error);
       
  1203 	test(error == KErrNone);
       
  1204 	CleanupStack::PopAndDestroy(entryBase);
       
  1205 
       
  1206 	// Calls DiscoveriesComplete for building the registry indexes
       
  1207 	// as registration of new plugin has happened.
       
  1208 	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
       
  1209 
       
  1210 	// Checks whether the implementations are already registered in the CRegistryData
       
  1211 	//The implementation Uids in EComExample12 are 0x10009E39, 0x10009E3C and 0x10009E3D
       
  1212 	// Checks implementation 0x10009E39
       
  1213 	implementationUid = TUid::Uid(0x10009E39);
       
  1214 	TUid dummyUid;
       
  1215 	dummyUid.iUid = 0;
       
  1216 	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
       
  1217 	test(error == KErrNone);
       
  1218 	test(implementationData != NULL);
       
  1219 	// Checks implementation 0x10009E3C
       
  1220 	implementationUid = TUid::Uid(0x10009E3C);
       
  1221 	dummyUid.iUid = 0;
       
  1222 	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
       
  1223 	test(error == KErrNone);
       
  1224 	test(implementationData != NULL);
       
  1225 	// Checks implementation 0x10009E3D
       
  1226 	// This implementation is said it's ROM-only but is actually in RAM.
       
  1227 	// So, this implementation will not be created.
       
  1228 	implementationUid = TUid::Uid(0x10009E3D);
       
  1229 	dummyUid.iUid = 0;
       
  1230 	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
       
  1231 	test(error == KErrNotFound);
       
  1232 	test(implementationData == NULL);
       
  1233 	}
       
  1234 
       
  1235 /**
       
  1236 @SYMTestCaseID		SYSLIB-ECOM-CT-0090
       
  1237 @SYMTestCaseDesc 	Check that the ParseL for spi data works correctly.
       
  1238 @SYMTestPriority 	High
       
  1239 @SYMTestActions  	Ensure ecomtest.spi can be parsed successfully
       
  1240 					and no leave occurred.
       
  1241 @SYMTestExpectedResults The test must not fail.
       
  1242 @SYMREQ REQ3655
       
  1243 */
       
  1244 void CRegistrarTest::ParseSpiRegistrationDataTestL()
       
  1245 	{
       
  1246 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0090 "));
       
  1247 	TDriveUnit driveUnit(EDriveZ);
       
  1248 	TEntry spiEntry;
       
  1249 	test(TheFs.Entry(KEComSpiTestFilePathAndName, spiEntry) == KErrNone);
       
  1250 	TParse spiPath;
       
  1251 	spiPath.Set(KEComSpiTestFilePathAndName, NULL, NULL);
       
  1252 
       
  1253 	RResourceArchive resourceArchive;
       
  1254 	resourceArchive.OpenL(TheFs, KEComSpiTestFilePathAndName);
       
  1255 	CleanupClosePushL(resourceArchive);
       
  1256 
       
  1257 	// Checks SPI file type
       
  1258 	TUid type = resourceArchive.Type();
       
  1259 	test(type == KEcomSpiFileTypeUid);
       
  1260 
       
  1261 	CPluginBase* entryBase=NULL;
       
  1262 	// there is only 1 resource file
       
  1263 	while(!resourceArchive.End())
       
  1264 		{
       
  1265 		const TTime modified(0);					//Dummy parameter...
       
  1266 		TBool update			= EFalse;			//Dummy parameter...
       
  1267 		TInt  driveIndex		= KErrNotFound;
       
  1268 		CRegistryData::CDriveData* driveData = NULL;
       
  1269 
       
  1270 		// Calls RegistryData->IsRegisteredWithDate to get the drive index,
       
  1271 		// that will be used in the ParseRegistrationDataL call
       
  1272 		// The drive should have been installed before registering any plugin
       
  1273 		TRAPD(error, driveIndex = iRegistryData->FindDriveL(driveUnit, driveData));
       
  1274 		::LeaveIfErrNoMemory(error);
       
  1275 		test(driveIndex != KErrNotFound);
       
  1276 		TRAPD(err, (void)iRegistryData->IsRegisteredWithDate(
       
  1277 
       
  1278 																	iDllUid,
       
  1279 																	modified,
       
  1280 																	update,
       
  1281 
       
  1282 																	driveData));
       
  1283 		::LeaveIfErrNoMemory(err);
       
  1284 		test(err == KErrNone);
       
  1285 
       
  1286 
       
  1287 		entryBase=CSpiPlugin::NewL(resourceArchive);
       
  1288 		CleanupStack::PushL(entryBase);
       
  1289 
       
  1290 		TRAP(err, iStateAccessor->ParseRegistrationDataL(*iRegistrar,
       
  1291 														 entryBase,
       
  1292 														 driveUnit,
       
  1293 														 update,
       
  1294 														 driveIndex,
       
  1295 														 driveData));
       
  1296 		::LeaveIfErrNoMemory(err);
       
  1297 		test(err == KErrNone);
       
  1298 		CleanupStack::PopAndDestroy(entryBase);
       
  1299 		entryBase = NULL;
       
  1300 		}
       
  1301 
       
  1302 	CleanupStack::PopAndDestroy(&resourceArchive);
       
  1303 
       
  1304 	// Calls DiscoveriesComplete for building the registry indexes
       
  1305 	// as registration of new plugin has happened.
       
  1306 	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
       
  1307 
       
  1308 	CRegistryData::CImplementationData *implementationData = NULL;
       
  1309 	TUid dummyUid;
       
  1310 	dummyUid.iUid = 0;
       
  1311 	TInt err = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, iImplementationUid, dummyUid, implementationData);
       
  1312 	test(err == KErrNone);
       
  1313 	test(implementationData != NULL);
       
  1314 	}
       
  1315 
       
  1316 /**
       
  1317 @SYMTestCaseID		SYSLIB-ECOM-UT-3568
       
  1318 @SYMTestCaseDesc 	Check that the ParseL for spi data works correctly.
       
  1319 @SYMTestPriority 	High
       
  1320 @SYMTestActions  	Ensure ecomtesttype3.spi can be parsed successfully
       
  1321 					and no leave occurs.
       
  1322 @SYMTestExpectedResults CRegistrar::ParseRegistrationDataL() function parses SPI file and registers
       
  1323 						implementations correctly.
       
  1324 @SYMEC                  EC43
       
  1325 */
       
  1326 void CRegistrarTest::ParseSpiRegistrationDataType3TestL()
       
  1327 	{
       
  1328 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3568 "));
       
  1329 	TDriveUnit driveUnit(EDriveZ);
       
  1330 	TEntry spiEntry;
       
  1331 	//"Z:\\Test\\Data\\ecomtesttype3.spi" is used for testing. The only resource file included
       
  1332 	//in the spi file is EComExample12.RSC
       
  1333 	test(TheFs.Entry(KEComSpiTestFileType3PathAndName, spiEntry) == KErrNone);
       
  1334 	TParse spiPath;
       
  1335 	spiPath.Set(KEComSpiTestFileType3PathAndName, NULL, NULL);
       
  1336 
       
  1337 	RResourceArchive resourceArchive;
       
  1338 	resourceArchive.OpenL(TheFs, KEComSpiTestFileType3PathAndName);
       
  1339 	CleanupClosePushL(resourceArchive);
       
  1340 
       
  1341 	// Checks SPI file type
       
  1342 	TUid type = resourceArchive.Type();
       
  1343 	test(type == KEcomSpiFileTypeUid);
       
  1344 
       
  1345 	CPluginBase* entryBase = NULL;
       
  1346 	// there is only 1 resource file in the spi file
       
  1347 	while(!resourceArchive.End())
       
  1348 		{
       
  1349 		const TTime modified(0);					//Dummy parameter...
       
  1350 		TBool update			= EFalse;			//Dummy parameter...
       
  1351 		TInt  driveIndex		= KErrNotFound;
       
  1352 		CRegistryData::CDriveData* driveData = NULL;
       
  1353 
       
  1354 		// Calls RegistryData->FindDriveL to get the drive index,
       
  1355 		// that will be used in the ParseRegistrationDataL call.
       
  1356 		// The drive should have been installed before registering any plugin
       
  1357 		TRAPD(error, driveIndex = iRegistryData->FindDriveL(driveUnit, driveData));
       
  1358 		::LeaveIfErrNoMemory(error);
       
  1359 		test(driveIndex != KErrNotFound);
       
  1360 		iRegistryData->IsRegisteredWithDate(Type3DllUid,modified,update,driveData);
       
  1361 
       
  1362 		entryBase=CSpiPlugin::NewL(resourceArchive);
       
  1363 		CleanupStack::PushL(entryBase);
       
  1364 
       
  1365 		TRAPD(err, iStateAccessor->ParseRegistrationDataL(*iRegistrar,
       
  1366 														 entryBase,
       
  1367 														 driveUnit,
       
  1368 														 update,
       
  1369 														 driveIndex,
       
  1370 														 driveData));
       
  1371 		::LeaveIfErrNoMemory(err);
       
  1372 		test(err == KErrNone);
       
  1373 		CleanupStack::PopAndDestroy(entryBase);
       
  1374 		entryBase = NULL;
       
  1375 		}
       
  1376 
       
  1377 	CleanupStack::PopAndDestroy(&resourceArchive);
       
  1378 
       
  1379 	// Calls DiscoveriesComplete for building the registry indexes
       
  1380 	// as registration of new plugin has happened.
       
  1381 	iStateAccessor->DiscoveriesComplete(*iRegistrar, EFalse);
       
  1382 
       
  1383 	CRegistryData::CImplementationData *implementationData=NULL;
       
  1384 	// Checks whether the implementations are already registered in the CRegistryData
       
  1385 	// The implementation Uids in EComExample12 are 0x10009E39, 0x10009E3C and 0x10009E3D
       
  1386 	// Checks implementation 0x10009E39
       
  1387 	TUid implementationUid = TUid::Uid(0x10009E39);
       
  1388 	TUid dummyUid;
       
  1389 	dummyUid.iUid = 0;
       
  1390 	TInt error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
       
  1391 	test(error == KErrNone);
       
  1392 	test(implementationData != NULL);
       
  1393 	// Checks implementation 0x10009E3C
       
  1394 	implementationUid = TUid::Uid(0x10009E3C);
       
  1395 	dummyUid.iUid = 0;
       
  1396 	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
       
  1397 	test(error == KErrNone);
       
  1398 	test(implementationData != NULL);
       
  1399 	// Checks implementation 0x10009E3D
       
  1400 	// Since ecomtesttype3.spi is under Z: drive which is ROM based,
       
  1401 	// the implementation (UID=0x10009E3D) will be created during Parsing.
       
  1402 	implementationUid = TUid::Uid(0x10009E3D);
       
  1403 	dummyUid.iUid = 0;
       
  1404 	error = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, implementationUid, dummyUid, implementationData);
       
  1405 	test(error == KErrNone);
       
  1406 	test(implementationData != NULL);
       
  1407 	}
       
  1408 
       
  1409 /**
       
  1410 @SYMTestCaseID		SYSLIB-ECOM-CT-0184
       
  1411 @SYMTestCaseDesc 	Check that SSA related states transition as expected when registration is staged
       
  1412 @SYMTestPriority 	High
       
  1413 @SYMTestActions  	Use CRegistrar::ProcessSSAEventL to start registration in stages i.e. rom only
       
  1414 then non rom only. Check that the
       
  1415 CRegistrar state is transitioning correctly at every step.
       
  1416 @SYMTestExpectedResults The test must not fail.
       
  1417 @SYMPREQ PREQ967
       
  1418 */
       
  1419 void CRegistrarTest::StateTransitionTestL()
       
  1420 	{
       
  1421 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0184 "));
       
  1422 	//After construction check that initial state is EReg_StartupInProgess
       
  1423 	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupInProgess);
       
  1424 
       
  1425 	//Call ProcessSSAEventL with EStartupStateUndefined. Check that state
       
  1426 	// is not changed. i.e. still EReg_StartupInProgess
       
  1427 	iRegistrar->ProcessSSAEventL(EStartupStateUndefined);
       
  1428 	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupInProgess);
       
  1429 
       
  1430 	//Call ProcessSSAEventL with EStartupStateCriticalStatic. Check that state
       
  1431 	// is not changed. i.e. still EReg_StartupInProgess
       
  1432 	iRegistrar->ProcessSSAEventL(EStartupStateCriticalStatic);
       
  1433 	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupInProgess);
       
  1434 
       
  1435 	//Call ProcessSSAEventL with EStartupStateCriticalDynamic. Check that state
       
  1436 	// is not changed. i.e. still EReg_StartupInProgess
       
  1437 	iRegistrar->ProcessSSAEventL(EStartupStateCriticalDynamic);
       
  1438 	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupInProgess);
       
  1439 
       
  1440 	//Call ProcessSSAEventL with EStartupStateNonCritical. Check that state
       
  1441 	//is changed to EReg_StartupComplete
       
  1442 	iRegistrar->ProcessSSAEventL(EStartupStateNonCritical);
       
  1443 	test(iStateAccessor->State(*iRegistrar) == CRegistrar::EReg_StartupComplete);
       
  1444 	}
       
  1445 
       
  1446 /**
       
  1447 @SYMTestCaseID          SYSLIB-ECOM-CT-0733
       
  1448 @SYMTestCaseDesc	    Tests the creation and deletion of CRegistrar
       
  1449 @SYMTestPriority 	    High
       
  1450 @SYMTestActions  	    Create and delete CRegistrar object,checks for open handles
       
  1451 @SYMTestExpectedResults The test must not fail.
       
  1452 @SYMREQ                 REQ0000
       
  1453 */
       
  1454 LOCAL_C void CreateDeleteTestL()
       
  1455 	{
       
  1456 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0733 CreateDeleteTestL "));
       
  1457 	// Set up for heap leak checking
       
  1458 	__UHEAP_MARK;
       
  1459 	//Check Thread handles leak
       
  1460 	TInt startProcessHandleCount = 0;
       
  1461 	TInt startThreadHandleCount = 0;
       
  1462 	TInt endProcessHandleCount = 0;
       
  1463 	TInt endThreadHandleCount = 0;
       
  1464 
       
  1465 	RThread rThread;
       
  1466 	rThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  1467 
       
  1468 	//CREATE DELETE TEST START//
       
  1469 
       
  1470 	CRegistrarTest* registrarTest = CRegistrarTest::NewL(EFalse);
       
  1471 
       
  1472 	test(registrarTest != NULL);
       
  1473 
       
  1474 	delete registrarTest;
       
  1475 
       
  1476 	//CREATE DELETE TEST END//
       
  1477 
       
  1478 	// Check for open handles
       
  1479 	rThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  1480 	test(startThreadHandleCount == endThreadHandleCount);
       
  1481 
       
  1482 	//Test ends
       
  1483 	__UHEAP_MARKEND;
       
  1484 	}
       
  1485 /*
       
  1486 LOCAL_C void OOMCreateDeleteTest()
       
  1487 	{
       
  1488 	//
       
  1489 	// Out of memory test
       
  1490 	// ------------------------------------------------------------------
       
  1491 	//
       
  1492 	test.Next(_L("OOM CreateDeleteTest"));
       
  1493 	TInt err;
       
  1494 	TInt failAt = 0;
       
  1495 	__UNUSED_VAR(failAt);
       
  1496 
       
  1497 	CRegistrarTest* registrarTest = NULL;
       
  1498 
       
  1499 	do
       
  1500 		{
       
  1501 		__UHEAP_MARK;
       
  1502   		// find out the number of open handles
       
  1503 		TInt startProcessHandleCount;
       
  1504 		TInt startThreadHandleCount;
       
  1505 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  1506 
       
  1507 		// Setting Heap failure for OOM test
       
  1508 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++failAt);
       
  1509 
       
  1510 		TRAP(err, registrarTest = CRegistrarTest::NewL(EFalse));
       
  1511 
       
  1512 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
  1513 
       
  1514 		delete registrarTest;
       
  1515 		registrarTest = NULL;
       
  1516 
       
  1517 		// check that no handles have leaked
       
  1518 		TInt endProcessHandleCount;
       
  1519 		TInt endThreadHandleCount;
       
  1520 		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  1521 
       
  1522 		test(startProcessHandleCount == endProcessHandleCount);
       
  1523 		test(startThreadHandleCount  == endThreadHandleCount);
       
  1524 
       
  1525 		__UHEAP_MARKEND;
       
  1526 		}
       
  1527 	while (err == KErrNoMemory);
       
  1528 
       
  1529 	test.Printf(_L("- Succeeded at heap failure rate of %i\n"), failAt);
       
  1530 	test(err == KErrNone);
       
  1531 	}
       
  1532 */
       
  1533 // Type definition for pointer to member function.
       
  1534 // Used in calling the CDiscovererTest member function for testing.
       
  1535 typedef void (CRegistrarTest::*ClassFuncPtrL) (void);
       
  1536 
       
  1537 /**
       
  1538 @SYMTestCaseID          SYSLIB-ECOM-CT-0735
       
  1539 @SYMTestCaseDesc	    Wrapper function to call all test functions
       
  1540 @SYMTestPriority 	    High
       
  1541 @SYMTestActions  	    Calls up test functions of CRegistrarTest.
       
  1542 @SYMTestExpectedResults The test must not fail.
       
  1543 @SYMREQ                 REQ0000
       
  1544 */
       
  1545 /**
       
  1546 Wrapper function to call all test functions
       
  1547 
       
  1548 @param		testFuncL pointer to test function
       
  1549 @param		aTestDesc test function name
       
  1550 */
       
  1551 LOCAL_C void DoBasicTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc, TBool aIsFullDiscovery)
       
  1552 	{
       
  1553 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0735 "));
       
  1554 	test.Next(aTestDesc);
       
  1555 
       
  1556 	__UHEAP_MARK;
       
  1557   	// find out the number of open handles
       
  1558 	TInt startProcessHandleCount;
       
  1559 	TInt startThreadHandleCount;
       
  1560 	RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  1561 
       
  1562 	CRegistrarTest* registrarTest = CRegistrarTest::NewL(aIsFullDiscovery);
       
  1563 	CleanupStack::PushL(registrarTest);
       
  1564 
       
  1565 	(registrarTest->*testFuncL)();
       
  1566 
       
  1567 	CleanupStack::PopAndDestroy(registrarTest);
       
  1568 
       
  1569 	// check that no handles have leaked
       
  1570 	TInt endProcessHandleCount;
       
  1571 	TInt endThreadHandleCount;
       
  1572 	RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  1573 
       
  1574 	test(startProcessHandleCount == endProcessHandleCount);
       
  1575 	test(startThreadHandleCount  == endThreadHandleCount);
       
  1576 
       
  1577 	__UHEAP_MARKEND;
       
  1578 	}
       
  1579 
       
  1580 /**
       
  1581 @SYMTestCaseID          SYSLIB-ECOM-CT-0736
       
  1582 @SYMTestCaseDesc	    Function to call all test functions
       
  1583 @SYMTestPriority 	    High
       
  1584 @SYMTestActions  	    Calls up all OOM test functions of CRegistrarTest.
       
  1585 @SYMTestExpectedResults The test must not fail.
       
  1586 @SYMREQ                 REQ0000
       
  1587 */
       
  1588 /**
       
  1589 Utility function to continually invoke a test function and cause memory allocation failures
       
  1590 
       
  1591 @param		testFuncL pointer to OOM test function
       
  1592 @param	 	tryCount specifies what value to start memory allocation failures at
       
  1593 @param		increment how much to increase the point at which memory allocation will fail on each test attempt
       
  1594 @param		stopCount the value of memory allocation failure to stop testing at
       
  1595 */
       
  1596 TInt RunTestUnderOOMCondition(ClassFuncPtrL testFuncL, TBool aIsFullDiscovery, TInt tryCount, TInt increment, TInt stopCount)
       
  1597 {
       
  1598 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0736 "));
       
  1599 	TInt err = KErrNone;
       
  1600 
       
  1601 	do
       
  1602 	{
       
  1603 		__UHEAP_MARK;
       
  1604   		// find out the number of open handles
       
  1605 		TInt startProcessHandleCount;
       
  1606 		TInt startThreadHandleCount;
       
  1607 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  1608 
       
  1609 		// Need to create object here as ECom has embedded TRAPs
       
  1610 		// that will fail the test if memory not available
       
  1611 		CRegistrarTest* registrarTest = CRegistrarTest::NewL(aIsFullDiscovery);
       
  1612 		CleanupStack::PushL(registrarTest);
       
  1613 
       
  1614 		// Setting Heap failure for OOM test
       
  1615  		__UHEAP_SETFAIL(RHeap::EDeterministic, tryCount);
       
  1616 
       
  1617 		TRAP(err, (registrarTest->*testFuncL)());
       
  1618 
       
  1619 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
  1620 
       
  1621 		CleanupStack::PopAndDestroy(registrarTest);
       
  1622 		registrarTest = NULL;
       
  1623 
       
  1624 		// check that no handles have leaked
       
  1625 		TInt endProcessHandleCount;
       
  1626 		TInt endThreadHandleCount;
       
  1627 		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  1628 
       
  1629 		test(startProcessHandleCount == endProcessHandleCount);
       
  1630 		test(startThreadHandleCount  == endThreadHandleCount);
       
  1631 
       
  1632 		__UHEAP_MARKEND;
       
  1633 		tryCount = tryCount + increment;
       
  1634 
       
  1635 	} while((err == KErrNoMemory) && (tryCount != stopCount));
       
  1636 
       
  1637 	tryCount = tryCount - increment;
       
  1638 
       
  1639 	if (err == KErrNoMemory)
       
  1640 	{
       
  1641 		// test has not yet been able to pass due to memory allocation failures.
       
  1642 		return -1;
       
  1643 	}
       
  1644 
       
  1645 	test(err == KErrNone);
       
  1646 
       
  1647 	// If enough memory has finally been allocated for the test to pass then return
       
  1648 	// the memory allocation counter value.
       
  1649 	test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
       
  1650 	return tryCount;
       
  1651 
       
  1652 }
       
  1653 
       
  1654 /**
       
  1655 Wrapper function to call all OOM test functions
       
  1656 
       
  1657 @param		testFuncL pointer to OOM test function
       
  1658 @param		aTestDesc test function name
       
  1659 */
       
  1660 LOCAL_C void DoOOMTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc, TBool aIsFullDiscovery)
       
  1661 	{
       
  1662 	test.Next(aTestDesc);
       
  1663 
       
  1664 	TInt startCount = 1;
       
  1665 	TInt increment = 1;
       
  1666 	TInt successRate = -1;
       
  1667 	TInt stopCount = 256;
       
  1668 
       
  1669  	successRate = RunTestUnderOOMCondition(testFuncL, aIsFullDiscovery, startCount, increment, stopCount);
       
  1670 
       
  1671  	// (INC115057)
       
  1672  	// When method CDiscoverer::CDirScanner::DoScanDriveL is encountered in a test hundreds
       
  1673  	// of plug-in files will be scanned. It takes in the order of 3-4000 memory allocation failure
       
  1674  	// loops (in techview context) before the scan is finished and the test can complete successfully.
       
  1675  	// This will take over an hour. Instead determine the approximate failure point by
       
  1676  	// testing with large increments between failures. Once a failure rate interval is found test
       
  1677  	// for OOM conditions running up to it.
       
  1678  	// This in effect means that we are checking OOM at the start and end of tests but skipping
       
  1679  	// the scanning of each and every plugin in the middle of the test.
       
  1680  	// (Note that CDiscoverer::CDirScanner::DoScanDriveL may return without leaving when it
       
  1681  	// can't allocate TFileName. In this case it seems to this function that the test is
       
  1682  	// successful. Therefore even if the successRate above indicates a pass the test is still
       
  1683  	// re-run below with larger memory allocation failure valued to make sure that the test does
       
  1684  	// in fact run to completion.
       
  1685 
       
  1686    	startCount = 256;
       
  1687  	increment = 256;
       
  1688  	stopCount = -1;
       
  1689  		successRate = RunTestUnderOOMCondition(testFuncL, aIsFullDiscovery, startCount, increment, stopCount);
       
  1690  	test(successRate > 0);
       
  1691 
       
  1692  	if (successRate > 256)
       
  1693  	{
       
  1694  		startCount = successRate - 256;
       
  1695  		increment = 1;
       
  1696  		stopCount = -1;
       
  1697  		successRate = RunTestUnderOOMCondition(testFuncL, aIsFullDiscovery, startCount, increment, stopCount);
       
  1698  	}
       
  1699 
       
  1700  	test(successRate > 0);
       
  1701 
       
  1702 	}
       
  1703 
       
  1704 LOCAL_C void DoTestsL()
       
  1705 	{
       
  1706 	__UHEAP_MARK;
       
  1707 
       
  1708 	// Basic tests
       
  1709 	CreateDeleteTestL();
       
  1710 
       
  1711 	DoBasicTestL(&CRegistrarTest::EnableDisableTestL, _L("EnableDisableTestL"), ETrue);
       
  1712 	DoBasicTestL(&CRegistrarTest::ResumeSuspendTestL, _L("ResumeSuspendTestL"), ETrue);
       
  1713 	DoBasicTestL(&CRegistrarTest::DriveRemovedReinstatedTestL, _L("DriveRemovedReinstatedTestL"), ETrue);
       
  1714 	DoBasicTestL(&CRegistrarTest::DiscoveriesBegin_Register_CompleteTestL, _L("DiscoveriesBegin_Register_CompleteTestL"), ETrue);
       
  1715 	DoBasicTestL(&CRegistrarTest::ParseTestL, _L("ParseTestL"), ETrue);
       
  1716 	DoBasicTestL(&CRegistrarTest::ParseType2TestL, _L("ParseType2TestL"), ETrue);
       
  1717 	DoBasicTestL(&CRegistrarTest::ParseType3TestL, _L("ParseType3TestL"), ETrue);
       
  1718 	DoBasicTestL(&CRegistrarTest::ParseType3BadDataTestL, _L("ParseType3BadDataTestL"), ETrue);
       
  1719 	DoBasicTestL(&CRegistrarTest::ParseRegistrationDataTestL, _L("ParseRegistrationDataTestL"), ETrue);
       
  1720 	DoBasicTestL(&CRegistrarTest::ParseRegistrationDataType3TestL, _L("ParseRegistrationDataType3TestL"), ETrue);
       
  1721 	DoBasicTestL(&CRegistrarTest::ParseSpiTestL, _L("ParseSpiTestL"), ETrue);
       
  1722 	DoBasicTestL(&CRegistrarTest::ParseSpiType3TestL, _L("ParseSpiType3TestL"), ETrue);
       
  1723 	DoBasicTestL(&CRegistrarTest::ParseSpiRegistrationDataTestL, _L("ParseSpiRegistrationDataTestL"), ETrue);
       
  1724 	DoBasicTestL(&CRegistrarTest::ParseSpiRegistrationDataType3TestL, _L("ParseSpiRegistrationDataType3TestL"), ETrue);
       
  1725 	DoBasicTestL(&CRegistrarTest::StateTransitionTestL, _L("StateTransitionTestL"), EFalse);
       
  1726 	// OOM tests
       
  1727 	// The OOM test for CRegistrar takes nearly 1 hour on hardware as it is reading the entire ecom.spi file
       
  1728  	// Since ECOMSERVERTEST OOM test covered the full CRegistar OOM part, we will not run this the following
       
  1729  	// test as that means 2 hours for ecom tests.
       
  1730 	//OOMCreateDeleteTest();
       
  1731 	DoOOMTestL(&CRegistrarTest::EnableDisableTestL, _L("OOM EnableDisableTestL"), ETrue);
       
  1732 	DoOOMTestL(&CRegistrarTest::ResumeSuspendTestL, _L("OOM ResumeSuspendTestL"), ETrue);
       
  1733 	DoOOMTestL(&CRegistrarTest::DriveRemovedReinstatedTestL, _L("OOM DriveRemovedReinstatedTestL"), ETrue);
       
  1734 	DoOOMTestL(&CRegistrarTest::DiscoveriesBegin_Register_CompleteTestL, _L("OOM DiscoveriesBegin_Register_CompleteTestL"), ETrue);
       
  1735 	DoOOMTestL(&CRegistrarTest::ParseTestL, _L("OOM ParseTestL"), ETrue);
       
  1736 	DoOOMTestL(&CRegistrarTest::ParseType2TestL, _L("OOM ParseType2TestL"), ETrue);
       
  1737 	DoOOMTestL(&CRegistrarTest::ParseType3TestL, _L("OOM ParseType3TestL"), ETrue);
       
  1738 	DoOOMTestL(&CRegistrarTest::ParseSpiTestL, _L("OOM ParseSpiTestL"), ETrue);
       
  1739 	DoOOMTestL(&CRegistrarTest::ParseSpiType3TestL, _L("OOM ParseSpiType3TestL"), ETrue);
       
  1740 	DoOOMTestL(&CRegistrarTest::StateTransitionTestL, _L("OOM StateTransitionTestL"), EFalse);
       
  1741 	// Not performing the OOM on ParseRegistrationDataL because of TRAPs present inside this function.
       
  1742 	// The OOM error is trapped inside during the creation of the DllData but this error is not propagated to
       
  1743 	// the calling funtion. Hence does not give the right results. However the normal test is performed above.
       
  1744 	//DoOOMTestL(&CRegistrarTest::ParseRegistrationDataTestL,_L("OOM ParseRegistrationDataTestL"));
       
  1745 	__UHEAP_MARKEND;
       
  1746 	}
       
  1747 
       
  1748 // Copies the Plugins to specific folder for testing purpose
       
  1749 LOCAL_C void CopyPlugins()
       
  1750 	{
       
  1751 	TInt err=KErrNone;
       
  1752 	TRAP(err, EComTestUtils::FileManCopyFileL(KNewResourceFileNameZ, KNewResourceFileNameC));
       
  1753 	test(err==KErrNone);
       
  1754 	TRAP(err, EComTestUtils::FileManCopyFileL(KNewDllFileNameZ, KNewDllFileNameC));
       
  1755 	test(err==KErrNone);
       
  1756 	TRAP(err, EComTestUtils::FileManCopyFileL(KType3ResourceFileNameZ, KType3ResourceFileNameC));
       
  1757 	test(err==KErrNone);
       
  1758 	TRAP(err, EComTestUtils::FileManCopyFileL(KType3DllFileNameZ, KType3DllFileNameC));
       
  1759 	test(err==KErrNone);
       
  1760 	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadDataResourceFileNameZ, KType3BadDataResourceFileNameC));
       
  1761 	test(err==KErrNone);
       
  1762 	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadDataDllFileNameZ, KType3BadDataDllFileNameC));
       
  1763 	test(err==KErrNone);
       
  1764 	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadData1ResourceFileNameZ, KType3BadData1ResourceFileNameC));
       
  1765 	test(err==KErrNone);
       
  1766 	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadData1DllFileNameZ, KType3BadData1DllFileNameC));
       
  1767 	test(err==KErrNone);
       
  1768 	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadData2ResourceFileNameZ, KType3BadData2ResourceFileNameC));
       
  1769 	test(err==KErrNone);
       
  1770 	TRAP(err, EComTestUtils::FileManCopyFileL(KType3BadData2DllFileNameZ, KType3BadData2DllFileNameC));
       
  1771 	test(err==KErrNone);
       
  1772 	TRAP(err, EComTestUtils::FileManCopyFileL(KType2ResourceFileNameZ, KType2ResourceFileNameC));
       
  1773 	test(err==KErrNone);
       
  1774 	TRAP(err, EComTestUtils::FileManCopyFileL(KType2DllFileNameZ, KType2DllFileNameC));
       
  1775 	test(err==KErrNone);
       
  1776 	}
       
  1777 
       
  1778 // Deleting plugin from the RAM for cleanup purpose
       
  1779 inline LOCAL_C void DeleteTestPlugin()
       
  1780 	{
       
  1781 	TInt err=KErrNone;
       
  1782 	TRAP(err, EComTestUtils::FileManDeleteFileL(KNewResourceFileNameC));
       
  1783 	TRAP(err, EComTestUtils::FileManDeleteFileL(KNewDllFileNameC));
       
  1784 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3ResourceFileNameC));
       
  1785 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3DllFileNameC));
       
  1786 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadDataResourceFileNameC));
       
  1787 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadDataDllFileNameC));
       
  1788 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadData1ResourceFileNameC));
       
  1789 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadData1DllFileNameC));
       
  1790 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadData2ResourceFileNameC));
       
  1791 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType3BadData2DllFileNameC));
       
  1792 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType2ResourceFileNameC));
       
  1793 	TRAP(err, EComTestUtils::FileManDeleteFileL(KType2DllFileNameC));
       
  1794 	}
       
  1795 
       
  1796 //Initialise the Active Scheduler
       
  1797 LOCAL_C void SetupL()
       
  1798 	{
       
  1799 	// Construct and install the Active Scheduler. The Active Schedular is needed
       
  1800 	// by components used by this test as they are ActiveObjects.
       
  1801 	TheActiveScheduler = new(ELeave)CActiveScheduler;
       
  1802 	CActiveScheduler::Install(TheActiveScheduler);
       
  1803 	}
       
  1804 
       
  1805 GLDEF_C TInt E32Main()
       
  1806 	{
       
  1807 	__UHEAP_MARK;
       
  1808 
       
  1809 	test.Printf(_L("\n"));
       
  1810 	test.Title();
       
  1811 	test.Start( _L("Registrar Tests.") );
       
  1812 
       
  1813 	TheTrapCleanup = CTrapCleanup::New();
       
  1814 
       
  1815 	// Connect the file server instance
       
  1816 	User::LeaveIfError(TheFs.Connect());
       
  1817 
       
  1818 	TRAPD(err, SetupL());
       
  1819 	test(err == KErrNone);
       
  1820 
       
  1821 	// We need to clean up the registry files to ensure a fresh discovery that
       
  1822 	// has the effect of taking certain pathways within the code. This
       
  1823 	// tests the memory cleanup
       
  1824 	// Delete the prevous data files so we rediscover from scratch
       
  1825 
       
  1826 	TRAP(err, EComTestUtils::FileManDeleteFileL(KDataDir));
       
  1827 	CopyPlugins();
       
  1828 
       
  1829 	// The reason for the folowing delay is:
       
  1830 	// ECOM server could be already started. It means that when we copy some
       
  1831 	// ECOM plugins from Z: to C: drive - ECOM server should look for and
       
  1832 	// find the new ECOM plugins. The ECOM server uses for that an active object,
       
  1833 	// which scans plugin directories. So the discovering service is asynchronous.
       
  1834 	// We have to wait some time until it finishes.
       
  1835 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
  1836 	User::After(KOneSecond * 3);
       
  1837 
       
  1838 	// Call the main tests
       
  1839 	TRAP(err, DoTestsL());
       
  1840 	test(err == KErrNone);
       
  1841 
       
  1842 	// Cleanup files. If the cleanup fails that is no problem,
       
  1843 	// as any subsequent tests will replace them. The only downside
       
  1844 	// would be the disk not being tidied
       
  1845 	DeleteTestPlugin();
       
  1846 
       
  1847 	delete TheActiveScheduler;
       
  1848 	delete TheTrapCleanup;
       
  1849 
       
  1850 	TheFs.Close();
       
  1851 
       
  1852 	test.End();
       
  1853 	test.Close();
       
  1854 
       
  1855 	__UHEAP_MARKEND;
       
  1856 	return (KErrNone);
       
  1857 	}