diff -r 000000000000 -r 5d03bc08d59c graphicsresourceservices/graphicsresource/test/tsgimagecollectiongeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsresourceservices/graphicsresource/test/tsgimagecollectiongeneric.cpp Tue Feb 02 01:47:50 2010 +0200 @@ -0,0 +1,1348 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include "tsgimagecollectiongeneric.h" + +CTSgImageCollectionGeneric::CTSgImageCollectionGeneric() + { + INFO_PRINTF1(_L("Graphics resource component test - RSgImageCollection Generic Tests.\r\n")); + } + +CTSgImageCollectionGeneric::~CTSgImageCollectionGeneric() + { + } + +/** +Overrides of base class pure virtual +Our implementation only gets called if the base class doTestStepPreambleL() did +not leave. That being the case, the current test result value will be EPass. +@leave Gets system wide error code +@return TVerdict code +*/ +TVerdict CTSgImageCollectionGeneric::doTestStepL() + { + SetTestStepID(_L("GRAPHICS-RESOURCE-0015")); + INFO_PRINTF1(_L("Creation of image collections.\r\n")); + TestCreateImageCollectionL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0016")); + INFO_PRINTF1(_L("Getting surface id of the image collection.\r\n")); + TestGetImageCollectionSurfaceIdL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0017")); + INFO_PRINTF1(_L("Getting the number of images in an image collection.\r\n")); + TestGetCollectionImageNumberL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0018")); + INFO_PRINTF1(_L("Getting information about the images in an image collection.\r\n")); + TestGetImageInfoInCollectionL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0019")); + INFO_PRINTF1(_L("Getting image at a specific location in an image collection.\r\n")); + TestOpenImageInCollectionL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0020")); + INFO_PRINTF1(_L("Mapping / Unmapping images in a collection.\r\n")); + TestMapImageInCollectionL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0021")); + INFO_PRINTF1(_L("Creation of multiple image collections.\r\n")); + TestCreateMultipleImageCollectionL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0034")); + INFO_PRINTF1(_L("Creation of the image collection with invalid parameters\r\n")); + TestCreateImageCollectionInvalidL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0035")); + INFO_PRINTF1(_L("Creation of multiple image collections with invalid parameters.\r\n")); + TestCreateMultipleImageCollectionsInvalidL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0036")); + INFO_PRINTF1(_L("Getting information about the images in an image collection under various invalid conditions.\r\n")); + TestGetImageCollectionInfoInvalidL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0037")); + INFO_PRINTF1(_L("Opening images from a collection under various invalid conditions.\r\n")); + TestOpenImageInCollectionInvalidL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0038")); + INFO_PRINTF1(_L("Invalid mapping/unmapping tests on individual images in a collection\r\n")); + TestMapUnmapImagesInCollectionInvalidL(); + RecordTestResultL(); + +#ifdef _DEBUG +/** +@SYMTestCaseID GRAPHICS-RESOURCE-0094 +*/ + SetTestStepID(_L("GRAPHICS-RESOURCE-0094")); + INFO_PRINTF1(_L("RSgImageCollection generic out of memory tests.\r\n")); + TestOOM(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0068")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - Close() with invalid imagecollection handle\r\n")); + TestPanicImageCollectionCloseInvalidHandleL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0069")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - Close() with non null imagecollection handle and uninitialised driver\r\n")); + TestPanicImageCollectionCloseNoDriverL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0070")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - SurfaceId() with invalid imagecollection handle\r\n")); + TestPanicImageCollectionSurfaceIdInvalidHandleL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0071")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - SurfaceId() with non null imagecollection handle and uninitialised driver\r\n")); + TestPanicImageCollectionSurfaceIdNoDriverL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0072")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - GetInfo() with invalid imagecollection handle\r\n")); + TestPanicImageCollectionGetInfoInvalidHandleL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0073")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - GetInfo() with non null imagecollection handle and uninitialised driver\r\n")); + TestPanicImageCollectionGetInfoNoDriverL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0074")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - Count() with invalid imagecollection handle\r\n")); + TestPanicImageCollectionCountInvalidHandleL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0075")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - Count() with non null imagecollection handle and uninitialised driver\r\n")); + TestPanicImageCollectionCountNoDriverL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0076")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - OpenImage() with invalid imagecollection handle\r\n")); + TestPanicImageCollectionOpenImageInvalidHandleL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0077")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - OpenImage() with non null imagecollection handle and uninitialised driver\r\n")); + TestPanicImageCollectionOpenImageNoDriverL(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0086")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - Create() a single image collection with an uninitialised driver\r\n")); + TestPanicImageCollectionCreateNoDriver1L(); + RecordTestResultL(); + + SetTestStepID(_L("GRAPHICS-RESOURCE-0086")); + INFO_PRINTF1(_L("RSgImageCollection generic panic test - Create() multiple image collections with an uninitialised driver\r\n")); + TestPanicImageCollectionCreateNoDriver2L(); + RecordTestResultL(); +#else + INFO_PRINTF1(_L("Warning: Skipping the panic tests. \r\n")); +#endif + return TestStepResult(); + } + + +/** +@SYMTestCaseID GRAPHICS-RESOURCE-0015 +@SYMTestCaseDesc Creates an image collection. +@SYMPREQ PREQ39 +@SYMREQ REQ9214 +@SYMREQ REQ9224 +@SYMREQ REQ9233 +@SYMREQ REQ9234 +@SYMFssID RSgImageCollection::Create(const TSgImageInfo&, TInt)\n + RSgImageCollection::Close() +@SYMTestPriority Critical +@SYMTestType Unit Test +@SYMTestPurpose To ensure the image collection can be created. +@SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object + and Initialise all the member variables. Call Create() on the RSgImageCollection + with the image info and number of images. +@SYMTestExpectedResults The function should return KErrNone and memory for the image objects + are successfully allocated. +@SYMTestStatus Implemented + */ +void CTSgImageCollectionGeneric::TestCreateImageCollectionL() + { + TestOpenDriverL(); + TSgImageInfo info; + info.iSizeInPixels = TSize(8, 8); + info.iUsage = ESgUsageDirectGdiTarget; + info.iPixelFormat = EUidPixelFormatRGB_565; + + RSgImageCollection collection; + TEST(collection.IsNull()); + + CheckErrorL(KErrNone, collection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__); + CleanupClosePushL(collection); + TEST(!collection.IsNull()); + TEST(1 == SgDriver::ResourceCount()); + + CleanupStack::PopAndDestroy(); + TestCloseDriver(); + } + +/** +@SYMTestCaseID GRAPHICS-RESOURCE-0016 +@SYMTestCaseDesc Gets the surface id of the image collection. +@SYMPREQ PREQ39 +@SYMREQ REQ9214 +@SYMREQ REQ9215 +@SYMREQ REQ9224 +@SYMREQ REQ9233 +@SYMREQ REQ9234 +@SYMFssID RSgImageCollection::SurfaceId()\n +@SYMTestPriority Critical +@SYMTestType Unit Test +@SYMTestPurpose To ensure the surface id of the image collection can be retrieved successfully. +@SYMTestActions Initialise the graphics resource component. Create an image collection and call + SurfaceId() on it. +@SYMTestExpectedResults A non-null surface id should be returned. +@SYMTestStatus Implemented + */ +void CTSgImageCollectionGeneric::TestGetImageCollectionSurfaceIdL() + { + const TSurfaceId KNullSurfaceId = {0, 0, 0, 0}; + RSgImageCollection collection; + TSurfaceId surfaceid = collection.SurfaceId(); + TEST(surfaceid == KNullSurfaceId); + TestOpenDriverL(); + CreateImageCollectionL(collection); + CleanupClosePushL(collection); + surfaceid = collection.SurfaceId(); + TEST(!surfaceid.IsNull()); + + CleanupStack::PopAndDestroy(); + TestCloseDriver(); + } + +/** +@SYMTestCaseID GRAPHICS-RESOURCE-0017 +@SYMTestCaseDesc Gets the number of images in an image collection. +@SYMPREQ PREQ39 +@SYMREQ REQ9214 +@SYMREQ REQ9224 +@SYMREQ REQ9233 +@SYMREQ REQ9234 +@SYMFssID RSgImageCollection::Count())\n +@SYMTestPriority Critical +@SYMTestType Unit Test +@SYMTestPurpose To ensure the function returns the correct number of images. +@SYMTestActions Initialise the graphics resource component. Declare an image collection. Call Count(). + Create an image collection. Call Count() again. +@SYMTestExpectedResults First call should return zero. Second call should return the same value + as the one passed to the function at creation time. +@SYMTestStatus Implemented + */ +void CTSgImageCollectionGeneric::TestGetCollectionImageNumberL() + { + RSgImageCollection collection; + TInt number = collection.Count(); + TEST(0 == number); + TestOpenDriverL(); + CreateImageCollectionL(collection); + CleanupClosePushL(collection); + number = collection.Count(); + TEST(KNumImagesInCollection == number); + CleanupStack::PopAndDestroy(); + TestCloseDriver(); + } + +/** +@SYMTestCaseID GRAPHICS-RESOURCE-0018 +@SYMTestCaseDesc Calls GetInfo() on an image collection. +@SYMPREQ PREQ39 +@SYMREQ REQ9214 +@SYMREQ REQ9224 +@SYMREQ REQ9233 +@SYMREQ REQ9234 +@SYMFssID RSgImageCollection::GetInfo(TSgImageInfo&)\n +@SYMTestPriority Critical +@SYMTestType Unit Test +@SYMTestPurpose To ensure the information about the images in a collection can be correctly returned. +@SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object and + Initialise all the member variables. Create an image collection. Call GetInfo() and + compare the returned TSgImageInfo object with the original one. +@SYMTestExpectedResults The function should return KErrNone and the returned information should be the + same as the old one. +@SYMTestStatus Implemented + */ +void CTSgImageCollectionGeneric::TestGetImageInfoInCollectionL() + { + TestOpenDriverL(); + TSgImageInfo info; + info.iSizeInPixels = TSize(8, 8); + info.iUsage = ESgUsageDirectGdiTarget; + info.iPixelFormat = EUidPixelFormatRGB_565; + + RSgImageCollection collection; + CheckErrorL(KErrNone, collection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__); + CleanupClosePushL(collection); + TEST(!collection.IsNull()); + + TSgImageInfo info2; + TEST(KErrNone == collection.GetInfo(info2)); + TEST(CompareInfos(info, info2)); + CleanupStack::PopAndDestroy(); + + //get info with user attributes + TSgUserAttribute testAttributes[2] = {{0x00008888, 1}, {0x00009999, 2}}; + info.iUserAttributes = testAttributes; + info.iUserAttributeCount = 2; + CheckErrorL(KErrNone, collection.Create(info, KNumImagesInCollection), (TText8*)__FILE__, __LINE__); + CleanupClosePushL(collection); + TSgImageInfo info3; + TSgUserAttribute testAttributes2[2] = {{0x00008888, 0}, {0x00009999, 0}}; + info3.iUserAttributes = testAttributes2; + info3.iUserAttributeCount = 2; + TEST(KErrNone == collection.GetInfo(info3)); + TEST(CompareInfos(info, info3)); + CleanupStack::PopAndDestroy(); + + TestCloseDriver(); + } + +/** +@SYMTestCaseID GRAPHICS-RESOURCE-0019 +@SYMTestCaseDesc Gets image at a specific location in an image collection. +@SYMPREQ PREQ39 +@SYMREQ REQ9214 +@SYMREQ REQ9224 +@SYMREQ REQ9233 +@SYMREQ REQ9234 +@SYMFssID RSgImageCollection::OpenImage()\n +@SYMTestPriority Critical +@SYMTestType Unit Test +@SYMTestPurpose To ensure an image at a specific location can be returned. +@SYMTestActions Initialise the graphics resource component. Create the image collection. Call OpenImage() to + return all the images in order. +@SYMTestExpectedResults All the images are returned successfully. +@SYMTestStatus Implemented + */ +void CTSgImageCollectionGeneric::TestOpenImageInCollectionL() + { + TestOpenDriverL(); + RSgImageCollection collection; + CreateImageCollectionL(collection); + CleanupClosePushL(collection); + + TSgImageInfo info1; + collection.GetInfo(info1); + + for(TInt i=0; i