os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tsgimagegeneric.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tsgimagegeneric.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1757 @@
1.4 +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 + @internalComponent - Graphics Resource API Conformance Test Suite
1.23 +*/
1.24 +
1.25 +
1.26 +#include "tsgimagegeneric.h"
1.27 +
1.28 +#include <e32math.h>
1.29 +
1.30 +CTSgImageGeneric::CTSgImageGeneric(TBool aConformanceTests) :
1.31 + CTSgTestStepBase(aConformanceTests)
1.32 + {
1.33 + INFO_PRINTF1(_L("Graphics resource component test - RSgImage Generic Tests.\r\n"));
1.34 + }
1.35 +
1.36 +CTSgImageGeneric::~CTSgImageGeneric()
1.37 + {
1.38 + DestroyImages();
1.39 + }
1.40 +
1.41 +void CTSgImageGeneric::DestroyImages()
1.42 + {
1.43 + TInt count = iTestImages.Count();
1.44 + for(TInt i=0; i<count; ++i)
1.45 + {
1.46 + iTestImages[i].Close();
1.47 + }
1.48 + iTestImages.Reset();
1.49 + }
1.50 +
1.51 +/**
1.52 +Overrides of base class pure virtual
1.53 +Our implementation only gets called if the base class doTestStepPreambleL() did
1.54 +not leave. That being the case, the current test result value will be EPass.
1.55 +@leave Gets system wide error code
1.56 +@return TVerdict code
1.57 +*/
1.58 +TVerdict CTSgImageGeneric::doTestStepL()
1.59 + {
1.60 + SetTestStepID(_L("GRAPHICS-RESOURCE-0003"));
1.61 + INFO_PRINTF1(_L("Getting pixel formats supported on all platforms.\r\n"));
1.62 + TestGetPixelFormatsL();
1.63 + RecordTestResultL();
1.64 +
1.65 + SetTestStepID(_L("GRAPHICS-RESOURCE-0004"));
1.66 + INFO_PRINTF1(_L("Create an uninitialised image.\r\n"));
1.67 + TestCreateImageUninitializedL();
1.68 + RecordTestResultL();
1.69 +
1.70 + SetTestStepID(_L("GRAPHICS-RESOURCE-0005"));
1.71 + INFO_PRINTF1(_L("Create an image from a block of memory.\r\n"));
1.72 + TestCreateImageL();
1.73 + RecordTestResultL();
1.74 +
1.75 + SetTestStepID(_L("GRAPHICS-RESOURCE-0011"));
1.76 + INFO_PRINTF1(_L("Ensure all mandatory image pixel formats supported.\r\n"));
1.77 + TestCreateImageAllPixelFormatsL();
1.78 + RecordTestResultL();
1.79 +
1.80 + SetTestStepID(_L("GRAPHICS-RESOURCE-0006"));
1.81 + INFO_PRINTF1(_L("Create an image from an existing image.\r\n"));
1.82 + TestCreateImageFromExistingImageL();
1.83 + RecordTestResultL();
1.84 +
1.85 + SetTestStepID(_L("GRAPHICS-RESOURCE-0007"));
1.86 + INFO_PRINTF1(_L("Getting information about the image.\r\n"));
1.87 + TestGetImageInfoL();
1.88 + RecordTestResultL();
1.89 +
1.90 + SetTestStepID(_L("GRAPHICS-RESOURCE-0008"));
1.91 + INFO_PRINTF1(_L("Retrieving drawable id of an image.\r\n"));
1.92 + TestGetImageDrawableIdL();
1.93 + RecordTestResultL();
1.94 +
1.95 + SetTestStepID(_L("GRAPHICS-RESOURCE-0010"));
1.96 + INFO_PRINTF1(_L("Opening a handle to an image in both the current process and another process.\r\n"));
1.97 + TestOpenImageL();
1.98 + RecordTestResultL();
1.99 +
1.100 + SetTestStepID(_L("GRAPHICS-RESOURCE-0100"));
1.101 + INFO_PRINTF1(_L("Creating images with negative and invalid data strides.\r\n"));
1.102 + TestCreateImageDataStrideL();
1.103 + RecordTestResultL();
1.104 +
1.105 + SetTestStepID(_L("GRAPHICS-RESOURCE-0044"));
1.106 + INFO_PRINTF1(_L("Getting the available interfaces from an image.\r\n"));
1.107 + TestGetInterfaceL();
1.108 + RecordTestResultL();
1.109 +
1.110 + SetTestStepID(_L("GRAPHICS-RESOURCE-0024"));
1.111 + INFO_PRINTF1(_L("Getting supported pixel formats with invalid parameters.\r\n"));
1.112 + TestGetPixelFormatsInvalidL();
1.113 + RecordTestResultL();
1.114 +
1.115 + SetTestStepID(_L("GRAPHICS-RESOURCE-0025"));
1.116 + INFO_PRINTF1(_L("Opening an image with different invalid parameters.\r\n"));
1.117 + TestOpenImageInvalidL();
1.118 + RecordTestResultL();
1.119 +
1.120 + SetTestStepID(_L("GRAPHICS-RESOURCE-0026"));
1.121 + INFO_PRINTF1(_L("Closing the handle to an image object multiple times.\r\n"));
1.122 + TestCloseImageManyTimesL();
1.123 + RecordTestResultL();
1.124 +
1.125 + SetTestStepID(_L("GRAPHICS-RESOURCE-0027"));
1.126 + INFO_PRINTF1(_L("Closing the handle to an image object without opening it.\r\n"));
1.127 + TestCloseImageWithoutOpenL();
1.128 + RecordTestResultL();
1.129 +
1.130 + SetTestStepID(_L("GRAPHICS-RESOURCE-0028"));
1.131 + INFO_PRINTF1(_L("Creating an image with various invalid parameters.\r\n"));
1.132 + TestCreateImageInvalidL();
1.133 + RecordTestResultL();
1.134 +
1.135 + SetTestStepID(_L("GRAPHICS-RESOURCE-0039"));
1.136 + INFO_PRINTF1(_L("Getting information about an invalid image.\r\n"));
1.137 + TestGetInfoImageInvalidL();
1.138 + RecordTestResultL();
1.139 +
1.140 + SetTestStepID(_L("GRAPHICS-RESOURCE-0092"));
1.141 + INFO_PRINTF1(_L("Getting Attributes about an invalid image.\r\n"));
1.142 + TestGetAttributesImageInvalidL();
1.143 + RecordTestResultL();
1.144 +
1.145 + SetTestStepID(_L("GRAPHICS-RESOURCE-0048"));
1.146 + INFO_PRINTF1(_L("RSgImage generic stress test.\r\n"));
1.147 + TestStress1L();
1.148 + RecordTestResultL();
1.149 +
1.150 + SetTestStepID(_L("GRAPHICS-RESOURCE-0049"));
1.151 + INFO_PRINTF1(_L("RSgImage generic multi-thread stress test.\r\n"));
1.152 + TestStress2L();
1.153 + RecordTestResultL();
1.154 +
1.155 + SetTestStepID(_L("GRAPHICS-RESOURCE-0104"));
1.156 + INFO_PRINTF1(_L("Opening a RSgImage in a second process with multiple threads.\r\n"));
1.157 + TestOpenImageMultithreadedL();
1.158 + RecordTestResultL();
1.159 +
1.160 +#ifdef _DEBUG
1.161 +
1.162 + SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
1.163 + INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with non null image handle and uninitialised driver\r\n"));
1.164 + TestPanicImageGetInterfaceNoDriverL();
1.165 + RecordTestResultL();
1.166 +
1.167 + SetTestStepID(_L("GRAPHICS-RESOURCE-0054"));
1.168 + INFO_PRINTF1(_L("RSgImage generic panic test - Close() with non null image handle and uninitialised driver\r\n"));
1.169 + TestPanicImageCloseNoDriverL();
1.170 + RecordTestResultL();
1.171 +
1.172 + SetTestStepID(_L("GRAPHICS-RESOURCE-0056"));
1.173 + INFO_PRINTF1(_L("RSgImage generic panic test - Id() with non null image handle and uninitialised driver\r\n"));
1.174 + TestPanicImageIdNoDriverL();
1.175 + RecordTestResultL();
1.176 +
1.177 + SetTestStepID(_L("GRAPHICS-RESOURCE-0059"));
1.178 + INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with non null image handle and uninitialised driver\r\n"));
1.179 + TestPanicImageGetInfoNoDriverL();
1.180 + RecordTestResultL();
1.181 +
1.182 + SetTestStepID(_L("GRAPHICS-RESOURCE-0082"));
1.183 + INFO_PRINTF1(_L("RSgImage generic panic test - Open() with an uninitialised driver\r\n"));
1.184 + TestPanicImageOpenNoDriverL();
1.185 + RecordTestResultL();
1.186 +
1.187 + SetTestStepID(_L("GRAPHICS-RESOURCE-0083"));
1.188 + INFO_PRINTF1(_L("RSgImage generic panic test - Create() from memory with an uninitialised driver\r\n"));
1.189 + TestPanicImageCreateNoDriver1L();
1.190 + RecordTestResultL();
1.191 +
1.192 + SetTestStepID(_L("GRAPHICS-RESOURCE-0084"));
1.193 + INFO_PRINTF1(_L("RSgImage generic panic test - Create() from existing image with an uninitialised driver\r\n"));
1.194 + TestPanicImageCreateNoDriver2L();
1.195 + RecordTestResultL();
1.196 +
1.197 + SetTestStepID(_L("GRAPHICS-RESOURCE-0088"));
1.198 + INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with an uninitialised driver\r\n"));
1.199 + TestPanicImageDrawableTypeNoDriverL();
1.200 + RecordTestResultL();
1.201 +
1.202 + INFO_PRINTF1(_L("RSgImage generic panic test - GetAttribute() with an uninitialised driver\r\n"));
1.203 + TestPanicImageGetAttributeNoDriverL();
1.204 + RecordTestResultL();
1.205 +
1.206 + SetTestStepID(_L("GRAPHICS-RESOURCE-0097"));
1.207 + INFO_PRINTF1(_L("RSgAttributeArray generic panic test - Out of bounds array index specified\r\n"));
1.208 + TestPanicImageAttributeArrayInvalidIndexL();
1.209 + RecordTestResultL();
1.210 +
1.211 + SetTestStepID(_L("GRAPHICS-RESOURCE-0098"));
1.212 + INFO_PRINTF1(_L("RSgAttributeArray generic panic test - Out of bounds array index specified\r\n"));
1.213 + TestPanicImageAttributeArrayInvalidIndex2L();
1.214 + RecordTestResultL();
1.215 +
1.216 + SetTestStepID(_L("GRAPHICS-RESOURCE-0102"));
1.217 + INFO_PRINTF1(_L("RSgDriver/RSgImage multi processs Create, Open and Close test\r\n"));
1.218 + TestCreateOpenCloseImageAndDriverInSecondThreadL();
1.219 + RecordTestResultL();
1.220 +
1.221 + SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
1.222 + INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with invalid image handle\r\n"));
1.223 + TestPanicImageGetInterfaceInvalidHandleL();
1.224 + RecordTestResultL();
1.225 +
1.226 + SetTestStepID(_L("GRAPHICS-RESOURCE-0053"));
1.227 + INFO_PRINTF1(_L("RSgImage generic panic test - Close() with invalid image handle\r\n"));
1.228 + TestPanicImageCloseInvalidHandleL();
1.229 + RecordTestResultL();
1.230 +
1.231 + SetTestStepID(_L("GRAPHICS-RESOURCE-0055"));
1.232 + INFO_PRINTF1(_L("RSgImage generic panic test - Id() with invalid image handle\r\n"));
1.233 + TestPanicImageIdInvalidHandleL();
1.234 + RecordTestResultL();
1.235 +
1.236 + SetTestStepID(_L("GRAPHICS-RESOURCE-0057"));
1.237 + INFO_PRINTF1(_L("RSgImage generic panic test - Create() with invalid image handle\r\n"));
1.238 + TestPanicImageCreateInvalidHandleL();
1.239 + RecordTestResultL();
1.240 +
1.241 + SetTestStepID(_L("GRAPHICS-RESOURCE-0058"));
1.242 + INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n"));
1.243 + TestPanicImageGetInfoInvalidHandleL();
1.244 + RecordTestResultL();
1.245 +
1.246 + SetTestStepID(_L("GRAPHICS-RESOURCE-0089"));
1.247 + INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with invalid image handle\r\n"));
1.248 + TestPanicImageDrawableTypeInvalidHandleL();
1.249 + RecordTestResultL();
1.250 +
1.251 + INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n"));
1.252 + TestPanicImageGetAttributeInvalidHandleL();
1.253 + RecordTestResultL();
1.254 +
1.255 + SetTestStepID(_L("GRAPHICS-RESOURCE-0101"));
1.256 + INFO_PRINTF1(_L("RSgDriver generic panic test - Closing a driver with open resources\r\n"));
1.257 + TestPanicDriverCloseOpenResourcesL();
1.258 + RecordTestResultL();
1.259 +#else
1.260 + INFO_PRINTF1(_L("Warning: Skipping the panic tests in release build. \r\n"));
1.261 +#endif
1.262 + return TestStepResult();
1.263 + }
1.264 +
1.265 +
1.266 +/**
1.267 +@SYMTestCaseID GRAPHICS-RESOURCE-0003
1.268 +@SYMTestCaseDesc Gets supported pixel formats on all platforms.
1.269 +@SYMPREQ PREQ2637
1.270 +@SYMFssID RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&)
1.271 +@SYMTestPriority High
1.272 +@SYMTestType UT
1.273 +@SYMTestPurpose To ensure all the available pixel formats are returned
1.274 + in the array.
1.275 +@SYMTestActions Initialise the graphics resource component.
1.276 + Construct an RArray to recieve the pixel formats.
1.277 + 1. Retrieve pixel formats with an RArray<TInt>. Check the array size.
1.278 + 2. Retrieve pixel formats when using an invalid usage bit value.
1.279 + 3. Retrieve pixel formats supporting OpenGL ES.
1.280 + 4. Retrieve pixel formats supporting OpenGL ES 2.
1.281 + 5. Ensure the mandated pixel formats are available
1.282 +@SYMTestExpectedResults The function must return:
1.283 + 1. KErrNone
1.284 + 2. KErrNone, but zero entries in the returned array.
1.285 + 3. KErrNone, and a non-zero array size.
1.286 + 4. KErrNone, and a non-zero array size.
1.287 + 5. The returned pixel formats should cover the pixel formats
1.288 + in the image compatibility table that works on all platforms.
1.289 + */
1.290 +void CTSgImageGeneric::TestGetPixelFormatsL()
1.291 + {
1.292 + TestOpenDriverL();
1.293 +
1.294 + //Retrieve the pixel formats
1.295 + RArray<TInt> pixelFormatArray;
1.296 + CheckErrorL(KErrNone, RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormatArray), (TText8*)__FILE__, __LINE__);
1.297 + TEST(pixelFormatArray.Count() > 0);
1.298 + pixelFormatArray.Reset();
1.299 +
1.300 + // invalid usage bit
1.301 + const TInt KInvalidUsageBit = 0x1000;
1.302 + CheckErrorL(KErrNone, RSgImage::GetPixelFormats(KInvalidUsageBit, pixelFormatArray), (TText8*)__FILE__, __LINE__);
1.303 + TEST(pixelFormatArray.Count() == 0);
1.304 + pixelFormatArray.Reset();
1.305 +
1.306 + //check all the pixel formats returned are in the common compatibility guarantees table
1.307 + TestGetPixelFormatCompatibilityGuaranteesL();
1.308 +
1.309 + TestCloseDriver();
1.310 + }
1.311 +
1.312 +/**
1.313 +@SYMTestCaseID GRAPHICS-RESOURCE-0004
1.314 +@SYMTestCaseDesc Creates an uninitialised image.
1.315 +@SYMPREQ PREQ2637
1.316 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
1.317 + RSgImage::IsNull()
1.318 +@SYMTestPriority Critical
1.319 +@SYMTestType UT
1.320 +@SYMTestPurpose To ensure an uninitialised image can be created.
1.321 +@SYMTestActions Initialise the graphics resource component.
1.322 + Construct a well-defined TSgImageInfo object to work on all platforms.
1.323 + Create an image with a NULL base address for the TSgImageInfo object.
1.324 +@SYMTestExpectedResults Create() should return KErrNone in all cases.
1.325 + The image data in the created images is uninitialised.
1.326 + */
1.327 +void CTSgImageGeneric::TestCreateImageUninitializedL()
1.328 + {
1.329 + TestOpenDriverL();
1.330 + TSgImageInfo info;
1.331 + info.iSizeInPixels = TSize(100, 100);
1.332 + info.iUsage = ESgUsageBitOpenVgImage;
1.333 + info.iPixelFormat = EUidPixelFormatRGB_565;
1.334 +
1.335 + RSgImage image;
1.336 + CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
1.337 + TEST(!image.IsNull());
1.338 + image.Close();
1.339 +
1.340 + TestCloseDriver();
1.341 + }
1.342 +
1.343 +
1.344 +/**
1.345 +@SYMTestCaseID GRAPHICS-RESOURCE-0005
1.346 +@SYMTestCaseDesc Creates an image from a block of memory.
1.347 +@SYMPREQ PREQ2637
1.348 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
1.349 + RSgImage::IsNull()
1.350 +@SYMTestPriority Critical
1.351 +@SYMTestType UT
1.352 +@SYMTestPurpose To ensure images can be created from a block of memory.
1.353 +@SYMTestActions Initialise the graphics resource component.
1.354 + Construct well-defined TSgImageInfo objects that work on all platforms.
1.355 + Create a block of memory with or without initialised data.
1.356 + Then create an image with the starting address of that memory.
1.357 +@SYMTestExpectedResults The function should return KErrNone in all cases.
1.358 + The user data starting at address aDataAddress will be populated into the new image.
1.359 + */
1.360 +void CTSgImageGeneric::TestCreateImageL()
1.361 + {
1.362 + TestOpenDriverL();
1.363 + TSgImageInfo info;
1.364 + info.iSizeInPixels = TSize(8, 8);
1.365 + info.iPixelFormat = EUidPixelFormatRGB_565;
1.366 + info.iUsage = ESgUsageBitOpenVgImage;
1.367 +
1.368 + RSgImage image;
1.369 + CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
1.370 + TEST(!image.IsNull());
1.371 + image.Close();
1.372 +
1.373 + //Ensure that it is possible to create an image of at least 2048x2048
1.374 + RSgImage image2;
1.375 + TSgImageInfo info2;
1.376 + info2.iSizeInPixels = TSize(2048, 2048);
1.377 + info2.iPixelFormat = EUidPixelFormatXRGB_8888;
1.378 + info2.iUsage = ESgUsageBitOpenVgImage;
1.379 +
1.380 + TEST(KErrNone == image2.Create(info2));
1.381 + image2.Close();
1.382 +
1.383 + info2.iSizeInPixels = TSize(KDiagonalImageSize, KDiagonalImageSize);
1.384 + // This should create an image with a green diagonal from top-left to bottom-right on white background
1.385 + TEST(KErrNone == image.Create(info2, iDiagonalImageData, KDiagonalImageDataStride));
1.386 + image.Close();
1.387 + // This should create an image with a green diagonal from top-right to bottom-left on white background
1.388 + TEST(KErrNone == image.Create(info2, iDiagonalImageData, -KDiagonalImageDataStride));
1.389 + image.Close();
1.390 +
1.391 + TestCloseDriver();
1.392 + }
1.393 +
1.394 +/**
1.395 +@SYMTestCaseID GRAPHICS-RESOURCE-0011
1.396 +@SYMTestCaseDesc Creates an uninitialised image in all mandatory pixel formats.
1.397 +@SYMPREQ PREQ2637
1.398 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
1.399 +@SYMTestPriority High
1.400 +@SYMTestType UT
1.401 +@SYMTestPurpose To ensure all mandatory image pixel formats are supported.
1.402 +@SYMTestActions Initialise the graphics resource component.
1.403 + Create an image with a NULL base address for each mandatory pixel
1.404 + format of Graphics Resource implementations.
1.405 +@SYMTestExpectedResults The function should return KErrNone in all cases.
1.406 + */
1.407 +void CTSgImageGeneric::TestCreateImageAllPixelFormatsL()
1.408 + {
1.409 + TestOpenDriverL();
1.410 +
1.411 + RSgImage image;
1.412 + const TSize KImageSize = TSize(8, 8);
1.413 + const TUint32 KImageUsage = ESgUsageBitOpenVgImage;
1.414 + TInt err = KErrNone;
1.415 +
1.416 + err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatA_8, KImageUsage), NULL, 0);
1.417 + TESTE(err == KErrNone, err);
1.418 + TEST(!image.IsNull());
1.419 + image.Close();
1.420 +
1.421 + err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatRGB_565, KImageUsage), NULL, 0);
1.422 + TESTE(err == KErrNone, err);
1.423 + TEST(!image.IsNull());
1.424 + image.Close();
1.425 +
1.426 + err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatXRGB_8888, KImageUsage), NULL, 0);
1.427 + TESTE(err == KErrNone, err);
1.428 + TEST(!image.IsNull());
1.429 + image.Close();
1.430 +
1.431 + err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888, KImageUsage), NULL, 0);
1.432 + TESTE(err == KErrNone, err);
1.433 + TEST(!image.IsNull());
1.434 + image.Close();
1.435 +
1.436 + err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888_PRE, KImageUsage), NULL, 0);
1.437 + TESTE(err == KErrNone, err);
1.438 + TEST(!image.IsNull());
1.439 + image.Close();
1.440 +
1.441 + TestCloseDriver();
1.442 + }
1.443 +
1.444 +/**
1.445 +@SYMTestCaseID GRAPHICS-RESOURCE-0006
1.446 +@SYMTestCaseDesc Creates an image from an existing image.
1.447 +@SYMPREQ PREQ2637
1.448 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&)
1.449 +@SYMTestPriority Critical
1.450 +@SYMTestType UT
1.451 +@SYMTestPurpose To ensure images can be created from existing images.
1.452 +@SYMTestActions Initialise the graphics resource component.
1.453 + Create an image.
1.454 + Create another image with the attributes of this image as the TSgImageInfo.
1.455 +@SYMTestExpectedResults The function should return KErrNone.
1.456 + The new image should be identical to the old one.
1.457 + */
1.458 +void CTSgImageGeneric::TestCreateImageFromExistingImageL()
1.459 + {
1.460 + RSgImage image1;
1.461 + RSgImage image2;
1.462 + TSgImageInfo info;
1.463 + info.iUsage = ESgUsageBitOpenVgImage;
1.464 +
1.465 + TestOpenDriverL();
1.466 + CreateImageL(image1);
1.467 + CleanupClosePushL(image1);
1.468 + TEST(KErrNone == image1.GetInfo(info));
1.469 +
1.470 + info.iUsage = ESgUsageBitOpenVgImage;
1.471 + CheckErrorL(KErrNone, image2.Create(info, image1), (TText8*)__FILE__, __LINE__);
1.472 + CleanupClosePushL(image2);
1.473 + TSgImageInfo info2;
1.474 + TEST(KErrNone == image2.GetInfo(info2));
1.475 + TEST(CompareInfos(info, info2));
1.476 + CleanupStack::PopAndDestroy(2);
1.477 + TestCloseDriver();
1.478 + }
1.479 +
1.480 +
1.481 +/**
1.482 +@SYMTestCaseID GRAPHICS-RESOURCE-0007
1.483 +@SYMTestCaseDesc Calls GetInfo on an image.
1.484 +@SYMPREQ PREQ2637
1.485 +@SYMFssID RSgImage::GetInfo(TSgImageInfo&)
1.486 +@SYMTestPriority Critical
1.487 +@SYMTestType UT
1.488 +@SYMTestPurpose To ensure the information about the image is correct.
1.489 +@SYMTestActions Initialise the graphics resource component.
1.490 + Construct a TSgImageInfo object and initialise all the member variables.
1.491 + Call GetInfo() and compare the resulting TSgImageInfo objects with previous ones.
1.492 +@SYMTestExpectedResults The function should return KErrNone.
1.493 + Information about the image object is stored in the aInfo parameter.
1.494 + The retrieved TSgImageInfo objects should be identical to the original ones.
1.495 + */
1.496 +void CTSgImageGeneric::TestGetImageInfoL()
1.497 + {
1.498 + TestOpenDriverL();
1.499 + TSgImageInfo info;
1.500 + info.iPixelFormat = EUidPixelFormatRGB_565;
1.501 + info.iSizeInPixels = TSize(100, 100);
1.502 + info.iUsage = ESgUsageBitOpenVgImage;
1.503 +
1.504 + RSgImage image;
1.505 + CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
1.506 + CleanupClosePushL(image);
1.507 +
1.508 + TSgImageInfo info2;
1.509 + TEST(KErrNone == image.GetInfo(info2));
1.510 + TEST(CompareInfos(info, info2));
1.511 + CleanupStack::PopAndDestroy();
1.512 +
1.513 + TestCloseDriver();
1.514 + }
1.515 +
1.516 +/**
1.517 +@SYMTestCaseID GRAPHICS-RESOURCE-0008
1.518 +@SYMTestCaseDesc Retrieves drawable id and drawable type of an image.
1.519 +@SYMPREQ PREQ2637
1.520 +@SYMFssID RSgImage::Id()
1.521 + RSgImage::DrawableType()
1.522 +@SYMTestPriority Critical
1.523 +@SYMTestType UT
1.524 +@SYMTestPurpose To ensure the globally unique drawable id of the image can be retrieved.
1.525 +@SYMTestActions Initialise the graphics resource component. Create an image. Call
1.526 + Id() to retrieve its drawable id.
1.527 +@SYMTestExpectedResults A valid drawable id should be successfully returned when the image has been opened.
1.528 + KSgNullDrawableId should be returned if it has not; the default drawable type should
1.529 + be KNullUid.
1.530 + */
1.531 +void CTSgImageGeneric::TestGetImageDrawableIdL()
1.532 + {
1.533 + RSgImage image;
1.534 + TEST(KNullUid == image.DrawableType());
1.535 + TSgDrawableId id = image.Id();
1.536 + TEST(id == KSgNullDrawableId);
1.537 + TestOpenDriverL();
1.538 +
1.539 + CreateImageL(image);
1.540 + id = image.Id();
1.541 + TEST(id != KSgNullDrawableId);
1.542 + TEST(KSgImageTypeUid == image.DrawableType());
1.543 +
1.544 + image.Close();
1.545 + TestCloseDriver();
1.546 + }
1.547 +
1.548 +/**
1.549 +@SYMTestCaseID GRAPHICS-RESOURCE-0010
1.550 +@SYMTestCaseDesc Opens a handle to an image in both the current process and another process.
1.551 +@SYMPREQ PREQ2637
1.552 +@SYMFssID RSgImage::Open(const TSgDrawableId&)
1.553 +@SYMTestPriority Critical
1.554 +@SYMTestType UT
1.555 +@SYMTestPurpose To ensure image can be opened in both a second thread in the current
1.556 + process and another process.
1.557 +@SYMTestActions Initialise the graphics resource component. Create an image and call
1.558 + Open() on the image in the second thread in the current process and in
1.559 + another process. To ensure they are correct compare their Id and attributes.
1.560 +@SYMTestExpectedResults The function must return KErrNone in all cases.
1.561 + */
1.562 +void CTSgImageGeneric::TestOpenImageL()
1.563 + {
1.564 + TestOpenDriverL();
1.565 +
1.566 + RSgImage image1;
1.567 + TSgImageInfo info1;
1.568 + info1.iSizeInPixels = TSize(8, 8);
1.569 + info1.iUsage = ESgUsageBitOpenVgImage;
1.570 + info1.iPixelFormat = EUidPixelFormatRGB_565;
1.571 + CheckErrorL(KErrNone, image1.Create(info1, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
1.572 +
1.573 + const TSgDrawableId id1 = image1.Id();
1.574 +
1.575 + //opening image in the current thread
1.576 + RSgImage image2;
1.577 + TEST(KErrNone == image2.Open(id1));
1.578 + TEST(image1.Id() == image2.Id());
1.579 +
1.580 + TSgImageInfo getInfo1;
1.581 + TSgImageInfo getInfo2;
1.582 +
1.583 + image1.GetInfo(getInfo1);
1.584 + image2.GetInfo(getInfo2);
1.585 +
1.586 + TEST(CompareInfos(info1, getInfo1));
1.587 + TEST(getInfo1.iPixelFormat == getInfo2.iPixelFormat
1.588 + && getInfo1.iSizeInPixels == getInfo2.iSizeInPixels
1.589 + && getInfo1.iUsage == getInfo2.iUsage);
1.590 +
1.591 + if (iEnableConformanceTests)
1.592 + {
1.593 + //opening image in a second thread in the current process
1.594 + TSgThreadTestInfo threadInfo(id1, info1, ESgresSecondThreadOpenImage);
1.595 + TInt testResult = 0;
1.596 + TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo));
1.597 + TEST(err == KErrNone);
1.598 + TEST(testResult >= 0);
1.599 +
1.600 + // Test the results from the second thread
1.601 + TEST(testResult & EFirstTestPassed);
1.602 + TEST(testResult & ESecondTestPassed);
1.603 + TEST(testResult & EThirdTestPassed);
1.604 + TEST(testResult & EFourthTestPassed);
1.605 + TEST(testResult & EFifthTestPassed);
1.606 + TEST(testResult & ESixthTestPassed);
1.607 + TEST(testResult & ESeventhTestPassed);
1.608 + TEST(testResult & EEighthTestPassed);
1.609 +
1.610 + //opening image in a second process
1.611 + TSgProcessTestInfo processInfo(id1, getInfo1, ESgresSecondProcessOpenImage);
1.612 + TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
1.613 + TEST(err == KErrNone);
1.614 + TEST(testResult >= 0);
1.615 +
1.616 + TEST(testResult & EFirstTestPassed);
1.617 + TEST(testResult & ESecondTestPassed);
1.618 + TEST(testResult & EThirdTestPassed);
1.619 + TEST(testResult & EFourthTestPassed);
1.620 + TEST(testResult & EFifthTestPassed);
1.621 + TEST(testResult & ESixthTestPassed);
1.622 + TEST(testResult & ESeventhTestPassed);
1.623 + }
1.624 +
1.625 + image1.Close();
1.626 + image2.Close();
1.627 +
1.628 + TestCloseDriver();
1.629 + }
1.630 +
1.631 +/**
1.632 +Fake RSgImage extension interface used in negative RSgImage::GetInterface() Tests
1.633 + */
1.634 +class MFake
1.635 + {
1.636 +public:
1.637 + enum { EInterfaceUid = 0x88888888 };
1.638 + };
1.639 +
1.640 +class MFakeNullUid
1.641 + {
1.642 +public:
1.643 + enum { EInterfaceUid = KNullUidValue};
1.644 + };
1.645 +
1.646 +/**
1.647 +@SYMTestCaseID GRAPHICS-RESOURCE-0044
1.648 +@SYMTestCaseDesc Gets an invalid/unsupported image extension interface
1.649 +@SYMPREQ PREQ2637
1.650 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
1.651 + RSgImage::GetInterface()
1.652 +@SYMTestPriority Low
1.653 +@SYMTestType UT
1.654 +@SYMTestPurpose Negative test to ensure the correct error code is returned when attempting
1.655 + to retrieve an invalid RSgImage extension interface.
1.656 +@SYMTestActions Initialise the graphics resource component. Create an image.
1.657 + 1. Declare an unsupported interface MFake and pass to GetInterface().
1.658 + 2. Declare an interface MFakeNullUid which has a null uid and pass to GetInterface().
1.659 +@SYMTestExpectedResults 1. GetInterface() should return KErrExtensionNotSupported.
1.660 + 2. GetInterface() should return KErrArgument since null uids are not acceptable.
1.661 + */
1.662 +void CTSgImageGeneric::TestGetInterfaceL()
1.663 + {
1.664 + TestOpenDriverL();
1.665 +
1.666 + TSgImageInfo info;
1.667 + info.iSizeInPixels = TSize(8, 8);
1.668 + info.iUsage = ESgUsageBitOpenVgImage;
1.669 + info.iPixelFormat = EUidPixelFormatRGB_565;
1.670 +
1.671 + RSgImage image;
1.672 +
1.673 + //fake interface
1.674 + MFake* smFake = reinterpret_cast<MFake*>(1);
1.675 + MFake* smFake2 = reinterpret_cast<MFake*>(1);
1.676 +
1.677 + //Check Calls to Get Interface on Null Image Handle
1.678 + TEST(KErrBadHandle == image.GetInterface(smFake));
1.679 + TEST(KErrBadHandle == image.GetInterface(smFake2));
1.680 + TEST(!smFake);
1.681 + TEST(!smFake2);
1.682 +
1.683 + CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
1.684 +
1.685 + // check TSgDrawableId is not NULL
1.686 + TSgDrawableId id = image.Id();
1.687 + TEST(KSgNullDrawableId != id);
1.688 +
1.689 + smFake = reinterpret_cast<MFake*>(1);
1.690 + smFake2 = reinterpret_cast<MFake*>(1);
1.691 +
1.692 + TEST(KErrExtensionNotSupported == image.GetInterface(smFake));
1.693 + TEST(!smFake);
1.694 +
1.695 + TEST(KErrExtensionNotSupported == image.GetInterface(smFake2));
1.696 + TEST(!smFake2);
1.697 +
1.698 + // null interface uid
1.699 + MFakeNullUid* smFake3 = NULL;
1.700 + TEST(KErrArgument == image.GetInterface(smFake3));
1.701 + TEST(!smFake3);
1.702 +
1.703 + image.Close();
1.704 +
1.705 + TestCloseDriver();
1.706 + }
1.707 +
1.708 +/**
1.709 +@SYMTestCaseID GRAPHICS-RESOURCE-0024
1.710 +@SYMTestCaseDesc Gets supported pixel formats with invalid parameters.
1.711 +@SYMPREQ PREQ2637
1.712 +@SYMFssID RSgImage::GetPixelFormats(TUint32, RArray<TInt>,
1.713 + const TSgAttributeArrayBase*)
1.714 +@SYMTestPriority Low
1.715 +@SYMTestType UT
1.716 +@SYMTestPurpose Negative test to ensure the correct error messages are returned when user tries to
1.717 + call GetPixelFormats() with invalid parameters.
1.718 +@SYMTestActions Initialise the graphics resource component. Call RSgImage::GetPixelFormats with:
1.719 + 1. Usage of 0
1.720 + 2. Invalid attribute array
1.721 + 3. Valid arguments
1.722 + 4. Pixel formats array is not empty
1.723 +@SYMTestExpectedResults RSgImage::GetPixelFormats() should return:
1.724 + 1. KErrArgument
1.725 + 2. KErrNotSupported
1.726 + 3. KErrNone
1.727 + 4. KErrArgument
1.728 + */
1.729 +void CTSgImageGeneric::TestGetPixelFormatsInvalidL()
1.730 + {
1.731 + RArray<TInt> pixelFormats;
1.732 + CleanupClosePushL(pixelFormats);
1.733 + TSgAttributeArray<1> attribArray;
1.734 + attribArray[0].iUid = KNullUid;
1.735 + attribArray[0].iValue = 0;
1.736 + TEST(attribArray.Count() == 1);
1.737 +
1.738 + TestOpenDriverL();
1.739 +
1.740 + TEST(KErrArgument == RSgImage::GetPixelFormats(0, pixelFormats));
1.741 + pixelFormats.Reset();
1.742 +
1.743 + TEST(KErrNotSupported == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats, &attribArray));
1.744 + pixelFormats.Reset();
1.745 +
1.746 + TEST(KErrNone == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats));
1.747 + TEST(pixelFormats.Count() > 0);
1.748 + //Don't reset pixel formats for next test
1.749 +
1.750 + TEST(KErrArgument == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats));
1.751 + pixelFormats.Reset();
1.752 +
1.753 + TestCloseDriver();
1.754 + CleanupStack::PopAndDestroy(&pixelFormats);
1.755 + }
1.756 +
1.757 +/**
1.758 +@SYMTestCaseID GRAPHICS-RESOURCE-0025
1.759 +@SYMTestCaseDesc Opens an image with different invalid and valid parameters.
1.760 +@SYMPREQ PREQ2637
1.761 +@SYMFssID RSgImage::Open(const TSgDrawableId&)
1.762 +@SYMTestPriority Medium
1.763 +@SYMTestType UT
1.764 +@SYMTestPurpose Negative test to check correct error messages are returned when opening
1.765 + image with different invalid parameters.
1.766 +@SYMTestActions Initialise the graphics resource component. Construct an RSgImage object.
1.767 + Call the Open() function in both the current process and another process with:
1.768 + 1. a non-null RSgImage handle
1.769 + 2. null drawable id
1.770 + 3. fake drawable id
1.771 + 4. a valid RSgImage handle
1.772 + Do the same tests in a second thread and a second process.
1.773 +@SYMTestExpectedResults The function should return:
1.774 + 1. KErrInUse
1.775 + 2. KErrArgument
1.776 + 3. KErrNotFound
1.777 + 4. KErrNone
1.778 + */
1.779 +void CTSgImageGeneric::TestOpenImageInvalidL()
1.780 + {
1.781 + TestOpenDriverL();
1.782 + //create a non-sharable image
1.783 + TSgImageInfo info;
1.784 + info.iSizeInPixels = TSize(8, 8);
1.785 + info.iUsage = ESgUsageBitOpenVgImage;
1.786 + info.iPixelFormat = EUidPixelFormatRGB_565;
1.787 +
1.788 + RSgImage image;
1.789 + CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
1.790 + CleanupClosePushL(image);
1.791 + const TSgDrawableId id = image.Id();
1.792 +
1.793 + //Attempt to create the image again using the same object
1.794 + TEST(KErrInUse == image.Create(info, KCrossImageData, KCrossImageDataStride));
1.795 +
1.796 + //same thread
1.797 + // non-empty handle
1.798 + RSgImage image1;
1.799 + CreateImageL(image1);
1.800 + CleanupClosePushL(image1);
1.801 + TEST(KErrInUse == image1.Open(id));
1.802 + image1.Close();
1.803 +
1.804 + // non-existing drawable id
1.805 + TSgDrawableId fakeid = {0xFFFFFFFFFFFFFFFFU};
1.806 + CheckErrorL(KErrNotFound, image1.Open(fakeid), (TText8*)__FILE__, __LINE__);
1.807 + image1.Close();
1.808 +
1.809 + if (iEnableConformanceTests)
1.810 + {
1.811 + //different thread in the same process
1.812 + TSgThreadTestInfo threadInfo(id, info, ESgresSecondThreadOpenImageInvalid);
1.813 + TInt testResult = 0;
1.814 + TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo));
1.815 + TEST(testResult >= 0);
1.816 + // Test the results from the second thread
1.817 + TEST(testResult & EFirstTestPassed);
1.818 + TEST(testResult & ESecondTestPassed);
1.819 + TEST(testResult & EThirdTestPassed);
1.820 + TEST(testResult & EFourthTestPassed);
1.821 + TEST(testResult & EFifthTestPassed);
1.822 +
1.823 + //different process
1.824 + TSgProcessTestInfo processInfo(id, info, ESgresSecondProcessOpenImageInvalid);
1.825 + TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
1.826 + TEST(testResult >= 0);
1.827 + TEST(testResult & EFirstTestPassed);
1.828 + TEST(testResult & ESecondTestPassed);
1.829 + TEST(testResult & EThirdTestPassed);
1.830 + TEST(testResult & EFourthTestPassed);
1.831 + TEST(testResult & EFifthTestPassed);
1.832 + }
1.833 +
1.834 + CleanupStack::PopAndDestroy(2);
1.835 + TestCloseDriver();
1.836 + }
1.837 +
1.838 +/**
1.839 +@SYMTestCaseID GRAPHICS-RESOURCE-0026
1.840 +@SYMTestCaseDesc Closes an image multiple times.
1.841 +@SYMPREQ PREQ2637
1.842 +@SYMFssID RSgImage::Close()
1.843 +@SYMTestPriority High
1.844 +@SYMTestType UT
1.845 +@SYMTestPurpose To check calling Close() multiple times after Open() does not cause
1.846 + errors or panics.
1.847 +@SYMTestActions Initialise the graphics resource component. Create an image and then
1.848 + call Close() three times on it.
1.849 +@SYMTestExpectedResults The function should not cause any errors or panics.
1.850 + */
1.851 +void CTSgImageGeneric::TestCloseImageManyTimesL()
1.852 + {
1.853 + TestOpenDriverL();
1.854 + RSgImage image;
1.855 + CreateImageL(image);
1.856 + TEST(!image.IsNull());
1.857 +
1.858 + image.Close();
1.859 + TEST(image.IsNull());
1.860 + image.Close();
1.861 + TEST(image.IsNull());
1.862 + image.Close();
1.863 + TEST(image.IsNull());
1.864 +
1.865 + TestCloseDriver();
1.866 + }
1.867 +
1.868 +
1.869 +/**
1.870 +@SYMTestCaseID GRAPHICS-RESOURCE-0027
1.871 +@SYMTestCaseDesc Closes an image object without opening it.
1.872 +@SYMPREQ PREQ2637
1.873 +@SYMFssID RSgImage::Close()
1.874 +@SYMTestPriority Medium
1.875 +@SYMTestType UT
1.876 +@SYMTestPurpose To check Close() does nothing if the image is not already opened.
1.877 +@SYMTestActions Initialise the graphics resource component. Declare an RSgImage object and
1.878 + call Close() on it.
1.879 +@SYMTestExpectedResults The function should not cause any errors or panics.
1.880 + */
1.881 +void CTSgImageGeneric::TestCloseImageWithoutOpenL()
1.882 + {
1.883 + TestOpenDriverL();
1.884 + RSgImage image;
1.885 + TEST(image.IsNull());
1.886 + image.Close();
1.887 + TEST(image.IsNull());
1.888 + TestCloseDriver();
1.889 + }
1.890 +
1.891 +/**
1.892 +@SYMTestCaseID GRAPHICS-RESOURCE-0028
1.893 +@SYMTestCaseDesc Creates an image with various invalid parameters.
1.894 +@SYMPREQ PREQ2637
1.895 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt, const TSgAttributeArrayBase* = NULL)
1.896 + RSgImage::Create(const TSgImageInfo&, const RSgImage&, const TSgAttributeArrayBase* = NULL)
1.897 +@SYMTestPriority Medium
1.898 +@SYMTestType UT
1.899 +@SYMTestPurpose Negative test to check the function returns the correct error messages when
1.900 + the parameters are invalid.
1.901 +@SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object
1.902 + and initialise the all the member variables with random values. Call the appropriate
1.903 + Create() function with:
1.904 + 1. invalid TSgImageInfo.iSizeInPixels
1.905 + 2. unsupported TSgImageInfo Pixel Format
1.906 + 3. the creating RSgImage handle is not null
1.907 + 4. the aSgImage handle is null
1.908 + 5. the size and pixel format in TSgImageInfo is not the same as that of aSgImage
1.909 + 6. the pixel stride specified is 0 when bitmap data is given
1.910 +@SYMTestExpectedResults The function should return
1.911 + 1. KErrArgument or KErrNotSupported for the overload taking an RSgImage
1.912 + 2. KErrNotSupported
1.913 + 3. KErrInUse
1.914 + 4. KErrArgument
1.915 + 5. KErrNotSupported
1.916 + 6. KErrArgument
1.917 + */
1.918 +void CTSgImageGeneric::TestCreateImageInvalidL()
1.919 + {
1.920 + TestOpenDriverL();
1.921 + RSgImage image;
1.922 +
1.923 + RSgImage validImage;
1.924 + TSgImageInfo validInfo(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
1.925 + TEST(KErrNone == validImage.Create(validInfo, KCrossImageData, KCrossImageDataStride));
1.926 +
1.927 + //invalid info 1 - invalid width
1.928 + TSgImageInfo info1(TSize(-100,100), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
1.929 + TEST(KErrArgument == image.Create(info1, NULL, 0));
1.930 + image.Close();
1.931 + TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride));
1.932 + image.Close();
1.933 + //invalid height
1.934 + info1.iSizeInPixels = TSize(100, -100);
1.935 + TEST(KErrArgument == image.Create(info1, NULL, 0));
1.936 + image.Close();
1.937 + //Sizes don't match
1.938 + TEST(KErrNotSupported == image.Create(info1, validImage));
1.939 + image.Close();
1.940 +
1.941 + info1.iSizeInPixels = TSize(0,0);
1.942 + TEST(KErrArgument == image.Create(info1, NULL, 0));
1.943 + image.Close();
1.944 + TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride));
1.945 + image.Close();
1.946 + //Sizes don't match
1.947 + TEST(KErrNotSupported == image.Create(info1, validImage));
1.948 + image.Close();
1.949 +
1.950 + //Invalid usage
1.951 + info1.iUsage = KMaxTUint32;
1.952 + info1.iSizeInPixels = TSize(8,8);
1.953 + TEST(KErrNotSupported == image.Create(info1, KCrossImageData, KCrossImageDataStride));
1.954 + image.Close();
1.955 + TEST(KErrNotSupported == image.Create(info1, validImage));
1.956 + image.Close();
1.957 +
1.958 + //unsupported info 1 - invalid pixel format
1.959 + TSgImageInfo info2;
1.960 + info2.iSizeInPixels = TSize(8, 8);
1.961 + info2.iUsage = ESgUsageBitOpenVgImage;
1.962 + info2.iPixelFormat = EUidPixelFormatUnknown;
1.963 + TEST(KErrArgument == image.Create(info2, NULL, 0));
1.964 + image.Close();
1.965 + TEST(KErrArgument == image.Create(info2, KCrossImageData, KCrossImageDataStride));
1.966 + image.Close();
1.967 +
1.968 + //unsupported info 2 - large image size
1.969 + info2.iPixelFormat = ESgPixelFormatRGB_565;
1.970 + info2.iSizeInPixels = TSize(40000, 100);
1.971 + TEST(KErrTooBig == image.Create(info2, NULL, 0));
1.972 + info2.iSizeInPixels = TSize(100, 40000);
1.973 + TEST(KErrTooBig == image.Create(info2, NULL, 0));
1.974 + image.Close();
1.975 +
1.976 + //non-null handle
1.977 + CreateImageL(image);
1.978 + TSgImageInfo info3;
1.979 + info3.iSizeInPixels = TSize(8, 8);
1.980 + info3.iUsage = ESgUsageBitOpenVgImage;
1.981 + info3.iPixelFormat = ESgPixelFormatRGB_565;
1.982 +
1.983 + TInt ret = image.Create(info3, NULL, 16);
1.984 + TEST(KErrInUse == ret);
1.985 +
1.986 + //non-null handle: create from an existing image
1.987 + RSgImage image1;
1.988 + CreateImageL(image1);
1.989 + TEST(KErrInUse == image1.Create(info3, image));
1.990 + image1.Close();
1.991 +
1.992 + //null existing image handle
1.993 + RSgImage image2;
1.994 + TEST(image2.IsNull());
1.995 + TEST(KErrArgument == image1.Create(info3, image2));
1.996 +
1.997 + //the size and pixel format in TSgImageInfo is not the same as that of aSgImage
1.998 + TSgImageInfo info4(TSize(100,100), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
1.999 + TEST(KErrNotSupported == image1.Create(info4, image));
1.1000 +
1.1001 + image1.GetInfo(info3);
1.1002 + info4.iSizeInPixels = info3.iSizeInPixels;
1.1003 + info4.iPixelFormat = ESgPixelFormatXRGB_8888;
1.1004 + TEST(KErrNotSupported == image1.Create(info4, image));
1.1005 +
1.1006 + image.Close();
1.1007 + image1.Close();
1.1008 +
1.1009 + TSgImageInfo info5(TSize(8,8), ESgPixelFormatRGB_565, ESgUsageBitOpenVgImage);
1.1010 +
1.1011 + TSgAttributeArray<1> attribArray;
1.1012 + attribArray[0].iUid = KNullUid;
1.1013 + attribArray[0].iValue = 0;
1.1014 +
1.1015 + TEST(KErrNotSupported == image1.Create(info5, KCrossImageData, KCrossImageDataStride, &attribArray));
1.1016 + image1.Close();
1.1017 +
1.1018 + //Stride of 0
1.1019 + TEST(KErrArgument == image1.Create(info5, KCrossImageData, 0));
1.1020 + image1.Close();
1.1021 +
1.1022 + validImage.Close();
1.1023 +
1.1024 + TestCloseDriver();
1.1025 + }
1.1026 +
1.1027 +/**
1.1028 +@SYMTestCaseID GRAPHICS-RESOURCE-0039
1.1029 +@SYMTestCaseDesc Calls GetInfo() on an invalid image.
1.1030 +@SYMPREQ PREQ2637
1.1031 +@SYMFssID RSgImage::GetInfo(TSgImageInfo&)
1.1032 +@SYMTestPriority Low
1.1033 +@SYMTestType UT
1.1034 +@SYMTestPurpose Negative test to check the correct error is returned when the client
1.1035 + tries to get information on an invalid image.
1.1036 +@SYMTestActions Initialise the graphics resource component.
1.1037 + Call GetInfo() on an image that is not initialised.
1.1038 +@SYMTestExpectedResults GetInfo() should return KErrBadHandle
1.1039 + */
1.1040 +void CTSgImageGeneric::TestGetInfoImageInvalidL()
1.1041 + {
1.1042 + TestOpenDriverL();
1.1043 + RSgImage image;
1.1044 + TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
1.1045 +
1.1046 + //uninitialised image
1.1047 + TEST(KErrBadHandle == image.GetInfo(info));
1.1048 +
1.1049 + TestCloseDriver();
1.1050 + }
1.1051 +
1.1052 +/**
1.1053 +@SYMTestCaseID GRAPHICS-RESOURCE-0092
1.1054 +@SYMTestCaseDesc Calls GetAttribute() on an invalid image.
1.1055 +@SYMPREQ PREQ2637
1.1056 +@SYMFssID RSgImage::GetAttribute(TUid, TInt&)
1.1057 +@SYMTestPriority Low
1.1058 +@SYMTestType UT
1.1059 +@SYMTestPurpose Negative test to check the correct error is returned when the client
1.1060 + tries to get attributes on an invalid image.
1.1061 +@SYMTestActions Initialise the graphics resource component.
1.1062 + Call GetInfo on an image that is not initialised.
1.1063 +@SYMTestExpectedResults GetAttribute() should return KErrBadHandle
1.1064 + */
1.1065 +void CTSgImageGeneric::TestGetAttributesImageInvalidL()
1.1066 + {
1.1067 + TestOpenDriverL();
1.1068 + RSgImage image;
1.1069 + TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
1.1070 +
1.1071 + TUid uid = {0x12345678};
1.1072 + TInt val = 0;
1.1073 + TEST(KErrBadHandle == image.GetAttribute(uid, val));
1.1074 +
1.1075 + image.Close();
1.1076 +
1.1077 + TestCloseDriver();
1.1078 + }
1.1079 +
1.1080 +/**
1.1081 +@SYMTestCaseID GRAPHICS-RESOURCE-0100
1.1082 +@SYMTestCaseDesc Creates images using negative and invalid data strides.
1.1083 +@SYMPREQ PREQ2637
1.1084 +@SYMFssID RSgImage::Create(TUid, TInt&)
1.1085 +@SYMTestPriority Medium
1.1086 +@SYMTestType UT
1.1087 +@SYMTestPurpose Positive test for using negative data strides.
1.1088 + Negative test for using invalid data strides.
1.1089 +@SYMTestActions Initialise the graphics resource component.
1.1090 + 1. Create an image with a data stride that is smaller than the width
1.1091 + of the image.
1.1092 + 2. Create an image with a pointer to bitmap data, but 0 data stride.
1.1093 + 3. Create an image with a negative data stride equal to the width
1.1094 + of the image.
1.1095 + 4. Create an image with a negative data stride less than the width
1.1096 + of the image.
1.1097 +@SYMTestExpectedResults 1. Create() should return KErrArgument.
1.1098 + 2. Create() should return KErrArgument.
1.1099 + 3. Create() should successfully create the image and return KErrNone.
1.1100 + 4. Create() should return KErrArgument.
1.1101 + */
1.1102 +void CTSgImageGeneric::TestCreateImageDataStrideL()
1.1103 + {
1.1104 + TestOpenDriverL();
1.1105 +
1.1106 + RSgImage image;
1.1107 + TSgImageInfo info1(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
1.1108 +
1.1109 + TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride-1));
1.1110 + image.Close();
1.1111 + TEST(KErrArgument == image.Create(info1, KCrossImageData, 0));
1.1112 + image.Close();
1.1113 +
1.1114 + TEST(KErrNone == image.Create(info1, KCrossImageData, -KCrossImageDataStride));
1.1115 + image.Close();
1.1116 +
1.1117 + TEST(KErrArgument == image.Create(info1, KCrossImageData, -KCrossImageDataStride+1));
1.1118 + image.Close();
1.1119 +
1.1120 + TestCloseDriver();
1.1121 + }
1.1122 +
1.1123 +/**
1.1124 +@SYMTestCaseID GRAPHICS-RESOURCE-0048
1.1125 +@SYMTestCaseDesc RSgImage stress tests
1.1126 +@SYMPREQ PREQ2637
1.1127 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
1.1128 + RSgImage::Close()
1.1129 +@SYMTestPriority Medium
1.1130 +@SYMTestType CT
1.1131 +@SYMTestPurpose To ensure creating and destroying RSgImage multiple times work well.
1.1132 +@SYMTestActions Create images 1000 times but only store KMaxImagesInArray of them
1.1133 + at one time in an RArray. When a new image is to be added to the
1.1134 + array, a random image from the array is removed.
1.1135 +@SYMTestExpectedResults There should be no panics or leaves.
1.1136 + */
1.1137 +void CTSgImageGeneric::TestStress1L()
1.1138 + {
1.1139 + TestOpenDriverL();
1.1140 + TSgImageInfo info;
1.1141 + info.iPixelFormat = EUidPixelFormatRGB_565;
1.1142 + info.iSizeInPixels = TSize(100, 100);
1.1143 + info.iUsage = ESgUsageBitOpenVgImage;
1.1144 +
1.1145 + TInt KMaxImagesInArray =40;
1.1146 + TInt64 seed = 0;
1.1147 + for (TInt count = 1000; count > 0; --count)
1.1148 + {
1.1149 + RSgImage image;
1.1150 + CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
1.1151 + CleanupClosePushL(image);
1.1152 + iTestImages.AppendL(image);
1.1153 + CleanupStack::Pop();
1.1154 + if (iTestImages.Count() >= KMaxImagesInArray)
1.1155 + {
1.1156 + TInt i = Math::Rand(seed) % KMaxImagesInArray;
1.1157 + iTestImages[i].Close();
1.1158 + iTestImages.Remove(i);
1.1159 + }
1.1160 + }
1.1161 + TInt count = iTestImages.Count();
1.1162 + for(TInt i=0; i<count; ++i)
1.1163 + {
1.1164 + iTestImages[i].Close();
1.1165 + }
1.1166 + iTestImages.Reset();
1.1167 + TestCloseDriver();
1.1168 + }
1.1169 +
1.1170 +/**
1.1171 +@SYMTestCaseID GRAPHICS-RESOURCE-0049
1.1172 +@SYMTestCaseDesc RSgImage multiple threads open and close stress tests
1.1173 +@SYMPREQ PREQ2637
1.1174 +@SYMFssID RSgImage::Open(const TSgDrawableId&)
1.1175 + RSgImage::Close()
1.1176 +@SYMTestPriority Medium
1.1177 +@SYMTestType CT
1.1178 +@SYMTestPurpose To ensure opening and destroying RSgImage multiple times and randomly
1.1179 + in other threads work well.
1.1180 +@SYMTestActions Create an image in the main thread. In a loop of 1000 times, randomly select
1.1181 + one of the five threads and either open or close the image depending on the
1.1182 + state of the thread.
1.1183 +@SYMTestExpectedResults There should be no panics or leaves.
1.1184 + */
1.1185 +void CTSgImageGeneric::TestStress2L()
1.1186 + {
1.1187 + TestOpenDriverL();
1.1188 + RSgImage image;
1.1189 + CreateImageL(image);
1.1190 + CleanupClosePushL(image);
1.1191 + const TSgDrawableId id = image.Id();
1.1192 +
1.1193 + TSgImageInfo info;
1.1194 + TEST(KErrNone == image.GetInfo(info));
1.1195 + TSgThreadTestInfo threadInfo(id, info, ESgresMultipleThreadStressTest);
1.1196 +
1.1197 + //create a semaphore
1.1198 + RSemaphore sem;
1.1199 + User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread));
1.1200 + CleanupClosePushL(sem);
1.1201 +
1.1202 + //create threads
1.1203 + const TInt KNoOfThreads = 5;
1.1204 + RArray<RThread> threads;
1.1205 + _LIT(KMultipleThreadName, "Multiple Threads Stress Test Thread ");
1.1206 + for (TInt i = 0; i < KNoOfThreads; ++i)
1.1207 + {
1.1208 + TBuf<50> threadName(KMultipleThreadName);
1.1209 + threadName.AppendNum(i);
1.1210 + RThread thread;
1.1211 + User::LeaveIfError(thread.Create(threadName, SgTestSecondThread::ThreadStart, KDefaultStackSize, KSecondThreadMinHeapSize, KSecondThreadMaxHeapSize, &threadInfo));
1.1212 + thread.SetPriority(EPriorityLess);
1.1213 + threads.AppendL(thread);
1.1214 + }
1.1215 + // run threads
1.1216 + for (TInt i = 0; i < KNoOfThreads; ++i)
1.1217 + {
1.1218 + threads[i].Resume();
1.1219 + }
1.1220 + // wait for the threads to terminate processing
1.1221 + for (TInt i = 0; i < KNoOfThreads; ++i)
1.1222 + {
1.1223 + sem.Wait();
1.1224 + }
1.1225 + for (TInt i = 0; i < KNoOfThreads; ++i)
1.1226 + {
1.1227 + threads[i].Close();
1.1228 + }
1.1229 + CleanupStack::PopAndDestroy(2, &image); // image, sem
1.1230 + TestCloseDriver();
1.1231 + }
1.1232 +
1.1233 +/**
1.1234 +@SYMTestCaseID GRAPHICS-RESOURCE-0051
1.1235 +@SYMTestCaseDesc Calls RSgImage::GetInterface() with an invalid image handle
1.1236 +@SYMPREQ PREQ2637
1.1237 +@SYMFssID RSgImage::GetInterface(TUid, TAny*&)
1.1238 +@SYMTestPriority Low
1.1239 +@SYMTestType UT
1.1240 +@SYMTestPurpose Negative test to ensure calling GetInterface() with an invalid image handle
1.1241 + will cause a panic.
1.1242 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1243 + Declare another image and assign it to the current image handle. Close the current
1.1244 + image so the second image handle becomes invalid. Call GetInterface() on the
1.1245 + second handle.
1.1246 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1.1247 + */
1.1248 +void CTSgImageGeneric::TestPanicImageGetInterfaceInvalidHandleL()
1.1249 + {
1.1250 + TSgImageInfo info(TSize(),0,0);
1.1251 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceInvalidHandle);
1.1252 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1253 + _LIT(KTestName, "TestImageGetInterfaceInvalidHandleLThread");
1.1254 + CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1.1255 + }
1.1256 +
1.1257 +/**
1.1258 +@SYMTestCaseID GRAPHICS-RESOURCE-0052
1.1259 +@SYMTestCaseDesc Calls RSgImage::GetInterface() with a non-null handle and an uninitialised driver
1.1260 +@SYMPREQ PREQ2637
1.1261 +@SYMFssID RSgImage::GetInterface(TUid, TAny*&)
1.1262 +@SYMTestPriority Low
1.1263 +@SYMTestType UT
1.1264 +@SYMTestPurpose Negative test to ensure calling GetInterface() with a non-null handle and an
1.1265 + uninitialised driver will cause a panic.
1.1266 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1267 + Declare another image and assign it to the current image handle. Close the current
1.1268 + image so the second image handle becomes invalid. Close the graphics resource driver.
1.1269 + Call GetInterface() on the second handle.
1.1270 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1271 + */
1.1272 +void CTSgImageGeneric::TestPanicImageGetInterfaceNoDriverL()
1.1273 + {
1.1274 + TSgImageInfo info(TSize(),0,0);
1.1275 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceNoDriver);
1.1276 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1277 + _LIT(KTestName, "TestImageGetInterfaceNoDriverL");
1.1278 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1279 + }
1.1280 +
1.1281 +/**
1.1282 +@SYMTestCaseID GRAPHICS-RESOURCE-0053
1.1283 +@SYMTestCaseDesc Calls RSgImage::Close() with an invalid image handle
1.1284 +@SYMPREQ PREQ2637
1.1285 +@SYMFssID RSgImage::Close()
1.1286 +@SYMTestPriority Low
1.1287 +@SYMTestType UT
1.1288 +@SYMTestPurpose Negative test to ensure calling Close() with an invalid image handle will
1.1289 + cause a panic.
1.1290 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1291 + Declare another image and assign it to the current image handle. Close the current
1.1292 + image so the second image handle becomes invalid. Call Close() on the second handle.
1.1293 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1.1294 + */
1.1295 +void CTSgImageGeneric::TestPanicImageCloseInvalidHandleL()
1.1296 + {
1.1297 + TSgImageInfo info(TSize(),0,0);
1.1298 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseInvalidHandle);
1.1299 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1300 + _LIT(KTestName, "TestImageCloseInvalidHandleL");
1.1301 + CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1.1302 + }
1.1303 +
1.1304 +/**
1.1305 +@SYMTestCaseID GRAPHICS-RESOURCE-0054
1.1306 +@SYMTestCaseDesc Calls RSgImage::Close() with a non-null handle and an uninitialised driver
1.1307 +@SYMPREQ PREQ2637
1.1308 +@SYMFssID RSgImage::Close()
1.1309 +@SYMTestPriority Low
1.1310 +@SYMTestType UT
1.1311 +@SYMTestPurpose Negative test to ensure calling Close() with a non-null handle and an
1.1312 + uninitialised driver will cause a panic.
1.1313 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1314 + Declare another image and assign it to the current image handle. Close the current
1.1315 + image so the second image handle becomes invalid. Close the graphics resource driver.
1.1316 + Call Close() on the second handle.
1.1317 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1318 + */
1.1319 +void CTSgImageGeneric::TestPanicImageCloseNoDriverL()
1.1320 + {
1.1321 + TSgImageInfo info(TSize(),0,0);
1.1322 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseNoDriver);
1.1323 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1324 + _LIT(KTestName, "TestImageCloseNoDriverL");
1.1325 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1326 + }
1.1327 +
1.1328 +/**
1.1329 +@SYMTestCaseID GRAPHICS-RESOURCE-0055
1.1330 +@SYMTestCaseDesc Calls RSgImage::Id() with an invalid image handle
1.1331 +@SYMPREQ PREQ2637
1.1332 +@SYMFssID RSgImage::Id()
1.1333 +@SYMTestPriority Low
1.1334 +@SYMTestType UT
1.1335 +@SYMTestPurpose Negative test to ensure calling Id() with an invalid image handle will
1.1336 + cause a panic.
1.1337 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1338 + Declare another image and assign it to the current image handle. Close the current
1.1339 + image so the second image handle becomes invalid. Call Id() on the second
1.1340 + handle.
1.1341 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1.1342 + */
1.1343 +void CTSgImageGeneric::TestPanicImageIdInvalidHandleL()
1.1344 + {
1.1345 + TSgImageInfo info(TSize(),0,0);
1.1346 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdInvalidHandle);
1.1347 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1348 + _LIT(KTestName, "TestImageIdInvalidHandleL");
1.1349 + CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1.1350 + }
1.1351 +
1.1352 +/**
1.1353 +@SYMTestCaseID GRAPHICS-RESOURCE-0056
1.1354 +@SYMTestCaseDesc Calls RSgImage::Id() with a non-null handle and an uninitialised driver
1.1355 +@SYMPREQ PREQ2637
1.1356 +@SYMFssID RSgImage::Id()
1.1357 +@SYMTestPriority Low
1.1358 +@SYMTestType UT
1.1359 +@SYMTestPurpose Negative test to ensure calling Id() with a non-null handle and an
1.1360 + uninitialised driver will cause a panic.
1.1361 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1362 + Declare another image and assign it to the current image handle. Close the current
1.1363 + image so the second image handle becomes invalid. Close the graphics resource driver.
1.1364 + Call Id() on the second handle.
1.1365 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1366 + */
1.1367 +void CTSgImageGeneric::TestPanicImageIdNoDriverL()
1.1368 + {
1.1369 + TSgImageInfo info(TSize(),0,0);
1.1370 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdNoDriver);
1.1371 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1372 + _LIT(KTestName, "TestImageIdNoDriverL");
1.1373 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1374 + }
1.1375 +
1.1376 +/**
1.1377 +@SYMTestCaseID GRAPHICS-RESOURCE-0057
1.1378 +@SYMTestCaseDesc Calls RSgImage::Create() with an invalid image handle
1.1379 +@SYMPREQ PREQ2637
1.1380 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&)
1.1381 +@SYMTestPriority Low
1.1382 +@SYMTestType UT
1.1383 +@SYMTestPurpose Negative test to ensure calling Create() with an invalid image handle will
1.1384 + cause a panic.
1.1385 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1386 + Declare another image and assign it to the current image handle. Close the current
1.1387 + image so the second image handle becomes invalid. Call Create() on the second
1.1388 + handle.
1.1389 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1.1390 + */
1.1391 +void CTSgImageGeneric::TestPanicImageCreateInvalidHandleL()
1.1392 + {
1.1393 + TSgImageInfo info(TSize(),0,0);
1.1394 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateInvalidHandle);
1.1395 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1396 + _LIT(KTestName, "TestImageCreateInvalidHandleL");
1.1397 + CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1.1398 + }
1.1399 +
1.1400 +/**
1.1401 +@SYMTestCaseID GRAPHICS-RESOURCE-0058
1.1402 +@SYMTestCaseDesc Calls RSgImage::GetInfo() with an invalid image handle
1.1403 +@SYMPREQ PREQ2637
1.1404 +@SYMFssID RSgImage::GetInfo(TSgImageInfo&)
1.1405 +@SYMTestPriority Low
1.1406 +@SYMTestType UT
1.1407 +@SYMTestPurpose Negative test to ensure calling GetInfo() with an invalid image handle will
1.1408 + cause a panic.
1.1409 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1410 + Declare another image and assign it to the current image handle. Close the current
1.1411 + image so the second image handle becomes invalid. Call GetInfo() on the second
1.1412 + handle.
1.1413 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1.1414 + */
1.1415 +void CTSgImageGeneric::TestPanicImageGetInfoInvalidHandleL()
1.1416 + {
1.1417 + TSgImageInfo info(TSize(),0,0);
1.1418 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoInvalidHandle);
1.1419 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1420 + _LIT(KTestName, "TestImageGetInfoInvalidHandleL");
1.1421 + CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1.1422 + }
1.1423 +
1.1424 +/**
1.1425 +@SYMTestCaseID GRAPHICS-RESOURCE-0059
1.1426 +@SYMTestCaseDesc Calls RSgImage::GetInfo() with a non-null handle and an uninitialised driver
1.1427 +@SYMPREQ PREQ2637
1.1428 +@SYMFssID SgImage::GetInfo(TSgImageInfo&)
1.1429 +@SYMTestPriority Low
1.1430 +@SYMTestType UT
1.1431 +@SYMTestPurpose Negative test to ensure calling GetInfo() with a non-null handle and an
1.1432 + uninitialised driver will cause a panic.
1.1433 +@SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1.1434 + Declare another image and assign it to the current image handle. Close the current
1.1435 + image so the second image handle becomes invalid. Close the graphics resource driver.
1.1436 + Call GetInfo() on the second handle.
1.1437 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1438 + */
1.1439 +void CTSgImageGeneric::TestPanicImageGetInfoNoDriverL()
1.1440 + {
1.1441 + TSgImageInfo info(TSize(),0,0);
1.1442 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoNoDriver);
1.1443 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1444 + _LIT(KTestName, "TestImageGetInfoNoDriverL");
1.1445 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1446 + }
1.1447 +
1.1448 +/**
1.1449 +@SYMTestCaseID GRAPHICS-RESOURCE-0082
1.1450 +@SYMTestCaseDesc Calls RSgImage::Open() when the driver was not initialised.
1.1451 +@SYMPREQ PREQ2637
1.1452 +@SYMFssID RSgImage::Open(const TSgDrawableId&, TUint32)
1.1453 +@SYMTestPriority Low
1.1454 +@SYMTestType UT
1.1455 +@SYMTestPurpose Negative test to ensure calling RSgImage::Open() with an uninitialised driver
1.1456 + will cause a panic.
1.1457 +@SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open()
1.1458 + in a second thread.
1.1459 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1460 + */
1.1461 +void CTSgImageGeneric::TestPanicImageOpenNoDriverL()
1.1462 + {
1.1463 + TSgImageInfo info(TSize(),0,0);
1.1464 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageOpenNoDriver);
1.1465 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1466 + _LIT(KTestName, "TestPanicImageOpenNoDriverL");
1.1467 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1468 + }
1.1469 +
1.1470 +/**
1.1471 +@SYMTestCaseID GRAPHICS-RESOURCE-0083
1.1472 +@SYMTestCaseDesc Creates an image from memory when the driver was not initialised.
1.1473 +@SYMPREQ PREQ2637
1.1474 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
1.1475 +@SYMTestPriority Low
1.1476 +@SYMTestType UT
1.1477 +@SYMTestPurpose Negative test to ensure calling RSgImage::Create() with an uninitialised
1.1478 + driver will cause a panic.
1.1479 +@SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open()
1.1480 + in a second thread.
1.1481 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1482 + */
1.1483 +void CTSgImageGeneric::TestPanicImageCreateNoDriver1L()
1.1484 + {
1.1485 + TSgImageInfo info(TSize(),0,0);
1.1486 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver1);
1.1487 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1488 + _LIT(KTestName, "TestPanicImageCreateNoDriver1L");
1.1489 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1490 + }
1.1491 +
1.1492 +/**
1.1493 +@SYMTestCaseID GRAPHICS-RESOURCE-0084
1.1494 +@SYMTestCaseDesc Creates an image from an existing image when the driver was not initialised.
1.1495 +@SYMPREQ PREQ2637
1.1496 +@SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&)
1.1497 +@SYMTestPriority Low
1.1498 +@SYMTestType UT
1.1499 +@SYMTestPurpose Negative test to ensure calling RSgImage::Create() with an uninitialised driver
1.1500 + will cause a panic.
1.1501 +@SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open() in
1.1502 + a second thread.
1.1503 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1504 + */
1.1505 +void CTSgImageGeneric::TestPanicImageCreateNoDriver2L()
1.1506 + {
1.1507 + TSgImageInfo info(TSize(),0,0);
1.1508 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver2);
1.1509 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1510 + _LIT(KTestName, "TestPanicImageCreateNoDriver2L");
1.1511 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1512 + }
1.1513 +
1.1514 +/**
1.1515 +@SYMTestCaseID GRAPHICS-RESOURCE-0088
1.1516 +@SYMTestCaseDesc Calls RSgImage::DrawableType() when the driver was not initialised.
1.1517 +@SYMPREQ PREQ2637
1.1518 +@SYMFssID RSgImage::DrawableType()
1.1519 +@SYMTestPriority Low
1.1520 +@SYMTestType UT
1.1521 +@SYMTestPurpose Negative test to ensure calling RSgImage::DrawableType() with an uninitialised
1.1522 + driver will cause a panic.
1.1523 +@SYMTestActions Do not initialise the graphics resource component and call RSgImage::DrawableType()
1.1524 + in a second thread.
1.1525 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1526 + */
1.1527 +void CTSgImageGeneric::TestPanicImageDrawableTypeNoDriverL()
1.1528 + {
1.1529 + TSgImageInfo info(TSize(),0,0);
1.1530 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeNoDriver);
1.1531 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1532 + _LIT(KTestName, "TestPanicImageOpenNoDriverL");
1.1533 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1534 + }
1.1535 +
1.1536 +/**
1.1537 +@SYMTestCaseID GRAPHICS-RESOURCE-0089
1.1538 +@SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle
1.1539 +@SYMPREQ PREQ2637
1.1540 +@SYMFssID RSgImage::DrawableType()
1.1541 +@SYMTestPriority Low
1.1542 +@SYMTestType UT
1.1543 +@SYMTestPurpose Negative test to ensure calling RSgImage::DrawableType() with an uninitialised
1.1544 + driver will cause a panic.
1.1545 +@SYMTestActions Do not initialise the graphics resource component and call RSgImage::DrawableType()
1.1546 + in a second thread.
1.1547 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle).
1.1548 + */
1.1549 +void CTSgImageGeneric::TestPanicImageDrawableTypeInvalidHandleL()
1.1550 + {
1.1551 + TSgImageInfo info(TSize(),0,0);
1.1552 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeInvalidHandle);
1.1553 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1554 + _LIT(KTestName, "TestPanicImageOpenNoDriverL");
1.1555 + CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1.1556 + }
1.1557 +
1.1558 +/**
1.1559 +@SYMTestCaseID GRAPHICS-RESOURCE-0090
1.1560 +@SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle
1.1561 +@SYMPREQ PREQ2637
1.1562 +@SYMFssID RSgImage::GetAttribute()
1.1563 +@SYMTestPriority Low
1.1564 +@SYMTestType UT
1.1565 +@SYMTestPurpose Negative test to ensure calling RSgImage::GetAttribute() with an invalid handle
1.1566 + will cause a panic.
1.1567 +@SYMTestActions Initialise the graphics resource component and call RSgImage::GetAttribute()
1.1568 + in a second thread with an invalid handle.
1.1569 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle).
1.1570 + */
1.1571 +void CTSgImageGeneric::TestPanicImageGetAttributeInvalidHandleL()
1.1572 + {
1.1573 + TSgImageInfo info(TSize(),0,0);
1.1574 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeInvalidHandle);
1.1575 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1576 + _LIT(KTestName, "TestPanicImageGetAttributeInvalidHandleL");
1.1577 + CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1.1578 + }
1.1579 +
1.1580 +/**
1.1581 +@SYMTestCaseID GRAPHICS-RESOURCE-0091
1.1582 +@SYMTestCaseDesc Calls RSgImage::GetAttribute() with no open driver
1.1583 +@SYMPREQ PREQ2637
1.1584 +@SYMFssID RSgImage::GetAttribute()
1.1585 +@SYMTestPriority Low
1.1586 +@SYMTestType UT
1.1587 +@SYMTestPurpose Negative test to ensure calling RSgImage::GetAttribute() with an uninitialised
1.1588 + driver will cause a panic.
1.1589 +@SYMTestActions Do not initialise the graphics resource component and call RSgImage::GetAttribute()
1.1590 + in a second thread.
1.1591 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1.1592 + */
1.1593 +void CTSgImageGeneric::TestPanicImageGetAttributeNoDriverL()
1.1594 + {
1.1595 + TSgImageInfo info(TSize(),0,0);
1.1596 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeNoDriver);
1.1597 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1598 + _LIT(KTestName, "TestPanicImageGetAttributeNoDriverL");
1.1599 + CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1.1600 + }
1.1601 +
1.1602 +/**
1.1603 +@SYMTestCaseID GRAPHICS-RESOURCE-0097
1.1604 +@SYMTestCaseDesc Access out of bound TSgAttibuteArray index
1.1605 +@SYMPREQ PREQ2637
1.1606 +@SYMFssID TSgAttributeArray
1.1607 +@SYMTestPriority Low
1.1608 +@SYMTestType UT
1.1609 +@SYMTestPurpose Negative test to ensure calling an out of bound index on a TSgAttributeArray
1.1610 + will cause a panic.
1.1611 +@SYMTestActions Create a TSgAttributeArray of size 5 and attempt to access an element higher
1.1612 + than the size.
1.1613 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex).
1.1614 + */
1.1615 +void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndexL()
1.1616 + {
1.1617 + TSgImageInfo info(TSize(),0,0);
1.1618 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex);
1.1619 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1620 + _LIT(KTestName, "AttributeArrayInvalidIndexL");
1.1621 + CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName);
1.1622 + }
1.1623 +
1.1624 +/**
1.1625 +@SYMTestCaseID GRAPHICS-RESOURCE-0098
1.1626 +@SYMTestCaseDesc Access out of bound TSgAttibuteArray index
1.1627 +@SYMPREQ PREQ2637
1.1628 +@SYMFssID TSgAttributeArray
1.1629 +@SYMTestPriority Low
1.1630 +@SYMTestType UT
1.1631 +@SYMTestPurpose Negative test to ensure calling an out of bound index on a TSgAttributeArray
1.1632 + will cause a panic.
1.1633 +@SYMTestActions Create a TSgAttributeArray of size 5 and attempt to access an element higher
1.1634 + than the size.
1.1635 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex).
1.1636 + */
1.1637 +void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndex2L()
1.1638 + {
1.1639 + TSgImageInfo info(TSize(),0,0);
1.1640 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex2);
1.1641 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1642 + _LIT(KTestName, "AttributeArrayInvalidIndexL");
1.1643 + CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName);
1.1644 + }
1.1645 +
1.1646 +/**
1.1647 +@SYMTestCaseID GRAPHICS-RESOURCE-0101
1.1648 +@SYMTestCaseDesc Close an RSgDriver with open resources
1.1649 +@SYMPREQ PREQ2637
1.1650 +@SYMFssID RSgDriver
1.1651 +@SYMTestPriority Low
1.1652 +@SYMTestType UT
1.1653 +@SYMTestPurpose Negative test to ensure closing a driver with open resources will cause a panic.
1.1654 +@SYMTestActions Create an RSgImage on an open driver, then close the driver.
1.1655 +@SYMTestExpectedResults Should panic in the second thread with panic code SGRES 2 (ESgPanicUnclosedResources).
1.1656 + */
1.1657 +void CTSgImageGeneric::TestPanicDriverCloseOpenResourcesL()
1.1658 + {
1.1659 + TSgImageInfo info(TSize(),0,0);
1.1660 + TSgProcessTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondProcessPanicDriverCloseOpenResources);
1.1661 + TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1.1662 + CreateSecondProcessAndCheckPanicL(threadInfo, 2, exitCategoryName, KSecondProcess);
1.1663 + }
1.1664 +
1.1665 +/**
1.1666 +@SYMTestCaseID GRAPHICS-RESOURCE-0102
1.1667 +@SYMTestCaseDesc Open/Close RSgDriver and Create/Close RSgImage in separate threads
1.1668 +@SYMPREQ PREQ2637
1.1669 +@SYMFssID RSgDriver, RSgImage
1.1670 +@SYMTestPriority High
1.1671 +@SYMTestType UT
1.1672 +@SYMTestPurpose To ensure that it is possible to Open/Close the RSgDriver from
1.1673 + a separate thread, and to ensure that it is possible to Create/Open/Close
1.1674 + RSgImages from a seperate thread.
1.1675 +@SYMTestActions 1. Declare a RSgDriver, and pass to another thread to open.
1.1676 + 2. Declare a RSgImage, and pass to another thread to create.
1.1677 + 3. Pass created RSgImage to another thread to Open().
1.1678 + 4. Pass the image to another thread to Close().
1.1679 + 5. Pass the RSgDriver to another thread to Close()
1.1680 +@SYMTestExpectedResults All steps to succeed with no errors reported.
1.1681 + */
1.1682 +void CTSgImageGeneric::TestCreateOpenCloseImageAndDriverInSecondThreadL()
1.1683 + {
1.1684 + TSgImageInfo info(TSize(),0,0);
1.1685 + TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadOpenPassedDriver);
1.1686 +
1.1687 + RSgDriver driver;
1.1688 + threadInfo.iSgDriver = &driver;
1.1689 +
1.1690 + RSgImage image;
1.1691 + threadInfo.iSgImage = ℑ
1.1692 +
1.1693 + //Open the driver in another thread
1.1694 + TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1.1695 +
1.1696 + //Create the image in a thread
1.1697 + threadInfo.iTestCase = ESgresSecondThreadCreatePassedImage;
1.1698 + TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1.1699 +
1.1700 + //Now try opening the image in another thread
1.1701 + RSgImage image2;
1.1702 + threadInfo.iTestCase = ESgresSecondThreadOpenPassedImage;
1.1703 + threadInfo.iDrawableId = image.Id();
1.1704 + threadInfo.iSgImage = &image2;
1.1705 + TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1.1706 +
1.1707 + //Close the "Opened" image in another thread
1.1708 + threadInfo.iTestCase = ESgresSecondThreadClosePassedImage;
1.1709 + TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1.1710 +
1.1711 + //Close the "Created" image in another thread
1.1712 + threadInfo.iTestCase = ESgresSecondThreadClosePassedImage;
1.1713 + threadInfo.iSgImage = ℑ
1.1714 + TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1.1715 +
1.1716 + //Close the driver in another thread
1.1717 + threadInfo.iTestCase = ESgresSecondThreadClosePassedDriver;
1.1718 + TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1.1719 + }
1.1720 +
1.1721 +/**
1.1722 +@SYMTestCaseID GRAPHICS-RESOURCE-0104
1.1723 +@SYMTestCaseDesc Open a RSgImage using multiple threads.
1.1724 +@SYMDEF ou1cimx1#197357
1.1725 +@SYMFssID RSgImage
1.1726 +@SYMTestPriority Low
1.1727 +@SYMTestType UT
1.1728 +@SYMTestPurpose To show that images can be opened safely when used with multiple threads in
1.1729 + separate processes.
1.1730 +@SYMTestActions 1. Process A, creates an RSgImage
1.1731 + 2. Process B, creates a secondary thread, which creates a handle to the image
1.1732 + created in A.
1.1733 + 3. Process B, primary thread opens a handle to the same image.
1.1734 + 4. Process B, secondary thread closes the handle and terminates thread.
1.1735 + 5. Process B, primary thread waits for thread cleanup, then attempts to
1.1736 + access the data of the image by creating a copy of it.
1.1737 +@SYMTestExpectedResults All steps to succeed with no errors reported.
1.1738 + */
1.1739 +void CTSgImageGeneric::TestOpenImageMultithreadedL()
1.1740 + {
1.1741 + TestOpenDriverL();
1.1742 + RSgImage image;
1.1743 + CreateImageL(image);
1.1744 + CleanupClosePushL(image);
1.1745 +
1.1746 + TSgImageInfo info;
1.1747 + TInt err = image.GetInfo(info);
1.1748 + TESTE(err == KErrNone, err);
1.1749 +
1.1750 + TSgProcessTestInfo processInfo(image.Id(), info, ESgresSecondProcessOpenImageMultithreaded);
1.1751 + TInt testResult = 0;
1.1752 + TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
1.1753 + TESTE(err == KErrNone, err);
1.1754 + TEST(testResult & EFirstTestPassed);
1.1755 + TEST(testResult & ESecondTestPassed);
1.1756 + TEST(testResult <= (EFirstTestPassed | ESecondTestPassed));
1.1757 +
1.1758 + CleanupStack::PopAndDestroy(1); // image
1.1759 + TestCloseDriver();
1.1760 + }