sl@0: // Copyright (c) 2003-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: // Tests CResourceFile class - memory allocation tests sl@0: // sl@0: // sl@0: sl@0: #include <e32test.h> sl@0: #include <barsc2.h> sl@0: sl@0: LOCAL_D RTest test(_L("T_RSCMEM")); sl@0: LOCAL_D RFs TheFs; sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0484 sl@0: @SYMTestCaseDesc CResourceFile class test sl@0: Memory allocation tests sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for the out of memory conditions sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestOpenL(const TDesC &aFileName, TUint aFileOffset, TUint aFileSize) sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0484 ")); sl@0: __UHEAP_RESET; sl@0: sl@0: for(TInt count = 1; ;count++) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, count); sl@0: __UHEAP_MARK; sl@0: sl@0: CResourceFile* rsc_file = NULL; sl@0: TRAPD(err, rsc_file = CResourceFile::NewL(TheFs, aFileName, aFileOffset, aFileSize)); sl@0: delete rsc_file; sl@0: sl@0: if(err == KErrNoMemory) sl@0: { sl@0: __UHEAP_MARKEND; sl@0: } sl@0: else if(err == KErrNone) sl@0: { sl@0: __UHEAP_MARKEND; sl@0: break; sl@0: } sl@0: else sl@0: User::Panic(_L("CResourceFile::NewL(), error "), err); sl@0: } sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: LOCAL_C void DoTestsL() sl@0: { sl@0: CleanupClosePushL(TheFs); sl@0: User::LeaveIfError(TheFs.Connect()); sl@0: sl@0: ::TestOpenL(_L("z:\\system\\data\\Trsc.rsc"), 0, 0); 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: test.Title(); sl@0: test.Start(_L("Testing CResourceFile::NewL()")); sl@0: TRAPD(err, DoTestsL()); sl@0: test.Printf(_L("Error code is %d\n"), err); sl@0: test(err == KErrNone); sl@0: test.Next(_L("/n")); sl@0: test.End(); sl@0: test.Close(); sl@0: delete cleanup; sl@0: __UHEAP_MARKEND; sl@0: return 0; sl@0: }