sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: #include <e32test.h>
sl@0: #include <bautils.h>
sl@0: #include <barsread2.h>
sl@0: #include <barsc2.h>
sl@0: #include <baspi.h>
sl@0: #include "BaArchiveImpl.h"
sl@0: 
sl@0: 
sl@0: LOCAL_D RTest TheTest(_L("T_RSCARCHIVE"));
sl@0: LOCAL_D RFs TheFs;
sl@0: 
sl@0: //Test files
sl@0: _LIT(KXipSpiFile,"z:\\system\\data\\Spi_ECom.SPI");
sl@0: _LIT(KNonXipSpiFile, "c:\\system\\data\\Spi_ECom.SPI");
sl@0: 
sl@0: 
sl@0: //----------------------UTILITY FUNCTIONS----------------------------------
sl@0: LOCAL_C void CopyFileL(const TDesC& aFrom,const TDesC& aTo)
sl@0: 	{
sl@0: 	TheFs.Delete(aTo);
sl@0: 	CFileMan* man=CFileMan::NewL(TheFs);
sl@0: 	TInt r=man->Copy(aFrom,aTo, CFileMan::ERecurse);
sl@0: 	delete man;
sl@0: 	User::LeaveIfError(r);
sl@0: 	User::LeaveIfError(TheFs.SetAtt(aTo,0,KEntryAttReadOnly)); // clear RO
sl@0: 	}
sl@0: 
sl@0: LOCAL_C void DeleteFile(const TDesC& aFileName)
sl@0: 	{
sl@0: 	// make sure the file is read/write
sl@0: 	TInt err = TheFs.SetAtt(aFileName, 0, KEntryAttReadOnly);
sl@0: 	if(err != KErrNone)
sl@0: 		{
sl@0: 		RDebug::Print(_L("error changing attributes file = %d"),err);
sl@0: 		}
sl@0: 	// delete the file
sl@0: 	err = BaflUtils::DeleteFile(TheFs, aFileName);
sl@0: 	if(err != KErrNone)
sl@0: 		{
sl@0: 		RDebug::Print(_L("error deleting file = %d"),err);
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: LOCAL_C void DeleteTestFile()
sl@0: 	{
sl@0: 	DeleteFile(KNonXipSpiFile);
sl@0: 	//Testcase 1 files
sl@0: 	DeleteFile(_L("c:\\system\\data\\spi_ecom-0-0.spi"));
sl@0: 	DeleteFile(_L("c:\\system\\data\\spi_ecom-1-0.spi"));
sl@0: 	//Testcase 2 files
sl@0: 	DeleteFile(_L("c:\\system\\data\\ecom-1-0.spi"));
sl@0: 	DeleteFile(_L("c:\\system\\data\\ecom-1-0.s02"));
sl@0: 	DeleteFile(_L("c:\\system\\data\\ecom-2-0.spi"));
sl@0: 	DeleteFile(_L("c:\\system\\data\\ecom-2-0.s02"));
sl@0: 	//Testcase 3 files
sl@0: 	DeleteFile(_L("c:\\system\\data\\cecom-0-0.spi"));
sl@0: 	DeleteFile(_L("c:\\system\\data\\cecom-1-0.spi"));
sl@0: 	//Testcase 5 files
sl@0: 	DeleteFile(_L("c:\\system\\data\\spi_ecom_case-0-0.spi"));
sl@0: 	DeleteFile(_L("c:\\system\\data\\spi_ecom_case-1-0.spi"));
sl@0: 	}
sl@0: 
sl@0: LOCAL_C void CopyTestFile()
sl@0: 	{
sl@0: 	CopyFileL(KXipSpiFile,KNonXipSpiFile);
sl@0: 	//Testcase1 files
sl@0: 	CopyFileL(_L("z:\\system\\data\\spi_ecom-0-0.spi"),_L("c:\\system\\data\\spi_ecom-0-0.spi"));
sl@0: 	CopyFileL(_L("z:\\system\\data\\spi_ecom-1-0.spi"),_L("c:\\system\\data\\spi_ecom-1-0.spi"));
sl@0: 	//Testcase2 files
sl@0: 	CopyFileL(_L("z:\\system\\data\\ecom-1-0.spi"),_L("c:\\system\\data\\ecom-1-0.spi"));
sl@0: 	CopyFileL(_L("z:\\system\\data\\ecom-1-0.s02"),_L("c:\\system\\data\\ecom-1-0.s02"));
sl@0: 	CopyFileL(_L("z:\\system\\data\\ecom-2-0.spi"),_L("c:\\system\\data\\ecom-2-0.spi"));
sl@0: 	CopyFileL(_L("z:\\system\\data\\ecom-2-0.s02"),_L("c:\\system\\data\\ecom-2-0.s02"));
sl@0: 	//Testcase 3 files
sl@0: 	CopyFileL(_L("z:\\system\\data\\cecom-0-0.spi"),_L("c:\\system\\data\\cecom-0-0.spi"));
sl@0: 	CopyFileL(_L("z:\\system\\data\\cecom-1-0.spi"),_L("c:\\system\\data\\cecom-1-0.spi"));
sl@0: 	//Testcase 5 files
sl@0: 	CopyFileL(_L("z:\\system\\data\\spi_ecom_case-0-0.spi"),_L("c:\\system\\data\\spi_ecom_case-0-0.spi"));
sl@0: 	CopyFileL(_L("z:\\system\\data\\spi_ecom_case-1-0.spi"),_L("c:\\system\\data\\spi_ecom_case-1-0.spi"));
sl@0: 	}
sl@0: 
sl@0: //Test macroses and functions
sl@0: LOCAL_C void Check(TInt aValue, TInt aLine)
sl@0: 	{
sl@0: 	if(!aValue)
sl@0: 		{
sl@0: 		::DeleteTestFile();
sl@0: 		TheTest(EFalse, aLine);
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: #define TEST(arg) ::Check((arg), __LINE__)
sl@0: 
sl@0: //---------------------TEST CASE for RResoureArchive------------------
sl@0: class RStaticPluginInfoTest
sl@0: 	{
sl@0: public:
sl@0: 	static void TestCase1L(const TDesC& aPath);
sl@0: 	static void TestCase2L(const TDesC& aPath);
sl@0: 	static void TestCase3L(const TDesC& aPath);
sl@0: 	static void TestCase4L(const TDesC& aPath);
sl@0: 	static void TestCase5L(const TDesC& aPath);
sl@0: 	};
sl@0: 
sl@0: typedef void (*FunctionPtr)(const TDesC&);
sl@0: 
sl@0: static void DoBasicTestingL(FunctionPtr aFunctionPtr,const TDesC& aPath,const TDesC& aDescription)
sl@0: {
sl@0: 	TheTest.Next(aDescription);
sl@0: 	__UHEAP_MARK;
sl@0: 	TInt startProcessHandleCount;
sl@0: 	TInt startThreadHandleCount;
sl@0: 	RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
sl@0: 
sl@0: 	aFunctionPtr(aPath);
sl@0: 
sl@0: 	TInt endProcessHandleCount;
sl@0: 	TInt endThreadHandleCount;
sl@0: 	RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
sl@0: 
sl@0: 	TEST(startProcessHandleCount == endProcessHandleCount);
sl@0: 	TEST(startThreadHandleCount  == endThreadHandleCount);
sl@0: 
sl@0: 	__UHEAP_MARKEND;
sl@0: }
sl@0: 
sl@0: 
sl@0: static void DoOOMTestingL(FunctionPtr aFunctionPtr,const TDesC& aPath,const TDesC& aDescription)
sl@0: {
sl@0: 	TheTest.Next(aDescription);
sl@0: 	TInt err;
sl@0: 	TInt tryCount = 0;
sl@0: 	do
sl@0: 		{
sl@0: 		__UHEAP_MARK;
sl@0:   		// find out the number of open handles
sl@0: 		TInt startProcessHandleCount;
sl@0: 		TInt startThreadHandleCount;
sl@0: 		RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
sl@0: 		__UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount);
sl@0: 
sl@0: 		TRAP(err,aFunctionPtr(aPath));
sl@0: 
sl@0: 		__UHEAP_SETFAIL(RHeap::ENone, 0);
sl@0: 
sl@0: 		//Add ReleaseLanguage for Test4
sl@0: 		BaflUtils::ReleaseIdealLanguage();
sl@0: 
sl@0: 		// check that no handles have leaked
sl@0: 		TInt endProcessHandleCount;
sl@0: 		TInt endThreadHandleCount;
sl@0: 		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
sl@0: 
sl@0: 		TEST(startProcessHandleCount == endProcessHandleCount);
sl@0: 		TEST(startThreadHandleCount  == endThreadHandleCount);
sl@0: 		__UHEAP_MARKEND;
sl@0: 		} while(err == KErrNoMemory);
sl@0: 	RDebug::Print(_L("Success at count=%d\n"),tryCount);
sl@0: }
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID SYSLIB-BAFL-UT-1698
sl@0: @SYMTestCaseDesc Test for creating and deleting newly added constructor for CResourceArchiveImpl
sl@0: @SYMTestPriority High
sl@0: @SYMTestActions
sl@0: -create and delete CResourceArchiveImpl
sl@0: -check for the resource file entry from multiple spi files
sl@0: -and test for the replacing/hiding feature
sl@0: files used
sl@0: -----------------------------------------------------------
sl@0: spi_ecom-0-0.spi |	spi_ecom-1-0.spi  |	Visible resources
sl@0: -----------------------------------------------------------
sl@0: Spi_EComRsc1	 |	hide Spi_EComRsc1 |	Spi_EComRsc2(id=1)
sl@0: Spi_EComRsc2	 |	Spi_EComRsc2	  |	Spi_EComRsc3(id=0)
sl@0: Spi_EComRsc3	 |	Spi_EComRsc4	  |	Spi_EComRsc4(id=1)
sl@0: @SYMTestExpectedResults The test must not fail.
sl@0: @SYMREQ CR0759
sl@0: */
sl@0: void RStaticPluginInfoTest::TestCase1L(const TDesC& aPath)
sl@0: 	{
sl@0: 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-UT-1698 "));
sl@0: 	//create and delete
sl@0: 	CResourceArchiveImpl* impl=CResourceArchiveImpl::NewL(TheFs,aPath,_L("Spi_ECom"));
sl@0: 	delete impl;
sl@0: 
sl@0: 	//check and read resource entry
sl@0: 	impl=CResourceArchiveImpl::NewL(TheFs,aPath,_L("Spi_ECom"));
sl@0: 	CleanupStack::PushL(impl);
sl@0: 	HBufC* rscName=NULL;
sl@0: 	CResourceFile* rscFile=NULL;
sl@0: 	TInt count=0;
sl@0: 	while (impl->NextResourceExist())
sl@0: 		{
sl@0: 		TFileName expectedFile;
sl@0: 		expectedFile.Append(aPath);
sl@0: 		//test the rsc entry file association
sl@0: 		if (count==0 || count==2)
sl@0: 			{
sl@0: 			expectedFile.Append(_L("spi_ecom-1-0.spi"));
sl@0: 			TEST(impl->iRscList[count].iFileNamePtr.Compare(expectedFile)==0);
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			expectedFile.Append(_L("spi_ecom-0-0.spi"));
sl@0: 			TEST(impl->iRscList[count].iFileNamePtr.Compare(expectedFile)==0);
sl@0: 			}
sl@0: 		count++;
sl@0: 		rscFile=impl->NextL(rscName);
sl@0: 		TEST(rscFile!=NULL);
sl@0: 		TEST(rscName!=NULL);
sl@0: 		TBuf<12> buf;
sl@0: 		TInt temp=count+1;
sl@0: 		buf.AppendFormat(_L("Spi_EComRsc%d"),temp);
sl@0: 		TEST(rscName->Compare(buf)==0);
sl@0: 		delete rscName;
sl@0: 		rscName=NULL;
sl@0: 		delete rscFile;
sl@0: 		rscFile=NULL;
sl@0: 		}
sl@0: 	TEST(count==3);
sl@0: 
sl@0: 	//Testing Reset
sl@0: 	TEST(!impl->NextResourceExist());
sl@0: 	impl->Reset();
sl@0: 	TEST(impl->NextResourceExist());
sl@0: 
sl@0: 	//Testing Type
sl@0: 	const TUid KEcomSpiFileTypeUid = {0x10205C2C};
sl@0: 	TEST(impl->Type()==KEcomSpiFileTypeUid);
sl@0: 
sl@0: 	CleanupStack::PopAndDestroy();
sl@0: 	}
sl@0: 
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1695
sl@0: @SYMTestCaseDesc Test that loading of multiple localised spis return a correct list
sl@0: of resource files
sl@0: @SYMTestPriority High
sl@0: @SYMTestActions  Set different language downgrade path before using CResourceArchiveImpl
sl@0: to open a path containing a mix of spi files. Check that the list returned when
sl@0: calling NextL contains the expected resource files.
sl@0: -------------------------------------------------------------------------------
sl@0: Ecom-1-0.spi | Ecom-1-0.s02 | Ecom-2-0.spi | Ecom-2-0.s02  |DGP(1)   | DGP(2-1)
sl@0: ROFS(1)	     | (ROFS1)      | (ROFS2)	   | (ROFS2)       |
sl@0: -------------------------------------------------------------------------------
sl@0: A.RSC		 |	A.R02		|   B.RSC	   |  Hide D.R02   |A.RSC(1) | A.R02(1)
sl@0: B.RSC	     |	D.R02		|			   |  C.R02        |B.RSC(2) | B.RSC(2)
sl@0: C.RSC        |              |              |               |C.RSC(1) | C.R02(2)
sl@0: -------------------------------------------------------------------------------
sl@0: @SYMTestExpectedResults The test must not fail.
sl@0: @SYMREQ CR0759
sl@0: */
sl@0: void RStaticPluginInfoTest::TestCase2L(const TDesC& aPath)
sl@0: 	{
sl@0: 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1695 "));
sl@0: 	//Language DownGradePath(1)
sl@0: 	CResourceArchiveImpl* impl=CResourceArchiveImpl::NewL(TheFs,aPath,_L("ECom"));
sl@0: 	CleanupStack::PushL(impl);
sl@0: 	HBufC* rscName=NULL;
sl@0: 	CResourceFile* rscFile=NULL;
sl@0: 	TInt count=0;
sl@0: 	while (impl->NextResourceExist())
sl@0: 		{
sl@0: 		TFileName expectedFile;
sl@0: 		expectedFile.Append(aPath);
sl@0: 		rscFile=impl->NextL(rscName);
sl@0: 		if (count==0)
sl@0: 			{
sl@0: 			TEST(rscName->Compare(_L("Spi_EComRscA"))==0);
sl@0: 			//also testing the spi file association of the resource entry
sl@0: 			expectedFile.Append(_L("ecom-1-0.spi"));
sl@0: 			TEST(impl->iRscList[count].iFileNamePtr.Compare(expectedFile)==0);
sl@0: 			}
sl@0: 		if (count==1)
sl@0: 			{
sl@0: 			TEST(rscName->Compare(_L("Spi_EComRscB"))==0);
sl@0: 			expectedFile.Append(_L("ecom-2-0.spi"));
sl@0: 			TEST(impl->iRscList[count].iFileNamePtr.Compare(expectedFile)==0);
sl@0: 			}
sl@0: 		if (count==2)
sl@0: 			{
sl@0: 			TEST(rscName->Compare(_L("Spi_EComRscC"))==0);
sl@0: 			expectedFile.Append(_L("ecom-1-0.spi"));
sl@0: 			TEST(impl->iRscList[count].iFileNamePtr.Compare(expectedFile)==0);
sl@0: 			}
sl@0: 		count++;
sl@0: 		delete rscName;
sl@0: 		rscName=NULL;
sl@0: 		delete rscFile;
sl@0: 		rscFile=NULL;
sl@0: 		}
sl@0: 	TEST(count==3);
sl@0: 	CleanupStack::PopAndDestroy();
sl@0: 
sl@0: 	//Language DownGradePath(2-1)
sl@0: 	User::LeaveIfError(BaflUtils::SetIdealLanguage(ELangFrench));
sl@0: 	impl=CResourceArchiveImpl::NewL(TheFs,aPath,_L("ECom"));
sl@0: 	CleanupStack::PushL(impl);
sl@0: 	rscName=NULL;
sl@0: 	rscFile=NULL;
sl@0: 	count=0;
sl@0: 	while (impl->NextResourceExist())
sl@0: 		{
sl@0: 		TFileName expectedFile;
sl@0: 		expectedFile.Append(aPath);
sl@0: 		rscFile=impl->NextL(rscName);
sl@0: 		if (count==0)
sl@0: 			{
sl@0: 			TEST(rscName->Compare(_L("Spi_EComRscA"))==0);
sl@0: 			//also testing the spi file association of the resource entry
sl@0: 			expectedFile.Append(_L("ecom-1-0.s02"));
sl@0: 			TEST(impl->iRscList[count].iFileNamePtr.Compare(expectedFile)==0);
sl@0: 			}
sl@0: 		if (count==1)
sl@0: 			{
sl@0: 			TEST(rscName->Compare(_L("Spi_EComRscB"))==0);
sl@0: 			expectedFile.Append(_L("ecom-2-0.spi"));
sl@0: 			TEST(impl->iRscList[count].iFileNamePtr.Compare(expectedFile)==0);
sl@0: 			}
sl@0: 		if (count==2)
sl@0: 			{
sl@0: 			TEST(rscName->Compare(_L("Spi_EComRscC"))==0);
sl@0: 			expectedFile.Append(_L("ecom-2-0.s02"));
sl@0: 			TEST(impl->iRscList[count].iFileNamePtr.Compare(expectedFile)==0);
sl@0: 			}
sl@0: 		count++;
sl@0: 		delete rscName;
sl@0: 		rscName=NULL;
sl@0: 		delete rscFile;
sl@0: 		rscFile=NULL;
sl@0: 		}
sl@0: 	TEST(count==3);
sl@0: 	CleanupStack::PopAndDestroy();
sl@0: 
sl@0: 	BaflUtils::ReleaseIdealLanguage();
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1696
sl@0: @SYMTestCaseDesc Test opening corrupt file and an inconsistent list of spi files
sl@0: @SYMTestPriority High
sl@0: @SYMTestActions  Try to open an invalid/corrupt spi file. Try to open a list
sl@0: of spi files where one of them has a different spi type, expect this to leave
sl@0: with KErrCorrupt.
sl@0: @SYMTestExpectedResults The test must not fail.
sl@0: @SYMREQ CR0759
sl@0: */
sl@0: //negative testing using cecom-0-0.spi(Corrupt) and cecom-1-0.spi(OK)
sl@0: void RStaticPluginInfoTest::TestCase3L(const TDesC& aPath)
sl@0: 	{
sl@0: 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1696 "));
sl@0: 	TInt err=KErrNone;
sl@0: 	CResourceArchiveImpl* impl=NULL;
sl@0: 	//Testing opening single corrupt spi file
sl@0: 	TFileName filename;
sl@0: 	filename.Append(aPath);
sl@0: 	filename.Append(_L("cecom-0-0.spi"));
sl@0: 	TRAP(err,impl=CResourceArchiveImpl::NewL(TheFs,filename));
sl@0: 	if (err==KErrNoMemory)
sl@0: 		User::LeaveNoMemory();
sl@0: 	TEST(err==KErrCorrupt);
sl@0: 	delete impl;
sl@0: 
sl@0: 	//Testing opening spi files where one is not a valid spi file
sl@0: 	TRAP(err,impl=CResourceArchiveImpl::NewL(TheFs,aPath,_L("CECom")));
sl@0: 	if (err==KErrNoMemory)
sl@0: 		User::LeaveNoMemory();
sl@0: 	TEST(err==KErrCorrupt);
sl@0: 	delete impl;
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1697
sl@0: @SYMTestCaseDesc Test opening file which does not exist
sl@0: @SYMTestPriority High
sl@0: @SYMTestActions  Try to open spi files in a specified path but there
sl@0: is no file that matches the specified pattern to look for.
sl@0: @SYMTestExpectedResults The test must not fail.
sl@0: @SYMREQ CR0759
sl@0: */
sl@0: void RStaticPluginInfoTest::TestCase4L(const TDesC& aPath)
sl@0: 	{
sl@0: 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1697 "));
sl@0: 	TInt err=KErrNone;
sl@0: 	TRAP(err,CResourceArchiveImpl* impl=CResourceArchiveImpl::NewL(TheFs,aPath,_L("SpiECom")));
sl@0: 	if (err==KErrNoMemory)
sl@0: 		User::LeaveNoMemory();
sl@0: 	TEST(err==KErrNotFound);
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID SYSLIB-BAFL-UT-3473
sl@0: @SYMTestCaseDesc Test that resource selection is case insensitive
sl@0: @SYMTestPriority High
sl@0: @SYMTestActions
sl@0: -create a CResourceArchiveImpl
sl@0: -check the correct resource file entry is chosen from multiple spi files
sl@0: ------------------------------------------------------------------
sl@0: Spi_ECom_Case-0-0.spi |	Spi_ECom_Case-1-0.spi  | Visible resources
sl@0: ------------------------------------------------------------------
sl@0: Spi_EComRsc1	      |	Spi_ECOMRSC1           | Spi_ECOMRSC1(id=1)
sl@0: Spi_ECOMRSC2	      |	Spi_EComRsc2	       | Spi_EComRsc2(id=1)
sl@0: ------------------------------------------------------------------
sl@0: @SYMTestExpectedResults The overridden resource is chosen regardless of case.
sl@0: @SYMDEF DEF105972
sl@0: @SYMUnit CResourceArchiveImpl::ProcessEntryL()
sl@0: */
sl@0: void RStaticPluginInfoTest::TestCase5L(const TDesC& aPath)
sl@0: 	{
sl@0: 	//check and read resource entry
sl@0: 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-UT-3473 "));
sl@0: 	CResourceArchiveImpl* impl=CResourceArchiveImpl::NewL(TheFs,aPath,_L("Spi_ECom_Case"));
sl@0: 	CleanupStack::PushL(impl);
sl@0: 	HBufC* rscName=NULL;
sl@0: 	CResourceFile* rscFile=NULL;
sl@0: 	TInt count=0;
sl@0: 	while (impl->NextResourceExist())
sl@0: 		{
sl@0: 		TFileName expectedFile;
sl@0: 		expectedFile.Append(aPath);
sl@0: 		//test that the overridden resource is always chosen
sl@0: 		expectedFile.Append(_L("spi_ecom_case-1-0.spi"));
sl@0: 		TEST(impl->iRscList[count].iFileNamePtr.CompareF(expectedFile)==0);
sl@0: 
sl@0: 		count++;
sl@0: 		rscFile=impl->NextL(rscName);
sl@0: 		TEST(rscFile!=NULL);
sl@0: 		TEST(rscName!=NULL);
sl@0: 		delete rscName;
sl@0: 		rscName=NULL;
sl@0: 		delete rscFile;
sl@0: 		rscFile=NULL;
sl@0: 		}
sl@0: 	TEST(count==2);
sl@0: 
sl@0: 	impl->Reset();
sl@0: 	CleanupStack::PopAndDestroy();
sl@0: 	}
sl@0: 
sl@0: LOCAL_C void DoAllTestsL()
sl@0: 	{
sl@0: 	CleanupClosePushL(TheFs);
sl@0: 	User::LeaveIfError(TheFs.Connect());
sl@0: 
sl@0: 	TheTest.Printf(_L("Copying SPI files to RAM\r\n"));
sl@0: 
sl@0: 	//Copying test spi file and individual rsc files that are included inside spi
sl@0: 	CopyTestFile();
sl@0: 
sl@0: 	//Basic Test
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase1L,_L("z:\\system\\data\\"),_L("Test Case 1 Basic Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase1L,_L("c:\\system\\data\\"),_L("Test Case 1 Basic Non-Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase2L,_L("z:\\system\\data\\"),_L("Test Case 2 Basic Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase2L,_L("c:\\system\\data\\"),_L("Test Case 2 Basic Non-Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase3L,_L("z:\\system\\data\\"),_L("Test Case 3 Basic Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase3L,_L("c:\\system\\data\\"),_L("Test Case 3 Basic Non-Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase4L,_L("z:\\system\\data\\"),_L("Test Case 4 Basic Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase4L,_L("c:\\system\\data\\"),_L("Test Case 4 Basic Non-Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase5L,_L("z:\\system\\data\\"),_L("Test Case 5 Basic Xip"));
sl@0: 	DoBasicTestingL(RStaticPluginInfoTest::TestCase5L,_L("c:\\system\\data\\"),_L("Test Case 5 Basic Non-Xip"));
sl@0: 
sl@0: 	//OOM Test
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase1L,_L("z:\\system\\data\\"),_L("Test Case 1 OOM Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase1L,_L("c:\\system\\data\\"),_L("Test Case 1 OOM Non-Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase2L,_L("z:\\system\\data\\"),_L("Test Case 2 OOM Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase2L,_L("c:\\system\\data\\"),_L("Test Case 2 OOM Non-Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase3L,_L("z:\\system\\data\\"),_L("Test Case 3 OOM Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase3L,_L("c:\\system\\data\\"),_L("Test Case 3 OOM Non-Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase4L,_L("z:\\system\\data\\"),_L("Test Case 4 OOM Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase4L,_L("c:\\system\\data\\"),_L("Test Case 4 OOM Non-Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase5L,_L("z:\\system\\data\\"),_L("Test Case 5 OOM Xip"));
sl@0: 	DoOOMTestingL(RStaticPluginInfoTest::TestCase5L,_L("c:\\system\\data\\"),_L("Test Case 5 OOM Non-Xip"));
sl@0: 
sl@0: 	//Clearing all the test files we have copied to C
sl@0: 	DeleteTestFile();
sl@0: 
sl@0: 	CleanupStack::PopAndDestroy(1, &TheFs);
sl@0: 	}
sl@0: 
sl@0: GLDEF_C TInt E32Main()
sl@0: 	{
sl@0:     __UHEAP_MARK;
sl@0:     CTrapCleanup *cleanup=CTrapCleanup::New();
sl@0: 	TheTest.Title();
sl@0: 	TheTest.Start(_L("Testing RResourceArchive internal class"));
sl@0:     TRAPD(err,DoAllTestsL());
sl@0:     TheTest.Printf(_L("Error code is %d\n"),err);
sl@0:     TEST(err==KErrNone);
sl@0:     TheTest.End();
sl@0:     TheTest.Close();
sl@0:     delete cleanup;
sl@0:     __UHEAP_MARKEND;
sl@0: 	return(0);
sl@0:     }
sl@0: