lowlevellibsandfws/pluginfw/Framework/PluginDiscoveryTests/t_plugindiscovery.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 // Contains tests with invalid/missing plugin DLLs
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 #include <ecom/ecom.h>
       
    20 #include "EComUidCodes.h"
       
    21 #include "Interface.h" // interface to Plugins
       
    22 #include "../EcomTestUtils/EcomTestUtils.h"
       
    23 
       
    24 #include <e32test.h>
       
    25 #include <f32file.h>
       
    26 #include <bautils.h>
       
    27 
       
    28 LOCAL_D RTest test(_L("t_plugindiscovery.exe"));
       
    29 
       
    30 LOCAL_D CTrapCleanup* 	  TheTrapCleanup 	 = NULL;
       
    31 
       
    32 LOCAL_D CActiveScheduler* TheActiveScheduler = NULL;
       
    33 
       
    34 LOCAL_D RFs					TheFs;
       
    35 
       
    36 // Implementaion ID used for testing
       
    37 const TUid KUidTestImplementation = {0x101F847C};
       
    38 
       
    39 
       
    40 //It is used by some test methods which are called two times:
       
    41 //from normal test and from OOM test.
       
    42 static void LeaveIfErrNoMemory(TInt aError)
       
    43 	{
       
    44 	if(aError == KErrNoMemory)
       
    45 		{
       
    46 		REComSession::FinalClose();
       
    47 		User::Leave(aError);
       
    48 		}
       
    49 	}
       
    50 
       
    51 
       
    52 // Plugins used in tests.
       
    53 _LIT(KEComInvalidDllOnZ, "z:\\RAMOnly\\InvalidSIDPlugin.dll");
       
    54 _LIT(KEComInvalidRscOnZ, "z:\\RAMOnly\\InvalidSIDPlugin.rsc");
       
    55 _LIT(KEComInvalidDllOnC, "c:\\sys\\bin\\InvalidSIDPlugin.dll");
       
    56 _LIT(KEComInvalidRscOnC, "c:\\resource\\plugins\\InvalidSIDPlugin.rsc");
       
    57 
       
    58 _LIT(KEComExample5RscOnZ, "z:\\RAMOnly\\EComExample5.rsc");
       
    59 _LIT(KEComExample5RscOnC, "c:\\resource\\plugins\\EComExample5.rsc");
       
    60 _LIT(KEComRomRslvrExampleRscOnCRomLocation, "z:\\RAMOnly\\EComRomRslvrExampleOnC.RSC");
       
    61 _LIT(KEComRomRslvrExampleRscOnCRamLocation, "c:\\resource\\plugins\\EComRomRslvrExampleOnZ.RSC");
       
    62 
       
    63 // Plugins used in plugins directory removing test
       
    64 _LIT(KEComDefectPluginDLLOnZ,			"Z:\\RAMOnly\\DefectPlugin.dll");
       
    65 _LIT(KEComDefectPluginRSCOnZ,			"Z:\\RAMOnly\\DefectPlugin.rsc");
       
    66 _LIT(KEComDefectPluginDLLOnC,			"C:\\sys\\bin\\DefectPlugin.dll");
       
    67 _LIT(KEComDefectPluginRSCOnC,			"C:\\Resource\\Plugins\\DefectPlugin.rsc");
       
    68 _LIT(KEComResourcePluginDirNameOnC,		"C:\\Resource\\Plugins\\");
       
    69 _LIT(KEComResourcePluginDirNameOffOnC,	"C:\\Resource\\PluginsNameOff\\");
       
    70 
       
    71 /**
       
    72 @SYMTestCaseID SYSLIB-ECOM-CT-0030
       
    73 @SYMTestCaseDesc Test that an orphaned resource file does not create a registry
       
    74 				 entry.
       
    75 @SYMTestPriority High
       
    76 @SYMTestActions  EComExample5.rsc file copied to C: drive.
       
    77 				 Check call to REComSession::CreateImplementationL() via test
       
    78 				 CExampleInterface class fails to return the implementation.
       
    79 @SYMTestExpectedResults The test must not fail.
       
    80 @SYMREQ REQ3846
       
    81 */
       
    82 LOCAL_C void TestOrphanedRscFileL()
       
    83 	{
       
    84 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0030 "));
       
    85 	__UHEAP_MARK;
       
    86 
       
    87 	// Copy plugin
       
    88 	TRAPD(ignoreErr, EComTestUtils::FileManDeleteFileL(KEComExample5RscOnC));
       
    89 	ignoreErr = ignoreErr;
       
    90 
       
    91 	TRAPD(err, EComTestUtils::FileManCopyFileL(KEComExample5RscOnZ, KEComExample5RscOnC));
       
    92 	test(err == KErrNone);
       
    93 
       
    94 	// The reason for the folowing delay is:
       
    95 	// ECOM server could be already started. It means that when we copy some
       
    96 	// ECOM plugins from Z: to C: drive - ECOM server should look for and
       
    97 	// find the new ECOM plugins. The ECOM server uses for that an active object,
       
    98 	// which scans plugin directories. So the discovering service is asynchronous.
       
    99 	// We have to wait some time until it finishes.
       
   100 	// Otherwise CreateImplementationsL could fail to create requested implementations.
       
   101 	WAIT_FOR3s;
       
   102 
       
   103 	CExampleInterface* interfaceimpl = NULL;
       
   104 	TRAP(err, interfaceimpl = CExampleInterface::NewL2(KUidTestImplementation));
       
   105 	::LeaveIfErrNoMemory(err);
       
   106 	test(err == KErrNotFound);
       
   107 	CleanupStack::PushL(interfaceimpl);
       
   108 
       
   109 	CleanupStack::PopAndDestroy(interfaceimpl);
       
   110 	REComSession::FinalClose();
       
   111 
       
   112 	// Delete plugin
       
   113 	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComExample5RscOnC));
       
   114 	test(err == KErrNone);
       
   115 	__UHEAP_MARK;
       
   116 	}
       
   117 
       
   118 
       
   119 /**
       
   120 @SYMTestCaseID SYSLIB-ECOM-CT-1404
       
   121 @SYMTestCaseDesc Test that an orphaned resource file does not create a registry entry.
       
   122 			and that other valid implementations are discovered instead.
       
   123 @SYMTestPriority High
       
   124 @SYMTestActions  Copy EComRomRslvrExampleOnC to the plug-ins directory on the C drive, without the associated DLL
       
   125 	Because the DLL is not there, Ecom should fall back to the implementations on the Z drive in EComRomRslvrExampleOnZ
       
   126 @SYMTestExpectedResults ECom plugins with invalid DLLs fall back to the correct implementations.
       
   127 @SYMPREQ	PREQ1192
       
   128 */
       
   129 LOCAL_C void TestOrphanedRscFileFallBackL()
       
   130 	{
       
   131 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1404 "));
       
   132 	__UHEAP_MARK;
       
   133 
       
   134 	// Copy plugin resource file and NOT the associated DLL
       
   135 	TRAPD(err, EComTestUtils::FileManCopyFileL(KEComRomRslvrExampleRscOnCRomLocation, KEComRomRslvrExampleRscOnCRamLocation));
       
   136 	test(err == KErrNone);
       
   137 
       
   138 	// The reason for the folowing delay is:
       
   139 	// ECOM server could be already started. It means that when we copy some
       
   140 	// ECOM plugins from Z: to C: drive - ECOM server should look for and
       
   141 	// find the new ECOM plugins. The ECOM server uses for that an active object,
       
   142 	// which scans plugin directories. So the discovering service is asynchronous.
       
   143 	// We have to wait some time until it finishes.
       
   144 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
   145 	WAIT_FOR3s;
       
   146 
       
   147 	TUid romRslvrExampleInterfaceUid = {0x10009DC8};
       
   148 	RImplInfoPtrArray ifArray;
       
   149 	TRAP(err, REComSession::ListImplementationsL(romRslvrExampleInterfaceUid, ifArray));
       
   150 	::LeaveIfErrNoMemory(err);
       
   151 	test(err == KErrNone);
       
   152 
       
   153 	// Go through the implementations for the given interface, and find the ones that match up with
       
   154 	// EComRomRslvrExampleRscOnZ (and not EComRomRslvrExampleRscOnC becuase it's DLL is missing)
       
   155 	// EComRomRslvrExampleOnZ contains the implementation 0x10009DC7v2 and 0x10009DC6v1 (these should be found)
       
   156 	// EComRomRslvrExampleOnC contains the implementation 0x10009DC7v1 and 0x10009DC6v2 (these should NOT be returned becuase of the missing DLL)
       
   157 	TBool foundRightImplementation1 = EFalse;
       
   158 	TBool foundRightImplementation2 = EFalse;
       
   159 	for(TInt index = 0; index < ifArray.Count(); ++index)
       
   160 		{
       
   161 		TUid uid = ifArray[index]->ImplementationUid();
       
   162 		TInt version = ifArray[index]->Version();
       
   163 		TInt drive = ifArray[index]->Drive();
       
   164 		if (uid.iUid == 0x10009DC6)
       
   165 			{
       
   166 			test(version == 1);
       
   167 			test(drive==EDriveZ);
       
   168 			foundRightImplementation1 = ETrue;
       
   169 			}
       
   170 		if (uid.iUid == 0x10009DC7)
       
   171 			{
       
   172 			test(version == 2);
       
   173 			test(drive==EDriveZ);
       
   174 			foundRightImplementation2 = ETrue;
       
   175 			}
       
   176 		}
       
   177 	test(foundRightImplementation1 && foundRightImplementation2);
       
   178 
       
   179 	ifArray.ResetAndDestroy();
       
   180 	REComSession::FinalClose();
       
   181 
       
   182 	// Delete plugin
       
   183 	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComRomRslvrExampleRscOnCRamLocation));
       
   184 	test(err == KErrNone);
       
   185 	__UHEAP_MARK;
       
   186 	}
       
   187 
       
   188 
       
   189 /**
       
   190 @SYMTestCaseID SYSLIB-ECOM-CT-0031
       
   191 @SYMTestCaseDesc Test that a plugin whose SID does not match the value in it's
       
   192 				 resource file will not be installed in the registry.
       
   193 @SYMTestPriority High
       
   194 @SYMTestActions  InvalidSIDPlugin dll and rsc files copied to C: drive.
       
   195 				 Verify plugin is not registered by checking
       
   196 				 ListImplementationsL returns zero plugins for this interface.
       
   197 @SYMTestExpectedResults The test must not fail.
       
   198 @SYMREQ REQ3846
       
   199 */
       
   200 LOCAL_C void TestInvalidSIDPluginL()
       
   201 	{
       
   202 	// InvalidSIDPlugin .dll and .rsc are copied from EComExample5.dll and
       
   203 	// HeapTestImpl.rsc.
       
   204 
       
   205 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0031 "));
       
   206 	__UHEAP_MARK;
       
   207 
       
   208 	// Copy plugins
       
   209 	TRAPD(err, EComTestUtils::FileManCopyFileL(KEComInvalidDllOnZ, KEComInvalidDllOnC));
       
   210 	test(err == KErrNone);
       
   211 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComInvalidRscOnZ, KEComInvalidRscOnC));
       
   212 	test(err == KErrNone);
       
   213 
       
   214 	// The reason for the folowing delay is:
       
   215 	// ECOM server could be already started. It means that when we copy some
       
   216 	// ECOM plugins from Z: to C: drive - ECOM server should look for and
       
   217 	// find the new ECOM plugins. The ECOM server uses for that an active object,
       
   218 	// which scans plugin directories. So the discovering service is asynchronous.
       
   219 	// We have to wait some time until it finishes.
       
   220 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
   221 	WAIT_FOR3s;
       
   222 
       
   223 	TUid ifUid = {0x101FE392};  // HeapTestImpl.rsc interface_uid
       
   224 	RImplInfoPtrArray ifArray;
       
   225 	REComSession::ListImplementationsL(ifUid, ifArray);
       
   226 
       
   227 	const TInt availCount = ifArray.Count();
       
   228 	test.Printf(_L("Found %d implementations.\n"),availCount);
       
   229 	test(availCount == 0);
       
   230 
       
   231 	ifArray.ResetAndDestroy();
       
   232 	REComSession::FinalClose(); // Don't want leaks outside the test
       
   233 
       
   234 	// Cleanup plugins
       
   235 	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComInvalidDllOnC));
       
   236 	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComInvalidRscOnC));
       
   237 
       
   238 	__UHEAP_MARK;
       
   239 	}
       
   240 
       
   241 /**
       
   242 @SYMTestCaseID SYSLIB-ECOM-CT-1858
       
   243 @SYMTestCaseDesc Test that rediscovery of removing and adding "\Resource\Plugins" directory
       
   244 					works properly.
       
   245 @SYMTestPriority High
       
   246 @SYMTestActions  Removes "\Resource\Plugins" directory on C: drive, check that
       
   247 					rediscovery	works properly by verifying plugin's registration.
       
   248 				 Adds "\Resource\Plugins" directory on C: drive, check that rediscovery works
       
   249 				 	fine by verifying plugin's registration.
       
   250 @SYMTestExpectedResults The test must not fail.
       
   251 @SYMDEF DEF088454
       
   252 */
       
   253 LOCAL_C void TestPluginsDirectoryRemovingL()
       
   254 	{
       
   255 	test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1858 "));
       
   256 	__UHEAP_MARK;
       
   257 
       
   258 	/**
       
   259 	Add The following plugin to C drive
       
   260 
       
   261 	Interface UID		DLL	UID		Imp. UID		Version		DllFile
       
   262 	------------------------------------------------------------------------------------------------------------------------------------------
       
   263 	0x102797A1			0x102797A0	0x102797A2		1			C:\\..\\DefectPlugin.dll
       
   264 
       
   265 	**/
       
   266 	TRAPD(err, EComTestUtils::FileManCopyFileL(KEComDefectPluginDLLOnZ, KEComDefectPluginDLLOnC));
       
   267 	test(err == KErrNone);
       
   268 	TRAP(err, EComTestUtils::FileManCopyFileL(KEComDefectPluginRSCOnZ, KEComDefectPluginRSCOnC));
       
   269 	test(err == KErrNone);
       
   270 
       
   271 	WAIT_FOR3s;
       
   272 
       
   273 	TUid interfaceUid={0x102797A1};
       
   274 	RImplInfoPtrArray implArray;
       
   275 
       
   276 	// Now start ecom discovery and get implementations for IF UID 0x102797A1
       
   277 	TRAP(err, REComSession::ListImplementationsL(interfaceUid, implArray));
       
   278 	::LeaveIfErrNoMemory(err);
       
   279 	test(err == KErrNone);
       
   280 
       
   281 	// Expected number of implementations returned
       
   282 	test(implArray.Count()==1);
       
   283 
       
   284 	// Check that the implementation uid returned matched the specs above
       
   285 	TUid implUid = implArray[0]->ImplementationUid();
       
   286 	TInt version = implArray[0]->Version();
       
   287 	TInt drive = implArray[0]->Drive();
       
   288 	// imp. uid
       
   289 	test(implUid.iUid == 0x102797A2);
       
   290 	// version
       
   291 	test(version == 1);
       
   292 	// C drive
       
   293 	test(drive == EDriveC);
       
   294 
       
   295 	implArray.ResetAndDestroy();
       
   296 
       
   297 	// Now remove plugins directory
       
   298 	TRAP(err, EComTestUtils::FileManRenameL(KEComResourcePluginDirNameOnC, KEComResourcePluginDirNameOffOnC));
       
   299 	test(err == KErrNone);
       
   300 	TRAP(err, EComTestUtils::FileManDeleteDirL(KEComResourcePluginDirNameOnC));
       
   301 	test(err == KErrNone);
       
   302 
       
   303 	TEntry entry;
       
   304 	err = TheFs.Entry(KEComResourcePluginDirNameOnC, entry);
       
   305 	// Test the plugins directory is now gone
       
   306 	test(err == KErrNotFound);
       
   307 
       
   308 	// Wait EComServer performing rediscovery
       
   309 	WAIT_FOR3s;
       
   310 
       
   311 	TRAP(err, REComSession::ListImplementationsL(interfaceUid, implArray));
       
   312 	::LeaveIfErrNoMemory(err);
       
   313 	test(err == KErrNone);
       
   314 
       
   315 	// Test the rediscovery and directory scanning has been performed on renaming off event
       
   316 	test(implArray.Count()==0);
       
   317 
       
   318 	implArray.ResetAndDestroy();
       
   319 
       
   320 	// Now rename plugins directory back
       
   321 	TRAP(err, EComTestUtils::FileManRenameL(KEComResourcePluginDirNameOffOnC, KEComResourcePluginDirNameOnC));
       
   322 	test(err == KErrNone);
       
   323 	TRAP(err, EComTestUtils::FileManDeleteDirL(KEComResourcePluginDirNameOffOnC));
       
   324 	test(err == KErrNone);
       
   325 
       
   326 	// Test the plugins directory is added back
       
   327 	err = TheFs.Entry(KEComResourcePluginDirNameOnC, entry);
       
   328 	test(err == KErrNone);
       
   329 
       
   330 	// Wait EComServer performing rediscovery
       
   331 	WAIT_FOR3s;
       
   332 
       
   333 	TRAP(err, REComSession::ListImplementationsL(interfaceUid, implArray));
       
   334 	::LeaveIfErrNoMemory(err);
       
   335 	test(err == KErrNone);
       
   336 
       
   337 	// Test the rediscovery and directory scanning has been performed on renaming off event
       
   338 	test(implArray.Count()==1);
       
   339 
       
   340 	//Check that the implementation uid returned matched the specs above
       
   341 	implUid = implArray[0]->ImplementationUid();
       
   342 	version = implArray[0]->Version();
       
   343 	drive = implArray[0]->Drive();
       
   344 	test(implUid.iUid == 0x102797A2);
       
   345 	test(version == 1);
       
   346 	test(drive == EDriveC);
       
   347 
       
   348 	implArray.ResetAndDestroy();
       
   349 
       
   350 	REComSession::FinalClose(); // Don't want leaks outside the test
       
   351 
       
   352 	// Cleanup plugins
       
   353 	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComDefectPluginDLLOnC));
       
   354 	TRAP(err, EComTestUtils::FileManDeleteFileL(KEComDefectPluginRSCOnC));
       
   355 
       
   356 	__UHEAP_MARK;
       
   357 	}
       
   358 
       
   359 
       
   360 
       
   361 
       
   362 typedef void (*ClassFuncPtrL) (void);
       
   363 
       
   364 /**
       
   365 Wrapper function to call all test functions
       
   366 
       
   367 @param		testFuncL pointer to test function
       
   368 @param		aTestDesc test function name
       
   369 */
       
   370 LOCAL_C void DoBasicTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc)
       
   371 	{
       
   372 	test.Next(aTestDesc);
       
   373 
       
   374 	__UHEAP_MARK;
       
   375   	// find out the number of open handles
       
   376 	TInt startProcessHandleCount;
       
   377 	TInt startThreadHandleCount;
       
   378 	RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
   379 
       
   380 	//Call the test function
       
   381 	(*testFuncL)();
       
   382 
       
   383 	// check that no handles have leaked
       
   384 	TInt endProcessHandleCount;
       
   385 	TInt endThreadHandleCount;
       
   386 	RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
   387 
       
   388 	test(startThreadHandleCount  == endThreadHandleCount);
       
   389 
       
   390 	__UHEAP_MARKEND;
       
   391 	}
       
   392 
       
   393 /**
       
   394 Wrapper function to call all OOM test functions
       
   395 @param		testFuncL pointer to OOM test function
       
   396 @param		aTestDesc test function name
       
   397 */
       
   398 LOCAL_C void DoOOMTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc)
       
   399 	{
       
   400 	test.Next(aTestDesc);
       
   401 
       
   402 	TInt err;
       
   403 	TInt tryCount = 0;
       
   404 	do
       
   405 		{
       
   406 		__UHEAP_MARK;
       
   407   		// find out the number of open handles
       
   408 		TInt startProcessHandleCount;
       
   409 		TInt startThreadHandleCount;
       
   410 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
       
   411 
       
   412 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
       
   413 
       
   414 		//Call the test function
       
   415 		TRAP(err, ((*testFuncL)()));
       
   416 
       
   417 		__UHEAP_SETFAIL(RHeap::ENone, 0);
       
   418 
       
   419 		// release handles
       
   420 		if(err == KErrNone)
       
   421 			{
       
   422 			REComSession::FinalClose();
       
   423 			}
       
   424 
       
   425 		// check that no handles have leaked
       
   426 		TInt endProcessHandleCount;
       
   427 		TInt endThreadHandleCount;
       
   428 		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
       
   429 
       
   430 		test(startProcessHandleCount == endProcessHandleCount);
       
   431 		test(startThreadHandleCount  == endThreadHandleCount);
       
   432 
       
   433 		__UHEAP_MARKEND;
       
   434 		} while(err == KErrNoMemory);
       
   435 
       
   436 	test(err == KErrNone);
       
   437 	test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
       
   438 	}
       
   439 
       
   440 
       
   441 
       
   442 LOCAL_C void DoTestsL()
       
   443 	{
       
   444 	__UHEAP_MARK;
       
   445 
       
   446 	// Basic tests
       
   447 	test.Next(_L("Basic Test Suite"));
       
   448 	test.Start(_L("Basic Test Suite"));
       
   449 	DoBasicTestL(&TestOrphanedRscFileL, _L("TestOrphanedRscFileL"));
       
   450 	DoBasicTestL(&TestInvalidSIDPluginL, _L("TestInvalidSIDPluginL"));
       
   451 	DoBasicTestL(&TestOrphanedRscFileFallBackL, _L("TestOrphanedRscFileFallBackL"));
       
   452 	DoBasicTestL(&TestPluginsDirectoryRemovingL, _L("TestPluginsDirectoryRemovingL"));
       
   453 	test.End();
       
   454 
       
   455 	// OOM tests
       
   456 	test.Next(_L("Out-of-memory Repeat Tests"));
       
   457 	test.Start(_L("Out-of-memory Repeat Tests"));
       
   458 	DoOOMTestL(&TestOrphanedRscFileL, _L("TestOrphanedRscFileL"));
       
   459 	DoOOMTestL(&TestInvalidSIDPluginL, _L("TestInvalidSIDPluginL"));
       
   460 	DoOOMTestL(&TestOrphanedRscFileFallBackL, _L("TestOrphanedRscFileFallBackL"));
       
   461 	DoOOMTestL(&TestPluginsDirectoryRemovingL, _L("TestPluginsDirectoryRemovingL"));
       
   462 	test.End();
       
   463 
       
   464 	__UHEAP_MARKEND;
       
   465 	}
       
   466 
       
   467 
       
   468 //Initialise the Active Scheduler
       
   469 //
       
   470 LOCAL_C void SetupL()
       
   471 	{
       
   472 	// Construct and install the Active Scheduler. The Active Schedular is needed
       
   473 	// by components used by this test as they are ActiveObjects.
       
   474 	TheActiveScheduler = new(ELeave)CActiveScheduler;
       
   475 	CActiveScheduler::Install(TheActiveScheduler);
       
   476 	}
       
   477 
       
   478 GLDEF_C TInt E32Main()
       
   479 	{
       
   480 	__UHEAP_MARK;
       
   481 
       
   482 	test.Printf(_L("\n"));
       
   483 	test.Title();
       
   484 	test.Start(_L("Dual-Mode Discovery Tests"));
       
   485 
       
   486 	TheTrapCleanup = CTrapCleanup::New();
       
   487 	TInt err = TheFs.Connect();
       
   488 	test(err == KErrNone);
       
   489 	TRAP(err, SetupL());
       
   490 	test(err == KErrNone);
       
   491 
       
   492 
       
   493 	// Perform tests.
       
   494 	TRAP(err,DoTestsL());
       
   495 	test(err==KErrNone);
       
   496 
       
   497 	delete TheActiveScheduler;
       
   498 	TheFs.Close();
       
   499 	delete TheTrapCleanup;
       
   500 
       
   501 	test.End();
       
   502 	test.Close();
       
   503 
       
   504 	__UHEAP_MARKEND;
       
   505 	return (KErrNone);
       
   506 	}