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 "tsgimagecollectiongeneric.h" sl@0: sl@0: CTSgImageCollectionGeneric::CTSgImageCollectionGeneric() sl@0: { sl@0: INFO_PRINTF1(_L("Graphics resource component test - RSgImageCollection Generic Tests.\r\n")); sl@0: } sl@0: sl@0: CTSgImageCollectionGeneric::~CTSgImageCollectionGeneric() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Overrides of base class pure virtual sl@0: Our implementation only gets called if the base class doTestStepPreambleL() did sl@0: not leave. That being the case, the current test result value will be EPass. sl@0: @leave Gets system wide error code sl@0: @return TVerdict code sl@0: */ sl@0: TVerdict CTSgImageCollectionGeneric::doTestStepL() sl@0: { sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0015")); sl@0: INFO_PRINTF1(_L("Creation of image collections.\r\n")); sl@0: TestCreateImageCollectionL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0016")); sl@0: INFO_PRINTF1(_L("Getting surface id of the image collection.\r\n")); sl@0: TestGetImageCollectionSurfaceIdL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0017")); sl@0: INFO_PRINTF1(_L("Getting the number of images in an image collection.\r\n")); sl@0: TestGetCollectionImageNumberL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0018")); sl@0: INFO_PRINTF1(_L("Getting information about the images in an image collection.\r\n")); sl@0: TestGetImageInfoInCollectionL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0019")); sl@0: INFO_PRINTF1(_L("Getting image at a specific location in an image collection.\r\n")); sl@0: TestOpenImageInCollectionL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0020")); sl@0: INFO_PRINTF1(_L("Mapping / Unmapping images in a collection.\r\n")); sl@0: TestMapImageInCollectionL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0021")); sl@0: INFO_PRINTF1(_L("Creation of multiple image collections.\r\n")); sl@0: TestCreateMultipleImageCollectionL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0034")); sl@0: INFO_PRINTF1(_L("Creation of the image collection with invalid parameters\r\n")); sl@0: TestCreateImageCollectionInvalidL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0035")); sl@0: INFO_PRINTF1(_L("Creation of multiple image collections with invalid parameters.\r\n")); sl@0: TestCreateMultipleImageCollectionsInvalidL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0036")); sl@0: INFO_PRINTF1(_L("Getting information about the images in an image collection under various invalid conditions.\r\n")); sl@0: TestGetImageCollectionInfoInvalidL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0037")); sl@0: INFO_PRINTF1(_L("Opening images from a collection under various invalid conditions.\r\n")); sl@0: TestOpenImageInCollectionInvalidL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0038")); sl@0: INFO_PRINTF1(_L("Invalid mapping/unmapping tests on individual images in a collection\r\n")); sl@0: TestMapUnmapImagesInCollectionInvalidL(); sl@0: RecordTestResultL(); sl@0: sl@0: #ifdef _DEBUG sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0094 sl@0: */ sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0094")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic out of memory tests.\r\n")); sl@0: TestOOM(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0068")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - Close() with invalid imagecollection handle\r\n")); sl@0: TestPanicImageCollectionCloseInvalidHandleL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0069")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - Close() with non null imagecollection handle and uninitialised driver\r\n")); sl@0: TestPanicImageCollectionCloseNoDriverL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0070")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - SurfaceId() with invalid imagecollection handle\r\n")); sl@0: TestPanicImageCollectionSurfaceIdInvalidHandleL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0071")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - SurfaceId() with non null imagecollection handle and uninitialised driver\r\n")); sl@0: TestPanicImageCollectionSurfaceIdNoDriverL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0072")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - GetInfo() with invalid imagecollection handle\r\n")); sl@0: TestPanicImageCollectionGetInfoInvalidHandleL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0073")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - GetInfo() with non null imagecollection handle and uninitialised driver\r\n")); sl@0: TestPanicImageCollectionGetInfoNoDriverL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0074")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - Count() with invalid imagecollection handle\r\n")); sl@0: TestPanicImageCollectionCountInvalidHandleL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0075")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - Count() with non null imagecollection handle and uninitialised driver\r\n")); sl@0: TestPanicImageCollectionCountNoDriverL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0076")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - OpenImage() with invalid imagecollection handle\r\n")); sl@0: TestPanicImageCollectionOpenImageInvalidHandleL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0077")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - OpenImage() with non null imagecollection handle and uninitialised driver\r\n")); sl@0: TestPanicImageCollectionOpenImageNoDriverL(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0086")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - Create() a single image collection with an uninitialised driver\r\n")); sl@0: TestPanicImageCollectionCreateNoDriver1L(); sl@0: RecordTestResultL(); sl@0: sl@0: SetTestStepID(_L("GRAPHICS-RESOURCE-0086")); sl@0: INFO_PRINTF1(_L("RSgImageCollection generic panic test - Create() multiple image collections with an uninitialised driver\r\n")); sl@0: TestPanicImageCollectionCreateNoDriver2L(); sl@0: RecordTestResultL(); sl@0: #else sl@0: INFO_PRINTF1(_L("Warning: Skipping the panic tests. \r\n")); sl@0: #endif sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0015 sl@0: @SYMTestCaseDesc Creates an image collection. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ9214 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImageCollection::Create(const TSgImageInfo&, TInt)\n sl@0: RSgImageCollection::Close() sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure the image collection can be created. sl@0: @SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object sl@0: and Initialise all the member variables. Call Create() on the RSgImageCollection sl@0: with the image info and number of images. sl@0: @SYMTestExpectedResults The function should return KErrNone and memory for the image objects sl@0: are successfully allocated. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageCollectionGeneric::TestCreateImageCollectionL() sl@0: { sl@0: TestOpenDriverL(); sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(8, 8); sl@0: info.iUsage = ESgUsageDirectGdiTarget; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: sl@0: RSgImageCollection collection; sl@0: TEST(collection.IsNull()); sl@0: sl@0: CheckErrorL(KErrNone, collection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(collection); sl@0: TEST(!collection.IsNull()); sl@0: TEST(1 == SgDriver::ResourceCount()); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0016 sl@0: @SYMTestCaseDesc Gets the surface id of the image collection. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ9214 sl@0: @SYMREQ REQ9215 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImageCollection::SurfaceId()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure the surface id of the image collection can be retrieved successfully. sl@0: @SYMTestActions Initialise the graphics resource component. Create an image collection and call sl@0: SurfaceId() on it. sl@0: @SYMTestExpectedResults A non-null surface id should be returned. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageCollectionGeneric::TestGetImageCollectionSurfaceIdL() sl@0: { sl@0: const TSurfaceId KNullSurfaceId = {0, 0, 0, 0}; sl@0: RSgImageCollection collection; sl@0: TSurfaceId surfaceid = collection.SurfaceId(); sl@0: TEST(surfaceid == KNullSurfaceId); sl@0: TestOpenDriverL(); sl@0: CreateImageCollectionL(collection); sl@0: CleanupClosePushL(collection); sl@0: surfaceid = collection.SurfaceId(); sl@0: TEST(!surfaceid.IsNull()); sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0017 sl@0: @SYMTestCaseDesc Gets the number of images in an image collection. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ9214 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImageCollection::Count())\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure the function returns the correct number of images. sl@0: @SYMTestActions Initialise the graphics resource component. Declare an image collection. Call Count(). sl@0: Create an image collection. Call Count() again. sl@0: @SYMTestExpectedResults First call should return zero. Second call should return the same value sl@0: as the one passed to the function at creation time. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageCollectionGeneric::TestGetCollectionImageNumberL() sl@0: { sl@0: RSgImageCollection collection; sl@0: TInt number = collection.Count(); sl@0: TEST(0 == number); sl@0: TestOpenDriverL(); sl@0: CreateImageCollectionL(collection); sl@0: CleanupClosePushL(collection); sl@0: number = collection.Count(); sl@0: TEST(KNumImagesInCollection == number); sl@0: CleanupStack::PopAndDestroy(); sl@0: TestCloseDriver(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-RESOURCE-0018 sl@0: @SYMTestCaseDesc Calls GetInfo() on an image collection. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ9214 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImageCollection::GetInfo(TSgImageInfo&)\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure the information about the images in a collection can be correctly returned. sl@0: @SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object and sl@0: Initialise all the member variables. Create an image collection. Call GetInfo() and sl@0: compare the returned TSgImageInfo object with the original one. sl@0: @SYMTestExpectedResults The function should return KErrNone and the returned information should be the sl@0: same as the old one. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageCollectionGeneric::TestGetImageInfoInCollectionL() sl@0: { sl@0: TestOpenDriverL(); sl@0: TSgImageInfo info; sl@0: info.iSizeInPixels = TSize(8, 8); sl@0: info.iUsage = ESgUsageDirectGdiTarget; sl@0: info.iPixelFormat = EUidPixelFormatRGB_565; sl@0: sl@0: RSgImageCollection collection; sl@0: CheckErrorL(KErrNone, collection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(collection); sl@0: TEST(!collection.IsNull()); sl@0: sl@0: TSgImageInfo info2; sl@0: TEST(KErrNone == collection.GetInfo(info2)); sl@0: TEST(CompareInfos(info, info2)); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: //get info with user attributes sl@0: TSgUserAttribute testAttributes[2] = {{0x00008888, 1}, {0x00009999, 2}}; sl@0: info.iUserAttributes = testAttributes; sl@0: info.iUserAttributeCount = 2; sl@0: CheckErrorL(KErrNone, collection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__); sl@0: CleanupClosePushL(collection); sl@0: TSgImageInfo info3; sl@0: TSgUserAttribute testAttributes2[2] = {{0x00008888, 0}, {0x00009999, 0}}; sl@0: info3.iUserAttributes = testAttributes2; sl@0: info3.iUserAttributeCount = 2; sl@0: TEST(KErrNone == collection.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-0019 sl@0: @SYMTestCaseDesc Gets image at a specific location in an image collection. sl@0: @SYMPREQ PREQ39 sl@0: @SYMREQ REQ9214 sl@0: @SYMREQ REQ9224 sl@0: @SYMREQ REQ9233 sl@0: @SYMREQ REQ9234 sl@0: @SYMFssID RSgImageCollection::OpenImage()\n sl@0: @SYMTestPriority Critical sl@0: @SYMTestType Unit Test sl@0: @SYMTestPurpose To ensure an image at a specific location can be returned. sl@0: @SYMTestActions Initialise the graphics resource component. Create the image collection. Call OpenImage() to sl@0: return all the images in order. sl@0: @SYMTestExpectedResults All the images are returned successfully. sl@0: @SYMTestStatus Implemented sl@0: */ sl@0: void CTSgImageCollectionGeneric::TestOpenImageInCollectionL() sl@0: { sl@0: TestOpenDriverL(); sl@0: RSgImageCollection collection; sl@0: CreateImageCollectionL(collection); sl@0: CleanupClosePushL(collection); sl@0: sl@0: TSgImageInfo info1; sl@0: collection.GetInfo(info1); sl@0: sl@0: for(TInt i=0; i