lowlevellibsandfws/pluginfw/Framework/RegistryDataTest/t_registrydata.cpp
changeset 0 e4d67989cc36
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 CRegistryData. Where necessary stubs
       
    16 // are implemented to help in writing test harness using RTest.
       
    17 // Test can fail if the Registry Index files are corrupted or missing.
       
    18 // To solve that problem we need to run some component test harness, which
       
    19 // runs by linking against ECom.lib. like t_listimplementation or t_suicide.
       
    20 // 
       
    21 //
       
    22 
       
    23 #include <ecom/ecom.h>
       
    24 #include "EComUidCodes.h"
       
    25 #include "RegistrarObserver.h"
       
    26 #include "RegistryData.h"
       
    27 #include "Registrar.h"
       
    28 #include "EComResolverParams.h"
       
    29 #include "Discoverer.h"
       
    30 #include "DiscovererObserver.h"
       
    31 #include "DriveInfo.h"
       
    32 #include "DowngradePath.h"
       
    33 #include "../EcomTestUtils/EcomTestUtils.h"
       
    34 #include "RegistryResolveTransaction.h"
       
    35 #include "ParseImplementationData.h"
       
    36 
       
    37 #include <ecom/ecompanics.h>
       
    38 #include <s32file.h>
       
    39 #include <e32test.h>
       
    40 #include <f32file.h>
       
    41 #include <bautils.h>
       
    42 #include <babackup.h>
       
    43 #include <hal.h>
       
    44 
       
    45 #define UNUSED_VAR(a) a = a
       
    46 
       
    47 // Used within tests
       
    48 const TUid KCExampleInterfaceUid = {0x10009DC0};
       
    49 const TUid KCExampleInterfaceImp = {0x10009DC3};
       
    50 const TUid KCDummyUid = {0x00000000};
       
    51 const TUid KCInvalidUid = {0x10009999};
       
    52 
       
    53 const TInt KOneSecond = 1000000;
       
    54 
       
    55 // Used for suppressing warning in OOM tests
       
    56 #define __UNUSED_VAR(var) var = var
       
    57 
       
    58 // Used for OOM test
       
    59 #define TEST_OOM_ERR if(err == KErrNoMemory) User::Leave(err)
       
    60 
       
    61 // The implemented structure for the registry data
       
    62 typedef CRegistryData::CImplementationData* CImplementationDataPtr;
       
    63 typedef RArray<CImplementationDataPtr> RImplDataArray;
       
    64 
       
    65 // Test plugins and corresponding .rsc files that be copied to RAM for testing purpose
       
    66 _LIT(KEComExDllOnZ,		"Z:\\RAMOnly\\EComExample5.dll");
       
    67 
       
    68 _LIT(KEComExDllOnC,		"C:\\sys\\bin\\EComExample5.dll");
       
    69 _LIT(KEComRscFileOnC,	"C:\\resource\\plugins\\EComExample5.rsc");
       
    70 _LIT(KEComRscFileOnZ,	"Z:\\RAMOnly\\EComExample5.rsc");
       
    71 _LIT(KEComExampleDllOnC,		"C:\\sys\\bin\\EComExample.dll");
       
    72 _LIT(KEComExampleDllOnZSysBin,	"Z:\\sys\\bin\\EComExample.dll");
       
    73 _LIT(KEComExample2DllOnC,		"C:\\sys\\bin\\EComExample2.dll");
       
    74 _LIT(KEComExample3DllOnC,		"C:\\sys\\bin\\EComExample3.dll");
       
    75 
       
    76 _LIT(KEComExampleRscOnC,		"C:\\resource\\plugins\\EComExample.rsc");
       
    77 _LIT(KEComExample2RscOnC,		"C:\\resource\\plugins\\EComExample2.rsc");
       
    78 _LIT(KEComExample3RscOnC,		"C:\\resource\\plugins\\EComExample3.rsc");
       
    79 
       
    80 _LIT(KEComExampleRscOnZ,		"Z:\\RAMOnly\\EComExample.rsc");
       
    81 _LIT(KEComExample2RscOnZ,		"Z:\\RAMOnly\\EComExample2.rsc");
       
    82 _LIT(KEComExample3RscOnZ,		"Z:\\RAMOnly\\EComExample3.rsc");
       
    83 
       
    84 _LIT(KEComExampleDllOnZ,			"Z:\\RAMOnly\\EComExample.dll");
       
    85 _LIT(KEComExample2DllOnZ,		"Z:\\RAMOnly\\EComExample2.dll");
       
    86 _LIT(KEComExample3DllOnZ,		"Z:\\RAMOnly\\EComExample3.dll");
       
    87 
       
    88 // These RSC files/DLLs are used to test an RSC file with a SID that does not
       
    89 // match it's corresponding DLL. The implementations should not be listed/created.
       
    90 _LIT(KEComInvalidDllOnZ, "z:\\RAMOnly\\InvalidSIDPlugin.dll");
       
    91 _LIT(KEComInvalidRscOnZ, "z:\\RAMOnly\\InvalidSIDPlugin.rsc");
       
    92 _LIT(KEComInvalidDllOnC, "c:\\sys\\bin\\InvalidSIDPlugin.dll");
       
    93 _LIT(KEComInvalidRscOnC, "c:\\resource\\plugins\\InvalidSIDPlugin.rsc");
       
    94 
       
    95 // This DLL does not exist, and should fail a security check
       
    96 _LIT(KEComMissingDll, "c:\\sys\\bin\\NonExistentDllName.dll");
       
    97 
       
    98 // These RSC files/DLLs are used to test an RSC file that points to a missing DLL
       
    99 _LIT(KMissingDllRomRscFile, 		"z:\\RAMOnly\\EComRomRslvrExampleOnC.rsc");
       
   100 _LIT(KMissingDllRamRscFile, 		"c:\\resource\\plugins\\EComRomRslvrExampleOnC.rsc");
       
   101 // When the above RSC file's security check fails, the following implementations should be rolled back to
       
   102 // (even though the filenames are EComRomRslvrExampleOnZ they will be copied to and exist on C Drive)
       
   103 _LIT(KRollbackForMissingDllRomDllFile, 			"z:\\RAMOnly\\EComRomRslvrExampleOnZ.dll");
       
   104 _LIT(KRollbackForMissingDllRamDllFile, 			"c:\\sys\\bin\\EComRomRslvrExampleOnZ.dll");
       
   105 _LIT(KRollbackForMissingDllRomRscFile, 			"z:\\RAMOnly\\EComRomRslvrExampleOnZ.rsc");
       
   106 _LIT(KRollbackForMissingDllRamRscFile, 			"c:\\resource\\plugins\\EComRomRslvrExampleOnZ.rsc");
       
   107 
       
   108 //PLUGIN1 DLL with interfaceID: 0x10009E36
       
   109 _LIT(KEComExample14DllOnC,		"C:\\sys\\bin\\EComExample14.dll");
       
   110 _LIT(KEComExample14DllOnZ,		"Z:\\RAMOnly\\EComExample14.dll");
       
   111 _LIT(KEComExample14RscOnC,		"C:\\resource\\plugins\\EComExample14.rsc");
       
   112 _LIT(KEComExample14RscOnZ,		"Z:\\RAMOnly\\EComExample14.rsc");
       
   113 //PLUGIN3 DLL with interfaceID: 0x10009E36, implementation version 2
       
   114 _LIT(KEComExample15DllOnC,		"C:\\sys\\bin\\EComExample15.dll");
       
   115 _LIT(KEComExample15DllOnZ,		"Z:\\RAMOnly\\EComExample15.dll");
       
   116 _LIT(KEComExample15RscOnC,		"C:\\resource\\plugins\\EComExample15.rsc");
       
   117 _LIT(KEComExample15RscOnZ,		"Z:\\RAMOnly\\EComExample15.rsc");
       
   118 //PLUGIN3 DLL with interfaceID: 0x10009E36
       
   119 _LIT(KEComExample12DllOnC,		"C:\\sys\\bin\\EComExample12.dll");
       
   120 _LIT(KEComExample12DllOnZ,		"Z:\\RAMOnly\\EComExample12.dll");
       
   121 _LIT(KEComExample12RscOnC,		"C:\\resource\\plugins\\EComExample12.rsc");
       
   122 _LIT(KEComExample12RscOnZ,		"Z:\\RAMOnly\\EComExample12.rsc");
       
   123 
       
   124 _LIT(KEComExample10DllOnC,		"C:\\sys\\bin\\EComExample10.dll");
       
   125 //PLUGIN3 Upgraded
       
   126 _LIT(KEcomExample12UpgradedOnC, "C:\\resource\\plugins\\EComExample12Upgraded.rsc");
       
   127 _LIT(KEcomExample12UpgradedOnZ, "Z:\\RAMOnly\\EComExample12Upgraded.rsc");
       
   128 _LIT(KEcomExample12UpgradedResourceNameOnly, "EComExample12Upgraded.rsc");
       
   129 //PLUGIN1 Upgraded to PLUGIN3
       
   130 _LIT(KEcomExample14UpgradedOnC, "C:\\resource\\plugins\\EComExample14Upgraded.rsc");
       
   131 _LIT(KEcomExample14UpgradedOnZ, "Z:\\RAMOnly\\EComExample14Upgraded.rsc");
       
   132 _LIT(KEcomExample14UpgradedResourceNameOnly, "EComExample14Upgraded.rsc");
       
   133 //PLUGIN3 Downgraded to PLUGIN1
       
   134 _LIT(KEcomExample12DowngradedOnC, "C:\\resource\\plugins\\EComExample12Downgraded.rsc");
       
   135 _LIT(KEcomExample12DowngradedOnZ, "Z:\\RAMOnly\\EComExample12Downgraded.rsc");
       
   136 _LIT(KEcomExample12DowngradedResourceNameOnly, "EComExample12Downgraded.rsc");
       
   137 
       
   138 _LIT(KDriveC, "C");
       
   139 
       
   140 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
       
   141     _LIT(KEnglishLocale, "elocl.01");
       
   142     _LIT(KEComSpanishLocale, "elocl.04");
       
   143 #else
       
   144     // refer base/os/kernelhwsrv/kernel/eka/euser/locmapping.cpp
       
   145     // Language
       
   146     _LIT(KEComEnglishLang,"elocl_lan.001");
       
   147     //_LIT(KEComFrenchLang,"elocl_lan.002");
       
   148     //_LIT(KEComGermanLang,"elocl_lan.003");
       
   149     _LIT(KEComSpanishLang,"elocl_lan.004");
       
   150     // Region
       
   151     _LIT(KEComEnglishReg,"elocl_reg.826");
       
   152     //_LIT(KEComFrenchReg,"elocl_reg.250");
       
   153     //_LIT(KEComGermanReg,"elocl_reg.276");
       
   154     _LIT(KEComSpanishReg,"elocl_reg.724");
       
   155     // Collation
       
   156     _LIT(KEComEnglishColl,"elocl_col.001");
       
   157     //_LIT(KEComFrenchColl,"elocl_col.002");
       
   158     //_LIT(KEComGermanColl,"elocl_col.003");
       
   159     _LIT(KEComSpanishColl,"elocl_col.001");
       
   160 #endif
       
   161 
       
   162 LOCAL_D CTrapCleanup*		TheTrapCleanup=NULL;
       
   163 
       
   164 LOCAL_D CActiveScheduler*	TheActiveScheduler=NULL;
       
   165 
       
   166 LOCAL_D RFs					TheFs;
       
   167 
       
   168 LOCAL_D RTest				TheTest(_L("t_registrydata.exe"));
       
   169 
       
   170 //TPtrC defined which will point to KEComSpiFilePathAndName or KEComSpiFilePathAndNameForNand
       
   171 //according to the rom build type
       
   172 LOCAL_D TPtrC				TheEComSpiFilePathAndNamePtrC;
       
   173 
       
   174 TCapabilitySet dummycaps;
       
   175 
       
   176 LOCAL_C void CopyPluginsL();
       
   177 
       
   178 inline LOCAL_C void DeleteTestPlugin()
       
   179 	{
       
   180 	TRAPD(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExDllOnC));
       
   181 	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComRscFileOnC));
       
   182  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExampleDllOnC));
       
   183  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample2DllOnC));
       
   184  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample3DllOnC));
       
   185  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExampleRscOnC));
       
   186  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample2RscOnC));
       
   187  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample3RscOnC));
       
   188  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComInvalidDllOnC));
       
   189  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComInvalidRscOnC));
       
   190  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KMissingDllRamRscFile));
       
   191  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KRollbackForMissingDllRamDllFile));
       
   192  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KRollbackForMissingDllRamRscFile));
       
   193  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample12DllOnC));
       
   194  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample12RscOnC));
       
   195  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample14DllOnC));
       
   196  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample14RscOnC));
       
   197  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample15DllOnC));
       
   198  	TRAP(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample15RscOnC));
       
   199 	}
       
   200 
       
   201 //
       
   202 //
       
   203 //Test macroses and functions
       
   204 LOCAL_C void Check(TInt aValue, TInt aLine)
       
   205 	{
       
   206 	if(!aValue)
       
   207 		{
       
   208 		::DeleteTestPlugin();
       
   209 		TheTest(EFalse, aLine);
       
   210 		}
       
   211 	}
       
   212 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
       
   213 	{
       
   214 	if(aValue != aExpected)
       
   215 		{
       
   216 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
       
   217 		::DeleteTestPlugin();
       
   218 		TheTest(EFalse, aLine);
       
   219 		}
       
   220 	}
       
   221 /**
       
   222 Sets up the system-wide locale and language downgrade path.
       
   223 */
       
   224 LOCAL_C void SetLanguageL(const TLanguage aLang[3])
       
   225 	{
       
   226 	TLocale locale;
       
   227 	locale.SetLanguageDowngrade(0, aLang[0]);
       
   228 	locale.SetLanguageDowngrade(1, aLang[1]);
       
   229 	locale.SetLanguageDowngrade(2, aLang[2]);
       
   230 	User::LeaveIfError(locale.Set());
       
   231 	}
       
   232 
       
   233 #define TEST(arg) ::Check((arg), __LINE__)
       
   234 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
       
   235 //
       
   236 //
       
   237 
       
   238 /**
       
   239 This class allows us to provide stub behavior to instantiate CRegistrar
       
   240 */
       
   241 class TRegistrarObserverStub : public MRegistrarObserver
       
   242 	{
       
   243 public:
       
   244 /**
       
   245 The overloaded method from the MRegistrarObserver class Used for firing
       
   246 notifications to the client sessions that the underlying registry data has changed.
       
   247 @post		The CEComServer has notified all its client sessions
       
   248 			registered for notifications that the data changed
       
   249 */
       
   250 	void Notification(TInt aNotificationCode)
       
   251 		{
       
   252 		RDebug::Print(_L("TRegistrarObserverStub called with notification code %d.\n"), aNotificationCode);
       
   253 		};
       
   254 	};
       
   255 
       
   256 /**
       
   257 This friend class allows us to access private and protected members of production
       
   258 code class CDiscoverer.
       
   259 */
       
   260 class TDiscoverer_StateAccessor
       
   261 	{
       
   262 public:
       
   263 	TDiscoverer_StateAccessor() {};
       
   264 	void ScanDirectoryL(CDiscoverer& aDiscoverer)
       
   265 		{
       
   266 		aDiscoverer.ProcessSSAEventL(EStartupStateNonCritical);
       
   267 		}
       
   268 	void ScanDriveL(CDiscoverer& aDiscoverer, TDriveUnit& aDrive)
       
   269 		{
       
   270 		TBool isRO = aDiscoverer.iCachedDriveInfo->DriveIsReadOnlyInternalL(aDrive);
       
   271 		aDiscoverer.iDirScanner->ScanDriveL(aDrive, isRO);
       
   272 		}
       
   273 	};
       
   274 
       
   275 /**
       
   276 This friend class allows us to access private and protected members of production
       
   277 code class CRegistrar.
       
   278 */
       
   279 class TRegistrar_StateAccessor
       
   280 	{
       
   281 public:
       
   282 	TRegistrar_StateAccessor() {};
       
   283 	void ScanDirectoryL(CRegistrar& aRegistrar)
       
   284 		{
       
   285 		TDiscoverer_StateAccessor discovererStateAccessor;
       
   286 		discovererStateAccessor.ScanDirectoryL(*(aRegistrar.iDiscoverer));
       
   287 		}
       
   288 	void ScanDriveL(CRegistrar& aRegistrar, TDriveUnit& aDrive)
       
   289 		{
       
   290 		TDiscoverer_StateAccessor discovererStateAccessor;
       
   291 		discovererStateAccessor.ScanDriveL(*(aRegistrar.iDiscoverer), aDrive);
       
   292 		}
       
   293 	void ParseL(CRegistrar& aRegistrar, CPluginBase*& aEntry,CRegistryData::CDllData& aDll);
       
   294 	};
       
   295 
       
   296 void TRegistrar_StateAccessor::ParseL(CRegistrar& aRegistrar, CPluginBase*& aEntry,CRegistryData::CDllData& aDll)
       
   297 		{
       
   298 		aRegistrar.ParseL(aEntry,aDll);
       
   299 		}
       
   300 
       
   301 
       
   302 /**
       
   303 This friend class allows us to access private and protected members of production
       
   304 code class CRegistryData.
       
   305 */
       
   306 class TRegistryData_StateAccessor
       
   307 	{
       
   308 public:
       
   309 	TBool IsIndexValid(CRegistryData& aRegData);
       
   310 
       
   311 	TInt IndexedFind(CRegistryData& aRegData, const TUid& aImplementationUid);
       
   312 
       
   313 	TBool IsRegisteredDriveL(CRegistryData& aRegData, TDriveUnit aDriveUnit);
       
   314 
       
   315 	TInt RegistrationsCount(CRegistryData& aRegData);
       
   316 
       
   317 	TInt ImplementationsCount(CRegistryData& aRegData);
       
   318 
       
   319 	void SetRegistryChanged(CRegistryData& aRegData, TBool aChanged, TDriveUnit aDrive);
       
   320 
       
   321 	void ClearImplementationIndexList(CRegistryData& aRegData);
       
   322 
       
   323 	void ClearRegistrations(CRegistryData& aRegData);
       
   324 
       
   325 	void ResetAndDestroy(CRegistryData& aRegData);
       
   326 
       
   327 	void ConstructL(CRegistryData& aRegData);
       
   328 
       
   329 	TBool FindAnImplementation(CRegistryData& aRegData, TUid& aInterfaceUid, TDriveUnit& aDrive);
       
   330 
       
   331 	void GetImplementationInfoL(CRegistryData& aRegData, TUid& aInterfaceUid, RImplDataArray& aImplementationInfo);
       
   332 
       
   333 	void AppendDriveDataL(CRegistryData& aRegData, CRegistryData::CDriveData* aDriveData);
       
   334 
       
   335 	TInt FindImplementation(CRegistryData& aRegData, const TUid aImplUid, const TUid aInterfaceUid,
       
   336 										CRegistryData::CImplementationData*& aImplData) const;
       
   337 	static void ResetStaticDriveData();
       
   338 	TInt GetDllListL(CRegistryData& aRegistryData, TDriveUnit aDriveUnit, TDll*& aDllList);
       
   339 	TBool IsLanguageInitChanged(CRegistryData& aRegistryData);
       
   340 	TInt DrivesRemoved(CRegistryData& aRegistryData);
       
   341 	};
       
   342 
       
   343 /**
       
   344 Constructs the registry
       
   345 
       
   346 */
       
   347 void TRegistryData_StateAccessor::ConstructL(CRegistryData& aRegData)
       
   348 	{
       
   349 	aRegData.ConstructL();
       
   350 	}
       
   351 
       
   352 /**
       
   353 Resets the registry
       
   354 
       
   355 */
       
   356 void TRegistryData_StateAccessor::ResetAndDestroy(CRegistryData& aRegData)
       
   357 	{
       
   358 	aRegData.iRegistrations->ResetAndDestroy();
       
   359 	delete aRegData.iRegistrations;
       
   360 	}
       
   361 
       
   362 /**
       
   363 Clears the Implementations
       
   364 @param		aRegData RegistryData object under test
       
   365 */
       
   366 void TRegistryData_StateAccessor::ClearImplementationIndexList(CRegistryData& aRegData)
       
   367 	{
       
   368 	for(TInt index = 0; index < aRegData.iInterfaceImplIndex.Count(); ++index)
       
   369 		{
       
   370 		aRegData.iInterfaceImplIndex[index].Reset();
       
   371 		}
       
   372 	aRegData.iInterfaceImplIndex.Reset();
       
   373 	aRegData.iImplIndex.Reset();
       
   374 	}
       
   375 
       
   376 
       
   377 /**
       
   378 Clears the Registrations
       
   379 @param		aRegData RegistryData object under test
       
   380 */
       
   381 void TRegistryData_StateAccessor::ClearRegistrations(CRegistryData& aRegData)
       
   382 	{
       
   383 	if(aRegData.iRegistrations)
       
   384 		{
       
   385 		aRegData.iRegistrations->ResetAndDestroy();
       
   386 		}
       
   387 	}
       
   388 
       
   389 /**
       
   390 Indicates whether the registry index is currently valid. The
       
   391 index will not be valid if discoveries are currently taking place.
       
   392 @param		aRegData RegistryData object under test
       
   393 @return		ETrue if index is valid EFalse otherwise
       
   394 */
       
   395 TBool TRegistryData_StateAccessor::IsIndexValid(CRegistryData& aRegData)
       
   396 	{
       
   397 	return aRegData.IndexValid();
       
   398 	}
       
   399 
       
   400 /**
       
   401 Tries to find the index entry of the passed implementation uid
       
   402 @param		aRegData RegistryData object under test
       
   403 @param		aImplementationUid the implementation Uid of the implementation to locate
       
   404 @return		Index of the implementation, KErrNotFound otherwise
       
   405 */
       
   406 TInt TRegistryData_StateAccessor::IndexedFind(CRegistryData& aRegData,
       
   407 											  const TUid& aImplementationUid)
       
   408 	{
       
   409 	return aRegData.IndexedFind(aImplementationUid);
       
   410 	}
       
   411 
       
   412 /**
       
   413 Checks if the drive is already registered
       
   414 @param		aRegData RegistryData object under test
       
   415 @param		aDriveUnit the drive on which plugins are registered
       
   416 @return		ETrue if drive is registered, EFalse otherwise
       
   417 */
       
   418 TBool TRegistryData_StateAccessor::IsRegisteredDriveL(CRegistryData& aRegData,
       
   419 													 TDriveUnit aDriveUnit)
       
   420 	{
       
   421 	TInt driveIndex = KErrNotFound;
       
   422 	CRegistryData::CDriveData* aDriveData=NULL;
       
   423 	driveIndex = aRegData.FindDriveL(aDriveUnit, aDriveData);
       
   424 	// Return True if the driveindex has some valid value i.e. not KErrNotFound
       
   425 	return (driveIndex != KErrNotFound);
       
   426 	}
       
   427 
       
   428 /**
       
   429 Obtains count of plugin registrations
       
   430 @param		aRegData RegistryData object under test
       
   431 @return		Number of registrations
       
   432 */
       
   433 TInt TRegistryData_StateAccessor::RegistrationsCount(CRegistryData& aRegData)
       
   434 	{
       
   435 	return aRegData.iRegistrations->Count();
       
   436 	}
       
   437 
       
   438 /**
       
   439 Obtains count of plugin registrations
       
   440 @param		aRegData RegistryData object under test
       
   441 @return		Number of registrations
       
   442 */
       
   443 TInt TRegistryData_StateAccessor::ImplementationsCount(CRegistryData& aRegData)
       
   444 	{
       
   445 	return aRegData.iInterfaceImplIndex.Count();
       
   446 	}
       
   447 
       
   448 /**
       
   449 Sets Registry Changed flag to the given value
       
   450 @param		aRegData RegistryData object under test
       
   451 @param		aChanged True if the registry is changed
       
   452 @param		aDrive the drive under test
       
   453 */
       
   454 void TRegistryData_StateAccessor::SetRegistryChanged(CRegistryData& aRegData, TBool aChanged, TDriveUnit aDrive)
       
   455 	{
       
   456 	for(TInt i = 0; i <aRegData.iRegistrations->Count(); i++)
       
   457 		{
       
   458 		if ((*aRegData.iRegistrations)[i]->iDrive == aDrive)
       
   459 			{
       
   460 			(*aRegData.iRegistrations)[i]->iRegistryChanged = aChanged;
       
   461 			}
       
   462 		}
       
   463 	}
       
   464 
       
   465 /**
       
   466 See if an implementation is discovered on the questioned drive
       
   467 @param		aRegData RegistryData object under test
       
   468 @param		aInterfaceUid Interface UID for the implementation
       
   469 @param		aDrive Drive to search the implementation on
       
   470 @return 	ETrue if an implementation exists
       
   471 */
       
   472 TBool TRegistryData_StateAccessor::FindAnImplementation(CRegistryData& aRegData, TUid& aInterfaceUid, TDriveUnit& aDrive)
       
   473 	{
       
   474 	const TInt driveCount = aRegData.iRegistrations->Count();
       
   475 	for(TInt driveIndex = 0; driveIndex < driveCount; ++driveIndex)
       
   476 		{
       
   477 		CRegistryData::CDriveData* driveData = (*aRegData.iRegistrations)[driveIndex];
       
   478 		if(driveData->iDrive == aDrive)
       
   479 			{
       
   480 			TDll* dllList = (*aRegData.iRegistrations)[driveIndex]->iDllList;
       
   481 			const TInt dllCount = dllList->Count();
       
   482 			for(TInt dllIndex = 0; dllIndex < dllCount;++dllIndex)
       
   483 				{
       
   484 				// For each dll structure
       
   485 				RInterfaceList* interfaceList = (*dllList)[dllIndex]->iIfList;
       
   486 				const TInt ifCount = interfaceList->Count();
       
   487 				for(TInt ifIndex = 0; ifIndex < ifCount; ++ifIndex)
       
   488 					{
       
   489 					CRegistryData::TInterfaceIndex index;
       
   490 
       
   491 					// For each interface structure
       
   492 					TUid interfaceUid = (*interfaceList)[ifIndex]->iInterfaceUid;
       
   493 					if(interfaceUid == aInterfaceUid)
       
   494 						{
       
   495 						return ETrue;
       
   496 						}
       
   497 					}
       
   498 				}
       
   499 			}
       
   500 		}
       
   501 
       
   502 	return EFalse;
       
   503 	}
       
   504 
       
   505 /**
       
   506 Get implementation info from the index
       
   507 @param		aRegData RegistryData object under test
       
   508 @param		aInterfaceUid Interface UID for the implementation
       
   509 @param  	aImplementationData Reference of array of Implementation Data
       
   510 */
       
   511 void TRegistryData_StateAccessor::GetImplementationInfoL(CRegistryData& aRegData, TUid& aInterfaceUid, RImplDataArray& aImplementationData)
       
   512 	{
       
   513 	aRegData.ListImplementationsL(aInterfaceUid, aImplementationData);
       
   514 	}
       
   515 
       
   516 /**
       
   517 Append DriveSata to iRegistrations
       
   518 @param		aRegData RegistryData object under test
       
   519 @param		aInterfaceUid Interface UID for the implementation
       
   520 @return 	Array of Implementations
       
   521 */
       
   522 void TRegistryData_StateAccessor::AppendDriveDataL(CRegistryData& aRegData, CRegistryData::CDriveData* aDriveData)
       
   523 	{
       
   524 	aRegData.iRegistrations->AppendL(aDriveData);
       
   525 	}
       
   526 
       
   527 /**
       
   528 @param		aRegistryData The CRegistryData class object
       
   529 @param		aImplUid The implementation to find.
       
   530 @param		aInterfaceUid If greater than 0 the interface associated with the
       
   531 			implementation to find.
       
   532 @param		aImplData The found implementation data.
       
   533 @return		KErrNone if found otherwise KErrNotFound
       
   534 */
       
   535 TInt TRegistryData_StateAccessor::FindImplementation(CRegistryData& aRegistryData,
       
   536 												const TUid aImplUid,
       
   537 												const TUid aInterfaceUid,
       
   538 												CRegistryData::CImplementationData*& aImplData) const
       
   539 	{
       
   540 	return aRegistryData.FindImplementation(aImplUid, aInterfaceUid, aImplData);
       
   541 	}
       
   542 
       
   543 /**
       
   544 @param		aRegistryData The CRegistryData class object
       
   545 @param		aDriveUnit A drive unit
       
   546 @param		aDllList The dll list returned on a specified drive.
       
   547 @return		Index of the specified drive in registryData if found otherwise KErrNotFound
       
   548 */
       
   549 TInt TRegistryData_StateAccessor::GetDllListL(CRegistryData& aRegistryData, TDriveUnit aDriveUnit, TDll*& aDllList)
       
   550 {
       
   551 	CRegistryData::CDriveData* drive =NULL;
       
   552 
       
   553 	// Get the drive data in the registry.
       
   554 	TInt registryDriveIndex = aRegistryData.FindDriveL(aDriveUnit, drive);
       
   555 	if(registryDriveIndex != KErrNotFound)
       
   556 		{
       
   557 		aDllList = (*aRegistryData.iRegistrations)[registryDriveIndex]->iDllList;
       
   558 		}
       
   559 	return registryDriveIndex;
       
   560 }
       
   561 
       
   562 /**
       
   563 Indicates whether the language downgrade path has been changed during start-up time.
       
   564 @param		aRegData RegistryData object under test
       
   565 @return		ETrue if index is valid EFalse otherwise
       
   566 */
       
   567 TBool TRegistryData_StateAccessor::IsLanguageInitChanged(CRegistryData& aRegistryData)
       
   568 {
       
   569 	return aRegistryData.iLanguageChanged;
       
   570 }
       
   571 
       
   572 TInt TRegistryData_StateAccessor::DrivesRemoved(CRegistryData& aRegistryData)
       
   573 	{
       
   574 		return aRegistryData.iRemovedDrives;
       
   575 	}
       
   576 
       
   577 /** class to hold all the data required to create an instance of
       
   578 CRegistryData::CImplementationData.
       
   579 NB: the pointers in this struct are all owned by some other objects.
       
   580 */
       
   581 _LIT8(KDefaultImplDataType, "Data Type");
       
   582 _LIT8(KDefaultImplOpaqueData, "");
       
   583 
       
   584 struct TImplCreationStruct
       
   585 	{
       
   586 	TImplCreationStruct(TDriveNumber aDriveNumber,
       
   587 						TUid  aInterfaceUid,
       
   588 						TUid  aImplUid,
       
   589 						const TDesC& aDllPathName,
       
   590 						const TDesC& aImplDisplayName,
       
   591 						const TDesC8& aImplDataType = KDefaultImplDataType,
       
   592 						const TDesC8& aImplOpaqueData = KDefaultImplOpaqueData,
       
   593 						TInt  aImplVersion = 1,
       
   594 						TBool aRomBased = EFalse,
       
   595 						TBool aRomOnly = EFalse);
       
   596 
       
   597 	TDriveUnit		iDriveUnit;
       
   598 	TUid			iInterfaceUid;
       
   599 	TUid			iImplUid;
       
   600 	const TDesC&	iDllPathName;
       
   601 	const TDesC&	iImplDisplayName;
       
   602 	const TDesC8&	iImplDataType;
       
   603 	const TDesC8&	iImplOpaqueData;
       
   604 	TInt			iDriveIndex;
       
   605 	CRegistryData::CDriveData*		iDriveData;
       
   606 	CRegistryData::CDllData*		iDllData;
       
   607 	CRegistryData::CInterfaceData*	iInterfaceData;
       
   608 	CRegistryData::CImplementationData* iImplData;
       
   609 	TInt			iImplVersion;
       
   610 	TBool			iRomBased;
       
   611 	TBool			iRomOnly;
       
   612 	};
       
   613 
       
   614 // TImplCreationStruct Constructor
       
   615 TImplCreationStruct::TImplCreationStruct(TDriveNumber aDriveNumber,
       
   616 										TUid  aInterfaceUid,
       
   617 										TUid  aImplUid,
       
   618 										const TDesC& aDllPathName,
       
   619 										const TDesC& aImplDisplayName,
       
   620 										const TDesC8& aImplDataType,
       
   621 										const TDesC8& aImplOpaqueData,
       
   622 										TInt  aImplVersion,
       
   623 										TBool aRomBased,
       
   624 										TBool aRomOnly)
       
   625 	: iDriveUnit(aDriveNumber), iInterfaceUid(aInterfaceUid),
       
   626 	iImplUid(aImplUid), iDllPathName(aDllPathName),
       
   627 	iImplDisplayName(aImplDisplayName), iImplDataType(aImplDataType),
       
   628 	iImplOpaqueData(aImplOpaqueData), iDriveIndex(KErrNotFound),
       
   629 	iDriveData(NULL), iDllData(NULL), iInterfaceData(NULL),
       
   630 	iImplData(NULL), iImplVersion(aImplVersion), iRomBased(aRomBased),
       
   631 	iRomOnly(aRomOnly)
       
   632 	{
       
   633 	}
       
   634 
       
   635 /**
       
   636 Test class encloses necessary members that aid to test CRegistryData
       
   637 */
       
   638 class CRegistryDataTest: public CBase
       
   639 	{
       
   640 public:
       
   641 	static CRegistryDataTest* NewL(TBool aIsFullDiscovery);
       
   642 
       
   643 	virtual ~CRegistryDataTest();
       
   644 
       
   645 	void AddDllDataPlugIn3TestL();
       
   646 	void AddDllDataTestL();
       
   647 
       
   648 	void IsRegisteredWithDateUpdateDllDataTestL();
       
   649 	void CopyOrgPlugInL();
       
   650 	void UpdateDllDataTest1L();
       
   651 	void UpdateDllDataTest2L();
       
   652 	void UpdateDllDataTest3L();
       
   653 
       
   654 	void SetEnabledStateTestL();
       
   655 
       
   656 	void FindImplementationTestL();
       
   657 	//Test for ListImplementationsL() in CRegistryData
       
   658 	void ListImplementationsL();
       
   659 	//Test for ListImplementationsL() in CRegistryResolverTransaction
       
   660 	void ListImplementationsTestT1L();
       
   661 	void ListImplementationsTestT2L();
       
   662 	void ListImplementationsTestT3L();
       
   663 	void ListImplementationsTestT4L();
       
   664 	void ListImplementationsTestT5L();
       
   665 
       
   666 	//Test for ListExtendedInterfacesL() in CRegistryData
       
   667 	void ListExtendedInterfacesTestL();
       
   668 
       
   669 	void DoUndoTemporaryUninstallTestL();
       
   670 
       
   671 	void DiscoveriesBeginCompleteTestL();
       
   672 
       
   673 	void IndexedFindTestL();
       
   674 
       
   675 	void GetImplementationDllInfoForServerTest();
       
   676 
       
   677 	void GetImplementationDllInfoForClientTestL();
       
   678 
       
   679 	void GetImplementationDllInfoForServerPlugIn3Test();
       
   680 
       
   681 	void GetImplementationDllInfoForClientPlugIn3TestL();
       
   682 
       
   683 	void VerifySelectNewPluginTypeL();
       
   684 
       
   685 	void AllAtOnceDiscoveryStateTransitionTestL();
       
   686 
       
   687 	void StagedDiscoveryStateTransitionTestL();
       
   688 
       
   689 	void ImplementationDataTestL();
       
   690 
       
   691 	void InsertIntoIndexRemoveFromIndexTestL();
       
   692 
       
   693 	void RollbackTestL();
       
   694 
       
   695 	void ProcessSecurityCheckTestL();
       
   696 
       
   697 	void FailedSecurityCheckTestListImplementationsL();
       
   698 
       
   699 	void FailedSecurityCheckTestGetImplementationInfoL();
       
   700 
       
   701 	void IsAnyDllDiscoveredTestL();
       
   702 	void IsAnyDllDiscoveredTestNoSpiL();
       
   703 	void IsAnyDllDiscoveredTestWithSpiL();
       
   704 
       
   705 	void CheckDuplicatPluginsOnCL();
       
   706 
       
   707 	void CheckNoPluginsOnCL();
       
   708 
       
   709 	void DuplicateImplUidTestL();
       
   710 	void TestDuplicatedImplPrecedenceL(const TImplCreationStruct& highprecedence,
       
   711 									const TImplCreationStruct& lowprecedence);
       
   712 
       
   713 	static TBool SpiFileExists();
       
   714 
       
   715 	void LanguageChangedTestL();
       
   716 
       
   717 	void DrivesRemovedTestL();
       
   718 private:
       
   719 	CRegistryDataTest();
       
   720 
       
   721 	void ConstructL(TBool aIsFullDiscovery);
       
   722 
       
   723 	void CreateImplL(TImplCreationStruct& aCreationData);
       
   724 public:
       
   725 	/** The instance of the class under test */
       
   726 	CRegistryData*						iRegistryData;
       
   727 
       
   728 	/** Registrar observer test class */
       
   729 	TRegistrarObserverStub* iRegistrarObserver;
       
   730 
       
   731 	/** CRegistrar required for populating the CRegistryData */
       
   732 	CRegistrar*							iRegistrar;
       
   733 	/** CRegistrar state accessor */
       
   734 	TRegistrar_StateAccessor* iRegistrarAccessor;
       
   735 
       
   736 	/** A list of returned UIDs from the list methods */
       
   737 	RImplInfoArray*						iUidList;
       
   738 
       
   739 	/** A list of implementation data from the list methods */
       
   740 	RImplDataArray						iImplDataList;
       
   741 
       
   742 	/** Friend class pointer used for accessing private members */
       
   743 	TRegistryData_StateAccessor*		iStateAccessor;
       
   744 
       
   745 	/** The current drive unit identifier */
       
   746 	TDriveUnit							iDriveUnit;
       
   747 
       
   748 	/** UID for an implementation of an interface */
       
   749 	TUid								iImplementationUid;
       
   750 
       
   751 	/** UID to identify a particular interface */
       
   752 	TUid								iInterfaceUid;
       
   753 
       
   754 	/** The directory entry data for a dll */
       
   755 	TEntry								iDllEntry;
       
   756 
       
   757 	/** Flag to indicate if the registry entry requires an update */
       
   758 	TBool								iUpdate;
       
   759 
       
   760 	/** The drive index returned by IsRegistered... so we know which drive to update on */
       
   761 	TInt								iFoundDriveIndex;
       
   762 
       
   763 	};
       
   764 
       
   765 /**
       
   766 Creates a new CRegistryDataTest object
       
   767 @param		aIsFullDriveCDiscovery whether the constructor make full discovery on Drive C
       
   768 @return		A pointer to the newly created class.
       
   769 */
       
   770 CRegistryDataTest* CRegistryDataTest::NewL(TBool aIsFullDriveCDiscovery)
       
   771 	{
       
   772 	CRegistryDataTest* self = new (ELeave) CRegistryDataTest();
       
   773 	CleanupStack::PushL(self);
       
   774 	self->ConstructL(aIsFullDriveCDiscovery);
       
   775 	CleanupStack::Pop();
       
   776 	return self;
       
   777 	}
       
   778 
       
   779 /**
       
   780 Standardized default constructor
       
   781 @post		CRegistryDataTest is fully constructed.
       
   782 */
       
   783 CRegistryDataTest::CRegistryDataTest()
       
   784 :	CBase()
       
   785 	{
       
   786 	iDriveUnit = EDriveC;
       
   787 
       
   788 	TUid thirdUid = {0x101F847B};
       
   789 
       
   790 	iDllEntry.iType = TUidType(KNullUid, KNullUid, thirdUid);
       
   791 	iDllEntry.iName = KEComExDllOnC;
       
   792 
       
   793 	iInterfaceUid.iUid		= KCExampleInterfaceUid.iUid;
       
   794 	iImplementationUid.iUid	= KCExampleInterfaceImp.iUid;
       
   795 	}
       
   796 
       
   797 /**
       
   798 Standardized 2nd(Initialization) phase of two phase construction.
       
   799 Completes the safe construction of the CRegistryDataTest object
       
   800 @param		aIsFullDriveCDiscovery whether the constructor make full discovery on Drive C
       
   801 @post		CRegistryDataTest is fully constructed.
       
   802 @leave		KErrNoMemory.
       
   803 */
       
   804 void CRegistryDataTest::ConstructL(TBool aIsFullDriveCDiscovery)
       
   805 	{
       
   806 	iUidList = new(ELeave) RImplInfoArray;
       
   807 	iStateAccessor= new(ELeave) TRegistryData_StateAccessor;
       
   808 	iRegistryData = CRegistryData::NewL(TheFs);
       
   809 	iRegistrarObserver=new (ELeave) TRegistrarObserverStub;
       
   810 	iRegistrarAccessor=new (ELeave) TRegistrar_StateAccessor;
       
   811 	iRegistrar=CRegistrar::NewL(*iRegistryData, *iRegistrarObserver, TheFs);
       
   812 	if (aIsFullDriveCDiscovery)
       
   813 		{
       
   814 		TDriveUnit driveUnitC = EDriveC;
       
   815 		iRegistrarAccessor->ScanDriveL(*iRegistrar,driveUnitC);
       
   816 		}
       
   817 	}
       
   818 
       
   819 /**
       
   820 Standard destructor
       
   821 */
       
   822 CRegistryDataTest::~CRegistryDataTest()
       
   823 	{
       
   824 	delete iUidList;
       
   825 	delete iStateAccessor;
       
   826 	delete iRegistrarAccessor;
       
   827 	delete iRegistrar;
       
   828 	delete iRegistrarObserver;
       
   829 	delete iRegistryData;
       
   830 	}
       
   831 
       
   832 /**
       
   833  @return ETrue if the ECom.spi file exists on Z drive, EFalse if it does not
       
   834 */
       
   835 TBool CRegistryDataTest::SpiFileExists()
       
   836 	{
       
   837 	TEntry entry;
       
   838 	if (TheFs.Entry(TheEComSpiFilePathAndNamePtrC, entry) == KErrNone)
       
   839 		{
       
   840 		return ETrue;
       
   841 		}
       
   842 	return EFalse;
       
   843 	}
       
   844 
       
   845 /**
       
   846 @SYMTestCaseID          SYSLIB-ECOM-UT-3712
       
   847 @SYMTestCaseDesc	    Tests for AddExtendedInterfaceL when adding duplicate extended interface Uid.
       
   848 @SYMTestPriority 	    High
       
   849 @SYMTestActions  	    Call CImplementationInformation::AddExtendedInterfaceL() with duplicate extended
       
   850 						interface Uid.
       
   851 						AddExtendedInterfacePanicL() and ThreadPanicTest() are used for this test case.
       
   852 @SYMTestExpectedResults Ensure that the AddExtendedInterfaceL panics in debug mode, but duplicate extended
       
   853 						interface is ignored in release mode.
       
   854 @SYMDEF                 DEF111196
       
   855 */
       
   856 LOCAL_C void AddExtendedInterfaceTestL()
       
   857 	{
       
   858 	
       
   859 	// Test Starts...
       
   860 	TUid testImplUid;
       
   861 	testImplUid.iUid = KCExampleInterfaceUid.iUid;
       
   862 	TInt testImplVersion = 2;
       
   863 	_LIT(KTestImplName, "Implementation");
       
   864 	_LIT8(KTestImplDataType, "Data Type");
       
   865 	_LIT8(KTestImplOpaqueData, "Opaque Data");
       
   866 	TUid testExtendedInterfaceUid1;
       
   867 	TUid testExtendedInterfaceUid2;
       
   868 	testExtendedInterfaceUid1.iUid = 0x10009E44;
       
   869 	testExtendedInterfaceUid2.iUid = 0x10009E45;
       
   870 
       
   871 	TDriveUnit testImplDrive = EDriveC;
       
   872 	TBool testImplRomOnly = ETrue;
       
   873 	TBool testImplRomBased = EFalse;
       
   874 
       
   875 	CRegistryData* registryData = CRegistryData::NewL(TheFs);
       
   876 	CleanupStack::PushL(registryData);
       
   877 	CRegistryData::CDriveData* driveData = CRegistryData::CDriveData::NewLC(testImplDrive, registryData);
       
   878 	CRegistryData::CDllData* dllData = CRegistryData::CDllData::NewLC(driveData);
       
   879 	CRegistryData::CInterfaceData* interfaceData = CRegistryData::CInterfaceData::NewLC(dllData);
       
   880 
       
   881 	// NewL test
       
   882 	HBufC* name = KTestImplName().AllocLC();
       
   883 	HBufC8* dataType = KTestImplDataType().AllocLC();
       
   884 	HBufC8* opaqueData = KTestImplOpaqueData().AllocLC();
       
   885 
       
   886 	RArray<TUid>* extendedInterfaces = new(ELeave) RArray<TUid>;
       
   887 
       
   888 	CleanupStack::PushL(TCleanupItem(CloseAndDeleteArray, extendedInterfaces));
       
   889 
       
   890 	CRegistryData::CImplementationData* implementationData;
       
   891 	implementationData = CRegistryData::CImplementationData::NewL(interfaceData,
       
   892 															testImplUid,
       
   893 															testImplVersion,
       
   894 															name,
       
   895 															dataType,
       
   896 															opaqueData,
       
   897 															testImplDrive,
       
   898 															testImplRomOnly,
       
   899 															testImplRomBased,
       
   900 															extendedInterfaces);
       
   901 
       
   902 	CleanupStack::Pop(extendedInterfaces);
       
   903 	CleanupStack::Pop(opaqueData);
       
   904 	CleanupStack::Pop(dataType);
       
   905 	CleanupStack::Pop(name);
       
   906 
       
   907 	CleanupStack::PushL(implementationData);
       
   908 	TEST(interfaceData == implementationData->iParent);
       
   909 
       
   910 	//Add extended interface
       
   911 	implementationData->iImplInfo->AddExtendedInterfaceL(testExtendedInterfaceUid1);
       
   912 	implementationData->iImplInfo->AddExtendedInterfaceL(testExtendedInterfaceUid2);
       
   913 	const RArray<TUid>* extendedInterfacesList = implementationData->iImplInfo->GetExtendedInterfaceList();
       
   914 	TEST(extendedInterfacesList->Count() == 2);
       
   915 	RDebug::Printf("Number of extended interfaces = %d",extendedInterfacesList->Count());
       
   916 	// Add duplicate extended interface, will panic in debug mode, but duplicate extended interface
       
   917 	// is ignored in release mode
       
   918 	implementationData->iImplInfo->AddExtendedInterfaceL(testExtendedInterfaceUid2);
       
   919 
       
   920 #ifdef NDEBUG
       
   921 	const RArray<TUid>* extendedInterfacesList1 = implementationData->iImplInfo->GetExtendedInterfaceList();
       
   922 	TEST(extendedInterfacesList1->Count() == 2);
       
   923 	RDebug::Printf("Number of extended interfaces after adding duplicate extended interface = %d",extendedInterfacesList->Count());
       
   924 #endif
       
   925 	// Tidy up
       
   926 	CleanupStack::PopAndDestroy(5, registryData);
       
   927 
       
   928 	// Test Ends...
       
   929 	}
       
   930 
       
   931 LOCAL_C TInt AddExtendedInterfacePanicL(TAny*)
       
   932 	{
       
   933 	__UHEAP_MARK;
       
   934 	CTrapCleanup* threadcleanup = CTrapCleanup::New();
       
   935 	TRAPD(err,AddExtendedInterfaceTestL());
       
   936 	TEST(err==KErrNone);
       
   937 	delete threadcleanup;
       
   938 	__UHEAP_MARKEND;
       
   939 	return KErrNone;
       
   940 	}
       
   941 
       
   942 /**
       
   943 The test code is used for capturing the PANIC that occurs as a result of calling AddExtendedInterfaceL
       
   944 with duplicate extended interface Uid .
       
   945 */
       
   946 LOCAL_C void ThreadPanicTest(const TDesC& aName,TThreadFunction aFunction)
       
   947 	{
       
   948 	TRequestStatus threadStatus;
       
   949 	RThread thread;
       
   950 	TBool jit;
       
   951 	jit=User::JustInTime();
       
   952 	User::SetJustInTime(EFalse);
       
   953 
       
   954 	// Default stack size was doubled for X86, so reduce this multiplier to prevent panic
       
   955 #ifdef __X86GCC__
       
   956 	TInt err=thread.Create(aName,aFunction,KDefaultStackSize*4,KMinHeapSize,0x100000,0);
       
   957 #else
       
   958 	TInt err=thread.Create(aName,aFunction,KDefaultStackSize*8,KMinHeapSize,0x100000,0);
       
   959 #endif	
       
   960 	TEST(err==KErrNone);
       
   961 	thread.Logon(threadStatus)	;
       
   962 	thread.Resume();
       
   963 
       
   964 	User::WaitForRequest(threadStatus);
       
   965 
       
   966 	//Now check why the thread Exit
       
   967 	// There is Assert_Debug check for the duplicate extended interface Uid for AddExtendedInterfaceL(),
       
   968 	// Therefore, the panic reason would be KErrAlreadyExists for debug mode.
       
   969 	// in release mode, the duplicate extended interface is ignored.
       
   970 #ifdef _DEBUG
       
   971 	RDebug::Printf("Thread status: %d", thread.ExitType());
       
   972 	TEST(thread.ExitType()==EExitPanic);
       
   973 	TEST(thread.ExitReason()==EEComPanic_CImlpementationInfromation_DuplicateExIf);
       
   974 #else
       
   975 	RDebug::Printf("Thread status: %d", thread.ExitType());
       
   976 	TEST(thread.ExitType()==EExitKill);
       
   977 #endif
       
   978 	CLOSE_AND_WAIT(thread);
       
   979 	User::SetJustInTime(jit);
       
   980 	}
       
   981 
       
   982 
       
   983 /**
       
   984 Plugins to be used in this test
       
   985 Interface UID	DLL	UID		Implementation UID	Version		DLL Type	Extended Interfaces
       
   986 --------------------------------------------------------------------------------
       
   987 0x10009E36		0x10009E3E	0x10009E39				1		PLUGIN3		{0x10009E44, 0x10009E45, 0x10009E46}
       
   988 				0x10009E3E	0x10009E3C				1		PLUGIN3		{}
       
   989 				0x10009E3E	0x10009E3D				1		PLUGIN3		{0x10009E44}
       
   990 0x10009DC0		0x101F847B	0x101F847C				1		PLUGIN1		NULL
       
   991 
       
   992 @SYMTestCaseID          SYSLIB-ECOM-UT-3575
       
   993 @SYMTestCaseDesc	    Tests for CImplementationInformation::GetExtendedInterfaceList() and
       
   994 						CImplementationInformation::GetExtendedInterfaceListL() functions. Makes sure that
       
   995 						results from both of the functions are identical.
       
   996 @SYMTestPriority 	    High
       
   997 @SYMTestActions  	    List the extended interfaces for a valid implementation UID
       
   998 						List the extended interfaces for a non-existing implementation UID
       
   999 						List the extended interfaces for a valid PLUGIN1 implementation UID
       
  1000 @SYMTestExpectedResults Expected extended interfaces are returned.
       
  1001 @SYMEC                  EC43
       
  1002 @SYMDEF					DEF111196
       
  1003 */
       
  1004 void CRegistryDataTest::ListExtendedInterfacesTestL()
       
  1005 	{
       
  1006 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3575 "));
       
  1007 	TUid ImpUid = {0x10009E39};
       
  1008 	TUid ImpUid1 = {0x10009E3C};
       
  1009 	TUid ImpUidPLUGIN1 = {0x101F847C};
       
  1010  	TUid extendedInterfacesUid[] = {0x10009E44,0x10009E45,0x10009E46};
       
  1011  	TEntry dllinfo;
       
  1012  	TInt err;
       
  1013  	TClientRequest clntRq;
       
  1014 
       
  1015  	//Gets the Implementation Information for a valid implementation UID with extended interfaces
       
  1016  	CImplementationInformation* implementationInfo=NULL;
       
  1017  	TRAP(err,iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid, KCDummyUid, dllinfo, implementationInfo, ETrue));
       
  1018  	TEST_OOM_ERR;
       
  1019  	TEST2(err, KErrNone);
       
  1020  	TEST(implementationInfo->ImplementationUid() == ImpUid);
       
  1021 
       
  1022  	//Gets the list of extended Interfaces
       
  1023  	RArray<TUid>* extendedInterfaces = implementationInfo->GetExtendedInterfaceList();
       
  1024 
       
  1025  	//Checks the extended interfaces list
       
  1026  	TEST(extendedInterfaces != NULL);
       
  1027 	for (TInt i = 0; i < extendedInterfaces->Count(); i++)
       
  1028 		{
       
  1029 		TEST((*extendedInterfaces)[i] == extendedInterfacesUid[i]);
       
  1030 		}
       
  1031 
       
  1032 	// Uses the GetExtendedInterfaceListL API to get the extended interface.
       
  1033 	RArray<TUid> extendedInterfacesAPI;
       
  1034 	CleanupClosePushL(extendedInterfacesAPI);
       
  1035 	implementationInfo->GetExtendedInterfaceListL(extendedInterfacesAPI);
       
  1036 	// Makes sure that the list return is the same as the one return from GetExtendedInterfaceList.
       
  1037 	TEST(extendedInterfacesAPI.Count() == extendedInterfaces->Count());
       
  1038 	for (TInt i = 0; i < extendedInterfaces->Count(); i++)
       
  1039 		{
       
  1040 		TEST((*extendedInterfaces)[i] == extendedInterfacesAPI[i]);
       
  1041 		}
       
  1042 	CleanupStack::PopAndDestroy(&extendedInterfacesAPI);
       
  1043 
       
  1044 	//Gets the Implementation Information for a valid implementation UID without extended interfaces
       
  1045  	TRAP(err,iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid1, KCDummyUid, dllinfo, implementationInfo, ETrue));
       
  1046  	TEST_OOM_ERR;
       
  1047  	TEST2(err, KErrNone);
       
  1048  	TEST(implementationInfo->ImplementationUid() == ImpUid1);
       
  1049 
       
  1050  	//Gets the list of extended Interfaces
       
  1051 	extendedInterfaces = implementationInfo->GetExtendedInterfaceList();
       
  1052  	TEST(extendedInterfaces->Count() == 0);
       
  1053 
       
  1054 	// Uses the GetExtendedInterfaceListL API to get the extended interface.
       
  1055 	RArray<TUid> extendedInterfacesAPI1;
       
  1056 	CleanupClosePushL(extendedInterfacesAPI1);
       
  1057 	implementationInfo->GetExtendedInterfaceListL(extendedInterfacesAPI1);
       
  1058 	// Makes sure that the list return is the same as the one return from GetExtendedInterfaceList.
       
  1059 	TEST(extendedInterfacesAPI1.Count() == extendedInterfaces->Count());
       
  1060 	for (TInt i = 0; i < extendedInterfaces->Count(); i++)
       
  1061 		{
       
  1062 		TEST((*extendedInterfaces)[i] == extendedInterfacesAPI1[i]);
       
  1063 		}
       
  1064 	CleanupStack::PopAndDestroy(&extendedInterfacesAPI1);
       
  1065 
       
  1066 	//Gets the Implementation Information for a non-existing implementation UID
       
  1067 	TRAP(err,iRegistryData->GetImplementationDllInfoForClientL(clntRq, KCInvalidUid, KCDummyUid, dllinfo, implementationInfo, ETrue));
       
  1068 	TEST_OOM_ERR;
       
  1069 	TEST2(err,KErrNone);
       
  1070 	TEST(implementationInfo == NULL);
       
  1071 
       
  1072 	//Gets the Implementation Information for a valid PLUGIN1 implementation UID without extended interfaces
       
  1073  	TRAP(err,iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUidPLUGIN1, KCDummyUid, dllinfo, implementationInfo, ETrue));
       
  1074  	TEST_OOM_ERR;
       
  1075  	TEST2(err, KErrNone);
       
  1076  	TEST(implementationInfo->ImplementationUid() == ImpUidPLUGIN1);
       
  1077 
       
  1078  	//Gets the list of extended Interfaces
       
  1079 	extendedInterfaces = implementationInfo->GetExtendedInterfaceList();
       
  1080  	TEST(extendedInterfaces == NULL);
       
  1081 
       
  1082 	// Uses the GetExtendedInterfaceListL API to get the extended interface.
       
  1083 	RArray<TUid> extendedInterfacesAPI2;
       
  1084 	CleanupClosePushL(extendedInterfacesAPI2);
       
  1085 	implementationInfo->GetExtendedInterfaceListL(extendedInterfacesAPI2);
       
  1086 	// Makes sure that the list return is the same as the one return from GetExtendedInterfaceList.
       
  1087 	TEST(extendedInterfacesAPI2.Count() == 0);
       
  1088 	CleanupStack::PopAndDestroy(&extendedInterfacesAPI2);
       
  1089 	}
       
  1090 
       
  1091 
       
  1092 /**
       
  1093 The interface Uid 0x10009E36 has 5 implementations on different DLLs(EComExample12.dll,EComExample14.dll and EComExample15.dll).
       
  1094 0x10009E3D is said to be ROM-Only, it will not be created. 0x10009E39 has higher version in EComExample15.
       
  1095 Interface UID	DLL	UID		Implementation UID	Version		DLL Type	Extended Interfaces
       
  1096 --------------------------------------------------------------------------------
       
  1097 0x10009E36		0x10009E40	0x10009E48				1		PLUGIN1		None
       
  1098 				0x10009E3E	0x10009E39				1		PLUGIN3		{0x10009E44, 0x10009E45, 0x10009E46}
       
  1099 				0x10009E3E	0x10009E3C				1		PLUGIN3		{}
       
  1100 				0x10009E3E	0x10009E3D				1		PLUGIN3		{0x10009E44}
       
  1101 				0x10009E42	0x10009E39				2		PLUGIN3		{0x10009E44, 0x10009E45, 0x10009E46}
       
  1102 
       
  1103 @SYMTestCaseID          SYSLIB-ECOM-UT-3580
       
  1104 @SYMTestCaseDesc	    Tests for CRegistryResolveTransaction::ListImplementationsL() function with matches
       
  1105 						that fall into a PLUGIN1 Dll and PLUGIN3. The extended interface list will not be populated
       
  1106 @SYMTestPriority 	    High
       
  1107 @SYMTestActions  	    List the implementations for an interface UID and a set of extended interfaces.
       
  1108 						Check the VID of every implementation matches the VID of the DLL which the implementation
       
  1109                         belongs to.
       
  1110 @SYMTestExpectedResults Expected matches are returned from both PLUGIN1 and PLUGIN3.
       
  1111 @SYMEC                  EC43
       
  1112 */
       
  1113 void CRegistryDataTest::ListImplementationsTestT5L()
       
  1114 	{
       
  1115 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3580 "));
       
  1116 	const TUid KInterfaceUid = {0x10009E36};
       
  1117 
       
  1118 	TEST(iRegistryData->IndexValid());
       
  1119 	// Set up client request and extended interfaces
       
  1120 	TClientRequest clientReq;
       
  1121 	RArray<TUid> extendedInterfaces;
       
  1122 	CleanupClosePushL(extendedInterfaces);
       
  1123 	TBool capability= ETrue;
       
  1124 	CRegistryResolveTransaction* registryResolveTransaction = CRegistryResolveTransaction::NewL(*iRegistryData,extendedInterfaces,clientReq,capability);
       
  1125 	CleanupStack::PushL(registryResolveTransaction);
       
  1126 	RImplInfoArray* iUidListPtr = NULL;
       
  1127 	TRAPD(err, iUidListPtr = &(registryResolveTransaction->ListImplementationsL(KInterfaceUid)));
       
  1128 
       
  1129 	TEST_OOM_ERR;
       
  1130 	TEST2(err, KErrNone);
       
  1131 
       
  1132 	// Prints UIDs of implementations
       
  1133 	_LIT(KUIDFormat,"Uid = 0x%08x\n");
       
  1134 	_LIT(KLists,"There are %d Implementations \n");
       
  1135 
       
  1136 	TheTest.Printf(KLists, iUidListPtr->Count());
       
  1137 	// Tests for expected number of implementations.
       
  1138 	TEST(iUidListPtr->Count() == 3);
       
  1139 
       
  1140 	for(TInt index = 0; index < iUidListPtr->Count(); ++index)
       
  1141 		{
       
  1142 		// check VID of every implementation
       
  1143 		TEST(((*(iUidListPtr))[index]->VendorId()).iId == 0x70000001);
       
  1144 		TUid uid = (*(iUidListPtr))[index]->ImplementationUid();
       
  1145 		TheTest.Printf(KUIDFormat, uid);
       
  1146 		}
       
  1147 	CleanupStack::PopAndDestroy(registryResolveTransaction);
       
  1148 	CleanupStack::PopAndDestroy(&extendedInterfaces);
       
  1149 	}
       
  1150 /**
       
  1151 The interface Uid 0x10009E36 has 5 implementations on different DLLs(EComExample12.dll,EComExample14.dll and EComExample15.dll).
       
  1152 0x10009E3D is said to be ROM-Only, it will not be created. 0x10009E39 has higher version in EComExample15.
       
  1153 Interface UID	DLL	UID		Implementation UID	Version	DLL Type	Extended Interfaces
       
  1154 -------------------------------------------------------------------------------------------------------
       
  1155 0x10009E36		0x10009E40	0x10009E48			1		PLUGIN1		None
       
  1156 				0x10009E3E	0x10009E39			1		PLUGIN3		{0x10009E44, 0x10009E45, 0x10009E46}
       
  1157 				0x10009E3E	0x10009E3C			1		PLUGIN3		{}
       
  1158 				0x10009E3E	0x10009E3D			1		PLUGIN3		{0x10009E44}
       
  1159 				0x10009E42	0x10009E39			2		PLUGIN3		{0x10009E44, 0x10009E45, 0x10009E46}
       
  1160 
       
  1161 @SYMTestCaseID          SYSLIB-ECOM-UT-3579
       
  1162 @SYMTestCaseDesc	    Tests for CRegistryResolveTransaction::ListImplementationsL() function with matches
       
  1163 						that fall into a PLUGIN1 Dll and PLUGIN3. The extended interface list will be populated
       
  1164 @SYMTestPriority 	    High
       
  1165 @SYMTestActions  	    List the implementations for an interface UID and a set of extended interfaces.
       
  1166 						Check the VID of every implementation match the VID of the DLL which the implementation
       
  1167                         belongs to.
       
  1168 @SYMTestExpectedResults No PLUGIN1 implementations should be returned.
       
  1169 @SYMEC                  EC43
       
  1170 */
       
  1171 void CRegistryDataTest::ListImplementationsTestT4L()
       
  1172 	{
       
  1173 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3579 "));
       
  1174 	const TUid KInterfaceUid = {0x10009E36};
       
  1175 	const TUid KExtendedInterfaceUid = {0x10009E44};
       
  1176 
       
  1177 	TEST(iRegistryData->IndexValid());
       
  1178 	//Set up client request and extended interfaces
       
  1179 	TClientRequest clientReq;
       
  1180 	RArray<TUid> extendedInterfaces;
       
  1181 	CleanupClosePushL(extendedInterfaces);
       
  1182 	extendedInterfaces.AppendL(KExtendedInterfaceUid);
       
  1183 	TBool capability= ETrue;
       
  1184 	CRegistryResolveTransaction* registryResolveTransaction = CRegistryResolveTransaction::NewL(*iRegistryData,extendedInterfaces,clientReq,capability);
       
  1185 	CleanupStack::PushL(registryResolveTransaction);
       
  1186 	RImplInfoArray* iUidListPtr = NULL;
       
  1187 	TRAPD(err, iUidListPtr = &(registryResolveTransaction->ListImplementationsL(KInterfaceUid)));
       
  1188 
       
  1189 	TEST_OOM_ERR;
       
  1190 	TEST2(err, KErrNone);
       
  1191 
       
  1192 	// Prints UIDs of implementations
       
  1193 	_LIT(KUIDFormat,"Uid = 0x%08x\n");
       
  1194 	_LIT(KLists,"There are %d Implementations \n");
       
  1195 
       
  1196 	TheTest.Printf(KLists, iUidListPtr->Count());
       
  1197 	// Tests for expected number of implementations.
       
  1198 	TEST(iUidListPtr->Count() == 1);
       
  1199 
       
  1200 	for(TInt index = 0; index < iUidListPtr->Count(); ++index)
       
  1201 		{
       
  1202 		// check VID of every implementation
       
  1203 		TEST(((*(iUidListPtr))[index]->VendorId()).iId == 0x70000001);
       
  1204 		TUid uid = (*(iUidListPtr))[index]->ImplementationUid();
       
  1205 		TheTest.Printf(KUIDFormat, uid);
       
  1206 		}
       
  1207 	CleanupStack::PopAndDestroy(registryResolveTransaction);
       
  1208 	CleanupStack::PopAndDestroy(&extendedInterfaces);
       
  1209 	}
       
  1210 
       
  1211 /**
       
  1212 @SYMTestCaseID          SYSLIB-ECOM-UT-3578
       
  1213 @SYMTestCaseDesc	    Tests for CRegistryResolveTransaction::ListImplementationsL() function with invalid interface id.
       
  1214 @SYMTestPriority 	    High
       
  1215 @SYMTestActions  	    List the implementations for an invalid interface UID and valid extended interfaces.
       
  1216 @SYMTestExpectedResults No implementation is returned.
       
  1217 @SYMEC                  EC43
       
  1218 */
       
  1219 void CRegistryDataTest::ListImplementationsTestT3L()
       
  1220 	{
       
  1221 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3578 "));
       
  1222 	const TUid KExtendedInterfaceUid = {0x10009E44};
       
  1223 
       
  1224 	TEST(iRegistryData->IndexValid());
       
  1225 	//Set up client request and extended interfaces
       
  1226 	TClientRequest clientReq;
       
  1227 	RArray<TUid> extendedInterfaces;
       
  1228 	CleanupClosePushL(extendedInterfaces);
       
  1229 	extendedInterfaces.AppendL(KExtendedInterfaceUid);
       
  1230 	TBool capability= ETrue;
       
  1231 	CRegistryResolveTransaction* registryResolveTransaction = CRegistryResolveTransaction::NewL(*iRegistryData,extendedInterfaces,clientReq,capability);
       
  1232 	CleanupStack::PushL(registryResolveTransaction);
       
  1233 	TRAPD(err, RImplInfoArray*	iUidListPtr = &(registryResolveTransaction->ListImplementationsL(KCInvalidUid)));
       
  1234 
       
  1235 	TEST_OOM_ERR;
       
  1236 	TEST2(err, KEComErrNoInterfaceIdentified);
       
  1237 	TheTest.Printf(_L("No Implementation is found.\n"));
       
  1238 	CleanupStack::PopAndDestroy(registryResolveTransaction);
       
  1239 	CleanupStack::PopAndDestroy(&extendedInterfaces);
       
  1240 	}
       
  1241 
       
  1242 /**
       
  1243 The interface Uid 0x10009E36 has 5 implementations (EComExample12.dll,EComExample14.dll and EComExample15.dll), but only 1 will
       
  1244 be picked up as 2 of them do not match the extended interfaces criteria (0x10009E3C and 0x10009E48),
       
  1245 1 of them is said to be ROM only but it is on RAM(0x10009E3D), and 1 of them has older version(0x10009E39).
       
  1246 
       
  1247 Interface UID	DLL	UID		Implementation UID	Version		Type	Extended Interfaces
       
  1248 --------------------------------------------------------------------------------------
       
  1249 0x10009E36		0x10009E3E	0x10009E39			1			PlugIn3	{0x10009E44, 0x10009E45, 0x10009E46}
       
  1250 				0x10009E3E	0x10009E3C			1			PlugIn3	{}
       
  1251 				0x10009E3E	0x10009E3D			1			PlugIn3	{0x10009E44}
       
  1252 				0x10009E40	0x10009E48			1			PLUGIN1	None
       
  1253 				0x10009E42	0x10009E39			2			PlugIn3	{0x10009E44, 0x10009E45, 0x10009E46}
       
  1254 
       
  1255 @SYMTestCaseID          SYSLIB-ECOM-UT-3577
       
  1256 @SYMTestCaseDesc	    Tests for CRegistryResolveTransaction::ListImplementationsL() function with matches
       
  1257 						that fall into a PLUGIN3 Dll.
       
  1258 @SYMTestPriority 	    High
       
  1259 @SYMTestActions  	    List the implementations for an existing interface UID and a set of extended interfaces.
       
  1260                         Test for expected number of implementations. Check the VID of every implementation match
       
  1261                         the VID of the DLL which the implementation belongs to.
       
  1262 @SYMTestExpectedResults Expected number of implementations are returned.
       
  1263 @SYMEC                  EC43
       
  1264 */
       
  1265 void CRegistryDataTest::ListImplementationsTestT2L()
       
  1266 	{
       
  1267 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3577 "));
       
  1268 	const TUid KInterfaceUid = {0x10009E36};
       
  1269 	const TUid KExtendedInterfaceUid = {0x10009E44};
       
  1270 
       
  1271 	TEST(iRegistryData->IndexValid());
       
  1272 	// Set up client request and extended interfaces
       
  1273 	TClientRequest clientReq;
       
  1274 	RArray<TUid> extendedInterfaces;
       
  1275 	CleanupClosePushL(extendedInterfaces);
       
  1276 	extendedInterfaces.AppendL(KExtendedInterfaceUid);
       
  1277 	TBool capability= ETrue;
       
  1278 	CRegistryResolveTransaction* registryResolveTransaction = CRegistryResolveTransaction::NewL(*iRegistryData,extendedInterfaces,clientReq,capability);
       
  1279 	CleanupStack::PushL(registryResolveTransaction);
       
  1280 	RImplInfoArray* iUidListPtr = NULL;
       
  1281 	TRAPD(err, iUidListPtr = &(registryResolveTransaction->ListImplementationsL(KInterfaceUid)));
       
  1282 
       
  1283 	TEST_OOM_ERR;
       
  1284 	TEST2(err, KErrNone);
       
  1285 
       
  1286 	// Prints UIDs of implementations
       
  1287 	_LIT(KUIDFormat,"Uid = 0x%08x\n");
       
  1288 	_LIT(KLists,"There are %d Implementations \n");
       
  1289 
       
  1290 	TheTest.Printf(KLists, iUidListPtr->Count());
       
  1291 	// Tests for expected number of implementations.
       
  1292 	TEST(iUidListPtr->Count() == 1);
       
  1293 
       
  1294 	for(TInt index = 0; index < iUidListPtr->Count(); ++index)
       
  1295 		{
       
  1296 		// checks VID of every implementation
       
  1297 		TEST(((*(iUidListPtr))[index]->VendorId()).iId == 0x70000001);
       
  1298 		TUid uid = (*(iUidListPtr))[index]->ImplementationUid();
       
  1299 		TheTest.Printf(KUIDFormat, uid);
       
  1300 		}
       
  1301 	CleanupStack::PopAndDestroy(registryResolveTransaction);
       
  1302 	CleanupStack::PopAndDestroy(&extendedInterfaces);
       
  1303 	}
       
  1304 
       
  1305 
       
  1306 /**
       
  1307 The interface Uid 0x10009DC0 has 6 implementations on different DLLs but only 4 will
       
  1308 be picked up as 2 of them are of older version(Impl ID 0x10009DC3 and 0x10009DC4 with version 1)
       
  1309 
       
  1310 Interface UID	DLL	UID		Implementation UID	Version
       
  1311 -------------------------------------------------------
       
  1312 0x10009DC0		0x10009DB1	0x10009DC3			1
       
  1313 				0x10009DB1	0x10009DC4			1
       
  1314 				0x10009DB3	0x10009DC3			2
       
  1315 				0x10009DB3	0x10009DC4			2
       
  1316 				0x101F8477	0x101F8478			1
       
  1317 				0x101F847B	0x101F847C			1
       
  1318 
       
  1319 @SYMTestCaseID          SYSLIB-ECOM-UT-3576
       
  1320 @SYMTestCaseDesc	    Tests for CRegistryResolveTransaction::ListImplementationsL() function with matches
       
  1321 						that fall into a PLUGIN1 Dll.
       
  1322 @SYMTestPriority 	    High
       
  1323 @SYMTestActions  	    List the implementations for an existing interface UID and
       
  1324                         test for expected number of implementations.Check the VID of
       
  1325                         every implementation match the VID of the DLL which the implementation
       
  1326                         belongs to.
       
  1327 @SYMTestExpectedResults Expected number of implementations are returned.
       
  1328 @SYMEC                  EC43
       
  1329 */
       
  1330 void CRegistryDataTest::ListImplementationsTestT1L()
       
  1331 	{
       
  1332 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3576 "));
       
  1333 	TEST(iRegistryData->IndexValid());
       
  1334 	// Set up client request and extended interfaces
       
  1335 	TClientRequest clientReq;
       
  1336 	RArray<TUid> extendedInterfaces;
       
  1337 	CleanupClosePushL(extendedInterfaces);
       
  1338 	TBool capability= ETrue;
       
  1339 	CRegistryResolveTransaction* registryResolveTransaction = CRegistryResolveTransaction::NewL(*iRegistryData,extendedInterfaces,clientReq,capability);
       
  1340 	CleanupStack::PushL(registryResolveTransaction);
       
  1341 	RImplInfoArray* iUidListPtr = NULL;
       
  1342 	TRAPD(err, iUidListPtr = &(registryResolveTransaction->ListImplementationsL(iInterfaceUid)));
       
  1343 
       
  1344 	TEST_OOM_ERR;
       
  1345 	TEST2(err, KErrNone);
       
  1346 	// Prints UIDs of implementations
       
  1347 	_LIT(KUIDFormat,"Uid = 0x%08x\n");
       
  1348 	_LIT(KLists,"There are %d Implementations \n");
       
  1349 
       
  1350 	TheTest.Printf(KLists, iUidListPtr->Count());
       
  1351 	// Tests for expected number of implementations.
       
  1352 	TEST(iUidListPtr->Count() == 4);
       
  1353 
       
  1354 	for(TInt index = 0; index < iUidListPtr->Count(); ++index)
       
  1355 		{
       
  1356 		// checks VID of every implementation
       
  1357 		TEST(((*(iUidListPtr))[index]->VendorId()).iId == 0x70000001);
       
  1358 		TUid uid = (*(iUidListPtr))[index]->ImplementationUid();
       
  1359 		TheTest.Printf(KUIDFormat, uid);
       
  1360 		}
       
  1361 	CleanupStack::PopAndDestroy(registryResolveTransaction);
       
  1362 	CleanupStack::PopAndDestroy(&extendedInterfaces);
       
  1363 	}
       
  1364 
       
  1365 /** In order to create an instance of CImplementationData, the test
       
  1366 has to create the chain of: drive data, dll data, and interface data.
       
  1367 Use this method to safe the repetitive work.
       
  1368 
       
  1369 This method will not new the CImplementationData's parents if they
       
  1370 have been set. Hence can be used to add an implementation to an
       
  1371 existing interface data.
       
  1372 */
       
  1373 void CRegistryDataTest::CreateImplL(TImplCreationStruct& aCreationData)
       
  1374 	{
       
  1375 	if (aCreationData.iImplData)
       
  1376 	  {
       
  1377 	  // Should not call this method. There is nothing to create.
       
  1378 	  User::Leave(KErrGeneral);
       
  1379 	  }
       
  1380 
       
  1381 	if (! aCreationData.iDriveData || (KErrNotFound == aCreationData.iDriveIndex))
       
  1382 		{
       
  1383         aCreationData.iDriveIndex = iRegistryData->FindDriveL(
       
  1384             aCreationData.iDriveUnit, aCreationData.iDriveData);
       
  1385         if (KErrNotFound == aCreationData.iDriveIndex)
       
  1386             {
       
  1387             aCreationData.iDriveData = CRegistryData::CDriveData::NewLC(
       
  1388                 aCreationData.iDriveUnit, iRegistryData);
       
  1389             iStateAccessor->AppendDriveDataL(*iRegistryData,
       
  1390                                              aCreationData.iDriveData);
       
  1391             CleanupStack::Pop(aCreationData.iDriveData);
       
  1392 
       
  1393             aCreationData.iDriveIndex = iRegistryData->FindDriveL(
       
  1394             	aCreationData.iDriveUnit,aCreationData.iDriveData);
       
  1395             }
       
  1396 		}
       
  1397 
       
  1398 	if (! aCreationData.iDllData)
       
  1399 		{
       
  1400 		if (aCreationData.iInterfaceData)
       
  1401 			{
       
  1402 			User::Leave(KErrGeneral); // can not have child without parent
       
  1403 			}
       
  1404 		TEntry e;
       
  1405 		e.iName = aCreationData.iDllPathName;
       
  1406 		TParse fileparse;
       
  1407 		fileparse.Set(e.iName,NULL,NULL);
       
  1408 		aCreationData.iDllData = CRegistryData::CDllData::NewLC(
       
  1409 			fileparse.NameAndExt(),e.iModified,KNullUid,KNullUid, aCreationData.iDriveData);
       
  1410 		aCreationData.iDllData->iSecurityChecked = ETrue;
       
  1411 		aCreationData.iDriveData->AddL(aCreationData.iDllData);
       
  1412 		CleanupStack::Pop(aCreationData.iDllData);
       
  1413 		}
       
  1414 
       
  1415 	if (!aCreationData.iInterfaceData)
       
  1416 		{
       
  1417 		aCreationData.iInterfaceData = CRegistryData::CInterfaceData::NewLC(
       
  1418 			aCreationData.iInterfaceUid, aCreationData.iDllData);
       
  1419 		aCreationData.iDllData->AddL(aCreationData.iInterfaceData);
       
  1420 		CleanupStack::Pop(aCreationData.iInterfaceData);
       
  1421 		}
       
  1422 
       
  1423 	HBufC* name = aCreationData.iImplDisplayName.AllocLC();
       
  1424 	HBufC8* dataType = aCreationData.iImplDataType.AllocLC();
       
  1425 	HBufC8* opaqueData = aCreationData.iImplOpaqueData.AllocLC();
       
  1426 
       
  1427 	aCreationData.iImplData = CRegistryData::CImplementationData::NewL(
       
  1428 		aCreationData.iInterfaceData,
       
  1429 		aCreationData.iImplUid,
       
  1430 		aCreationData.iImplVersion,
       
  1431 		name,
       
  1432 		dataType,
       
  1433 		opaqueData,
       
  1434 		aCreationData.iDriveUnit,
       
  1435 		aCreationData.iRomOnly,
       
  1436 		aCreationData.iRomBased);
       
  1437 
       
  1438 	CleanupStack::Pop(opaqueData);
       
  1439 	CleanupStack::Pop(dataType);
       
  1440 	CleanupStack::Pop(name);
       
  1441 
       
  1442 	CleanupStack::PushL(aCreationData.iImplData);
       
  1443 	aCreationData.iInterfaceData->AddL(aCreationData.iImplData);
       
  1444 	CleanupStack::Pop(aCreationData.iImplData);
       
  1445 	}
       
  1446 
       
  1447 
       
  1448 /**
       
  1449 @SYMTestCaseID			SYSLIB-ECOM-CT-0290
       
  1450 @SYMTestCaseDesc		Unit tests for CRegistryData::CImplementationData
       
  1451 @SYMTestPriority			High
       
  1452 @SYMTestActions			Create instances using NewLC and NewL. Check that the parent supplied is
       
  1453 						correctly set.
       
  1454 						Externalize instance created by NewL.
       
  1455 						Internalize data set by previous step. Check implementation data is identical.
       
  1456 						Check compare uid returns correct values.
       
  1457 						Check for no crash and memory leaks.
       
  1458 @SYMTestExpectedResults	The test must not fail.
       
  1459 @SYMPREQ				PREQ277
       
  1460 */
       
  1461 void  CRegistryDataTest::ImplementationDataTestL()
       
  1462 	{
       
  1463 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0290 "));
       
  1464 	// Set up for heap leak checking
       
  1465 	__UHEAP_MARK;
       
  1466 
       
  1467 	// and leaking thread handles
       
  1468 	TInt startProcessHandleCount;
       
  1469 	TInt startThreadHandleCount;
       
  1470 	TInt endProcessHandleCount;
       
  1471 	TInt endThreadHandleCount;
       
  1472 
       
  1473 	// Test Starts...
       
  1474 	RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  1475 
       
  1476 	// Test Data
       
  1477 	TUid testImplUid;
       
  1478 	testImplUid.iUid = KCExampleInterfaceUid.iUid;
       
  1479 	TInt testImplVersion = 2;
       
  1480 	_LIT(KTestImplName, "Implementation");
       
  1481 	_LIT8(KTestImplDataType, "Data Type");
       
  1482 	_LIT8(KTestImplOpaqueData, "Opaque Data");
       
  1483 	TUid testExtendedInterfaceUid1;
       
  1484 	TUid testExtendedInterfaceUid2;
       
  1485 	testExtendedInterfaceUid1.iUid = 0x10009E44;
       
  1486 	testExtendedInterfaceUid2.iUid = 0x10009E45;
       
  1487 
       
  1488 	TDriveUnit testImplDrive = EDriveC;
       
  1489 	TBool testImplRomOnly = ETrue;
       
  1490 	TBool testImplRomBased = EFalse;
       
  1491 
       
  1492 	CRegistryData* registryData = CRegistryData::NewL(TheFs);
       
  1493 	CleanupStack::PushL(registryData);
       
  1494 	CRegistryData::CDriveData* driveData = CRegistryData::CDriveData::NewLC(testImplDrive, registryData);
       
  1495 	CRegistryData::CDllData* dllData = CRegistryData::CDllData::NewLC(driveData);
       
  1496 	CRegistryData::CInterfaceData* interfaceData = CRegistryData::CInterfaceData::NewLC(dllData);
       
  1497 
       
  1498 	// Start tests...
       
  1499 	// NewLC test
       
  1500 	CRegistryData::CImplementationData* implementation1;
       
  1501 	implementation1 = CRegistryData::CImplementationData::NewLC(interfaceData);
       
  1502 	TEST(interfaceData == implementation1->iParent);
       
  1503 
       
  1504 	// NewL test
       
  1505 	HBufC* name = KTestImplName().AllocLC();
       
  1506 	HBufC8* dataType = KTestImplDataType().AllocLC();
       
  1507 	HBufC8* opaqueData = KTestImplOpaqueData().AllocLC();
       
  1508 
       
  1509 	RArray<TUid>* extendedInterfaces = new(ELeave) RArray<TUid>;
       
  1510 
       
  1511 	CleanupStack::PushL(TCleanupItem(CloseAndDeleteArray, extendedInterfaces));
       
  1512 
       
  1513 	CRegistryData::CImplementationData* implementation2;
       
  1514 	implementation2 = CRegistryData::CImplementationData::NewL(interfaceData,
       
  1515 															testImplUid,
       
  1516 															testImplVersion,
       
  1517 															name,
       
  1518 															dataType,
       
  1519 															opaqueData,
       
  1520 															testImplDrive,
       
  1521 															testImplRomOnly,
       
  1522 															testImplRomBased,
       
  1523 															extendedInterfaces);
       
  1524 
       
  1525 	CleanupStack::Pop(extendedInterfaces);
       
  1526 	CleanupStack::Pop(opaqueData);
       
  1527 	CleanupStack::Pop(dataType);
       
  1528 	CleanupStack::Pop(name);
       
  1529 
       
  1530 	CleanupStack::PushL(implementation2);
       
  1531 	TEST(interfaceData == implementation1->iParent);
       
  1532 
       
  1533 	//Add extended interface
       
  1534 	implementation2->iImplInfo->AddExtendedInterfaceL(testExtendedInterfaceUid1);
       
  1535 	implementation2->iImplInfo->AddExtendedInterfaceL(testExtendedInterfaceUid2);
       
  1536 
       
  1537 	// Externalize test
       
  1538 	_LIT(KFileName,"c:\\ecomimpldata.dat");
       
  1539 	RFile file;
       
  1540 	TFileName fileName(KFileName);
       
  1541 	TEST2(file.Replace(TheFs,fileName,EFileWrite|EFileRead), KErrNone);
       
  1542 	RFileBuf buf;
       
  1543 	CleanupClosePushL(buf);
       
  1544 	buf.Attach(file);
       
  1545 	RWriteStream stream(&buf);
       
  1546 
       
  1547 	implementation2->ExternalizeL(stream);
       
  1548 	buf.SynchL();
       
  1549 	CleanupStack::PopAndDestroy(&buf);
       
  1550 
       
  1551 	// Internalize test
       
  1552 	TInt err = file.Open(TheFs,fileName,EFileRead);
       
  1553 	TEST2(err, KErrNone);
       
  1554 	RFileBuf buf2;
       
  1555 	CleanupClosePushL(buf2);
       
  1556 	buf2.Attach(file);
       
  1557 	RReadStream stream2(&buf2);
       
  1558 
       
  1559 	implementation1->InternalizeL(stream2);
       
  1560 
       
  1561 	TEST(implementation1->iImplInfo->ImplementationUid().Uid == testImplUid.Uid);
       
  1562 	TEST(implementation1->iImplInfo->Version() == testImplVersion);
       
  1563 	TEST2(KErrNone, name->Compare(implementation1->iImplInfo->DisplayName()));
       
  1564 	TEST2(KErrNone, dataType->Compare(implementation1->iImplInfo->DataType()));
       
  1565 	TEST2(KErrNone, opaqueData->Compare(implementation1->iImplInfo->OpaqueData()));
       
  1566 	TEST(implementation1->iImplInfo->Drive() == testImplDrive);
       
  1567 	TEST(implementation1->iImplInfo->RomOnly() == testImplRomOnly);
       
  1568 	TEST(implementation1->iImplInfo->RomBased() == testImplRomBased);
       
  1569 	//Get extended interface and check
       
  1570 	RArray<TUid>* extendedInterfaceList = implementation1->iImplInfo->GetExtendedInterfaceList();
       
  1571 	TEST((*extendedInterfaceList)[0] == testExtendedInterfaceUid1);
       
  1572 	TEST((*extendedInterfaceList)[1] == testExtendedInterfaceUid2);
       
  1573 
       
  1574 	CleanupStack::PopAndDestroy(&buf2);
       
  1575 
       
  1576 	// Setup data for Compare Implementation Uid
       
  1577 	name = KTestImplName().AllocLC();
       
  1578 	dataType = KTestImplDataType().AllocLC();
       
  1579 	opaqueData = KTestImplOpaqueData().AllocLC();
       
  1580 	TUid compareTestImplUid;
       
  1581 	compareTestImplUid.iUid = 0x10009DC3;
       
  1582 	CRegistryData::CImplementationData* implementation3;
       
  1583 	implementation3 = CRegistryData::CImplementationData::NewL(interfaceData,
       
  1584 															compareTestImplUid,
       
  1585 															testImplVersion,
       
  1586 															name,
       
  1587 															dataType,
       
  1588 															opaqueData,
       
  1589 															testImplDrive,
       
  1590 															testImplRomOnly,
       
  1591 															testImplRomBased);
       
  1592 	CleanupStack::Pop(opaqueData);
       
  1593 	CleanupStack::Pop(dataType);
       
  1594 	CleanupStack::Pop(name);
       
  1595 
       
  1596 	CleanupStack::PushL(implementation3);
       
  1597 	TEST(interfaceData == implementation3->iParent);
       
  1598 
       
  1599 	// Compare Implementation Uid test
       
  1600 	TEST(CRegistryData::CImplementationData::CompareImplUid(*implementation3, *implementation2) > 0);
       
  1601 	TEST(CRegistryData::CImplementationData::CompareImplUid(*implementation1, *implementation3) < 0);
       
  1602 	TEST(CRegistryData::CImplementationData::CompareImplUid(*implementation3, *implementation3) == 0);
       
  1603 
       
  1604 	// Tidy up
       
  1605 	CleanupStack::PopAndDestroy(7, registryData);
       
  1606 	TheFs.Delete(KFileName);
       
  1607 
       
  1608 // Check for open handles
       
  1609 	RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  1610 	TEST(startThreadHandleCount == endThreadHandleCount);
       
  1611 
       
  1612 	// Test Ends...
       
  1613 	__UHEAP_MARKEND;
       
  1614 	}
       
  1615 
       
  1616 /**
       
  1617 @SYMTestCaseID			SYSLIB-ECOM-CT-0291
       
  1618 @SYMTestCaseDesc		Tests for CRegistryData::InsertIntoIndexRemoveFromIndexTestL
       
  1619 						See CR65BCA3.
       
  1620 @SYMTestPriority			High
       
  1621 @SYMTestActions			Create 2 identical implementations, 1 for the Z drive and 1 for the C drive,
       
  1622 						including parents and add to the registry.
       
  1623 						Create a 3rd identical implementation, except for the name, for the C drive.
       
  1624 						Check there are no implementations in the Implementation Index List.
       
  1625 						Insert the Z implementations into the Implementation Index List and check.
       
  1626 						Insert the 1st C implementation with security check on and check the upgrade
       
  1627 						took place.
       
  1628 						Remove the implementation. Check.
       
  1629 						Add the Z drive implementation. Check.
       
  1630 						Insert the 1st C implementation with security check off and check the upgrade
       
  1631 						took place.
       
  1632 						Remove the implementation. Check.
       
  1633 						Add the Z drive implementation. Check.
       
  1634 						Insert the 2nd C implementation with security check on and check the upgrade
       
  1635 						did not take place.
       
  1636 						Insert the 2nd C implementation with security check off and check the upgrade
       
  1637 						did took place.
       
  1638 						Remove the implementation. Check.
       
  1639 						Check for no crash and memory leaks.
       
  1640 @SYMTestExpectedResults	The test must not fail.
       
  1641 @SYMPREQ				PREQ277
       
  1642 */
       
  1643 void  CRegistryDataTest::InsertIntoIndexRemoveFromIndexTestL()
       
  1644 	{
       
  1645 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0291 "));
       
  1646 	_LIT(KTestImplName, "Implementation");
       
  1647 	_LIT8(KTestImplDataType, "Data Type");
       
  1648 	_LIT8(KTestImplOpaqueData, "Opaque Data");
       
  1649 
       
  1650 	// create Z drive data
       
  1651 	TDriveUnit implDriveZ = EDriveZ;
       
  1652 	CRegistryData::CDriveData* driveDataZ = CRegistryData::CDriveData::NewLC(implDriveZ,  iRegistryData);
       
  1653 	iStateAccessor->AppendDriveDataL(*iRegistryData, driveDataZ);
       
  1654 	CleanupStack::Pop(driveDataZ);
       
  1655 
       
  1656 	// Create Implementation 1 on Z drive
       
  1657 	_LIT(KEComUpgradeExample1OnZ,		"Z:\\sys\\bin\\EComUpgradeExampleOne.dll");
       
  1658 	TEntry upgradeExample1OnZ;
       
  1659 	upgradeExample1OnZ.iName = KEComUpgradeExample1OnZ;
       
  1660 	TParse fileparse;
       
  1661 	fileparse.Set(KEComUpgradeExample1OnZ,NULL,NULL);
       
  1662 
       
  1663 	CRegistryData::CDllData* dllDataZ = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),upgradeExample1OnZ.iModified,KNullUid, KNullUid, driveDataZ);
       
  1664 	dllDataZ->iSecurityChecked = ETrue;
       
  1665 	driveDataZ->AddL(dllDataZ);
       
  1666 	CleanupStack::Pop(dllDataZ);
       
  1667 	CRegistryData::CInterfaceData* interfaceDataZ = CRegistryData::CInterfaceData::NewLC(iInterfaceUid, dllDataZ);
       
  1668 	dllDataZ->AddL(interfaceDataZ);
       
  1669 	CleanupStack::Pop(interfaceDataZ);
       
  1670 	HBufC* name = KTestImplName().AllocLC();
       
  1671 	HBufC8* dataType = KTestImplDataType().AllocLC();
       
  1672 	HBufC8* opaqueData = KTestImplOpaqueData().AllocLC();
       
  1673 
       
  1674 	CRegistryData::CImplementationData* implementation1;
       
  1675 	implementation1 = CRegistryData::CImplementationData::NewL(interfaceDataZ,
       
  1676 															iImplementationUid,
       
  1677 															1,
       
  1678 															name,
       
  1679 															dataType,
       
  1680 															opaqueData,
       
  1681 															implDriveZ,
       
  1682 															EFalse,
       
  1683 															EFalse);
       
  1684 	CleanupStack::Pop(opaqueData);
       
  1685 	CleanupStack::Pop(dataType);
       
  1686 	CleanupStack::Pop(name);
       
  1687 	CleanupStack::PushL(implementation1);
       
  1688 	interfaceDataZ->AddL(implementation1);
       
  1689 	CleanupStack::Pop(implementation1);
       
  1690 
       
  1691 	// create C drive data
       
  1692 	TDriveUnit implDriveC = EDriveC;
       
  1693 	CRegistryData::CDriveData* driveDataC = CRegistryData::CDriveData::NewLC(implDriveC,  iRegistryData);
       
  1694 	iStateAccessor->AppendDriveDataL(*iRegistryData, driveDataC);
       
  1695 	CleanupStack::Pop(driveDataC);
       
  1696 
       
  1697 	// Create Implementation 1 on C drive
       
  1698 	_LIT(KEComUpgradeExample1OnC,		"C:\\sys\\bin\\EComUpgradeExampleOne.dll");
       
  1699 	TEntry upgradeExample1OnC;
       
  1700 	upgradeExample1OnC.iName = KEComUpgradeExample1OnC;
       
  1701 	fileparse.Set(KEComUpgradeExample1OnC,NULL,NULL);
       
  1702 
       
  1703 	CRegistryData::CDllData* dllDataC1 = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),upgradeExample1OnC.iModified,KNullUid, KNullUid, driveDataC);
       
  1704 	dllDataC1->iSecurityChecked = ETrue;
       
  1705 	driveDataC->AddL(dllDataC1);
       
  1706 	CleanupStack::Pop(dllDataC1);
       
  1707 	CRegistryData::CInterfaceData* interfaceDataC1 = CRegistryData::CInterfaceData::NewLC(iInterfaceUid, dllDataC1);
       
  1708 	dllDataC1->AddL(interfaceDataC1);
       
  1709 	CleanupStack::Pop(interfaceDataC1);
       
  1710 	name = KTestImplName().AllocLC();
       
  1711 	dataType = KTestImplDataType().AllocLC();
       
  1712 	opaqueData = KTestImplOpaqueData().AllocLC();
       
  1713 
       
  1714 	CRegistryData::CImplementationData* implementation2;
       
  1715 	implementation2 = CRegistryData::CImplementationData::NewL(interfaceDataC1,
       
  1716 															iImplementationUid,
       
  1717 															2,
       
  1718 															name,
       
  1719 															dataType,
       
  1720 															opaqueData,
       
  1721 															implDriveC,
       
  1722 															EFalse,
       
  1723 															EFalse);
       
  1724 	CleanupStack::Pop(opaqueData);
       
  1725 	CleanupStack::Pop(dataType);
       
  1726 	CleanupStack::Pop(name);
       
  1727 	CleanupStack::PushL(implementation2);
       
  1728 	interfaceDataC1->AddL(implementation2);
       
  1729 	CleanupStack::Pop(implementation2);
       
  1730 
       
  1731 	// Create Implementation 2 on C drive
       
  1732 	_LIT(KEComUpgradeExample2OnC,		"C:\\sys\\bin\\EComUpgradeExampleTwo.dll");
       
  1733 	TEntry upgradeExample2OnC;
       
  1734 	upgradeExample2OnC.iName = KEComUpgradeExample2OnC;
       
  1735 	fileparse.Set(KEComUpgradeExample2OnC,NULL,NULL);
       
  1736 
       
  1737 	CRegistryData::CDllData* dllDataC2 = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),upgradeExample2OnC.iModified,KNullUid,KNullUid, driveDataC);
       
  1738 	dllDataC2->iSecurityChecked = ETrue;
       
  1739 	driveDataC->AddL(dllDataC2);
       
  1740 	CleanupStack::Pop(dllDataC2);
       
  1741 	CRegistryData::CInterfaceData* interfaceDataC2 = CRegistryData::CInterfaceData::NewLC(iInterfaceUid, dllDataC2);
       
  1742 	dllDataC2->AddL(interfaceDataC2);
       
  1743 	CleanupStack::Pop(interfaceDataC2);
       
  1744 	name = KTestImplName().AllocLC();
       
  1745 	dataType = KTestImplDataType().AllocLC();
       
  1746 	opaqueData = KTestImplOpaqueData().AllocLC();
       
  1747 
       
  1748 	CRegistryData::CImplementationData* implementation3;
       
  1749 	implementation3 = CRegistryData::CImplementationData::NewL(interfaceDataC2,
       
  1750 															iImplementationUid,
       
  1751 															2,
       
  1752 															name,
       
  1753 															dataType,
       
  1754 															opaqueData,
       
  1755 															implDriveC,
       
  1756 															EFalse,
       
  1757 															EFalse);
       
  1758 	CleanupStack::Pop(opaqueData);
       
  1759 	CleanupStack::Pop(dataType);
       
  1760 	CleanupStack::Pop(name);
       
  1761 	CleanupStack::PushL(implementation3);
       
  1762 	interfaceDataC2->AddL(implementation3);
       
  1763 	CleanupStack::Pop(implementation3);
       
  1764 
       
  1765 //===========================================================================
       
  1766 
       
  1767 	// Check index is empty
       
  1768 	TEST(iStateAccessor->ImplementationsCount(*iRegistryData) == 0);
       
  1769 
       
  1770 //===========================================================================
       
  1771 
       
  1772 	// Add Implementation from Z drive to index
       
  1773 	TBool result = iRegistryData->InsertIntoIndexL(implementation1, ETrue);
       
  1774 	TEST2(result, ETrue);
       
  1775 
       
  1776 	RImplDataArray impls;
       
  1777 	CleanupClosePushL(impls);
       
  1778 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1779 	TEST(impls.Count() == 1);
       
  1780 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  1781 
       
  1782 //===========================================================================
       
  1783 
       
  1784 	// Add Implementation from C drive to index - this should upgrade existing implementation
       
  1785 	result = iRegistryData->InsertIntoIndexL(implementation2, ETrue);
       
  1786 	TEST2(result, ETrue);
       
  1787 
       
  1788 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1789 	TEST(impls.Count() == 1);
       
  1790 	TEST(impls[0]->iImplInfo->Drive() == implDriveC);
       
  1791 
       
  1792 //===========================================================================
       
  1793 
       
  1794 	// remove existing implementation which causes rollback to Z drive impl
       
  1795 	iRegistryData->RemoveFromIndexL(dllDataC1);
       
  1796 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1797 	TEST(impls.Count() == 1);
       
  1798 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  1799 
       
  1800 //===========================================================================
       
  1801 
       
  1802 	// Add Implementation from C drive to index - this should upgrade existing implementation
       
  1803 	result = iRegistryData->InsertIntoIndexL(implementation2, EFalse);
       
  1804 	TEST2(result, ETrue);
       
  1805 
       
  1806 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1807 	TEST(impls.Count() == 1);
       
  1808 	TEST(impls[0]->iImplInfo->Drive() == implDriveC);
       
  1809 //===========================================================================
       
  1810 
       
  1811 	// remove existing implementation which causes rollback to Z drive impl
       
  1812 	iRegistryData->RemoveFromIndexL(dllDataC1);
       
  1813 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1814 	TEST(impls.Count() == 1);
       
  1815 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  1816 //===========================================================================
       
  1817 
       
  1818 	// Add Implementation with different name from C drive to index
       
  1819 	// this should NOT upgrade existing implementation
       
  1820 	result = iRegistryData->InsertIntoIndexL(implementation3, ETrue);
       
  1821 	TEST2(result, EFalse);
       
  1822 
       
  1823 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1824 	TEST(impls.Count() == 1);
       
  1825 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  1826 //===========================================================================
       
  1827 
       
  1828 	// Add Implementation with different name from C drive to index
       
  1829 	// this should upgrade existing implementation as security check is OFF
       
  1830 	result = iRegistryData->InsertIntoIndexL(implementation3, EFalse);
       
  1831 	TEST2(result, ETrue);
       
  1832 
       
  1833 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1834 	TEST(impls.Count() == 1);
       
  1835 	TEST(impls[0]->iImplInfo->Drive() == implDriveC);
       
  1836 //===========================================================================
       
  1837 
       
  1838 	// remove existing implementation which causes rollback to Z drive impl
       
  1839 	iRegistryData->RemoveFromIndexL(dllDataC2);
       
  1840 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1841 	TEST(impls.Count() == 1);
       
  1842 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  1843 	CleanupStack::PopAndDestroy(&impls);
       
  1844 	}
       
  1845 
       
  1846 /**
       
  1847 Test case for Defect ECOM Index must rollback	to original Impl. if upgrade impl. is removed
       
  1848 
       
  1849 @SYMTestCaseID			SYSLIB-ECOM-CT-1373
       
  1850 @SYMTestCaseDesc		Test case for defect number DEF065559 ECOM Index must rollback
       
  1851 						to original Impl. if upgrade impl. is removed.
       
  1852 @SYMTestPriority			High
       
  1853 @SYMTestActions			Create 3 identical implementations, 1 for the Z drive, 1 for the C drive and
       
  1854 						1 for the D drive, including parents and add to the registry.
       
  1855 						Insert the Z implementation and check.
       
  1856 						Insert the C implementation and check the upgrade took place.
       
  1857 						Insert the D implementation and check the upgrade took place.
       
  1858 						Remove the D implementation and check rollback to C occurred.
       
  1859 						Remove the C implementation and check rollback to Z occurred.
       
  1860 						Insert the C implementation and check the upgrade took place.
       
  1861 						Insert the D implementation and check the upgrade took place.
       
  1862 						Remove the C implementation and check no rollback occurred. i.e D impl available
       
  1863 						Remove the D implementation and check rollback to Z occurred.
       
  1864 						Insert the D implementation and check the upgrade took place.
       
  1865 						Insert the C implementation and check no upgrade took place. i.e D impl available
       
  1866 						Remove the D implementation and check rollback to C occurred.
       
  1867 						Remove the C implementation and check rollback to Z occurred.
       
  1868 						Check for no crash and memory leaks.
       
  1869 @SYMTestExpectedResults	The test must not fail.
       
  1870 @SYMDEF				DEF065559
       
  1871 */
       
  1872 void  CRegistryDataTest::RollbackTestL()
       
  1873 	{
       
  1874 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1373 "));
       
  1875 	_LIT(KTestImplName, "Implementation");
       
  1876 	_LIT8(KTestImplDataType, "Data Type");
       
  1877 	_LIT8(KTestImplOpaqueData, "Opaque Data");
       
  1878 
       
  1879 	// Create Implementation 1 on Z drive
       
  1880 	_LIT(KEComUpgradeExample1OnZ,		"Z:\\sys\\bin\\EComUpgradeExampleOne.dll");
       
  1881 	TImplCreationStruct zDllData(EDriveZ,
       
  1882 								iInterfaceUid,
       
  1883 								iImplementationUid,
       
  1884 								KEComUpgradeExample1OnZ,
       
  1885 								KTestImplName,
       
  1886 								KTestImplDataType,
       
  1887 								KTestImplOpaqueData,
       
  1888 								1,
       
  1889 								ETrue,  // Z: is ROMBased
       
  1890 								EFalse);
       
  1891 	CreateImplL(zDllData);
       
  1892 
       
  1893 	// Create Implementation 1 on C drive
       
  1894 	_LIT(KEComUpgradeExample1OnC,		"C:\\sys\\bin\\EComUpgradeExampleOne.dll");
       
  1895 	TImplCreationStruct cDllData(EDriveC,
       
  1896 								iInterfaceUid,
       
  1897 								iImplementationUid,
       
  1898 								KEComUpgradeExample1OnC,
       
  1899 								KTestImplName,
       
  1900 								KTestImplDataType,
       
  1901 								KTestImplOpaqueData,
       
  1902 								2);
       
  1903 	CreateImplL(cDllData);
       
  1904 
       
  1905 	// create drive data on third drive.
       
  1906 
       
  1907 	// find a valid drive which is not Z and not C.
       
  1908 	TEComCachedDriveInfoIterator iter(*iRegistryData->iCachedDriveInfo);
       
  1909 	iter.Last(); // positioned at Z:
       
  1910 	iter.Prev(); // the drive before Z:
       
  1911 	for (; iter.InRange(); iter.Prev())
       
  1912 		{
       
  1913 		if (iter.DriveNumber() != EDriveC)
       
  1914 			{
       
  1915 			break;
       
  1916 			}
       
  1917 		}
       
  1918 
       
  1919 	TEST(iter.InRange() && iter.DriveNumber() != EDriveC);
       
  1920 
       
  1921 	TDriveName drvName = iter.DriveUnit().Name();
       
  1922 
       
  1923 	_LIT(KEComUpgradeExample1On3,		"_:\\sys\\bin\\EComUpgradeExampleOne.dll");
       
  1924 	TBuf<36> dllName3(KEComUpgradeExample1On3);
       
  1925 	dllName3[0] = drvName[0];
       
  1926 	TImplCreationStruct thirdDllData(iter.DriveNumber(),
       
  1927 									iInterfaceUid,
       
  1928 									iImplementationUid,
       
  1929 									dllName3,
       
  1930 									KTestImplName,
       
  1931 									KTestImplDataType,
       
  1932 									KTestImplOpaqueData,
       
  1933 									3);
       
  1934 	CreateImplL(thirdDllData);
       
  1935 //===========================================================================
       
  1936 
       
  1937 	// Check index is empty
       
  1938 	TEST(iStateAccessor->ImplementationsCount(*iRegistryData) == 0);
       
  1939 
       
  1940 //===========================================================================
       
  1941 	TDriveUnit implDriveZ = EDriveZ;
       
  1942 	TDriveUnit implDriveC = EDriveC;
       
  1943 
       
  1944 	// Add Implementation from Z drive to index
       
  1945 	TBool result = iRegistryData->InsertIntoIndexL(zDllData.iImplData, ETrue);
       
  1946 	TEST2(result, ETrue);
       
  1947 
       
  1948 	RImplDataArray impls;
       
  1949 	CleanupClosePushL(impls);
       
  1950 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1951 	TEST(impls.Count() == 1);
       
  1952 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  1953 
       
  1954 //===========================================================================
       
  1955 
       
  1956 	// Add Implementation from C drive to index - this should upgrade existing implementation
       
  1957 	result = iRegistryData->InsertIntoIndexL(cDllData.iImplData, ETrue);
       
  1958 	TEST2(result, ETrue);
       
  1959 
       
  1960 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1961 	TEST(impls.Count() == 1);
       
  1962 	TEST(impls[0]->iImplInfo->Drive() == implDriveC);
       
  1963 
       
  1964 //===========================================================================
       
  1965 
       
  1966 	// Add Implementation from third drive to index - this should upgrade existing implementation
       
  1967 	result = iRegistryData->InsertIntoIndexL(thirdDllData.iImplData, ETrue);
       
  1968 	TEST2(result, ETrue);
       
  1969 
       
  1970 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1971 	TEST(impls.Count() == 1);
       
  1972 	TEST(impls[0]->iImplInfo->Drive() == iter.DriveUnit());
       
  1973 
       
  1974 //===========================================================================
       
  1975 
       
  1976 	// remove implementation from third drive which causes rollback to C drive impl
       
  1977 	iRegistryData->RemoveFromIndexL(thirdDllData.iDllData);
       
  1978 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1979 	TEST(impls.Count() == 1);
       
  1980 	TEST(impls[0]->iImplInfo->Drive() == implDriveC);
       
  1981 
       
  1982 //===========================================================================
       
  1983 
       
  1984 	// remove implementation from C which causes rollback to Z drive impl
       
  1985 	iRegistryData->RemoveFromIndexL(cDllData.iDllData);
       
  1986 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1987 	TEST(impls.Count() == 1);
       
  1988 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  1989 
       
  1990 //===========================================================================
       
  1991 
       
  1992 	// Add Implementation from C drive to index - this should upgrade existing implementation
       
  1993 	result = iRegistryData->InsertIntoIndexL(cDllData.iImplData, ETrue);
       
  1994 	TEST2(result, ETrue);
       
  1995 
       
  1996 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  1997 	TEST(impls.Count() == 1);
       
  1998 	TEST(impls[0]->iImplInfo->Drive() == implDriveC);
       
  1999 
       
  2000 //===========================================================================
       
  2001 
       
  2002 	// Add Implementation from third drive to index - this should upgrade existing implementation
       
  2003 	result = iRegistryData->InsertIntoIndexL(thirdDllData.iImplData, ETrue);
       
  2004 	TEST2(result, ETrue);
       
  2005 
       
  2006 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  2007 	TEST(impls.Count() == 1);
       
  2008 	TEST(impls[0]->iImplInfo->Drive() == iter.DriveUnit());
       
  2009 
       
  2010 //===========================================================================
       
  2011 
       
  2012 	// remove implementation from C which should cause no rollback
       
  2013 	iRegistryData->RemoveFromIndexL(cDllData.iDllData);
       
  2014 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  2015 	TEST(impls.Count() == 1);
       
  2016 	TEST(impls[0]->iImplInfo->Drive() == iter.DriveUnit());
       
  2017 
       
  2018 //===========================================================================
       
  2019 
       
  2020 	// remove implementation from third drive which causes rollback to Z drive impl
       
  2021 	iRegistryData->RemoveFromIndexL(thirdDllData.iDllData);
       
  2022 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  2023 	TEST(impls.Count() == 1);
       
  2024 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  2025 
       
  2026 //===========================================================================
       
  2027 
       
  2028 	// Add Implementation from third drive to index - this should upgrade existing implementation
       
  2029 	result = iRegistryData->InsertIntoIndexL(thirdDllData.iImplData, ETrue);
       
  2030 	TEST2(result, ETrue);
       
  2031 
       
  2032 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  2033 	TEST(impls.Count() == 1);
       
  2034 	TEST(impls[0]->iImplInfo->Drive() == iter.DriveUnit());
       
  2035 
       
  2036 //===========================================================================
       
  2037 
       
  2038 	// Add Implementation from C drive to index - this should not upgrade existing implementation
       
  2039 	result = iRegistryData->InsertIntoIndexL(cDllData.iImplData, ETrue);
       
  2040 	TEST2(result, ETrue);
       
  2041 
       
  2042 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  2043 	TEST(impls.Count() == 1);
       
  2044 	TEST(impls[0]->iImplInfo->Drive() == iter.DriveUnit());
       
  2045 
       
  2046 //===========================================================================
       
  2047 
       
  2048 	// remove implementation from third drive which causes rollback to C drive impl
       
  2049 	iRegistryData->RemoveFromIndexL(thirdDllData.iDllData);
       
  2050 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  2051 	TEST(impls.Count() == 1);
       
  2052 	TEST(impls[0]->iImplInfo->Drive() == implDriveC);
       
  2053 
       
  2054 //===========================================================================
       
  2055 
       
  2056 	// remove implementation from C which causes rollback to Z drive impl
       
  2057 	iRegistryData->RemoveFromIndexL(cDllData.iDllData);
       
  2058 	iStateAccessor->GetImplementationInfoL(*iRegistryData, iInterfaceUid, impls);
       
  2059 	TEST(impls.Count() == 1);
       
  2060 	TEST(impls[0]->iImplInfo->Drive() == implDriveZ);
       
  2061 	CleanupStack::PopAndDestroy(&impls);
       
  2062 	}
       
  2063 
       
  2064 /**
       
  2065 @SYMTestCaseID          SYSLIB-ECOM-CT-0737
       
  2066 @SYMTestCaseDesc	    Tests the creation and deletion of CRegistryData
       
  2067 @SYMTestPriority 	    High
       
  2068 @SYMTestActions  	    Create and delete CRegistryData object,checks for open handles
       
  2069 @SYMTestExpectedResults The test must not fail.
       
  2070 @SYMREQ                 REQ0000
       
  2071 */
       
  2072 LOCAL_C void CreateDeleteTestL()
       
  2073 	{
       
  2074 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0737 Create and Delete Test "));
       
  2075 	// Set up for heap leak checking
       
  2076 	__UHEAP_MARK;
       
  2077 
       
  2078 	// and leaking thread handles
       
  2079 	TInt startProcessHandleCount;
       
  2080 	TInt startThreadHandleCount;
       
  2081 	TInt endProcessHandleCount;
       
  2082 	TInt endThreadHandleCount;
       
  2083 
       
  2084 	// Test Starts...
       
  2085 	RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  2086 
       
  2087 	CRegistryDataTest* theTest = NULL;
       
  2088 	// Create the object
       
  2089 	TRAPD(err, theTest = CRegistryDataTest::NewL(EFalse));
       
  2090 	TEST2(err, KErrNone);
       
  2091 	// Delete the object
       
  2092 	delete theTest;
       
  2093 
       
  2094 	// Check for open handles
       
  2095 	RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  2096 	TEST(startThreadHandleCount == endThreadHandleCount);
       
  2097 
       
  2098 	// Test Ends...
       
  2099 	__UHEAP_MARKEND;
       
  2100 	}
       
  2101 
       
  2102 /**
       
  2103 @SYMTestCaseID          SYSLIB-ECOM-UT-3572
       
  2104 @SYMTestCaseDesc	    Tests for CRegistryData::UpdateDllDataL() function when an existing registered
       
  2105 						PLUGIN3 is downgraded with an updated PLUGIN1 resource file.
       
  2106 @SYMTestPriority 	    High
       
  2107 @SYMTestActions  	    Update the data for a dll in the registry.
       
  2108                         Tests for OOM error.
       
  2109 @SYMTestExpectedResults The data for the dll in the registry is updated.
       
  2110 @SYMEC                  EC43
       
  2111 */
       
  2112 void CRegistryDataTest::UpdateDllDataTest3L()
       
  2113 	{
       
  2114 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3572 "));
       
  2115 	// Checks if drive is registered
       
  2116 	TEST(iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit)!= KErrNotFound);
       
  2117 	CRegistryData::CDriveData* driveData = NULL;
       
  2118 	// Fetches index of drive, in iFoundDriveIndex
       
  2119 	iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData);
       
  2120 
       
  2121 	TEntry dllEntry;
       
  2122 	TUid example12ThirdUid = {0x10009E3E};
       
  2123 	dllEntry.iType = TUidType(KNullUid, KNullUid, example12ThirdUid);
       
  2124 	dllEntry.iName = KEComExample12DllOnC;
       
  2125 	dllEntry.iModified.HomeTime();
       
  2126 
       
  2127 	TBool registered = EFalse;
       
  2128 
       
  2129 	registered = iRegistryData->IsRegisteredWithDate(
       
  2130 										 dllEntry[2],
       
  2131 										 dllEntry.iModified,
       
  2132 										 iUpdate,
       
  2133 										 driveData);
       
  2134 	TEST(registered);
       
  2135 	// Log message if implementations need update
       
  2136 	if (!iUpdate)
       
  2137 		{
       
  2138 		TheTest.Printf(_L("Specified implementation group is already registered and does not need an update\n"));
       
  2139 		}
       
  2140 	//If the implementation needs an update, update it using UpdateDllDataL
       
  2141 	else
       
  2142 		{
       
  2143 		TheTest.Printf(_L("Specified implementation group is not registered with date and needs an update\n"));
       
  2144 		// Checks Implementation 0x10009E48 registered in the registry is version 1, display name is "Example 12 PlugIn3"
       
  2145 		// A reference to the implementation entry in the registry
       
  2146 		const TUid implementationUid = {0x10009E3C};
       
  2147 		CRegistryData::CImplementationData*	implementationData = NULL;
       
  2148 		TInt err = iStateAccessor->FindImplementation(*iRegistryData, implementationUid, KCDummyUid, implementationData);
       
  2149 		TEST2(err,KErrNone);
       
  2150 		CImplementationInformation* implementationInfo = implementationData->iImplInfo;
       
  2151 		TEST(implementationInfo->Version() == 1);
       
  2152 		TEST(implementationInfo->DisplayName().CompareF(_L("Example 12 PlugIn3"))==0);
       
  2153 
       
  2154 		// Dll Data object to be updated
       
  2155 		CRegistryData::CDllData* updateDllData = NULL;
       
  2156 		TParse fileparse;
       
  2157 		fileparse.Set(dllEntry.iName,NULL,NULL);
       
  2158 		updateDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),dllEntry.iModified,dllEntry[1], dllEntry[2],driveData);
       
  2159 
       
  2160 		//Copies the downgraded resource file to C:
       
  2161 		TRAP(err, EComTestUtils::FileManCopyFileL(KEcomExample12DowngradedOnZ, KEcomExample12DowngradedOnC));
       
  2162 		TEST2(err, KErrNone);
       
  2163 		//Creats the entry using downgraded resource file
       
  2164 		TEntry rscBasedEntry;
       
  2165 		rscBasedEntry.iName = KEcomExample12DowngradedResourceNameOnly;
       
  2166 		TParse rscPath;
       
  2167 		rscPath.Set(KEcomExample12DowngradedOnC,NULL,NULL);
       
  2168 		CPluginBase* entryBase = NULL;
       
  2169 		entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), EFalse);
       
  2170 		CleanupStack::PushL(entryBase);
       
  2171 		// Updates resource ext info
       
  2172 		HBufC* resourceExt = entryBase->RscFileExt();
       
  2173 		if(resourceExt)
       
  2174 			{
       
  2175 			updateDllData->SetResourceExtL(*resourceExt);
       
  2176 			}
       
  2177 		// parses the downgraded resource file
       
  2178 		TInt error = KErrNone;
       
  2179 		TRAP(error, iRegistrarAccessor->ParseL(*iRegistrar, entryBase, *updateDllData));
       
  2180 		if (error == KErrNoMemory)
       
  2181 			{
       
  2182 			User::LeaveNoMemory();
       
  2183 			}
       
  2184 		CleanupStack::PopAndDestroy(entryBase);
       
  2185 		TDriveUnit aDrive;
       
  2186 		// Updates DLL data with a new dll data
       
  2187 		TRAP(err, iRegistryData->UpdateDllDataL(aDrive, iFoundDriveIndex, updateDllData));
       
  2188 		TEST_OOM_ERR;
       
  2189 		TEST2(err, KErrNone);
       
  2190 		CleanupStack::Pop(updateDllData);
       
  2191 		// Checks registry data is updated with new data
       
  2192 		// Implementation 0x10009E48 is downgraded from version 1 to version 0, display name is changed to "Example 12 PlugIn"
       
  2193 		implementationData = NULL;
       
  2194 		err = iStateAccessor->FindImplementation(*iRegistryData, implementationUid, KCDummyUid, implementationData);
       
  2195 		TEST2(err,KErrNone);
       
  2196 		implementationInfo = implementationData->iImplInfo;
       
  2197 		TEST(implementationInfo->Version() == 0);
       
  2198 		TEST(implementationInfo->DisplayName().CompareF(_L("Example 12 PlugIn")) == 0);
       
  2199 		TheTest.Printf(_L("DLL data is updated \n"));
       
  2200 		//deletes the downgraded resource file
       
  2201 		TRAP(err,EComTestUtils::FileManDeleteFileL(KEcomExample12DowngradedOnC));
       
  2202 		}
       
  2203 	registered = iRegistryData->IsRegisteredWithDate(
       
  2204 										 dllEntry[2],
       
  2205 										 dllEntry.iModified,
       
  2206 										 iUpdate,
       
  2207 										 driveData);
       
  2208 	TEST(registered);
       
  2209 	TEST(!iUpdate);
       
  2210 	}
       
  2211 
       
  2212 /**
       
  2213 @SYMTestCaseID          SYSLIB-ECOM-UT-3571
       
  2214 @SYMTestCaseDesc	    Tests for CRegistryData::UpdateDllDataL() function when an existing registered
       
  2215 						PLUGIN1 is upgraded with an updated PLUGIN3 resource file.
       
  2216 @SYMTestPriority 	    High
       
  2217 @SYMTestActions  	    Update the data for a dll in the registry.
       
  2218                         Tests for OOM error.
       
  2219 @SYMTestExpectedResults The data for the dll in the registry is updated.
       
  2220 @SYMEC                  EC43
       
  2221 */
       
  2222 void CRegistryDataTest::UpdateDllDataTest2L()
       
  2223 	{
       
  2224 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3571 "));
       
  2225 	// Checks if drive is registered
       
  2226 	TEST(iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit)!= KErrNotFound);
       
  2227 	CRegistryData::CDriveData* driveData = NULL;
       
  2228 	// Fetches index of drive, in iFoundDriveIndex
       
  2229 	iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData);
       
  2230 
       
  2231 	TEntry dllEntry;
       
  2232 	TUid example14ThirdUid = {0x10009E40};
       
  2233 	dllEntry.iType = TUidType(KNullUid, KNullUid, example14ThirdUid);
       
  2234 	dllEntry.iName = KEComExample14DllOnC;
       
  2235 	dllEntry.iModified.HomeTime();
       
  2236 
       
  2237 	TBool registered = EFalse;
       
  2238 
       
  2239 	registered = iRegistryData->IsRegisteredWithDate(
       
  2240 										 dllEntry[2],
       
  2241 										 dllEntry.iModified,
       
  2242 										 iUpdate,
       
  2243 										 driveData);
       
  2244 	TEST(registered);
       
  2245 	// Log message if implementations need update
       
  2246 	if (!iUpdate)
       
  2247 		{
       
  2248 		TheTest.Printf(_L("Specified implementation group is already registered and does not need an update\n"));
       
  2249 		}
       
  2250 	//If the implementation needs an update, update it using UpdateDllDataL
       
  2251 	else
       
  2252 		{
       
  2253 		TheTest.Printf(_L("Specified implementation group is not registered with date and needs an update\n"));
       
  2254 
       
  2255 		// Checks Implementation 0x10009E48 registered in the registry is version 1, display name is "Example 14 PlugIn"
       
  2256 		// A reference to the implementation entry in the registry
       
  2257 		const TUid implementationUid = {0x10009E48};
       
  2258 		CRegistryData::CImplementationData*	implementationData = NULL;
       
  2259 		TInt err = iStateAccessor->FindImplementation(*iRegistryData, implementationUid, KCDummyUid, implementationData);
       
  2260 		TEST2(err,KErrNone);
       
  2261 		CImplementationInformation* implementationInfo = implementationData->iImplInfo;
       
  2262 		TEST(implementationInfo->Version() == 1);
       
  2263 		TEST(implementationInfo->DisplayName().CompareF(_L("Example 14 PlugIn"))==0);
       
  2264 
       
  2265 		// Dll Data object to be updated
       
  2266 		CRegistryData::CDllData* updateDllData = NULL;
       
  2267 		TParse fileparse;
       
  2268 		fileparse.Set(dllEntry.iName,NULL,NULL);
       
  2269 		updateDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),dllEntry.iModified,dllEntry[1], dllEntry[2],driveData);
       
  2270 
       
  2271 		//copies the upgraded resource file to C:
       
  2272 		TRAP(err, EComTestUtils::FileManCopyFileL(KEcomExample14UpgradedOnZ, KEcomExample14UpgradedOnC));
       
  2273 		TEST2(err, KErrNone);
       
  2274 		//Creats the entry using upgraded resource file
       
  2275 		TEntry rscBasedEntry;
       
  2276 		rscBasedEntry.iName = KEcomExample14UpgradedResourceNameOnly;
       
  2277 		TParse rscPath;
       
  2278 		rscPath.Set(KEcomExample14UpgradedOnC,NULL,NULL);
       
  2279 		CPluginBase* entryBase = NULL;
       
  2280 		entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), EFalse);
       
  2281 		CleanupStack::PushL(entryBase);
       
  2282 		// Updates resource ext info
       
  2283 		HBufC* resourceExt = entryBase->RscFileExt();
       
  2284 		if(resourceExt)
       
  2285 			{
       
  2286 			updateDllData->SetResourceExtL(*resourceExt);
       
  2287 			}
       
  2288 		// parses the upgraded resource file
       
  2289 		TInt error = KErrNone;
       
  2290 		TRAP(error, iRegistrarAccessor->ParseL(*iRegistrar, entryBase, *updateDllData));
       
  2291 		if (error == KErrNoMemory)
       
  2292 			{
       
  2293 			User::LeaveNoMemory();
       
  2294 			}
       
  2295 		CleanupStack::PopAndDestroy(entryBase);
       
  2296 
       
  2297 		TDriveUnit aDrive;
       
  2298 		// Updates DLL data with a new dll data
       
  2299 		TRAP(err, iRegistryData->UpdateDllDataL(aDrive, iFoundDriveIndex, updateDllData));
       
  2300 		TEST_OOM_ERR;
       
  2301 		TEST2(err, KErrNone);
       
  2302 		CleanupStack::Pop(updateDllData);
       
  2303 		// Checks registry data is updated with new data
       
  2304 		// Implementation 0x10009E48 is upgraded from version 1 to version 2, display name is changed to "Example 14 PlugIn3"
       
  2305 		implementationData = NULL;
       
  2306 		err = iStateAccessor->FindImplementation(*iRegistryData, implementationUid, KCDummyUid, implementationData);
       
  2307 		TEST2(err,KErrNone);
       
  2308 		implementationInfo = implementationData->iImplInfo;
       
  2309 		TEST(implementationInfo->Version() == 2);
       
  2310 		TEST(implementationInfo->DisplayName().CompareF(_L("Example 14 PlugIn3"))==0);
       
  2311 		TheTest.Printf(_L("DLL data is updated \n"));
       
  2312 		//deletes the upgraded resource file
       
  2313 		TRAP(err,EComTestUtils::FileManDeleteFileL(KEcomExample14UpgradedOnC));
       
  2314 		}
       
  2315 	registered = iRegistryData->IsRegisteredWithDate(
       
  2316 										 dllEntry[2],
       
  2317 										 dllEntry.iModified,
       
  2318 										 iUpdate,
       
  2319 										 driveData);
       
  2320 	TEST(registered);
       
  2321 	TEST(!iUpdate);
       
  2322 	}
       
  2323 
       
  2324 /**
       
  2325 @SYMTestCaseID          SYSLIB-ECOM-UT-3570
       
  2326 @SYMTestCaseDesc	    Tests for CRegistryData::UpdateDllDataL() function when an existing registered
       
  2327 						PLUGIN3 is upgraded with an updated PLUGIN3 resource file.
       
  2328 @SYMTestPriority 	    High
       
  2329 @SYMTestActions  	    Update the data for a dll in the registry.
       
  2330                         Tests for OOM error.
       
  2331 @SYMTestExpectedResults The data for the dll in the registry is updated.
       
  2332 @SYMEC                  EC43
       
  2333 */
       
  2334 
       
  2335 void CRegistryDataTest::UpdateDllDataTest1L()
       
  2336 	{
       
  2337 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3570 "));
       
  2338 	// Checks if drive is registered
       
  2339 	TEST2(iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit),ETrue);
       
  2340 	CRegistryData::CDriveData* driveData = NULL;
       
  2341 	// Fetches index of drive, in iFoundDriveIndex
       
  2342 	iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData);
       
  2343 
       
  2344 	TEntry dllEntry;
       
  2345 	TUid example12ThirdUid = {0x10009E3E};
       
  2346 	dllEntry.iType = TUidType(KNullUid, KNullUid, example12ThirdUid);
       
  2347 	dllEntry.iName = KEComExample12DllOnC;
       
  2348 	dllEntry.iModified.HomeTime();
       
  2349 
       
  2350 	TBool registered = EFalse;
       
  2351 	registered = iRegistryData->IsRegisteredWithDate(
       
  2352 										 dllEntry[2],
       
  2353 										 dllEntry.iModified,
       
  2354 										 iUpdate,
       
  2355 										 driveData);
       
  2356 	TEST(registered);
       
  2357 	// Log message if implementations need update
       
  2358 	if (!iUpdate)
       
  2359 		{
       
  2360 		TheTest.Printf(_L("Specified implementation group is already registered and does not need an update\n"));
       
  2361 		}
       
  2362 	//If the implementation needs an update, update it using UpdateDllDataL
       
  2363 	else
       
  2364 		{
       
  2365 		TheTest.Printf(_L("Specified implementation group is not registered with date and needs an update\n"));
       
  2366 
       
  2367 		// Checks Implementation 0x10009E3C registered in the registry is version 1
       
  2368 		// A reference to the implementation entry in the registry
       
  2369 		const TUid implementationUid = {0x10009E3C};
       
  2370 		CRegistryData::CImplementationData*	implementationData = NULL;
       
  2371 		TInt err = iStateAccessor->FindImplementation(*iRegistryData, implementationUid, KCDummyUid, implementationData);
       
  2372 		TEST2(err,KErrNone);
       
  2373 		CImplementationInformation* implementationInfo = implementationData->iImplInfo;
       
  2374 		TEST(implementationInfo->Version() == 1);
       
  2375 		// Dll Data object to be updated
       
  2376 		CRegistryData::CDllData* updateDllData = NULL;
       
  2377 		TParse fileparse;
       
  2378 		fileparse.Set(dllEntry.iName,NULL,NULL);
       
  2379 		updateDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),dllEntry.iModified,dllEntry[1], dllEntry[2],driveData);
       
  2380 
       
  2381 		//copies the upgraded resource file to C:
       
  2382 		TRAP(err, EComTestUtils::FileManCopyFileL(KEcomExample12UpgradedOnZ, KEcomExample12UpgradedOnC));
       
  2383 		TEST_OOM_ERR;
       
  2384 		TEST2(err, KErrNone);
       
  2385 		//Creats the entry using upgraded resource file
       
  2386 		TEntry rscBasedEntry;
       
  2387 		rscBasedEntry.iName = KEcomExample12UpgradedResourceNameOnly;
       
  2388 		TParse rscPath;
       
  2389 		rscPath.Set(KEcomExample12UpgradedOnC,NULL,NULL);
       
  2390 		CPluginBase* entryBase = NULL;
       
  2391 		entryBase=CSecurePlugin::NewL(TheFs,rscBasedEntry,rscPath.Drive(), EFalse);
       
  2392 		CleanupStack::PushL(entryBase);
       
  2393 		// Updates resource ext info
       
  2394 		HBufC* resourceExt = entryBase->RscFileExt();
       
  2395 		if(resourceExt)
       
  2396 			{
       
  2397 			updateDllData->SetResourceExtL(*resourceExt);
       
  2398 			}
       
  2399 		// parses the upgraded resource file
       
  2400 		TInt error = KErrNone;
       
  2401 		TRAP(error, iRegistrarAccessor->ParseL(*iRegistrar, entryBase, *updateDllData));
       
  2402 		if (error == KErrNoMemory)
       
  2403 			{
       
  2404 			User::LeaveNoMemory();
       
  2405 			}
       
  2406 		CleanupStack::PopAndDestroy(entryBase);
       
  2407 		TDriveUnit aDrive;
       
  2408 		// Updates DLL data with a new dll data
       
  2409 		TRAP(err, iRegistryData->UpdateDllDataL(aDrive, iFoundDriveIndex, updateDllData));
       
  2410 		TEST_OOM_ERR;
       
  2411 		TEST2(err, KErrNone);
       
  2412 		CleanupStack::Pop(updateDllData);
       
  2413 		// Checks registry data is updated with new data
       
  2414 		// Implementation 0x10009E3C is upgraded from version 1 to version 2
       
  2415 		implementationData = NULL;
       
  2416 		err = iStateAccessor->FindImplementation(*iRegistryData, implementationUid, KCDummyUid, implementationData);
       
  2417 		TEST_OOM_ERR;
       
  2418 		TEST2(err,KErrNone);
       
  2419 		implementationInfo = implementationData->iImplInfo;
       
  2420 		TEST(implementationInfo->Version() == 2);
       
  2421 		TheTest.Printf(_L("DLL data is updated \n"));
       
  2422 		//cleans the upgraded resource file
       
  2423 		TRAP(err,EComTestUtils::FileManDeleteFileL(KEcomExample12UpgradedOnC));
       
  2424 		}
       
  2425 	registered = iRegistryData->IsRegisteredWithDate(
       
  2426 										 dllEntry[2],
       
  2427 										 dllEntry.iModified,
       
  2428 										 iUpdate,
       
  2429 										 driveData);
       
  2430 	TEST(registered);
       
  2431 	TEST(!iUpdate);
       
  2432 	}
       
  2433 
       
  2434 
       
  2435 
       
  2436 /**
       
  2437 @SYMTestCaseID          SYSLIB-ECOM-UT-3569
       
  2438 @SYMTestCaseDesc	    Tests for CRegistryData::AddDllDataL() function using Dll type PLUGIN3
       
  2439 @SYMTestPriority 	    High
       
  2440 @SYMTestActions  	    Adds data on a specific dll to the registry.
       
  2441                         Tests for OOM error,checks if drive is registered.
       
  2442 @SYMTestExpectedResults Dll data is added to the registry.
       
  2443 @SYMEC                  EC43
       
  2444 */
       
  2445 void CRegistryDataTest::AddDllDataPlugIn3TestL()
       
  2446 	{
       
  2447 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3569 "));
       
  2448 	// Checks if drive is registered
       
  2449 	TEST(iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit)!= KErrNotFound);
       
  2450 	CRegistryData::CDriveData* driveData = NULL;
       
  2451 	// Fetches index of drive, in iFoundDriveIndex
       
  2452 	iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData);
       
  2453 
       
  2454 	TEntry dllEntry;
       
  2455 	TUid example10ThirdUid = {0x10009E37};
       
  2456 	dllEntry.iType = TUidType(KNullUid, KNullUid, example10ThirdUid);
       
  2457 	dllEntry.iName = KEComExample10DllOnC;
       
  2458 	TBool registered = EFalse;
       
  2459 	TRAPD(err, registered = iRegistryData->IsRegisteredWithDate(
       
  2460 										 dllEntry[2],
       
  2461 										 dllEntry.iModified,
       
  2462 										 iUpdate,
       
  2463 										 driveData));
       
  2464 	TEST_OOM_ERR;
       
  2465 	TEST2(err, KErrNone);
       
  2466 	TEST(!registered);
       
  2467 	// Dll Data object to be added
       
  2468 	CRegistryData::CDllData* addDllData = NULL;
       
  2469 	TParse fileparse;
       
  2470 	fileparse.Set(dllEntry.iName,NULL,NULL);
       
  2471 	addDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),dllEntry.iModified,dllEntry[1], dllEntry[2],driveData);
       
  2472 
       
  2473 	// Adds DLL data of an existing DLL
       
  2474 	TRAP(err, iRegistryData->AddDllDataL(iDriveUnit, iFoundDriveIndex, addDllData));
       
  2475 
       
  2476 	TEST_OOM_ERR;
       
  2477 	CleanupStack::Pop(addDllData);
       
  2478 	TEST2(err, KErrNone);
       
  2479 
       
  2480 
       
  2481 	TRAP(err, iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData));
       
  2482 	TEST_OOM_ERR;
       
  2483 	TEST2(err, KErrNone);
       
  2484 	TRAP(err, registered = iRegistryData->IsRegisteredWithDate(
       
  2485 										 dllEntry[2],
       
  2486 										 dllEntry.iModified,
       
  2487 										 iUpdate,
       
  2488 										 driveData));
       
  2489 
       
  2490 	TEST_OOM_ERR;
       
  2491 	TEST2(err, KErrNone);
       
  2492 	TEST(registered);
       
  2493 	// Do not delete addDllData as ownership is with the iRegistryData
       
  2494 	}
       
  2495 
       
  2496 
       
  2497 /**
       
  2498 Adds the dll data on a perticular drive.
       
  2499 
       
  2500 @SYMTestCaseID          SYSLIB-ECOM-CT-0738
       
  2501 @SYMTestCaseDesc	    Tests for CRegistryData::AddDllDataL() function
       
  2502 @SYMTestPriority 	    High
       
  2503 @SYMTestActions  	    Adds data on a specific dll to the registry.
       
  2504                         Tests for OOM error,checks if drive is registered.
       
  2505 @SYMTestExpectedResults The test must not fail.
       
  2506 @SYMREQ                 REQ0000
       
  2507 */
       
  2508 void CRegistryDataTest::AddDllDataTestL()
       
  2509 	{
       
  2510 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0738 "));
       
  2511 	// Check if drive is registered
       
  2512 	TEST(iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit)!= KErrNotFound);
       
  2513 	CRegistryData::CDriveData* driveData = NULL;
       
  2514 	// Fetch index of drive, in iFoundDriveIndex
       
  2515 	iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData);
       
  2516 
       
  2517 	iRegistryData->IsRegisteredWithDate(
       
  2518 										 iDllEntry[2],
       
  2519 										 iDllEntry.iModified,
       
  2520 										 iUpdate,
       
  2521 
       
  2522 										 driveData);
       
  2523 	// Dll Data object to be added
       
  2524 	CRegistryData::CDllData*			addDllData=NULL;
       
  2525 	TParse fileparse;
       
  2526 	fileparse.Set(iDllEntry.iName,NULL,NULL);
       
  2527 	addDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),iDllEntry.iModified,iDllEntry[1], iDllEntry[2],driveData);
       
  2528 
       
  2529 	// Add DLL data of an existing DLL
       
  2530 	TRAPD(err, iRegistryData->AddDllDataL(iDriveUnit, iFoundDriveIndex, addDllData));
       
  2531 
       
  2532 	TEST_OOM_ERR;
       
  2533 	CleanupStack::Pop(addDllData);
       
  2534 	TEST2(err, KErrNone);
       
  2535 
       
  2536 	TBool registered = EFalse;
       
  2537 	TRAP(err, iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData));
       
  2538 	TEST_OOM_ERR;
       
  2539 	TEST2(err, KErrNone);
       
  2540 	TRAP(err, registered = iRegistryData->IsRegisteredWithDate(
       
  2541 										 iDllEntry[2],
       
  2542 										 iDllEntry.iModified,
       
  2543 										 iUpdate,
       
  2544 
       
  2545 										 driveData));
       
  2546 
       
  2547 	TEST_OOM_ERR;
       
  2548 	TEST2(err, KErrNone);
       
  2549 	TEST(registered);
       
  2550 	// Do not delete addDllData as ownership is with the iRegistryData
       
  2551 	}
       
  2552 
       
  2553 /**
       
  2554 Determines if the specified implementation is already registered and
       
  2555 updates the data for the dll in the registry if it needs an update
       
  2556 
       
  2557 @SYMTestCaseID          SYSLIB-ECOM-CT-0739
       
  2558 @SYMTestCaseDesc	    Tests for CRegistryData::UpdateDllDataL() function
       
  2559 @SYMTestPriority 	    High
       
  2560 @SYMTestActions  	    Update the data for a dll in the registry if it needs an update.
       
  2561                         Tests for OOM error.
       
  2562 @SYMTestExpectedResults The test must not fail.
       
  2563 @SYMREQ                 REQ0000
       
  2564 */
       
  2565 void CRegistryDataTest::IsRegisteredWithDateUpdateDllDataTestL()
       
  2566 	{
       
  2567 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0739 "));
       
  2568 	TBool result=EFalse;
       
  2569 	CRegistryData::CDriveData* driveData = NULL;
       
  2570 	TInt err = KErrNone;
       
  2571 	// Here we are doing positive testing. We are testing with valid entry.
       
  2572 	// If that is not registered, register it using UpdateDllDataL
       
  2573 	TRAP(err, iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData));
       
  2574 	TEST_OOM_ERR;
       
  2575 	TEST2(err, KErrNone);
       
  2576 
       
  2577 	TRAP(err, result = iRegistryData->IsRegisteredWithDate(
       
  2578 					  										 iDllEntry[2],
       
  2579 															 iDllEntry.iModified,
       
  2580 															 iUpdate,
       
  2581 
       
  2582 															 driveData));
       
  2583 	TEST_OOM_ERR;
       
  2584 	TEST2(err, KErrNone);
       
  2585 	// Log message if implementations need update
       
  2586 	if(result)
       
  2587 		{
       
  2588 		if(!iUpdate)
       
  2589 			{
       
  2590 			TEST(!iUpdate);
       
  2591 			TheTest.Printf(_L("Specified implementation group is already registered and does not need an update\n"));
       
  2592 			}
       
  2593 		else
       
  2594 			{
       
  2595 			TheTest.Printf(_L("Specified implementation group is not registered with date and needs an update\n"));
       
  2596 
       
  2597 			// Dll Data object to be updated
       
  2598 			CRegistryData::CDllData*			updateDllData=NULL;
       
  2599 			TParse fileparse;
       
  2600 			fileparse.Set(iDllEntry.iName,NULL,NULL);
       
  2601 			updateDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),iDllEntry.iModified,iDllEntry[1],iDllEntry[2],driveData);
       
  2602 			TDriveUnit aDrive;
       
  2603 
       
  2604 			// Updates DLL data with a new dll data
       
  2605 			TRAP(err, iRegistryData->UpdateDllDataL(aDrive, iFoundDriveIndex, updateDllData));
       
  2606 			TEST_OOM_ERR;
       
  2607 			CleanupStack::Pop(updateDllData);
       
  2608 			TEST2(err, KErrNone);
       
  2609 			// Print to that dll data is updated else we won't know we did.
       
  2610 			TheTest.Printf(_L("DLL data is updated \n"));
       
  2611 			}
       
  2612 		}
       
  2613 
       
  2614 	TUid thirdUid = {0x101F8400};
       
  2615 	iDllEntry.iType = TUidType(KNullUid, KNullUid, thirdUid);
       
  2616 	// Here we are doing negative testing. We are testing with invalid entry.
       
  2617 	// The result should be false
       
  2618 	TRAP(err, iFoundDriveIndex = iRegistryData->FindDriveL(iDriveUnit,driveData));
       
  2619 	TEST_OOM_ERR;
       
  2620 	TEST2(err, KErrNone);
       
  2621 	TRAP(err, result = iRegistryData->IsRegisteredWithDate(
       
  2622 					  										iDllEntry[2],
       
  2623 															iDllEntry.iModified,
       
  2624 															iUpdate,
       
  2625 
       
  2626 															driveData));
       
  2627 	TEST_OOM_ERR;
       
  2628 	TEST2(err, KErrNone);
       
  2629 	TEST(!result);
       
  2630 	}
       
  2631 
       
  2632 /**
       
  2633 Tests that an implementation is disabled and enabled by setting the state
       
  2634 
       
  2635 @SYMTestCaseID          SYSLIB-ECOM-CT-0740
       
  2636 @SYMTestCaseDesc	    Tests for CRegistryData::SetEnabledState() function
       
  2637 @SYMTestPriority 	    High
       
  2638 @SYMTestActions  	    Tests for enable or disable the specified interface implementation
       
  2639 						within the registry.
       
  2640 @SYMTestExpectedResults The test must not fail.
       
  2641 @SYMREQ                 REQ0000
       
  2642 */
       
  2643 void CRegistryDataTest::SetEnabledStateTestL()
       
  2644 	{
       
  2645 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0740 "));
       
  2646 	// A reference to the implementation entry in the registry
       
  2647 	CRegistryData::CImplementationData*	implementationData = NULL;
       
  2648 
       
  2649 	// Pass the state and enable or disable the implementaion
       
  2650 	TInt err;
       
  2651 	err = iStateAccessor->FindImplementation(*iRegistryData, iImplementationUid, KCDummyUid, implementationData);
       
  2652 	TEST2(err, KErrNone);
       
  2653 
       
  2654 	const CImplementationInformation* implementationInfo = implementationData->iImplInfo;
       
  2655 
       
  2656 	// SetEnabledState() will disable the implementation if enablestate parameter is EFalse.
       
  2657 	// If the  disablestate parameter is false the reverse will happen.
       
  2658 	TBool result=EFalse;
       
  2659 	TBool enableState=EFalse;
       
  2660 	TRAP(err, result = iRegistryData->SetEnabledState(iImplementationUid, enableState));
       
  2661 	TEST_OOM_ERR;
       
  2662 	TEST2(err, KErrNone);
       
  2663 	TEST(result == KErrNone);
       
  2664 
       
  2665 	//Implementation should be disabled
       
  2666 	TEST(implementationInfo->Disabled()==(!enableState));
       
  2667 
       
  2668 	// enable it
       
  2669 	enableState = ETrue;
       
  2670 	TRAP(err, result = iRegistryData->SetEnabledState(iImplementationUid, enableState));
       
  2671 	TEST_OOM_ERR;
       
  2672 	TEST2(err, KErrNone);
       
  2673 	TEST(result == KErrNone);
       
  2674 
       
  2675 	// Implementation should be enabled
       
  2676 	TEST(implementationInfo->Disabled()==(!enableState));
       
  2677 	}
       
  2678 
       
  2679 /**
       
  2680 Obtains Implementation data and prints to log
       
  2681 
       
  2682 @SYMTestCaseID		SYSLIB-ECOM-CT-0741
       
  2683 @SYMTestCaseDesc	Tests for CRegistryData::FindImplementation() functions
       
  2684 @SYMTestPriority		High
       
  2685 @SYMTestActions		Fetch the information on a particular implementation (UID)
       
  2686 					Tests for the validation of the information fetched.
       
  2687 					Fetch the information on a particular implementation (UID) and interface (UID)
       
  2688 					Tests for the validation of the information fetched.
       
  2689 @SYMTestExpectedResults The test must not fail.
       
  2690 @SYMREQ                 REQ0000
       
  2691 */
       
  2692 void CRegistryDataTest::FindImplementationTestL()
       
  2693 	{
       
  2694 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0741 "));
       
  2695 	// A reference to the implementation entry in the registry
       
  2696 	CRegistryData::CImplementationData*	implementationData = NULL;
       
  2697 
       
  2698 	// find implementation with interface uid unknown
       
  2699 	TInt err = iStateAccessor->FindImplementation(*iRegistryData, iImplementationUid, KCDummyUid, implementationData);
       
  2700 	TEST_OOM_ERR;
       
  2701 	TEST2(err, KErrNone);
       
  2702 
       
  2703 	const CImplementationInformation* implementationInfo = implementationData->iImplInfo;
       
  2704 
       
  2705 	TheTest.Printf((implementationInfo->DisplayName()));
       
  2706 	_LIT(KUIDFormat,"Uid = 0x%08X\n");
       
  2707 	TheTest.Printf(KUIDFormat, iImplementationUid);
       
  2708 	TheTest.Printf(KUIDFormat, implementationInfo->ImplementationUid());
       
  2709 	// Check for if its the same implementation
       
  2710 	TEST(iImplementationUid == implementationInfo->ImplementationUid());
       
  2711 
       
  2712 	// find implementation with interface uid known
       
  2713 	err = iStateAccessor->FindImplementation(*iRegistryData, iImplementationUid, iInterfaceUid, implementationData);
       
  2714 	TEST_OOM_ERR;
       
  2715 	TEST2(err, KErrNone);
       
  2716 
       
  2717 	implementationInfo = implementationData->iImplInfo;
       
  2718 
       
  2719 	TheTest.Printf((implementationInfo->DisplayName()));
       
  2720 	TheTest.Printf(KUIDFormat, iImplementationUid);
       
  2721 	TheTest.Printf(KUIDFormat, implementationInfo->ImplementationUid());
       
  2722 	TheTest.Printf(KUIDFormat, iInterfaceUid);
       
  2723 	TheTest.Printf(KUIDFormat, implementationData->iParent->iInterfaceUid);
       
  2724 
       
  2725 	// Check for if its the same implementation
       
  2726 	TEST(iImplementationUid == implementationInfo->ImplementationUid());
       
  2727 	// Check for if its the same interface
       
  2728 	TEST(iInterfaceUid == implementationData->iParent->iInterfaceUid);
       
  2729 
       
  2730 	// attempt to find unknown implementation with dummy interface uid
       
  2731 	err = iStateAccessor->FindImplementation(*iRegistryData, KCInvalidUid, KCDummyUid, implementationData);
       
  2732 	TEST_OOM_ERR;
       
  2733 	TEST2(err, KErrNotFound);
       
  2734 
       
  2735 	// attempt to find implementation for unknown interface uid
       
  2736 	err = iStateAccessor->FindImplementation(*iRegistryData, iImplementationUid, KCInvalidUid, implementationData);
       
  2737 	TEST_OOM_ERR;
       
  2738 	TEST2(err, KErrNotFound);
       
  2739 	}
       
  2740 
       
  2741 /**
       
  2742 Tests functionality of ListImplementationsL for an interface id and listing all
       
  2743 the implementations.
       
  2744 The interface Uid 0x10009DC0 has 6 implementations on different DLLs but only 4 will
       
  2745 be picked as as 2 of them are of older version(Impl ID 0x10009DC3 and 0x10009DC4 with version 1)
       
  2746 
       
  2747 Interface UID	DLL	UID		Implementation UID	Version
       
  2748 -------------------------------------------------------
       
  2749 0x10009DC0		0x10009DB1	0x10009DC3			1
       
  2750 				0x10009DB1	0x10009DC4			1
       
  2751 				0x10009DB3	0x10009DC3			2
       
  2752 				0x10009DB3	0x10009DC4			2
       
  2753 				0x101F8477	0x101F8478			1
       
  2754 				0x101F847B	0x101F847C			1
       
  2755 
       
  2756 @SYMTestCaseID          SYSLIB-ECOM-CT-0742
       
  2757 @SYMTestCaseDesc	    Tests for CRegistryData::ListImplementationsL() function
       
  2758 @SYMTestPriority 	    High
       
  2759 @SYMTestActions  	    List the implementations for an existing interface UID and
       
  2760                         test for expected number of implementations.Check the VID of
       
  2761                         every implementation match the VID of the DLL which the implementation
       
  2762                         belongs to.
       
  2763 @SYMTestExpectedResults The test must not fail.
       
  2764 @SYMREQ                 REQ0000, REQ6111
       
  2765 */
       
  2766 void CRegistryDataTest::ListImplementationsL()
       
  2767 	{
       
  2768 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0742 "));
       
  2769 	// List the implementations for an existing interface UID
       
  2770 	TEST(iRegistryData->IndexValid());
       
  2771 
       
  2772 	TRAPD(err, iRegistryData->ListImplementationsL(iInterfaceUid,iImplDataList));
       
  2773 	CleanupClosePushL(iImplDataList);
       
  2774 
       
  2775 	TEST_OOM_ERR;
       
  2776 	TEST2(err, KErrNone);
       
  2777 
       
  2778 	// Print UIDs of implementations
       
  2779 	_LIT(KUIDFormat,"Uid = 0x%08x\n");
       
  2780 	_LIT(KLists,"There are %d Implementations \n");
       
  2781 
       
  2782 	TheTest.Printf(KLists, iImplDataList.Count());
       
  2783 	// Test for expected number of implementations
       
  2784 	TEST(iImplDataList.Count() == 4);
       
  2785 
       
  2786 	for(TInt index = 0; index < iImplDataList.Count(); ++index)
       
  2787 		{
       
  2788 		CImplementationInformation* implInfo = iImplDataList[index]->iImplInfo;
       
  2789 		TUid uid = implInfo->ImplementationUid();
       
  2790 		TheTest.Printf(KUIDFormat, uid);
       
  2791 		}
       
  2792 	// Empty the array of implementation data
       
  2793 	CleanupStack::PopAndDestroy(&iImplDataList);
       
  2794 	}
       
  2795 
       
  2796 /**
       
  2797 Tests functionality of TemporaryUninstallL and UndoTemporaryUninstallL
       
  2798 Test does temporarily 1.install 2.uninstall and 3.install the specified drive
       
  2799 
       
  2800 @SYMTestCaseID          SYSLIB-ECOM-CT-0743
       
  2801 @SYMTestCaseDesc	    Tests for CRegistryData::UndoTemporaryUninstallL(),TemporaryUninstallL() function
       
  2802 @SYMTestPriority 	    High
       
  2803 @SYMTestActions  	    Tests for temporarily install,uninstall,install the specified drive
       
  2804 @SYMTestExpectedResults The test must not fail.
       
  2805 @SYMREQ                 REQ0000
       
  2806 */
       
  2807 void CRegistryDataTest::DoUndoTemporaryUninstallTestL()
       
  2808 	{
       
  2809 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0743 "));
       
  2810 	// We are testing with F drive.
       
  2811 	iDriveUnit = EDriveF;
       
  2812 	TBool driveregistered = iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit);
       
  2813 	// Check that the drive is registered. If its not there add it by UndoTemporaryUninstallL
       
  2814 	if (!driveregistered)
       
  2815 		{
       
  2816 		TRAPD(err, iRegistryData->UndoTemporaryUninstallL(iDriveUnit));
       
  2817 		TEST_OOM_ERR;
       
  2818 		TEST2(err, KErrNone);
       
  2819 		}
       
  2820 
       
  2821 	// Test drive should be present
       
  2822 	TEST(iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit));
       
  2823 
       
  2824 	// Uninstall the test drive
       
  2825 	TRAPD(err, iRegistryData->TemporaryUninstallL(iDriveUnit));
       
  2826 	TEST_OOM_ERR;
       
  2827 	TEST2(err, KErrNone);
       
  2828 	// Test drive should not be present
       
  2829 	TEST(!(iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit)));
       
  2830 
       
  2831 	// Put the test drive back to work if it was registered before
       
  2832 	if (driveregistered)
       
  2833 		{
       
  2834 		TRAP(err, iRegistryData->UndoTemporaryUninstallL(iDriveUnit));
       
  2835 		TEST_OOM_ERR;
       
  2836 		TEST2(err, KErrNone);
       
  2837 		// Test drive should be present
       
  2838 		TEST(iStateAccessor->IsRegisteredDriveL(*iRegistryData, iDriveUnit));
       
  2839 		}
       
  2840 	}
       
  2841 
       
  2842 /**
       
  2843 Tests functionality of DiscoveriesBeginning and DiscoveriesCompleteL
       
  2844 Tests registry data discovery process.
       
  2845 
       
  2846 @SYMTestCaseID          SYSLIB-ECOM-CT-0745
       
  2847 @SYMTestCaseDesc	    Tests for CRegistryData::DiscoveriesBeginning(),CRegistryData::DiscoveriesCompleteL() functions
       
  2848 @SYMTestPriority 	    High
       
  2849 @SYMTestActions  	    Tests for registry data discovery process.
       
  2850 @SYMTestExpectedResults The test must not fail.
       
  2851 @SYMREQ                 REQ0000
       
  2852 */
       
  2853 void CRegistryDataTest::DiscoveriesBeginCompleteTestL()
       
  2854 	{
       
  2855 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0745 "));
       
  2856 	// Issue discoveries begin and complete requests
       
  2857 	// and confirm the same
       
  2858 
       
  2859 	// DiscoveriesBegin marks the registry indexes as invalid as
       
  2860 	// the discovery process is in progress
       
  2861 	TRAPD(err, iRegistryData->DiscoveriesBeginning());
       
  2862 	TEST_OOM_ERR;
       
  2863 	TEST2(err, KErrNone);
       
  2864 	// Check Registry is invalid
       
  2865 	TEST(!iStateAccessor->IsIndexValid(*(iRegistryData)));
       
  2866 
       
  2867 	// DiscoveriesCompleteL marks the registry indexes valid as
       
  2868 	// the discovery process is complete
       
  2869 	TBool regChanged = EFalse;
       
  2870 	TRAP(err, iRegistryData->DiscoveriesCompleteL(EFalse, EPluginProcessingTypeAll,regChanged));
       
  2871 	TEST_OOM_ERR;
       
  2872 	TEST2(err, KErrNone);
       
  2873 	// Check Registry is valid
       
  2874 	TEST(iStateAccessor->IsIndexValid(*(iRegistryData)));
       
  2875 	}
       
  2876 
       
  2877 /**
       
  2878 Tests finding index for an entry for implementation Uid
       
  2879 
       
  2880 @SYMTestCaseID          SYSLIB-ECOM-CT-0747
       
  2881 @SYMTestCaseDesc	    Tests for CRegistryData::IndexedFindTestL() function
       
  2882 @SYMTestPriority 	    High
       
  2883 @SYMTestActions  	    Tests to find the index entry for aImplementationUid and log it
       
  2884 @SYMTestExpectedResults The test must not fail.
       
  2885 @SYMREQ                 REQ0000
       
  2886 */
       
  2887 void CRegistryDataTest::IndexedFindTestL()
       
  2888 	{
       
  2889 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0747 "));
       
  2890 	// Find the index entry for aImplementationUid and print it
       
  2891 	TInt index=0;
       
  2892 
       
  2893 	TRAPD(err, index = iStateAccessor->IndexedFind(*(iRegistryData), iInterfaceUid));
       
  2894 	TEST_OOM_ERR;
       
  2895 	TEST2(err, KErrNone);
       
  2896 	TheTest.Printf(_L("The index of interface 0x%08x is %d \n"), iInterfaceUid, index);
       
  2897 	// Index should have some valid value
       
  2898 	TEST(index >= 0);
       
  2899 	}
       
  2900 
       
  2901 
       
  2902 /**
       
  2903 Plugins to be used in this test
       
  2904 Interface UID	DLL	UID		Implementation UID	Version		DLL File
       
  2905 --------------------------------------------------------------------------------
       
  2906 0x10009E36		0x10009E3E	0x10009E39				1		C:\\..\\EComExample12.dll
       
  2907 				0x10009E3E	0x10009E3C				1		C:\\..\\EComExample12.dll
       
  2908 				0x10009E3E	0x10009E3D				1		C:\\..\\EComExample12.dll
       
  2909 				0x10009E42	0x10009E39				2		C:\\..\\EComExample15.dll
       
  2910 
       
  2911 
       
  2912 @SYMTestCaseID			SYSLIB-ECOM-UT-3573
       
  2913 @SYMTestCaseDesc		Tests for CRegistryData::GetImplementationDllInfoForClientL() function for DLL type PLUGIN3.
       
  2914 @SYMTestPriority		High
       
  2915 @SYMTestActions			Get the plugin information of the implementation UID and validate the information.
       
  2916 						Get the plugin information of the implementation UID and Interface UID and validate
       
  2917 						the information.
       
  2918 						Tests for that the implementation returned will have the highest version
       
  2919 @SYMTestExpectedResults	Implementation information is returned correctly.
       
  2920 @SYMEC					EC43
       
  2921 */
       
  2922 void CRegistryDataTest::GetImplementationDllInfoForClientPlugIn3TestL()
       
  2923  	{
       
  2924 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3573 "));
       
  2925 	TUid ImpUid15 = {0x10009E39};
       
  2926  	TUid ImpUid12 = {0x10009E3C};
       
  2927  	TUid InterfaceUid = {0x10009E36};
       
  2928  	TEntry dllinfo;
       
  2929  	TInt err;
       
  2930  	TClientRequest clntRq;
       
  2931 
       
  2932  	//Tests the CImplementationInformation is correct
       
  2933  	//and the DllInfo contains correct implementation info
       
  2934  	//Implementation uid used=0x10009E3C
       
  2935  	CImplementationInformation* implementationInfo = NULL;
       
  2936  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid12, KCDummyUid, dllinfo, implementationInfo, ETrue);
       
  2937  	TEST2(err, KErrNone);
       
  2938  	TEST(implementationInfo->ImplementationUid() == ImpUid12);
       
  2939  	TEST(implementationInfo->Version() == 1);
       
  2940  	TEST(dllinfo.iName.CompareF(KEComExample12DllOnC) == 0);
       
  2941 
       
  2942  	// ... again but with interface uid
       
  2943   	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid12, InterfaceUid, dllinfo, implementationInfo, ETrue);
       
  2944  	TEST2(err, KErrNone);
       
  2945  	TEST(implementationInfo->ImplementationUid() == ImpUid12);
       
  2946  	TEST(implementationInfo->Version() == 1);
       
  2947  	TEST(dllinfo.iName.CompareF(KEComExample12DllOnC) == 0);
       
  2948 
       
  2949  	//Tests that the implementation returned will have the highest version
       
  2950  	//EComExample12.dll  contains Impl 0x10009E39 with version 1
       
  2951  	//EComExample15.dll contains Impl 0x10009E39 with version 2
       
  2952  	//Ensure that choose the implementation in EComExample15.dll
       
  2953  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid15, KCDummyUid, dllinfo, implementationInfo, ETrue);
       
  2954  	TEST2(err, KErrNone);
       
  2955  	TEST(implementationInfo->ImplementationUid() == ImpUid15);
       
  2956  	TEST(implementationInfo->Version() == 2);
       
  2957  	TEST(dllinfo.iName.CompareF(KEComExample15DllOnC) == 0);
       
  2958 
       
  2959  	// ... again but with interface uid
       
  2960  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid15, InterfaceUid, dllinfo, implementationInfo, ETrue);
       
  2961  	TEST2(err, KErrNone);
       
  2962  	TEST(implementationInfo->ImplementationUid() == ImpUid15);
       
  2963  	TEST(implementationInfo->Version() == 2);
       
  2964  	TEST(dllinfo.iName.CompareF(KEComExample15DllOnC) == 0);
       
  2965  	}
       
  2966 
       
  2967 /**
       
  2968 Plugins to be used in this test
       
  2969 Interface UID	DLL	UID		Implementation UID	Version		DLL File
       
  2970 --------------------------------------------------------------------------------
       
  2971 0x10009E36		0x10009E3E	0x10009E39				1		C:\\..\\EComExample12.dll
       
  2972 				0x10009E3E	0x10009E3C				1		C:\\..\\EComExample12.dll
       
  2973 				0x10009E3E	0x10009E3D				1		C:\\..\\EComExample12.dll
       
  2974 				0x10009E42	0x10009E39				2		C:\\..\\EComExample15.dll
       
  2975 
       
  2976 @SYMTestCaseID			SYSLIB-ECOM-UT-3574
       
  2977 @SYMTestCaseDesc		Tests for CRegistryData::GetImplementationDllInfoForServer() function for DLL type PLUGIN3.
       
  2978 @SYMTestPriority		High
       
  2979 @SYMTestActions			Get the plugin information of the implementation UID and validate the information.
       
  2980 						Get the plugin information of the implementation UID and Interface UID and validate
       
  2981 						the information.
       
  2982 						Tests for loading implementation from RAM
       
  2983 						Tests for that the implementation returned will have the highest version
       
  2984 @SYMTestExpectedResults	Implementation information is returned correctly.
       
  2985 @SYMEC					EC43
       
  2986 */
       
  2987 void CRegistryDataTest::GetImplementationDllInfoForServerPlugIn3Test()
       
  2988  	{
       
  2989 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3574 "));
       
  2990   	TUid ImpUid15={0x10009E39};
       
  2991  	TUid ImpUid12={0x10009E3C};
       
  2992  	TUid InterfaceUid={0x10009E36};
       
  2993  	TEntry dllinfo;
       
  2994  	TInt err;
       
  2995 	TBool dummyBool;
       
  2996 
       
  2997  	//Tests the CImplementationInformation is correct
       
  2998  	//and the DllInfo contains correct implementation info
       
  2999  	//Implementation uid used=0x10009E3C
       
  3000  	CImplementationInformation* implementationInfo=NULL;
       
  3001  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid12, KCDummyUid, dllinfo, implementationInfo, dummyBool);
       
  3002  	TEST2(err, KErrNone);
       
  3003  	TEST(implementationInfo->ImplementationUid() == ImpUid12);
       
  3004  	TEST(implementationInfo->Version() == 1);
       
  3005  	TEST(dllinfo.iName.CompareF(KEComExample12DllOnC) == 0);
       
  3006 
       
  3007  	// ... again but with interface uid
       
  3008   	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid12, InterfaceUid, dllinfo, implementationInfo, dummyBool);
       
  3009  	TEST2(err, KErrNone);
       
  3010  	TEST(implementationInfo->ImplementationUid() == ImpUid12);
       
  3011  	TEST(implementationInfo->Version() == 1);
       
  3012  	TEST(dllinfo.iName.CompareF(KEComExample12DllOnC) == 0);
       
  3013 
       
  3014  	//Tests that the implementation returned will have the highest version
       
  3015  	//EComExample12.dll  contains Impl 0x10009E39 with version 1
       
  3016  	//EComExample15.dll contains Impl 0x10009E39 with version 2
       
  3017  	//Ensure that choose the implementation in EComExample15.dll
       
  3018  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid15, KCDummyUid, dllinfo, implementationInfo, dummyBool);
       
  3019  	TEST2(err, KErrNone);
       
  3020  	TEST(implementationInfo->ImplementationUid() == ImpUid15);
       
  3021  	TEST(implementationInfo->Version() == 2);
       
  3022  	TEST(dllinfo.iName.CompareF(KEComExample15DllOnC) == 0);
       
  3023 
       
  3024  	// ... again but with interface uid
       
  3025  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid15, InterfaceUid, dllinfo, implementationInfo, dummyBool);
       
  3026  	TEST2(err, KErrNone);
       
  3027  	TEST(implementationInfo->ImplementationUid() == ImpUid15);
       
  3028  	TEST(implementationInfo->Version() == 2);
       
  3029  	TEST(dllinfo.iName.CompareF(KEComExample15DllOnC) == 0);
       
  3030  	}
       
  3031 
       
  3032 /**
       
  3033 Tests for the CRegistryData::GetImplementationDllInfoForClientTestL.
       
  3034 Plugins to be used in this test
       
  3035 Interface UID	DLL	UID		Implementation UID	Version		DllFile
       
  3036 -------------------------------------------------------------------
       
  3037 0x10009DC0		0x10009DB1	0x10009DC3			1		C:\\..\\EComExample.dll
       
  3038 				0x10009DB1	0x10009DC4			1		C:\\..\\EComExample.dll
       
  3039 				0x10009DB3	0x10009DC3			2		C:\\..\\EComExample2.dll
       
  3040 				0x10009DB3	0x10009DC4			2		C:\\..\\EComExample2.dll
       
  3041 				0x101F8477	0x101F8478			1		C:\\..\\EComExample3.dll
       
  3042 				0x101F847B	0x101F847C			1		C:\\..\\EComExample5.dll
       
  3043 
       
  3044 
       
  3045 @SYMTestCaseID			SYSLIB-ECOM-CT-1374
       
  3046 @SYMTestCaseDesc		Tests for CRegistryData::GetImplementationDllInfoForClientL() function.
       
  3047 @SYMTestPriority			High
       
  3048 @SYMTestActions			Get the plugin information of the implementation UID and validate the information.
       
  3049 						Get the plugin information of the implementation UID and Interface UID and validate
       
  3050 						the information.
       
  3051 						Tests for  the CImplementationInformation is correct
       
  3052 						Tests for loading implementation from RAM
       
  3053 						Tests for that the implementation returned will have the highest version
       
  3054 						Tests for for invalid ImplementationUid
       
  3055 @SYMTestExpectedResults	The test must not fail.
       
  3056 @SYMREQ				DEF065552
       
  3057 */
       
  3058 void CRegistryDataTest::GetImplementationDllInfoForClientTestL()
       
  3059  	{
       
  3060 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1374 "));
       
  3061  	_LIT(KEComExample2,"C:\\sys\\bin\\EComExample2.dll");
       
  3062  	_LIT(KEComExample3,"C:\\sys\\bin\\EComExample3.dll");
       
  3063  	_LIT(KEComExample5,"C:\\sys\\bin\\EComExample5.dll");
       
  3064 
       
  3065  	TUid ImpUid={0x10009DC3};
       
  3066  	TUid ImpUid3={0x101F8478};
       
  3067  	TUid ImpUid5={0x101F847C};
       
  3068  	TEntry dllinfo;
       
  3069  	TInt err;
       
  3070  	TClientRequest clntRq;
       
  3071 
       
  3072  	//Testing the CImplementationInformation is correct
       
  3073  	//and the DllInfo contains correct implementation info
       
  3074  	//Implementation uid used=0x101F8478
       
  3075  	CImplementationInformation* implementationInfo=NULL;
       
  3076  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid3, KCDummyUid, dllinfo, implementationInfo, ETrue);
       
  3077  	TEST2(err, KErrNone);
       
  3078  	TEST(implementationInfo->ImplementationUid()==ImpUid3);
       
  3079  	TEST(implementationInfo->Version()==1);
       
  3080  	TEST(dllinfo.iName.CompareF(KEComExample3)==0);
       
  3081 
       
  3082  	// ... again but with interface uid
       
  3083   	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid3, iInterfaceUid, dllinfo, implementationInfo, ETrue);
       
  3084  	TEST2(err, KErrNone);
       
  3085  	TEST(implementationInfo->ImplementationUid()==ImpUid3);
       
  3086  	TEST(implementationInfo->Version()==1);
       
  3087  	TEST(dllinfo.iName.CompareF(KEComExample3)==0);
       
  3088 
       
  3089  	//Testing loading implementation from RAM(EComExample5.dll)
       
  3090  	//Implementation uid used=0x101F847C
       
  3091  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid5, KCDummyUid, dllinfo, implementationInfo, ETrue);
       
  3092  	TEST2(err, KErrNone);
       
  3093  	TEST(implementationInfo->ImplementationUid()==ImpUid5);
       
  3094  	TEST(implementationInfo->Version()==1);
       
  3095  	TEST(dllinfo.iName.CompareF(KEComExample5)==0);
       
  3096 
       
  3097  	// ... again but with interface uid
       
  3098  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid5, iInterfaceUid, dllinfo, implementationInfo, ETrue);
       
  3099  	TEST2(err, KErrNone);
       
  3100  	TEST(implementationInfo->ImplementationUid()==ImpUid5);
       
  3101  	TEST(implementationInfo->Version()==1);
       
  3102  	TEST(dllinfo.iName.CompareF(KEComExample5)==0);
       
  3103 
       
  3104  	//Testing that the implementation returned will have the highest version
       
  3105  	//EComExample.dll  contains Impl 0x10009DC3 with version 1
       
  3106  	//EComExample2.dll contains Impl 0x10009DC3 with version 2
       
  3107  	//Ensure that choose the implementation in EComExample2.dll
       
  3108  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid, KCDummyUid, dllinfo, implementationInfo, ETrue);
       
  3109  	TEST2(err, KErrNone);
       
  3110  	TEST(implementationInfo->ImplementationUid()==ImpUid);
       
  3111  	TEST(implementationInfo->Version()==2);
       
  3112  	TEST(dllinfo.iName.CompareF(KEComExample2)==0);
       
  3113 
       
  3114  	// ... again but with interface uid
       
  3115  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid, iInterfaceUid, dllinfo, implementationInfo, ETrue);
       
  3116  	TEST2(err, KErrNone);
       
  3117  	TEST(implementationInfo->ImplementationUid()==ImpUid);
       
  3118  	TEST(implementationInfo->Version()==2);
       
  3119  	TEST(dllinfo.iName.CompareF(KEComExample2)==0);
       
  3120 
       
  3121  	//Testing for invalid ImplementationUid
       
  3122  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, KCInvalidUid, KCDummyUid, dllinfo, implementationInfo, ETrue);
       
  3123  	TEST2(err, KErrNotFound);
       
  3124  	TEST(implementationInfo==0);
       
  3125 
       
  3126  	//Testing for invalid InterfaceUid
       
  3127  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, ImpUid, KCInvalidUid, dllinfo, implementationInfo, ETrue);
       
  3128  	TEST2(err, KErrNotFound);
       
  3129  	TEST(implementationInfo==0);
       
  3130 
       
  3131  	//Testing for invalid ImplementationUid and invalid InterfaceUid
       
  3132  	err = iRegistryData->GetImplementationDllInfoForClientL(clntRq, KCInvalidUid, KCInvalidUid, dllinfo, implementationInfo, ETrue);
       
  3133  	TEST2(err, KErrNotFound);
       
  3134  	TEST(implementationInfo==0);
       
  3135  	}
       
  3136 
       
  3137 /**
       
  3138 Tests for the CRegistryData::GetImplementationDllInfoForServer.
       
  3139 This new API is introduced in the Clientside loading of plugins(ECOM Platform security)
       
  3140 where the server will return the plugin information(aEntry) of the implementation Uid
       
  3141 requested by the client.
       
  3142 Plugins to be used in this test
       
  3143 Interface UID	DLL	UID		Implementation UID	Version		DllFile
       
  3144 -------------------------------------------------------------------
       
  3145 0x10009DC0		0x10009DB1	0x10009DC3			1		C:\\..\\EComExample.dll
       
  3146 				0x10009DB1	0x10009DC4			1		C:\\..\\EComExample.dll
       
  3147 				0x10009DB3	0x10009DC3			2		C:\\..\\EComExample2.dll
       
  3148 				0x10009DB3	0x10009DC4			2		C:\\..\\EComExample2.dll
       
  3149 				0x101F8477	0x101F8478			1		C:\\..\\EComExample3.dll
       
  3150 				0x101F847B	0x101F847C			1		C:\\..\\EComExample5.dll
       
  3151 
       
  3152 
       
  3153 @SYMTestCaseID			SYSLIB-ECOM-CT-0749
       
  3154 @SYMTestCaseDesc		Tests for CRegistryData::GetImplementationDllInfoForServer() function.
       
  3155 @SYMTestPriority			High
       
  3156 @SYMTestActions			Get the plugin information of the implementation UID and validate the information.
       
  3157 						Get the plugin information of the implementation UID and Interface UID and validate
       
  3158 						the information.
       
  3159 						Tests for  the CImplementationInformation is correct
       
  3160 						Tests for loading implementation from RAM
       
  3161 						Tests for that the implementation returned will have the highest version
       
  3162 						Tests for for invalid ImplementationUid
       
  3163 @SYMTestExpectedResults	The test must not fail.
       
  3164 @SYMREQ				REQ0000
       
  3165 */
       
  3166 void CRegistryDataTest::GetImplementationDllInfoForServerTest()
       
  3167  	{
       
  3168 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0749 "));
       
  3169  	_LIT(KEComExample2,"C:\\sys\\bin\\EComExample2.dll");
       
  3170  	_LIT(KEComExample3,"C:\\sys\\bin\\EComExample3.dll");
       
  3171  	_LIT(KEComExample5,"C:\\sys\\bin\\EComExample5.dll");
       
  3172 
       
  3173  	TUid ImpUid={0x10009DC3};
       
  3174  	TUid ImpUid3={0x101F8478};
       
  3175  	TUid ImpUid5={0x101F847C};
       
  3176  	TEntry dllinfo;
       
  3177  	TInt err;
       
  3178 	TBool dummyBool;
       
  3179 
       
  3180  	//Testing the CImplementationInformation is correct
       
  3181  	//and the DllInfo contains correct implementation info
       
  3182  	//Implementation uid used=0x101F8478
       
  3183  	CImplementationInformation* implementationInfo=NULL;
       
  3184  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid3, KCDummyUid, dllinfo, implementationInfo, dummyBool);
       
  3185  	TEST2(err, KErrNone);
       
  3186  	TEST(implementationInfo->ImplementationUid()==ImpUid3);
       
  3187  	TEST(implementationInfo->Version()==1);
       
  3188  	TEST(dllinfo.iName.CompareF(KEComExample3)==0);
       
  3189 
       
  3190  	// ... again but with interface uid
       
  3191   	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid3, iInterfaceUid, dllinfo, implementationInfo, dummyBool);
       
  3192  	TEST2(err, KErrNone);
       
  3193  	TEST(implementationInfo->ImplementationUid()==ImpUid3);
       
  3194  	TEST(implementationInfo->Version()==1);
       
  3195  	TEST(dllinfo.iName.CompareF(KEComExample3)==0);
       
  3196 
       
  3197  	//Testing loading implementation from RAM(EComExample5.dll)
       
  3198  	//Implementation uid used=0x101F847C
       
  3199  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid5, KCDummyUid, dllinfo, implementationInfo, dummyBool);
       
  3200  	TEST2(err, KErrNone);
       
  3201  	TEST(implementationInfo->ImplementationUid()==ImpUid5);
       
  3202  	TEST(implementationInfo->Version()==1);
       
  3203  	TEST(dllinfo.iName.CompareF(KEComExample5)==0);
       
  3204 
       
  3205  	// ... again but with interface uid
       
  3206  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid5, iInterfaceUid, dllinfo, implementationInfo, dummyBool);
       
  3207  	TEST2(err, KErrNone);
       
  3208  	TEST(implementationInfo->ImplementationUid()==ImpUid5);
       
  3209  	TEST(implementationInfo->Version()==1);
       
  3210  	TEST(dllinfo.iName.CompareF(KEComExample5)==0);
       
  3211 
       
  3212  	//Testing that the implementation returned will have the highest version
       
  3213  	//EComExample.dll  contains Impl 0x10009DC3 with version 1
       
  3214  	//EComExample2.dll contains Impl 0x10009DC3 with version 2
       
  3215  	//Ensure that choose the implementation in EComExample2.dll
       
  3216  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid, KCDummyUid, dllinfo, implementationInfo, dummyBool);
       
  3217  	TEST2(err, KErrNone);
       
  3218  	TEST(implementationInfo->ImplementationUid()==ImpUid);
       
  3219  	TEST(implementationInfo->Version()==2);
       
  3220  	TEST(dllinfo.iName.CompareF(KEComExample2)==0);
       
  3221 
       
  3222  	// ... again but with interface uid
       
  3223  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid, iInterfaceUid, dllinfo, implementationInfo, dummyBool);
       
  3224  	TEST2(err, KErrNone);
       
  3225  	TEST(implementationInfo->ImplementationUid()==ImpUid);
       
  3226  	TEST(implementationInfo->Version()==2);
       
  3227  	TEST(dllinfo.iName.CompareF(KEComExample2)==0);
       
  3228 
       
  3229  	//Testing for invalid ImplementationUid
       
  3230  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, KCInvalidUid, KCDummyUid, dllinfo, implementationInfo, dummyBool);
       
  3231  	TEST2(err, KErrNotFound);
       
  3232  	TEST(implementationInfo==0);
       
  3233 
       
  3234  	//Testing for invalid InterfaceUid
       
  3235  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, ImpUid, KCInvalidUid, dllinfo, implementationInfo, dummyBool);
       
  3236  	TEST2(err, KErrNotFound);
       
  3237  	TEST(implementationInfo==0);
       
  3238 
       
  3239  	//Testing for invalid ImplementationUid and invalid InterfaceUid
       
  3240  	err = iRegistryData->GetImplementationDllInfoForServer(dummycaps, KCInvalidUid, KCInvalidUid, dllinfo, implementationInfo, dummyBool);
       
  3241  	TEST2(err, KErrNotFound);
       
  3242  	TEST(implementationInfo==0);
       
  3243  	}
       
  3244 
       
  3245 /**
       
  3246 @SYMTestCaseID          SYSLIB-ECOM-CT-0750
       
  3247 @SYMTestCaseDesc	    OOM test for the creation and deletion of CRegistryData
       
  3248 @SYMTestPriority 	    High
       
  3249 @SYMTestActions  	    Create and delete CRegistryData object,checks for handles leaked
       
  3250 @SYMTestExpectedResults The test must not fail.
       
  3251 @SYMREQ                 REQ0000
       
  3252 */
       
  3253 LOCAL_C void OOMCreateDeleteTest()
       
  3254 	{
       
  3255 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0750 OOM CreateDeleteTest "));
       
  3256 	TInt err;
       
  3257 	TInt failAt = 1;
       
  3258 	__UNUSED_VAR(failAt);
       
  3259 
       
  3260 	CRegistryDataTest* theTest = NULL;
       
  3261 
       
  3262 	do
       
  3263 		{
       
  3264 		__UHEAP_MARK;
       
  3265   		// find out the number of open handles
       
  3266 		TInt startProcessHandleCount;
       
  3267 		TInt startThreadHandleCount;
       
  3268 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  3269 
       
  3270 		__UHEAP_SETFAIL(RHeap::EDeterministic, failAt++);
       
  3271 
       
  3272 		TRAP(err, theTest = CRegistryDataTest::NewL(EFalse));
       
  3273 
       
  3274 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
  3275 
       
  3276 		delete theTest;
       
  3277 		theTest = NULL;
       
  3278 
       
  3279 		// check that no handles have leaked
       
  3280 		TInt endProcessHandleCount;
       
  3281 		TInt endThreadHandleCount;
       
  3282 		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  3283 
       
  3284 		TEST(startProcessHandleCount == endProcessHandleCount);
       
  3285 		TEST(startThreadHandleCount  == endThreadHandleCount);
       
  3286 
       
  3287 		__UHEAP_MARKEND;
       
  3288 		}
       
  3289 	while(err == KErrNoMemory);
       
  3290 
       
  3291 	TheTest.Printf(_L("- Succeeded at heap failure rate of %i\n"), failAt);
       
  3292  	TEST2(err, KErrNone);
       
  3293 	}
       
  3294 
       
  3295 /**
       
  3296 @SYMTestCaseID			SYSLIB-ECOM-UT-1408
       
  3297 @SYMTestCaseDesc		Unit tests for CRegistryData::IsAnyDiscoveredL
       
  3298 @SYMTestPriority		High
       
  3299 @SYMTestActions			Calls each of the actions that should cause IsAnyDiscovered to be set. Because the behavior is different with and without SPI, the tests are separated into a test with SPI and a test without
       
  3300 @SYMTestExpectedResults	IsAnyDiscovered should be false when CDriveData is created, and false when the drive is internalized with no dat file.
       
  3301 						It should be true when the drive is internalized and there is a dat file.
       
  3302 @SYMPREQ				PREQ1192
       
  3303 */
       
  3304 void  CRegistryDataTest::IsAnyDllDiscoveredTestL()
       
  3305 	{
       
  3306 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-1408 "));
       
  3307 	if (SpiFileExists())
       
  3308 		{
       
  3309 		IsAnyDllDiscoveredTestWithSpiL();
       
  3310 		}
       
  3311 	IsAnyDllDiscoveredTestNoSpiL();
       
  3312 	}
       
  3313 
       
  3314 void  CRegistryDataTest::IsAnyDllDiscoveredTestWithSpiL()
       
  3315 	{
       
  3316 	//
       
  3317 	// Test DatFileExists for dat files on ROM when there is a SPI file
       
  3318 	//
       
  3319 
       
  3320 	iStateAccessor->ClearRegistrations(*iRegistryData);
       
  3321 
       
  3322 	// when a CDriveData is created DatFileExists should be false
       
  3323 	CRegistryData::CDriveData* driveDataZ = CRegistryData::CDriveData::NewLC(EDriveZ, iRegistryData);
       
  3324 	iStateAccessor->AppendDriveDataL(*iRegistryData, driveDataZ);
       
  3325 	CleanupStack::Pop(driveDataZ);
       
  3326 	TEST(!iRegistryData->IsAnyDllRegisteredWithDriveL(EDriveZ));
       
  3327 	}
       
  3328 
       
  3329 void  CRegistryDataTest::IsAnyDllDiscoveredTestNoSpiL()
       
  3330 	{
       
  3331 	//
       
  3332 	// Test IsAnyDiscovered for dat files on ROM when there is no SPI file
       
  3333 	//
       
  3334 
       
  3335 	iStateAccessor->ClearRegistrations(*iRegistryData);
       
  3336 
       
  3337 	// when a CDriveData is created there should be no DLL entries so IsAnyDiscoveredL should be false
       
  3338 	CRegistryData::CDriveData* driveDataC = CRegistryData::CDriveData::NewLC(EDriveC, iRegistryData);
       
  3339 	iStateAccessor->AppendDriveDataL(*iRegistryData, driveDataC);
       
  3340 	CleanupStack::Pop(driveDataC);
       
  3341 	TEST(!iRegistryData->IsAnyDllRegisteredWithDriveL(EDriveC));
       
  3342 	}
       
  3343 
       
  3344 /**
       
  3345 Adds the dll data on a particular drive.
       
  3346 
       
  3347 @SYMTestCaseID          SYSLIB-ECOM-UT-1407
       
  3348 @SYMTestCaseDesc	    Tests for CRegistryData::CDllData::ProcessSecurityCheckL() function
       
  3349 @SYMTestPriority 	    High
       
  3350 @SYMTestActions  	    Creates CDllData objects and calls ProcessSecurityCheckL on them
       
  3351                         The CDllData with a missing DLL should return EFalse, the CDllData with invalid
       
  3352                         SID should return EFalse, and a valid CDllData should return ETrue and ensure the VID
       
  3353                         match the VID of the valid DLL.
       
  3354 @SYMTestExpectedResults ProcessSecurityCheckL returns false when a plugin's dll doesn't exist or has an invalid SID, true otherwise.
       
  3355 @SYMREQ                 PREQ1192, REQ6111
       
  3356 */
       
  3357 void CRegistryDataTest::ProcessSecurityCheckTestL()
       
  3358 	{
       
  3359 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-1407 "));
       
  3360 	TParse fileparse;
       
  3361 	TDriveUnit driveUnitC(EDriveC);
       
  3362 	CRegistryData *registryData = CRegistryData::NewL(TheFs);
       
  3363 	CleanupStack::PushL(registryData);
       
  3364 	CRegistryData::CDriveData *driveCData = CRegistryData::CDriveData::NewLC(driveUnitC, registryData);
       
  3365 
       
  3366 	//
       
  3367 	// Test that a missing DLL causes ProcessSecurityCheckL to return EFalse
       
  3368 	//
       
  3369 	TEntry missingDllEntry;
       
  3370 	missingDllEntry.iName = KEComMissingDll;
       
  3371 	fileparse.Set(KEComMissingDll,NULL,NULL);
       
  3372 	CRegistryData::CDllData* missingDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),missingDllEntry.iModified,KNullUid,KNullUid, driveCData);
       
  3373 	TEST(!missingDllData->ProcessSecurityCheckL());
       
  3374 	CleanupStack::PopAndDestroy(missingDllData);
       
  3375 
       
  3376 	//
       
  3377 	// Test that an invalid SID causes ProcessSecurityCheckL to return EFalse
       
  3378 	//
       
  3379 	TEntry mismatchedSidDllEntry;
       
  3380 	// The actual secure Id for this DLL is 0x10009DB1, here the corresponding ID is set to 0x01010101
       
  3381 	TUidType mismatchedSidUidType(KCInvalidUid, KCInvalidUid, KCInvalidUid);
       
  3382 	mismatchedSidDllEntry.iName = KEComExampleDllOnZSysBin;
       
  3383 	mismatchedSidDllEntry.iType = mismatchedSidUidType;
       
  3384 	fileparse.Set(KEComExampleDllOnZSysBin,NULL,NULL);
       
  3385 	CRegistryData::CDllData* mismatchedSidDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),mismatchedSidDllEntry.iModified,mismatchedSidUidType[1],mismatchedSidUidType[2], driveCData);
       
  3386 	TEST(!mismatchedSidDllData->ProcessSecurityCheckL());
       
  3387 	CleanupStack::PopAndDestroy(mismatchedSidDllData);
       
  3388 
       
  3389 	//
       
  3390 	// Test that a valid entry causes ProcessSecurityCheckL to return ETrue
       
  3391 	//
       
  3392 	TUid KEcomExampleSecureId = {0x10009DB1};
       
  3393 	TEntry validDllEntry;
       
  3394 	TUidType validUidType(KCInvalidUid, KUidInterfaceImplementationCollection, KEcomExampleSecureId);
       
  3395 	validDllEntry.iName = KEComExampleDllOnZSysBin;
       
  3396 	validDllEntry.iType = validUidType;
       
  3397 	fileparse.Set(KEComExampleDllOnZSysBin(),NULL,NULL);
       
  3398 	CRegistryData::CDllData* validDllData = CRegistryData::CDllData::NewLC(fileparse.NameAndExt(),validDllEntry.iModified,validUidType[1],validUidType[2], driveCData);
       
  3399 	// Because ProcessSecurityCheckL is handled differently the first and second times it is called for a given DLL
       
  3400 	// ProcessSecurityCheckL is called twice here to test both cases (the fist time the security check is performed, and the second time
       
  3401 	// a cached value is used)
       
  3402 	TEST(validDllData->ProcessSecurityCheckL());
       
  3403 	TEST(validDllData->ProcessSecurityCheckL());
       
  3404 	// check the VID of the DLL.
       
  3405 	TEST((validDllData->iVid).iId == 0x70000001);
       
  3406 	CleanupStack::PopAndDestroy(validDllData);
       
  3407 
       
  3408 
       
  3409 	// Clean up
       
  3410 	CleanupStack::PopAndDestroy(driveCData);
       
  3411 	CleanupStack::PopAndDestroy(registryData);
       
  3412 	}
       
  3413 
       
  3414 /**
       
  3415 Tests functionality of ListImplementationsL for an interface ID where the security checks
       
  3416 for DLLs implementing the given interface fail
       
  3417 
       
  3418 @SYMTestCaseID          SYSLIB-ECOM-UT-1405
       
  3419 @SYMTestCaseDesc	    Tests for CRegistryData::ListImplementationsL() function
       
  3420 @SYMTestPriority 	    High
       
  3421 @SYMTestActions  		Makes sure the failed DLL security checks are handled properly
       
  3422 						An RSC file with an incorrect SID is tested, followed by an RSC file with a missing DLL
       
  3423 @SYMTestExpectedResults ECom plugin's with invalid DLLs are not returned.
       
  3424 @SYMREQ                 PREQ1192
       
  3425 */
       
  3426 void CRegistryDataTest::FailedSecurityCheckTestListImplementationsL()
       
  3427 	{
       
  3428 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-1405 "));
       
  3429 	// Set up for heap leak checking
       
  3430 	__UHEAP_MARK;
       
  3431 
       
  3432 	//
       
  3433 	// Test that mismatching SIDs cause a plug-in to not be returned through ListImplementationsL
       
  3434 	// InvalidSIDPlugin.rsc and InvalidSIDPlugin.dll are on the C drive, but their SIDs do not match
       
  3435 	// This will cause the DLL security check to fail, and since there are no other implementations of this interface,
       
  3436 	// no implementations should be returned
       
  3437 	//
       
  3438 	TUid ifUid1 = {0x101FE392};	// the interface UID for InvalidSIDPlugin
       
  3439 
       
  3440 	TRAPD(err, iRegistryData->ListImplementationsL(ifUid1,iImplDataList));
       
  3441 
       
  3442 	TEST_OOM_ERR;
       
  3443 	// Since there are no other plug-ins implementing {0x101FE392}, there should be no implementations found
       
  3444 	TEST2(err, KEComErrNoInterfaceIdentified);
       
  3445 
       
  3446 	//
       
  3447 	// Test that a missing DLL causes a plug-in to not be returned through ListImplementationsL
       
  3448 	// and that other valid implementations are rolled back to when this happens
       
  3449 	//
       
  3450 	// EComRomRslvrExampleOnC.rsc is on the C drive, and has an implementation that upgrades EComRomRslvrExampleOnZ.rsc
       
  3451 	// The DLL corresponding to EComRomRslvrExampleOnC.rsc is missing, so will fail the security check
       
  3452 	// This means Ecom should fall back to the implementations from EComRomRslvrExampleOnZ
       
  3453 	//
       
  3454 	TUid ifUid3 = {0x10009DC8};  // the interface UID for EComRomRslvrExampleDllOnZ and EComRomRslvrExampleDllOnC
       
  3455 	TRAP(err, iRegistryData->ListImplementationsL(ifUid3,iImplDataList));
       
  3456 
       
  3457 	TEST_OOM_ERR;
       
  3458 	TEST2(err, KErrNone);
       
  3459 	CleanupClosePushL(iImplDataList);
       
  3460 
       
  3461 	// Print UIDs of implementations
       
  3462 	_LIT(KUIDFormat,"Uid = 0x%08x\n");
       
  3463 	_LIT(KLists,"There are %d Implementations \n");
       
  3464 
       
  3465 	TheTest.Printf(KLists, iImplDataList.Count());
       
  3466 
       
  3467 	// Go through each of the implementations returned, and find the ones that match up with EComRomRslvrExampleRscOnZ
       
  3468 	// (not the ones from EComRomRslvrExampleRscOnC because it's DLL is missing)
       
  3469 	// EComRomRslvrExampleOnZ contains the implementation 0x10009DC7v2 and 0x10009DC6v1 (these should be found)
       
  3470 	// EComRomRslvrExampleOnC contains the implementation 0x10009DC7v1 and 0x10009DC6v2 (these should NOT be returned becuase of the missing DLL)
       
  3471 	TBool foundRightImplementation1 = EFalse;
       
  3472 	TBool foundRightImplementation2 = EFalse;
       
  3473 	for(TInt index = 0; index < iImplDataList.Count(); ++index)
       
  3474 		{
       
  3475 		CImplementationInformation* implInfo = iImplDataList[index]->iImplInfo;
       
  3476 		TUid uid = implInfo->ImplementationUid();
       
  3477 		TInt version = implInfo->Version();
       
  3478 		if (uid.iUid == 0x10009DC6)
       
  3479 			{
       
  3480 			TEST(version == 1);
       
  3481 			// The implementation of 0x10009DC6 from EComRomRslvrExampleOnZ was found
       
  3482 			foundRightImplementation1 = ETrue;
       
  3483 			}
       
  3484 		if (uid.iUid == 0x10009DC7)
       
  3485 			{
       
  3486 			TEST(version == 2);
       
  3487 			// The implementation of 0x10009DC7 from EComRomRslvrExampleOnZ was found
       
  3488 			foundRightImplementation2 = ETrue;
       
  3489 			}
       
  3490 		TheTest.Printf(KUIDFormat, uid);
       
  3491 		}
       
  3492 	// Test that both implementations were found
       
  3493 	TEST(foundRightImplementation1 && foundRightImplementation2);
       
  3494 
       
  3495 
       
  3496 	CleanupStack::PopAndDestroy(&iImplDataList);
       
  3497 	__UHEAP_MARKEND;
       
  3498 	}
       
  3499 
       
  3500 /**
       
  3501 Tests functionality of ListImplementationsL for an interface id where the corresponding
       
  3502 DLL fails the se
       
  3503 
       
  3504 @SYMTestCaseID          SYSLIB-ECOM-UT-1406
       
  3505 @SYMTestCaseDesc	    Tests for CRegistryData::GetImplementationDllInfoForClientL() function
       
  3506 @SYMTestPriority 	    High
       
  3507 @SYMTestActions  		Makes sure the plug-ins that will fail a security check are not returned through GetImplementationDllInfoForClientL
       
  3508 						InvalidSIDPlugin.rsc and InvalidSIDPlugin.dll are on the C drive, with non-matching SIDs, so will fail a security check
       
  3509 						Because the security check fails, no implementation should be returned
       
  3510 						EComRomRslvrExampleOnC is on the C drive, without its associated DLL so will fail a security check
       
  3511 						Because the DLL is not there, Ecom should fall back to the implementations on the Z drive in EComRomRslvrExampleOnZ
       
  3512 @SYMTestExpectedResults ECom plugin's with invalid DLLs are not returned.
       
  3513 @SYMREQ                 PREQ1192
       
  3514 */
       
  3515 void CRegistryDataTest::FailedSecurityCheckTestGetImplementationInfoL()
       
  3516 	{
       
  3517 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-1406 "));
       
  3518 	// Set up for heap leak checking
       
  3519 	__UHEAP_MARK;
       
  3520 
       
  3521 	//
       
  3522 	// Test that mismatching SIDs cause a plug-in to not be returned through GetImplementationDllInfoForClientL
       
  3523 	//
       
  3524 	TUid implUid1 = {0x101FE393};  // the implementation UID for InvalidSIDPlugin
       
  3525 	TUid ifUid1 = {0x101FE392};  // the interface UID for InvalidSIDPlugin
       
  3526 	TClientRequest clientReq;
       
  3527 	TEntry dllInfo;
       
  3528 	CImplementationInformation *implementationInfo = NULL;
       
  3529 	// Test for GetImplementatioDllInfoForClientL when security check is not done.
       
  3530 	TInt err = iRegistryData->GetImplementationDllInfoForClientL(clientReq, implUid1, ifUid1, dllInfo, implementationInfo, EFalse);
       
  3531 	TEST2(err, KErrNone);
       
  3532 	TEST(dllInfo.iName.Compare(_L("C:\\sys\\bin\\InvalidSIDPlugin.dll")) == 0);
       
  3533 	// Test for GetImplementatioDllInfoForClientL when security check is done.
       
  3534 	err = iRegistryData->GetImplementationDllInfoForClientL(clientReq, implUid1, ifUid1, dllInfo, implementationInfo, ETrue);
       
  3535 	// Because the security check failed for InvalidSIDPlugin and there are no other implementations of implementation UID 0x101FE393, KErrNotFound is returned
       
  3536 	TEST2(err, KErrNotFound);
       
  3537 	//
       
  3538 	// Test that a missing DLL causes a plug-in to not be returned through GetImplementationDllInfoForClientL
       
  3539 	// and that other valid implementations are rolled back to when this happens
       
  3540 	//
       
  3541 	TUid implUid3 = {0x10009DC7};  // EComRomRslvrExampleDllOnZ
       
  3542 	TUid ifUid3 = {0x10009DC8};  // EComRomRslvrExampleDllOnZ
       
  3543 	err = iRegistryData->GetImplementationDllInfoForClientL(clientReq, implUid3, ifUid3, dllInfo, implementationInfo, ETrue);
       
  3544 	TEST2(err, KErrNone);
       
  3545 	// Because the security check failed for EComRomRslvrExampleDllOnC the returned implementation should rollback to the implementation on the Z drive
       
  3546 	TEST(dllInfo.iName.Compare(_L("C:\\sys\\bin\\EComRomRslvrExampleOnZ.dll")) == 0);
       
  3547 
       
  3548 	__UHEAP_MARKEND;
       
  3549 	}
       
  3550 
       
  3551 /**
       
  3552 Test case for Defect ECOM non-spi handling of multiple localised resource files with same name but different extension.
       
  3553 Only one dll is created.
       
  3554 
       
  3555 @SYMTestCaseID		SYSLIB-ECOM-CT-1806
       
  3556 @SYMTestCaseDesc 	This function is used to check no duplication DLL is created when
       
  3557 					there are multiple resource files with same name but different extensions.
       
  3558 @SYMTestPriority 	High
       
  3559 @SYMTestActions  	Use CDiscoverer::CDirScanner::ScanDriveL to start discovery plugins on C:.
       
  3560 					Check that the dll list only has one dll existing with specified dll and interface UID.
       
  3561 @SYMTestExpectedResults The test must not fail.
       
  3562 @SYMDEF	DEF87787
       
  3563 */
       
  3564 void CRegistryDataTest::CheckDuplicatPluginsOnCL()
       
  3565 	{
       
  3566 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1806 "));
       
  3567 
       
  3568 	//clean up all resource files in C:
       
  3569 	DeleteTestPlugin();
       
  3570 
       
  3571 	TDriveUnit driveC = TDriveUnit(KDriveC);
       
  3572 
       
  3573 	TRegistrarObserverStub* registrarObsv = new(ELeave) TRegistrarObserverStub;
       
  3574 	CleanupStack::PushL(registrarObsv);
       
  3575 
       
  3576 	CRegistryData* registryData = CRegistryData::NewL(TheFs);
       
  3577 	CleanupStack::PushL(registryData);
       
  3578 
       
  3579 	CRegistrar* registrar = CRegistrar::NewL(*registryData, *registrarObsv, TheFs);
       
  3580 	CleanupStack::PushL(registrar);
       
  3581 
       
  3582 	TRegistryData_StateAccessor* stateAccessor= new(ELeave) TRegistryData_StateAccessor;
       
  3583 	CleanupStack::PushL(stateAccessor);
       
  3584 
       
  3585 	//After construction check that: registry is empty
       
  3586 	TEST(stateAccessor->RegistrationsCount(*registryData) == 0);
       
  3587 
       
  3588     //Copies multiple resource file with same name but different extensions on C:.
       
  3589     TRAPD(err, EComTestUtils::FileManCopyFileL(KEComExDllOnZ, KEComExDllOnC));
       
  3590  	TEST2(err, KErrNone);
       
  3591 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComRscFileOnZ, KEComRscFileOnC));
       
  3592  	TEST2(err, KErrNone);
       
  3593  	_LIT(KEComRscFileA01OnC,	"C:\\resource\\plugins\\EComExample5.A01");
       
  3594  	TRAP(err, EComTestUtils::FileManCopyFileL(KEComRscFileOnZ, KEComRscFileA01OnC));
       
  3595  	TEST2(err, KErrNone);
       
  3596  	_LIT(KEComRscFileA02OnC,	"C:\\resource\\plugins\\EComExample5.A02");
       
  3597  	TRAP(err, EComTestUtils::FileManCopyFileL(KEComRscFileOnZ, KEComRscFileA02OnC));
       
  3598  	TEST2(err, KErrNone);
       
  3599 
       
  3600 	//Scan C: drive
       
  3601 	TRegistrar_StateAccessor registrarStateAccessorStub;
       
  3602 	registrarStateAccessorStub.ScanDriveL(*registrar, driveC);
       
  3603 
       
  3604 
       
  3605 	TDll *DllList = NULL;
       
  3606 	TInt indx = stateAccessor->GetDllListL(*registryData, driveC, DllList);
       
  3607 	TEST(indx == 0);
       
  3608 	TEST(DllList->Count() == 1);
       
  3609 	CRegistryData::CDllData *dllData = (*DllList)[0];
       
  3610 
       
  3611 	//Testing loading implementation from RAM(EComExample5.dll) with specified Dll and interface UID.
       
  3612  	TUid thirdDllUid = {0x101F847B};
       
  3613 	TEST(dllData->iDllEntry->GetThirdUid() == thirdDllUid);
       
  3614  	TUid InterfaceUid5={0x10009DC0};
       
  3615 	TEST2(stateAccessor->FindAnImplementation(*registryData, InterfaceUid5, driveC), ETrue);
       
  3616 
       
  3617 	//Clean up
       
  3618 	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComExDllOnC));
       
  3619  	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComRscFileOnC));
       
  3620  	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComRscFileA01OnC));
       
  3621  	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComRscFileA02OnC));
       
  3622 
       
  3623  	CleanupStack::PopAndDestroy(stateAccessor);
       
  3624     CleanupStack::PopAndDestroy(registrar);
       
  3625     CleanupStack::PopAndDestroy(registryData);
       
  3626     CleanupStack::PopAndDestroy(registrarObsv);
       
  3627 
       
  3628     //back to orignal state before the test
       
  3629     CopyPluginsL();
       
  3630  	}
       
  3631 
       
  3632 /**
       
  3633 Test case for Defect ECOM non-spi handling of multiple localised resource files but without
       
  3634 a proper RSC file based on language downgrade path.
       
  3635 
       
  3636 @SYMTestCaseID		SYSLIB-ECOM-CT-1829
       
  3637 @SYMTestCaseDesc 	This function is used to check no DLL is created when multiple resource files
       
  3638 					exists but no proper RSC file based on language downgrade path.
       
  3639 @SYMTestPriority 	High
       
  3640 @SYMTestActions  	Use CDiscoverer::CDirScanner::ScanDriveL to start discovery plugins on C:.
       
  3641 					Check that the dll list is empty after scanning.
       
  3642 @SYMTestExpectedResults The test must not fail.
       
  3643 @SYMDEF	DEF87787
       
  3644 */
       
  3645 
       
  3646 void CRegistryDataTest::CheckNoPluginsOnCL()
       
  3647 	{
       
  3648 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1829 "));
       
  3649 
       
  3650 	//clean up all resource files in C:
       
  3651 	DeleteTestPlugin();
       
  3652 
       
  3653 	TDriveUnit driveC = TDriveUnit(KDriveC);
       
  3654 
       
  3655 	TRegistrarObserverStub* registrarObsv = new(ELeave) TRegistrarObserverStub;
       
  3656 	CleanupStack::PushL(registrarObsv);
       
  3657 
       
  3658 	CRegistryData* registryData = CRegistryData::NewL(TheFs);
       
  3659 	CleanupStack::PushL(registryData);
       
  3660 
       
  3661 	CRegistrar* registrar = CRegistrar::NewL(*registryData, *registrarObsv, TheFs);
       
  3662 	CleanupStack::PushL(registrar);
       
  3663 
       
  3664 	TRegistryData_StateAccessor* stateAccessor= new(ELeave) TRegistryData_StateAccessor;
       
  3665 	CleanupStack::PushL(stateAccessor);
       
  3666 
       
  3667 	//After construction check that registry is empty
       
  3668 	TEST(stateAccessor->RegistrationsCount(*registryData) == 0);
       
  3669 
       
  3670     //Copies only EComExample5.A01 and EComExample5.A02 to C:, but no EComExample5.RSC
       
  3671 	TRAPD(err, EComTestUtils::FileManCopyFileL(KEComExDllOnZ, KEComExDllOnC));
       
  3672  	TEST2(err, KErrNone);
       
  3673  	_LIT(KEComRscFileA01OnC,	"C:\\resource\\plugins\\EComExample5.A01");
       
  3674  	TRAP(err, EComTestUtils::FileManCopyFileL(KEComRscFileOnZ, KEComRscFileA01OnC));
       
  3675  	TEST2(err, KErrNone);
       
  3676  	_LIT(KEComRscFileA02OnC,	"C:\\resource\\plugins\\EComExample5.A02");
       
  3677  	TRAP(err, EComTestUtils::FileManCopyFileL(KEComRscFileOnZ, KEComRscFileA02OnC));
       
  3678  	TEST2(err, KErrNone);
       
  3679 
       
  3680 	//Scan C: drive
       
  3681 	TRegistrar_StateAccessor registrarStateAccessorStub;
       
  3682 	registrarStateAccessorStub.ScanDriveL(*registrar, driveC);
       
  3683 
       
  3684 	//check dll list. No dll is created.
       
  3685 	TDll *DllList = NULL;
       
  3686 	TInt indx = stateAccessor->GetDllListL(*registryData, driveC, DllList);
       
  3687 	TEST(indx == 0);
       
  3688 	TEST(DllList->Count() == 0);
       
  3689 
       
  3690  	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComExDllOnC));
       
  3691  	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComRscFileA01OnC));
       
  3692  	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComRscFileA02OnC));
       
  3693 
       
  3694  	CleanupStack::PopAndDestroy(stateAccessor);
       
  3695     CleanupStack::PopAndDestroy(registrar);
       
  3696     CleanupStack::PopAndDestroy(registryData);
       
  3697     CleanupStack::PopAndDestroy(registrarObsv);
       
  3698 
       
  3699     //back to orignal state before the test
       
  3700     CopyPluginsL();
       
  3701 
       
  3702 	}
       
  3703 
       
  3704 /**
       
  3705 Test case for implementations with same implementation UID but different
       
  3706 interface UIDs. Implementation UIDs should be globally unique. So this
       
  3707 is an error condition. But to maintain backward compatibility,
       
  3708 ECom will allow it. List operation and most of the time, create
       
  3709 should work. Problem arises if client uses the create request which
       
  3710 does not supply the interface UID. In that case ECom applies a set of
       
  3711 rules to determine which of the duplicate to pick. The returned
       
  3712 impl. may not be the one the client is expecting. The rules from high
       
  3713 precedence to low are:
       
  3714 1. ROM based > non-ROM based,
       
  3715 2. High drive letter > low drive letter
       
  3716 3. Low I/F UID > High I/F UID.
       
  3717 Rule number 1 is tested in SYSLIB-ECOM-CIT-3161.
       
  3718 This testcase tests rule number 2 and number 3.
       
  3719 
       
  3720 @SYMTestCaseID		SYSLIB-ECOM-CT-3157
       
  3721 @SYMTestCaseDesc 	This function verifies that ECom handles duplicated
       
  3722 					implementation UID as expected:
       
  3723 					- List operations always return the correct implementations.
       
  3724 					- Create request which does not specify the I/F UID would get
       
  3725 					  the implementation with the lowest I/F UID.
       
  3726 					- Create request specifying both I/F UID and impl UID would
       
  3727 					  get the correct implementation.
       
  3728 @SYMTestPriority 	High
       
  3729 @SYMTestActions  	1. Add two plugins with duplicated impl. UID but different I/F UID.
       
  3730 					2. Perform list operation on each interface. Check that the
       
  3731 					correct implementation is returned in each case.
       
  3732 					3. Do a search by implementation UID only (I/F UID is zero).
       
  3733 					Check that ECom returns the implementation with the lower
       
  3734 					I/F UID.
       
  3735 					4. Do another search specifying both I/F UID and impl. UID.
       
  3736 					Check that ECom returns the correct implementation.
       
  3737 					5. Remove the implementation with lower I/F UID from the
       
  3738 					indexes. Do search by impl UID only. ECom should return the high
       
  3739 					implementation.
       
  3740 @SYMTestExpectedResults The test must not fail.
       
  3741 @SYMDEF				INC080992
       
  3742 */
       
  3743 void CRegistryDataTest::DuplicateImplUidTestL()
       
  3744 	{
       
  3745 	// Do not run this test in OOM mode. Main part of this test is
       
  3746 	// inserting implementation in iInterfaceImplIndex and iImplIndex.
       
  3747 	// This operation does not cleanup properly if OOM because it
       
  3748 	// relies on server exit.
       
  3749 
       
  3750 	// This test uses 2 interfaces: KCExampleInterfaceUid (10009DC0) and
       
  3751 	//                              KCInvalidUid (10009999).
       
  3752 	// They have a common implementationUID KCExampleInterfaceImp.
       
  3753 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3157 "));
       
  3754 
       
  3755 	_LIT(KHighDllPath, "C:\\resource\\plugins\\interfacehigh.dll");
       
  3756 	_LIT(KLowDllPath, "C:\\resource\\plugins\\interfacelow.dll");
       
  3757 
       
  3758 	_LIT(KHighDisplayName, "dupl impl. of 10009DC0");
       
  3759 	_LIT(KLowDisplayName, "dupl impl. of 10009999");
       
  3760 
       
  3761 	// Create implementation with high interface UID
       
  3762 	TImplCreationStruct highIfUid(EDriveC,
       
  3763 							 KCExampleInterfaceUid,
       
  3764 							 KCExampleInterfaceImp,
       
  3765 							 KHighDllPath,
       
  3766 							 KHighDisplayName);
       
  3767 	CreateImplL(highIfUid);
       
  3768 
       
  3769 	// Create implementation with low interface UID
       
  3770 	TImplCreationStruct lowIfUid(EDriveC,
       
  3771 							KCInvalidUid,
       
  3772 							KCExampleInterfaceImp,
       
  3773 							KLowDllPath,
       
  3774 							KLowDisplayName);
       
  3775 	CreateImplL(lowIfUid);
       
  3776 
       
  3777 	TheTest.Printf(_L("Testing low I/F UID overrides high I/F UID on same drive\n"));
       
  3778 	TestDuplicatedImplPrecedenceL(lowIfUid, highIfUid);
       
  3779 
       
  3780 	_LIT(KHighDriveDllPath, "K:\\resource\\plugins\\highdriveletter.dll");
       
  3781 	_LIT(KHighDriveDisplayName, "K: impl. of i/f 10009DC0");
       
  3782 	TImplCreationStruct highDriveLetter(EDriveK,
       
  3783 							 KCExampleInterfaceUid,
       
  3784 							 KCExampleInterfaceImp,
       
  3785 							 KHighDriveDllPath,
       
  3786 							 KHighDriveDisplayName);
       
  3787 	CreateImplL(highDriveLetter);
       
  3788 
       
  3789 	// I/f UID of the dll in K: is same as highIfUid above.
       
  3790 	// But K: take precedence over C: by virtue of higher drive number.
       
  3791 	TheTest.Printf(_L("Testing high drive letter overrides low drive letter"));
       
  3792 	TestDuplicatedImplPrecedenceL(highDriveLetter, lowIfUid);
       
  3793 	}
       
  3794 
       
  3795 /** Helper of DuplicateImplUidTestL. This function does the real
       
  3796 work while DuplicateImplUidTestL just setup the test parameters.
       
  3797 
       
  3798 @param highprecedence - data of the implementation of higher precedence.
       
  3799 @param lowprecedence - the other implementation of lower precedence.
       
  3800 */
       
  3801 void CRegistryDataTest::TestDuplicatedImplPrecedenceL(
       
  3802 	const TImplCreationStruct& highprecedence,
       
  3803 	const TImplCreationStruct& lowprecedence)
       
  3804 	{
       
  3805 	TUid commonImplUid = highprecedence.iImplUid;
       
  3806 	TEST2(lowprecedence.iImplUid.iUid, highprecedence.iImplUid.iUid);
       
  3807 
       
  3808 	//=============================================================
       
  3809 	// Check index is empty
       
  3810 	TEST2(iStateAccessor->ImplementationsCount(*iRegistryData), 0);
       
  3811 
       
  3812 	//=============================================================
       
  3813 	// Add implementation of lowprecedence to indexes
       
  3814 	TBool result = iRegistryData->InsertIntoIndexL(lowprecedence.iImplData,
       
  3815 												   ETrue);
       
  3816 	TEST2(result, ETrue);
       
  3817 
       
  3818 	//=============================================================
       
  3819 	// Add implementation of highprecedence to indexes
       
  3820 	result = iRegistryData->InsertIntoIndexL(highprecedence.iImplData,
       
  3821 											 ETrue);
       
  3822 	TEST2(result, ETrue);
       
  3823 
       
  3824 	//=============================================================
       
  3825 	// Check the two plugins are inserted in the indexes and list
       
  3826 	// operation works OK
       
  3827 	TUid tempUid = lowprecedence.iInterfaceUid;
       
  3828 	RImplDataArray impls;
       
  3829 	CleanupClosePushL(impls);
       
  3830 	iStateAccessor->GetImplementationInfoL(*iRegistryData, tempUid, impls);
       
  3831 	TEST2(impls.Count(), 1);
       
  3832 	TEST(impls[0]->iImplInfo->DisplayName() == lowprecedence.iImplDisplayName);
       
  3833 
       
  3834 	// Next do a list on the other I/F.
       
  3835 	tempUid = highprecedence.iInterfaceUid;
       
  3836 	iStateAccessor->GetImplementationInfoL(*iRegistryData, tempUid, impls);
       
  3837 	TEST2(impls.Count(), 1);
       
  3838 	TEST(impls[0]->iImplInfo->DisplayName() == highprecedence.iImplDisplayName);
       
  3839 
       
  3840 	//=============================================================
       
  3841 	// If not specify interface UID, FindImplementation should return
       
  3842 	// the implementation of high precedence
       
  3843 	CRegistryData::CImplementationData*	searchResult = NULL;
       
  3844 	TInt err = iStateAccessor->FindImplementation(*iRegistryData,
       
  3845 											 commonImplUid,
       
  3846 											 KNullUid,
       
  3847 											 searchResult);
       
  3848 	TEST2(err, KErrNone);
       
  3849 	TEST(searchResult == highprecedence.iImplData);
       
  3850 
       
  3851 	//=============================================================
       
  3852 	// FindImplementation should return the correct implementation
       
  3853 	// if the interface UID is specified.
       
  3854 	err = iStateAccessor->FindImplementation(*iRegistryData,
       
  3855 											 commonImplUid,
       
  3856 											 lowprecedence.iInterfaceUid,
       
  3857 											 searchResult);
       
  3858 	TEST2(err, KErrNone);
       
  3859 	TEST(searchResult == lowprecedence.iImplData);
       
  3860 
       
  3861 	// Repeat FindImplementation test on the highprecedence interface UID
       
  3862 	err = iStateAccessor->FindImplementation(*iRegistryData,
       
  3863 											 commonImplUid,
       
  3864 											 highprecedence.iInterfaceUid,
       
  3865 											 searchResult);
       
  3866 	TEST2(err, KErrNone);
       
  3867 	TEST(searchResult == highprecedence.iImplData);
       
  3868 
       
  3869 	//=============================================================
       
  3870 	// Remove the implementation of higher precedence.
       
  3871 	TRAP(err, iRegistryData->RemoveFromIndexL(highprecedence.iDllData));
       
  3872 	TEST2(err, KErrNone);
       
  3873 
       
  3874 	//=============================================================
       
  3875 	// Now only the implementation with low precedence is in the indexes
       
  3876 	err = iStateAccessor->FindImplementation(*iRegistryData,
       
  3877 											 commonImplUid,
       
  3878 											 KNullUid,
       
  3879 											 searchResult);
       
  3880 	TEST2(err, KErrNone);
       
  3881 	TEST(searchResult == lowprecedence.iImplData);
       
  3882 
       
  3883 	// Before exit, make sure the indexes are empty.
       
  3884 	TRAP(err, iRegistryData->RemoveFromIndexL(lowprecedence.iDllData));
       
  3885 	TEST2(err, KErrNone);
       
  3886 
       
  3887 	// Check index is empty
       
  3888 	TEST2(iStateAccessor->ImplementationsCount(*iRegistryData), 0);
       
  3889 	CleanupStack::PopAndDestroy(&impls);
       
  3890 	}
       
  3891 /**
       
  3892 Test case for making sure the flag for indication of language switch set properly when
       
  3893 language downgrade change happens during the running time.
       
  3894 
       
  3895 @SYMTestCaseID		SYSLIB-ECOM-UT-3171
       
  3896 @SYMTestCaseDesc 	This function verifies that ECom set the flag for indicating
       
  3897 					language change properly:
       
  3898 					- False when there is no language switch activity.
       
  3899 					- True when language downgrade path is changed from non-localise to localise.
       
  3900 					- True when first language changed only as opposed to  complete language downgrade path
       
  3901 					- False when there is language switch activity, however, the language downgrade
       
  3902 					  path has no change.
       
  3903 @SYMTestPriority 	High
       
  3904 @SYMTestActions  	1. construct language downgrade path
       
  3905 					2. Sets up the system-wide locale and language downgrade path.
       
  3906 					3. Check flag whether set properly.
       
  3907 @SYMTestExpectedResults The test must not fail.
       
  3908 @SYMDEF				CR0902
       
  3909 */
       
  3910 void CRegistryDataTest::LanguageChangedTestL()
       
  3911 	{
       
  3912 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3171 "));
       
  3913 	//exclude those changes for language downgrade path during start-up time
       
  3914 	if(!iStateAccessor->IsLanguageInitChanged(*iRegistryData))
       
  3915 		{
       
  3916 		// Language files used for locale settings
       
  3917 		_LIT(KEComEnglishLocale, "elocl.01");
       
  3918 		_LIT(KEComSpanishLocale, "elocl.04");
       
  3919 
       
  3920 		TLanguage downgradePathSetup[3];
       
  3921 		TLocale locale;
       
  3922 		TExtendedLocale extendedLocale;
       
  3923 
       
  3924 		TBool isLanguageChange = EFalse;
       
  3925 		//There is no language switch activity, expect EFalse
       
  3926 		TRAPD(err, iRegistryData->LanguageChangedL(isLanguageChange));
       
  3927 		TEST_OOM_ERR;
       
  3928 		TEST2(err, KErrNone);
       
  3929 		TEST2(isLanguageChange, EFalse);
       
  3930 
       
  3931 		//change language downgrade path from non localise to localise.
       
  3932 		extendedLocale.LoadSystemSettings();
       
  3933         #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
       
  3934             extendedLocale.LoadLocale(KEComEnglishLocale);
       
  3935         #else
       
  3936             extendedLocale.LoadLocale(KEComEnglishLang,KEComEnglishReg,KEComEnglishColl);
       
  3937         #endif  
       
  3938  		extendedLocale.SaveSystemSettings();
       
  3939 
       
  3940 		downgradePathSetup[0] = ELangEnglish;
       
  3941 		downgradePathSetup[1] = ELangFrench;
       
  3942 		downgradePathSetup[2] = ELangGerman;
       
  3943 		SetLanguageL(downgradePathSetup);
       
  3944 
       
  3945 		TRAP(err, iRegistryData->LanguageChangedL(isLanguageChange));
       
  3946 		TEST_OOM_ERR;
       
  3947 		TEST2(err, KErrNone);
       
  3948 		TEST2(isLanguageChange, ETrue);
       
  3949 		//Change first language from English to Spanish..
       
  3950 		extendedLocale.LoadSystemSettings();
       
  3951         #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
       
  3952             extendedLocale.LoadLocale(KEComSpanishLocale);
       
  3953         #else
       
  3954             extendedLocale.LoadLocale(KEComSpanishLang,KEComSpanishReg,KEComSpanishColl);
       
  3955         #endif  
       
  3956 		extendedLocale.SaveSystemSettings();
       
  3957 		downgradePathSetup[0] =ELangSpanish;
       
  3958 		SetLanguageL(downgradePathSetup);
       
  3959 		TRAP(err, iRegistryData->LanguageChangedL(isLanguageChange));
       
  3960 		TEST_OOM_ERR;
       
  3961 		TEST2(err, KErrNone);
       
  3962 		TEST2(isLanguageChange, ETrue);
       
  3963 
       
  3964 		//use same language downgrade path setting.
       
  3965 		SetLanguageL(downgradePathSetup);
       
  3966 		TRAP(err, iRegistryData->LanguageChangedL(isLanguageChange));
       
  3967 		TEST_OOM_ERR;
       
  3968 		TEST2(err, KErrNone);
       
  3969 		TEST2(isLanguageChange, EFalse);
       
  3970 		}
       
  3971 	}
       
  3972 
       
  3973 /**
       
  3974 @SYMTestCaseID		SYSLIB-ECOM-UT-3670
       
  3975 @SYMTestCaseDesc 	This test verifies that ECom sets the iDrivesRemoved correctly when drives
       
  3976 					are added and removed
       
  3977 @SYMTestPriority 	High
       
  3978 @SYMTestActions  	Call UndoTemporaryUninstallL to install some drives
       
  3979 					Remove selected drives by calling TemporaryUninstallL
       
  3980 					Use the state accessor to verify that the iDrivesRemoved flag
       
  3981 					correctly stores the removed drives
       
  3982 @SYMTestExpectedResults The iDrivesRemoved flag should match the removed drives
       
  3983 @SYMDEF				INC110470
       
  3984 */
       
  3985 void CRegistryDataTest::DrivesRemovedTestL()
       
  3986 	{
       
  3987 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3670 "));
       
  3988 
       
  3989 	//Ensure that the following drives are all installed
       
  3990 	iRegistryData->UndoTemporaryUninstallL(EDriveA);
       
  3991 	iRegistryData->UndoTemporaryUninstallL(EDriveO);
       
  3992 	iRegistryData->UndoTemporaryUninstallL(EDriveF);
       
  3993 	iRegistryData->UndoTemporaryUninstallL(EDriveZ);
       
  3994 
       
  3995 	//Test that there are no drives removed
       
  3996 	TEST2(iStateAccessor->DrivesRemoved(*iRegistryData), 0);
       
  3997 
       
  3998 	//Remove a drive and check that the state indicates the correct drive
       
  3999 	//has been removed
       
  4000 	iRegistryData->TemporaryUninstallL(EDriveZ);
       
  4001 	TInt drivesRemoved = iStateAccessor->DrivesRemoved(*iRegistryData);
       
  4002 	TEST2(drivesRemoved, 0x2000000);
       
  4003 
       
  4004 	//remove another drive then re-add the first and make sure the
       
  4005 	//correct drive is removed
       
  4006 	iRegistryData->TemporaryUninstallL(EDriveA);
       
  4007 	iRegistryData->UndoTemporaryUninstallL(EDriveZ);
       
  4008 	drivesRemoved = iStateAccessor->DrivesRemoved(*iRegistryData);
       
  4009 	TEST2(drivesRemoved, 0x1);
       
  4010 
       
  4011 	//Remove all existing drives  plus that hasnt been mounted
       
  4012 	//and check the result
       
  4013 	iRegistryData->TemporaryUninstallL(EDriveA);
       
  4014 	iRegistryData->TemporaryUninstallL(EDriveO);
       
  4015 	iRegistryData->TemporaryUninstallL(EDriveF);
       
  4016 	iRegistryData->TemporaryUninstallL(EDriveZ);
       
  4017 	iRegistryData->TemporaryUninstallL(EDriveX);
       
  4018 
       
  4019 	drivesRemoved = iStateAccessor->DrivesRemoved(*iRegistryData);
       
  4020 	TEST2(drivesRemoved, 0x2004021);
       
  4021 
       
  4022 	//Add some existing and some new drives check the result
       
  4023 	iRegistryData->UndoTemporaryUninstallL(EDriveF);
       
  4024 	iRegistryData->UndoTemporaryUninstallL(EDriveZ);
       
  4025 	iRegistryData->UndoTemporaryUninstallL(EDriveB);
       
  4026 	iRegistryData->UndoTemporaryUninstallL(EDriveR);
       
  4027 
       
  4028 	drivesRemoved = iStateAccessor->DrivesRemoved(*iRegistryData);
       
  4029 	TEST2(drivesRemoved, 0x0004001);
       
  4030 
       
  4031 	}
       
  4032 
       
  4033 // Type definition for pointer to member function.
       
  4034 // Used in calling the CRegistryDataTest member function for testing.
       
  4035 typedef void (CRegistryDataTest::*ClassFuncPtrL) (void);
       
  4036 
       
  4037 /**
       
  4038 @SYMTestCaseID          SYSLIB-ECOM-CT-0751
       
  4039 @SYMTestCaseDesc	    Function to call all test functions
       
  4040 @SYMTestPriority 	    High
       
  4041 @SYMTestActions  	    Calls up all test functions related to CRegistryData
       
  4042 @SYMTestExpectedResults The test must not fail.
       
  4043 @SYMREQ                 REQ0000
       
  4044 */
       
  4045 /**
       
  4046 Wrapper function to call all test functions
       
  4047 @param		testFunc pointer to test function
       
  4048 @param		aTestDesc test function name
       
  4049 @param		aIsFullDriveCDiscovery whether the constructor make full discovery on drive C
       
  4050 */
       
  4051 LOCAL_C void DoBasicTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc, TBool aIsFullDriveCDiscovery)
       
  4052 	{
       
  4053 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0751 "));
       
  4054 	TheTest.Next(aTestDesc);
       
  4055 
       
  4056 	__UHEAP_MARK;
       
  4057   	// find out the number of open handles
       
  4058 	TInt startProcessHandleCount;
       
  4059 	TInt startThreadHandleCount;
       
  4060 	RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  4061 
       
  4062 	CRegistryDataTest* theTest = CRegistryDataTest::NewL(aIsFullDriveCDiscovery);
       
  4063 	CleanupStack::PushL(theTest);
       
  4064 
       
  4065 	(theTest->*testFuncL)();
       
  4066 
       
  4067 	CleanupStack::PopAndDestroy(theTest);
       
  4068 
       
  4069 	// check that no handles have leaked
       
  4070 	TInt endProcessHandleCount;
       
  4071 	TInt endThreadHandleCount;
       
  4072 	RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  4073 
       
  4074 	TEST(startProcessHandleCount == endProcessHandleCount);
       
  4075 	TEST(startThreadHandleCount  == endThreadHandleCount);
       
  4076 
       
  4077 	__UHEAP_MARKEND;
       
  4078 	}
       
  4079 
       
  4080 /**
       
  4081 @SYMTestCaseID          SYSLIB-ECOM-CT-0752
       
  4082 @SYMTestCaseDesc	    Function to call all OOM test functions
       
  4083 @SYMTestPriority 	    High
       
  4084 @SYMTestActions  	    Calls up all OOM test functions related to CRegistryData
       
  4085 @SYMTestExpectedResults The test must not fail.
       
  4086 @SYMREQ                 REQ0000
       
  4087 */
       
  4088 /**
       
  4089 Wrapper function to call all OOM test functions
       
  4090 @param		testFuncL pointer to OOM test function
       
  4091 @param		aTestDesc test function name
       
  4092 @param		aIsFullDriveCDiscovery whether the constructor make full discovery on drive C
       
  4093 */
       
  4094 LOCAL_C void DoOOMTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc, TBool aIsFullDriveCDiscovery)
       
  4095 	{
       
  4096 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0752 "));
       
  4097 	TheTest.Next(aTestDesc);
       
  4098 
       
  4099 	TInt err;
       
  4100 	TInt tryCount = 0;
       
  4101 	do
       
  4102 		{
       
  4103 		__UHEAP_MARK;
       
  4104   		// find out the number of open handles
       
  4105 		TInt startProcessHandleCount;
       
  4106 		TInt startThreadHandleCount;
       
  4107 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  4108 
       
  4109 		CRegistryDataTest* theTest = CRegistryDataTest::NewL(aIsFullDriveCDiscovery);
       
  4110 		CleanupStack::PushL(theTest);
       
  4111 
       
  4112 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
       
  4113 
       
  4114 		TRAP(err, (theTest->*testFuncL)());
       
  4115 
       
  4116 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
  4117 
       
  4118 		CleanupStack::PopAndDestroy(theTest);
       
  4119 		theTest = NULL;
       
  4120 		// check that no handles have leaked
       
  4121 		TInt endProcessHandleCount;
       
  4122 		TInt endThreadHandleCount;
       
  4123 		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  4124 
       
  4125 		TEST(startProcessHandleCount == endProcessHandleCount);
       
  4126 		TEST(startThreadHandleCount  == endThreadHandleCount);
       
  4127 
       
  4128 		__UHEAP_MARKEND;
       
  4129 		} while(err == KErrNoMemory);
       
  4130 
       
  4131  	TEST2(err, KErrNone);
       
  4132 	TheTest.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
       
  4133 	}
       
  4134 
       
  4135 /**
       
  4136 Wrapper function for OOM test of function UpdateDllDataTest1L,UpdateDllDataTest2L,UpdateDllDataTest3L
       
  4137 @param		testFuncL pointer to OOM test function
       
  4138 @param		aTestDesc test function name
       
  4139 @param		aIsFullDriveCDiscovery whether the constructor makes full discovery on drive C
       
  4140 @param		aTestNumber The number identifies the test case of update dll data.
       
  4141 */
       
  4142 LOCAL_C void DoOOMTestUpdateDllDataL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc, TBool aIsFullDriveCDiscovery,TInt aTestNumber)
       
  4143 	{
       
  4144 	TheTest.Next(aTestDesc);
       
  4145 
       
  4146 	TInt err;
       
  4147 	TInt tryCount = 0;
       
  4148 	do
       
  4149 		{
       
  4150 		__UHEAP_MARK;
       
  4151 		switch (aTestNumber)
       
  4152 			{
       
  4153 				case 1:
       
  4154 					{
       
  4155 					TRAP(err,EComTestUtils::FileManDeleteFileL(KEcomExample12UpgradedOnC));
       
  4156 					}
       
  4157 				case 2:
       
  4158 					{
       
  4159 					TRAP(err,EComTestUtils::FileManDeleteFileL(KEcomExample14UpgradedOnC));
       
  4160 					}
       
  4161 				case 3:
       
  4162 					{
       
  4163 					TRAP(err,EComTestUtils::FileManDeleteFileL(KEcomExample12DowngradedOnC));
       
  4164 					}
       
  4165 			}
       
  4166   		// find out the number of open handles
       
  4167 		TInt startProcessHandleCount;
       
  4168 		TInt startThreadHandleCount;
       
  4169 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
  4170 
       
  4171 		CRegistryDataTest* theTest = CRegistryDataTest::NewL(aIsFullDriveCDiscovery);
       
  4172 		CleanupStack::PushL(theTest);
       
  4173 
       
  4174 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
       
  4175 
       
  4176 		TRAP(err, (theTest->*testFuncL)());
       
  4177 
       
  4178 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
  4179 
       
  4180 		CleanupStack::PopAndDestroy(theTest);
       
  4181 		theTest = NULL;
       
  4182 		// check that no handles have leaked
       
  4183 		TInt endProcessHandleCount;
       
  4184 		TInt endThreadHandleCount;
       
  4185 		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
  4186 
       
  4187 		TEST(startProcessHandleCount == endProcessHandleCount);
       
  4188 		TEST(startThreadHandleCount  == endThreadHandleCount);
       
  4189 
       
  4190 		__UHEAP_MARKEND;
       
  4191 		} while(err == KErrNoMemory);
       
  4192 
       
  4193  	TEST2(err, KErrNone);
       
  4194 	TheTest.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
       
  4195 	}
       
  4196 
       
  4197 
       
  4198 LOCAL_C void DoTestsL()
       
  4199 	{
       
  4200 	__UHEAP_MARK;
       
  4201 	// Create backup server session here. When deleted it deletes safely.
       
  4202 	// Registrar object creates BackUpNotifier object which
       
  4203 	// internally creates CBaBackupSessionWrapper, an interface to BackUpSErver session opens 3 handles.
       
  4204 	// but when Registrar object is deleted it deletes one handle and two are left open.
       
  4205 
       
  4206 	CBaBackupSessionWrapper *BackupSession = CBaBackupSessionWrapper::NewL();
       
  4207 
       
  4208 	// Basic tests
       
  4209 	CreateDeleteTestL();
       
  4210 	DoBasicTestL(&CRegistryDataTest::FailedSecurityCheckTestListImplementationsL,_L("FailedSecurityCheckTestListImplementations Test"), ETrue);
       
  4211 	DoBasicTestL(&CRegistryDataTest::FailedSecurityCheckTestGetImplementationInfoL,_L("FailedSecurityCheckTestGetImplementationInfo Test"), ETrue);
       
  4212 	DoBasicTestL(&CRegistryDataTest::ProcessSecurityCheckTestL, _L("ProcessSecurityCheckTest Test"), ETrue);
       
  4213 	DoBasicTestL(&CRegistryDataTest::IsAnyDllDiscoveredTestL,_L("IsAnyDllDiscoveredTest Test"), ETrue);
       
  4214 	DoBasicTestL(&CRegistryDataTest::ImplementationDataTestL,_L("ImplementationData Test"), EFalse);
       
  4215 	DoBasicTestL(&CRegistryDataTest::InsertIntoIndexRemoveFromIndexTestL,_L("InsertIntoIndexRemoveFromIndex Test"), EFalse);
       
  4216 	DoBasicTestL(&CRegistryDataTest::RollbackTestL,_L("Rollback Test"), EFalse);
       
  4217 	DoBasicTestL(&CRegistryDataTest::AddDllDataTestL, _L("AddDllData Test"), ETrue);
       
  4218 	DoBasicTestL(&CRegistryDataTest::AddDllDataPlugIn3TestL, _L("AddDllData PlugIn3 Test"), ETrue);
       
  4219 	DoBasicTestL(&CRegistryDataTest::UpdateDllDataTest1L, _L("UpdateDllData Test 1"), ETrue);
       
  4220 	DoBasicTestL(&CRegistryDataTest::UpdateDllDataTest2L, _L("UpdateDllData Test 2"), ETrue);
       
  4221 	DoBasicTestL(&CRegistryDataTest::UpdateDllDataTest3L, _L("UpdateDllData Test 3"), ETrue);
       
  4222 	DoBasicTestL(&CRegistryDataTest::IsRegisteredWithDateUpdateDllDataTestL, _L("IsRegisteredWithDate and UpdateDllData Test"), ETrue);
       
  4223 	DoBasicTestL(&CRegistryDataTest::SetEnabledStateTestL, _L("SetEnabledState Test"), ETrue);
       
  4224 	DoBasicTestL(&CRegistryDataTest::FindImplementationTestL, _L("FindImplementation Test"), ETrue);
       
  4225 	DoBasicTestL(&CRegistryDataTest::ListImplementationsL, _L("ListImplementations Test for CRegistryData"), ETrue);
       
  4226 	DoBasicTestL(&CRegistryDataTest::ListImplementationsTestT1L, _L("ListImplementations Test for CRegistryResolveTransaction 1"), ETrue);
       
  4227 	DoBasicTestL(&CRegistryDataTest::ListImplementationsTestT2L, _L("ListImplementations Test for CRegistryResolveTransaction 2"), ETrue);
       
  4228 	DoBasicTestL(&CRegistryDataTest::ListImplementationsTestT3L, _L("ListImplementations Test for CRegistryResolveTransaction 3"), ETrue);
       
  4229 	DoBasicTestL(&CRegistryDataTest::ListImplementationsTestT4L, _L("ListImplementations Test for CRegistryResolveTransaction 4"), ETrue);
       
  4230 	DoBasicTestL(&CRegistryDataTest::ListImplementationsTestT5L, _L("ListImplementations Test for CRegistryResolveTransaction 5"), ETrue);
       
  4231 	DoBasicTestL(&CRegistryDataTest::ListExtendedInterfacesTestL, _L("ListExtendedInterfaces Test"), ETrue);
       
  4232 
       
  4233 	DoBasicTestL(&CRegistryDataTest::DoUndoTemporaryUninstallTestL, _L("TemporaryUninstall and UndoTemporaryUninstall Test"), ETrue);
       
  4234 	DoBasicTestL(&CRegistryDataTest::DiscoveriesBeginCompleteTestL, _L("DiscoveriesBegin and DiscoveriesComplete Test"), ETrue);
       
  4235 
       
  4236 	DoBasicTestL(&CRegistryDataTest::IndexedFindTestL, _L("IndexedFind Test"), ETrue);
       
  4237 	DoBasicTestL(&CRegistryDataTest::GetImplementationDllInfoForClientTestL,_L("GetImplementationDllInfoForClientL Test"), ETrue);
       
  4238 	DoBasicTestL(&CRegistryDataTest::GetImplementationDllInfoForServerTest,_L("GetImplementationDllInfoForServer Test"), ETrue);
       
  4239 	DoBasicTestL(&CRegistryDataTest::GetImplementationDllInfoForClientPlugIn3TestL,_L("GetImplementationDllInfoForClientPlugIn3L Test"), ETrue);
       
  4240 	DoBasicTestL(&CRegistryDataTest::GetImplementationDllInfoForServerPlugIn3Test,_L("GetImplementationDllInfoForServerPlugIn3 Test"), ETrue);
       
  4241 	DoBasicTestL(&CRegistryDataTest::CheckDuplicatPluginsOnCL,_L("CheckDuplicatPluginsOnCL Test"), EFalse);
       
  4242 	DoBasicTestL(&CRegistryDataTest::CheckNoPluginsOnCL,_L("CheckNoPluginsOnCL Test"), EFalse);
       
  4243 	DoBasicTestL(&CRegistryDataTest::DuplicateImplUidTestL,_L("DuplicateImplUidTestL Test"), EFalse);
       
  4244 	DoBasicTestL(&CRegistryDataTest::LanguageChangedTestL,_L("LanguageChangedTestL Test"), EFalse);
       
  4245 	DoBasicTestL(&CRegistryDataTest::DrivesRemovedTestL,_L("DrivesRemovedTestL Test"), EFalse);
       
  4246 
       
  4247 	//OOM tests
       
  4248 
       
  4249 	OOMCreateDeleteTest();
       
  4250 	DoOOMTestL(&CRegistryDataTest::FailedSecurityCheckTestListImplementationsL,_L("OOM FailedSecurityCheckTestListImplementations Test"), ETrue);
       
  4251 	DoOOMTestL(&CRegistryDataTest::FailedSecurityCheckTestGetImplementationInfoL,_L("OOM FailedSecurityCheckTestGetImplementationInfo Test"), ETrue);
       
  4252 	DoOOMTestL(&CRegistryDataTest::ProcessSecurityCheckTestL, _L("OOM ProcessSecurityCheckTest Test"), ETrue);
       
  4253 	DoOOMTestL(&CRegistryDataTest::IsAnyDllDiscoveredTestL, _L("OOM IsAnyDllDiscoveredTestL Test"), ETrue);
       
  4254 	DoOOMTestL(&CRegistryDataTest::ImplementationDataTestL, _L("OOM ImplementationData Test"), EFalse);
       
  4255 	DoOOMTestL(&CRegistryDataTest::InsertIntoIndexRemoveFromIndexTestL, _L("OOM InsertIntoIndexRemoveFromIndex Test"), EFalse);
       
  4256 	DoOOMTestL(&CRegistryDataTest::RollbackTestL, _L("OOM Rollback Test"), EFalse);
       
  4257 	DoOOMTestL(&CRegistryDataTest::AddDllDataTestL, _L("OOM AddDllData Test"), ETrue);
       
  4258 	DoOOMTestL(&CRegistryDataTest::AddDllDataPlugIn3TestL, _L("OOM AddDllData PlugIn3 Test"), ETrue);
       
  4259 	DoOOMTestUpdateDllDataL(&CRegistryDataTest::UpdateDllDataTest1L, _L("OOM UpdateDllData Test 1"), ETrue, 1);
       
  4260 	DoOOMTestUpdateDllDataL(&CRegistryDataTest::UpdateDllDataTest2L, _L("OOM UpdateDllData Test 2"), ETrue, 2);
       
  4261 	DoOOMTestUpdateDllDataL(&CRegistryDataTest::UpdateDllDataTest3L, _L("OOM UpdateDllData Test 3"), ETrue, 3);
       
  4262 	DoOOMTestL(&CRegistryDataTest::IsRegisteredWithDateUpdateDllDataTestL, _L("IsRegisteredWithDate and UpdateDllData Test"), ETrue);
       
  4263 	DoOOMTestL(&CRegistryDataTest::SetEnabledStateTestL, _L("OOM SetEnabledState Test"), ETrue);
       
  4264 	DoOOMTestL(&CRegistryDataTest::FindImplementationTestL, _L("OOM FindImplementation Test"), ETrue);
       
  4265 	DoOOMTestL(&CRegistryDataTest::ListImplementationsL, _L("OOM ListImplementations Test for CRegistryData"), ETrue);
       
  4266 	DoOOMTestL(&CRegistryDataTest::ListImplementationsTestT1L, _L("OOM ListImplementations Test for CRegistryResolveTransaction 1"), ETrue);
       
  4267 	DoOOMTestL(&CRegistryDataTest::ListImplementationsTestT2L, _L("OOM ListImplementations Test for CRegistryResolveTransaction 2"), ETrue);
       
  4268 	DoOOMTestL(&CRegistryDataTest::ListImplementationsTestT3L, _L("OOM ListImplementations Test for CRegistryResolveTransaction 3"), ETrue);
       
  4269 	DoOOMTestL(&CRegistryDataTest::ListImplementationsTestT4L, _L("OOM ListImplementations Test for CRegistryResolveTransaction 4"), ETrue);
       
  4270 	DoOOMTestL(&CRegistryDataTest::ListImplementationsTestT5L, _L("OOM ListImplementations Test for CRegistryResolveTransaction 5"), ETrue);
       
  4271     DoOOMTestL(&CRegistryDataTest::ListExtendedInterfacesTestL, _L("OOM ListExtendedInterfaces Test"), ETrue);
       
  4272 	DoOOMTestL(&CRegistryDataTest::DoUndoTemporaryUninstallTestL, _L("OOM Test for TemporaryUninstall and UndoTemporaryUninstall"), ETrue);
       
  4273 	DoOOMTestL(&CRegistryDataTest::DiscoveriesBeginCompleteTestL, _L("OOM Test for DiscoveriesBegin and DiscoveriesComplete"), ETrue);
       
  4274 	DoOOMTestL(&CRegistryDataTest::IndexedFindTestL, _L("OOM IndexedFind Test"), ETrue);
       
  4275 	DoOOMTestL(&CRegistryDataTest::GetImplementationDllInfoForClientTestL,_L("OOM Test for GetImplementationDllInfoForClientL Test"), ETrue);
       
  4276 	DoOOMTestL(&CRegistryDataTest::GetImplementationDllInfoForServerTest,_L("OOM Test for GetImplementationDllInfoForServer Test"), ETrue);
       
  4277 	DoOOMTestL(&CRegistryDataTest::GetImplementationDllInfoForClientTestL,_L("OOM Test for GetImplementationDllInfoForClientPlugIn3L Test"), ETrue);
       
  4278 	DoOOMTestL(&CRegistryDataTest::GetImplementationDllInfoForServerTest,_L("OOM Test for GetImplementationDllInfoForServerPlugIn3L Test"), ETrue);
       
  4279 	DoOOMTestL(&CRegistryDataTest::LanguageChangedTestL,_L("OOM Test for LanguageChangedTestL Test"), ETrue);
       
  4280 	DoOOMTestL(&CRegistryDataTest::DrivesRemovedTestL,_L("OOM Test for DrivesRemovedTestL Test"), ETrue);
       
  4281 
       
  4282 	// OOM test can not be performed on API StoreL nad RestoreL, since registry index file gets corrupted when its
       
  4283 	// data is not completely written, causing to fail in next call.
       
  4284 	delete BackupSession;
       
  4285 
       
  4286 	// Panic Test
       
  4287 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3712 "));
       
  4288 	ThreadPanicTest(_L("AddExtendedInterface Panic Testing"),AddExtendedInterfacePanicL);
       
  4289 
       
  4290 	__UHEAP_MARKEND;
       
  4291 	}
       
  4292 
       
  4293 /**
       
  4294 Copies the Plugins to specific folder for testing purpose
       
  4295 */
       
  4296 LOCAL_C void CopyPluginsL()
       
  4297     {
       
  4298 	// Copy the dlls and .rsc files on to RAM
       
  4299 	TRAPD(err, EComTestUtils::FileManCopyFileL(KEComExDllOnZ, KEComExDllOnC));
       
  4300  	TEST2(err, KErrNone);
       
  4301 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComRscFileOnZ, KEComRscFileOnC));
       
  4302  	TEST2(err, KErrNone);
       
  4303 
       
  4304   	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExampleDllOnZ, KEComExampleDllOnC));
       
  4305 	TEST2(err, KErrNone);
       
  4306 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample2DllOnZ, KEComExample2DllOnC));
       
  4307 	TEST2(err, KErrNone);
       
  4308  	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample3DllOnZ, KEComExample3DllOnC));
       
  4309 	TEST2(err, KErrNone);
       
  4310 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample12DllOnZ, KEComExample12DllOnC));
       
  4311 	TEST2(err, KErrNone);
       
  4312 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample14DllOnZ, KEComExample14DllOnC));
       
  4313 	TEST2(err, KErrNone);
       
  4314 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample15DllOnZ, KEComExample15DllOnC));
       
  4315 	TEST2(err, KErrNone);
       
  4316 
       
  4317 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExampleRscOnZ, KEComExampleRscOnC));
       
  4318 	TEST2(err, KErrNone);
       
  4319 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample2RscOnZ, KEComExample2RscOnC));
       
  4320 	TEST2(err, KErrNone);
       
  4321 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample3RscOnZ, KEComExample3RscOnC));
       
  4322 	TEST2(err, KErrNone);
       
  4323 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample12RscOnZ, KEComExample12RscOnC));
       
  4324 	TEST2(err, KErrNone);
       
  4325 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample14RscOnZ, KEComExample14RscOnC));
       
  4326 	TEST2(err, KErrNone);
       
  4327 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComExample15RscOnZ, KEComExample15RscOnC));
       
  4328 	TEST2(err, KErrNone);
       
  4329 
       
  4330 	// Test plug-in resource file SID that doesn't match the DLL
       
  4331 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComInvalidDllOnZ, KEComInvalidDllOnC));
       
  4332 	TEST2(err, KErrNone);
       
  4333 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComInvalidRscOnZ, KEComInvalidRscOnC));
       
  4334 	TEST2(err, KErrNone);
       
  4335 
       
  4336 	TRAP(err, EComTestUtils::FileManCopyFileL(KMissingDllRomRscFile, KMissingDllRamRscFile));
       
  4337 	TEST2(err, KErrNone);
       
  4338 	TRAP(err, EComTestUtils::FileManCopyFileL(KRollbackForMissingDllRomDllFile, KRollbackForMissingDllRamDllFile));
       
  4339 	TEST2(err, KErrNone);
       
  4340 	TRAP(err, EComTestUtils::FileManCopyFileL(KRollbackForMissingDllRomRscFile, KRollbackForMissingDllRamRscFile));
       
  4341 	TEST2(err, KErrNone);
       
  4342 
       
  4343 	// Wait, so that ECom server looks for plugins copied from Z: to C drive
       
  4344 	// ECOM server could be already started. It means that when we copy some
       
  4345 	// ECOM plugins from Z: to C: drive - ECOM server should look for and
       
  4346 	// find the new ECOM plugins. The ECOM server uses for that CDiscoverer::CIdleScanningTimer
       
  4347 	// which is an active object. So the discovering service is asynchronous. We have to
       
  4348 	// wait some time until it finishes. Otherwise ListImplementationsL could fail to find
       
  4349 	// requested implementations.
       
  4350 	User::After(KOneSecond * 3);
       
  4351 	}
       
  4352 
       
  4353 //Initialise the Active Scheduler
       
  4354 LOCAL_C void SetupL()
       
  4355     {
       
  4356 	// Construct and install the Active Scheduler. The Active Schedular is needed
       
  4357 	// by components used by this test as they are ActiveObjects.
       
  4358 	TheActiveScheduler = new(ELeave)CActiveScheduler;
       
  4359 	CActiveScheduler::Install(TheActiveScheduler);
       
  4360 	ECOMTU_KILL_SERVER_L(TheTest);
       
  4361 	}
       
  4362 
       
  4363 GLDEF_C TInt E32Main()
       
  4364 	{
       
  4365 	__UHEAP_MARK;
       
  4366 
       
  4367 	TheTest.Printf(_L("\n"));
       
  4368 	TheTest.Title();
       
  4369 	TheTest.Start(_L("Registry Data Tests"));
       
  4370 
       
  4371 	TheTrapCleanup = CTrapCleanup::New();
       
  4372 
       
  4373 	User::LeaveIfError(TheFs.Connect());
       
  4374 
       
  4375 	TRAPD(err, SetupL());
       
  4376 	TEST2(err, KErrNone);
       
  4377 
       
  4378 	CopyPluginsL();
       
  4379 
       
  4380 	TRAP(err, DoTestsL());
       
  4381 	TEST2(err, KErrNone);
       
  4382 
       
  4383 	// Cleanup files. If the cleanup fails that is no problem,
       
  4384 	// as any subsequent tests will replace them. The only downside
       
  4385 	// would be the disk not being tidied
       
  4386 	DeleteTestPlugin();
       
  4387 	TheFs.Close();
       
  4388 
       
  4389 	delete TheTrapCleanup;
       
  4390 	delete TheActiveScheduler;
       
  4391 	TheTest.End();
       
  4392 	TheTest.Close();
       
  4393 
       
  4394 	__UHEAP_MARKEND;
       
  4395 	return(KErrNone);
       
  4396 	}