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 "tsgimagegeneric.h" sl@0: #include sl@0: #include sl@0: sl@0: CTSgImageGeneric::CTSgImageGeneric() sl@0: { sl@0: INFO_PRINTF1(_L("Graphics resource component test - RSgImage Generic Tests.\r\n")); sl@0: } sl@0: sl@0: CTSgImageGeneric::~CTSgImageGeneric() sl@0: { sl@0: TInt count = iTestImages.Count(); sl@0: for(TInt i=0; i 1); sl@0: sl@0: //array length bigger than available pixel formats sl@0: TInt count = numPixelFormats + 10; sl@0: TUidPixelFormat* pixelFormatArray = new(ELeave) TUidPixelFormat[count]; sl@0: CleanupArrayDeletePushL(pixelFormatArray); sl@0: CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__); sl@0: TEST(count == numPixelFormats); sl@0: sl@0: info.iScreenId = -1; sl@0: CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__); sl@0: TEST(count == numPixelFormats); sl@0: sl@0: info.iScreenId = 0; sl@0: CleanupStack::PopAndDestroy(pixelFormatArray); sl@0: //array length is equal to the supported pixel formats sl@0: count = numPixelFormats; sl@0: pixelFormatArray = new(ELeave) TUidPixelFormat[count]; sl@0: CleanupArrayDeletePushL(pixelFormatArray); sl@0: sl@0: CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info, pixelFormatArray, count), (TText8*)__FILE__, __LINE__); sl@0: TEST(count == numPixelFormats); sl@0: sl@0: CleanupStack::PopAndDestroy(pixelFormatArray); sl@0: //array length is smaller than the supported pixel formats sl@0: count = numPixelFormats - 1; sl@0: pixelFormatArray = new(ELeave) TUidPixelFormat[count]; sl@0: CleanupArrayDeletePushL(pixelFormatArray); sl@0: TEST(KErrOverflow == RSgImage::GetPixelFormats(info, pixelFormatArray, count)); sl@0: TEST(count == numPixelFormats); sl@0: CleanupStack::PopAndDestroy(pixelFormatArray); sl@0: sl@0: //check all the pixel formats returned are in the common compatibility guarantees table sl@0: TestGetPixelFormatCompatibilityGuaranteesL(); sl@0: sl@0: //reset the array used by the GetPixelFormats function to prevent memory leaks sl@0: info.iCpuAccess = ESgCpuAccessReadWrite; sl@0: info.iScreenId = 100; sl@0: TEST(KErrNone == RSgImage::GetPixelFormats(info, NULL, count)); sl@0: TEST(count == 0); sl@0: sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0004 sl@0: @SYMTestCaseDesc Creates an uninitialised image. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n sl@0: RSgImage::IsNull() sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure an uninitialised image can be created. sl@0: @SYMTestActions Initialise the graphics resource component. Construct well-defined sl@0: TSgImageInfo objects that work on all platforms. Create an image sl@0: with a NULL base address for each of the TSgImageInfo object. sl@0: @SYMTestExpectedResults The function should return KErrNone in all cases. The created images sl@0: are uninitialised. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestCreateImageUninitializedL() sl@0: { sl@0: TestOpenDriverL(); sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(100, 100); sl@0: info.iUsage = ESgUsageDirectGdiTarget; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: sl@0: RSgImage image; sl@0: CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0005 sl@0: @SYMTestCaseDesc Creates an image from a block of memory. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n sl@0: RSgImage::IsNull() sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure images can be created from a block of memory. sl@0: @SYMTestActions Initialise the graphics resource component. Construct well-defined sl@0: TSgImageInfo objects that work on all platforms. Create a block of sl@0: memory with or without initialised data. Then create an image with sl@0: the starting address of that memory. sl@0: @SYMTestExpectedResults The function should return KErrNone in all cases. The user data starting sl@0: at address aDataAddress will be populated into the new image. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestCreateImageL() sl@0: { sl@0: TestOpenDriverL(); sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(8, 8); sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iUsage = ESgUsageDirectGdiSource; sl@0: info.iShareable = ETrue; sl@0: sl@0: RSgImage image; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: CleanupStack::PopAndDestroy(); sl@0: #ifdef __WINS__ sl@0: //create an image with usage set to screen source sl@0: TSize screenSize; sl@0: if(HAL::Get(info.iScreenId, HALData::EDisplayXPixels, screenSize.iWidth) == KErrNone sl@0: && HAL::Get(info.iScreenId, HALData::EDisplayYPixels, screenSize.iHeight) == KErrNone) sl@0: { sl@0: info.iUsage = ESgUsageScreenSource; sl@0: info.iScreenId = KSgScreenIdMain; sl@0: info.iSizeInPixels = TSize(screenSize.iWidth, screenSize.iHeight); sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: info.iSizeInPixels = TSize(screenSize.iHeight, screenSize.iWidth); sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: #endif sl@0: //create an image with some user attributes sl@0: TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}}; sl@0: info.iUserAttributes = testAttributes; sl@0: info.iUserAttributeCount = 2; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0006 sl@0: @SYMTestCaseDesc Creates an image from an existing image. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9192 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure images can be created from existing images. sl@0: @SYMTestActions Initialise the graphics resource component. Create an image. Create another sl@0: image with the attributes of this image as the TSgImageInfo. sl@0: @SYMTestExpectedResults The function should return KErrNone. The new image should be identical to sl@0: the old one. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestCreateImageFromExistingImageL() sl@0: { sl@0: RSgImage image1; sl@0: RSgImage image2; sl@0: TSgImageInfo info; sl@0: sl@0: TestOpenDriverL(); sl@0: CreateImageL(image1); sl@0: CleanupClosePushL(image1); sl@0: TEST(KErrNone == image1.GetInfo(info)); sl@0: CheckErrorL(KErrNone, image2.Create(info, image1), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image2); sl@0: TSgImageInfo info2; sl@0: TEST(KErrNone == image2.GetInfo(info2)); sl@0: TEST(CompareInfos(info, info2)); sl@0: CleanupStack::PopAndDestroy(2); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0007 sl@0: @SYMTestCaseDesc Calls GetInfo on an image. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::GetInfo(TSgImageInfo&) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure the information about the image is correct. sl@0: @SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object sl@0: and Initialise all the member variables. Create images without and with sl@0: user attributes. Call GetInfo() and compare the resulting TSgImageInfo objects sl@0: with the previous ones. sl@0: @SYMTestExpectedResults The function should return KErrNone. Information about the image object sl@0: is stored in the aInfo parameter. The retrieved TSgImageInfo objects should be sl@0: identical to the original ones. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestGetImageInfoL() sl@0: { sl@0: TestOpenDriverL(); sl@0: TSgImageInfo info; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iSizeInPixels = TSize(100, 100); sl@0: info.iUsage = ESgUsageDirectGdiTarget; sl@0: sl@0: RSgImage image; sl@0: CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: sl@0: TSgImageInfo info2; sl@0: TEST(KErrNone == image.GetInfo(info2)); sl@0: TEST(CompareInfos(info, info2)); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: //get info of image with user attributes sl@0: TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}}; sl@0: info.iUserAttributes = testAttributes; sl@0: info.iUserAttributeCount = 2; sl@0: CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: TSgImageInfo info3; sl@0: TSgUserAttribute testAttributes2[2]; sl@0: testAttributes2[0].iUid = TUid::Uid(0x00008888); sl@0: testAttributes2[1].iUid = TUid::Uid(0x00009999); sl@0: info3.iUserAttributes = testAttributes2; sl@0: info3.iUserAttributeCount = 2; sl@0: TEST(KErrNone == image.GetInfo(info3)); sl@0: TEST(CompareInfos(info, info3)); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: info.iShareable = ETrue; sl@0: CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: TEST(KErrNone == image.GetInfo(info3)); sl@0: TEST(CompareInfos(info, info3)); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0008 sl@0: @SYMTestCaseDesc Retrieves drawable id and drawable type of an image. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Id()\n sl@0: RSgImage::DrawableType() sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure the globally unique drawable id of the image can be retrieved. sl@0: @SYMTestActions Initialise the graphics resource component. Create an image. Call sl@0: Id() to retrieve its drawable id. sl@0: @SYMTestExpectedResults A valid drawable id should be successfully returned. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestGetImageDrawableIdL() sl@0: { sl@0: RSgImage image; sl@0: TEST(KNullUid == image.DrawableType()); sl@0: TSgDrawableId id = image.Id(); sl@0: TEST(id == KSgNullDrawableId); sl@0: TestOpenDriverL(); sl@0: CreateImageL(image); sl@0: CleanupClosePushL(image); sl@0: id = image.Id(); sl@0: TEST(id != KSgNullDrawableId); sl@0: TEST(KSgImageTypeUid == image.DrawableType()); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0009 sl@0: @SYMTestCaseDesc Maps and unmaps an image from its creator process. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::MapReadOnly(const TAny*&, TInt&) const\n sl@0: RSgImage::MapWriteOnly(TAny*&, TInt&)\n sl@0: RSgImage::MapReadWrite(TAny*&, TInt&)\n sl@0: RSgImage::Unmap() sl@0: by its creator process. sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure an image can be successfully mapped and unmapped sl@0: @SYMTestActions Initialise the graphics resource component. Create mappable images sl@0: with different TSgImageInfo values. Call different map functions the Unmap() sl@0: function on each of them. sl@0: @SYMTestExpectedResults All the functions should return KErrNone. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestMapImageL() sl@0: { sl@0: TestOpenDriverL(); sl@0: RSgImage image; sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(8, 8); sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iUsage = ESgUsageDirectGdiSource; sl@0: info.iCpuAccess = ESgCpuAccessReadOnly; sl@0: sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: sl@0: //test MapReadOnly sl@0: const TAny* dataAddress; sl@0: TInt dataStride; sl@0: TInt mapResult = image.MapReadOnly(dataAddress, dataStride); sl@0: TEST(KErrNone == mapResult); sl@0: if(KErrNone == mapResult) sl@0: { sl@0: for (TInt y = 0; y < 8; ++y) sl@0: for (TInt x = 0; x < 8; ++x) sl@0: { sl@0: TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress, sizeof(TUint16) * x + dataStride * y); sl@0: if (pixelValue != 0x7E0) sl@0: { sl@0: TEST(EFalse); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: TEST(KErrNone == image.Unmap()); sl@0: CleanupStack::PopAndDestroy(&image); sl@0: sl@0: //test MapWriteOnly sl@0: TAny* dataAddress1; sl@0: sl@0: info.iCpuAccess = ESgCpuAccessWriteOnly; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: mapResult = image.MapWriteOnly(dataAddress1, dataStride); sl@0: TEST(KErrNone == mapResult); sl@0: //change the second line to red sl@0: if(KErrNone == mapResult) sl@0: { sl@0: for(TInt x = 0; x < 8; ++x) sl@0: { sl@0: *(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x + dataStride * 1) = 0xF800; sl@0: } sl@0: } sl@0: TEST(KErrNone == image.Unmap()); sl@0: sl@0: //check if the modification is successful sl@0: //create another image from the existing one and map it as read only sl@0: info.iCpuAccess = ESgCpuAccessReadOnly; sl@0: RSgImage image1; sl@0: CheckErrorL(KErrNone, image1.Create(info, image), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image1); sl@0: mapResult = image1.MapReadOnly(dataAddress, dataStride); sl@0: TEST(mapResult == KErrNone); sl@0: if(mapResult == KErrNone) sl@0: { sl@0: for(TInt x = 0; x < 8; ++x) sl@0: { sl@0: TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress, sizeof(TUint16) * x + dataStride * 1); sl@0: if(pixelValue != 0xF800) sl@0: { sl@0: TEST(EFalse); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: TEST(KErrNone == image1.Unmap()); sl@0: CleanupStack::PopAndDestroy(2, &image); sl@0: sl@0: //test MapReadWrite sl@0: info.iCpuAccess = ESgCpuAccessReadWrite; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: mapResult = image.MapReadWrite(dataAddress1, dataStride); sl@0: TEST(KErrNone == mapResult); sl@0: sl@0: if(KErrNone == mapResult) sl@0: { sl@0: //modify the image, set first line to blue sl@0: for(TInt x = 0; x < 8; ++x) sl@0: { sl@0: *(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x) = 0x1F; sl@0: } sl@0: sl@0: //check the modification sl@0: for(TInt x = 0; x < 8; ++x) sl@0: { sl@0: TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddress1, sizeof(TUint16) * x); sl@0: if(pixelValue != 0x1F) sl@0: { sl@0: TEST(EFalse); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: TEST(KErrNone == image.Unmap()); sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0010 sl@0: @SYMTestCaseDesc Opens a handle to an image in both the current process and another process. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Open(const TSgDrawableId&) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure image can be opened in both a second thread in the current sl@0: process and another process. sl@0: @SYMTestActions Initialise the graphics resource component. Create a shareable image and sl@0: a non-shareable image. Open() the image in the second thread in the current sl@0: process and in another process. sl@0: Check various image attributes. sl@0: @SYMTestExpectedResults The function must return KErrNone in both cases. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestOpenImageL() sl@0: { sl@0: TestOpenDriverL(); sl@0: sl@0: //shareable image sl@0: RSgImage image1; sl@0: TSgImageInfo info1; sl@0: info1.iSizeInPixels = TSize(8, 8); sl@0: info1.iUsage = ESgUsageDirectGdiSource; sl@0: info1.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info1.iCpuAccess = ESgCpuAccessReadWrite; sl@0: info1.iShareable = ETrue; sl@0: CheckErrorL(KErrNone, image1.Create(info1, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image1); sl@0: sl@0: //non-shareable image sl@0: RSgImage image2; sl@0: TSgImageInfo info2; sl@0: info2.iSizeInPixels = TSize(8, 8); sl@0: info2.iUsage = ESgUsageDirectGdiSource; sl@0: info2.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info2.iCpuAccess = ESgCpuAccessReadWrite; sl@0: info2.iShareable = EFalse; sl@0: CheckErrorL(KErrNone, image2.Create(info2, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image2); sl@0: sl@0: const TSgDrawableId id1 = image1.Id(); sl@0: const TSgDrawableId id2 = image2.Id(); sl@0: sl@0: //opening image in the current thread sl@0: RSgImage image3; sl@0: TEST(KErrNone == image3.Open(id1)); sl@0: image3.Close(); sl@0: TEST(KErrNone == image3.Open(id2)); sl@0: image3.Close(); sl@0: sl@0: //opening image in a second thread in the current process sl@0: TSgresTestInfo threadInfo = {id1, info1, 0, ESgresSecondThreadOpenImage}; sl@0: TInt testResult = CreateSecondThreadAndDoTestL(threadInfo); sl@0: // Test the results from the second thread sl@0: User::LeaveIfError(testResult); sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: TEST(testResult & EThirdTestPassed); sl@0: TEST(testResult & EFourthTestPassed); sl@0: TEST(testResult & EFifthTestPassed); sl@0: sl@0: threadInfo.iDrawableId = id2; sl@0: threadInfo.iImageInfo = info2; sl@0: testResult = CreateSecondThreadAndDoTestL(threadInfo); sl@0: // Test the results from the second thread sl@0: User::LeaveIfError(testResult); sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: TEST(testResult & EThirdTestPassed); sl@0: TEST(testResult & EFourthTestPassed); sl@0: TEST(testResult & EFifthTestPassed); sl@0: sl@0: //opening image in a second process sl@0: TSgresTestInfo processInfo = {id1, info1, 0, ESgresSecondProcessOpenImage}; sl@0: testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo); sl@0: User::LeaveIfError(testResult); sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: TEST(testResult & EThirdTestPassed); sl@0: TEST(testResult & EFourthTestPassed); sl@0: sl@0: CleanupStack::PopAndDestroy(2, &image1); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: class MFake sl@0: { sl@0: public: sl@0: enum { EInterfaceUid = 0x88888888 }; sl@0: }; sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0011 sl@0: @SYMTestCaseDesc Opens a handle to an image with mode flags. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Open(const TSgDrawableId&, TUint32) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure image can be opened with mode flags. sl@0: @SYMTestActions Initialise the graphics resource component. Create an image and sl@0: call Open() on the image with flag ESgDoNotRestrictUsage. Call sl@0: GetInfo() on the opened image and check the usage bit. Declare another sl@0: image object and call Open() on it with the Id of the previously sl@0: opened handle and without mode flags. Call GetInfo() on this image sl@0: and check the usage bit. sl@0: @SYMTestExpectedResults Both infos should contain all the possible usages supported by sl@0: the underlying implementation. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestOpenImageInternalL() sl@0: { sl@0: TestOpenDriverL(); sl@0: sl@0: //shareable image sl@0: RSgImage shareableImage; sl@0: TSgImageInfo shareableInfo; sl@0: shareableInfo.iSizeInPixels = TSize(8, 8); sl@0: shareableInfo.iUsage = ESgUsageDirectGdiSource; sl@0: shareableInfo.iPixelFormat = EUidPixelFormatRGB_565; sl@0: shareableInfo.iCpuAccess = ESgCpuAccessReadWrite; sl@0: shareableInfo.iShareable = ETrue; sl@0: CheckErrorL(KErrNone, shareableImage.Create(shareableInfo, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(shareableImage); sl@0: sl@0: RSgImage image1; sl@0: CheckErrorL(KErrNone, image1.Open(shareableImage.Id(), ESgDoNotRestrictUsage), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image1); sl@0: TSgImageInfo info1; sl@0: image1.GetInfo(info1); sl@0: TEST(ESgUsageDirectGdiSource | info1.iUsage); sl@0: TEST(ESgUsageCompositionSource | info1.iUsage); sl@0: TEST(ESgUsageOpenGlesTexture2D | info1.iUsage); sl@0: TEST(ESgUsageOpenGles2Texture2D | info1.iUsage); sl@0: TEST(ESgUsageOpenVgImage | info1.iUsage); sl@0: sl@0: RSgImage image2; sl@0: CheckErrorL(KErrNone, image2.Open(image1.Id()), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image2); sl@0: TSgImageInfo info2; sl@0: image2.GetInfo(info2); sl@0: TEST(ESgUsageDirectGdiSource | info2.iUsage); sl@0: TEST(ESgUsageCompositionSource | info2.iUsage); sl@0: TEST(ESgUsageOpenGlesTexture2D | info2.iUsage); sl@0: TEST(ESgUsageOpenGles2Texture2D | info2.iUsage); sl@0: TEST(ESgUsageOpenVgImage | info2.iUsage); sl@0: sl@0: //non-shareable image sl@0: RSgImage nonshareableImage; sl@0: TSgImageInfo nonshareableInfo; sl@0: nonshareableInfo.iSizeInPixels = TSize(8, 8); sl@0: nonshareableInfo.iUsage = ESgUsageDirectGdiSource; sl@0: nonshareableInfo.iPixelFormat = EUidPixelFormatRGB_565; sl@0: nonshareableInfo.iCpuAccess = ESgCpuAccessReadWrite; sl@0: nonshareableInfo.iShareable = EFalse; sl@0: CheckErrorL(KErrNone, nonshareableImage.Create(nonshareableInfo, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(nonshareableImage); sl@0: sl@0: RSgImage image3; sl@0: CheckErrorL(KErrNone, image3.Open(nonshareableImage.Id(), ESgDoNotRestrictUsage), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image3); sl@0: TSgImageInfo info3; sl@0: image3.GetInfo(info3); sl@0: TEST(ESgUsageDirectGdiSource | info3.iUsage); sl@0: TEST(ESgUsageCompositionSource | info3.iUsage); sl@0: TEST(ESgUsageOpenGlesTexture2D | info3.iUsage); sl@0: TEST(ESgUsageOpenGles2Texture2D | info3.iUsage); sl@0: TEST(ESgUsageOpenVgImage | info3.iUsage); sl@0: sl@0: RSgImage image4; sl@0: CheckErrorL(KErrNone, image4.Open(image3.Id()), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image4); sl@0: TSgImageInfo info4; sl@0: image4.GetInfo(info4); sl@0: TEST(ESgUsageDirectGdiSource | info4.iUsage); sl@0: TEST(ESgUsageCompositionSource | info4.iUsage); sl@0: TEST(ESgUsageOpenGlesTexture2D | info4.iUsage); sl@0: TEST(ESgUsageOpenGles2Texture2D | info4.iUsage); sl@0: TEST(ESgUsageOpenVgImage | info4.iUsage); sl@0: sl@0: CleanupStack::PopAndDestroy(6, &shareableImage); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0044 sl@0: @SYMTestCaseDesc Gets the interfaces implemented by CSgImageImpl class. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n sl@0: RSgImage::GetInterface() sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure the extension interfaces supported by RSgImage can be sl@0: returned. sl@0: @SYMTestActions Initialise the graphics resource component. Create an image. Call sl@0: GetInterface() to return the MSgImage_Sw and MSgImage_Chunk interfaces. sl@0: Perform various operations on the interfaces. Declare a fake interface sl@0: MFake and call GetInterface() on the image handle. sl@0: @SYMTestExpectedResults The operations on the MSgImage_Sw and MSgImage_Chunk interfaces should sl@0: succeed. Trying to get the MFake interface should return KErrExtensionNotSupported. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestGetInterfaceL() sl@0: { sl@0: TestOpenDriverL(); 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: RSgImage image; sl@0: MSgImage_Sw* swInterface = NULL; sl@0: TEST(KErrBadHandle == image.GetInterface(swInterface)); sl@0: sl@0: CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: sl@0: // check TSgDrawableId is not NULL sl@0: TSgDrawableId id = image.Id(); sl@0: TEST(KSgNullDrawableId != id); sl@0: sl@0: TAny* dataAddress1 = NULL; sl@0: TInt dataStride1 = 0; sl@0: TInt result1 = image.GetInterface(swInterface); sl@0: TEST(KErrNone == result1); sl@0: if(KErrNone == result1) sl@0: { sl@0: // Fill the image with 0xF0 sl@0: TInt sizeInBytes = 8 * 8 * 2; sl@0: TESTL(swInterface->BeginDataAccess(ESgCpuAccessNone) == KErrArgument); sl@0: TEST(swInterface->BeginDataAccess(ESgCpuAccessWriteOnly) == KErrNone); sl@0: dataAddress1 = swInterface->DataAddress(); sl@0: dataStride1 = swInterface->DataStride(); sl@0: Mem::Fill(dataAddress1, sizeInBytes, 0xF0); sl@0: TEST(swInterface->EndDataAccess() == KErrNone); sl@0: sl@0: //Map the image as read only and check if the previous operation is successful sl@0: const TAny* dataAddressRead; sl@0: TInt dataStride2; sl@0: TInt mapResult = image.MapReadOnly(dataAddressRead, dataStride2); sl@0: TEST(KErrNone == mapResult); sl@0: TEST(dataAddress1 == dataAddressRead); sl@0: TEST(dataStride1 == dataStride2); sl@0: if(KErrNone == mapResult) sl@0: { sl@0: for (TInt y = 0; y < 8; ++y) sl@0: for (TInt x = 0; x < 8; ++x) sl@0: { sl@0: TUint16 pixelValue = *(TUint16*)PtrAdd(dataAddressRead, sizeof(TUint16) * x + dataStride2 * y); sl@0: if (pixelValue != 0xF0F0) sl@0: { sl@0: TEST(EFalse); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: TEST(KErrNone == image.Unmap()); sl@0: } sl@0: sl@0: MSgImage_Chunk* smChunk = NULL; sl@0: TInt result2 = image.GetInterface(smChunk); sl@0: TEST(KErrNone == result2); sl@0: if(KErrNone == result2) sl@0: { sl@0: TAny* address = PtrAdd(smChunk->DataChunk().Base(), smChunk->DataOffset()); sl@0: TInt datastride = smChunk->DataStride(); sl@0: if(KErrNone == result1) sl@0: { sl@0: TEST(address == dataAddress1); sl@0: TEST(datastride == dataStride1); sl@0: } sl@0: } sl@0: sl@0: //fake interface sl@0: MFake* smFake = NULL; sl@0: TEST(KErrExtensionNotSupported == image.GetInterface(smFake)); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0024 sl@0: @SYMTestCaseDesc Gets supported pixel formats with invalid parameters. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure the correct error messages are returned when user tries to sl@0: call GetPixelFormats() with invalid parameters. sl@0: @SYMTestActions Initialise the graphics resource component. Call RSgImage::GetPixelFormats with:\n sl@0: \t 1. invalid TSgImageInfo object, it could be any combinations of the following:\n sl@0: \t \t negative width or height\n sl@0: \t \t mutability incompatible with the specified CPU access and usage\n sl@0: \t \t screen id < -1\n sl@0: \t \t usage flag ESgUsageScreenSource with screen id -1\n sl@0: \t 2. invalid aCount sl@0: @SYMTestExpectedResults The function should return KErrArgument in both cases. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestGetPixelFormatsInvalidL() sl@0: { sl@0: TSgImageInfo info1; sl@0: TInt count = 0; sl@0: sl@0: TestOpenDriverL(); sl@0: //negative width sl@0: info1.iSizeInPixels = TSize(-100, 100); sl@0: TEST(KErrArgument == RSgImage::GetPixelFormats(info1, NULL, count)); sl@0: sl@0: //negative height sl@0: TSgImageInfo info2; sl@0: info2.iSizeInPixels = TSize(100, -100); sl@0: TEST(KErrArgument == RSgImage::GetPixelFormats(info2, NULL, count)); sl@0: sl@0: //invalid or non-existent screen id sl@0: TSgImageInfo info5; sl@0: info5.iSizeInPixels = TSize(8, 8); sl@0: info5.iUsage = ESgUsageScreenSource; sl@0: info5.iCpuAccess = ESgCpuAccessReadWrite; sl@0: info5.iScreenId = -2; sl@0: TEST(KErrArgument == RSgImage::GetPixelFormats(info5, NULL, count)); sl@0: info5.iScreenId = 100; sl@0: TEST(KErrNone == RSgImage::GetPixelFormats(info5, NULL, count)); sl@0: TEST(count == 0); sl@0: sl@0: //usage flag ESgUsageScreenSource with screen id -1 sl@0: TSgImageInfo info6; sl@0: info6.iSizeInPixels = TSize(8, 8); sl@0: info6.iScreenId = -1; sl@0: info6.iUsage = ESgUsageScreenSource; sl@0: TEST(KErrArgument == RSgImage::GetPixelFormats(info6, NULL, count)); sl@0: sl@0: //negative aCount sl@0: TSgImageInfo info7; sl@0: info7.iCpuAccess = ESgCpuAccessNone; sl@0: info7.iShareable = EFalse; sl@0: info7.iSizeInPixels = TSize(10, 10); sl@0: CheckErrorL(KErrNone, RSgImage::GetPixelFormats(info7, NULL, count), (TText8*)__FILE__, __LINE__); sl@0: sl@0: if(count > 0) sl@0: { sl@0: TUidPixelFormat* pixelFormatArray = new(ELeave) TUidPixelFormat[count]; sl@0: if(!pixelFormatArray) sl@0: { sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: CleanupStack::PushL(pixelFormatArray); sl@0: count = -100; sl@0: TEST(KErrArgument == RSgImage::GetPixelFormats(info7, pixelFormatArray, count)); sl@0: sl@0: CleanupStack::PopAndDestroy(pixelFormatArray); sl@0: } sl@0: sl@0: //reset the array used by the GetPixelFormats function to prevent memory leaks sl@0: TSgImageInfo info8; sl@0: info8.iSizeInPixels = TSize(10, 10); sl@0: info8.iCpuAccess = ESgCpuAccessReadWrite; sl@0: info8.iUsage = ESgUsageDirectGdiSource; sl@0: info8.iShareable = EFalse; sl@0: info8.iScreenId = 100; sl@0: TEST(KErrNone == RSgImage::GetPixelFormats(info8, NULL, count)); sl@0: TEST(count == 0); sl@0: sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0025 sl@0: @SYMTestCaseDesc Opens an image with different invalid parameters. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Open(const TSgDrawableId&) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To check correct error messages are returned when opening image with sl@0: different invalid parameters. sl@0: @SYMTestActions Initialise the graphics resource component. Construct an RSgImage object. sl@0: Call the Open() function in both the current process and another process with:\n sl@0: \t 1. a non-null RSgImage handle\n sl@0: \t 2. null drawable id\n sl@0: \t 3. fake drawable id\n sl@0: \t 4. a non-sharable RSgImage handle sl@0: Do the same tests in a second thread and a second process. sl@0: @SYMTestExpectedResults The function should return:\n sl@0: \t 1. KErrInUse\n sl@0: \t 2. KErrArgument\n sl@0: \t 3. KErrNotFound\n sl@0: \t 4. KErrNone in the same process and KErrPermissionDenied or KErrNotFound in the second process sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestOpenImageInvalidL() sl@0: { sl@0: TestOpenDriverL(); sl@0: //create a non-sharable image sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(8, 8); sl@0: info.iUsage = ESgUsageDirectGdiTarget; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iShareable = EFalse; sl@0: sl@0: RSgImage image; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: const TSgDrawableId id = image.Id(); sl@0: sl@0: //same thread sl@0: // non-empty handle sl@0: RSgImage image1; sl@0: CreateImageL(image1); sl@0: CleanupClosePushL(image1); sl@0: TEST(KErrInUse == image1.Open(id)); sl@0: image1.Close(); sl@0: sl@0: // null drawable id sl@0: CheckErrorL(KErrArgument, image1.Open(KSgNullDrawableId), (TText8*)__FILE__, __LINE__); sl@0: image1.Close(); sl@0: sl@0: // non-existing drawable id sl@0: TSgDrawableId fakeid = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; sl@0: CheckErrorL(KErrNotFound, image1.Open(fakeid), (TText8*)__FILE__, __LINE__); sl@0: image1.Close(); sl@0: sl@0: // open a non-sharable image sl@0: TEST(KErrNone == image1.Open(id)); sl@0: image1.Close(); sl@0: sl@0: //different thread in the same process sl@0: TSgresTestInfo threadInfo = {id, info, 0, ESgresSecondThreadOpenImageInvalid}; sl@0: TInt testResult = CreateSecondThreadAndDoTestL(threadInfo); sl@0: User::LeaveIfError(testResult); sl@0: // Test the results from the second thread sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: TEST(testResult & EThirdTestPassed); sl@0: TEST(testResult & EFourthTestPassed); sl@0: TEST(testResult & EFifthTestPassed); sl@0: sl@0: //different process sl@0: TSgresTestInfo processInfo = {id, info, 0, ESgresSecondProcessOpenImageInvalid}; sl@0: testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo); sl@0: User::LeaveIfError(testResult); sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: TEST(testResult & EThirdTestPassed); sl@0: TEST(testResult & EFourthTestPassed); sl@0: TEST(testResult & EFifthTestPassed); sl@0: sl@0: CleanupStack::PopAndDestroy(2); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0026 sl@0: @SYMTestCaseDesc Closes an image multiple times. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Close() sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To check calling Close() multiple times after Open() does not cause sl@0: errors or panics. sl@0: @SYMTestActions Initialise the graphics resource component. Create an image and then sl@0: call Close() three times on it. sl@0: @SYMTestExpectedResults The function should not cause any errors or panics. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestCloseImageManyTimesL() sl@0: { sl@0: TestOpenDriverL(); sl@0: RSgImage image; sl@0: CreateImageL(image); sl@0: sl@0: image.Close(); sl@0: image.Close(); sl@0: image.Close(); sl@0: sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0027 sl@0: @SYMTestCaseDesc Closes an image object without opening it. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Close () sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To check Close() does nothing if the image is not already opened. sl@0: @SYMTestActions Initialise the graphics resource component. Declare an RSgImage object and sl@0: call Close() on it. sl@0: @SYMTestExpectedResults The function should not cause any errors or panics. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestCloseImageWithoutOpenL() sl@0: { sl@0: TestOpenDriverL(); sl@0: RSgImage image; sl@0: image.Close(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0028 sl@0: @SYMTestCaseDesc Creates an image with various invalid parameters. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9192 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n sl@0: RSgImage::Create(const TSgImageInfo, const RSgImage&) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To check the function returns the correct error messages when the parameters sl@0: are invalid. sl@0: @SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object sl@0: and Initialise the all the member variables with random values. Call the appropriate sl@0: Create() function with:\n sl@0: \t 1. invalid TSgImageInfo\n sl@0: \t 2. unsupported TSgImageInfo\n sl@0: \t 3. the creating RSgImage handle is not null\n sl@0: \t 4. the aSgImage handle is null\n sl@0: \t 5. the size and pixel format in TSgImageInfo is not the same as that of aSgImage\n sl@0: \t 6. number of iUserAttributes is more than KMaxHint (8)\n sl@0: @SYMTestExpectedResults The function should return\n sl@0: \t 1. KErrArgument\n sl@0: \t 2. KErrNotSupported\n sl@0: \t 3. KErrInUse\n sl@0: \t 4. KErrArgument\n sl@0: \t 5. KErrNotSupported\n sl@0: \t 6. KErrOverflow\n sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestCreateImageInvalidL() sl@0: { sl@0: TestOpenDriverL(); sl@0: RSgImage image; sl@0: sl@0: //invalid info 1 - invalid size sl@0: TSgImageInfo info1; sl@0: info1.iSizeInPixels = TSize(-100, 100); sl@0: TEST(KErrArgument == image.Create(info1, NULL, 0)); sl@0: sl@0: //invalid info 2 - const image with writable cpu access flag sl@0: info1.iUsage = ESgUsageDirectGdiSource; sl@0: info1.iCpuAccess = ESgCpuAccessReadWrite; sl@0: TEST(KErrArgument == image.Create(info1, NULL, 0)); sl@0: sl@0: //invalid info 3 - the image is used as a screen source but screen id is set to -1 sl@0: info1.iUsage = ESgUsageScreenSource; sl@0: info1.iScreenId = KSgScreenIdAny; sl@0: TEST(KErrArgument == image.Create(info1, NULL, 0)); sl@0: sl@0: //invalid info 4 - incorrect user attribute count sl@0: info1.iScreenId = KSgScreenIdMain; sl@0: TSgUserAttribute KTestAttributes[] = {{0x00008888, 1}, {0x00009999, 2}}; sl@0: info1.iUserAttributes = KTestAttributes; sl@0: info1.iUserAttributeCount = 0; sl@0: TEST(KErrArgument == image.Create(info1, NULL, 0)); sl@0: sl@0: //unsupported info 1 - unsupported pixel format sl@0: TSgImageInfo info2; sl@0: info2.iSizeInPixels = TSize(10, 10); sl@0: info2.iUsage = ESgUsageDirectGdiTarget; sl@0: info2.iPixelFormat = EUidPixelFormatAP_88; sl@0: TEST(KErrNotSupported == image.Create(info2, NULL, 0)); sl@0: sl@0: //unsupported info 2 - usage set to screen source and size is not the same as screen size sl@0: info2.iUsage = ESgUsageScreenSource|ESgUsageDirectGdiTarget; sl@0: info2.iSizeInPixels = TSize(9999, 8888); sl@0: TEST(KErrNotSupported == image.Create(info2, NULL, 0)); sl@0: sl@0: #ifdef __WINS__ sl@0: TSize screenSize; sl@0: if(HAL::Get(info2.iScreenId, HALData::EDisplayXPixels, screenSize.iWidth) == KErrNone sl@0: && HAL::Get(info2.iScreenId, HALData::EDisplayYPixels, screenSize.iHeight) == KErrNone) sl@0: { sl@0: info2.iUsage = ESgUsageScreenSource; sl@0: info2.iScreenId = KSgScreenIdMain; sl@0: info2.iCpuAccess = ESgCpuAccessReadWrite; sl@0: info2.iSizeInPixels = TSize(screenSize.iWidth + 10, screenSize.iHeight); sl@0: TEST(KErrNotSupported == image.Create(info2, NULL, 0)); sl@0: sl@0: info2.iSizeInPixels = TSize(screenSize.iWidth, screenSize.iHeight + 10); sl@0: TEST(KErrNotSupported == image.Create(info2, NULL, 0)); sl@0: sl@0: info2.iSizeInPixels = TSize(screenSize.iHeight, screenSize.iWidth + 10); sl@0: TEST(KErrNotSupported == image.Create(info2, NULL, 0)); sl@0: } sl@0: #endif sl@0: sl@0: //non-null handle sl@0: CreateImageL(image); sl@0: CleanupClosePushL(image); sl@0: TSgImageInfo info3; sl@0: info3.iSizeInPixels = TSize(8, 8); sl@0: info3.iUsage = ESgUsageDirectGdiSource; sl@0: info3.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info3.iCpuAccess = ESgCpuAccessReadWrite; sl@0: TInt ret = image.Create(info3, NULL, 0); sl@0: TEST(KErrInUse == ret); sl@0: sl@0: //non-null handle: create from an existing image sl@0: RSgImage image1; sl@0: CreateImageL(image1); sl@0: CleanupClosePushL(image1); sl@0: TEST(KErrInUse == image1.Create(info3, image)); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: //null existing image handle sl@0: RSgImage image2; sl@0: TEST(image2.IsNull()); sl@0: TEST(KErrArgument == image1.Create(info3, image2)); sl@0: sl@0: //the size and pixel format in TSgImageInfo is not the same as that of aSgImage sl@0: TSgImageInfo info4; sl@0: info4.iSizeInPixels = TSize(100, 100); sl@0: info4.iUsage = ESgUsageDirectGdiSource; sl@0: info4.iCpuAccess = ESgCpuAccessReadWrite; sl@0: TEST(KErrNotSupported == image1.Create(info4, image)); sl@0: sl@0: info4.iSizeInPixels = info3.iSizeInPixels; sl@0: info4.iPixelFormat = EUidPixelFormatXRGB_8888; sl@0: TEST(KErrNotSupported == image1.Create(info4, image)); sl@0: sl@0: //number of iUserAttributes more than KMaxHint(8) sl@0: TSgImageInfo info5; sl@0: info5.iSizeInPixels = TSize(100, 100); sl@0: info5.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info5.iCpuAccess = ESgCpuAccessNone; sl@0: info5.iUsage = ESgUsageDirectGdiTarget; sl@0: info5.iShareable = ETrue; sl@0: TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}}; sl@0: info5.iUserAttributes = testAttributes; sl@0: info5.iUserAttributeCount = 100; sl@0: CheckErrorL(KErrOverflow, image1.Create(info5, NULL, 0), (TText8*)__FILE__, __LINE__); sl@0: sl@0: CleanupStack::PopAndDestroy(&image); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0039 sl@0: @SYMTestCaseDesc Calls GetInfo() on an invalid image. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::GetInfo(TSgImageInfo&) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To check the correct error is returned when the client tries to get sl@0: information on an invalid image. sl@0: @SYMTestActions Initialise the graphics resource component. Call GetInfo on an image:\n sl@0: \t 1. that is not initialised\n sl@0: \t 2. TSgImageInfo has different user attributes Ids from the existing Ids. sl@0: @SYMTestExpectedResults The function should return:\n sl@0: \t 1. KErrBadHandle\n sl@0: \t 2. KErrNotFound or KErrArgument sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestGetInfoInvalidImageL() sl@0: { sl@0: TestOpenDriverL(); sl@0: RSgImage image; sl@0: TSgImageInfo info; sl@0: sl@0: //uninitialised image sl@0: TEST(KErrBadHandle == image.GetInfo(info)); sl@0: sl@0: //TSgImageInfo has different user attributes Ids from the existing Ids. sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iSizeInPixels = TSize(100, 100); sl@0: info.iUsage = ESgUsageDirectGdiTarget; sl@0: TSgUserAttribute testAttributes[] = {{0x00008888, 1}, {0x00009999, 2}}; sl@0: info.iUserAttributes = testAttributes; sl@0: info.iUserAttributeCount = 2; sl@0: CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: TSgImageInfo info2; sl@0: TSgUserAttribute testAttributes2[1]; sl@0: info2.iUserAttributes = testAttributes2; sl@0: info2.iUserAttributes[0].iUid = TUid::Uid(0x11111111); sl@0: info2.iUserAttributeCount = 1; sl@0: TInt result = image.GetInfo(info2); sl@0: TEST(KErrNotFound == result || KErrArgument == result); sl@0: TEST(!CompareInfos(info, info2)); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0030 sl@0: @SYMTestCaseDesc Maps an image under various invalid conditions. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::MapReadOnly(const TAny*&, TInt&) const\n sl@0: RSgImage::MapWriteOnly(TAny*&, TInt&)\n sl@0: RSgImage::MapReadWrite(TAny*&, TInt&) sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To check the correct error messages are returned when different map sl@0: functions are called under various invalid conditions. sl@0: @SYMTestActions Initialise the graphics resource component. \n sl@0: \t 1. call any map function on an uninitialised RSgImage\n sl@0: \t 2. call any map function twice\n sl@0: \t 3. call MapReadOnly() on an RSgImage created without CPU access sl@0: flag ESgCpuAccessReadOnly or ESgCpuAccessReadWrite\n sl@0: \t 4. call MapWriteOnly() on an RSgImage created without CPU access sl@0: flag ESgCpuAccessWriteOnly or ESgCpuAccessReadWrite\n sl@0: \t 5. call MapReadWrite() on an RSgImage created without CPU access sl@0: flag ESgCpuAccessReadWrite\n sl@0: \t 6. call any map function in a second process sl@0: @SYMTestExpectedResults The function should return:\n sl@0: \t 1. KErrBadHandle\n sl@0: \t 2. KErrInUse\n sl@0: \t 3. KErrAccessDenied\n sl@0: \t 4. KErrAccessDenied\n sl@0: \t 5. KErrAccessDenied\n sl@0: \t 6. KErrPermissionDenied sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestMapImageInvalidL() sl@0: { sl@0: TestOpenDriverL(); sl@0: RSgImage image; sl@0: const TAny* dataAddressRead; sl@0: TAny* dataAddressWrite; sl@0: TInt dataStride; sl@0: sl@0: //an uninitialised image sl@0: TEST(KErrBadHandle == image.MapReadOnly(dataAddressRead, dataStride)); sl@0: TEST(KErrBadHandle == image.MapWriteOnly(dataAddressWrite, dataStride)); sl@0: TEST(KErrBadHandle == image.MapReadWrite(dataAddressWrite, dataStride)); sl@0: sl@0: //map twice sl@0: RSgImage image1; sl@0: CreateImageL(image1); sl@0: CleanupClosePushL(image1); sl@0: TEST(KErrNone == image1.MapReadOnly(dataAddressRead, dataStride)); sl@0: TEST(KErrInUse == image1.MapReadOnly(dataAddressRead, dataStride)); sl@0: TEST(KErrNone == image1.Unmap()); sl@0: sl@0: TEST(KErrNone == image1.MapWriteOnly(dataAddressWrite, dataStride)); sl@0: TEST(KErrInUse == image1.MapWriteOnly(dataAddressWrite, dataStride)); sl@0: TEST(KErrNone == image1.Unmap()); sl@0: sl@0: TEST(KErrNone == image1.MapReadWrite(dataAddressWrite, dataStride)); sl@0: TEST(KErrInUse == image1.MapReadWrite(dataAddressWrite, dataStride)); sl@0: TEST(KErrNone == image1.Unmap()); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: // Initialise image 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: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: TEST(KErrNone == image.MapReadWrite(dataAddressWrite, dataStride)); //first time should pass sl@0: TEST(KErrInUse == image.MapReadWrite(dataAddressWrite, dataStride)); //second time should fail sl@0: TEST(KErrNone == image.Unmap()); sl@0: image.Close(); sl@0: sl@0: //call MapReadOnly() on an RSgImage created without CPU access sl@0: //flag ESgCpuAccessReadOnly or ESgCpuAccessReadWrite sl@0: info.iCpuAccess = ESgCpuAccessNone; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: TEST(KErrAccessDenied == image.MapReadOnly(dataAddressRead, dataStride)); sl@0: image.Close(); sl@0: sl@0: info.iCpuAccess = ESgCpuAccessWriteOnly; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: TEST(KErrAccessDenied == image.MapReadOnly(dataAddressRead, dataStride)); sl@0: image.Close(); sl@0: sl@0: //call MapWriteOnly() on an RSgImage created without CPU access sl@0: //flag ESgCpuAccessWriteOnly or ESgCpuAccessReadWrite sl@0: info.iCpuAccess = ESgCpuAccessNone; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: TEST(KErrAccessDenied == image.MapWriteOnly(dataAddressWrite, dataStride)); sl@0: image.Close(); sl@0: sl@0: info.iCpuAccess = ESgCpuAccessReadOnly; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: TEST(KErrAccessDenied == image.MapWriteOnly(dataAddressWrite, dataStride)); sl@0: image.Close(); sl@0: sl@0: //call MapReadWrite() on an RSgImage created without CPU access sl@0: //flag ESgCpuAccessReadWrite sl@0: info.iCpuAccess = ESgCpuAccessNone; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride)); sl@0: image.Close(); sl@0: sl@0: info.iCpuAccess = ESgCpuAccessReadOnly; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride)); sl@0: image.Close(); sl@0: sl@0: info.iCpuAccess = ESgCpuAccessWriteOnly; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: TEST(KErrAccessDenied == image.MapReadWrite(dataAddressWrite, dataStride)); sl@0: image.Close(); sl@0: sl@0: info.iCpuAccess = ESgCpuAccessReadWrite; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: sl@0: //call map in a second thread in the current process - should succeed sl@0: TSgresTestInfo threadInfo = {image.Id(), info, 0, ESgresSecondThreadMapImage}; sl@0: TInt testResult = CreateSecondThreadAndDoTestL(threadInfo); sl@0: User::LeaveIfError(testResult); sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: TEST(testResult & EThirdTestPassed); sl@0: TEST(testResult & EFourthTestPassed); sl@0: TEST(testResult & EFifthTestPassed); sl@0: TEST(testResult & ESixthTestPassed); sl@0: TEST(testResult & ESeventhTestPassed); sl@0: sl@0: //call map in a non-owner process sl@0: TSgresTestInfo processInfo = {image.Id(), info, 0, ESgresSecondProcessMapImage}; sl@0: testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo); sl@0: User::LeaveIfError(testResult); sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: TEST(testResult & EThirdTestPassed); sl@0: TEST(testResult & EFourthTestPassed); sl@0: TEST(testResult & EFifthTestPassed); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0031 sl@0: @SYMTestCaseDesc Unmaps an image under various invalid conditions. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::MapReadOnly(const TAny*&, TInt&) const\n sl@0: RSgImage::MapWriteOnly(TAny*&, TInt&)\n sl@0: RSgImage::MapReadWrite(TAny*&, TInt&)\n sl@0: RSgImage::Unmap() sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To check the correct error messages are returned when the Unmap() sl@0: function is called under various invalid conditions. sl@0: @SYMTestActions Initialise the graphics resource component.\n sl@0: \t 1. call Unmap() on an uninitialised image object\n sl@0: \t 2. create an image with CPU access flag ESgCpuAccessNone and then unmap it\n sl@0: \t 3. call Unmap() on an image that was not mapped.\n sl@0: \t 4. call Unmap() on a mapped image in a second thread in the same process.\n sl@0: \t 5. call Unmap() on an image in a non-owner process sl@0: @SYMTestExpectedResults The function should return:\n sl@0: \t 1. KErrBadHandle\n sl@0: \t 2. KErrGeneral\n sl@0: \t 3. KErrGeneral\n sl@0: \t 4. KErrNone\n sl@0: \t 5. KErrGeneral sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestUnmapImageInvalidL() sl@0: { sl@0: TestOpenDriverL(); sl@0: RSgImage image; sl@0: sl@0: //unitialized image sl@0: TEST(KErrBadHandle == image.Unmap()); sl@0: sl@0: //create an image 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.iShareable = ETrue; sl@0: info.iCpuAccess = ESgCpuAccessReadWrite; sl@0: const TAny* dataAddressRead; sl@0: TInt dataStride; sl@0: CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: sl@0: //call on an unmapped image sl@0: TEST(KErrGeneral == image.Unmap()); sl@0: sl@0: //map in the current thread and try to unmap in another thread in the current process sl@0: //should fail sl@0: TEST(KErrNone == image.MapReadOnly(dataAddressRead, dataStride)); sl@0: TSgDrawableId id = image.Id(); sl@0: TSgImageInfo imageinfo; sl@0: image.GetInfo(imageinfo); sl@0: sl@0: TSgresTestInfo threadInfo = {id, imageinfo, 0, ESgresSecondThreadUnmapImage}; sl@0: TInt testResult = CreateSecondThreadAndDoTestL(threadInfo); sl@0: User::LeaveIfError(testResult); sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: sl@0: //image should already be unmapped sl@0: TEST(KErrGeneral == image.Unmap()); sl@0: sl@0: //map in the current thread and try to unmap in another process sl@0: //should fail sl@0: TEST(KErrNone == image.MapReadOnly(dataAddressRead, dataStride)); sl@0: TSgresTestInfo processInfo = {id, imageinfo, 0, ESgresSecondProcessUnmapImage}; sl@0: testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo); sl@0: User::LeaveIfError(testResult); sl@0: TEST(testResult & EFirstTestPassed); sl@0: TEST(testResult & ESecondTestPassed); sl@0: sl@0: //image should still be mapped sl@0: TEST(KErrNone == image.Unmap()); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0048 sl@0: @SYMTestCaseDesc RSgImage stress tests sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n sl@0: RSgImage::Close() sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure creating and destroying RSgImage multiple times work well. sl@0: @SYMTestActions Create images 1000 times but only store KMaxImagesInArray of them sl@0: at one time in an RArray. When a new image is to be added to the sl@0: array, a random image from the array is removed. sl@0: @SYMTestExpectedResults There should be no panics or leaves. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestStress1L() sl@0: { sl@0: TestOpenDriverL(); sl@0: TSgImageInfo info; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: info.iSizeInPixels = TSize(100, 100); sl@0: info.iUsage = ESgUsageDirectGdiTarget; sl@0: sl@0: TInt KMaxImagesInArray =40; sl@0: TInt64 seed = 0; sl@0: for (TInt count = 1000; count > 0; --count) sl@0: { sl@0: RSgImage image; sl@0: CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(image); sl@0: iTestImages.AppendL(image); sl@0: CleanupStack::Pop(); sl@0: if (iTestImages.Count() >= KMaxImagesInArray) sl@0: { sl@0: TInt i = Math::Rand(seed) % KMaxImagesInArray; sl@0: iTestImages[i].Close(); sl@0: iTestImages.Remove(i); sl@0: } sl@0: } sl@0: TInt count = iTestImages.Count(); sl@0: for(TInt i=0; i threads; sl@0: _LIT(KMultipleThreadName, "Multiple Threads Stress Test Thread "); sl@0: for (TInt i = 0; i < KNoOfThreads; ++i) sl@0: { sl@0: TBuf<50> threadName(KMultipleThreadName); sl@0: threadName.AppendNum(i); sl@0: RThread thread; sl@0: User::LeaveIfError(thread.Create(threadName, SecondThreadStart, KDefaultStackSize, &User::Heap(), &threadInfo)); sl@0: thread.SetPriority(EPriorityLess); sl@0: threads.AppendL(thread); sl@0: } sl@0: // run threads sl@0: for (TInt i = 0; i < KNoOfThreads; ++i) sl@0: { sl@0: threads[i].Resume(); sl@0: } sl@0: // wait for the threads to terminate processing sl@0: for (TInt i = 0; i < KNoOfThreads; ++i) sl@0: { sl@0: sem.Wait(); sl@0: } sl@0: for (TInt i = 0; i < KNoOfThreads; ++i) sl@0: { sl@0: threads[i].Close(); sl@0: } sl@0: CleanupStack::PopAndDestroy(2); // image, sem sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0051 sl@0: @SYMTestCaseDesc Calls RSgImage::GetInterface() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::GetInterface(TUid, TAny*&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling GetInterface() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call GetInterface() on the second sl@0: handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageGetInterfaceInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInterfaceInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageGetInterfaceInvalidHandleLThread"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0052 sl@0: @SYMTestCaseDesc Calls RSgImage::GetInterface() with a non-null handle and an uninitialised driver sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::GetInterface(TUid, TAny*&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling GetInterface() with a non-null handle and an uninitialised driver will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Close the graphics resource driver. sl@0: Call GetInterface() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageGetInterfaceNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInterfaceNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageGetInterfaceNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0053 sl@0: @SYMTestCaseDesc Calls RSgImage::Close() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Close()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling Close() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call Close() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageCloseInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCloseInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageCloseInvalidHandleL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0054 sl@0: @SYMTestCaseDesc Calls RSgImage::Close() with a non-null handle and an uninitialised driver sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Close()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling Close() with a non-null handle and an uninitialised driver will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Close the graphics resource driver. sl@0: Call Close() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageCloseNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCloseNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageCloseNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0055 sl@0: @SYMTestCaseDesc Calls RSgImage::Id() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Id()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling Id() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call Id() on the second sl@0: handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageIdInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageIdInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageIdInvalidHandleL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0056 sl@0: @SYMTestCaseDesc Calls RSgImage::Id() with a non-null handle and an uninitialised driver sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Id()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling Id() with a non-null handle and an uninitialised driver will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Close the graphics resource driver. sl@0: Call Id() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageIdNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageIdNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageIdNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0057 sl@0: @SYMTestCaseDesc Calls RSgImage::Create() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9192 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling Create() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call Create() on the second sl@0: handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageCreateInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageCreateInvalidHandleL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0058 sl@0: @SYMTestCaseDesc Calls RSgImage::GetInfo() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::GetInfo(TSgImageInfo&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling GetInfo() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call GetInfo() on the second sl@0: handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageGetInfoInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInfoInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageGetInfoInvalidHandleL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0059 sl@0: @SYMTestCaseDesc Calls RSgImage::GetInfo() with a non-null handle and an uninitialised driver sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID SgImage::GetInfo(TSgImageInfo&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling GetInfo() with a non-null handle and an uninitialised driver will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Close the graphics resource driver. sl@0: Call GetInfo() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageGetInfoNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetInfoNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageGetInfoNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0060 sl@0: @SYMTestCaseDesc Calls RSgImage::MapReadOnly with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMFssID RSgImage::MapReadOnly(const TAny*&, TInt&) const\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling MapReadOnly() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call MapReadOnly() on the second sl@0: handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageMapReadOnlyInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadOnlyInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageMapReadOnlyInvalidHandleL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0061 sl@0: @SYMTestCaseDesc Calls RSgImage::MapReadOnly with a non-null handle and an uninitialised driver sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMFssID RSgImage::MapReadOnly(const TAny*&, TInt&) const\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling MapReadOnly() with a non-null handle and an uninitialised driver will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Close the graphics resource driver. sl@0: Call MapReadOnly() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageMapReadOnlyNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadOnlyNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageMapReadOnlyNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0062 sl@0: @SYMTestCaseDesc Calls RSgImage::MapWriteOnly() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMFssID RSgImage::MapWriteOnly(TAny*&, TInt&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling MapWriteOnly() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call MapWriteOnly() on the second sl@0: handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageMapWriteOnlyInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapWriteOnlyInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageMapWriteOnlyInvalidHandleL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0063 sl@0: @SYMTestCaseDesc Calls RSgImage::MapWriteOnly() with a non-null handle and an uninitialised driver sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMFssID RSgImage::MapWriteOnly(TAny*&, TInt&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling MapWriteOnly() with a non-null handle and an uninitialised driver will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Close the graphics resource driver. sl@0: Call MapWriteOnly() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageMapWriteOnlyNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapWriteOnlyNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageMapWriteOnlyNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0064 sl@0: @SYMTestCaseDesc Calls RSgImage::MapReadWrite() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMFssID RSgImage::MapReadWrite(TAny*&, TInt&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling MapReadWrite() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call MapReadWrite() on the second sl@0: handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageMapReadWriteInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadWriteInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageMapReadWriteInvalidHandleL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0065 sl@0: @SYMTestCaseDesc Calls RSgImage::MapReadWrite() with a non-null handle and an uninitialised driver sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMFssID RSgImage::MapReadWrite(TAny*&, TInt&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling MapReadWrite() with a non-null handle and an uninitialised driver will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Close the graphics resource driver. sl@0: Call MapReadWrite() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageMapReadWriteNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageMapReadWriteNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageMapReadWriteNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0066 sl@0: @SYMTestCaseDesc Calls RSgImage::Unmap() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMREQ REQ9193 sl@0: @SYMFssID RSgImage::Unmap()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling Unmap() with an invalid image handle will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Call Unmap() on the second sl@0: handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageUnmapInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageUnmapInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageUnmapInvalidHandleL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0067 sl@0: @SYMTestCaseDesc Calls RSgImage::Unmap() with a non-null handle and an uninitialised driver sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Unmap()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling Unmap() with a non-null handle and an uninitialised driver will cause a panic. sl@0: @SYMTestActions Initialise the graphics resource component and create an image in a second thread. sl@0: Declare another image and assign it to the current image handle. Close the current sl@0: image so the second image handle becomes invalid. Close the graphics resource driver. sl@0: Call Unmap() on the second handle. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageUnmapNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageUnmapNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestImageUnmapNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0082 sl@0: @SYMTestCaseDesc Calls RSgImage::Open() when the driver was not initialised. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Open(const TSgDrawableId&, TUint32)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling RSgImage::Open() with an uninitialised driver will cause a panic. sl@0: @SYMTestActions Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageOpenNoDriver1L() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageOpenNoDriver1, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestPanicImageOpenNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0083 sl@0: @SYMTestCaseDesc Creates an image from memory when the driver was not initialised. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling RSgImage::Create() with an uninitialised driver will cause a panic. sl@0: @SYMTestActions Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageCreateNoDriver1L() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateNoDriver1, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestPanicImageCreateNoDriver1L"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0084 sl@0: @SYMTestCaseDesc Creates an image from an existing image when the driver was not initialised. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling RSgImage::Create() with an uninitialised driver will cause a panic. sl@0: @SYMTestActions Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageCreateNoDriver2L() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageCreateNoDriver2, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestPanicImageCreateNoDriver2L"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0085 sl@0: @SYMTestCaseDesc Calls RSgImage::GetPixelFormats() when the driver was not initialised. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&) \n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling RSgImage::GetPixelFormats() with an uninitialised driver will cause a panic. sl@0: @SYMTestActions Do not Initialise the graphics resource component and call RSgImage::GetPixelFormats() in a second thread. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageGetPixelFormatsNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageGetPixelFormatsNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestPanicImageGetPixelFormatsNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0093 sl@0: @SYMTestCaseDesc Calls RSgImage::Open() with mode flags when the driver was not initialised. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::Open(const TSgDrawableId&, TUint32)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling RSgImage::Open() with an uninitialised driver will cause a panic. sl@0: @SYMTestActions Do not Initialise the graphics resource component and call RSgImage::Open() in a second thread. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageOpenNoDriver2L() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageOpenNoDriver2, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestPanicImageOpenNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0088 sl@0: @SYMTestCaseDesc Calls RSgImage::DrawableType() when the driver was not initialised. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::DrawableType()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling RSgImage::DrawableType() with an uninitialised driver will cause a panic. sl@0: @SYMTestActions Do not Initialise the graphics resource component and call RSgImage::DrawableType() in a second thread. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageDrawableTypeNoDriverL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageDrawableTypeInvalidHandle, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestPanicImageOpenNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 2, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0089 sl@0: @SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ8809 sl@0: @SYMREQ REQ9175 sl@0: @SYMFssID RSgImage::DrawableType()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure calling RSgImage::DrawableType() with an uninitialised driver will cause a panic. sl@0: @SYMTestActions Do not Initialise the graphics resource component and call RSgImage::DrawableType() in a second thread. sl@0: @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES SGRES 2(ESgPanicBadDrawableHandle). sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageGeneric::TestPanicImageDrawableTypeInvalidHandleL() sl@0: { sl@0: TSgImageInfo info; sl@0: TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicImageDrawableTypeNoDriver, ETrue}; sl@0: TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); sl@0: _LIT(KTestName, "TestPanicImageOpenNoDriverL"); sl@0: CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); sl@0: } sl@0: sl@0: void CTSgImageGeneric::DoMemoryTestsL() sl@0: { sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestGetPixelFormatsL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestCreateImageUninitializedL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestCreateImageL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestCreateImageFromExistingImageL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestGetImageInfoL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestGetImageDrawableIdL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestMapImageL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestOpenImageL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestGetInterfaceL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestGetPixelFormatsInvalidL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestOpenImageInvalidL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestCloseImageManyTimesL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestCloseImageWithoutOpenL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestCreateImageInvalidL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestGetInfoInvalidImageL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestMapImageInvalidL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: sl@0: __UHEAP_MARK; SgDriver::AllocMarkStart(); sl@0: TestUnmapImageInvalidL(); sl@0: __UHEAP_MARKEND; SgDriver::AllocMarkEnd(0); sl@0: }