sl@0: // Copyright (c) 2007-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: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "tgraphicsresourceteststepbase.h" sl@0: #include sl@0: sl@0: CTSgTestStepBase::CTSgTestStepBase() sl@0: { sl@0: } sl@0: sl@0: CTSgTestStepBase::~CTSgTestStepBase() sl@0: { sl@0: iSecondThread.Close(); sl@0: } sl@0: sl@0: /** sl@0: Overrides of base class virtual sl@0: @leave Gets system wide error code sl@0: @return - TVerdict code sl@0: */ sl@0: TVerdict CTSgTestStepBase::doTestStepPreambleL() sl@0: { sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /** sl@0: Override of base class virtual sl@0: @leave Gets system wide error code sl@0: @return - TVerdict code sl@0: */ sl@0: TVerdict CTSgTestStepBase::doTestStepPostambleL() sl@0: { sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /** sl@0: Override of function from CTestStep so that each test failure is reported in output. sl@0: */ sl@0: EXPORT_C void CTSgTestStepBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine) sl@0: { sl@0: TRAP_IGNORE(testBooleanTrueL(aCondition, aFile, aLine, ETrue)); sl@0: } sl@0: sl@0: /** sl@0: Creates an image with some predefined parametres. sl@0: @param aImage output image handle sl@0: @leave Gets system wide error code sl@0: */ sl@0: void CTSgTestStepBase::CreateImageL(RSgImage& aImage) sl@0: { sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(8, 8); sl@0: info.iUsage = ESgUsageDirectGdiSource; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iCpuAccess = ESgCpuAccessReadWrite; sl@0: info.iShareable = ETrue; sl@0: sl@0: CheckErrorL(KErrNone, aImage.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: } sl@0: sl@0: /** sl@0: Creates an image collection with some predefined parametres. sl@0: @param aCollection output image collection handle sl@0: @leave Gets system wide error code sl@0: */ sl@0: void CTSgTestStepBase::CreateImageCollectionL(RSgImageCollection& aCollection) sl@0: { sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(8, 8); sl@0: info.iUsage = ESgUsageDirectGdiSource; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iCpuAccess = ESgCpuAccessReadWrite; sl@0: CheckErrorL(KErrNone, aCollection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__); sl@0: TEST(!aCollection.IsNull()); sl@0: } sl@0: sl@0: /** sl@0: Creates a second process and do some tests in it. sl@0: @param aProcessName The name of the new process sl@0: @param aTestInfo The information for the tests sl@0: @leave Gets system wide error code sl@0: */ sl@0: TInt CTSgTestStepBase::CreateSecondProcessAndDoTestL(const TDesC &aProcessName, TSgresTestInfo& aTestInfo) sl@0: { sl@0: // Create a second process sl@0: RProcess process; sl@0: User::LeaveIfError(process.Create(aProcessName, KNullDesC)); sl@0: CleanupClosePushL(process); sl@0: sl@0: // Specify the test for the second process sl@0: TESTL(KErrNone == process.SetParameter(KSecondProcessFunctionSlot, ((TSgresTestInfo)aTestInfo).iTestCase)); sl@0: // Specify the id passed to the second process sl@0: TPckg ptr(aTestInfo); sl@0: sl@0: TESTL(KErrNone == process.SetParameter(KSecondProcessParametersSlot, ptr)); sl@0: // Kick off the second process and wait for it to complete sl@0: // The actual testing is done in the second process sl@0: TRequestStatus status = KRequestPending; sl@0: process.Logon(status); sl@0: process.Resume(); sl@0: User::WaitForRequest(status); sl@0: sl@0: TInt exitreason = process.ExitReason(); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: //return test result sl@0: return exitreason; sl@0: } sl@0: sl@0: /** sl@0: Creates a second thread and do some tests in it. sl@0: @param aTestInfo The information for the tests sl@0: @leave Gets system wide error code sl@0: */ sl@0: TInt CTSgTestStepBase::CreateSecondThreadAndDoTestL(TSgresTestInfo aTestInfo) sl@0: { sl@0: //create a semaphore sl@0: RSemaphore sem; sl@0: User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread)); sl@0: CleanupClosePushL(sem); sl@0: sl@0: User::LeaveIfError(iSecondThread.Create(KSecondThread, SecondThreadStart, KDefaultStackSize, &User::Heap(), &aTestInfo)); sl@0: // Launch second thread sl@0: TRequestStatus statusSecondThread; sl@0: iSecondThread.Logon(statusSecondThread); sl@0: iSecondThread.SetPriority(EPriorityLess); sl@0: iSecondThread.Resume(); sl@0: sl@0: User::WaitForRequest(statusSecondThread); sl@0: sl@0: TInt result = iSecondThread.ExitReason(); sl@0: sl@0: //Close the handle sl@0: CleanupStack::PopAndDestroy(1, &sem); sl@0: iSecondThread.Close(); sl@0: sl@0: return result; sl@0: } sl@0: sl@0: /** sl@0: Creates a second thread and do some panic tests in it. sl@0: @param aTestInfo The information for the tests sl@0: @param aPanicCode The expected panic code sl@0: @param aExitCategory The expected panic category sl@0: @param aThreadName The name of the new thread sl@0: @leave Gets system wide error code sl@0: */ sl@0: void CTSgTestStepBase::CreateSecondThreadAndCheckPanicL(TSgresTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName) sl@0: { sl@0: User::LeaveIfError(iSecondThread.Create(aThreadName, SecondThreadStart, KDefaultStackSize, 0x100, 0x100, &aTestInfo)); sl@0: // Launch second thread sl@0: TRequestStatus statusSecondThread; sl@0: iSecondThread.Logon(statusSecondThread); sl@0: iSecondThread.SetPriority(EPriorityLess); sl@0: iSecondThread.Resume(); sl@0: sl@0: User::WaitForRequest(statusSecondThread); sl@0: sl@0: if(EExitPanic != iSecondThread.ExitType()) sl@0: { sl@0: ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, iSecondThread.ExitType()); sl@0: TEST(EFalse); sl@0: } sl@0: sl@0: if(aPanicCode != iSecondThread.ExitReason()) sl@0: { sl@0: ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, iSecondThread.ExitReason()); sl@0: TEST(EFalse); sl@0: } sl@0: sl@0: TExitCategoryName secondThreadExitCategory = iSecondThread.ExitCategory(); sl@0: if(aExitCategory != secondThreadExitCategory) sl@0: { sl@0: ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &secondThreadExitCategory); sl@0: TEST(EFalse); sl@0: } sl@0: sl@0: //close the driver if the second thread exited with type EExitKill sl@0: //assumming the second thread only calls SgDriver::Open() once sl@0: if(iSecondThread.ExitType() != EExitKill) sl@0: { sl@0: SgDriver::Close(); sl@0: } sl@0: sl@0: //Close the handle sl@0: iSecondThread.Close(); sl@0: } sl@0: sl@0: /** sl@0: Creates a second process and do some panic tests in it. sl@0: @param aTestInfo The information for the tests sl@0: @param aPanicCode The expected panic code sl@0: @param aExitCategory The expected panic category sl@0: @param aProcessName The name of the new process sl@0: @leave Gets system wide error code sl@0: */ sl@0: void CTSgTestStepBase::CreateSecondProcessAndCheckPanicL(TSgresTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aProcessName) sl@0: { sl@0: // Create a second process sl@0: RProcess process; sl@0: User::LeaveIfError(process.Create(KSecondProcess, aProcessName)); sl@0: CleanupClosePushL(process); sl@0: sl@0: // Specify the test for the second process sl@0: TESTL(KErrNone == process.SetParameter(KSecondProcessFunctionSlot, ((TSgresTestInfo)aTestInfo).iTestCase)); sl@0: // Specify the id passed to the second process sl@0: TPckg ptr(aTestInfo); sl@0: sl@0: TESTL(KErrNone == process.SetParameter(KSecondProcessParametersSlot, ptr)); sl@0: // Kick off the second process and wait for it to complete sl@0: // The actual testing is done in the second process sl@0: TRequestStatus status; sl@0: process.Logon(status); sl@0: process.Resume(); sl@0: User::WaitForRequest(status); sl@0: sl@0: if(EExitPanic != process.ExitType()) sl@0: { sl@0: ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, process.ExitType()); sl@0: TEST(EFalse); sl@0: } sl@0: if(aPanicCode != process.ExitReason()) sl@0: { sl@0: ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, process.ExitReason()); sl@0: TEST(EFalse); sl@0: } sl@0: sl@0: _LIT(KMemoryLeakCategory, "SGALLOC"); sl@0: TExitCategoryName processExitCategory = process.ExitCategory(); sl@0: TBool matchCategory; sl@0: if (aExitCategory != KMemoryLeakCategory) sl@0: { sl@0: matchCategory = aExitCategory == processExitCategory; sl@0: } sl@0: else sl@0: { sl@0: matchCategory = processExitCategory.Left(KMemoryLeakCategory().Length()) == KMemoryLeakCategory; sl@0: } sl@0: if (!matchCategory) sl@0: { sl@0: ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &processExitCategory); sl@0: TEST(EFalse); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: sl@0: /** sl@0: Gets the supporting pixel formats according to the specified cpu access, usage, shareability and screen id flags. sl@0: @leave Gets system wide error code sl@0: */ sl@0: void CTSgTestStepBase::CallGetPixelFormatsL(TSgCpuAccess aCpuAccess, TUint32 aUsage, TBool aShareable, TInt aScreenId) sl@0: { sl@0: TSgImageInfo info; sl@0: info.iCpuAccess = aCpuAccess; sl@0: info.iUsage = aUsage; sl@0: info.iShareable = aShareable; sl@0: info.iScreenId = aScreenId; sl@0: info.iSizeInPixels = TSize(10, 10); sl@0: iPixelFormatCount = KMaxPixelFormats; sl@0: Mem::FillZ(iPixelFormatArray, KMaxPixelFormats * sizeof(TUidPixelFormat)); sl@0: CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, iPixelFormatArray, iPixelFormatCount), (TText8*)__FILE__, __LINE__); sl@0: } sl@0: sl@0: /** sl@0: Checks the pixel formats returned against the compatibility guarantee table. sl@0: @leave Gets system wide error code sl@0: */ sl@0: void CTSgTestStepBase::TestGetPixelFormatCompatibilityGuaranteesL() sl@0: { sl@0: CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource, ETrue, KSgScreenIdAny); sl@0: CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); sl@0: CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); sl@0: CheckPixelFormatPresent(EUidPixelFormatRGB_565); sl@0: sl@0: CallGetPixelFormatsL(ESgCpuAccessReadWrite, ESgUsageDirectGdiSource, ETrue, KSgScreenIdMain); sl@0: CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); sl@0: CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); sl@0: CheckPixelFormatPresent(EUidPixelFormatRGB_565); sl@0: sl@0: CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageDirectGdiTarget, ETrue, KSgScreenIdMain); sl@0: CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); sl@0: CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); sl@0: sl@0: CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenGlesTarget, ETrue, KSgScreenIdMain); sl@0: CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); sl@0: CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); sl@0: sl@0: CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenVgTarget, ETrue, KSgScreenIdMain); sl@0: CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); sl@0: CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); sl@0: sl@0: CallGetPixelFormatsL(ESgCpuAccessNone, ESgUsageDirectGdiSource|ESgUsageOpenGles2Target, ETrue, KSgScreenIdMain); sl@0: CheckPixelFormatPresent(EUidPixelFormatARGB_8888_PRE); sl@0: CheckPixelFormatPresent(EUidPixelFormatXRGB_8888); sl@0: } sl@0: sl@0: /** sl@0: Helper function to check if a certain pixel format is present sl@0: in the returned pixel formats array. sl@0: @param aPixelFormat The pixelformat to check sl@0: */ sl@0: void CTSgTestStepBase::CheckPixelFormatPresent(TUidPixelFormat aPixelFormat) sl@0: { sl@0: for(TInt i=0; iiTestCase; sl@0: sl@0: RSgImage image; sl@0: RSgDrawable drawable; sl@0: TSgImageInfo info1; sl@0: TSgImageInfo info2; sl@0: TSgDrawableId id; sl@0: const TAny* dataAddressRead; sl@0: TAny* dataAddressWrite; sl@0: TInt dataStride; sl@0: TSgDrawableId fakeid = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; sl@0: sl@0: //test cases without the need of an initialised driver sl@0: switch (testcase) sl@0: { sl@0: case ESgresSecondThreadPanicResourceCountNoDriver: sl@0: { sl@0: SgDriver::ResourceCount(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicAllocMarkStartNoDriver: sl@0: { sl@0: SgDriver::AllocMarkStart(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicAllocMarkEndNoDriver: sl@0: { sl@0: SgDriver::AllocMarkEnd(0); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicSetAllocFailNoDriver: sl@0: { sl@0: SgDriver::SetAllocFail(RAllocator::EFailNext, 1); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicDrawableOpenNoDriver: sl@0: { sl@0: drawable.Open(KSgNullDrawableId); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageOpenNoDriver1: sl@0: { sl@0: image.Open(KSgNullDrawableId); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageOpenNoDriver2: sl@0: { sl@0: image.Open(KSgNullDrawableId, ESgDoNotRestrictUsage); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCreateNoDriver1: sl@0: { sl@0: image.Create(info1, NULL, 0); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCreateNoDriver2: sl@0: { sl@0: RSgImage tempImage; sl@0: image.Create(info1, tempImage); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageGetPixelFormatsNoDriver: sl@0: { sl@0: TInt count = 0; sl@0: RSgImage::GetPixelFormats(info1, NULL, count); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionCreateNoDriver1: sl@0: { sl@0: RSgImageCollection c; sl@0: c.Create(info1, 0); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionCreateNoDriver2: sl@0: { sl@0: RSgImageCollection c; sl@0: c.Create(NULL, 0, NULL, 0); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: } sl@0: sl@0: sl@0: //open driver sl@0: TInt ret = SgDriver::Open(); sl@0: if(KErrNoMemory == ret) sl@0: { sl@0: sem.Close(); sl@0: return KErrNoMemory; sl@0: } sl@0: if(KErrNone == ret) sl@0: { sl@0: switch (testcase) sl@0: { sl@0: case ESgresSecondThreadOpenImage: sl@0: { sl@0: TInt err = image.Open(((TSgresTestInfo*)aInfo)->iDrawableId); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrNone == err) sl@0: { sl@0: result |= EFirstTestPassed; sl@0: } sl@0: if(KErrNone == image.GetInfo(info2)) sl@0: { sl@0: result |= ESecondTestPassed; sl@0: } sl@0: info1 = ((TSgresTestInfo*)aInfo)->iImageInfo; sl@0: if(CompareInfos(info1, info2)) sl@0: { sl@0: result |= EThirdTestPassed; sl@0: } sl@0: id = image.Id(); sl@0: if(id != KSgNullDrawableId) sl@0: { sl@0: result |= EFourthTestPassed; sl@0: } sl@0: if(id == ((TSgresTestInfo*)aInfo)->iDrawableId) sl@0: { sl@0: result |= EFifthTestPassed; sl@0: } sl@0: } sl@0: break; sl@0: case ESgresSecondThreadOpenDrawable: sl@0: { sl@0: TInt err = drawable.Open(((TSgresTestInfo*)aInfo)->iDrawableId); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrNone == err) sl@0: { sl@0: result |= EFirstTestPassed; sl@0: } sl@0: id = drawable.Id(); sl@0: if(id != KSgNullDrawableId) sl@0: { sl@0: result |= ESecondTestPassed; sl@0: } sl@0: if(id == ((TSgresTestInfo*)aInfo)->iDrawableId) sl@0: { sl@0: result |= EThirdTestPassed; sl@0: } sl@0: } sl@0: break; sl@0: case ESgresSecondThreadOpenImageInvalid: sl@0: { sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(8, 8); sl@0: info.iUsage = ESgUsageDirectGdiSource; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iCpuAccess = ESgCpuAccessReadWrite; sl@0: sl@0: TInt err = image.Create(info, KImageData, 16); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrNone == err) sl@0: { sl@0: result |= EFirstTestPassed; sl@0: } sl@0: sl@0: // non-empty handle sl@0: id = ((TSgresTestInfo*)aInfo)->iDrawableId; sl@0: err = image.Open(id); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrInUse == err) sl@0: { sl@0: result |= ESecondTestPassed; sl@0: } sl@0: image.Close(); sl@0: sl@0: // null drawable id sl@0: err = image.Open(KSgNullDrawableId); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrArgument == err) sl@0: { sl@0: result |= EThirdTestPassed; sl@0: } sl@0: image.Close(); sl@0: sl@0: // non-existing drawable id sl@0: err = image.Open(fakeid); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrNotFound == err) sl@0: { sl@0: result |= EFourthTestPassed; sl@0: } sl@0: image.Close(); sl@0: sl@0: // open a non-sharable image sl@0: err = image.Open(id); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrNone == err) sl@0: { sl@0: result |= EFifthTestPassed; sl@0: } sl@0: image.Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadOpenDrawableInvalid: sl@0: // null drawable id sl@0: { sl@0: TInt err = drawable.Open(KSgNullDrawableId); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrArgument == err) sl@0: { sl@0: result |= EFirstTestPassed; sl@0: } sl@0: drawable.Close(); sl@0: sl@0: // non-existing drawable id sl@0: err = drawable.Open(fakeid); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: sl@0: if(KErrNotFound == err) sl@0: { sl@0: result |= ESecondTestPassed; sl@0: } sl@0: drawable.Close(); sl@0: sl@0: // open a non-sharable image - should succeed sl@0: id = ((TSgresTestInfo*)aInfo)->iDrawableId; sl@0: err = drawable.Open(id); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrNone == err) sl@0: { sl@0: result |= EThirdTestPassed; sl@0: } sl@0: sl@0: // non-empty handle sl@0: if(KErrInUse == drawable.Open(id)) sl@0: { sl@0: result |= EFourthTestPassed; sl@0: } sl@0: drawable.Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadMapImage: sl@0: { sl@0: id = ((TSgresTestInfo*)aInfo)->iDrawableId; sl@0: TInt err = image.Open(id); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrNone == err) sl@0: { sl@0: result |= EFirstTestPassed; sl@0: } sl@0: if(KErrNone == image.MapReadOnly(dataAddressRead, dataStride)) sl@0: { sl@0: result |= ESecondTestPassed; sl@0: } sl@0: if(KErrNone == image.Unmap()) sl@0: { sl@0: result |= EThirdTestPassed; sl@0: } sl@0: if(KErrNone == image.MapWriteOnly(dataAddressWrite, dataStride)) sl@0: { sl@0: result |= EFourthTestPassed; sl@0: } sl@0: if(KErrNone == image.Unmap()) sl@0: { sl@0: result |= EFifthTestPassed; sl@0: } sl@0: if(KErrNone == image.MapReadWrite(dataAddressWrite, dataStride)) sl@0: { sl@0: result |= ESixthTestPassed; sl@0: } sl@0: if(KErrNone == image.Unmap()) sl@0: { sl@0: result |= ESeventhTestPassed; sl@0: } sl@0: } sl@0: break; sl@0: case ESgresSecondThreadUnmapImage: sl@0: { sl@0: id = ((TSgresTestInfo*)aInfo)->iDrawableId; sl@0: TInt err = image.Open(id); sl@0: if(KErrNoMemory == err) sl@0: { sl@0: result = KErrNoMemory; sl@0: break; sl@0: } sl@0: if(KErrNone == err) sl@0: { sl@0: result |= EFirstTestPassed; sl@0: } sl@0: if(KErrNone == image.Unmap()) sl@0: { sl@0: result |= ESecondTestPassed; sl@0: } sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageGetInterfaceInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: MSgImage_Sw* swInterface = NULL; sl@0: ret = anotherImage.GetInterface(swInterface); //should panic with SGRES 2 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageGetInterfaceNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: SgDriver::Close(); sl@0: MSgImage_Sw* swInterface = NULL; sl@0: anotherImage.GetInterface(swInterface); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCloseInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: anotherImage.Close(); //should panic with SGRES 2 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCloseNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: SgDriver::Close(); sl@0: anotherImage.Close(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageIdInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: anotherImage.Id(); //should panic with SGRES 2 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageIdNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: SgDriver::Close(); sl@0: anotherImage.Id(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageDrawableTypeInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: anotherImage.DrawableType(); //should panic with SGRES 2 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageDrawableTypeNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: SgDriver::Close(); sl@0: anotherImage.DrawableType(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCreateInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: RSgImage newImage; sl@0: TSgImageInfo info; sl@0: image.GetInfo(info); sl@0: newImage.Create(info, anotherImage); //should panic with SGRES 3 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageGetInfoInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: TSgImageInfo anotherInfo; sl@0: anotherImage.GetInfo(anotherInfo); //should panic with SGRES 3 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageGetInfoNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: SgDriver::Close(); sl@0: TSgImageInfo anotherInfo; sl@0: anotherImage.GetInfo(anotherInfo); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageMapReadOnlyInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: anotherImage.MapReadOnly(dataAddressRead, dataStride); //should panic with SGRES 3 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageMapReadOnlyNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: SgDriver::Close(); sl@0: anotherImage.MapReadOnly(dataAddressRead, dataStride); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageMapWriteOnlyInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: anotherImage.MapWriteOnly(dataAddressWrite, dataStride); //should panic with SGRES 3 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageMapWriteOnlyNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: SgDriver::Close(); sl@0: anotherImage.MapWriteOnly(dataAddressWrite, dataStride); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageMapReadWriteInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: anotherImage.MapReadWrite(dataAddressWrite, dataStride); //should panic with SGRES 3 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageMapReadWriteNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: SgDriver::Close(); sl@0: anotherImage.MapReadWrite(dataAddressWrite, dataStride); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageUnmapInvalidHandle: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: sl@0: anotherImage.Unmap(); //should panic with SGRES 3 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageUnmapNoDriver: sl@0: { sl@0: RSgImage image; sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: RSgImage anotherImage; sl@0: anotherImage = image; sl@0: image.Close(); sl@0: SgDriver::Close(); sl@0: anotherImage.Unmap(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionCloseInvalidHandle: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: anotherCollection.Close(); //should panic with SGRES 4 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionCloseNoDriver: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: SgDriver::Close(); sl@0: anotherCollection.Close(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionSurfaceIdInvalidHandle: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: anotherCollection.SurfaceId(); //should panic with SGRES 4 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionSurfaceIdNoDriver: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: SgDriver::Close(); sl@0: anotherCollection.SurfaceId(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionGetInfoInvalidHandle: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: TSgImageInfo anotherInfo; sl@0: anotherCollection.GetInfo(anotherInfo); //should panic with SGRES 4 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionGetInfoNoDriver: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: TSgImageInfo anotherInfo; sl@0: SgDriver::Close(); sl@0: anotherCollection.GetInfo(anotherInfo); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionCountInvalidHandle: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: anotherCollection.Count(); //should panic with SGRES 4 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionCountNoDriver: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: SgDriver::Close(); sl@0: anotherCollection.Count(); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionOpenImageInvalidHandle: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: RSgImage image; sl@0: anotherCollection.OpenImage(0, image); //should panic with SGRES 4 sl@0: SgDriver::Close(); sl@0: } sl@0: break; sl@0: case ESgresSecondThreadPanicImageCollectionOpenImageNoDriver: sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt ret = CreateImageCollectionWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, EFalse, ESgCpuAccessReadWrite, collection); sl@0: if(KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: sl@0: RSgImageCollection anotherCollection; sl@0: anotherCollection = collection; sl@0: collection.Close(); sl@0: RSgImage image; sl@0: SgDriver::Close(); sl@0: anotherCollection.OpenImage(0, image); // should panic with SGRES 5 sl@0: } sl@0: break; sl@0: case ESgresMultipleThreadStressTest: sl@0: { sl@0: for (TInt i = 0; i < 1000 && result == KErrNone; ++i) sl@0: { sl@0: TInt ret = CreateImageWithParameters(8, 8, EUidPixelFormatRGB_565, ESgUsageDirectGdiSource, ETrue, ESgCpuAccessReadWrite, image); sl@0: if (KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: const TInt KMaxOpenCount = 100; sl@0: RSgImage images[KMaxOpenCount]; sl@0: TInt count = Math::Random() % KMaxOpenCount; sl@0: for (TInt k = 0; k < count; ++k) sl@0: { sl@0: ret = images[k].Open(((TSgresTestInfo*)aInfo)->iDrawableId); sl@0: if (KErrNone != ret) sl@0: { sl@0: result = ret; sl@0: break; sl@0: } sl@0: } sl@0: image.Close(); sl@0: for (TInt k = 0; k < count; ++k) sl@0: { sl@0: images[k].Close(); sl@0: } sl@0: } sl@0: } sl@0: break; sl@0: }; sl@0: } sl@0: image.Close(); sl@0: drawable.Close(); sl@0: SgDriver::Close(); sl@0: if (KErrNone == openSem) sl@0: { sl@0: sem.Signal(); sl@0: } sl@0: __UHEAP_MARKEND; sl@0: sem.Close(); sl@0: TInt procHandles2 =0; sl@0: TInt threadHandles2=0; sl@0: RThread().HandleCount(procHandles2,threadHandles2); sl@0: if (threadHandles1 != threadHandles2) sl@0: { sl@0: result = KErrGeneral; // Thread-owned handles not closed sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: /** sl@0: Static function used by the cleanup item to close the driver. sl@0: */ sl@0: void CTSgTestStepBase::CloseDriverWhenLeave(TAny* /*aInfo*/) sl@0: { sl@0: SgDriver::Close(); sl@0: } sl@0: sl@0: /** sl@0: Checks the function for the passed error codes and logs an error if the codes do not match. sl@0: If the test is running out of memory tests, KErrNoMemory is also an expected error code and sl@0: the function would just leave with KErrNoMemory in that case. sl@0: sl@0: @param aExpectedErrorCode The expected error code to check against sl@0: @param aActualErrorCode The actual error code sl@0: @param aFile The filename to use when reporting the error sl@0: @param aLine The line number to use when reporting the error sl@0: */ sl@0: void CTSgTestStepBase::CheckErrorL(TInt aExpectedErrorCode, TInt aActualErrorCode, const TText8* aFile, TInt aLine) sl@0: { sl@0: if(iRunningOomTests && KErrNoMemory == aActualErrorCode) sl@0: { sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: TESTWITHFILENAMEANDLINENUMBERL(aExpectedErrorCode == aActualErrorCode, aFile, aLine); sl@0: } sl@0: sl@0: /** sl@0: Out of memory tests. sl@0: */ sl@0: void CTSgTestStepBase::TestOOM() sl@0: { sl@0: SgDriver::Open(); sl@0: TInt err = KErrNone; sl@0: TInt tryCount = 0; sl@0: iRunningOomTests = ETrue; sl@0: do sl@0: { sl@0: SgDriver::SetAllocFail(RAllocator::EFailNext, ++tryCount); sl@0: TRAP(err, DoMemoryTestsL()); sl@0: } sl@0: while(err == KErrNoMemory); sl@0: sl@0: SgDriver::SetAllocFail(RAllocator::ENone, 0); sl@0: iRunningOomTests = EFalse; sl@0: SgDriver::Close(); sl@0: INFO_PRINTF2(_L("- server succeeded at private heap failure rate of %i\n"), tryCount); sl@0: } sl@0: sl@0: /** sl@0: Specifies which functions to run in out of memory conditions. sl@0: To be overridden by the derived test classes. sl@0: */ sl@0: void CTSgTestStepBase::DoMemoryTestsL() sl@0: { sl@0: }