os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tsgimagegeneric.cpp
Update contrib.
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Graphics Resource API Conformance Test Suite
23 #include "tsgimagegeneric.h"
27 CTSgImageGeneric::CTSgImageGeneric(TBool aConformanceTests) :
28 CTSgTestStepBase(aConformanceTests)
30 INFO_PRINTF1(_L("Graphics resource component test - RSgImage Generic Tests.\r\n"));
33 CTSgImageGeneric::~CTSgImageGeneric()
38 void CTSgImageGeneric::DestroyImages()
40 TInt count = iTestImages.Count();
41 for(TInt i=0; i<count; ++i)
43 iTestImages[i].Close();
49 Overrides of base class pure virtual
50 Our implementation only gets called if the base class doTestStepPreambleL() did
51 not leave. That being the case, the current test result value will be EPass.
52 @leave Gets system wide error code
55 TVerdict CTSgImageGeneric::doTestStepL()
57 SetTestStepID(_L("GRAPHICS-RESOURCE-0003"));
58 INFO_PRINTF1(_L("Getting pixel formats supported on all platforms.\r\n"));
59 TestGetPixelFormatsL();
62 SetTestStepID(_L("GRAPHICS-RESOURCE-0004"));
63 INFO_PRINTF1(_L("Create an uninitialised image.\r\n"));
64 TestCreateImageUninitializedL();
67 SetTestStepID(_L("GRAPHICS-RESOURCE-0005"));
68 INFO_PRINTF1(_L("Create an image from a block of memory.\r\n"));
72 SetTestStepID(_L("GRAPHICS-RESOURCE-0011"));
73 INFO_PRINTF1(_L("Ensure all mandatory image pixel formats supported.\r\n"));
74 TestCreateImageAllPixelFormatsL();
77 SetTestStepID(_L("GRAPHICS-RESOURCE-0006"));
78 INFO_PRINTF1(_L("Create an image from an existing image.\r\n"));
79 TestCreateImageFromExistingImageL();
82 SetTestStepID(_L("GRAPHICS-RESOURCE-0007"));
83 INFO_PRINTF1(_L("Getting information about the image.\r\n"));
87 SetTestStepID(_L("GRAPHICS-RESOURCE-0008"));
88 INFO_PRINTF1(_L("Retrieving drawable id of an image.\r\n"));
89 TestGetImageDrawableIdL();
92 SetTestStepID(_L("GRAPHICS-RESOURCE-0010"));
93 INFO_PRINTF1(_L("Opening a handle to an image in both the current process and another process.\r\n"));
97 SetTestStepID(_L("GRAPHICS-RESOURCE-0100"));
98 INFO_PRINTF1(_L("Creating images with negative and invalid data strides.\r\n"));
99 TestCreateImageDataStrideL();
102 SetTestStepID(_L("GRAPHICS-RESOURCE-0044"));
103 INFO_PRINTF1(_L("Getting the available interfaces from an image.\r\n"));
107 SetTestStepID(_L("GRAPHICS-RESOURCE-0024"));
108 INFO_PRINTF1(_L("Getting supported pixel formats with invalid parameters.\r\n"));
109 TestGetPixelFormatsInvalidL();
112 SetTestStepID(_L("GRAPHICS-RESOURCE-0025"));
113 INFO_PRINTF1(_L("Opening an image with different invalid parameters.\r\n"));
114 TestOpenImageInvalidL();
117 SetTestStepID(_L("GRAPHICS-RESOURCE-0026"));
118 INFO_PRINTF1(_L("Closing the handle to an image object multiple times.\r\n"));
119 TestCloseImageManyTimesL();
122 SetTestStepID(_L("GRAPHICS-RESOURCE-0027"));
123 INFO_PRINTF1(_L("Closing the handle to an image object without opening it.\r\n"));
124 TestCloseImageWithoutOpenL();
127 SetTestStepID(_L("GRAPHICS-RESOURCE-0028"));
128 INFO_PRINTF1(_L("Creating an image with various invalid parameters.\r\n"));
129 TestCreateImageInvalidL();
132 SetTestStepID(_L("GRAPHICS-RESOURCE-0039"));
133 INFO_PRINTF1(_L("Getting information about an invalid image.\r\n"));
134 TestGetInfoImageInvalidL();
137 SetTestStepID(_L("GRAPHICS-RESOURCE-0092"));
138 INFO_PRINTF1(_L("Getting Attributes about an invalid image.\r\n"));
139 TestGetAttributesImageInvalidL();
142 SetTestStepID(_L("GRAPHICS-RESOURCE-0048"));
143 INFO_PRINTF1(_L("RSgImage generic stress test.\r\n"));
147 SetTestStepID(_L("GRAPHICS-RESOURCE-0049"));
148 INFO_PRINTF1(_L("RSgImage generic multi-thread stress test.\r\n"));
152 SetTestStepID(_L("GRAPHICS-RESOURCE-0104"));
153 INFO_PRINTF1(_L("Opening a RSgImage in a second process with multiple threads.\r\n"));
154 TestOpenImageMultithreadedL();
159 SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
160 INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with non null image handle and uninitialised driver\r\n"));
161 TestPanicImageGetInterfaceNoDriverL();
164 SetTestStepID(_L("GRAPHICS-RESOURCE-0054"));
165 INFO_PRINTF1(_L("RSgImage generic panic test - Close() with non null image handle and uninitialised driver\r\n"));
166 TestPanicImageCloseNoDriverL();
169 SetTestStepID(_L("GRAPHICS-RESOURCE-0056"));
170 INFO_PRINTF1(_L("RSgImage generic panic test - Id() with non null image handle and uninitialised driver\r\n"));
171 TestPanicImageIdNoDriverL();
174 SetTestStepID(_L("GRAPHICS-RESOURCE-0059"));
175 INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with non null image handle and uninitialised driver\r\n"));
176 TestPanicImageGetInfoNoDriverL();
179 SetTestStepID(_L("GRAPHICS-RESOURCE-0082"));
180 INFO_PRINTF1(_L("RSgImage generic panic test - Open() with an uninitialised driver\r\n"));
181 TestPanicImageOpenNoDriverL();
184 SetTestStepID(_L("GRAPHICS-RESOURCE-0083"));
185 INFO_PRINTF1(_L("RSgImage generic panic test - Create() from memory with an uninitialised driver\r\n"));
186 TestPanicImageCreateNoDriver1L();
189 SetTestStepID(_L("GRAPHICS-RESOURCE-0084"));
190 INFO_PRINTF1(_L("RSgImage generic panic test - Create() from existing image with an uninitialised driver\r\n"));
191 TestPanicImageCreateNoDriver2L();
194 SetTestStepID(_L("GRAPHICS-RESOURCE-0088"));
195 INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with an uninitialised driver\r\n"));
196 TestPanicImageDrawableTypeNoDriverL();
199 INFO_PRINTF1(_L("RSgImage generic panic test - GetAttribute() with an uninitialised driver\r\n"));
200 TestPanicImageGetAttributeNoDriverL();
203 SetTestStepID(_L("GRAPHICS-RESOURCE-0097"));
204 INFO_PRINTF1(_L("RSgAttributeArray generic panic test - Out of bounds array index specified\r\n"));
205 TestPanicImageAttributeArrayInvalidIndexL();
208 SetTestStepID(_L("GRAPHICS-RESOURCE-0098"));
209 INFO_PRINTF1(_L("RSgAttributeArray generic panic test - Out of bounds array index specified\r\n"));
210 TestPanicImageAttributeArrayInvalidIndex2L();
213 SetTestStepID(_L("GRAPHICS-RESOURCE-0102"));
214 INFO_PRINTF1(_L("RSgDriver/RSgImage multi processs Create, Open and Close test\r\n"));
215 TestCreateOpenCloseImageAndDriverInSecondThreadL();
218 SetTestStepID(_L("GRAPHICS-RESOURCE-0052"));
219 INFO_PRINTF1(_L("RSgImage generic panic test - GetInterface() with invalid image handle\r\n"));
220 TestPanicImageGetInterfaceInvalidHandleL();
223 SetTestStepID(_L("GRAPHICS-RESOURCE-0053"));
224 INFO_PRINTF1(_L("RSgImage generic panic test - Close() with invalid image handle\r\n"));
225 TestPanicImageCloseInvalidHandleL();
228 SetTestStepID(_L("GRAPHICS-RESOURCE-0055"));
229 INFO_PRINTF1(_L("RSgImage generic panic test - Id() with invalid image handle\r\n"));
230 TestPanicImageIdInvalidHandleL();
233 SetTestStepID(_L("GRAPHICS-RESOURCE-0057"));
234 INFO_PRINTF1(_L("RSgImage generic panic test - Create() with invalid image handle\r\n"));
235 TestPanicImageCreateInvalidHandleL();
238 SetTestStepID(_L("GRAPHICS-RESOURCE-0058"));
239 INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n"));
240 TestPanicImageGetInfoInvalidHandleL();
243 SetTestStepID(_L("GRAPHICS-RESOURCE-0089"));
244 INFO_PRINTF1(_L("RSgImage generic panic test - DrawableType() with invalid image handle\r\n"));
245 TestPanicImageDrawableTypeInvalidHandleL();
248 INFO_PRINTF1(_L("RSgImage generic panic test - GetInfo() with invalid image handle\r\n"));
249 TestPanicImageGetAttributeInvalidHandleL();
252 SetTestStepID(_L("GRAPHICS-RESOURCE-0101"));
253 INFO_PRINTF1(_L("RSgDriver generic panic test - Closing a driver with open resources\r\n"));
254 TestPanicDriverCloseOpenResourcesL();
257 INFO_PRINTF1(_L("Warning: Skipping the panic tests in release build. \r\n"));
259 return TestStepResult();
264 @SYMTestCaseID GRAPHICS-RESOURCE-0003
265 @SYMTestCaseDesc Gets supported pixel formats on all platforms.
267 @SYMFssID RSgImage::GetPixelFormats(const TSgImageInfo&, TUidPixelFormat*, TInt&)
268 @SYMTestPriority High
270 @SYMTestPurpose To ensure all the available pixel formats are returned
272 @SYMTestActions Initialise the graphics resource component.
273 Construct an RArray to recieve the pixel formats.
274 1. Retrieve pixel formats with an RArray<TInt>. Check the array size.
275 2. Retrieve pixel formats when using an invalid usage bit value.
276 3. Retrieve pixel formats supporting OpenGL ES.
277 4. Retrieve pixel formats supporting OpenGL ES 2.
278 5. Ensure the mandated pixel formats are available
279 @SYMTestExpectedResults The function must return:
281 2. KErrNone, but zero entries in the returned array.
282 3. KErrNone, and a non-zero array size.
283 4. KErrNone, and a non-zero array size.
284 5. The returned pixel formats should cover the pixel formats
285 in the image compatibility table that works on all platforms.
287 void CTSgImageGeneric::TestGetPixelFormatsL()
291 //Retrieve the pixel formats
292 RArray<TInt> pixelFormatArray;
293 CheckErrorL(KErrNone, RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormatArray), (TText8*)__FILE__, __LINE__);
294 TEST(pixelFormatArray.Count() > 0);
295 pixelFormatArray.Reset();
298 const TInt KInvalidUsageBit = 0x1000;
299 CheckErrorL(KErrNone, RSgImage::GetPixelFormats(KInvalidUsageBit, pixelFormatArray), (TText8*)__FILE__, __LINE__);
300 TEST(pixelFormatArray.Count() == 0);
301 pixelFormatArray.Reset();
303 //check all the pixel formats returned are in the common compatibility guarantees table
304 TestGetPixelFormatCompatibilityGuaranteesL();
310 @SYMTestCaseID GRAPHICS-RESOURCE-0004
311 @SYMTestCaseDesc Creates an uninitialised image.
313 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
315 @SYMTestPriority Critical
317 @SYMTestPurpose To ensure an uninitialised image can be created.
318 @SYMTestActions Initialise the graphics resource component.
319 Construct a well-defined TSgImageInfo object to work on all platforms.
320 Create an image with a NULL base address for the TSgImageInfo object.
321 @SYMTestExpectedResults Create() should return KErrNone in all cases.
322 The image data in the created images is uninitialised.
324 void CTSgImageGeneric::TestCreateImageUninitializedL()
328 info.iSizeInPixels = TSize(100, 100);
329 info.iUsage = ESgUsageBitOpenVgImage;
330 info.iPixelFormat = EUidPixelFormatRGB_565;
333 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
334 TEST(!image.IsNull());
342 @SYMTestCaseID GRAPHICS-RESOURCE-0005
343 @SYMTestCaseDesc Creates an image from a block of memory.
345 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
347 @SYMTestPriority Critical
349 @SYMTestPurpose To ensure images can be created from a block of memory.
350 @SYMTestActions Initialise the graphics resource component.
351 Construct well-defined TSgImageInfo objects that work on all platforms.
352 Create a block of memory with or without initialised data.
353 Then create an image with the starting address of that memory.
354 @SYMTestExpectedResults The function should return KErrNone in all cases.
355 The user data starting at address aDataAddress will be populated into the new image.
357 void CTSgImageGeneric::TestCreateImageL()
361 info.iSizeInPixels = TSize(8, 8);
362 info.iPixelFormat = EUidPixelFormatRGB_565;
363 info.iUsage = ESgUsageBitOpenVgImage;
366 CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
367 TEST(!image.IsNull());
370 //Ensure that it is possible to create an image of at least 2048x2048
373 info2.iSizeInPixels = TSize(2048, 2048);
374 info2.iPixelFormat = EUidPixelFormatXRGB_8888;
375 info2.iUsage = ESgUsageBitOpenVgImage;
377 TEST(KErrNone == image2.Create(info2));
380 info2.iSizeInPixels = TSize(KDiagonalImageSize, KDiagonalImageSize);
381 // This should create an image with a green diagonal from top-left to bottom-right on white background
382 TEST(KErrNone == image.Create(info2, iDiagonalImageData, KDiagonalImageDataStride));
384 // This should create an image with a green diagonal from top-right to bottom-left on white background
385 TEST(KErrNone == image.Create(info2, iDiagonalImageData, -KDiagonalImageDataStride));
392 @SYMTestCaseID GRAPHICS-RESOURCE-0011
393 @SYMTestCaseDesc Creates an uninitialised image in all mandatory pixel formats.
395 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
396 @SYMTestPriority High
398 @SYMTestPurpose To ensure all mandatory image pixel formats are supported.
399 @SYMTestActions Initialise the graphics resource component.
400 Create an image with a NULL base address for each mandatory pixel
401 format of Graphics Resource implementations.
402 @SYMTestExpectedResults The function should return KErrNone in all cases.
404 void CTSgImageGeneric::TestCreateImageAllPixelFormatsL()
409 const TSize KImageSize = TSize(8, 8);
410 const TUint32 KImageUsage = ESgUsageBitOpenVgImage;
413 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatA_8, KImageUsage), NULL, 0);
414 TESTE(err == KErrNone, err);
415 TEST(!image.IsNull());
418 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatRGB_565, KImageUsage), NULL, 0);
419 TESTE(err == KErrNone, err);
420 TEST(!image.IsNull());
423 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatXRGB_8888, KImageUsage), NULL, 0);
424 TESTE(err == KErrNone, err);
425 TEST(!image.IsNull());
428 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888, KImageUsage), NULL, 0);
429 TESTE(err == KErrNone, err);
430 TEST(!image.IsNull());
433 err = image.Create(TSgImageInfo(KImageSize, EUidPixelFormatARGB_8888_PRE, KImageUsage), NULL, 0);
434 TESTE(err == KErrNone, err);
435 TEST(!image.IsNull());
442 @SYMTestCaseID GRAPHICS-RESOURCE-0006
443 @SYMTestCaseDesc Creates an image from an existing image.
445 @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&)
446 @SYMTestPriority Critical
448 @SYMTestPurpose To ensure images can be created from existing images.
449 @SYMTestActions Initialise the graphics resource component.
451 Create another image with the attributes of this image as the TSgImageInfo.
452 @SYMTestExpectedResults The function should return KErrNone.
453 The new image should be identical to the old one.
455 void CTSgImageGeneric::TestCreateImageFromExistingImageL()
460 info.iUsage = ESgUsageBitOpenVgImage;
463 CreateImageL(image1);
464 CleanupClosePushL(image1);
465 TEST(KErrNone == image1.GetInfo(info));
467 info.iUsage = ESgUsageBitOpenVgImage;
468 CheckErrorL(KErrNone, image2.Create(info, image1), (TText8*)__FILE__, __LINE__);
469 CleanupClosePushL(image2);
471 TEST(KErrNone == image2.GetInfo(info2));
472 TEST(CompareInfos(info, info2));
473 CleanupStack::PopAndDestroy(2);
479 @SYMTestCaseID GRAPHICS-RESOURCE-0007
480 @SYMTestCaseDesc Calls GetInfo on an image.
482 @SYMFssID RSgImage::GetInfo(TSgImageInfo&)
483 @SYMTestPriority Critical
485 @SYMTestPurpose To ensure the information about the image is correct.
486 @SYMTestActions Initialise the graphics resource component.
487 Construct a TSgImageInfo object and initialise all the member variables.
488 Call GetInfo() and compare the resulting TSgImageInfo objects with previous ones.
489 @SYMTestExpectedResults The function should return KErrNone.
490 Information about the image object is stored in the aInfo parameter.
491 The retrieved TSgImageInfo objects should be identical to the original ones.
493 void CTSgImageGeneric::TestGetImageInfoL()
497 info.iPixelFormat = EUidPixelFormatRGB_565;
498 info.iSizeInPixels = TSize(100, 100);
499 info.iUsage = ESgUsageBitOpenVgImage;
502 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
503 CleanupClosePushL(image);
506 TEST(KErrNone == image.GetInfo(info2));
507 TEST(CompareInfos(info, info2));
508 CleanupStack::PopAndDestroy();
514 @SYMTestCaseID GRAPHICS-RESOURCE-0008
515 @SYMTestCaseDesc Retrieves drawable id and drawable type of an image.
517 @SYMFssID RSgImage::Id()
518 RSgImage::DrawableType()
519 @SYMTestPriority Critical
521 @SYMTestPurpose To ensure the globally unique drawable id of the image can be retrieved.
522 @SYMTestActions Initialise the graphics resource component. Create an image. Call
523 Id() to retrieve its drawable id.
524 @SYMTestExpectedResults A valid drawable id should be successfully returned when the image has been opened.
525 KSgNullDrawableId should be returned if it has not; the default drawable type should
528 void CTSgImageGeneric::TestGetImageDrawableIdL()
531 TEST(KNullUid == image.DrawableType());
532 TSgDrawableId id = image.Id();
533 TEST(id == KSgNullDrawableId);
538 TEST(id != KSgNullDrawableId);
539 TEST(KSgImageTypeUid == image.DrawableType());
546 @SYMTestCaseID GRAPHICS-RESOURCE-0010
547 @SYMTestCaseDesc Opens a handle to an image in both the current process and another process.
549 @SYMFssID RSgImage::Open(const TSgDrawableId&)
550 @SYMTestPriority Critical
552 @SYMTestPurpose To ensure image can be opened in both a second thread in the current
553 process and another process.
554 @SYMTestActions Initialise the graphics resource component. Create an image and call
555 Open() on the image in the second thread in the current process and in
556 another process. To ensure they are correct compare their Id and attributes.
557 @SYMTestExpectedResults The function must return KErrNone in all cases.
559 void CTSgImageGeneric::TestOpenImageL()
565 info1.iSizeInPixels = TSize(8, 8);
566 info1.iUsage = ESgUsageBitOpenVgImage;
567 info1.iPixelFormat = EUidPixelFormatRGB_565;
568 CheckErrorL(KErrNone, image1.Create(info1, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
570 const TSgDrawableId id1 = image1.Id();
572 //opening image in the current thread
574 TEST(KErrNone == image2.Open(id1));
575 TEST(image1.Id() == image2.Id());
577 TSgImageInfo getInfo1;
578 TSgImageInfo getInfo2;
580 image1.GetInfo(getInfo1);
581 image2.GetInfo(getInfo2);
583 TEST(CompareInfos(info1, getInfo1));
584 TEST(getInfo1.iPixelFormat == getInfo2.iPixelFormat
585 && getInfo1.iSizeInPixels == getInfo2.iSizeInPixels
586 && getInfo1.iUsage == getInfo2.iUsage);
588 if (iEnableConformanceTests)
590 //opening image in a second thread in the current process
591 TSgThreadTestInfo threadInfo(id1, info1, ESgresSecondThreadOpenImage);
593 TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo));
594 TEST(err == KErrNone);
595 TEST(testResult >= 0);
597 // Test the results from the second thread
598 TEST(testResult & EFirstTestPassed);
599 TEST(testResult & ESecondTestPassed);
600 TEST(testResult & EThirdTestPassed);
601 TEST(testResult & EFourthTestPassed);
602 TEST(testResult & EFifthTestPassed);
603 TEST(testResult & ESixthTestPassed);
604 TEST(testResult & ESeventhTestPassed);
605 TEST(testResult & EEighthTestPassed);
607 //opening image in a second process
608 TSgProcessTestInfo processInfo(id1, getInfo1, ESgresSecondProcessOpenImage);
609 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
610 TEST(err == KErrNone);
611 TEST(testResult >= 0);
613 TEST(testResult & EFirstTestPassed);
614 TEST(testResult & ESecondTestPassed);
615 TEST(testResult & EThirdTestPassed);
616 TEST(testResult & EFourthTestPassed);
617 TEST(testResult & EFifthTestPassed);
618 TEST(testResult & ESixthTestPassed);
619 TEST(testResult & ESeventhTestPassed);
629 Fake RSgImage extension interface used in negative RSgImage::GetInterface() Tests
634 enum { EInterfaceUid = 0x88888888 };
640 enum { EInterfaceUid = KNullUidValue};
644 @SYMTestCaseID GRAPHICS-RESOURCE-0044
645 @SYMTestCaseDesc Gets an invalid/unsupported image extension interface
647 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
648 RSgImage::GetInterface()
651 @SYMTestPurpose Negative test to ensure the correct error code is returned when attempting
652 to retrieve an invalid RSgImage extension interface.
653 @SYMTestActions Initialise the graphics resource component. Create an image.
654 1. Declare an unsupported interface MFake and pass to GetInterface().
655 2. Declare an interface MFakeNullUid which has a null uid and pass to GetInterface().
656 @SYMTestExpectedResults 1. GetInterface() should return KErrExtensionNotSupported.
657 2. GetInterface() should return KErrArgument since null uids are not acceptable.
659 void CTSgImageGeneric::TestGetInterfaceL()
664 info.iSizeInPixels = TSize(8, 8);
665 info.iUsage = ESgUsageBitOpenVgImage;
666 info.iPixelFormat = EUidPixelFormatRGB_565;
671 MFake* smFake = reinterpret_cast<MFake*>(1);
672 MFake* smFake2 = reinterpret_cast<MFake*>(1);
674 //Check Calls to Get Interface on Null Image Handle
675 TEST(KErrBadHandle == image.GetInterface(smFake));
676 TEST(KErrBadHandle == image.GetInterface(smFake2));
680 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
682 // check TSgDrawableId is not NULL
683 TSgDrawableId id = image.Id();
684 TEST(KSgNullDrawableId != id);
686 smFake = reinterpret_cast<MFake*>(1);
687 smFake2 = reinterpret_cast<MFake*>(1);
689 TEST(KErrExtensionNotSupported == image.GetInterface(smFake));
692 TEST(KErrExtensionNotSupported == image.GetInterface(smFake2));
695 // null interface uid
696 MFakeNullUid* smFake3 = NULL;
697 TEST(KErrArgument == image.GetInterface(smFake3));
706 @SYMTestCaseID GRAPHICS-RESOURCE-0024
707 @SYMTestCaseDesc Gets supported pixel formats with invalid parameters.
709 @SYMFssID RSgImage::GetPixelFormats(TUint32, RArray<TInt>,
710 const TSgAttributeArrayBase*)
713 @SYMTestPurpose Negative test to ensure the correct error messages are returned when user tries to
714 call GetPixelFormats() with invalid parameters.
715 @SYMTestActions Initialise the graphics resource component. Call RSgImage::GetPixelFormats with:
717 2. Invalid attribute array
719 4. Pixel formats array is not empty
720 @SYMTestExpectedResults RSgImage::GetPixelFormats() should return:
726 void CTSgImageGeneric::TestGetPixelFormatsInvalidL()
728 RArray<TInt> pixelFormats;
729 CleanupClosePushL(pixelFormats);
730 TSgAttributeArray<1> attribArray;
731 attribArray[0].iUid = KNullUid;
732 attribArray[0].iValue = 0;
733 TEST(attribArray.Count() == 1);
737 TEST(KErrArgument == RSgImage::GetPixelFormats(0, pixelFormats));
738 pixelFormats.Reset();
740 TEST(KErrNotSupported == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats, &attribArray));
741 pixelFormats.Reset();
743 TEST(KErrNone == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats));
744 TEST(pixelFormats.Count() > 0);
745 //Don't reset pixel formats for next test
747 TEST(KErrArgument == RSgImage::GetPixelFormats(ESgUsageBitOpenVgImage, pixelFormats));
748 pixelFormats.Reset();
751 CleanupStack::PopAndDestroy(&pixelFormats);
755 @SYMTestCaseID GRAPHICS-RESOURCE-0025
756 @SYMTestCaseDesc Opens an image with different invalid and valid parameters.
758 @SYMFssID RSgImage::Open(const TSgDrawableId&)
759 @SYMTestPriority Medium
761 @SYMTestPurpose Negative test to check correct error messages are returned when opening
762 image with different invalid parameters.
763 @SYMTestActions Initialise the graphics resource component. Construct an RSgImage object.
764 Call the Open() function in both the current process and another process with:
765 1. a non-null RSgImage handle
768 4. a valid RSgImage handle
769 Do the same tests in a second thread and a second process.
770 @SYMTestExpectedResults The function should return:
776 void CTSgImageGeneric::TestOpenImageInvalidL()
779 //create a non-sharable image
781 info.iSizeInPixels = TSize(8, 8);
782 info.iUsage = ESgUsageBitOpenVgImage;
783 info.iPixelFormat = EUidPixelFormatRGB_565;
786 CheckErrorL(KErrNone, image.Create(info, KCrossImageData, KCrossImageDataStride), (TText8*)__FILE__, __LINE__);
787 CleanupClosePushL(image);
788 const TSgDrawableId id = image.Id();
790 //Attempt to create the image again using the same object
791 TEST(KErrInUse == image.Create(info, KCrossImageData, KCrossImageDataStride));
796 CreateImageL(image1);
797 CleanupClosePushL(image1);
798 TEST(KErrInUse == image1.Open(id));
801 // non-existing drawable id
802 TSgDrawableId fakeid = {0xFFFFFFFFFFFFFFFFU};
803 CheckErrorL(KErrNotFound, image1.Open(fakeid), (TText8*)__FILE__, __LINE__);
806 if (iEnableConformanceTests)
808 //different thread in the same process
809 TSgThreadTestInfo threadInfo(id, info, ESgresSecondThreadOpenImageInvalid);
811 TRAPD(err, testResult = CreateSecondThreadAndDoTestL(threadInfo));
812 TEST(testResult >= 0);
813 // Test the results from the second thread
814 TEST(testResult & EFirstTestPassed);
815 TEST(testResult & ESecondTestPassed);
816 TEST(testResult & EThirdTestPassed);
817 TEST(testResult & EFourthTestPassed);
818 TEST(testResult & EFifthTestPassed);
821 TSgProcessTestInfo processInfo(id, info, ESgresSecondProcessOpenImageInvalid);
822 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
823 TEST(testResult >= 0);
824 TEST(testResult & EFirstTestPassed);
825 TEST(testResult & ESecondTestPassed);
826 TEST(testResult & EThirdTestPassed);
827 TEST(testResult & EFourthTestPassed);
828 TEST(testResult & EFifthTestPassed);
831 CleanupStack::PopAndDestroy(2);
836 @SYMTestCaseID GRAPHICS-RESOURCE-0026
837 @SYMTestCaseDesc Closes an image multiple times.
839 @SYMFssID RSgImage::Close()
840 @SYMTestPriority High
842 @SYMTestPurpose To check calling Close() multiple times after Open() does not cause
844 @SYMTestActions Initialise the graphics resource component. Create an image and then
845 call Close() three times on it.
846 @SYMTestExpectedResults The function should not cause any errors or panics.
848 void CTSgImageGeneric::TestCloseImageManyTimesL()
853 TEST(!image.IsNull());
856 TEST(image.IsNull());
858 TEST(image.IsNull());
860 TEST(image.IsNull());
867 @SYMTestCaseID GRAPHICS-RESOURCE-0027
868 @SYMTestCaseDesc Closes an image object without opening it.
870 @SYMFssID RSgImage::Close()
871 @SYMTestPriority Medium
873 @SYMTestPurpose To check Close() does nothing if the image is not already opened.
874 @SYMTestActions Initialise the graphics resource component. Declare an RSgImage object and
876 @SYMTestExpectedResults The function should not cause any errors or panics.
878 void CTSgImageGeneric::TestCloseImageWithoutOpenL()
882 TEST(image.IsNull());
884 TEST(image.IsNull());
889 @SYMTestCaseID GRAPHICS-RESOURCE-0028
890 @SYMTestCaseDesc Creates an image with various invalid parameters.
892 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt, const TSgAttributeArrayBase* = NULL)
893 RSgImage::Create(const TSgImageInfo&, const RSgImage&, const TSgAttributeArrayBase* = NULL)
894 @SYMTestPriority Medium
896 @SYMTestPurpose Negative test to check the function returns the correct error messages when
897 the parameters are invalid.
898 @SYMTestActions Initialise the graphics resource component. Construct a TSgImageInfo object
899 and initialise the all the member variables with random values. Call the appropriate
900 Create() function with:
901 1. invalid TSgImageInfo.iSizeInPixels
902 2. unsupported TSgImageInfo Pixel Format
903 3. the creating RSgImage handle is not null
904 4. the aSgImage handle is null
905 5. the size and pixel format in TSgImageInfo is not the same as that of aSgImage
906 6. the pixel stride specified is 0 when bitmap data is given
907 @SYMTestExpectedResults The function should return
908 1. KErrArgument or KErrNotSupported for the overload taking an RSgImage
915 void CTSgImageGeneric::TestCreateImageInvalidL()
921 TSgImageInfo validInfo(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
922 TEST(KErrNone == validImage.Create(validInfo, KCrossImageData, KCrossImageDataStride));
924 //invalid info 1 - invalid width
925 TSgImageInfo info1(TSize(-100,100), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
926 TEST(KErrArgument == image.Create(info1, NULL, 0));
928 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride));
931 info1.iSizeInPixels = TSize(100, -100);
932 TEST(KErrArgument == image.Create(info1, NULL, 0));
935 TEST(KErrNotSupported == image.Create(info1, validImage));
938 info1.iSizeInPixels = TSize(0,0);
939 TEST(KErrArgument == image.Create(info1, NULL, 0));
941 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride));
944 TEST(KErrNotSupported == image.Create(info1, validImage));
948 info1.iUsage = KMaxTUint32;
949 info1.iSizeInPixels = TSize(8,8);
950 TEST(KErrNotSupported == image.Create(info1, KCrossImageData, KCrossImageDataStride));
952 TEST(KErrNotSupported == image.Create(info1, validImage));
955 //unsupported info 1 - invalid pixel format
957 info2.iSizeInPixels = TSize(8, 8);
958 info2.iUsage = ESgUsageBitOpenVgImage;
959 info2.iPixelFormat = EUidPixelFormatUnknown;
960 TEST(KErrArgument == image.Create(info2, NULL, 0));
962 TEST(KErrArgument == image.Create(info2, KCrossImageData, KCrossImageDataStride));
965 //unsupported info 2 - large image size
966 info2.iPixelFormat = ESgPixelFormatRGB_565;
967 info2.iSizeInPixels = TSize(40000, 100);
968 TEST(KErrTooBig == image.Create(info2, NULL, 0));
969 info2.iSizeInPixels = TSize(100, 40000);
970 TEST(KErrTooBig == image.Create(info2, NULL, 0));
976 info3.iSizeInPixels = TSize(8, 8);
977 info3.iUsage = ESgUsageBitOpenVgImage;
978 info3.iPixelFormat = ESgPixelFormatRGB_565;
980 TInt ret = image.Create(info3, NULL, 16);
981 TEST(KErrInUse == ret);
983 //non-null handle: create from an existing image
985 CreateImageL(image1);
986 TEST(KErrInUse == image1.Create(info3, image));
989 //null existing image handle
991 TEST(image2.IsNull());
992 TEST(KErrArgument == image1.Create(info3, image2));
994 //the size and pixel format in TSgImageInfo is not the same as that of aSgImage
995 TSgImageInfo info4(TSize(100,100), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
996 TEST(KErrNotSupported == image1.Create(info4, image));
998 image1.GetInfo(info3);
999 info4.iSizeInPixels = info3.iSizeInPixels;
1000 info4.iPixelFormat = ESgPixelFormatXRGB_8888;
1001 TEST(KErrNotSupported == image1.Create(info4, image));
1006 TSgImageInfo info5(TSize(8,8), ESgPixelFormatRGB_565, ESgUsageBitOpenVgImage);
1008 TSgAttributeArray<1> attribArray;
1009 attribArray[0].iUid = KNullUid;
1010 attribArray[0].iValue = 0;
1012 TEST(KErrNotSupported == image1.Create(info5, KCrossImageData, KCrossImageDataStride, &attribArray));
1016 TEST(KErrArgument == image1.Create(info5, KCrossImageData, 0));
1025 @SYMTestCaseID GRAPHICS-RESOURCE-0039
1026 @SYMTestCaseDesc Calls GetInfo() on an invalid image.
1028 @SYMFssID RSgImage::GetInfo(TSgImageInfo&)
1029 @SYMTestPriority Low
1031 @SYMTestPurpose Negative test to check the correct error is returned when the client
1032 tries to get information on an invalid image.
1033 @SYMTestActions Initialise the graphics resource component.
1034 Call GetInfo() on an image that is not initialised.
1035 @SYMTestExpectedResults GetInfo() should return KErrBadHandle
1037 void CTSgImageGeneric::TestGetInfoImageInvalidL()
1041 TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
1043 //uninitialised image
1044 TEST(KErrBadHandle == image.GetInfo(info));
1050 @SYMTestCaseID GRAPHICS-RESOURCE-0092
1051 @SYMTestCaseDesc Calls GetAttribute() on an invalid image.
1053 @SYMFssID RSgImage::GetAttribute(TUid, TInt&)
1054 @SYMTestPriority Low
1056 @SYMTestPurpose Negative test to check the correct error is returned when the client
1057 tries to get attributes on an invalid image.
1058 @SYMTestActions Initialise the graphics resource component.
1059 Call GetInfo on an image that is not initialised.
1060 @SYMTestExpectedResults GetAttribute() should return KErrBadHandle
1062 void CTSgImageGeneric::TestGetAttributesImageInvalidL()
1066 TSgImageInfo info(TSize(5,5), ESgPixelFormatARGB_8888, ESgUsageBitOpenVgImage);
1068 TUid uid = {0x12345678};
1070 TEST(KErrBadHandle == image.GetAttribute(uid, val));
1078 @SYMTestCaseID GRAPHICS-RESOURCE-0100
1079 @SYMTestCaseDesc Creates images using negative and invalid data strides.
1081 @SYMFssID RSgImage::Create(TUid, TInt&)
1082 @SYMTestPriority Medium
1084 @SYMTestPurpose Positive test for using negative data strides.
1085 Negative test for using invalid data strides.
1086 @SYMTestActions Initialise the graphics resource component.
1087 1. Create an image with a data stride that is smaller than the width
1089 2. Create an image with a pointer to bitmap data, but 0 data stride.
1090 3. Create an image with a negative data stride equal to the width
1092 4. Create an image with a negative data stride less than the width
1094 @SYMTestExpectedResults 1. Create() should return KErrArgument.
1095 2. Create() should return KErrArgument.
1096 3. Create() should successfully create the image and return KErrNone.
1097 4. Create() should return KErrArgument.
1099 void CTSgImageGeneric::TestCreateImageDataStrideL()
1104 TSgImageInfo info1(TSize(8,8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage);
1106 TEST(KErrArgument == image.Create(info1, KCrossImageData, KCrossImageDataStride-1));
1108 TEST(KErrArgument == image.Create(info1, KCrossImageData, 0));
1111 TEST(KErrNone == image.Create(info1, KCrossImageData, -KCrossImageDataStride));
1114 TEST(KErrArgument == image.Create(info1, KCrossImageData, -KCrossImageDataStride+1));
1121 @SYMTestCaseID GRAPHICS-RESOURCE-0048
1122 @SYMTestCaseDesc RSgImage stress tests
1124 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
1126 @SYMTestPriority Medium
1128 @SYMTestPurpose To ensure creating and destroying RSgImage multiple times work well.
1129 @SYMTestActions Create images 1000 times but only store KMaxImagesInArray of them
1130 at one time in an RArray. When a new image is to be added to the
1131 array, a random image from the array is removed.
1132 @SYMTestExpectedResults There should be no panics or leaves.
1134 void CTSgImageGeneric::TestStress1L()
1138 info.iPixelFormat = EUidPixelFormatRGB_565;
1139 info.iSizeInPixels = TSize(100, 100);
1140 info.iUsage = ESgUsageBitOpenVgImage;
1142 TInt KMaxImagesInArray =40;
1144 for (TInt count = 1000; count > 0; --count)
1147 CheckErrorL(KErrNone, image.Create(info, NULL, 0), (TText8*)__FILE__, __LINE__);
1148 CleanupClosePushL(image);
1149 iTestImages.AppendL(image);
1150 CleanupStack::Pop();
1151 if (iTestImages.Count() >= KMaxImagesInArray)
1153 TInt i = Math::Rand(seed) % KMaxImagesInArray;
1154 iTestImages[i].Close();
1155 iTestImages.Remove(i);
1158 TInt count = iTestImages.Count();
1159 for(TInt i=0; i<count; ++i)
1161 iTestImages[i].Close();
1163 iTestImages.Reset();
1168 @SYMTestCaseID GRAPHICS-RESOURCE-0049
1169 @SYMTestCaseDesc RSgImage multiple threads open and close stress tests
1171 @SYMFssID RSgImage::Open(const TSgDrawableId&)
1173 @SYMTestPriority Medium
1175 @SYMTestPurpose To ensure opening and destroying RSgImage multiple times and randomly
1176 in other threads work well.
1177 @SYMTestActions Create an image in the main thread. In a loop of 1000 times, randomly select
1178 one of the five threads and either open or close the image depending on the
1179 state of the thread.
1180 @SYMTestExpectedResults There should be no panics or leaves.
1182 void CTSgImageGeneric::TestStress2L()
1186 CreateImageL(image);
1187 CleanupClosePushL(image);
1188 const TSgDrawableId id = image.Id();
1191 TEST(KErrNone == image.GetInfo(info));
1192 TSgThreadTestInfo threadInfo(id, info, ESgresMultipleThreadStressTest);
1194 //create a semaphore
1196 User::LeaveIfError(sem.CreateGlobal(KSecondThreadSemaphore, 0, EOwnerThread));
1197 CleanupClosePushL(sem);
1200 const TInt KNoOfThreads = 5;
1201 RArray<RThread> threads;
1202 _LIT(KMultipleThreadName, "Multiple Threads Stress Test Thread ");
1203 for (TInt i = 0; i < KNoOfThreads; ++i)
1205 TBuf<50> threadName(KMultipleThreadName);
1206 threadName.AppendNum(i);
1208 User::LeaveIfError(thread.Create(threadName, SgTestSecondThread::ThreadStart, KDefaultStackSize, KSecondThreadMinHeapSize, KSecondThreadMaxHeapSize, &threadInfo));
1209 thread.SetPriority(EPriorityLess);
1210 threads.AppendL(thread);
1213 for (TInt i = 0; i < KNoOfThreads; ++i)
1215 threads[i].Resume();
1217 // wait for the threads to terminate processing
1218 for (TInt i = 0; i < KNoOfThreads; ++i)
1222 for (TInt i = 0; i < KNoOfThreads; ++i)
1226 CleanupStack::PopAndDestroy(2, &image); // image, sem
1231 @SYMTestCaseID GRAPHICS-RESOURCE-0051
1232 @SYMTestCaseDesc Calls RSgImage::GetInterface() with an invalid image handle
1234 @SYMFssID RSgImage::GetInterface(TUid, TAny*&)
1235 @SYMTestPriority Low
1237 @SYMTestPurpose Negative test to ensure calling GetInterface() with an invalid image handle
1239 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1240 Declare another image and assign it to the current image handle. Close the current
1241 image so the second image handle becomes invalid. Call GetInterface() on the
1243 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1245 void CTSgImageGeneric::TestPanicImageGetInterfaceInvalidHandleL()
1247 TSgImageInfo info(TSize(),0,0);
1248 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceInvalidHandle);
1249 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1250 _LIT(KTestName, "TestImageGetInterfaceInvalidHandleLThread");
1251 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1255 @SYMTestCaseID GRAPHICS-RESOURCE-0052
1256 @SYMTestCaseDesc Calls RSgImage::GetInterface() with a non-null handle and an uninitialised driver
1258 @SYMFssID RSgImage::GetInterface(TUid, TAny*&)
1259 @SYMTestPriority Low
1261 @SYMTestPurpose Negative test to ensure calling GetInterface() with a non-null handle and an
1262 uninitialised driver will cause a panic.
1263 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1264 Declare another image and assign it to the current image handle. Close the current
1265 image so the second image handle becomes invalid. Close the graphics resource driver.
1266 Call GetInterface() on the second handle.
1267 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1269 void CTSgImageGeneric::TestPanicImageGetInterfaceNoDriverL()
1271 TSgImageInfo info(TSize(),0,0);
1272 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInterfaceNoDriver);
1273 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1274 _LIT(KTestName, "TestImageGetInterfaceNoDriverL");
1275 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1279 @SYMTestCaseID GRAPHICS-RESOURCE-0053
1280 @SYMTestCaseDesc Calls RSgImage::Close() with an invalid image handle
1282 @SYMFssID RSgImage::Close()
1283 @SYMTestPriority Low
1285 @SYMTestPurpose Negative test to ensure calling Close() with an invalid image handle will
1287 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1288 Declare another image and assign it to the current image handle. Close the current
1289 image so the second image handle becomes invalid. Call Close() on the second handle.
1290 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1292 void CTSgImageGeneric::TestPanicImageCloseInvalidHandleL()
1294 TSgImageInfo info(TSize(),0,0);
1295 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseInvalidHandle);
1296 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1297 _LIT(KTestName, "TestImageCloseInvalidHandleL");
1298 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1302 @SYMTestCaseID GRAPHICS-RESOURCE-0054
1303 @SYMTestCaseDesc Calls RSgImage::Close() with a non-null handle and an uninitialised driver
1305 @SYMFssID RSgImage::Close()
1306 @SYMTestPriority Low
1308 @SYMTestPurpose Negative test to ensure calling Close() with a non-null handle and an
1309 uninitialised driver will cause a panic.
1310 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1311 Declare another image and assign it to the current image handle. Close the current
1312 image so the second image handle becomes invalid. Close the graphics resource driver.
1313 Call Close() on the second handle.
1314 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1316 void CTSgImageGeneric::TestPanicImageCloseNoDriverL()
1318 TSgImageInfo info(TSize(),0,0);
1319 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCloseNoDriver);
1320 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1321 _LIT(KTestName, "TestImageCloseNoDriverL");
1322 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1326 @SYMTestCaseID GRAPHICS-RESOURCE-0055
1327 @SYMTestCaseDesc Calls RSgImage::Id() with an invalid image handle
1329 @SYMFssID RSgImage::Id()
1330 @SYMTestPriority Low
1332 @SYMTestPurpose Negative test to ensure calling Id() with an invalid image handle will
1334 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1335 Declare another image and assign it to the current image handle. Close the current
1336 image so the second image handle becomes invalid. Call Id() on the second
1338 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1340 void CTSgImageGeneric::TestPanicImageIdInvalidHandleL()
1342 TSgImageInfo info(TSize(),0,0);
1343 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdInvalidHandle);
1344 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1345 _LIT(KTestName, "TestImageIdInvalidHandleL");
1346 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1350 @SYMTestCaseID GRAPHICS-RESOURCE-0056
1351 @SYMTestCaseDesc Calls RSgImage::Id() with a non-null handle and an uninitialised driver
1353 @SYMFssID RSgImage::Id()
1354 @SYMTestPriority Low
1356 @SYMTestPurpose Negative test to ensure calling Id() with a non-null handle and an
1357 uninitialised driver will cause a panic.
1358 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1359 Declare another image and assign it to the current image handle. Close the current
1360 image so the second image handle becomes invalid. Close the graphics resource driver.
1361 Call Id() on the second handle.
1362 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1364 void CTSgImageGeneric::TestPanicImageIdNoDriverL()
1366 TSgImageInfo info(TSize(),0,0);
1367 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageIdNoDriver);
1368 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1369 _LIT(KTestName, "TestImageIdNoDriverL");
1370 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1374 @SYMTestCaseID GRAPHICS-RESOURCE-0057
1375 @SYMTestCaseDesc Calls RSgImage::Create() with an invalid image handle
1377 @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&)
1378 @SYMTestPriority Low
1380 @SYMTestPurpose Negative test to ensure calling Create() with an invalid image handle will
1382 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1383 Declare another image and assign it to the current image handle. Close the current
1384 image so the second image handle becomes invalid. Call Create() on the second
1386 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1388 void CTSgImageGeneric::TestPanicImageCreateInvalidHandleL()
1390 TSgImageInfo info(TSize(),0,0);
1391 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateInvalidHandle);
1392 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1393 _LIT(KTestName, "TestImageCreateInvalidHandleL");
1394 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1398 @SYMTestCaseID GRAPHICS-RESOURCE-0058
1399 @SYMTestCaseDesc Calls RSgImage::GetInfo() with an invalid image handle
1401 @SYMFssID RSgImage::GetInfo(TSgImageInfo&)
1402 @SYMTestPriority Low
1404 @SYMTestPurpose Negative test to ensure calling GetInfo() with an invalid image handle will
1406 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1407 Declare another image and assign it to the current image handle. Close the current
1408 image so the second image handle becomes invalid. Call GetInfo() on the second
1410 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3(ESgPanicBadDrawableHandle).
1412 void CTSgImageGeneric::TestPanicImageGetInfoInvalidHandleL()
1414 TSgImageInfo info(TSize(),0,0);
1415 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoInvalidHandle);
1416 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1417 _LIT(KTestName, "TestImageGetInfoInvalidHandleL");
1418 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1422 @SYMTestCaseID GRAPHICS-RESOURCE-0059
1423 @SYMTestCaseDesc Calls RSgImage::GetInfo() with a non-null handle and an uninitialised driver
1425 @SYMFssID SgImage::GetInfo(TSgImageInfo&)
1426 @SYMTestPriority Low
1428 @SYMTestPurpose Negative test to ensure calling GetInfo() with a non-null handle and an
1429 uninitialised driver will cause a panic.
1430 @SYMTestActions Initialise the graphics resource component and create an image in a second thread.
1431 Declare another image and assign it to the current image handle. Close the current
1432 image so the second image handle becomes invalid. Close the graphics resource driver.
1433 Call GetInfo() on the second handle.
1434 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1436 void CTSgImageGeneric::TestPanicImageGetInfoNoDriverL()
1438 TSgImageInfo info(TSize(),0,0);
1439 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetInfoNoDriver);
1440 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1441 _LIT(KTestName, "TestImageGetInfoNoDriverL");
1442 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1446 @SYMTestCaseID GRAPHICS-RESOURCE-0082
1447 @SYMTestCaseDesc Calls RSgImage::Open() when the driver was not initialised.
1449 @SYMFssID RSgImage::Open(const TSgDrawableId&, TUint32)
1450 @SYMTestPriority Low
1452 @SYMTestPurpose Negative test to ensure calling RSgImage::Open() with an uninitialised driver
1454 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open()
1456 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1458 void CTSgImageGeneric::TestPanicImageOpenNoDriverL()
1460 TSgImageInfo info(TSize(),0,0);
1461 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageOpenNoDriver);
1462 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1463 _LIT(KTestName, "TestPanicImageOpenNoDriverL");
1464 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1468 @SYMTestCaseID GRAPHICS-RESOURCE-0083
1469 @SYMTestCaseDesc Creates an image from memory when the driver was not initialised.
1471 @SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
1472 @SYMTestPriority Low
1474 @SYMTestPurpose Negative test to ensure calling RSgImage::Create() with an uninitialised
1475 driver will cause a panic.
1476 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open()
1478 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1480 void CTSgImageGeneric::TestPanicImageCreateNoDriver1L()
1482 TSgImageInfo info(TSize(),0,0);
1483 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver1);
1484 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1485 _LIT(KTestName, "TestPanicImageCreateNoDriver1L");
1486 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1490 @SYMTestCaseID GRAPHICS-RESOURCE-0084
1491 @SYMTestCaseDesc Creates an image from an existing image when the driver was not initialised.
1493 @SYMFssID RSgImage::Create(const TSgImageInfo&, const RSgImage&)
1494 @SYMTestPriority Low
1496 @SYMTestPurpose Negative test to ensure calling RSgImage::Create() with an uninitialised driver
1498 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::Open() in
1500 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1502 void CTSgImageGeneric::TestPanicImageCreateNoDriver2L()
1504 TSgImageInfo info(TSize(),0,0);
1505 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageCreateNoDriver2);
1506 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1507 _LIT(KTestName, "TestPanicImageCreateNoDriver2L");
1508 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1512 @SYMTestCaseID GRAPHICS-RESOURCE-0088
1513 @SYMTestCaseDesc Calls RSgImage::DrawableType() when the driver was not initialised.
1515 @SYMFssID RSgImage::DrawableType()
1516 @SYMTestPriority Low
1518 @SYMTestPurpose Negative test to ensure calling RSgImage::DrawableType() with an uninitialised
1519 driver will cause a panic.
1520 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::DrawableType()
1522 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1524 void CTSgImageGeneric::TestPanicImageDrawableTypeNoDriverL()
1526 TSgImageInfo info(TSize(),0,0);
1527 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeNoDriver);
1528 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1529 _LIT(KTestName, "TestPanicImageOpenNoDriverL");
1530 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1534 @SYMTestCaseID GRAPHICS-RESOURCE-0089
1535 @SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle
1537 @SYMFssID RSgImage::DrawableType()
1538 @SYMTestPriority Low
1540 @SYMTestPurpose Negative test to ensure calling RSgImage::DrawableType() with an uninitialised
1541 driver will cause a panic.
1542 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::DrawableType()
1544 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle).
1546 void CTSgImageGeneric::TestPanicImageDrawableTypeInvalidHandleL()
1548 TSgImageInfo info(TSize(),0,0);
1549 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageDrawableTypeInvalidHandle);
1550 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1551 _LIT(KTestName, "TestPanicImageOpenNoDriverL");
1552 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1556 @SYMTestCaseID GRAPHICS-RESOURCE-0090
1557 @SYMTestCaseDesc Calls RSgImage::DrawableType() with an invalid image handle
1559 @SYMFssID RSgImage::GetAttribute()
1560 @SYMTestPriority Low
1562 @SYMTestPurpose Negative test to ensure calling RSgImage::GetAttribute() with an invalid handle
1564 @SYMTestActions Initialise the graphics resource component and call RSgImage::GetAttribute()
1565 in a second thread with an invalid handle.
1566 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 3 (ESgPanicBadDrawableHandle).
1568 void CTSgImageGeneric::TestPanicImageGetAttributeInvalidHandleL()
1570 TSgImageInfo info(TSize(),0,0);
1571 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeInvalidHandle);
1572 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1573 _LIT(KTestName, "TestPanicImageGetAttributeInvalidHandleL");
1574 CreateSecondThreadAndCheckPanicL(threadInfo, 3, exitCategoryName, KTestName);
1578 @SYMTestCaseID GRAPHICS-RESOURCE-0091
1579 @SYMTestCaseDesc Calls RSgImage::GetAttribute() with no open driver
1581 @SYMFssID RSgImage::GetAttribute()
1582 @SYMTestPriority Low
1584 @SYMTestPurpose Negative test to ensure calling RSgImage::GetAttribute() with an uninitialised
1585 driver will cause a panic.
1586 @SYMTestActions Do not initialise the graphics resource component and call RSgImage::GetAttribute()
1588 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 1 (ESgPanicNoDriver).
1590 void CTSgImageGeneric::TestPanicImageGetAttributeNoDriverL()
1592 TSgImageInfo info(TSize(),0,0);
1593 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicImageGetAttributeNoDriver);
1594 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1595 _LIT(KTestName, "TestPanicImageGetAttributeNoDriverL");
1596 CreateSecondThreadAndCheckPanicL(threadInfo, 1, exitCategoryName, KTestName);
1600 @SYMTestCaseID GRAPHICS-RESOURCE-0097
1601 @SYMTestCaseDesc Access out of bound TSgAttibuteArray index
1603 @SYMFssID TSgAttributeArray
1604 @SYMTestPriority Low
1606 @SYMTestPurpose Negative test to ensure calling an out of bound index on a TSgAttributeArray
1608 @SYMTestActions Create a TSgAttributeArray of size 5 and attempt to access an element higher
1610 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex).
1612 void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndexL()
1614 TSgImageInfo info(TSize(),0,0);
1615 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex);
1616 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1617 _LIT(KTestName, "AttributeArrayInvalidIndexL");
1618 CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName);
1622 @SYMTestCaseID GRAPHICS-RESOURCE-0098
1623 @SYMTestCaseDesc Access out of bound TSgAttibuteArray index
1625 @SYMFssID TSgAttributeArray
1626 @SYMTestPriority Low
1628 @SYMTestPurpose Negative test to ensure calling an out of bound index on a TSgAttributeArray
1630 @SYMTestActions Create a TSgAttributeArray of size 5 and attempt to access an element higher
1632 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 4 (ESgPanicBadAttributeArrayIndex).
1634 void CTSgImageGeneric::TestPanicImageAttributeArrayInvalidIndex2L()
1636 TSgImageInfo info(TSize(),0,0);
1637 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadPanicAttributeArrayInvalidIndex2);
1638 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1639 _LIT(KTestName, "AttributeArrayInvalidIndexL");
1640 CreateSecondThreadAndCheckPanicL(threadInfo, 4, exitCategoryName, KTestName);
1644 @SYMTestCaseID GRAPHICS-RESOURCE-0101
1645 @SYMTestCaseDesc Close an RSgDriver with open resources
1648 @SYMTestPriority Low
1650 @SYMTestPurpose Negative test to ensure closing a driver with open resources will cause a panic.
1651 @SYMTestActions Create an RSgImage on an open driver, then close the driver.
1652 @SYMTestExpectedResults Should panic in the second thread with panic code SGRES 2 (ESgPanicUnclosedResources).
1654 void CTSgImageGeneric::TestPanicDriverCloseOpenResourcesL()
1656 TSgImageInfo info(TSize(),0,0);
1657 TSgProcessTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondProcessPanicDriverCloseOpenResources);
1658 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
1659 CreateSecondProcessAndCheckPanicL(threadInfo, 2, exitCategoryName, KSecondProcess);
1663 @SYMTestCaseID GRAPHICS-RESOURCE-0102
1664 @SYMTestCaseDesc Open/Close RSgDriver and Create/Close RSgImage in separate threads
1666 @SYMFssID RSgDriver, RSgImage
1667 @SYMTestPriority High
1669 @SYMTestPurpose To ensure that it is possible to Open/Close the RSgDriver from
1670 a separate thread, and to ensure that it is possible to Create/Open/Close
1671 RSgImages from a seperate thread.
1672 @SYMTestActions 1. Declare a RSgDriver, and pass to another thread to open.
1673 2. Declare a RSgImage, and pass to another thread to create.
1674 3. Pass created RSgImage to another thread to Open().
1675 4. Pass the image to another thread to Close().
1676 5. Pass the RSgDriver to another thread to Close()
1677 @SYMTestExpectedResults All steps to succeed with no errors reported.
1679 void CTSgImageGeneric::TestCreateOpenCloseImageAndDriverInSecondThreadL()
1681 TSgImageInfo info(TSize(),0,0);
1682 TSgThreadTestInfo threadInfo(KSgNullDrawableId, info, ESgresSecondThreadOpenPassedDriver);
1685 threadInfo.iSgDriver = &driver;
1688 threadInfo.iSgImage = ℑ
1690 //Open the driver in another thread
1691 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1693 //Create the image in a thread
1694 threadInfo.iTestCase = ESgresSecondThreadCreatePassedImage;
1695 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1697 //Now try opening the image in another thread
1699 threadInfo.iTestCase = ESgresSecondThreadOpenPassedImage;
1700 threadInfo.iDrawableId = image.Id();
1701 threadInfo.iSgImage = &image2;
1702 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1704 //Close the "Opened" image in another thread
1705 threadInfo.iTestCase = ESgresSecondThreadClosePassedImage;
1706 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1708 //Close the "Created" image in another thread
1709 threadInfo.iTestCase = ESgresSecondThreadClosePassedImage;
1710 threadInfo.iSgImage = ℑ
1711 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1713 //Close the driver in another thread
1714 threadInfo.iTestCase = ESgresSecondThreadClosePassedDriver;
1715 TEST(CreateSecondThreadAndDoTestL(threadInfo)==0);
1719 @SYMTestCaseID GRAPHICS-RESOURCE-0104
1720 @SYMTestCaseDesc Open a RSgImage using multiple threads.
1721 @SYMDEF ou1cimx1#197357
1723 @SYMTestPriority Low
1725 @SYMTestPurpose To show that images can be opened safely when used with multiple threads in
1727 @SYMTestActions 1. Process A, creates an RSgImage
1728 2. Process B, creates a secondary thread, which creates a handle to the image
1730 3. Process B, primary thread opens a handle to the same image.
1731 4. Process B, secondary thread closes the handle and terminates thread.
1732 5. Process B, primary thread waits for thread cleanup, then attempts to
1733 access the data of the image by creating a copy of it.
1734 @SYMTestExpectedResults All steps to succeed with no errors reported.
1736 void CTSgImageGeneric::TestOpenImageMultithreadedL()
1740 CreateImageL(image);
1741 CleanupClosePushL(image);
1744 TInt err = image.GetInfo(info);
1745 TESTE(err == KErrNone, err);
1747 TSgProcessTestInfo processInfo(image.Id(), info, ESgresSecondProcessOpenImageMultithreaded);
1748 TInt testResult = 0;
1749 TRAP(err, testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo));
1750 TESTE(err == KErrNone, err);
1751 TEST(testResult & EFirstTestPassed);
1752 TEST(testResult & ESecondTestPassed);
1753 TEST(testResult <= (EFirstTestPassed | ESecondTestPassed));
1755 CleanupStack::PopAndDestroy(1); // image